Leviathan  0.8.0.0
Leviathan game engine
Application.h
Go to the documentation of this file.
1 // Leviathan Game Engine
2 // Copyright (c) 2012-2017 Henri Hyyryläinen
3 #pragma once
4 // ------------------------------------ //
5 #include "Define.h"
6 // ------------------------------------ //
8 #include "Engine.h"
10 
11 namespace Leviathan {
12 
13 class NetworkInterface;
14 
17 public:
18  // creation and initialization //
20 
23 
25 
26  DLLEXPORT virtual bool Initialize(AppDef* configuration);
27 
30  DLLEXPORT void ForceRelease();
31 
34  DLLEXPORT virtual void StartRelease();
35 
39  DLLEXPORT void MarkAsClosing();
40 
41  // perform actions //
42  DLLEXPORT virtual int RunMessageLoop();
43  DLLEXPORT virtual void Render();
44  DLLEXPORT virtual bool PassCommandLine(int argcount, char* args[]);
45 
46  DLLEXPORT virtual void Tick(int mspassed);
47  DLLEXPORT virtual void PreFirstTick();
48 
49  // getting data from the class //
51  {
52  return Quit;
53  }
54 
56  {
57  return _Engine;
58  }
59 
61  {
63  }
64 
65 
69  DLLEXPORT void ClearTimers();
70 
71  // callback functions called during engine initialization at appropriate times //
72  DLLEXPORT virtual bool InitLoadCustomScriptTypes(asIScriptEngine* engine);
73 
74  DLLEXPORT virtual void CustomizeEnginePostLoad();
75  DLLEXPORT virtual void EnginePreShutdown();
76 
80  DLLEXPORT virtual std::shared_ptr<GameWorld> GetGameWorld(int id);
81 
82  DLLEXPORT virtual NETWORKED_TYPE GetProgramNetType() const = 0;
83 
84  // static access method for getting instance of this class //
86 
87  // Some dummy functions for ease of use //
89  DLLEXPORT static void DummyGameKeyConfigVariables(KeyConfiguration* keyconfigobj);
90 
91  // Utility functions //
92  DLLEXPORT static void StartServerProcess(
93  const std::string& processname, const std::string& commandline);
94 
96  DLLEXPORT static std::vector<std::string> CommandLineStringSplitter(
97  const char* str, std::vector<char*>& argcharstrings, bool addprogramname = true);
98 
99 protected:
102  DLLEXPORT virtual void Release();
103 
106  DLLEXPORT virtual void _InternalInit();
107 
108 
111 
114  virtual void _ShutdownApplicationPacketHandler() = 0;
115 
116 protected:
117  // ------------------------------------ //
118 
119  bool Quit = false;
120  bool ShouldQuit = false;
121 
123  bool QuitSometime = false;
124 
130 
131  // static part //
133 };
134 
135 
136 } // namespace Leviathan
137 
138 #ifdef LEAK_INTO_GLOBAL
140 #endif
virtual DLLEXPORT void EnginePreShutdown()
Allows the inherited object to be locked.
Definition: ThreadSafe.h:137
Holds key configuration for an application.
static DLLEXPORT void DummyGameConfigurationVariables(GameConfiguration *configobj)
static LeviathanApplication * Curapp
Definition: Application.h:132
virtual NetworkInterface * _GetApplicationPacketHandler()=0
Called in Initialize to get the derived packet handler type.
virtual DLLEXPORT int RunMessageLoop()
virtual DLLEXPORT NETWORKED_TYPE GetProgramNetType() const =0
virtual DLLEXPORT void _InternalInit()
virtual DLLEXPORT void Tick(int mspassed)
The main class of the Leviathan Game Engine.
Definition: Engine.h:34
virtual DLLEXPORT std::shared_ptr< GameWorld > GetGameWorld(int id)
Used to query a world for specific id.
DLLEXPORT void ForceRelease()
Used to immediately terminate the program.
Definition: Application.cpp:93
static DLLEXPORT std::vector< std::string > CommandLineStringSplitter(const char *str, std::vector< char * > &argcharstrings, bool addprogramname=true)
Splits a single string command line into arguments.
virtual DLLEXPORT void PreFirstTick()
virtual DLLEXPORT bool Initialize(AppDef *configuration)
Definition: Application.cpp:40
DLLEXPORT AppDef * GetDefinition()
Definition: Application.h:60
virtual DLLEXPORT ~LeviathanApplication()
Definition: Application.cpp:24
DLLEXPORT void MarkAsClosing()
Thread safely marks the game to close sometime.
virtual DLLEXPORT bool PassCommandLine(int argcount, char *args[])
virtual DLLEXPORT void Release()
Performs the final steps in the release process.
Definition: Application.cpp:56
NETWORKED_TYPE
Type of networked application.
Definition: CommonNetwork.h:22
virtual DLLEXPORT bool InitLoadCustomScriptTypes(asIScriptEngine *engine)
DLLEXPORT void ClearTimers()
Resets all time sensitive timers.
static DLLEXPORT void DummyGameKeyConfigVariables(KeyConfiguration *keyconfigobj)
virtual DLLEXPORT void StartRelease()
Safely releases the Application //.
Definition: Application.cpp:84
static DLLEXPORT void StartServerProcess(const std::string &processname, const std::string &commandline)
static DLLEXPORT LeviathanApplication * Get()
Definition: Application.cpp:33
DLLEXPORT Engine * GetEngine()
Definition: Application.h:55
virtual void _ShutdownApplicationPacketHandler()=0
#define DLLEXPORT
Definition: Include.h:84
Base class for all leviathan programs.
Definition: Application.h:16
virtual DLLEXPORT void CustomizeEnginePostLoad()
The access mask controls which registered functions and classes a script sees.
Definition: GameModule.h:12
Class that encapsulates common networking functionality that is required by all networked programs.
bool QuitSometime
This can be quickly set anywhere to quit sometime in the future.
Definition: Application.h:123
virtual DLLEXPORT void Render()