Emergency 20 Dokumentation  4.2.0
BuildingOverlayComponent.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 
16 //[-------------------------------------------------------]
17 //[ Namespace ]
18 //[-------------------------------------------------------]
19 namespace em5
20 {
21 
22 
23  //[-------------------------------------------------------]
24  //[ Structs ]
25  //[-------------------------------------------------------]
31  {
33  float progress;
34 
35  BuildingOverlayProvider(uint64 _entityId, float _progress) :
36  entityId(_entityId),
37  progress(_progress)
38  {
39  // Nothing here
40  }
41  };
42 
43 
44  //[-------------------------------------------------------]
45  //[ Classes ]
46  //[-------------------------------------------------------]
52  {
53 
54 
55  //[-------------------------------------------------------]
56  //[ Friends ]
57  //[-------------------------------------------------------]
59 
60 
61  //[-------------------------------------------------------]
62  //[ Public definitions ]
63  //[-------------------------------------------------------]
64  public:
65  static const uint32 COMPONENT_ID;
66 
67 
68  //[-------------------------------------------------------]
69  //[ Public static methods ]
70  //[-------------------------------------------------------]
71  public:
85  static void showProgress(qsf::Entity& buildingEntity, uint32 numberOfRequiredProviders, const qsf::Entity& providerEntity, float progress);
86 
96  static void hideOverlay(qsf::Entity& buildingEntity, const qsf::Entity& providerEntity);
97 
98 
99  //[-------------------------------------------------------]
100  //[ Public methods ]
101  //[-------------------------------------------------------]
102  public:
110  explicit BuildingOverlayComponent(qsf::Prototype* prototype);
111 
116  inline virtual ~BuildingOverlayComponent();
117 
118  inline const std::vector<BuildingOverlayProvider>& getRegisteredProviders() const;
119  inline bool isEmpty() const;
120 
121  void registerOrUpdateProvider(uint64 providerEntityId, float progress);
122  void unregisterProvider(uint64 providerEntityId);
123 
124  inline uint32 getNumberOfRequiredProviders() const;
125  void setNumberOfRequiredProviders(uint32 numberOfRequiredProviders);
126 
127 
128  //[-------------------------------------------------------]
129  //[ Protected virtual em5::OverlayComponent methods ]
130  //[-------------------------------------------------------]
131  protected:
132  virtual bool isContentEmpty() const override;
133  virtual void updateContent(Rocket::Core::ElementDocument& document) override;
134  virtual const glm::vec3& getContentWorldSpaceOffset() const override;
135  virtual const glm::vec2& getContentWindowSize() const override;
136  virtual const glm::vec2& getContentWindowOffset() const override;
137  virtual void updateAnimation(const qsf::JobArguments& jobArguments) override;
138 
139 
140  //[-------------------------------------------------------]
141  //[ Private definitions ]
142  //[-------------------------------------------------------]
143  private:
144  typedef std::vector<BuildingOverlayProvider> Providers;
145  Providers mRegisteredProviders;
146  uint32 mNumberOfRequiredProviders;
147 
148  enum Dirty
149  {
150  GUI_NOT_DIRTY,
151  GUI_PROGRESS_DIRTY,
152  GUI_LAYOUT_DIRTY
153  };
154  Dirty mDirty;
155 
156 
157  //[-------------------------------------------------------]
158  //[ Private methods ]
159  //[-------------------------------------------------------]
160  private:
161  void setDirtyState(Dirty dirty);
162  std::string getPersonalInnerRmlString(const qsf::Entity& providerEntity) const;
163 
164 
165  //[-------------------------------------------------------]
166  //[ CAMP reflection system ]
167  //[-------------------------------------------------------]
168  QSF_CAMP_RTTI() // Only adds the virtual method "campClassId()", nothing more
169 
170 
171  };
172 
173 
174 //[-------------------------------------------------------]
175 //[ Namespace ]
176 //[-------------------------------------------------------]
177 } // em5
178 
179 
180 //[-------------------------------------------------------]
181 //[ Implementation ]
182 //[-------------------------------------------------------]
184 
185 
186 //[-------------------------------------------------------]
187 //[ CAMP reflection system ]
188 //[-------------------------------------------------------]
Definition: ActionPriority.h:13
Entity class.
Definition: Entity.h:46
unsigned int uint32
Definition: PlatformTypes.h:181
#define EM5_API_EXPORT
Definition: Export.h:28
EMERGENCY 5 overlay component base class.
Definition: OverlayComponent.h:52
EMERGENCY 5 building overlay window manager.
Definition: BuildingOverlayWindowManager.h:43
uint64_t uint64
Definition: PlatformTypes.h:184
EMERGENCY 5 building overlay component class.
Definition: BuildingOverlayComponent.h:51
Job arguments class: holds data to be passed to the called job method by the job manager.
Definition: JobArguments.h:40
#define QSF_CAMP_RTTI()
Only adds the virtual method "campClassId()", nothing more.
Definition: CampClass.h:75
#define QSF_CAMP_TYPE_NONCOPYABLE(type)
See "CAMP_TYPE_NONCOPYABLE" for details.
Definition: CampClass.h:112
EMERGENCY 5 building overlay provider struct.
Definition: BuildingOverlayComponent.h:30
float progress
Progress of the provider (range [0-1] where 1 is a full bar)
Definition: BuildingOverlayComponent.h:33
BuildingOverlayProvider(uint64 _entityId, float _progress)
Definition: BuildingOverlayComponent.h:35
uint64 entityId
The entity ID of the provider, "qsf::getUninitialized()" if not set, yet. ...
Definition: BuildingOverlayComponent.h:32
Prototype class.
Definition: Prototype.h:100
static const uint32 COMPONENT_ID
"em5::BuildingOverlayComponent" unique component ID
Definition: BuildingOverlayComponent.h:65