Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
CMiniMap.h
Go to the documentation of this file.
1/* Copyright (C) 2021 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/Color.h"
22#include "graphics/Texture.h"
24#include "maths/Vector2D.h"
26
27#include <deque>
28#include <vector>
29
30class CMatrix3D;
31
32class CMiniMap : public IGUIObject
33{
35
36public:
37 CMiniMap(CGUI& pGUI);
38 virtual ~CMiniMap();
39
40 bool Flare(const CVector2D& pos, const CStr& colorStr);
41
42protected:
43 struct MapFlare
44 {
47 double time;
48 };
49
50 virtual void Draw(CCanvas2D& canvas);
51
52 virtual void CreateJSObject();
53
54 /**
55 * @see IGUIObject#HandleMessage()
56 */
57 virtual void HandleMessage(SGUIMessage& Message);
58
59 /**
60 * @see IGUIObject#IsMouseOver()
61 */
62 virtual bool IsMouseOver() const;
63
64private:
66
67 bool FireWorldClickEvent(int button, int clicks);
68
69 static const CStr EventNameWorldClick;
70
71 // Whether or not the mouse is currently down
73
74 std::deque<MapFlare> m_MapFlares;
75
76 std::vector<CTexturePtr> m_FlareTextures;
77
85
86 // Whether to draw a black square around and under the minimap.
88
89 // map size
91
92 // 1.f if map is circular or 1.414f if square (to shrink it inside the circle)
94
96
97 void DrawViewRect(CCanvas2D& canvas) const;
98
99 void DrawFlare(CCanvas2D& canvas, const MapFlare& flare, double currentTime) const;
100 void DrawFlareFrame(CCanvas2D& canvas, const u32 frameIndex, const CRect& destination, const CColor& color, float alpha) const;
101
102 void GetMouseWorldCoordinates(float& x, float& z) const;
103
104 float GetAngle() const;
105 CVector2D WorldSpaceToMiniMapSpace(const CVector3D& worldPosition) const;
106};
107
108#endif // INCLUDED_MINIMAP
#define GUI_OBJECT(obj)
Definition: IGUIObject.h:50
Definition: Canvas2D.h:36
The main object that represents a whole GUI page.
Definition: CGUI.h:61
Definition: Matrix3D.h:34
Definition: CMiniMap.h:33
virtual bool IsMouseOver() const
Definition: CMiniMap.cpp:188
virtual void Draw(CCanvas2D &canvas)
Draws the object.
Definition: CMiniMap.cpp:340
bool m_Clicking
Definition: CMiniMap.h:72
void RecreateFlareTextures()
Definition: CMiniMap.cpp:169
CGUISimpleSetting< bool > m_FlareInterleave
Definition: CMiniMap.h:80
void DrawFlareFrame(CCanvas2D &canvas, const u32 frameIndex, const CRect &destination, const CColor &color, float alpha) const
Definition: CMiniMap.cpp:328
CGUISimpleSetting< float > m_FlareStartFadeSeconds
Definition: CMiniMap.h:83
CGUISimpleSetting< u32 > m_FlareRenderSize
Definition: CMiniMap.h:79
std::vector< CTexturePtr > m_FlareTextures
Definition: CMiniMap.h:76
ssize_t m_MapSize
Definition: CMiniMap.h:90
virtual void CreateJSObject()
Creates the JS object representing this page upon first use.
CGUISimpleSetting< u32 > m_FlareTextureCount
Definition: CMiniMap.h:78
virtual void HandleMessage(SGUIMessage &Message)
Definition: CMiniMap.cpp:110
std::deque< MapFlare > m_MapFlares
Definition: CMiniMap.h:74
virtual ~CMiniMap()
void DrawViewRect(CCanvas2D &canvas) const
Definition: CMiniMap.cpp:268
void DrawFlare(CCanvas2D &canvas, const MapFlare &flare, double currentTime) const
Definition: CMiniMap.cpp:297
float m_MapScale
Definition: CMiniMap.h:93
CGUISimpleSetting< float > m_FlareStopFadeSeconds
Definition: CMiniMap.h:84
CMiniMap(CGUI &pGUI)
Definition: CMiniMap.cpp:95
void GetMouseWorldCoordinates(float &x, float &z) const
Definition: CMiniMap.cpp:197
bool Flare(const CVector2D &pos, const CStr &colorStr)
Definition: CMiniMap.cpp:406
CGUISimpleSetting< bool > m_Mask
Definition: CMiniMap.h:87
static const CStr EventNameWorldClick
Definition: CMiniMap.h:69
CGUISimpleSetting< float > m_FlareAnimationSpeed
Definition: CMiniMap.h:81
float GetAngle() const
Definition: CMiniMap.cpp:222
CVector2D WorldSpaceToMiniMapSpace(const CVector3D &worldPosition) const
Definition: CMiniMap.cpp:228
CGUISimpleSetting< float > m_FlareLifetimeSeconds
Definition: CMiniMap.h:82
bool FireWorldClickEvent(int button, int clicks)
Definition: CMiniMap.cpp:246
void SetCameraPositionFromMousePosition()
Definition: CMiniMap.cpp:212
Rectangle class used for screen rectangles.
Definition: Rect.h:31
Definition: Vector2D.h:32
Definition: Vector3D.h:31
GUI object such as a button or an input-box.
Definition: IGUIObject.h:60
Definition: Color.h:43
Definition: CMiniMap.h:44
double time
Definition: CMiniMap.h:47
CColor color
Definition: CMiniMap.h:46
CVector2D pos
Definition: CMiniMap.h:45
Message send to IGUIObject::HandleMessage() in order to give life to Objects manually with a derived ...
Definition: SGUIMessage.h:68
uint32_t u32
Definition: types.h:39
intptr_t ssize_t
Definition: wposix_types.h:82