Game Develop Core: Project.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
Project.h
Go to the documentation of this file.
1
6 #ifndef GDCORE_PROJECT_H
7 #define GDCORE_PROJECT_H
8 #include <string>
9 #include <vector>
10 class wxPropertyGrid;
11 class wxPropertyGridEvent;
12 class TiXmlElement;
13 #include "GDCore/PlatformDefinition/ObjectGroup.h"
14 #include "GDCore/PlatformDefinition/ClassWithObjects.h"
15 #include "GDCore/PlatformDefinition/ChangesNotifier.h"
16 #include "GDCore/PlatformDefinition/VariablesContainer.h"
17 #include "GDCore/PlatformDefinition/ResourcesManager.h"
18 namespace gd { class Platform; }
19 namespace gd { class Layout; }
20 namespace gd { class ExternalEvents; }
21 namespace gd { class ResourcesManager; }
22 namespace gd { class ExternalLayout; }
23 namespace gd { class Object; }
24 namespace gd { class VariablesContainer; }
25 namespace gd { class ArbitraryResourceWorker; }
26 namespace gd { class SourceFile; }
27 namespace gd { class ImageManager; }
28 namespace gd { class Automatism; }
29 namespace gd { class AutomatismsSharedData; }
30 namespace gd { class BaseEvent; }
31 #undef GetObject //Disable an annoying macro
32
33 namespace gd
34 {
40 class GD_CORE_API Project : public ClassWithObjects
41 {
42 public:
43 Project();
44 Project(const Project&);
45 virtual ~Project();
46 Project& operator=(const Project & rhs);
47
51
56 void SetName(const std::string & name_) { name = name_; };
57
61 const std::string & GetName() const {return name;}
62
63 #if defined(GD_IDE_ONLY)
64
67 void SetAuthor(const std::string & author_) { author = author_; };
68
72 const std::string & GetAuthor() const {return author;}
73
77 void SetProjectFile(const std::string & file) { gameFile = file; }
78
83 const std::string & GetProjectFile() const { return gameFile; }
84
88 void SetLastCompilationDirectory(const std::string & dir){ latestCompilationDirectory = dir; }
89
94 const std::string & GetLastCompilationDirectory() const {return latestCompilationDirectory;}
95 #endif
96
102 void SetDefaultWidth(unsigned int width) { windowWidth = width; }
103
107 unsigned int GetMainWindowDefaultWidth() const { return windowWidth; }
108
112 void SetDefaultHeight(unsigned int height) { windowHeight = height; }
113
117 unsigned int GetMainWindowDefaultHeight() const { return windowHeight; }
118
122 void SetMaximumFPS(int maxFPS_) { maxFPS = maxFPS_; }
123
127 int GetMaximumFPS() const { return maxFPS; }
128
132 void SetMinimumFPS(unsigned int minFPS_) { minFPS = minFPS_; }
133
137 unsigned int GetMinimumFPS() const { return minFPS; }
138
142 bool IsVerticalSynchronizationEnabledByDefault() const { return verticalSync; }
143
147 void SetVerticalSyncActivatedByDefault(bool enable) { verticalSync = enable; }
148
152 const std::vector < std::string > & GetUsedExtensions() const { return extensionsUsed; };
153
157 std::vector < std::string > & GetUsedExtensions() { return extensionsUsed; };
158
159 #if defined(GD_IDE_ONLY)
160
163 const std::vector < Platform* > & GetUsedPlatforms() const { return platforms; };
164
168 void AddPlatform(Platform & platform);
169
176 bool RemovePlatform(const std::string & platformName);
177
181 Platform & GetCurrentPlatform() const;
182
187 void SetCurrentPlatform(const std::string & platformName);
188 #endif
189
191
195
208 boost::shared_ptr<gd::Object> CreateObject(const std::string & type, const std::string & name, const std::string & platformName = "");
209
221 gd::Automatism* CreateAutomatism(const std::string & type, const std::string & platformName = "");
222
234 boost::shared_ptr<gd::AutomatismsSharedData> CreateAutomatismSharedDatas(const std::string & type, const std::string & platformName = "");
235
236 #if defined(GD_IDE_ONLY)
237
248 boost::shared_ptr<gd::BaseEvent> CreateEvent(const std::string & type, const std::string & platformName = "");
250 #endif
251
252 #if !defined(GD_NO_WX_GUI)
253
256
260 void PopulatePropertyGrid(wxPropertyGrid * grid);
261
265 void UpdateFromPropertyGrid(wxPropertyGrid * grid);
266
270 void OnSelectionInPropertyGrid(wxPropertyGrid * grid, wxPropertyGridEvent & event);
271
275 void OnChangeInPropertyGrid(wxPropertyGrid * grid, wxPropertyGridEvent & event);
277 #endif
278
282
287 bool HasLayoutNamed(const std::string & name) const;
288
292 Layout & GetLayout(const std::string & name);
293
297 const Layout & GetLayout(const std::string & name) const;
298
302 Layout & GetLayout(unsigned int index);
303
307 const Layout & GetLayout (unsigned int index) const;
308
312 unsigned int GetLayoutPosition(const std::string & name) const;
313
314 #if defined(GD_IDE_ONLY)
315
320 void SwapLayouts(unsigned int first, unsigned int second);
321 #endif
322
326 unsigned int GetLayoutCount() const;
327
331 gd::Layout & InsertNewLayout(const std::string & name, unsigned int position);
332
339 void InsertLayout(const Layout & layout, unsigned int position);
340
344 void RemoveLayout(const std::string & name);
345
347
351
357 bool SaveToFile(const std::string & filename);
358
362 bool LoadFromFile(const std::string & filename);
363
369 void SaveToXml(TiXmlElement * element) const;
370
374 void LoadFromXml(const TiXmlElement * element);
375
376 #if defined(GD_IDE_ONLY)
377
382 bool IsDirty() { return dirty; }
383
388 void SetDirty(bool enable = true) { dirty = enable; }
389
393 unsigned int GetLastSaveGDMajorVersion() { return GDMajorVersion; };
394
398 unsigned int GetLastSaveGDMinorVersion() { return GDMinorVersion; };
399 #endif
400
405 #if defined(GD_IDE_ONLY)
407
410 bool HasExternalEventsNamed(const std::string & name) const;
411
415 ExternalEvents & GetExternalEvents(const std::string & name);
416
420 const ExternalEvents & GetExternalEvents(const std::string & name) const;
421
425 ExternalEvents & GetExternalEvents(unsigned int index);
426
430 const ExternalEvents & GetExternalEvents (unsigned int index) const;
431
435 unsigned int GetExternalEventsPosition(const std::string & name) const;
436
442 void SwapExternalEvents(unsigned int first, unsigned int second);
443
447 unsigned int GetExternalEventsCount() const;
448
452 ExternalEvents & InsertNewExternalEvents(const std::string & name, unsigned int position);
453
460 void InsertExternalEvents(const ExternalEvents & externalEvents, unsigned int position);
461
465 void RemoveExternalEvents(const std::string & name);
466 #endif
467
472
477 bool HasExternalLayoutNamed(const std::string & name) const;
478
482 ExternalLayout & GetExternalLayout(const std::string & name);
483
487 const ExternalLayout & GetExternalLayout(const std::string & name) const;
488
492 ExternalLayout & GetExternalLayout(unsigned int index);
493
497 const ExternalLayout & GetExternalLayout (unsigned int index) const;
498
502 unsigned int GetExternalLayoutPosition(const std::string & name) const;
503
504 #if defined(GD_IDE_ONLY)
505
510 void SwapExternalLayouts(unsigned int first, unsigned int second);
511 #endif
512
516 unsigned int GetExternalLayoutsCount() const;
517
521 gd::ExternalLayout & InsertNewExternalLayout(const std::string & name, unsigned int position);
522
529 void InsertExternalLayout(const ExternalLayout & externalLayout, unsigned int position);
530
534 void RemoveExternalLayout(const std::string & name);
535
539 void SetFirstLayout(const std::string & name ) { firstLayout = name; }
540
544 const std::string & GetFirstLayout() { return firstLayout; }
545
547
551
553 #if defined(GD_IDE_ONLY)
554
557 std::vector <ObjectGroup> & GetObjectGroups() { return objectGroups; }
558
562 const std::vector <ObjectGroup> & GetObjectGroups() const { return objectGroups; }
563 #endif
564
566
570
574 const ResourcesManager & GetResourcesManager() const { return resourcesManager; }
575
579 ResourcesManager & GetResourcesManager() { return resourcesManager; }
580
585 const boost::shared_ptr<gd::ImageManager> & GetImageManager() const { return imageManager; }
586
591 boost::shared_ptr<gd::ImageManager> & GetImageManager() { return imageManager; }
592
597 void SetImageManager(boost::shared_ptr<gd::ImageManager> imageManager_) { imageManager = imageManager_; }
598
604 void ExposeResources(gd::ArbitraryResourceWorker & worker);
606
610
615 inline const gd::VariablesContainer & GetVariables() const { return variables; }
616
620 inline gd::VariablesContainer & GetVariables() { return variables; }
621
623
626
634 bool ValidateObjectName(const std::string & objectName);
635
641 std::string GetBadObjectNameWarning();
642
644
645 //TODO: Put this in private part
646 bool useExternalSourceFiles;
647
648 #if defined(GD_IDE_ONLY)
649 std::vector < std::string > imagesChanged;
650 std::string winExecutableFilename;
651 std::string winExecutableIconFile;
652 std::string linuxExecutableFilename;
653 std::string macExecutableFilename;
654 std::vector < boost::shared_ptr<gd::SourceFile> > externalSourceFiles;
655 #endif
656
657 private:
658
663 void Init(const gd::Project & project);
664
668 void LoadProjectInformationFromXml(const TiXmlElement * elem);
669
670 std::string name;
671 unsigned int windowWidth;
672 unsigned int windowHeight;
673 int maxFPS;
674 unsigned int minFPS;
675 bool verticalSync;
676 std::vector < boost::shared_ptr<gd::Layout> > scenes;
677 gd::VariablesContainer variables;
678 std::vector < boost::shared_ptr<gd::ExternalLayout> > externalLayouts;
679 gd::ResourcesManager resourcesManager;
680 boost::shared_ptr<gd::ImageManager> imageManager;
681 std::vector < std::string > extensionsUsed;
682 std::vector < gd::Platform* > platforms;
683 std::string firstLayout;
684 #if defined(GD_IDE_ONLY)
685 std::vector<ObjectGroup> objectGroups;
686 std::string author;
687 std::string gameFile;
688 std::string latestCompilationDirectory;
689 gd::Platform* currentPlatform;
690 std::vector < boost::shared_ptr<gd::ExternalEvents> > externalEvents;
691 mutable unsigned int GDMajorVersion;
692 mutable unsigned int GDMinorVersion;
693 mutable bool dirty;
694 #endif
695 };
696
697 }
698
699
700 #endif // GDCORE_PROJECT_H