source: ps/trunk/source/gui/ObjectTypes/CMiniMap.h@ 24141

Last change on this file since 24141 was 24141, checked in by Vladislav Belov, 4 years ago

Adds a LOS mask to Minimap.

Commented By: elexis, Stan

Differential Revision: https://code.wildfiregames.com/D2216

  • Property svn:eol-style set to native
File size: 2.9 KB
Line 
1/* Copyright (C) 2020 Wildfire Games.
2 * This file is part of 0 A.D.
3 *
4 * 0 A.D. is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * 0 A.D. is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef INCLUDED_MINIMAP
19#define INCLUDED_MINIMAP
20
21#include "graphics/ShaderProgramPtr.h"
22#include "gui/ObjectBases/IGUIObject.h"
23#include "renderer/VertexArray.h"
24
25class CCamera;
26class CMatrix3D;
27class CTerrain;
28
29class CMiniMap : public IGUIObject
30{
31 GUI_OBJECT(CMiniMap)
32public:
33 CMiniMap(CGUI& pGUI);
34 virtual ~CMiniMap();
35
36 /**
37 * @return The maximum height for unit passage in water.
38 */
39 static float GetShallowPassageHeight();
40
41protected:
42 virtual void Draw();
43
44 /**
45 * @see IGUIObject#HandleMessage()
46 */
47 virtual void HandleMessage(SGUIMessage& Message);
48
49 /**
50 * @see IGUIObject#IsMouseOver()
51 */
52 virtual bool IsMouseOver() const;
53
54 // create the minimap textures
55 void CreateTextures();
56
57 // rebuild the terrain texture map
58 void RebuildTerrainTexture();
59
60 // destroy and free any memory and textures
61 void Destroy();
62
63 void SetCameraPos();
64
65 bool FireWorldClickEvent(int button, int clicks);
66
67 static const CStr EventNameWorldClick;
68
69 // the terrain we are mini-mapping
70 const CTerrain* m_Terrain;
71
72 const CCamera* m_Camera;
73
74 //Whether or not the mouse is currently down
75 bool m_Clicking;
76
77 // minimap texture handles
78 GLuint m_TerrainTexture;
79
80 // texture data
81 u32* m_TerrainData;
82
83 // whether we need to regenerate the terrain texture
84 bool m_TerrainDirty;
85
86 // Whether to draw a black square around and under the minimap.
87 bool m_Mask;
88
89 ssize_t m_Width, m_Height;
90
91 // map size
92 ssize_t m_MapSize;
93
94 // texture size
95 GLsizei m_TextureSize;
96
97 // 1.f if map is circular or 1.414f if square (to shrink it inside the circle)
98 float m_MapScale;
99
100 // maximal water height to allow the passage of a unit (for underwater shallows).
101 float m_ShallowPassageHeight;
102
103 float m_WaterHeight;
104
105 void DrawTexture(CShaderProgramPtr shader, float coordMax, float angle, float x, float y, float x2, float y2, float z) const;
106
107 void DrawViewRect(CMatrix3D transform) const;
108
109 void GetMouseWorldCoordinates(float& x, float& z) const;
110
111 float GetAngle() const;
112
113 VertexIndexArray m_IndexArray;
114 VertexArray m_VertexArray;
115 VertexArray::Attribute m_AttributePos;
116 VertexArray::Attribute m_AttributeColor;
117
118 size_t m_EntitiesDrawn;
119
120 double m_PingDuration;
121 double m_HalfBlinkDuration;
122 double m_NextBlinkTime;
123 bool m_BlinkState;
124};
125
126#endif // INCLUDED_MINIMAP
Note: See TracBrowser for help on using the repository browser.