Game Develop Core: Object.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
Object.h
Go to the documentation of this file.
1
5 #ifndef GDCORE_OBJECT_H
6 #define GDCORE_OBJECT_H
7 #include <boost/shared_ptr.hpp>
8 #include <string>
9 #include <vector>
10 #include <map>
11 #include "GDCore/PlatformDefinition/VariablesContainer.h"
12 #include <SFML/System/Vector2.hpp>
13 namespace gd { class PropgridPropertyDescriptor; }
14 namespace gd { class Automatism; }
15 namespace gd { class Project; }
16 namespace gd { class Layout; }
17 namespace gd { class MainFrameWrapper; }
18 namespace gd { class ArbitraryResourceWorker; }
19 namespace gd { class InitialInstance; }
20 namespace sf { class RenderTarget; }
21 class wxWindow;
22 class wxBitmap;
23
24 namespace gd
25 {
26
32 class GD_CORE_API Object
33 {
34 public:
39 Object(const std::string & name);
40
44 Object(const gd::Object & object) { Init(object); };
45
49 Object& operator=(const gd::Object & object) { if( (this) != &object ) Init(object); return *this; }
50
54 virtual ~Object();
55
63 virtual gd::Object * Clone() const { return new gd::Object(*this); }
64
68
72 void SetName(const std::string & name_) { name = name_; };
73
76 const std::string & GetName() const { return name; };
77
80 void SetType(const std::string & type_) { type = type_; }
81
84 const std::string & GetType() const { return type; }
86
87 #if defined(GD_IDE_ONLY)
88
91
102 virtual void ExposeResources(gd::ArbitraryResourceWorker & worker) {return;};
103
107 virtual bool SupportShaders() { return false; }
109
113
120 virtual std::map<std::string, gd::PropgridPropertyDescriptor> GetInitialInstanceProperties(const gd::InitialInstance & instance, gd::Project & project, gd::Layout & layout);
121
128 virtual bool UpdateInitialInstanceProperty(gd::InitialInstance & instance, const std::string & name, const std::string & value, gd::Project & project, gd::Layout & layout) {return false;};
129
136 virtual void DrawInitialInstance(gd::InitialInstance & instance, sf::RenderTarget & renderTarget, gd::Project & project, gd::Layout & layout);
137
142 virtual void LoadResources(gd::Project & project, gd::Layout & layout) {};
143
148 virtual sf::Vector2f GetInitialInstanceDefaultSize(gd::InitialInstance & instance, gd::Project & project, gd::Layout & layout) const;
149
158 virtual sf::Vector2f GetInitialInstanceOrigin(gd::InitialInstance & instance, gd::Project & project, gd::Layout & layout) const;
160
164
168 virtual void EditObject( wxWindow* parent, gd::Project & project, gd::MainFrameWrapper & mainFrameWrapper_ ) {};
169
174 virtual bool GenerateThumbnail(const gd::Project & project, wxBitmap & thumbnail) const {return false;};
176 #endif
177
181
183 #if defined(GD_IDE_ONLY)
184
187 std::vector < std::string > GetAllAutomatismNames() const;
188
192 Automatism & GetAutomatism(const std::string & name);
193
197 const Automatism & GetAutomatism(const std::string & name) const;
198
202 bool HasAutomatismNamed(const std::string & name) const;
203
207 void RemoveAutomatism(const std::string & name);
208
213 bool RenameAutomatism(const std::string & name, const std::string & newName);
214
222 gd::Automatism * AddNewAutomatism(gd::Project & project, const std::string & type, const std::string & name);
223 #endif
224
228 const std::map<std::string, gd::Automatism* > & GetAllAutomatisms() const {return automatisms;};
230
234
238 const gd::VariablesContainer & GetVariables() const { return objectVariables; }
239
243 gd::VariablesContainer & GetVariables() { return objectVariables; }
245
249
254 void LoadFromXml(gd::Project & project, const TiXmlElement * elemScene);
255
256 #if defined(GD_IDE_ONLY)
257
260 void SaveToXml(TiXmlElement * elemScene);
261 #endif
262
264 protected:
265 std::string name;
266 std::string type;
267 std::map<std::string, gd::Automatism* > automatisms;
268 gd::VariablesContainer objectVariables;
269
273 virtual void DoLoadFromXml(gd::Project & project, const TiXmlElement * elemScene) {};
274
275 #if defined(GD_IDE_ONLY)
276
279 virtual void DoSaveToXml(TiXmlElement * elemScene) {};
280 #endif
281
286 void Init(const gd::Object & object);
287 };
288
294 struct ObjectHasName : public std::binary_function<boost::shared_ptr<gd::Object>, std::string, bool> {
295 bool operator()(const boost::shared_ptr<gd::Object> & object, const std::string & name) const { return object->GetName() == name; }
296 };
297
298 }
299
303 typedef std::vector < boost::shared_ptr<gd::Object> > ObjList;
304
308 typedef boost::shared_ptr<gd::Object> ObjSPtr;
309
310 void GD_CORE_API DestroyBaseObject(gd::Object * object);
311 gd::Object * GD_CORE_API CreateBaseObject(std::string name);
312
313 #endif // GDCORE_OBJECT_H