GDevelop Core
Core library for developing platforms and tools compatible with GDevelop.
AbstractEventsBasedEntity.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/NamedPropertyDescriptor.h"
10 #include "GDCore/Project/PropertiesContainer.h"
11 #include "GDCore/Project/EventsFunctionsContainer.h"
12 #include "GDCore/String.h"
13 namespace gd {
14 class SerializerElement;
15 class Project;
16 } // namespace gd
17 
18 namespace gd {
19 
29 class GD_CORE_API AbstractEventsBasedEntity {
30  public:
32  const gd::String& _name,
33  gd::EventsFunctionsContainer::FunctionOwner functionContainerSource);
34  virtual ~AbstractEventsBasedEntity(){};
35 
41 
46  bool IsPrivate() const { return isPrivate; }
47 
53  isPrivate = isPrivate_;
54  return *this;
55  }
56 
61  const gd::String& GetDescription() const { return description; };
62 
66  virtual AbstractEventsBasedEntity& SetDescription(const gd::String& description_) {
67  description = description_;
68  return *this;
69  }
70 
74  const gd::String& GetName() const { return name; };
75 
80  name = name_;
81  return *this;
82  }
83 
87  const gd::String& GetFullName() const { return fullName; };
88 
93  fullName = fullName_;
94  return *this;
95  }
96 
101  return eventsFunctionsContainer;
102  }
103 
109  return eventsFunctionsContainer;
110  }
111 
116  return propertyDescriptors;
117  }
118 
123  return propertyDescriptors;
124  }
125 
129  static gd::String GetPropertyActionName(const gd::String& propertyName) { return "SetProperty" + propertyName; };
130 
134  static gd::String GetPropertyConditionName(const gd::String& propertyName) { return "Property" + propertyName; };
135 
139  static gd::String GetPropertyExpressionName(const gd::String& propertyName) { return "Property" + propertyName; };
140 
144  static gd::String GetPropertyToggleActionName(const gd::String& propertyName) { return "ToggleProperty" + propertyName; };
145 
149 
152  virtual void SerializeTo(gd::SerializerElement& element) const;
153 
157  virtual void UnserializeFrom(gd::Project& project,
158  const gd::SerializerElement& element);
160 
161  private:
162  gd::String name;
163  gd::String fullName;
164  gd::String description;
165  gd::EventsFunctionsContainer eventsFunctionsContainer;
166  gd::PropertiesContainer propertyDescriptors;
167  gd::String extensionName;
168  bool isPrivate = false;
169 };
170 
171 } // namespace gd
Represents a behavior or an object that is implemented with events.
Definition: AbstractEventsBasedEntity.h:29
static gd::String GetPropertyToggleActionName(const gd::String &propertyName)
Get the name of the action to toggle a boolean property.
Definition: AbstractEventsBasedEntity.h:144
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
static gd::String GetPropertyExpressionName(const gd::String &propertyName)
Get the name of the expression to get a property.
Definition: AbstractEventsBasedEntity.h:139
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
const gd::PropertiesContainer & GetPropertyDescriptors() const
Return a const reference to the list of the properties.
Definition: AbstractEventsBasedEntity.h:122
static gd::String GetPropertyActionName(const gd::String &propertyName)
Get the name of the action to change a property.
Definition: AbstractEventsBasedEntity.h:129
static gd::String GetPropertyConditionName(const gd::String &propertyName)
Get the name of the condition to compare a property.
Definition: AbstractEventsBasedEntity.h:134
gd::PropertiesContainer & GetPropertyDescriptors()
Return a reference to the list of the properties.
Definition: AbstractEventsBasedEntity.h:115
AbstractEventsBasedEntity * Clone() const
Return a pointer to a new AbstractEventsBasedEntity constructed from this one.
Definition: AbstractEventsBasedEntity.h:40
const gd::String & GetFullName() const
Get the name of the behavior or object, that is displayed in the editor.
Definition: AbstractEventsBasedEntity.h:87
const EventsFunctionsContainer & GetEventsFunctions() const
Return a const reference to the functions of the events based behavior or object.
Definition: AbstractEventsBasedEntity.h:108
bool IsPrivate() const
Check if the behavior or object is private - it can't be used outside of its extension.
Definition: AbstractEventsBasedEntity.h:46
AbstractEventsBasedEntity & SetName(const gd::String &name_)
Set the internal name of the behavior or object.
Definition: AbstractEventsBasedEntity.h:79
EventsFunctionsContainer & GetEventsFunctions()
Return a reference to the functions of the events based behavior or object.
Definition: AbstractEventsBasedEntity.h:100
const gd::String & GetDescription() const
Get the description of the behavior or object, that is displayed in the editor.
Definition: AbstractEventsBasedEntity.h:61
AbstractEventsBasedEntity & SetFullName(const gd::String &fullName_)
Set the name of the behavior or object, to be displayed in the editor.
Definition: AbstractEventsBasedEntity.h:92
const gd::String & GetName() const
Get the internal name of the behavior or object.
Definition: AbstractEventsBasedEntity.h:74
Used as a base class for classes that will own events-backed functions.
Definition: EventsFunctionsContainer.h:27
Base class representing a project (game), including all resources, scenes, objects,...
Definition: Project.h:50
A container of properties, used for custom behaviors, custom objects, extensions.....
Definition: PropertiesContainer.h:17
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