Emergency 20 Dokumentation  4.2.0
StatusOverlayComponent.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 //[-------------------------------------------------------]
14 
15 #include <qsf/math/EnumBitmask.h>
16 
17 
18 //[-------------------------------------------------------]
19 //[ Forward declarations ]
20 //[-------------------------------------------------------]
21 namespace Rocket
22 {
23  namespace Core
24  {
25  class Element;
26  }
27 }
28 
29 
30 //[-------------------------------------------------------]
31 //[ Namespace ]
32 //[-------------------------------------------------------]
33 namespace em5
34 {
35 
36 
37  //[-------------------------------------------------------]
38  //[ Classes ]
39  //[-------------------------------------------------------]
45  {
46 
47 
48  //[-------------------------------------------------------]
49  //[ Public definitions ]
50  //[-------------------------------------------------------]
51  public:
52  static const uint32 COMPONENT_ID;
53  static const uint32 STATUS_BAR_WIDTH;
55 
56  static const glm::vec2 WINDOW_SIZE;
57  static const glm::vec2 WINDOW_OFFSET;
58 
59  static const glm::vec3 HEALTHBAR_WORLD_SPACE_OFFSET;
60 
61  static const float STATUS_BAR_ARROW_BLINK_PERIOD;
62  static const float STATUS_BAR_FULL_TO_LOW_PERCENT;
64 
65  static const std::string STATUS_FIRE_BAR_COLOR_FULL;
66  static const std::string STATUS_FIRE_BAR_COLOR_LOW;
67 
68  static const std::string STATUS_HEALTH_BAR_COLOR_FULL;
69  static const std::string STATUS_HEALTH_BAR_COLOR_LOW;
70 
71  static const std::string STATUS_LIFE_BAR_COLOR_FULL;
72  static const std::string STATUS_LIFE_BAR_COLOR_LOW;
73 
74  static const std::string STATUS_DEATH_BAR_COLOR_FULL;
75  static const std::string STATUS_DEATH_BAR_COLOR_LOW;
76 
77  static const std::string STATUS_PROGRESS_BAR_COLOR_FULL;
78  static const std::string STATUS_PROGRESS_BAR_COLOR_LOW;
79 
80  static const std::string STATUS_HEALTH_VEHICLE_BAR_COLOR_FULL;
81  static const std::string STATUS_HEALTH_VEHICLE_BAR_COLOR_LOW;
82  static const std::string STATUS_HEALTH_VEHICLE_BAR_COLOR_VERY_LOW;
83 
84  enum BarType
85  {
86  BAR_TYPE_NONE = -1,
87  BAR_TYPE_FIRE = 0,
93  _BAR_COUNT
94  };
95 
97  {
98  STATUS_ICON_UNDEFINED = -1,
133  _STATUS_ICON_COUNT
134  };
135 
136  struct Bar
137  {
138  float mProgress;
143  };
144  typedef boost::container::flat_map<BarType, Bar> BarMap;
145 
146 
147  //[-------------------------------------------------------]
148  //[ Public static methods ]
149  //[-------------------------------------------------------]
150  public:
151  // TODO(sw) Needed for multiplay so that we add the correct entity to the cache for the status overlay component
152  static qsf::Entity& getEntityOrChildWithMesh(qsf::Entity& entity);
153 
157  static void showBarOverlay(qsf::Entity& overlayOwnerEntity, BarType barType, float progress = 1.0f);
158  static void hideBarOverlay(qsf::Entity& overlayOwnerEntity, BarType barType);
159 
160  static void showIcon(qsf::Entity& overlayOwnerEntity, StatusIconType statusIconType, bool show = true);
161  static void hideIcon(qsf::Entity& overlayOwnerEntity, StatusIconType statusIconType);
162 
163 
164  //[-------------------------------------------------------]
165  //[ Public methods ]
166  //[-------------------------------------------------------]
167  public:
175  explicit StatusOverlayComponent(qsf::Prototype* prototype);
176 
181  inline virtual ~StatusOverlayComponent();
182 
183  void showBarOverlay(BarType barType, float progress);
184  void hideBarOverlay(BarType barType);
185 
186  void showIcon(StatusIconType statusIconType, bool enabled = true);
187  void hideIcon(StatusIconType statusIconType);
188 
189  // Needed for multiplay
190  inline uint64 getIconFlags() const;
191  inline const BarMap& getBarValues() const;
192 
193 
194  //[-------------------------------------------------------]
195  //[ Protected virtual em5::OverlayComponent methods ]
196  //[-------------------------------------------------------]
197  protected:
198  virtual bool isContentEmpty() const override;
199  virtual void updateContent(Rocket::Core::ElementDocument& document) override;
200  virtual const glm::vec3& getContentWorldSpaceOffset() const override;
201  virtual const glm::vec2& getContentWindowSize() const override;
202  virtual const glm::vec2& getContentWindowOffset() const override;
203  virtual void updateAnimation(const qsf::JobArguments& jobArguments) override;
204 
205 
206  //[-------------------------------------------------------]
207  //[ Private static methods ]
208  //[-------------------------------------------------------]
209  private:
210  static void initializeIconInfoMap();
211 
212 
213  //[-------------------------------------------------------]
214  //[ Private methods ]
215  //[-------------------------------------------------------]
216  private:
217  void centerStatusIcons(Rocket::Core::Element& element);
218 
219 
220  //[-------------------------------------------------------]
221  //[ Private definitions ]
222  //[-------------------------------------------------------]
223  private:
225 
226  struct IconInfo
227  {
228  std::string mStyleSheetClass;
229  std::string mTooltipId;
230  };
231  typedef boost::container::flat_map<StatusIconType, IconInfo> IconInfoMap;
232 
233 
234  //[-------------------------------------------------------]
235  //[ Private static data ]
236  //[-------------------------------------------------------]
237  private:
238  static IconInfoMap mIconInfoMap;
239 
240 
241  //[-------------------------------------------------------]
242  //[ Private data ]
243  //[-------------------------------------------------------]
244  private:
245  BarMap mBarMap;
246  StatusIconFlags mStatusIconFlags;
247  qsf::Time mTimePassed;
248  qsf::Time mLastUpdateTime;
249  bool mBarBackgroundsVisible;
250 
251 
252  //[-------------------------------------------------------]
253  //[ CAMP reflection system ]
254  //[-------------------------------------------------------]
255  QSF_CAMP_RTTI() // Only adds the virtual method "campClassId()", nothing more
256 
257 
258  };
259 
260 
261 //[-------------------------------------------------------]
262 //[ Namespace ]
263 //[-------------------------------------------------------]
264 } // em5
265 
266 
267 //[-------------------------------------------------------]
268 //[ Implementation ]
269 //[-------------------------------------------------------]
271 
272 
273 //[-------------------------------------------------------]
274 //[ CAMP reflection system ]
275 //[-------------------------------------------------------]
277 QSF_CAMP_TYPE_NONCOPYABLE(em5::StatusOverlayComponent::StatusIconType)
Small health bar.
Definition: StatusOverlayComponent.h:89
Health energy bar.
Definition: StatusOverlayComponent.h:88
Definition: ActionPriority.h:13
static const glm::vec2 WINDOW_SIZE
Definition: StatusOverlayComponent.h:56
Definition: StatusOverlayComponent.h:125
static const std::string STATUS_PROGRESS_BAR_COLOR_FULL
Definition: StatusOverlayComponent.h:77
float mLastProgress
Definition: StatusOverlayComponent.h:139
Entity class.
Definition: Entity.h:46
Definition: StatusOverlayComponent.h:109
Definition: StatusOverlayComponent.h:107
unsigned int uint32
Definition: PlatformTypes.h:181
static const std::string STATUS_DEATH_BAR_COLOR_LOW
Definition: StatusOverlayComponent.h:75
static const std::string STATUS_PROGRESS_BAR_COLOR_LOW
Definition: StatusOverlayComponent.h:78
static const std::string STATUS_LIFE_BAR_COLOR_LOW
Definition: StatusOverlayComponent.h:72
#define EM5_API_EXPORT
Definition: Export.h:28
Definition: StatusOverlayComponent.h:120
Definition: StatusOverlayComponent.h:131
static const std::string STATUS_FIRE_BAR_COLOR_LOW
Definition: StatusOverlayComponent.h:66
EMERGENCY 5 overlay component base class.
Definition: OverlayComponent.h:52
Definition: OverlayComponent.h:29
int mDirection
Definition: StatusOverlayComponent.h:142
static const std::string STATUS_LIFE_BAR_COLOR_FULL
Definition: StatusOverlayComponent.h:71
Definition: StatusOverlayComponent.h:100
Definition: StatusOverlayComponent.h:132
uint64_t uint64
Definition: PlatformTypes.h:184
Definition: StatusOverlayComponent.h:130
Job arguments class: holds data to be passed to the called job method by the job manager.
Definition: JobArguments.h:40
static const std::string STATUS_FIRE_BAR_COLOR_FULL
Definition: StatusOverlayComponent.h:65
Progress bar.
Definition: StatusOverlayComponent.h:92
static const std::string STATUS_HEALTH_BAR_COLOR_LOW
Definition: StatusOverlayComponent.h:69
Definition: StatusOverlayComponent.h:118
#define QSF_CAMP_RTTI()
Only adds the virtual method "campClassId()", nothing more.
Definition: CampClass.h:75
Definition: StatusOverlayComponent.h:99
Definition: StatusOverlayComponent.h:126
static const std::string STATUS_DEATH_BAR_COLOR_FULL
Definition: StatusOverlayComponent.h:74
static const std::string STATUS_HEALTH_VEHICLE_BAR_COLOR_VERY_LOW
Definition: StatusOverlayComponent.h:82
#define QSF_CAMP_TYPE_NONCOPYABLE(type)
See "CAMP_TYPE_NONCOPYABLE" for details.
Definition: CampClass.h:112
BarType
Definition: StatusOverlayComponent.h:84
Definition: StatusOverlayComponent.h:112
static const std::string STATUS_HEALTH_BAR_COLOR_FULL
Definition: StatusOverlayComponent.h:68
StatusIconType
Definition: StatusOverlayComponent.h:96
int mNumberOfArrows
Definition: StatusOverlayComponent.h:141
Definition: StatusOverlayComponent.h:117
Definition: StatusOverlayComponent.h:116
static const float STATUS_BAR_FULL_TO_VERY_LOW_PERCENT
Definition: StatusOverlayComponent.h:63
static const float STATUS_BAR_FULL_TO_LOW_PERCENT
Definition: StatusOverlayComponent.h:62
static const glm::vec3 HEALTHBAR_WORLD_SPACE_OFFSET
Definition: StatusOverlayComponent.h:59
Definition: StatusOverlayComponent.h:136
boost::container::flat_map< BarType, Bar > BarMap
Definition: StatusOverlayComponent.h:144
EMERGENCY 5 status overlay component class.
Definition: StatusOverlayComponent.h:44
Life energy bar.
Definition: StatusOverlayComponent.h:90
Definition: StatusOverlayComponent.h:127
static const uint32 COMPONENT_ID
"em5::StatusOverlayComponent" unique component ID
Definition: StatusOverlayComponent.h:52
static const uint32 STATUS_BAR_ARROW_WIDTH
Definition: StatusOverlayComponent.h:54
Definition: StatusOverlayComponent.h:121
Prototype class.
Definition: Prototype.h:100
Definition: StatusOverlayComponent.h:128
static const std::string STATUS_HEALTH_VEHICLE_BAR_COLOR_FULL
Definition: StatusOverlayComponent.h:80
Definition: StatusOverlayComponent.h:106
float mShownProgress
Definition: StatusOverlayComponent.h:140
Definition: StatusOverlayComponent.h:114
Deathfight energy bar.
Definition: StatusOverlayComponent.h:91
Definition: StatusOverlayComponent.h:101
Definition: StatusOverlayComponent.h:124
float mProgress
Definition: StatusOverlayComponent.h:138
Definition: StatusOverlayComponent.h:111
static const glm::vec2 WINDOW_OFFSET
Definition: StatusOverlayComponent.h:57
Definition: StatusOverlayComponent.h:110
Definition: StatusOverlayComponent.h:115
Definition: StatusOverlayComponent.h:113
static const float STATUS_BAR_ARROW_BLINK_PERIOD
Definition: StatusOverlayComponent.h:61
Definition: StatusOverlayComponent.h:129
static const std::string STATUS_HEALTH_VEHICLE_BAR_COLOR_LOW
Definition: StatusOverlayComponent.h:81
Definition: StatusOverlayComponent.h:108
static const uint32 STATUS_BAR_WIDTH
Definition: StatusOverlayComponent.h:53
Data type for encapsulating time information. It might represents points in time and time spans...
Definition: Time.h:32