GDevelop Core
Core library for developing platforms and tools compatible with GDevelop.
EventsBasedBehavior.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 #ifndef GDCORE_EVENTSBASEDBEHAVIOR_H
7 #define GDCORE_EVENTSBASEDBEHAVIOR_H
8 
9 #include <vector>
10 #include "GDCore/Project/AbstractEventsBasedEntity.h"
11 #include "GDCore/Project/NamedPropertyDescriptor.h"
12 #include "GDCore/Project/PropertiesContainer.h"
13 #include "GDCore/Project/EventsFunctionsContainer.h"
14 #include "GDCore/Project/QuickCustomization.h"
15 #include "GDCore/String.h"
16 namespace gd {
17 class SerializerElement;
18 class Project;
19 } // namespace gd
20 
21 namespace gd {
22 
33  public:
35  virtual ~EventsBasedBehavior(){};
36 
41  EventsBasedBehavior* Clone() const { return new EventsBasedBehavior(*this); };
42 
43  EventsBasedBehavior& SetDescription(const gd::String& description_) override {
45  return *this;
46  }
47 
53  return *this;
54  }
55 
61  return *this;
62  }
63 
67  const gd::String& GetObjectType() const { return objectType; };
68 
73  objectType = objectType_;
74  return *this;
75  }
76 
81  bool IsPrivate() const { return isPrivate; }
82 
87  EventsBasedBehavior& SetPrivate(bool _isPrivate) {
88  isPrivate = _isPrivate;
89  return *this;
90  }
91 
92  QuickCustomization::Visibility GetQuickCustomizationVisibility() const {
93  return quickCustomizationVisibility;
94  }
95 
96  EventsBasedBehavior& SetQuickCustomizationVisibility(QuickCustomization::Visibility visibility) {
97  quickCustomizationVisibility = visibility;
98  return *this;
99  }
100 
105  return sharedPropertyDescriptors;
106  }
107 
112  const {
113  return sharedPropertyDescriptors;
114  }
115 
119  static gd::String GetSharedPropertyActionName(const gd::String &propertyName) {
120  return "SetSharedProperty" + propertyName;
121  };
122 
127  return "SharedProperty" + propertyName;
128  };
129 
133  static gd::String
135  return "SharedProperty" + propertyName;
136  };
137 
142  return "ToggleSharedProperty" + propertyName;
143  };
144 
145  void SerializeTo(SerializerElement& element) const override;
146 
147  void UnserializeFrom(gd::Project& project,
148  const SerializerElement& element) override;
149 
150  private:
151  gd::String objectType;
152  bool isPrivate = false;
153  gd::PropertiesContainer sharedPropertyDescriptors;
154  QuickCustomization::Visibility quickCustomizationVisibility;
155 };
156 
157 } // namespace gd
158 
159 #endif // GDCORE_EVENTSBASEDBEHAVIOR_H
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 a behavior that is implemented with events.
Definition: EventsBasedBehavior.h:32
EventsBasedBehavior * Clone() const
Return a pointer to a new EventsBasedBehavior constructed from this one.
Definition: EventsBasedBehavior.h:41
static gd::String GetSharedPropertyConditionName(const gd::String &propertyName)
Get the name of the condition to compare a shared property.
Definition: EventsBasedBehavior.h:126
const gd::String & GetObjectType() const
Get the object type the behavior should be used with.
Definition: EventsBasedBehavior.h:67
static gd::String GetSharedPropertyExpressionName(const gd::String &propertyName)
Get the name of the expression to get a shared property.
Definition: EventsBasedBehavior.h:134
static gd::String GetSharedPropertyActionName(const gd::String &propertyName)
Get the name of the action to change a shared property.
Definition: EventsBasedBehavior.h:119
EventsBasedBehavior & SetName(const gd::String &name_)
Set the internal name of the behavior.
Definition: EventsBasedBehavior.h:51
const gd::PropertiesContainer & GetSharedPropertyDescriptors() const
Return a const reference to the list of shared properties.
Definition: EventsBasedBehavior.h:111
EventsBasedBehavior & SetFullName(const gd::String &fullName_)
Set the name of the behavior, to be displayed in the editor.
Definition: EventsBasedBehavior.h:59
EventsBasedBehavior & SetDescription(const gd::String &description_) override
Set the description of the behavior or object, to be displayed in the editor.
Definition: EventsBasedBehavior.h:43
EventsBasedBehavior & SetObjectType(const gd::String &objectType_)
Set the object type the behavior should be used with.
Definition: EventsBasedBehavior.h:72
bool IsPrivate() const
Check if the behavior is private - it can't be used outside of its extension.
Definition: EventsBasedBehavior.h:81
static gd::String GetSharedPropertyToggleActionName(const gd::String &propertyName)
Get the name of the action to toggle a boolean shared property.
Definition: EventsBasedBehavior.h:141
gd::PropertiesContainer & GetSharedPropertyDescriptors()
Return a reference to the list of shared properties.
Definition: EventsBasedBehavior.h:104
EventsBasedBehavior & SetPrivate(bool _isPrivate)
Set that the behavior is private - it can't be used outside of its extension.
Definition: EventsBasedBehavior.h:87
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
Visibility
Definition: QuickCustomization.h:8
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