| [25392] | 1 | /* Copyright (C) 2021 Wildfire Games.
|
|---|
| [27965] | 2 | * This file is part of 0 A.D.
|
|---|
| [6830] | 3 | *
|
|---|
| [27965] | 4 | * 0 A.D. is free software: you can redistribute it and/or modify
|
|---|
| [6830] | 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 | *
|
|---|
| [27965] | 9 | * 0 A.D. is distributed in the hope that it will be useful,
|
|---|
| [6830] | 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
|
|---|
| [27965] | 15 | * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
|
|---|
| [6830] | 16 | */
|
|---|
| 17 |
|
|---|
| [5040] | 18 | #ifndef INCLUDED_MINIMAP
|
|---|
| 19 | #define INCLUDED_MINIMAP
|
|---|
| [1230] | 20 |
|
|---|
| [25691] | 21 | #include "graphics/Color.h"
|
|---|
| 22 | #include "graphics/Texture.h"
|
|---|
| [23028] | 23 | #include "gui/ObjectBases/IGUIObject.h"
|
|---|
| [25691] | 24 | #include "maths/Vector2D.h"
|
|---|
| [13454] | 25 | #include "renderer/VertexArray.h"
|
|---|
| [4696] | 26 |
|
|---|
| [25691] | 27 | #include <deque>
|
|---|
| 28 | #include <vector>
|
|---|
| 29 |
|
|---|
| [22605] | 30 | class CMatrix3D;
|
|---|
| [1230] | 31 |
|
|---|
| 32 | class CMiniMap : public IGUIObject
|
|---|
| 33 | {
|
|---|
| [11748] | 34 | GUI_OBJECT(CMiniMap)
|
|---|
| [25691] | 35 |
|
|---|
| [1230] | 36 | public:
|
|---|
| [22741] | 37 | CMiniMap(CGUI& pGUI);
|
|---|
| [11748] | 38 | virtual ~CMiniMap();
|
|---|
| [23859] | 39 |
|
|---|
| [25691] | 40 | bool Flare(const CVector2D& pos, const CStr& colorStr);
|
|---|
| 41 |
|
|---|
| [1230] | 42 | protected:
|
|---|
| [25691] | 43 | struct MapFlare
|
|---|
| 44 | {
|
|---|
| 45 | CVector2D pos;
|
|---|
| 46 | CColor color;
|
|---|
| 47 | double time;
|
|---|
| 48 | };
|
|---|
| 49 |
|
|---|
| [25588] | 50 | virtual void Draw(CCanvas2D& canvas);
|
|---|
| [1230] | 51 |
|
|---|
| [25691] | 52 | virtual void CreateJSObject();
|
|---|
| 53 |
|
|---|
| [9340] | 54 | /**
|
|---|
| 55 | * @see IGUIObject#HandleMessage()
|
|---|
| 56 | */
|
|---|
| [16931] | 57 | virtual void HandleMessage(SGUIMessage& Message);
|
|---|
| [2979] | 58 |
|
|---|
| [14819] | 59 | /**
|
|---|
| [22757] | 60 | * @see IGUIObject#IsMouseOver()
|
|---|
| [14819] | 61 | */
|
|---|
| [22757] | 62 | virtual bool IsMouseOver() const;
|
|---|
| [14819] | 63 |
|
|---|
| [25628] | 64 | private:
|
|---|
| [25630] | 65 | void SetCameraPositionFromMousePosition();
|
|---|
| [1230] | 66 |
|
|---|
| [23653] | 67 | bool FireWorldClickEvent(int button, int clicks);
|
|---|
| [3381] | 68 |
|
|---|
| [23403] | 69 | static const CStr EventNameWorldClick;
|
|---|
| 70 |
|
|---|
| [25631] | 71 | // Whether or not the mouse is currently down
|
|---|
| [8610] | 72 | bool m_Clicking;
|
|---|
| [2970] | 73 |
|
|---|
| [25691] | 74 | std::deque<MapFlare> m_MapFlares;
|
|---|
| 75 |
|
|---|
| 76 | std::vector<CTexturePtr> m_FlareTextures;
|
|---|
| 77 |
|
|---|
| 78 | CGUISimpleSetting<u32> m_FlareTextureCount;
|
|---|
| 79 | CGUISimpleSetting<u32> m_FlareRenderSize;
|
|---|
| 80 | CGUISimpleSetting<bool> m_FlareInterleave;
|
|---|
| [25775] | 81 | CGUISimpleSetting<float> m_FlareAnimationSpeed;
|
|---|
| 82 | CGUISimpleSetting<float> m_FlareLifetimeSeconds;
|
|---|
| [26001] | 83 | CGUISimpleSetting<float> m_FlareStartFadeSeconds;
|
|---|
| 84 | CGUISimpleSetting<float> m_FlareStopFadeSeconds;
|
|---|
| [25691] | 85 |
|
|---|
| [24141] | 86 | // Whether to draw a black square around and under the minimap.
|
|---|
| [25392] | 87 | CGUISimpleSetting<bool> m_Mask;
|
|---|
| [24141] | 88 |
|
|---|
| [11748] | 89 | // map size
|
|---|
| 90 | ssize_t m_MapSize;
|
|---|
| [1230] | 91 |
|
|---|
| [9554] | 92 | // 1.f if map is circular or 1.414f if square (to shrink it inside the circle)
|
|---|
| 93 | float m_MapScale;
|
|---|
| [16931] | 94 |
|
|---|
| [25691] | 95 | void RecreateFlareTextures();
|
|---|
| 96 |
|
|---|
| [25973] | 97 | void DrawViewRect(CCanvas2D& canvas) const;
|
|---|
| [8470] | 98 |
|
|---|
| [26001] | 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;
|
|---|
| [25691] | 101 |
|
|---|
| [22757] | 102 | void GetMouseWorldCoordinates(float& x, float& z) const;
|
|---|
| [8470] | 103 |
|
|---|
| [22757] | 104 | float GetAngle() const;
|
|---|
| [25973] | 105 | CVector2D WorldSpaceToMiniMapSpace(const CVector3D& worldPosition) const;
|
|---|
| [1230] | 106 | };
|
|---|
| 107 |
|
|---|
| [16931] | 108 | #endif // INCLUDED_MINIMAP
|
|---|