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/ResourcesContainer.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  };
102 
109  virtual bool RenameProperty(const gd::String &oldName,
110  const gd::String &newName) {
111  return false;
112  };
114 
120 
127  virtual std::map<gd::String, gd::PropertyDescriptor>
128  GetInitialInstanceProperties(const gd::InitialInstance& instance);
129 
138  const gd::String& name,
139  const gd::String& value) {
140  return false;
141  };
143 
148 
159  virtual void ExposeResources(gd::ArbitraryResourceWorker& worker) { return; };
161 
166 
170  void SerializeTo(SerializerElement& element) const;
171 
176  void UnserializeFrom(gd::Project& project, const SerializerElement& element);
178 
183 
187  virtual size_t GetAnimationsCount() const {
188  return 0;
189  };
190 
195  virtual const gd::String &GetAnimationName(size_t index) const {
196  return badAnimationName;
197  }
198 
203  virtual bool HasAnimationNamed(const gd::String &animationName) const {
204  return false;
205  }
207 
208 protected:
211 
216  virtual void DoUnserializeFrom(gd::Project& project,
217  const SerializerElement& element){};
218 
223  virtual void DoSerializeTo(SerializerElement& element) const {};
224 
225 private:
226  static gd::String badAnimationName;
227 };
228 
229 } // namespace gd
230 
234 using ObjConfSPtr = std::unique_ptr<gd::ObjectConfiguration>;
235 
236 #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:29
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:195
void SetType(const gd::String &type_)
Change the type of the object.
Definition: ObjectConfiguration.h:64
virtual bool RenameProperty(const gd::String &oldName, const gd::String &newName)
Called when the IDE wants to rename a custom property of the object configuration.
Definition: ObjectConfiguration.h:109
virtual void DoSerializeTo(SerializerElement &element) const
Derived object configuration can redefine this method to save custom attributes.
Definition: ObjectConfiguration.h:223
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:159
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:203
gd::String type
Definition: ObjectConfiguration.h:209
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:137
virtual void DoUnserializeFrom(gd::Project &project, const SerializerElement &element)
Derived object configuration can redefine this method to load custom attributes.
Definition: ObjectConfiguration.h:216
virtual size_t GetAnimationsCount() const
Return the number of animations declared in this object configuration.
Definition: ObjectConfiguration.h:187
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