OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4Application.h
Go to the documentation of this file.
1 /*
2  * OpenClonk, http://www.openclonk.org
3  *
4  * Copyright (c) 1998-2000, Matthes Bender
5  * Copyright (c) 2001-2009, RedWolf Design GmbH, http://www.clonk.de/
6  * Copyright (c) 2009-2016, The OpenClonk Team and contributors
7  *
8  * Distributed under the terms of the ISC license; see accompanying file
9  * "COPYING" for details.
10  *
11  * "Clonk" is a registered trademark of Matthes Bender, used with permission.
12  * See accompanying file "TRADEMARK" for details.
13  *
14  * To redistribute this file separately, substitute the full license texts
15  * for the above references.
16  */
17 
18 #ifndef INC_C4Application
19 #define INC_C4Application
20 
21 #include "c4group/C4Group.h"
22 #include "platform/C4MusicSystem.h"
23 #include "platform/C4SoundSystem.h"
24 #include "c4group/C4Components.h"
26 #include "platform/C4App.h"
27 
29 
30 /* Main class to initialize configuration and execute the game */
31 
33 {
34 public:
35  C4Application();
37  // Flag for restarting the engine at the end
39  // main System.ocg in working folder
44  // Thread for interactive processes (automatically starts as needed)
46  // IRC client for global chat
48  // clear app
49  void Clear();
50  void ClearCommandLine();
51  // Tick timing
52  void GameTick();
53  void Draw();
54  // System.ocg helper funcs
55  bool OpenSystemGroup() { return SystemGroup.IsOpen() || SystemGroup.Open(C4CFN_System); }
56  void CloseSystemGroup() { SystemGroup.Close(); }
57  void SetGameTickDelay(int iDelay);
58  virtual void OnResolutionChanged(unsigned int iXRes, unsigned int iYRes);
59  virtual void OnKeyboardLayoutChanged();
60  bool SetGameFont(const char *szFontFace, int32_t iFontSize);
61  void NextTick();
62 
63  virtual void Quit();
64  void OpenGame(const char * scenario = 0); // start game in the next main loop round
65  void QuitGame(); // quit game, and application if in fullscreen without startup
66  void Activate(); // activate app to gain full focus in OS
67  void SetNextMission(const char *szMissionFilename);
68  virtual void OnCommand(const char *szCmd);
69 
70  bool IsQuittingGame() const { return AppState >= C4AS_AfterGame; }
71 
72  const char *GetRevision() const { return Revision.c_str(); }
73 
74  // set by ParseCommandLine
75  int isEditor;
76  // set by ParseCommandLine, for manually applying downloaded update packs
77  std::string IncomingUpdate;
78  // set by ParseCommandLine, for manually invoking an update check by command line or url
80 
81  bool FullScreenMode();
84 
85 protected:
88 
89  virtual bool DoInit(int argc, char * argv[]);
90  void ParseCommandLine(int argc, char * argv[]);
91  bool PreInit();
92  static bool ProcessCallback(const char *szMessage, int iProcess);
94 
95  // set by ParseCommandLine, if neither editor, scenario nor direct join adress has been specified
97  // set by ParseCommandLine, for installing registration keys
98  std::string IncomingKeyfile;
99 private:
100  // if set, this mission will be launched next
101  std::string NextMission;
102  // version information strings
103  static const std::string Revision;
104 };
105 
107 
109 {
110 public:
112 private:
113  C4TimeMilliseconds tLastGameTick;
114  unsigned int iGameTickDelay;
115  unsigned int iExtraGameTickDelay;
116 public:
117  void SetGameTickDelay(uint32_t iDelay);
118 
119  virtual bool Execute(int iTimeout, pollfd *);
120  virtual bool IsLowPriority();
121 };
122 
123 #endif
C4SoundSystem SoundSystem
Definition: C4Application.h:42
C4Config Config
Definition: C4Config.cpp:837
virtual void OnResolutionChanged(unsigned int iXRes, unsigned int iYRes)
virtual bool IsLowPriority()
void SetGameTickDelay(uint32_t iDelay)
virtual void OnCommand(const char *szCmd)
const char * GetRevision() const
Definition: C4Application.h:72
enum C4Application::State AppState
virtual void OnKeyboardLayoutChanged()
bool OpenSystemGroup()
Definition: C4Application.h:55
C4ConfigGraphics Graphics
Definition: C4Config.h:254
virtual void Quit()
bool IsOpen() const
Definition: C4Group.cpp:1891
C4ApplicationGameTimer * pGameTimer
Definition: C4Application.h:87
bool Open(const char *szGroupName, bool fCreate=false)
Definition: C4Group.cpp:514
std::string IncomingUpdate
Definition: C4Application.h:77
bool SetGameFont(const char *szFontFace, int32_t iFontSize)
int32_t WindowX
Definition: C4Config.h:105
#define CStdMultimediaTimerProc
Definition: StdScheduler.h:220
bool Close()
Definition: C4Group.cpp:755
static bool ProcessCallback(const char *szMessage, int iProcess)
virtual bool DoInit(int argc, char *argv[])
C4Application Application
Definition: C4Globals.cpp:44
void ParseCommandLine(int argc, char *argv[])
int GetConfigWidth()
Definition: C4Application.h:82
void CloseSystemGroup()
Definition: C4Application.h:56
bool IsQuittingGame() const
Definition: C4Application.h:70
int32_t WindowY
Definition: C4Config.h:105
void SetGameTickDelay(int iDelay)
int32_t ResX
Definition: C4Config.h:104
virtual bool Execute(int iTimeout, pollfd *)
int32_t ResY
Definition: C4Config.h:104
std::string IncomingKeyfile
Definition: C4Application.h:98
void ClearCommandLine()
int GetConfigHeight()
Definition: C4Application.h:83
#define C4CFN_System
Definition: C4Components.h:29
void ApplyResolutionConstraints()
C4GamePadControl * pGamePadControl
Definition: C4Application.h:43
void SetNextMission(const char *szMissionFilename)
C4Group SystemGroup
Definition: C4Application.h:40
C4InteractiveThread InteractiveThread
Definition: C4Application.h:45
C4Network2IRCClient & IRCClient
Definition: C4Application.h:47
void OpenGame(const char *scenario=0)
C4MusicSystem MusicSystem
Definition: C4Application.h:41