Emergency 20 Dokumentation  4.2.0
VehicleOrderWindow.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/gui/GuiDocument.h>
17 
18 #include <Rocket/Core/String.h>
19 
20 
21 //[-------------------------------------------------------]
22 //[ Forward declarations ]
23 //[-------------------------------------------------------]
24 namespace em5
25 {
26  class OrderInfo;
27 }
28 
29 
30 //[-------------------------------------------------------]
31 //[ Namespace ]
32 //[-------------------------------------------------------]
33 namespace em5
34 {
35 
36 
37  //[-------------------------------------------------------]
38  //[ Classes ]
39  //[-------------------------------------------------------]
52  {
53 
54 
55  //[-------------------------------------------------------]
56  //[ Public definitions ]
57  //[-------------------------------------------------------]
58  public:
59  static const int MAX_NUMBER_OF_PASSENGER;
60 
62  {
66  VEHICLEORDERWINDOW_CLOSE
67  };
68 
69 
70  //[-------------------------------------------------------]
71  //[ Public methods ]
72  //[-------------------------------------------------------]
73  public:
74  explicit VehicleOrderWindow(qsf::GuiContext& guiContext);
75  virtual ~VehicleOrderWindow();
76  void setMaximumOrderNumber(uint32 maximumOrderNumber);
77 
82  void setupWindow(const OrderInfo& orderInfo);
83 
93  void enableButton(VehicleOrderWindowButton buttonId, bool state);
94 
99  void enableCloseButton(bool enable);
100 
110  void blinkButton(VehicleOrderWindowButton buttonId, bool blink);
111 
116  void enablePersonalModification(bool enable);
117 
122  void startOrderMode(bool hideWindow = false);
123 
124  void closedViaEscapeKey();
125 
126 
127  //[-------------------------------------------------------]
128  //[ Public virtual qsf::GuiDocument methods ]
129  //[-------------------------------------------------------]
130  public:
131  virtual void processEvent(const std::string& eventKey, Rocket::Core::Event& event) override;
132 
133 
134  //[-------------------------------------------------------]
135  //[ Private definitions ]
136  //[-------------------------------------------------------]
137  private:
138  struct PersonalIconDetail
139  {
140  std::string iconName;
141  OrderInfo* orderInfo;
142  Rocket::Core::Element* element;
143 
144  enum ButtonState
145  {
146  STATE_NORMAL,
147  STATE_DESELECT,
148  STATE_NOT_AVAILABLE
149  };
150  ButtonState buttonState;
151  };
152 
153 
154  //[-------------------------------------------------------]
155  //[ Private virtual qsf::GuiDocument methods ]
156  //[-------------------------------------------------------]
157  private:
158  virtual bool onPreShow() override;
159  virtual void onPreHide() override;
160 
161 
162  //[-------------------------------------------------------]
163  //[ Private methods ]
164  //[-------------------------------------------------------]
165  private:
166  void setupUI();
167  void onReloadGui();
168  void increment(uint32 maximum);
169  void decrement(uint32 minimum);
170  void updatePersonalIcon(const PersonalIconDetail& personalIconDetail);
171  void updateOrderWindow(const qsf::MessageParameters& parameters);
172  Rocket::Core::String getStringById(VehicleOrderWindowButton buttonId) const;
173 
174 
175  //[-------------------------------------------------------]
176  //[ Private variables ]
177  //[-------------------------------------------------------]
178  private:
179  const OrderInfo* mOrderInfo;
180  Rocket::Core::Element* mAmountSetTextElement; // The element what shows the amount of ordered units (eg. "1")
181  BlinkButton mBlinkButton;
182  uint32 mAvailableUnits;
183  uint32 mAmountInHQ;
184  uint32 mMaxAmountInHQ;
185  uint32 mMaximumOrderNumber;
186 
187  std::vector<PersonalIconDetail> mPersonalDetails;
188  qsf::MessageProxy mUpdateOrderWindowProxy;
189 
190  // 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
191  // Proper fix see QSF Bug "H301 GUI | "qsf::GuiDocument" | We need to guarantee that for each e.g. "onPostShow()" there's a "onPostHide()""
192  boost::signals2::connection mReloadGuiConnection;
193 
194 
195  };
196 
197 
198 //[-------------------------------------------------------]
199 //[ Namespace ]
200 //[-------------------------------------------------------]
201 } // em5
Definition: ActionPriority.h:13
Vehicle order window.
Definition: VehicleOrderWindow.h:51
Definition: VehicleOrderWindow.h:63
Message parameters class.
Definition: MessageParameters.h:34
Order information.
Definition: OrderInfo.h:54
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
static const int MAX_NUMBER_OF_PASSENGER
Definition: VehicleOrderWindow.h:59
Message listener proxy class.
Definition: MessageProxy.h:47
Ingame Graphical User Interface (GUI) context class.
Definition: GuiContext.h:62
Definition: VehicleOrderWindow.h:65
VehicleOrderWindowButton
Definition: VehicleOrderWindow.h:61
Definition: MiniMapWindow.h:43
Definition: VehicleOrderWindow.h:64