Emergency 20 Dokumentation  4.2.0
CommandWindow.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 <boost/signals2.hpp>
19 #include <boost/container/flat_set.hpp>
20 
21 
22 //[-------------------------------------------------------]
23 //[ Forward declarations ]
24 //[-------------------------------------------------------]
25 namespace em5
26 {
27  class Command;
28  class CommandableComponent;
29  class OrderInfo;
30  class SelectionManager;
31 }
32 namespace qsf
33 {
34  class Map;
35 }
36 
37 
38 //[-------------------------------------------------------]
39 //[ Namespace ]
40 //[-------------------------------------------------------]
41 namespace em5
42 {
43 
44 
45  //[-------------------------------------------------------]
46  //[ Classes ]
47  //[-------------------------------------------------------]
53  {
54 
55 
56  //[-------------------------------------------------------]
57  //[ Public Boost signals ]
58  //[-------------------------------------------------------]
59  public:
60  boost::signals2::signal<void ()> NumberOfActiveButtonsChanged;
61 
62 
63  //[-------------------------------------------------------]
64  //[ Public definitions ]
65  //[-------------------------------------------------------]
66  public:
68 
69 
70  //[-------------------------------------------------------]
71  //[ Public methods ]
72  //[-------------------------------------------------------]
73  public:
74  explicit CommandWindow(qsf::GuiContext& guiContext);
75 
85  void enableButton(const qsf::StringHash commandId, bool enabled);
86 
94  void enableAllButtons(bool enabled);
95 
105  void blinkButton(const qsf::StringHash commandId, bool blink);
106 
111  uint32 getNumberOfActiveButtons() const;
112 
113  void activateButtonByIndex(int index);
114  void deactivateButtons();
115 
116 
117  //[-------------------------------------------------------]
118  //[ Public virtual qsf::GuiDocument methods ]
119  //[-------------------------------------------------------]
120  public:
121  virtual void processEvent(const std::string& eventKey, Rocket::Core::Event& event) override;
122 
123 
124  //[-------------------------------------------------------]
125  //[ Private methods ]
126  //[-------------------------------------------------------]
127  private:
128  void onSelectionChange(const qsf::MessageParameters& parameters = qsf::MessageParameters());
129  void updateCommandButtons(const std::vector<uint32>& commandVector);
130  void getSharedCommandIds(boost::container::flat_set<uint32>& outCommandIds);
131  bool getLocalPlayerUnits(SelectionManager& selectionManager, const qsf::Map& map, std::vector<const CommandableComponent*>& resultList);
132  bool isUnitFromLocalPlayer(const CommandableComponent& commandableComponent);
133  bool showCommandAsButton(const Command& command);
134  void updateEquipmentInformation();
135  const OrderInfo* getSingleSelectionOrderInfo() const;
136  void activateCommandFromElement(Rocket::Core::Element& element);
137 
138  Rocket::Core::Element* getButtonElementForCommand(const qsf::StringHash commandId);
139 
140 
141  //[-------------------------------------------------------]
142  //[ Private data ]
143  //[-------------------------------------------------------]
144  private:
145  uint32 mNumberOfActiveButtons;
146  qsf::MessageProxy mMessageProxy;
147  qsf::JobProxy mUpdateJobProxyEquipmentInformation;
148  std::string mCommandName;
149  Rocket::Core::Element* mCommandButtonContainer;
150  std::vector<Rocket::Core::Element*> mButtons;
151  BlinkButton mBlinkButton;
152  bool mIsSingleSelection;
153  boost::container::flat_map<uint32, bool> mIconFileExists;
154 
155 
156  };
157 
158 
159 //[-------------------------------------------------------]
160 //[ Namespace ]
161 //[-------------------------------------------------------]
162 } // em5
Definition: ActionPriority.h:13
Job proxy class.
Definition: JobProxy.h:51
Message parameters class.
Definition: MessageParameters.h:34
Map class.
Definition: Map.h:93
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
Abstract EMERGENCY 5 command base class.
Definition: Command.h:44
Message listener proxy class.
Definition: MessageProxy.h:47
static qsf::StringHash HELP_BUTTON_ID
Definition: CommandWindow.h:67
Definition: PickupPersonByParamedicAction.h:21
Ingame Graphical User Interface (GUI) context class.
Definition: GuiContext.h:62
EMERGENCY 5 selection manager class.
Definition: SelectionManager.h:42
boost::signals2::signal< void()> NumberOfActiveButtonsChanged
Definition: CommandWindow.h:60
Compile time string hash class.
Definition: StringHash.h:59
EMERGENCY 5 in-game command window.
Definition: CommandWindow.h:52
Commandable component class.
Definition: CommandableComponent.h:46