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  gd::Project& project,
119  gd::Layout& layout);
120 
129  const gd::String& name,
130  const gd::String& value,
131  gd::Project& project,
132  gd::Layout& layout) {
133  return false;
134  };
136 
141 
152  virtual void ExposeResources(gd::ArbitraryResourceWorker& worker) { return; };
154 
159 
163  void SerializeTo(SerializerElement& element) const;
164 
169  void UnserializeFrom(gd::Project& project, const SerializerElement& element);
171 
172  protected:
175 
180  virtual void DoUnserializeFrom(gd::Project& project,
181  const SerializerElement& element){};
182 
187  virtual void DoSerializeTo(SerializerElement& element) const {};
188 };
189 
190 } // namespace gd
191 
195 using ObjConfSPtr = std::unique_ptr<gd::ObjectConfiguration>;
196 
197 #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:25
Represent a layout ( also called a scene ) of a project.
Definition: Layout.h:39
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
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:187
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:152
gd::String type
Definition: ObjectConfiguration.h:173
virtual bool UpdateInitialInstanceProperty(gd::InitialInstance &instance, const gd::String &name, const gd::String &value, gd::Project &project, gd::Layout &layout)
Called when the IDE wants to update a custom property of an initial instance of this object configura...
Definition: ObjectConfiguration.h:128
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 void DoUnserializeFrom(gd::Project &project, const SerializerElement &element)
Derived object configuration can redefine this method to load custom attributes.
Definition: ObjectConfiguration.h:180
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:31
Definition: CommonTools.h:24