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 
79  virtual AbstractEventsBasedEntity& SetName(const gd::String& name_) {
80  name = name_;
81  return *this;
82  }
83 
87  const gd::String& GetFullName() const { return fullName; };
88 
92  virtual AbstractEventsBasedEntity& SetFullName(const gd::String& fullName_) {
93  fullName = fullName_;
94  return *this;
95  }
96 
97  const gd::String &GetPreviewIconUrl() const { return previewIconUrl; };
98  virtual AbstractEventsBasedEntity &
99  SetPreviewIconUrl(const gd::String &previewIconUrl_) {
100  previewIconUrl = previewIconUrl_;
101  return *this;
102  }
103 
104  const gd::String &GetIconUrl() const { return iconUrl; };
105  virtual AbstractEventsBasedEntity &SetIconUrl(const gd::String &iconUrl_) {
106  iconUrl = iconUrl_;
107  return *this;
108  }
109 
114  const gd::String &GetHelpPath() const { return helpPath; };
115 
120  virtual AbstractEventsBasedEntity &SetHelpPath(const gd::String &helpPath_) {
121  helpPath = helpPath_;
122  return *this;
123  }
124 
129  return eventsFunctionsContainer;
130  }
131 
137  return eventsFunctionsContainer;
138  }
139 
144  return propertyDescriptors;
145  }
146 
151  return propertyDescriptors;
152  }
153 
157  static gd::String GetPropertyActionName(const gd::String& propertyName) { return "SetProperty" + propertyName; };
158 
162  static gd::String GetPropertyConditionName(const gd::String& propertyName) { return "Property" + propertyName; };
163 
167  static gd::String GetPropertyExpressionName(const gd::String& propertyName) { return "Property" + propertyName; };
168 
172  static gd::String GetPropertyToggleActionName(const gd::String& propertyName) { return "ToggleProperty" + propertyName; };
173 
177 
180  virtual void SerializeTo(gd::SerializerElement& element) const;
181 
185  virtual void UnserializeFrom(gd::Project& project,
186  const gd::SerializerElement& element);
188 
189  private:
190  gd::String name;
191  gd::String fullName;
192  gd::String description;
193  gd::EventsFunctionsContainer eventsFunctionsContainer;
194  gd::PropertiesContainer propertyDescriptors;
195  gd::String extensionName;
196  bool isPrivate = false;
197  gd::String previewIconUrl;
198  gd::String iconUrl;
199  gd::String helpPath;
201 };
202 
203 } // 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:172
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:167
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:150
virtual AbstractEventsBasedEntity & SetName(const gd::String &name_)
Set the internal name of the behavior or object.
Definition: AbstractEventsBasedEntity.h:79
const gd::String & GetHelpPath() const
Get the help path relative to the GDevelop documentation root.
Definition: AbstractEventsBasedEntity.h:114
static gd::String GetPropertyActionName(const gd::String &propertyName)
Get the name of the action to change a property.
Definition: AbstractEventsBasedEntity.h:157
static gd::String GetPropertyConditionName(const gd::String &propertyName)
Get the name of the condition to compare a property.
Definition: AbstractEventsBasedEntity.h:162
gd::PropertiesContainer & GetPropertyDescriptors()
Return a reference to the list of the properties.
Definition: AbstractEventsBasedEntity.h:143
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:136
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
bool IsPrivate() const
Check if the behavior or object is private - it can't be used outside of its extension.
Definition: AbstractEventsBasedEntity.h:46
virtual AbstractEventsBasedEntity & SetHelpPath(const gd::String &helpPath_)
Set the help path relative to the GDevelop documentation root.
Definition: AbstractEventsBasedEntity.h:120
EventsFunctionsContainer & GetEventsFunctions()
Return a reference to the functions of the events based behavior or object.
Definition: AbstractEventsBasedEntity.h:128
const gd::String & GetDescription() const
Get the description of the behavior or object, that is displayed in the editor.
Definition: AbstractEventsBasedEntity.h:61
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:51
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