Emergency 20 Dokumentation  4.2.0
Application.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 
16 
19 
20 
21 //[-------------------------------------------------------]
22 //[ Forward declarations ]
23 //[-------------------------------------------------------]
24 namespace em5
25 {
26  class EmergencyGui;
27  class Game;
28  class NetworkManager;
29  class PlayerProgress;
30  class AccountManager;
31  class ContentAuthentication;
32 }
33 namespace qsf
34 {
35  class Map;
36  struct LogMessage;
37  namespace game
38  {
39  class StoreManager;
40  }
41 }
42 #ifdef QSF_PROFILING
43  namespace qsf
44  {
45  class ProfilingOverlay;
46  }
47 #endif
48 
49 
50 //[-------------------------------------------------------]
51 //[ Namespace ]
52 //[-------------------------------------------------------]
53 namespace em5
54 {
55 
56 
57  //[-------------------------------------------------------]
58  //[ Classes ]
59  //[-------------------------------------------------------]
65  {
66 
67 
68  //[-------------------------------------------------------]
69  //[ Friends ]
70  //[-------------------------------------------------------]
71  friend class StartMenuInstalled;
72 
73 
74  //[-------------------------------------------------------]
75  //[ Public definitions ]
76  //[-------------------------------------------------------]
77  public:
78  static const uint32 APPLICATION_ID;
79  static const std::string LAUNCHER_EXE_PATH;
80 
82  {
84  std::string mMapLocalAssetName;
86  std::string mGuiDocument;
89  };
90 
91 
92  //[-------------------------------------------------------]
93  //[ Public methods ]
94  //[-------------------------------------------------------]
95  public:
100  Application();
101 
106  virtual ~Application();
107 
112  std::string getUpdaterApplicationName() const;
113 
121  inline const boost::property_tree::ptree& getCustomizedParametersPTree() const;
122 
123  //[-------------------------------------------------------]
124  //[ Managers and sub-systems ]
125  //[-------------------------------------------------------]
133  inline Game& getGame() const;
134 
142  inline EmergencyGui& getGui() const;
143 
151  inline EmergencyGui* tryGetGui() const;
152 
160  inline NetworkManager& getNetworkManager() const;
161 
169  inline PlayerProgress& getPlayerProgress() const;
170 
178  inline AccountManager& getAccountManager() const;
179 
187  inline ContentAuthentication& getContentAuthentication() const;
188 
196  inline qsf::game::StoreManager& getStoreManager() const;
197 
198  //[-------------------------------------------------------]
199  //[ Application state ]
200  //[-------------------------------------------------------]
205  inline bool isInStartMenu() const;
206 
211  void triggerGotoLogoScreen();
212 
217  void triggerGotoMainMenu();
218 
226  void triggerStartGame();
227 
232  void triggerStopGame();
233 
234  //[-------------------------------------------------------]
235  //[ Misc ]
236  //[-------------------------------------------------------]
237  // Cheats
238  inline bool areCheatsEnabled() const;
239  void enableCheats();
240 
245  bool areRewardsEnabled() const;
246 
251  std::string getLauncherChecksum() const;
252 
257  bool getSkipStartMenu() const;
258 
259  void showDebugVersionInformation(bool show);
260 
261 #ifdef QSF_PROFILING
262 
266  void toggleProfilingOverlay();
267 #endif
268 
269 
270  //[-------------------------------------------------------]
271  //[ Public virtual qsf::Application methods ]
272  //[-------------------------------------------------------]
273  public:
274  virtual uint32 getId() override;
275 
276 
277  //[-------------------------------------------------------]
278  //[ Protected virtual qsf::Application methods ]
279  //[-------------------------------------------------------]
280  protected:
281  //[-------------------------------------------------------]
282  //[ Lifecycle ]
283  //[-------------------------------------------------------]
284  virtual bool onStartup() override;
285  virtual int onRun() override;
286  virtual void onShutdown() override;
287 
288 
289  //[-------------------------------------------------------]
290  //[ Protected virtual qsf::WindowApplication methods ]
291  //[-------------------------------------------------------]
292  protected:
293  virtual void getWindowSize(bool& fullscreen, uint32& width, uint32& height) override;
294  virtual void onRenderWindowFirstPreShow() override;
295  virtual void setDefaultWindowIcon() override;
296 
297 
298  //[-------------------------------------------------------]
299  //[ Protected virtual qsf::game::GameApplication methods ]
300  //[-------------------------------------------------------]
301  protected:
302  virtual void onVersionJsonLoaded(const boost::property_tree::ptree& pTree) override;
303 
304 
305  //[-------------------------------------------------------]
306  //[ Private methods ]
307  //[-------------------------------------------------------]
308  private:
309  bool runLoopContent();
310 
311  void setupLanguage();
312  void showMainMenu();
313  void stopMainMenuBackgroundMusic();
314  void showStopGameScreen();
315 
323  void startGame();
324 
329  void stopGame();
330 
335  void updateApplication();
336 
341  void setLoadingScreenPercentage(float percentage);
342 
350  void onMapLoadingProgress(float progress);
351 
352  // Uncommented
353  bool calculateLauncherChecksum();
354  std::string selectLoadingScreenImage() const;
355 
356  void onLauncherFinished();
357 
358  void mountMods(const std::string& installationVersion);
359 
360  // For configuration by "em5::StartMenuInstalled"
361  void disableEM20Project();
362 
363 
364  //[-------------------------------------------------------]
365  //[ Private definitions ]
366  //[-------------------------------------------------------]
367  private:
368  enum Instruction
369  {
370  INSTRUCTION_NONE = 0,
371  INSTRUCTION_GOTO_LOGO_SCREEN,
372  INSTRUCTION_GOTO_MAIN_MENU,
373  INSTRUCTION_START_GAME,
374  INSTRUCTION_STOP_GAME,
375  INSTRUCTION_EXIT_APPLICATION
376  };
377 
378 
379  //[-------------------------------------------------------]
380  //[ Private data ]
381  //[-------------------------------------------------------]
382  private:
383  bool mIsInStartMenu;
384  std::string mUpdaterAppNamePrefix;
385  std::string mOldLanguage;
386  qsf::Time mLastLoadingScreenPercentageUpdate;
387 
388  // Instructions
389  Instruction mCurrentInstruction;
390  std::string mInstructionParameter;
391 
392  // Settings
393  StartupSettings mStartupSettings;
394  boost::property_tree::ptree mCustomizedParametersPTree;
395 
396  // Managers and sub-systems
397  Game* mGame;
398  EmergencyGui* mGui;
399  NetworkManager& mNetworkManager;
400  PlayerProgress& mPlayerProgress;
401  AccountManager& mAccountManager;
402  ContentAuthentication& mContentAuthentication;
403  qsf::game::StoreManager& mStoreManager;
404  qsf::Map* mMainMenuMap;
405 
406  // Checksum
407  std::string mLauncherChecksum;
408 
409  // Others
410  bool mShowModResetWarning;
411 
412  // Debug & profiling
413  qsf::DebugDrawProxy mVersionDrawProxy;
414  bool mCheatsEnabled;
415  #ifdef QSF_PROFILING
416  qsf::ProfilingOverlay& mProfilingOverlay; // TODO(fw): Hmm, maybe it's not the best place here
417  #endif
418 
419 
420  //[-------------------------------------------------------]
421  //[ CAMP reflection system ]
422  //[-------------------------------------------------------]
423  QSF_CAMP_RTTI() // Only adds the virtual method "campClassId()", nothing more
424 
425 
426  };
427 
428 
429 //[-------------------------------------------------------]
430 //[ Namespace ]
431 //[-------------------------------------------------------]
432 } // em5
433 
434 
435 //[-------------------------------------------------------]
436 //[ Implementation ]
437 //[-------------------------------------------------------]
439 
440 
441 //[-------------------------------------------------------]
442 //[ CAMP reflection system ]
443 //[-------------------------------------------------------]
Definition: ActionPriority.h:13
bool mStartMultiplayerHost
"true" = create multiplayer host session, "false" = create a multiplayer client with a local host ...
Definition: Application.h:87
std::string mMapLocalAssetName
Definition: Application.h:84
Map class.
Definition: Map.h:93
static const std::string LAUNCHER_EXE_PATH
"/bin/em5_launcher.exe"
Definition: Application.h:79
unsigned int uint32
Definition: PlatformTypes.h:181
#define EM5_API_EXPORT
Definition: Export.h:28
EMERGENCY 5 game class.
Definition: Game.h:79
static const uint32 APPLICATION_ID
"em5::Application" unique ID
Definition: Application.h:78
EMERGENCY 5 application implementation.
Definition: Application.h:64
EMERGENCY 5 player progress class.
Definition: PlayerProgress.h:57
bool mSkipStartMenu
Definition: Application.h:88
bool mMapAlreadyLoaded
Definition: Application.h:83
Definition: PickupPersonByParamedicAction.h:21
Game application base class.
Definition: GameApplication.h:36
Unique instance interface.
Definition: UniqueInstance.h:34
Debug draw proxy class.
Definition: DebugDrawProxy.h:46
#define QSF_CAMP_RTTI()
Only adds the virtual method "campClassId()", nothing more.
Definition: CampClass.h:75
EMERGENCY 5 GUI instance to handle the game-specific user interface.
Definition: EmergencyGui.h:84
Store manager class managing in-app-purchases on platforms supporting this.
Definition: StoreManager.h:49
#define QSF_CAMP_TYPE_NONCOPYABLE(type)
See "CAMP_TYPE_NONCOPYABLE" for details.
Definition: CampClass.h:112
Definition: DensityCalculator.h:29
EMERGENCY 5 network manager class.
Definition: AccountManager.h:78
Definition: Application.h:81
Content authentication class.
Definition: ContentAuthentication.h:32
EMERGENCY 5 start menu installed GUI.
Definition: StartMenuInstalled.h:32
std::string mGuiDocument
Definition: Application.h:86
EMERGENCY 5 network manager class.
Definition: NetworkManager.h:63
uint32 mMainEventNumber
Definition: Application.h:85
Data type for encapsulating time information. It might represents points in time and time spans...
Definition: Time.h:32