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 
64  EventsBasedObject& SetName(const gd::String& name_) override {
66  return *this;
67  }
68 
72  EventsBasedObject &SetFullName(const gd::String &fullName_) override {
74  return *this;
75  }
76 
78  SetPreviewIconUrl(const gd::String &previewIconUrl_) override {
79  AbstractEventsBasedEntity::SetPreviewIconUrl(previewIconUrl_);
80  return *this;
81  }
82 
83  EventsBasedObject &SetIconUrl(const gd::String &iconUrl_) override {
84  AbstractEventsBasedEntity::SetIconUrl(iconUrl_);
85  return *this;
86  }
87 
92  EventsBasedObject &SetHelpPath(const gd::String &helpPath_) override {
94  return *this;
95  }
96 
101  const gd::String& GetAssetStoreTag() const { return assetStoreTag; }
102 
108  assetStoreTag = assetStoreTag_;
109  return *this;
110  }
111 
116  EventsBasedObject& SetPrivate(bool isPrivate) {
118  return *this;
119  }
120 
124  EventsBasedObject& MarkAsRenderedIn3D(bool isRenderedIn3D_) {
125  isRenderedIn3D = isRenderedIn3D_;
126  return *this;
127  }
128 
132  bool IsRenderedIn3D() const { return isRenderedIn3D; }
133 
137  EventsBasedObject& MarkAsAnimatable(bool isAnimatable_) {
138  isAnimatable = isAnimatable_;
139  return *this;
140  }
141 
145  bool IsAnimatable() const { return isAnimatable; }
146 
150  EventsBasedObject &MarkAsTextContainer(bool isTextContainer_) {
151  isTextContainer = isTextContainer_;
152  return *this;
153  }
154 
160  MarkAsInnerAreaFollowingParentSize(bool isInnerAreaExpandingWithParent_) {
161  isInnerAreaFollowingParentSize = isInnerAreaExpandingWithParent_;
162  return *this;
163  }
164 
176  return isInnerAreaFollowingParentSize;
177  }
178 
184  MakAsUsingLegacyInstancesRenderer(bool isUsingLegacyInstancesRenderer_) {
185  isUsingLegacyInstancesRenderer = isUsingLegacyInstancesRenderer_;
186  return *this;
187  }
188 
194  return isUsingLegacyInstancesRenderer;
195  }
196 
200  bool IsTextContainer() const { return isTextContainer; }
201 
205  const gd::EventsBasedObjectVariant& GetDefaultVariant() const { return defaultVariant; }
206 
210  gd::EventsBasedObjectVariant& GetDefaultVariant() { return defaultVariant; }
211 
215  const gd::EventsBasedObjectVariantsContainer& GetVariants() const { return variants; }
216 
221 
225 
228  const gd::LayersContainer& GetLayers() const { return defaultVariant.GetLayers(); }
229 
233  gd::LayersContainer& GetLayers() { return defaultVariant.GetLayers(); }
235 
239 
243  return defaultVariant.GetObjects();
244  }
245 
250  return defaultVariant.GetObjects();
251  }
253 
257 
261  return defaultVariant.GetInitialInstances();
262  }
263 
268  return defaultVariant.GetInitialInstances();
269  }
270 
278  int GetAreaMinX() const {
279  return defaultVariant.GetAreaMinX();
280  }
281 
285  void SetAreaMinX(int areaMinX) {
286  defaultVariant.SetAreaMinX(areaMinX);
287  }
288 
296  int GetAreaMinY() const {
297  return defaultVariant.GetAreaMinY();
298  }
299 
303  void SetAreaMinY(int areaMinY) {
304  defaultVariant.SetAreaMinY(areaMinY);
305  }
306 
314  int GetAreaMinZ() const {
315  return defaultVariant.GetAreaMinZ();
316  }
317 
321  void SetAreaMinZ(int areaMinZ) {
322  defaultVariant.SetAreaMinZ(areaMinZ);
323  }
324 
332  int GetAreaMaxX() const {
333  return defaultVariant.GetAreaMaxX();
334  }
335 
339  void SetAreaMaxX(int areaMaxX) {
340  defaultVariant.SetAreaMaxX(areaMaxX);
341  }
342 
350  int GetAreaMaxY() const {
351  return defaultVariant.GetAreaMaxY();
352  }
353 
357  void SetAreaMaxY(int areaMaxY) {
358  defaultVariant.SetAreaMaxY(areaMaxY);
359  }
360 
368  int GetAreaMaxZ() const {
369  return defaultVariant.GetAreaMaxZ();
370  }
371 
375  void SetAreaMaxZ(int areaMaxZ) {
376  defaultVariant.SetAreaMaxZ(areaMaxZ);
377  }
379 
384  void SerializeToExternal(SerializerElement& element) const;
385 
386  void SerializeTo(SerializerElement& element) const override;
387 
388  void UnserializeFrom(gd::Project& project,
389  const SerializerElement& element) override;
390 
391  private:
392  gd::String defaultName;
393  gd::String assetStoreTag;
394  bool isRenderedIn3D;
395  bool isAnimatable;
396  bool isTextContainer;
397  bool isInnerAreaFollowingParentSize;
398  bool isUsingLegacyInstancesRenderer;
399  gd::EventsBasedObjectVariant defaultVariant;
401 };
402 
403 } // 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
virtual AbstractEventsBasedEntity & SetName(const gd::String &name_)
Set the internal name of the behavior or object.
Definition: AbstractEventsBasedEntity.h:79
virtual AbstractEventsBasedEntity & SetFullName(const gd::String &fullName_)
Set the name of the behavior or object, to be displayed in the editor.
Definition: AbstractEventsBasedEntity.h:92
virtual AbstractEventsBasedEntity & SetHelpPath(const gd::String &helpPath_)
Set the help path relative to the GDevelop documentation root.
Definition: AbstractEventsBasedEntity.h:120
Represents an object that is implemented with events.
Definition: EventsBasedObject.h:32
EventsBasedObject & SetFullName(const gd::String &fullName_) override
Set the name of the object, to be displayed in the editor.
Definition: EventsBasedObject.h:72
const gd::ObjectsContainer & GetObjects() const
Get the objects of the custom object.
Definition: EventsBasedObject.h:249
EventsBasedObject & MarkAsInnerAreaFollowingParentSize(bool isInnerAreaExpandingWithParent_)
Declare that the parent scale will always be 1 and children will adapt there size....
Definition: EventsBasedObject.h:160
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:357
bool IsInnerAreaFollowingParentSize() const
Return true if objects handle size changes on their own and don't have the ScalableCapability.
Definition: EventsBasedObject.h:175
int GetAreaMinX() const
Get the left bound of the custom object.
Definition: EventsBasedObject.h:278
bool IsUsingLegacyInstancesRenderer() const
Return true if custom object are rendered using their child-objects instead of their child-instances.
Definition: EventsBasedObject.h:193
bool IsTextContainer() const
Return true if the object needs a TextContainer capability.
Definition: EventsBasedObject.h:200
gd::LayersContainer & GetLayers()
Get the layers of the custom object.
Definition: EventsBasedObject.h:233
int GetAreaMinZ() const
Get the min Z bound of the custom object.
Definition: EventsBasedObject.h:314
gd::EventsBasedObjectVariant & GetDefaultVariant()
Get the default variant of the custom object.
Definition: EventsBasedObject.h:210
void SetAreaMaxX(int areaMaxX)
Set the right bound of the custom object.
Definition: EventsBasedObject.h:339
const gd::EventsBasedObjectVariantsContainer & GetVariants() const
Get the variants of the custom object.
Definition: EventsBasedObject.h:215
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
EventsBasedObject & SetHelpPath(const gd::String &helpPath_) override
Set the help path relative to the GDevelop documentation root.
Definition: EventsBasedObject.h:92
int GetAreaMaxX() const
Get the right bound of the custom object.
Definition: EventsBasedObject.h:332
int GetAreaMinY() const
Get the top bound of the custom object.
Definition: EventsBasedObject.h:296
const gd::EventsBasedObjectVariant & GetDefaultVariant() const
Get the default variant of the custom object.
Definition: EventsBasedObject.h:205
bool IsRenderedIn3D() const
Return true if the object uses the 3D renderer.
Definition: EventsBasedObject.h:132
EventsBasedObject & SetAssetStoreTag(const gd::String &assetStoreTag_)
Set the tag from which to choose assets from when creating a new object.
Definition: EventsBasedObject.h:107
void SetAreaMinY(int areaMinY)
Set the top bound of the custom object.
Definition: EventsBasedObject.h:303
int GetAreaMaxY() const
Get the bottom bound of the custom object.
Definition: EventsBasedObject.h:350
EventsBasedObject & MarkAsRenderedIn3D(bool isRenderedIn3D_)
Declare a usage of the 3D renderer.
Definition: EventsBasedObject.h:124
gd::ObjectsContainer & GetObjects()
Get the objects of the custom object.
Definition: EventsBasedObject.h:242
void SetAreaMinX(int areaMinX)
Set the left bound of the custom object.
Definition: EventsBasedObject.h:285
gd::InitialInstancesContainer & GetInitialInstances()
Get the instances of the custom object.
Definition: EventsBasedObject.h:260
EventsBasedObject & SetPrivate(bool isPrivate)
Set that the object is private - it can't be used outside of its extension.
Definition: EventsBasedObject.h:116
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:228
EventsBasedObject & MarkAsTextContainer(bool isTextContainer_)
Declare a TextContainer capability.
Definition: EventsBasedObject.h:150
void SetAreaMaxZ(int areaMaxZ)
Set the bottom bound of the custom object.
Definition: EventsBasedObject.h:375
void SetAreaMinZ(int areaMinZ)
Set the min Z bound of the custom object.
Definition: EventsBasedObject.h:321
gd::EventsBasedObjectVariantsContainer & GetVariants()
Get the variants of the custom object.
Definition: EventsBasedObject.h:220
bool IsAnimatable() const
Return true if the object needs an Animatable capability.
Definition: EventsBasedObject.h:145
int GetAreaMaxZ() const
Get the max Z bound of the custom object.
Definition: EventsBasedObject.h:368
EventsBasedObject & MarkAsAnimatable(bool isAnimatable_)
Declare an Animatable capability.
Definition: EventsBasedObject.h:137
EventsBasedObject & MakAsUsingLegacyInstancesRenderer(bool isUsingLegacyInstancesRenderer_)
Declare that custom object are rendered using their child-objects instead of their child-instances.
Definition: EventsBasedObject.h:184
const gd::String & GetAssetStoreTag() const
Get the tag from which to choose assets from when creating a new object.
Definition: EventsBasedObject.h:101
const gd::InitialInstancesContainer & GetInitialInstances() const
Get the instances of the custom object.
Definition: EventsBasedObject.h:267
EventsBasedObject & SetName(const gd::String &name_) override
Set the internal name of the object.
Definition: EventsBasedObject.h:64
Represents a variation of style of an events-based object.
Definition: EventsBasedObjectVariant.h:26
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:39
Contains the layers for a scene or a custom object.
Definition: LayersContainer.h:22
Used as a base class for classes that will own objects (see gd::Object).
Definition: ObjectsContainer.h:38
std::vector< std::unique_ptr< gd::Object > > & GetObjects()
Definition: ObjectsContainer.h:178
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