Emergency 20 Dokumentation  4.2.0
MiniMapWindow.h
Go to the documentation of this file.
1 // Copyright (C) 2012-2018 Promotion Software GmbH
2 
3 
4 //[-------------------------------------------------------]
5 //[ Header guard ]
6 //[-------------------------------------------------------]
7 #pragma once
8 
9 
10 //[-------------------------------------------------------]
11 //[ Includes ]
12 //[-------------------------------------------------------]
13 #include "em5/audio/AudioProxy.h"
14 
15 #include <qsf/gui/GuiDocument.h>
16 #include <qsf/job/JobProxy.h>
17 
18 #include <glm/glm.hpp>
19 
20 #include <boost/container/flat_map.hpp>
21 
22 #include <unordered_map>
23 
24 
25 //[-------------------------------------------------------]
26 //[ Forward declarations ]
27 //[-------------------------------------------------------]
28 namespace em5
29 {
30  class MiniMapRenderer;
31 }
32 namespace qsf
33 {
34  class Map;
35  class JobArguments;
36 }
37 namespace Rocket
38 {
39  namespace Core
40  {
41  class Geometry;
42  class ElementDocument;
43  template<typename T> class StringBase;
44  typedef StringBase<char> String;
45  }
46 }
47 
48 
49 //[-------------------------------------------------------]
50 //[ Namespace ]
51 //[-------------------------------------------------------]
52 namespace em5
53 {
54 
55 
56  //[-------------------------------------------------------]
57  //[ Classes ]
58  //[-------------------------------------------------------]
64  {
65 
66 
67  //[-------------------------------------------------------]
68  //[ Public methods ]
69  //[-------------------------------------------------------]
70  public:
71  explicit MiniMapWindow(qsf::GuiContext& guiContext);
72  virtual ~MiniMapWindow();
73 
74  void setMap(qsf::Map& map);
75  void rebuildGui(bool forceRebuild = false);
76  inline bool isUnitOverviewButtonVisible() const;
77  void setUnitOverviewButtonVisible(bool visible);
78  void setPingButtonVisible(bool visible);
79  void setFilterButtonsVisible(bool visible);
80 
81  inline MiniMapRenderer& getRenderer() const;
82  inline Rocket::Core::Geometry* getLibRocketGeometry() const;
83 
84 
85  //[-------------------------------------------------------]
86  //[ Public virtual qsf::GuiDocument methods ]
87  //[-------------------------------------------------------]
88  public:
89  virtual void processEvent(const std::string& eventKey, Rocket::Core::Event& event) override;
90 
91 
92  //[-------------------------------------------------------]
93  //[ Private virtual qsf::GuiDocument methods ]
94  //[-------------------------------------------------------]
95  private:
96  virtual bool onPreShow() override;
97  virtual void onPreHide() override;
98 
99 
100  //[-------------------------------------------------------]
101  //[ Private methods ]
102  //[-------------------------------------------------------]
103  private:
104  void setupUI();
105  void onReloadGui();
106 
107  void update(const qsf::JobArguments& jobArguments);
108 
109  void updateFilterButtons();
110  void updateFilterButton(Rocket::Core::ElementDocument& elementDocument, const Rocket::Core::String& id, uint32 miniMapIconBucket);
111  void updateZoom();
112  void updateUnitOverviewButtonVisibleState();
113  void updatePingButtonVisibleState();
114  void updatePingButton();
115 
116  void onLeftMouseButton(Rocket::Core::Event& event, bool isDown);
117  void onRightMouseButton(Rocket::Core::Event& event);
118  void onMouseMove();
119  glm::vec2 mapMousePositionToViewportPosition(Rocket::Core::Event& event);
120  glm::vec3 getWorldPositionFromViewportPosition(Rocket::Core::Event& event);
121 
122 
123  //[-------------------------------------------------------]
124  //[ Private data ]
125  //[-------------------------------------------------------]
126  private:
127  MiniMapRenderer* mMiniMapRenderer;
128  Rocket::Core::Geometry* mMapGeometry;
129  bool mMapGeometryBuilt;
130  bool mWaitingForPingClick;
131  bool mUnitOverviewButtonVisible;
132  bool mPingButtonVisible;
133  bool mFilterButtonsVisible;
134  qsf::JobProxy mAnimationJobProxy;
135  AudioProxy mAudioProxy;
136 
137  // Needed for feature to move the minimap viewport around via left mouse down and drag
138  glm::vec2 mCurrentMousePositionOnViewport;
139  glm::vec2 mMousePositionOnViewportOnMouseDown;
140  glm::vec2 mLastMousePositionOnDrag;
141  bool mLeftMouseDown;
142 
143  // TODO(sw) This is an fix for the crash when going from the game to the main menu and initiate then a gui hot reloading -> The connection to the minimap was still there but the minimap instance was destroyed
144  // Proper fix see QSF Bug "H301 GUI | "qsf::GuiDocument" | We need to guarantee that for each e.g. "onPostShow()" there's a "onPostHide()""
145  boost::signals2::connection mReloadGuiConnection;
146 
147 
148  };
149 
150 
151 //[-------------------------------------------------------]
152 //[ Namespace ]
153 //[-------------------------------------------------------]
154 } // em5
155 
156 
157 //[-------------------------------------------------------]
158 //[ Implementation ]
159 //[-------------------------------------------------------]
Definition: ActionPriority.h:13
Job proxy class.
Definition: JobProxy.h:51
Minimap rendering class.
Definition: MiniMapRenderer.h:105
Map class.
Definition: Map.h:93
unsigned int uint32
Definition: PlatformTypes.h:181
Graphical User Interface (GUI) document base class.
Definition: GuiDocument.h:51
#define EM5_API_EXPORT
Definition: Export.h:28
Definition: OverlayComponent.h:29
Job arguments class: holds data to be passed to the called job method by the job manager.
Definition: JobArguments.h:40
EMERGENCY 5 mini-map window HUD element.
Definition: MiniMapWindow.h:63
Definition: PickupPersonByParamedicAction.h:21
Ingame Graphical User Interface (GUI) context class.
Definition: GuiContext.h:62
Extended audio proxy for easier multiplay usage.
Definition: AudioProxy.h:47
Definition: MiniMapWindow.h:43
StringBase< char > String
Definition: MiniMapWindow.h:43