GDevelop Core
Core library for developing platforms and tools compatible with GDevelop.
ObjectConfiguration.h
1 /*
2  * GDevelop Core
3  * Copyright 2008-2016 Florian Rival ([email protected]). All rights
4  * reserved. This project is released under the MIT License.
5  */
6 #ifndef GDCORE_OBJECTCONFIGURATION_H
7 #define GDCORE_OBJECTCONFIGURATION_H
8 #include "GDCore/Vector2.h"
9 #include <map>
10 #include <memory>
11 #include <vector>
12 
13 #include "GDCore/Project/Behavior.h"
14 #include "GDCore/Project/EffectsContainer.h"
15 #include "GDCore/Project/ResourcesManager.h"
16 #include "GDCore/Project/VariablesContainer.h"
17 #include "GDCore/String.h"
18 #include "GDCore/Tools/MakeUnique.h"
19 namespace gd {
20 class PropertyDescriptor;
21 class Project;
22 class Layout;
23 class ArbitraryResourceWorker;
24 class InitialInstance;
25 class SerializerElement;
26 class EffectsContainer;
27 } // namespace gd
28 
29 namespace gd {
30 
38 class GD_CORE_API ObjectConfiguration {
39  public:
44 
48  virtual ~ObjectConfiguration();
49 
58  virtual std::unique_ptr<gd::ObjectConfiguration> Clone() const {
59  return gd::make_unique<gd::ObjectConfiguration>(*this);
60  }
61 
64  void SetType(const gd::String& type_) {
65  type = type_;
66  }
67 
70  const gd::String& GetType() const { return type; }
71 
76 
91  virtual std::map<gd::String, gd::PropertyDescriptor> GetProperties() const;
92 
99  virtual bool UpdateProperty(const gd::String& name, const gd::String& value) {
100  return false;
101  };
103 
109 
116  virtual std::map<gd::String, gd::PropertyDescriptor>
117  GetInitialInstanceProperties(const gd::InitialInstance& instance);
118 
127  const gd::String& name,
128  const gd::String& value) {
129  return false;
130  };
132 
137 
148  virtual void ExposeResources(gd::ArbitraryResourceWorker& worker) { return; };
150 
155 
159  void SerializeTo(SerializerElement& element) const;
160 
165  void UnserializeFrom(gd::Project& project, const SerializerElement& element);
167 
172 
176  virtual size_t GetAnimationsCount() const {
177  return 0;
178  };
179 
184  virtual const gd::String &GetAnimationName(size_t index) const {
185  return badAnimationName;
186  }
187 
192  virtual bool HasAnimationNamed(const gd::String &animationName) const {
193  return false;
194  }
196 
197 protected:
200 
205  virtual void DoUnserializeFrom(gd::Project& project,
206  const SerializerElement& element){};
207 
212  virtual void DoSerializeTo(SerializerElement& element) const {};
213 
214 private:
215  static gd::String badAnimationName;
216 };
217 
218 } // namespace gd
219 
223 using ObjConfSPtr = std::unique_ptr<gd::ObjectConfiguration>;
224 
225 #endif // GDCORE_OBJECT_H
ArbitraryResourceWorker is used so as to inventory resources and sometimes update them.
Definition: ArbitraryResourceWorker.h:44
Represents an instance of an object to be created on a layout start up.
Definition: InitialInstance.h:26
Base class used to represent an object configuration. For example, this can be the animations in a sp...
Definition: ObjectConfiguration.h:38
virtual std::unique_ptr< gd::ObjectConfiguration > Clone() const
Definition: ObjectConfiguration.h:58
virtual const gd::String & GetAnimationName(size_t index) const
Return the name of an animation declared in this object configuration.
Definition: ObjectConfiguration.h:184
void SetType(const gd::String &type_)
Change the type of the object.
Definition: ObjectConfiguration.h:64
virtual void DoSerializeTo(SerializerElement &element) const
Derived object configuration can redefine this method to save custom attributes.
Definition: ObjectConfiguration.h:212
virtual void ExposeResources(gd::ArbitraryResourceWorker &worker)
Called ( e.g. during compilation ) so as to inventory internal resources and sometimes update their f...
Definition: ObjectConfiguration.h:148
virtual bool HasAnimationNamed(const gd::String &animationName) const
Return true if an animation is declared in this object configuration for a given name.
Definition: ObjectConfiguration.h:192
gd::String type
Definition: ObjectConfiguration.h:198
virtual bool UpdateProperty(const gd::String &name, const gd::String &value)
Called when the IDE wants to update a custom property of the object configuration.
Definition: ObjectConfiguration.h:99
const gd::String & GetType() const
Return the type of the object.
Definition: ObjectConfiguration.h:70
virtual bool UpdateInitialInstanceProperty(gd::InitialInstance &instance, const gd::String &name, const gd::String &value)
Called when the IDE wants to update a custom property of an initial instance of this object configura...
Definition: ObjectConfiguration.h:126
virtual void DoUnserializeFrom(gd::Project &project, const SerializerElement &element)
Derived object configuration can redefine this method to load custom attributes.
Definition: ObjectConfiguration.h:205
virtual size_t GetAnimationsCount() const
Return the number of animations declared in this object configuration.
Definition: ObjectConfiguration.h:176
Base class representing a project (game), including all resources, scenes, objects,...
Definition: Project.h:50
A generic container that can represent a value ( containing a string, double, bool or int),...
Definition: SerializerElement.h:37
String represents an UTF8 encoded string.
Definition: String.h:33
Definition: CommonTools.h:24