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/EventsBasedObjectVariant.h"
11 #include "GDCore/Project/EventsBasedObjectVariantsContainer.h"
12 #include "GDCore/Project/ObjectsContainer.h"
13 #include "GDCore/Project/InitialInstancesContainer.h"
14 #include "GDCore/Project/LayersContainer.h"
15 #include "GDCore/String.h"
16 namespace gd {
17 class SerializerElement;
18 class Project;
19 } // namespace gd
20 
21 namespace gd {
22 // TODO EBO Add a way to mark some parts of children configuration as readonly.
32 class GD_CORE_API EventsBasedObject: public AbstractEventsBasedEntity {
33  public:
35  virtual ~EventsBasedObject();
36 
41  EventsBasedObject* Clone() const { return new EventsBasedObject(*this); };
42 
46  const gd::String& GetDefaultName() const { return defaultName; };
47 
52  defaultName = defaultName_;
53  return *this;
54  }
55 
56  EventsBasedObject& SetDescription(const gd::String& description_) override {
58  return *this;
59  }
60 
66  return *this;
67  }
68 
74  return *this;
75  }
76 
81  EventsBasedObject& SetPrivate(bool isPrivate) {
83  return *this;
84  }
85 
89  EventsBasedObject& MarkAsRenderedIn3D(bool isRenderedIn3D_) {
90  isRenderedIn3D = isRenderedIn3D_;
91  return *this;
92  }
93 
97  bool IsRenderedIn3D() const { return isRenderedIn3D; }
98 
102  EventsBasedObject& MarkAsAnimatable(bool isAnimatable_) {
103  isAnimatable = isAnimatable_;
104  return *this;
105  }
106 
110  bool IsAnimatable() const { return isAnimatable; }
111 
115  EventsBasedObject &MarkAsTextContainer(bool isTextContainer_) {
116  isTextContainer = isTextContainer_;
117  return *this;
118  }
119 
125  MarkAsInnerAreaFollowingParentSize(bool isInnerAreaExpandingWithParent_) {
126  isInnerAreaFollowingParentSize = isInnerAreaExpandingWithParent_;
127  return *this;
128  }
129 
141  return isInnerAreaFollowingParentSize;
142  }
143 
149  MakAsUsingLegacyInstancesRenderer(bool isUsingLegacyInstancesRenderer_) {
150  isUsingLegacyInstancesRenderer = isUsingLegacyInstancesRenderer_;
151  return *this;
152  }
153 
159  return isUsingLegacyInstancesRenderer;
160  }
161 
165  bool IsTextContainer() const { return isTextContainer; }
166 
170  const gd::EventsBasedObjectVariant& GetDefaultVariant() const { return defaultVariant; }
171 
175  gd::EventsBasedObjectVariant& GetDefaultVariant() { return defaultVariant; }
176 
180  const gd::EventsBasedObjectVariantsContainer& GetVariants() const { return variants; }
181 
186 
190 
193  const gd::LayersContainer& GetLayers() const { return defaultVariant.GetLayers(); }
194 
198  gd::LayersContainer& GetLayers() { return defaultVariant.GetLayers(); }
200 
204 
208  return defaultVariant.GetObjects();
209  }
210 
215  return defaultVariant.GetObjects();
216  }
218 
222 
226  return defaultVariant.GetInitialInstances();
227  }
228 
233  return defaultVariant.GetInitialInstances();
234  }
235 
243  int GetAreaMinX() const {
244  return defaultVariant.GetAreaMinX();
245  }
246 
250  void SetAreaMinX(int areaMinX) {
251  defaultVariant.SetAreaMinX(areaMinX);
252  }
253 
261  int GetAreaMinY() const {
262  return defaultVariant.GetAreaMinY();
263  }
264 
268  void SetAreaMinY(int areaMinY) {
269  defaultVariant.SetAreaMinY(areaMinY);
270  }
271 
279  int GetAreaMinZ() const {
280  return defaultVariant.GetAreaMinZ();
281  }
282 
286  void SetAreaMinZ(int areaMinZ) {
287  defaultVariant.SetAreaMinZ(areaMinZ);
288  }
289 
297  int GetAreaMaxX() const {
298  return defaultVariant.GetAreaMaxX();
299  }
300 
304  void SetAreaMaxX(int areaMaxX) {
305  defaultVariant.SetAreaMaxX(areaMaxX);
306  }
307 
315  int GetAreaMaxY() const {
316  return defaultVariant.GetAreaMaxY();
317  }
318 
322  void SetAreaMaxY(int areaMaxY) {
323  defaultVariant.SetAreaMaxY(areaMaxY);
324  }
325 
333  int GetAreaMaxZ() const {
334  return defaultVariant.GetAreaMaxZ();
335  }
336 
340  void SetAreaMaxZ(int areaMaxZ) {
341  defaultVariant.SetAreaMaxZ(areaMaxZ);
342  }
344 
349  void SerializeToExternal(SerializerElement& element) const;
350 
351  void SerializeTo(SerializerElement& element) const override;
352 
353  void UnserializeFrom(gd::Project& project,
354  const SerializerElement& element) override;
355 
356  private:
357  gd::String defaultName;
358  bool isRenderedIn3D;
359  bool isAnimatable;
360  bool isTextContainer;
361  bool isInnerAreaFollowingParentSize;
362  bool isUsingLegacyInstancesRenderer;
363  gd::EventsBasedObjectVariant defaultVariant;
365 };
366 
367 } // 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:32
const gd::ObjectsContainer & GetObjects() const
Get the objects of the custom object.
Definition: EventsBasedObject.h:214
EventsBasedObject & MarkAsInnerAreaFollowingParentSize(bool isInnerAreaExpandingWithParent_)
Declare that the parent scale will always be 1 and children will adapt there size....
Definition: EventsBasedObject.h:125
EventsBasedObject * Clone() const
Return a pointer to a new EventsBasedObject constructed from this one.
Definition: EventsBasedObject.h:41
void SetAreaMaxY(int areaMaxY)
Set the bottom bound of the custom object.
Definition: EventsBasedObject.h:322
bool IsInnerAreaFollowingParentSize() const
Return true if objects handle size changes on their own and don't have the ScalableCapability.
Definition: EventsBasedObject.h:140
int GetAreaMinX() const
Get the left bound of the custom object.
Definition: EventsBasedObject.h:243
bool IsUsingLegacyInstancesRenderer() const
Return true if custom object are rendered using their child-objects instead of their child-instances.
Definition: EventsBasedObject.h:158
bool IsTextContainer() const
Return true if the object needs a TextContainer capability.
Definition: EventsBasedObject.h:165
gd::LayersContainer & GetLayers()
Get the layers of the custom object.
Definition: EventsBasedObject.h:198
EventsBasedObject & SetName(const gd::String &name_)
Set the internal name of the object.
Definition: EventsBasedObject.h:64
int GetAreaMinZ() const
Get the min Z bound of the custom object.
Definition: EventsBasedObject.h:279
gd::EventsBasedObjectVariant & GetDefaultVariant()
Get the default variant of the custom object.
Definition: EventsBasedObject.h:175
void SetAreaMaxX(int areaMaxX)
Set the right bound of the custom object.
Definition: EventsBasedObject.h:304
const gd::EventsBasedObjectVariantsContainer & GetVariants() const
Get the variants of the custom object.
Definition: EventsBasedObject.h:180
EventsBasedObject & SetDefaultName(const gd::String &defaultName_)
Set the default name for created objects.
Definition: EventsBasedObject.h:51
const gd::String & GetDefaultName() const
Get the default name for created objects.
Definition: EventsBasedObject.h:46
int GetAreaMaxX() const
Get the right bound of the custom object.
Definition: EventsBasedObject.h:297
int GetAreaMinY() const
Get the top bound of the custom object.
Definition: EventsBasedObject.h:261
const gd::EventsBasedObjectVariant & GetDefaultVariant() const
Get the default variant of the custom object.
Definition: EventsBasedObject.h:170
EventsBasedObject & SetFullName(const gd::String &fullName_)
Set the name of the object, to be displayed in the editor.
Definition: EventsBasedObject.h:72
bool IsRenderedIn3D() const
Return true if the object uses the 3D renderer.
Definition: EventsBasedObject.h:97
void SetAreaMinY(int areaMinY)
Set the top bound of the custom object.
Definition: EventsBasedObject.h:268
int GetAreaMaxY() const
Get the bottom bound of the custom object.
Definition: EventsBasedObject.h:315
EventsBasedObject & MarkAsRenderedIn3D(bool isRenderedIn3D_)
Declare a usage of the 3D renderer.
Definition: EventsBasedObject.h:89
gd::ObjectsContainer & GetObjects()
Get the objects of the custom object.
Definition: EventsBasedObject.h:207
void SetAreaMinX(int areaMinX)
Set the left bound of the custom object.
Definition: EventsBasedObject.h:250
gd::InitialInstancesContainer & GetInitialInstances()
Get the instances of the custom object.
Definition: EventsBasedObject.h:225
EventsBasedObject & SetPrivate(bool isPrivate)
Set that the object is private - it can't be used outside of its extension.
Definition: EventsBasedObject.h:81
EventsBasedObject & SetDescription(const gd::String &description_) override
Set the description of the behavior or object, to be displayed in the editor.
Definition: EventsBasedObject.h:56
const gd::LayersContainer & GetLayers() const
Get the layers of the custom object.
Definition: EventsBasedObject.h:193
EventsBasedObject & MarkAsTextContainer(bool isTextContainer_)
Declare a TextContainer capability.
Definition: EventsBasedObject.h:115
void SetAreaMaxZ(int areaMaxZ)
Set the bottom bound of the custom object.
Definition: EventsBasedObject.h:340
void SetAreaMinZ(int areaMinZ)
Set the min Z bound of the custom object.
Definition: EventsBasedObject.h:286
gd::EventsBasedObjectVariantsContainer & GetVariants()
Get the variants of the custom object.
Definition: EventsBasedObject.h:185
bool IsAnimatable() const
Return true if the object needs an Animatable capability.
Definition: EventsBasedObject.h:110
int GetAreaMaxZ() const
Get the max Z bound of the custom object.
Definition: EventsBasedObject.h:333
EventsBasedObject & MarkAsAnimatable(bool isAnimatable_)
Declare an Animatable capability.
Definition: EventsBasedObject.h:102
EventsBasedObject & MakAsUsingLegacyInstancesRenderer(bool isUsingLegacyInstancesRenderer_)
Declare that custom object are rendered using their child-objects instead of their child-instances.
Definition: EventsBasedObject.h:149
const gd::InitialInstancesContainer & GetInitialInstances() const
Get the instances of the custom object.
Definition: EventsBasedObject.h:232
Represents a variation of style of an events-based object.
Definition: EventsBasedObjectVariant.h:25
Used as a base class for classes that will own events-backed variants.
Definition: EventsBasedObjectVariantsContainer.h:27
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
std::vector< std::unique_ptr< gd::Object > > & GetObjects()
Definition: ObjectsContainer.h:177
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