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
- Modules
- 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 "GDCpp/RuntimeVariablesContainer.h"
11 #include <vector>
12 #include <string>
13 #include <map>
14 #include <SFML/System.hpp>
15 #include <boost/shared_ptr.hpp>
16 #include "GDCpp/ObjInstancesHolder.h"
17 namespace sf { class RenderWindow; }
18 namespace sf { class Event; }
19 namespace gd { class Project; }
20 namespace gd { class Object; }
21 namespace gd { class ImageManager; }
22 class CppPlatform;
23 class RuntimeLayer;
24 class RuntimeGame;
25 class AutomatismsRuntimeSharedData;
26 class ExtensionBase;
27 class Text;
28 class CodeExecutionEngine;
29 class ManualTimer;
30 #undef GetObject //Disable an annoying macro
31
32 #if defined(GD_IDE_ONLY)
33 class BaseDebugger;
34 class BaseProfiler;
35 #endif
36
46 class GD_API RuntimeScene : public Scene
47 {
48 public:
49 RuntimeScene(sf::RenderWindow * renderWindow_, RuntimeGame * game_);
50 virtual ~RuntimeScene();
51
52 RuntimeScene& operator=(const RuntimeScene & scene);
53 RuntimeScene(const RuntimeScene & scene);
54
55 sf::RenderWindow * renderWindow;
56 RuntimeGame * game;
57 #if defined(GD_IDE_ONLY)
58 BaseDebugger * debugger;
59 #endif
60 ObjInstancesHolder objectsInstances;
61 std::vector < ManualTimer > timers;
62 bool running;
63
67 inline const RuntimeVariablesContainer & GetVariables() const { return variables; }
68
72 inline RuntimeVariablesContainer & GetVariables() { return variables; }
73
78 boost::shared_ptr<gd::ImageManager> GetImageManager() const;
79
83 RuntimeLayer & GetRuntimeLayer(const std::string & name);
84
89 void DisplayText(Text & text);
90
95 const boost::shared_ptr<AutomatismsRuntimeSharedData> & GetAutomatismSharedDatas(const std::string & automatismName) const { return automatismsSharedDatas.find(automatismName)->second; }
96
104 bool LoadFromScene( const gd::Layout & scene );
105
111 bool LoadFromSceneAndCustomInstances( const gd::Layout & scene, const gd::InitialInstancesContainer & instances );
112
121 void CreateObjectsFrom(const gd::InitialInstancesContainer & container, float xOffset = 0, float yOffset = 0, std::map<const gd::InitialInstance *, boost::shared_ptr<RuntimeObject> > * optionalMap = NULL);
122
126 void ChangeRenderWindow(sf::RenderWindow * window);
127
131 bool RenderWindowIsFullScreen() { return isFullScreen; }
132
136 void SetRenderWindowIsFullScreen(bool yes = true) { isFullScreen = yes; }
137
141 bool RenderWindowHasFocus() { return windowHasFocus; }
142
147 void GotoSceneWhenEventsAreFinished(int scene);
148
153 int RenderAndStep();
154
158 void RenderWithoutStep();
159
163 inline void SetTimeScale(double timeScale_) { timeScale = timeScale_; };
164
168 inline double GetTimeScale() const { return timeScale; };
169
173 inline signed long long GetElapsedTime() const { return elapsedTime; };
174
178 inline signed long long GetTimeFromStart() const { return timeFromStart; };
179
183 inline bool IsFirstLoop() const { return firstLoop; };
184
189 void NotifyPauseWasMade(signed long long pauseTime_) { pauseTime += pauseTime_; }
190
191 void ManageRenderTargetEvents();
192
196 bool OrderObjectsByZOrder( RuntimeObjList & objList );
197
201 const std::vector<sf::Event> & GetRenderTargetEvents() const { return renderTargetEvents; }
202
203 #if defined(GD_IDE_ONLY)
204
211 std::vector<sf::Event> & GetRenderTargetEvents() { return renderTargetEvents; }
212 #endif
213
217
222 boost::shared_ptr<CodeExecutionEngine> GetCodeExecutionEngine() const { return codeExecutionEngine; }
223
228 void SetCodeExecutionEngine(boost::shared_ptr<CodeExecutionEngine> codeExecutionEngine_) { codeExecutionEngine = codeExecutionEngine_; }
230
231
232 protected:
233
237 void Render();
238 void ManageObjectsBeforeEvents();
239 void ManageObjectsAfterEvents();
240 bool UpdateTime();
241
242 bool firstLoop;
243 bool isFullScreen;
244 std::vector<sf::Event> renderTargetEvents;
245 signed int realElapsedTime;
246 signed int elapsedTime;
247 double timeScale;
248 signed long long timeFromStart;
249 signed long long pauseTime;
250 int specialAction;
251 RuntimeVariablesContainer variables;
252 std::vector < ExtensionBase * > extensionsToBeNotifiedOnObjectDeletion;
253 sf::Clock clock;
254 bool windowHasFocus;
255 std::map < std::string, boost::shared_ptr<AutomatismsRuntimeSharedData> > automatismsSharedDatas;
256 std::vector < RuntimeLayer > layers;
257 boost::shared_ptr<CodeExecutionEngine> codeExecutionEngine;
258 CppPlatform * platform;
259
260 std::vector < Text > textes;
261 bool DisplayLegacyTexts(std::string layer = "");
262
263 void Init(const RuntimeScene & scene);
264
265 static RuntimeLayer badRuntimeLayer;
266 };
267
268 #endif // RUNTIMESCENE_H
269