Game Develop Core: Layout.h Source File

| Game Develop Core Core library for developing platforms and tools compatible with Game Develop.

- Main Page
- Modules
- Classes

- File List
- File Members

All Classes Files Functions Variables Typedefs Enumerations Macros Groups Pages
Layout.h
Go to the documentation of this file.
1
6 #ifndef GDCORE_LAYOUT_H
7 #define GDCORE_LAYOUT_H
8 #include <string>
9 #include <vector>
10 #include <map>
11 #include <boost/shared_ptr.hpp>
12 #include "GDCore/PlatformDefinition/ObjectGroup.h"
13 #include "GDCore/PlatformDefinition/ClassWithObjects.h"
14 #include "GDCore/PlatformDefinition/AutomatismsSharedData.h"
15 #include "GDCore/PlatformDefinition/VariablesContainer.h"
16 #include "GDCore/PlatformDefinition/InitialInstancesContainer.h"
17 #include "GDCore/PlatformDefinition/Layer.h"
18 #if defined(GD_IDE_ONLY)
19 #if !defined(GD_NO_WX_GUI)
20 #include "GDCore/IDE/Dialogs/LayoutEditorCanvas/LayoutEditorCanvasOptions.h"
21 #endif
22 namespace gd { class BaseEvent; }
23 namespace gd { typedef boost::shared_ptr<BaseEvent> BaseEventSPtr; }
24 #endif
25 namespace gd { class BaseEvent; }
26 namespace gd { class Object; }
27 namespace gd { class Project; }
28 namespace gd { class InitialInstancesContainer; }
29 class TiXmlElement;
30 class BaseProfiler;
31 #undef GetObject //Disable an annoying macro
32
33 namespace gd
34 {
35
41 class GD_CORE_API Layout : public ClassWithObjects
42 {
43 public:
44 Layout();
45 Layout(const Layout&);
46 virtual ~Layout();
47 Layout& operator=(const Layout & rhs);
48
58 Layout * Clone() const { return new Layout(*this); };
59
63
68 void SetName(const std::string & name_);
69
73 const std::string & GetName() const {return name;};
74
78 const std::string & GetMangledName() const {return mangledName;};
79
83 void SetBackgroundColor(unsigned int r, unsigned int g, unsigned int b) { backgroundColorR = r; backgroundColorG = g; backgroundColorB = b; }
84
88 unsigned int GetBackgroundColorRed() const { return backgroundColorR; }
89
93 unsigned int GetBackgroundColorGreen() const { return backgroundColorG; }
94
98 unsigned int GetBackgroundColorBlue() const { return backgroundColorB; }
99
103 const std::string & GetWindowDefaultTitle() const {return title;};
104
108 void SetWindowDefaultTitle(const std::string & title_) {title = title_;};
109
111
115
119 const gd::InitialInstancesContainer & GetInitialInstances() const { return initialInstances; }
120
124 gd::InitialInstancesContainer & GetInitialInstances() { return initialInstances; }
126
130
132 #if defined(GD_IDE_ONLY)
133
136 const std::vector<boost::shared_ptr<gd::BaseEvent> > & GetEvents() const { return events; }
137
141 std::vector<boost::shared_ptr<gd::BaseEvent> > & GetEvents() { return events; }
142 #endif
143
148
153 std::vector <ObjectGroup> & GetObjectGroups() { return objectGroups; }
154
158 const std::vector <ObjectGroup> & GetObjectGroups() const { return objectGroups; }
159
161
165
171 inline const gd::VariablesContainer & GetVariables() const { return variables; }
172
177 inline gd::VariablesContainer & GetVariables() { return variables; }
178
180
184
189 bool HasLayerNamed(const std::string & name) const;
190
194 Layer & GetLayer(const std::string & name);
195
199 const Layer & GetLayer(const std::string & name) const;
200
204 Layer & GetLayer(unsigned int index);
205
209 const Layer & GetLayer (unsigned int index) const;
210
214 unsigned int GetLayerPosition(const std::string & name) const;
215
219 unsigned int GetLayersCount() const;
220
224 void InsertNewLayer(const std::string & name, unsigned int position);
225
232 void InsertLayer(const Layer & theLayer, unsigned int position);
233
237 void RemoveLayer(const std::string & name);
238
242 void SwapLayers(unsigned int firstLayerIndex, unsigned int secondLayerIndex);
244
253 void UpdateAutomatismsSharedData(gd::Project & project);
254
255 #if defined(GD_IDE_ONLY) && !defined(GD_NO_WX_GUI)
256
260 const gd::LayoutEditorCanvasOptions & GetAssociatedLayoutEditorCanvasOptions() const { return associatedSettings; }
261
266 gd::LayoutEditorCanvasOptions & GetAssociatedLayoutEditorCanvasOptions() { return associatedSettings; }
267 #endif
268
271
275 void DisableInputWhenFocusIsLost(bool disable = true) { disableInputWhenNotFocused = disable; }
276
280 bool IsInputDisabledWhenFocusIsLost() { return disableInputWhenNotFocused; }
281
285 void SetStandardSortMethod(bool enable = true) { standardSortMethod = enable; }
286
290 bool StandardSortMethod() const { return standardSortMethod; }
291
295 void SetStopSoundsOnStartup(bool enable = true) { stopSoundsOnStartup = enable; }
296
300 bool StopSoundsOnStartup() const { return stopSoundsOnStartup; }
301
305 void SetOpenGLFOV(float oglFOV_) { oglFOV = oglFOV_; }
306
310 float GetOpenGLFOV() const { return oglFOV; }
311
315 void SetOpenGLZNear(float oglZNear_) { oglZNear = oglZNear_; }
316
320 float GetOpenGLZNear() const { return oglZNear; }
321
325 void SetOpenGLZFar(float oglZFar_) { oglZFar = oglZFar_; }
326
330 float GetOpenGLZFar() const { return oglZFar; }
332
336
341 void SaveToXml(TiXmlElement * element) const;
342
346 void LoadFromXml(gd::Project & project, const TiXmlElement * element);
348
349 //TODO: Send this to private part.
350 std::map < std::string, boost::shared_ptr<gd::AutomatismsSharedData> > automatismsInitialSharedDatas;
351
352 //TODO: GD C++ Platform specific code below
353 #if defined(GD_IDE_ONLY)
354
359
369 void SetCompilationNeeded() { compilationNeeded = true; };
370
374 void SetCompilationNotNeeded() { compilationNeeded = false; };
375
381 bool CompilationNeeded() { return compilationNeeded; };
382
383 const std::string & GetCompiledEventsFile() const { return compiledEventsFile; }
384 void SetCompiledEventsFile(const std::string & file) { compiledEventsFile = file; }
385
387
392
398 bool RefreshNeeded() const { return refreshNeeded; }
399
404 void SetRefreshNeeded() { refreshNeeded = true; }
405
409 void SetRefreshNotNeeded() { refreshNeeded = false; }
411
415 BaseProfiler * GetProfiler() const { return profiler; };
416
420 void SetProfiler(BaseProfiler * profiler_) { profiler = profiler_; };
421 #endif
422
423 private:
424 std::string name;
425 std::string mangledName;
426 unsigned int backgroundColorR;
427 unsigned int backgroundColorG;
428 unsigned int backgroundColorB;
429 std::string title;
430 gd::VariablesContainer variables;
431 gd::InitialInstancesContainer initialInstances;
432 std::vector < gd::Layer > initialLayers;
433 std::vector<ObjectGroup> objectGroups;
434 bool stopSoundsOnStartup;
435 bool standardSortMethod;
436 float oglFOV;
437 float oglZNear;
438 float oglZFar;
439 bool disableInputWhenNotFocused;
440 static gd::Layer badLayer;
441 #if defined(GD_IDE_ONLY)
442 std::vector < gd::BaseEventSPtr > events;
443 #endif
444 #if defined(GD_IDE_ONLY) && !defined(GD_NO_WX_GUI)
445 gd::LayoutEditorCanvasOptions associatedSettings;
446 #endif
447
448 //TODO: GD C++ Platform specific code below
449 #if defined(GD_IDE_ONLY)
450 BaseProfiler * profiler;
451 bool refreshNeeded;
452 bool compilationNeeded;
453 std::string compiledEventsFile;
454 #endif
455
460 void Init(const gd::Layout & other);
461 };
462
467 struct LayoutHasName : public std::binary_function<boost::shared_ptr<Layout>, std::string, bool> {
468 bool operator()(const boost::shared_ptr<Layout> & layout, std::string name) const { return layout->GetName() == name; }
469 };
470
477 std::string GD_CORE_API GetTypeOfObject(const Project & game, const Layout & layout, std::string objectName, bool searchInGroups = true);
478
483 std::string GD_CORE_API GetTypeOfAutomatism(const Project & game, const Layout & layout, std::string automatismName, bool searchInGroups = true);
484
491 std::vector < std::string > GD_CORE_API GetAutomatismsOfObject(const Project & game, const Layout & layout, std::string objectName, bool searchInGroups = true);
492
493 }
494
495 typedef gd::Layout Scene;
496
497 #endif // GDCORE_LAYOUT_H