Emergency 20 Dokumentation  4.2.0
MenuBar.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/Export.h"
14 
15 #include <qsf/gui/GuiDocument.h>
17 #include <qsf/job/JobProxy.h>
18 
19 
20 //[-------------------------------------------------------]
21 //[ Forward declarations ]
22 //[-------------------------------------------------------]
23 namespace em5
24 {
25  namespace multiplayer
26  {
27  struct GameModeUpdateData;
28  }
29 }
30 
31 namespace Rocket
32 {
33  namespace Core
34  {
35  class ElementText;
36  }
37 }
38 
39 
40 //[-------------------------------------------------------]
41 //[ Namespace ]
42 //[-------------------------------------------------------]
43 namespace em5
44 {
45 
46 
47  //[-------------------------------------------------------]
48  //[ Classes ]
49  //[-------------------------------------------------------]
55  {
56 
57 
58  //[-------------------------------------------------------]
59  //[ Public methods ]
60  //[-------------------------------------------------------]
61  public:
62  explicit MenuBar(qsf::GuiContext& guiContext);
63  ~MenuBar();
64 
65  void rebuildGui();
66  void openBuyUpgradeWindow();
67  void showPauseSign(bool showPauseSign);
68  bool getAllowGameSpeedChanges() const;
69  void setAllowGameSpeedChanges(bool allowGameSpeedChanges);
70  void clickSpeed0();
71  void clickSpeed1();
72  void clickSpeed2();
73  void clickSpeed3();
74 
75  void updateBuyableButtonVisibility(bool visible = true);
76  void showBuyableBlinkText();
77  void hideBuyableBlinkText();
78 
79  void setShowCreditsInsteadOfScore(bool showCreditsInsteadOfScore);
80  void setCreditsScoreVisible(bool visible);
81  void setBuyButtonVisible(bool visible);
82 
83  void setCountdownTimer(qsf::Time countDownTime);
84  void showCountdownTimerElement(bool show);
85 
86 
87  //[-------------------------------------------------------]
88  //[ Public virtual qsf::GuiDocument methods ]
89  //[-------------------------------------------------------]
90  public:
91  virtual void processEvent(const std::string& eventKey, Rocket::Core::Event& event) override;
92 
93 
94  //[-------------------------------------------------------]
95  //[ Private virtual qsf::GuiDocument methods ]
96  //[-------------------------------------------------------]
97  private:
98  virtual bool onPreShow() override;
99  virtual void onPreHide() override;
100 
101 
102  //[-------------------------------------------------------]
103  //[ Private methods ]
104  //[-------------------------------------------------------]
105  private:
106  void setupGui();
107  void onReloadGui();
108  void onCreditsChanged();
109  void onScoreChanged();
110  void onGameSpeedChange(const qsf::MessageParameters& parameters);
111  void onFreeplayEventLevelChanged(const qsf::MessageParameters& parameters);
112  void updateTimeOfDay();
113  void changeGameSpeed(float gameSpeed);
114  void onGameModeDataChanged(const multiplayer::GameModeUpdateData& gameModeData);
115  void onUpdateBlink(const qsf::JobArguments& jobArguments);
116  void updateSpeedButtons(const Rocket::Core::Element* pressedButtonElement);
117  void onCreditsCounting(const qsf::JobArguments& jobArguments);
118  void onPointsCounting(const qsf::JobArguments& jobArguments);
119 
120 
121  //[-------------------------------------------------------]
122  //[ Private data ]
123  //[-------------------------------------------------------]
124  private:
125  bool mAllowGameSpeedChanges;
126  float mBlinkPhase;
127  qsf::MessageProxy mMessageProxyGameSpeed;
128  qsf::MessageProxy mMessageProxyCredits;
129  qsf::MessageProxy mMessageProxyScore;
130  qsf::MessageProxy mMessageProxyEventLevel;
131  qsf::JobProxy mUpdateJobProxy;
132  qsf::JobProxy mBlinkJobProxy;
133  qsf::JobProxy mAnimationJobProxyCredits;
134  qsf::JobProxy mAnimationJobProxyPoints;
135  uint32 mStartCountingPointsValue;
136  uint32 mStartCountingCreditsValue;
137  uint32 mEndCountingPointsValue;
138  uint32 mEndCountingCreditsValue;
139  bool mShowCreditsInsteadOfScore;
140  bool mCreditsScoreVisible;
141  bool mBuyButtonVisible;
142  bool mTimeOfDayMode;
143  std::string mDisplayedTimeOfDay;
144  std::string mDisplayedFreeplayTime;
145  qsf::Time mOldCountDownTime;
146 
147  // 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 menubar was still there but the menubar instance was destroyed
148  // Proper fix see QSF Bug "H301 GUI | "qsf::GuiDocument" | We need to guarantee that for each e.g. "onPostShow()" there's a "onPostHide()""
149  boost::signals2::connection mReloadGuiConnection;
150 
151  // EM20 specific
152  Rocket::Core::Element* mMissionNameElement;
153  Rocket::Core::ElementText* mMissionNameTextElement;
154 
155  Rocket::Core::Element* mMissionDifficultyElement;
156  Rocket::Core::ElementText* mMissionDifficultyTextElement;
157 
158 
159  };
160 
161 
162 //[-------------------------------------------------------]
163 //[ Namespace ]
164 //[-------------------------------------------------------]
165 } // em5
Definition: ActionPriority.h:13
Job proxy class.
Definition: JobProxy.h:51
Message parameters class.
Definition: MessageParameters.h:34
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
Message listener proxy class.
Definition: MessageProxy.h:47
Definition: OperationMessages.h:346
Job arguments class: holds data to be passed to the called job method by the job manager.
Definition: JobArguments.h:40
EMERGENCY 5 in-game information bar.
Definition: MenuBar.h:54
Ingame Graphical User Interface (GUI) context class.
Definition: GuiContext.h:62
Data type for encapsulating time information. It might represents points in time and time spans...
Definition: Time.h:32