GDevelop Core
Core library for developing platforms and tools compatible with GDevelop.
EventsBasedObject.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 #pragma once
7 
8 #include <vector>
9 #include "GDCore/Project/AbstractEventsBasedEntity.h"
10 #include "GDCore/Project/ObjectsContainer.h"
11 #include "GDCore/Project/InitialInstancesContainer.h"
12 #include "GDCore/Project/LayersContainer.h"
13 #include "GDCore/String.h"
14 namespace gd {
15 class SerializerElement;
16 class Project;
17 } // namespace gd
18 
19 namespace gd {
20 // TODO EBO Add a way to mark some parts of children configuration as readonly.
30 class GD_CORE_API EventsBasedObject: public AbstractEventsBasedEntity {
31  public:
33  virtual ~EventsBasedObject();
34 
39  EventsBasedObject* Clone() const { return new EventsBasedObject(*this); };
40 
44  const gd::String& GetDefaultName() const { return defaultName; };
45 
50  defaultName = defaultName_;
51  return *this;
52  }
53 
54  EventsBasedObject& SetDescription(const gd::String& description_) override {
56  return *this;
57  }
58 
64  return *this;
65  }
66 
72  return *this;
73  }
74 
79  EventsBasedObject& SetPrivate(bool isPrivate) {
81  return *this;
82  }
83 
87  EventsBasedObject& MarkAsRenderedIn3D(bool isRenderedIn3D_) {
88  isRenderedIn3D = isRenderedIn3D_;
89  return *this;
90  }
91 
95  bool IsRenderedIn3D() const { return isRenderedIn3D; }
96 
100  EventsBasedObject& MarkAsAnimatable(bool isAnimatable_) {
101  isAnimatable = isAnimatable_;
102  return *this;
103  }
104 
108  bool IsAnimatable() const { return isAnimatable; }
109 
113  EventsBasedObject &MarkAsTextContainer(bool isTextContainer_) {
114  isTextContainer = isTextContainer_;
115  return *this;
116  }
117 
123  MarkAsInnerAreaFollowingParentSize(bool isInnerAreaExpandingWithParent_) {
124  isInnerAreaFollowingParentSize = isInnerAreaExpandingWithParent_;
125  return *this;
126  }
127 
139  return isInnerAreaFollowingParentSize;
140  }
141 
147  MakAsUsingLegacyInstancesRenderer(bool isUsingLegacyInstancesRenderer_) {
148  isUsingLegacyInstancesRenderer = isUsingLegacyInstancesRenderer_;
149  return *this;
150  }
151 
157  return isUsingLegacyInstancesRenderer;
158  }
159 
163  bool IsTextContainer() const { return isTextContainer; }
164 
168 
171  const gd::LayersContainer& GetLayers() const { return layers; }
172 
176  gd::LayersContainer& GetLayers() { return layers; }
178 
182 
186  return objectsContainer;
187  }
188 
193  return objectsContainer;
194  }
196 
200 
204  return initialInstances;
205  }
206 
211  return initialInstances;
212  }
213 
221  int GetAreaMinX() const {
222  return areaMinX;
223  }
224 
228  void SetAreaMinX(int areaMinX_) {
229  areaMinX = areaMinX_;
230  }
231 
239  int GetAreaMinY() const {
240  return areaMinY;
241  }
242 
246  void SetAreaMinY(int areaMinY_) {
247  areaMinY = areaMinY_;
248  }
249 
257  int GetAreaMinZ() const {
258  return areaMinZ;
259  }
260 
264  void SetAreaMinZ(int areaMinZ_) {
265  areaMinZ = areaMinZ_;
266  }
267 
275  int GetAreaMaxX() const {
276  return areaMaxX;
277  }
278 
282  void SetAreaMaxX(int areaMaxX_) {
283  areaMaxX = areaMaxX_;
284  }
285 
293  int GetAreaMaxY() const {
294  return areaMaxY;
295  }
296 
300  void SetAreaMaxY(int areaMaxY_) {
301  areaMaxY = areaMaxY_;
302  }
303 
311  int GetAreaMaxZ() const {
312  return areaMaxZ;
313  }
314 
318  void SetAreaMaxZ(int areaMaxZ_) {
319  areaMaxZ = areaMaxZ_;
320  }
322 
323  void SerializeTo(SerializerElement& element) const override;
324 
325  void UnserializeFrom(gd::Project& project,
326  const SerializerElement& element) override;
327 
328  private:
329  gd::String defaultName;
330  bool isRenderedIn3D;
331  bool isAnimatable;
332  bool isTextContainer;
333  bool isInnerAreaFollowingParentSize;
334  bool isUsingLegacyInstancesRenderer;
335  gd::InitialInstancesContainer initialInstances;
336  gd::LayersContainer layers;
337  gd::ObjectsContainer objectsContainer;
338  double areaMinX;
339  double areaMinY;
340  double areaMinZ;
341  double areaMaxX;
342  double areaMaxY;
343  double areaMaxZ;
344 };
345 
346 } // namespace gd
Represents a behavior or an object that is implemented with events.
Definition: AbstractEventsBasedEntity.h:29
AbstractEventsBasedEntity & SetPrivate(bool isPrivate_)
Set that the behavior or object is private - it can't be used outside of its extension.
Definition: AbstractEventsBasedEntity.h:52
virtual AbstractEventsBasedEntity & SetDescription(const gd::String &description_)
Set the description of the behavior or object, to be displayed in the editor.
Definition: AbstractEventsBasedEntity.h:66
AbstractEventsBasedEntity & SetName(const gd::String &name_)
Set the internal name of the behavior or object.
Definition: AbstractEventsBasedEntity.h:79
AbstractEventsBasedEntity & SetFullName(const gd::String &fullName_)
Set the name of the behavior or object, to be displayed in the editor.
Definition: AbstractEventsBasedEntity.h:92
Represents an object that is implemented with events.
Definition: EventsBasedObject.h:30
const gd::ObjectsContainer & GetObjects() const
Get the objects of the custom object.
Definition: EventsBasedObject.h:192
EventsBasedObject & MarkAsInnerAreaFollowingParentSize(bool isInnerAreaExpandingWithParent_)
Declare that the parent scale will always be 1 and children will adapt there size....
Definition: EventsBasedObject.h:123
EventsBasedObject * Clone() const
Return a pointer to a new EventsBasedObject constructed from this one.
Definition: EventsBasedObject.h:39
void SetAreaMaxX(int areaMaxX_)
Set the right bound of the custom object.
Definition: EventsBasedObject.h:282
bool IsInnerAreaFollowingParentSize() const
Return true if objects handle size changes on their own and don't have the ScalableCapability.
Definition: EventsBasedObject.h:138
int GetAreaMinX() const
Get the left bound of the custom object.
Definition: EventsBasedObject.h:221
bool IsUsingLegacyInstancesRenderer() const
Return true if custom object are rendered using their child-objects instead of their child-instances.
Definition: EventsBasedObject.h:156
bool IsTextContainer() const
Return true if the object needs a TextContainer capability.
Definition: EventsBasedObject.h:163
gd::LayersContainer & GetLayers()
Get the layers of the custom object.
Definition: EventsBasedObject.h:176
EventsBasedObject & SetName(const gd::String &name_)
Set the internal name of the object.
Definition: EventsBasedObject.h:62
int GetAreaMinZ() const
Get the min Z bound of the custom object.
Definition: EventsBasedObject.h:257
EventsBasedObject & SetDefaultName(const gd::String &defaultName_)
Set the default name for created objects.
Definition: EventsBasedObject.h:49
const gd::String & GetDefaultName() const
Get the default name for created objects.
Definition: EventsBasedObject.h:44
int GetAreaMaxX() const
Get the right bound of the custom object.
Definition: EventsBasedObject.h:275
int GetAreaMinY() const
Get the top bound of the custom object.
Definition: EventsBasedObject.h:239
void SetAreaMinZ(int areaMinZ_)
Set the min Z bound of the custom object.
Definition: EventsBasedObject.h:264
void SetAreaMaxY(int areaMaxY_)
Set the bottom bound of the custom object.
Definition: EventsBasedObject.h:300
EventsBasedObject & SetFullName(const gd::String &fullName_)
Set the name of the object, to be displayed in the editor.
Definition: EventsBasedObject.h:70
bool IsRenderedIn3D() const
Return true if the object uses the 3D renderer.
Definition: EventsBasedObject.h:95
void SetAreaMaxZ(int areaMaxZ_)
Set the bottom bound of the custom object.
Definition: EventsBasedObject.h:318
int GetAreaMaxY() const
Get the bottom bound of the custom object.
Definition: EventsBasedObject.h:293
EventsBasedObject & MarkAsRenderedIn3D(bool isRenderedIn3D_)
Declare a usage of the 3D renderer.
Definition: EventsBasedObject.h:87
gd::ObjectsContainer & GetObjects()
Get the objects of the custom object.
Definition: EventsBasedObject.h:185
gd::InitialInstancesContainer & GetInitialInstances()
Get the instances of the custom object.
Definition: EventsBasedObject.h:203
EventsBasedObject & SetPrivate(bool isPrivate)
Set that the object is private - it can't be used outside of its extension.
Definition: EventsBasedObject.h:79
EventsBasedObject & SetDescription(const gd::String &description_) override
Set the description of the behavior or object, to be displayed in the editor.
Definition: EventsBasedObject.h:54
const gd::LayersContainer & GetLayers() const
Get the layers of the custom object.
Definition: EventsBasedObject.h:171
EventsBasedObject & MarkAsTextContainer(bool isTextContainer_)
Declare a TextContainer capability.
Definition: EventsBasedObject.h:113
bool IsAnimatable() const
Return true if the object needs an Animatable capability.
Definition: EventsBasedObject.h:108
int GetAreaMaxZ() const
Get the max Z bound of the custom object.
Definition: EventsBasedObject.h:311
EventsBasedObject & MarkAsAnimatable(bool isAnimatable_)
Declare an Animatable capability.
Definition: EventsBasedObject.h:100
EventsBasedObject & MakAsUsingLegacyInstancesRenderer(bool isUsingLegacyInstancesRenderer_)
Declare that custom object are rendered using their child-objects instead of their child-instances.
Definition: EventsBasedObject.h:147
void SetAreaMinY(int areaMinY_)
Set the top bound of the custom object.
Definition: EventsBasedObject.h:246
const gd::InitialInstancesContainer & GetInitialInstances() const
Get the instances of the custom object.
Definition: EventsBasedObject.h:210
void SetAreaMinX(int areaMinX_)
Set the left bound of the custom object.
Definition: EventsBasedObject.h:228
Defines a container of gd::InitialInstances.
Definition: InitialInstancesContainer.h:38
Contains the layers for a scene or a custom object.
Definition: LayersContainer.h:21
Used as a base class for classes that will own objects (see gd::Object).
Definition: ObjectsContainer.h:37
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