1 ////////////////////////////////////////////////////////////////////////////////
2 //            Copyright (C) 2013-2016 by Bertram (Valyria Tear)
3 //                         All Rights Reserved
4 //
5 // This code is licensed under the GNU GPL version 2. It is free software
6 // and you may modify it and/or redistribute it under the terms of this license.
7 // See https://www.gnu.org/copyleft/gpl.html for details.
8 ////////////////////////////////////////////////////////////////////////////////
9 
10 /** *********************************************************************************
11 *** \file map_minimap.h
12 *** \author Nik N (IkarusDowned) nihonnik@gmail.com
13 *** \brief Header file for mini maps
14 ***
15 *** This file contains the interface for the various supported minimaps in the game.
16 *** This includes the actual minimap image itself, along with any effect paramenters
17 *** that are specified for the map / toggled through game logic
18 *** ********************************************************************************/
19 
20 #ifndef __MAP_MINIMAP_HEADER__
21 #define __MAP_MINIMAP_HEADER__
22 
23 #include "engine/video/image.h"
24 
25 // Forward declerations.
26 namespace vt_gui
27 {
28     class MenuWindow;
29 } // vt_gui
30 
31 namespace vt_map
32 {
33 namespace private_map
34 {
35 
36 class ObjectSupervisor;
37 class VirtualSprite;
38 
39 //! \brief Handles the Collision minimap generation, caching, drawing and updating the minimap
40 class Minimap {
41 public:
42     /** \brief constructor creating the minimap image.
43     *** \param minimap_image_filename filename of a pre-made minimap image.
44     *** If empty, the minimap is generated using the map script collision map.
45     **/
46     Minimap(const std::string& minimap_image_filename = std::string());
47 
~Minimap()48     ~Minimap() {
49         _minimap_image.Clear();
50         _location_marker.Clear();
51     }
52 
53     /** updates the map with effect changes and player location information
54     *** \param camera a VirtualSprite indicating the camera location
55     *** \param the scaled alpha amount from the map
56     **/
57     void Update(VirtualSprite *camera, float map_alpha_scale = 1.0f);
58 
59     /** \brief draws the collision map along with the location cursor
60     *** and any effects we might have taking place on the collision map
61     **/
62     void Draw();
63 
64 private:
65     //! \brief the generated collision map image for this collision map
66     vt_video::StillImage _minimap_image;
67 
68     //! \brief objects for the "window" which will hold the map
69     //! \note we plan to move this to a Controller object, or something similar
70     //! that is a single instance held by the map itself
71     vt_video::StillImage _background;
72 
73     //! \brief the location sprite
74     vt_video::AnimatedImage _location_marker;
75 
76     //! \brief the current map locations
77     vt_common::Position2D _current_position;
78 
79     //! \brief the current box length for this collision map
80     uint32_t _box_x_length;
81     uint32_t _box_y_length;
82 
83     //! \brief map offset information
84     vt_common::Position2D _center_pos;
85     vt_common::Position2D _half_len;
86 
87     //! \brief grid height and width
88     uint32_t _grid_width;
89     uint32_t _grid_height;
90 
91     //! \brief opacities for when the character is under the map location
92     const vt_video::Color* _current_opacity;
93 
94     //! \brief specifies the additive alpha we get from the map class
95     float _map_alpha_scale;
96 
97     //! \brief creates the procedural collision minimap image
98     vt_video::StillImage _CreateProcedurally();
99 
100 #ifdef DEBUG_FEATURES
101     //! \brief Writes a XPM file with the minimap equivalient in it.
102     //! It is used to easily have a base to create nicer minimaps.
103     void _DEV_CreateXPMFromCollisionMap(const std::string& output_file);
104 #endif
105 };
106 
107 } // private_map
108 
109 } // vt_map
110 
111 #endif // __MAP_MINIMAP_HEADER__
112