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 
78  EventsBasedObject& MarkAsRenderedIn3D(bool isRenderedIn3D_) {
79  isRenderedIn3D = isRenderedIn3D_;
80  return *this;
81  }
82 
86  bool IsRenderedIn3D() const { return isRenderedIn3D; }
87 
91  EventsBasedObject& MarkAsAnimatable(bool isAnimatable_) {
92  isAnimatable = isAnimatable_;
93  return *this;
94  }
95 
99  bool IsAnimatable() const { return isAnimatable; }
100 
104  EventsBasedObject &MarkAsTextContainer(bool isTextContainer_) {
105  isTextContainer = isTextContainer_;
106  return *this;
107  }
108 
114  MarkAsInnerAreaFollowingParentSize(bool isInnerAreaExpandingWithParent_) {
115  isInnerAreaFollowingParentSize = isInnerAreaExpandingWithParent_;
116  return *this;
117  }
118 
130  return isInnerAreaFollowingParentSize;
131  }
132 
138  MakAsUsingLegacyInstancesRenderer(bool isUsingLegacyInstancesRenderer_) {
139  isUsingLegacyInstancesRenderer = isUsingLegacyInstancesRenderer_;
140  return *this;
141  }
142 
148  return isUsingLegacyInstancesRenderer;
149  }
150 
154  bool IsTextContainer() const { return isTextContainer; }
155 
159 
162  const gd::LayersContainer& GetLayers() const { return layers; }
163 
167  gd::LayersContainer& GetLayers() { return layers; }
169 
173 
177  return objectsContainer;
178  }
179 
184  return objectsContainer;
185  }
187 
191 
195  return initialInstances;
196  }
197 
202  return initialInstances;
203  }
204 
212  int GetAreaMinX() const {
213  return areaMinX;
214  }
215 
219  void SetAreaMinX(int areaMinX_) {
220  areaMinX = areaMinX_;
221  }
222 
230  int GetAreaMinY() const {
231  return areaMinY;
232  }
233 
237  void SetAreaMinY(int areaMinY_) {
238  areaMinY = areaMinY_;
239  }
240 
248  int GetAreaMinZ() const {
249  return areaMinZ;
250  }
251 
255  void SetAreaMinZ(int areaMinZ_) {
256  areaMinZ = areaMinZ_;
257  }
258 
266  int GetAreaMaxX() const {
267  return areaMaxX;
268  }
269 
273  void SetAreaMaxX(int areaMaxX_) {
274  areaMaxX = areaMaxX_;
275  }
276 
284  int GetAreaMaxY() const {
285  return areaMaxY;
286  }
287 
291  void SetAreaMaxY(int areaMaxY_) {
292  areaMaxY = areaMaxY_;
293  }
294 
302  int GetAreaMaxZ() const {
303  return areaMaxZ;
304  }
305 
309  void SetAreaMaxZ(int areaMaxZ_) {
310  areaMaxZ = areaMaxZ_;
311  }
313 
314  void SerializeTo(SerializerElement& element) const override;
315 
316  void UnserializeFrom(gd::Project& project,
317  const SerializerElement& element) override;
318 
319  private:
320  gd::String defaultName;
321  bool isRenderedIn3D;
322  bool isAnimatable;
323  bool isTextContainer;
324  bool isInnerAreaFollowingParentSize;
325  bool isUsingLegacyInstancesRenderer;
326  gd::InitialInstancesContainer initialInstances;
327  gd::LayersContainer layers;
328  gd::ObjectsContainer objectsContainer;
329  double areaMinX;
330  double areaMinY;
331  double areaMinZ;
332  double areaMaxX;
333  double areaMaxY;
334  double areaMaxZ;
335 };
336 
337 } // namespace gd
Represents a behavior or an object that is implemented with events.
Definition: AbstractEventsBasedEntity.h:30
virtual AbstractEventsBasedEntity & SetDescription(const gd::String &description_)
Set the description of the behavior or object, to be displayed in the editor.
Definition: AbstractEventsBasedEntity.h:52
AbstractEventsBasedEntity & SetName(const gd::String &name_)
Set the internal name of the behavior or object.
Definition: AbstractEventsBasedEntity.h:65
AbstractEventsBasedEntity & SetFullName(const gd::String &fullName_)
Set the name of the behavior or object, to be displayed in the editor.
Definition: AbstractEventsBasedEntity.h:78
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:183
EventsBasedObject & MarkAsInnerAreaFollowingParentSize(bool isInnerAreaExpandingWithParent_)
Declare that the parent scale will always be 1 and children will adapt there size....
Definition: EventsBasedObject.h:114
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:273
bool IsInnerAreaFollowingParentSize() const
Return true if objects handle size changes on their own and don't have the ScalableCapability.
Definition: EventsBasedObject.h:129
int GetAreaMinX() const
Get the left bound of the custom object.
Definition: EventsBasedObject.h:212
bool IsUsingLegacyInstancesRenderer() const
Return true if custom object are rendered using their child-objects instead of their child-instances.
Definition: EventsBasedObject.h:147
bool IsTextContainer() const
Return true if the object needs a TextContainer capability.
Definition: EventsBasedObject.h:154
gd::LayersContainer & GetLayers()
Get the layers of the custom object.
Definition: EventsBasedObject.h:167
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:248
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:266
int GetAreaMinY() const
Get the top bound of the custom object.
Definition: EventsBasedObject.h:230
void SetAreaMinZ(int areaMinZ_)
Set the min Z bound of the custom object.
Definition: EventsBasedObject.h:255
void SetAreaMaxY(int areaMaxY_)
Set the bottom bound of the custom object.
Definition: EventsBasedObject.h:291
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:86
void SetAreaMaxZ(int areaMaxZ_)
Set the bottom bound of the custom object.
Definition: EventsBasedObject.h:309
int GetAreaMaxY() const
Get the bottom bound of the custom object.
Definition: EventsBasedObject.h:284
EventsBasedObject & MarkAsRenderedIn3D(bool isRenderedIn3D_)
Declare a usage of the 3D renderer.
Definition: EventsBasedObject.h:78
gd::ObjectsContainer & GetObjects()
Get the objects of the custom object.
Definition: EventsBasedObject.h:176
gd::InitialInstancesContainer & GetInitialInstances()
Get the instances of the custom object.
Definition: EventsBasedObject.h:194
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:162
EventsBasedObject & MarkAsTextContainer(bool isTextContainer_)
Declare a TextContainer capability.
Definition: EventsBasedObject.h:104
bool IsAnimatable() const
Return true if the object needs an Animatable capability.
Definition: EventsBasedObject.h:99
int GetAreaMaxZ() const
Get the max Z bound of the custom object.
Definition: EventsBasedObject.h:302
EventsBasedObject & MarkAsAnimatable(bool isAnimatable_)
Declare an Animatable capability.
Definition: EventsBasedObject.h:91
EventsBasedObject & MakAsUsingLegacyInstancesRenderer(bool isUsingLegacyInstancesRenderer_)
Declare that custom object are rendered using their child-objects instead of their child-instances.
Definition: EventsBasedObject.h:138
void SetAreaMinY(int areaMinY_)
Set the top bound of the custom object.
Definition: EventsBasedObject.h:237
const gd::InitialInstancesContainer & GetInitialInstances() const
Get the instances of the custom object.
Definition: EventsBasedObject.h:201
void SetAreaMinX(int areaMinX_)
Set the left bound of the custom object.
Definition: EventsBasedObject.h:219
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:51
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