Game Develop C++ Platform: RuntimeScene.h Source File

| Game Develop C++ Platform Platform for developing native games based on OpenGL and SFML with Game Develop

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Groups Pages
RuntimeScene.h
Go to the documentation of this file.
1
6 #ifndef RUNTIMESCENE_H
7 #define RUNTIMESCENE_H
8
9 #include "GDCpp/Scene.h" //This include must be placed first
10 #include <vector>
11 #include <string>
12 #include <map>
13 #include <SFML/System.hpp>
14 #include <boost/shared_ptr.hpp>
15 #include "GDCpp/ObjInstancesHolder.h"
16 namespace sf { class RenderWindow; }
17 namespace sf { class Event; }
18 namespace gd { class Project; }
19 namespace gd { class Object; }
20 class CppPlatform;
21 class RuntimeLayer;
22 class AutomatismsRuntimeSharedData;
23 class ExtensionBase;
24 class Text;
25 class CodeExecutionEngine;
26 class ManualTimer;
27 #undef GetObject //Disable an annoying macro
28
29 #if defined(GD_IDE_ONLY)
30 class BaseDebugger;
31 class BaseProfiler;
32 #endif
33
43 class GD_API RuntimeScene : public Scene
44 {
45 public:
46 RuntimeScene(sf::RenderWindow * renderWindow_, gd::Project * game_);
47 virtual ~RuntimeScene();
48
49 RuntimeScene& operator=(const RuntimeScene & scene);
50 RuntimeScene(const RuntimeScene & scene);
51
52 sf::RenderWindow * renderWindow;
53 gd::Project * game;
54 #if defined(GD_IDE_ONLY)
55 BaseDebugger * debugger;
56 #endif
57 ObjInstancesHolder objectsInstances;
58 std::vector < ManualTimer > timers;
59 bool running;
60
64 inline const gd::VariablesContainer & GetVariables() const { return variables; }
65
69 inline gd::VariablesContainer & GetVariables() { return variables; }
70
74 RuntimeLayer & GetRuntimeLayer(const std::string & name);
75
80 void DisplayText(Text & text);
81
86 const boost::shared_ptr<AutomatismsRuntimeSharedData> & GetAutomatismSharedDatas(const std::string & automatismName) const { return automatismsSharedDatas.find(automatismName)->second; }
87
95 bool LoadFromScene( const gd::Layout & scene );
96
102 bool LoadFromSceneAndCustomInstances( const gd::Layout & scene, const gd::InitialInstancesContainer & instances );
103
112 void CreateObjectsFrom(const gd::InitialInstancesContainer & container, float xOffset = 0, float yOffset = 0, std::map<const gd::InitialInstance *, boost::shared_ptr<RuntimeObject> > * optionalMap = NULL);
113
117 void ChangeRenderWindow(sf::RenderWindow * window);
118
122 bool RenderWindowIsFullScreen() { return isFullScreen; }
123
127 void SetRenderWindowIsFullScreen(bool yes = true) { isFullScreen = yes; }
128
132 bool RenderWindowHasFocus() { return windowHasFocus; }
133
138 void GotoSceneWhenEventsAreFinished(int scene);
139
144 int RenderAndStep();
145
149 void RenderWithoutStep();
150
154 inline void SetTimeScale(double timeScale_) { timeScale = timeScale_; };
155
159 inline double GetTimeScale() const { return timeScale; };
160
164 inline signed long long GetElapsedTime() const { return elapsedTime; };
165
169 inline signed long long GetTimeFromStart() const { return timeFromStart; };
170
174 inline bool IsFirstLoop() const { return firstLoop; };
175
180 void NotifyPauseWasMade(signed long long pauseTime_) { pauseTime += pauseTime_; }
181
182 void ManageRenderTargetEvents();
183
187 bool OrderObjectsByZOrder( RuntimeObjList & objList );
188
192 const std::vector<sf::Event> & GetRenderTargetEvents() const { return renderTargetEvents; }
193
194 #if defined(GD_IDE_ONLY)
195
202 std::vector<sf::Event> & GetRenderTargetEvents() { return renderTargetEvents; }
203 #endif
204
208
213 boost::shared_ptr<CodeExecutionEngine> GetCodeExecutionEngine() const { return codeExecutionEngine; }
214
219 void SetCodeExecutionEngine(boost::shared_ptr<CodeExecutionEngine> codeExecutionEngine_) { codeExecutionEngine = codeExecutionEngine_; }
221
222
223 protected:
224
228 void Render();
229 void ManageObjectsBeforeEvents();
230 void ManageObjectsAfterEvents();
231 bool UpdateTime();
232
233 bool firstLoop;
234 bool isFullScreen;
235 std::vector<sf::Event> renderTargetEvents;
236 signed int realElapsedTime;
237 signed int elapsedTime;
238 double timeScale;
239 signed long long timeFromStart;
240 signed long long pauseTime;
241 int specialAction;
242 gd::VariablesContainer variables;
243 std::vector < ExtensionBase * > extensionsToBeNotifiedOnObjectDeletion;
244 sf::Clock clock;
245 bool windowHasFocus;
246 std::map < std::string, boost::shared_ptr<AutomatismsRuntimeSharedData> > automatismsSharedDatas;
247 std::vector < RuntimeLayer > layers;
248 boost::shared_ptr<CodeExecutionEngine> codeExecutionEngine;
249 CppPlatform * platform;
250
251 std::vector < Text > textes;
252 bool DisplayLegacyTexts(std::string layer = "");
253
254 void Init(const RuntimeScene & scene);
255
256 static RuntimeLayer badRuntimeLayer;
257 };
258
259 #endif // RUNTIMESCENE_H
260