GDevelop Core
Core library for developing platforms and tools compatible with GDevelop.
InitialInstance.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 
7 #ifndef GDCORE_INITIALINSTANCE_H
8 #define GDCORE_INITIALINSTANCE_H
9 #include <map>
10 
11 #include "GDCore/Project/VariablesContainer.h"
12 #include "GDCore/String.h"
13 namespace gd {
14 class PropertyDescriptor;
15 class Project;
16 class Layout;
17 } // namespace gd
18 
19 namespace gd {
20 
25 class GD_CORE_API InitialInstance {
26  public:
31  virtual ~InitialInstance(){};
32 
38  InitialInstance* Clone() const { return new InitialInstance(*this); }
39 
44 
48  const gd::String& GetObjectName() const { return objectName; }
49 
53  void SetObjectName(const gd::String& name) { objectName = name; }
54 
58  double GetX() const { return x; }
59 
63  void SetX(double x_) { x = x_; }
64 
68  double GetY() const { return y; }
69 
73  void SetY(double y_) { y = y_; }
74 
78  double GetZ() const { return z; }
79 
83  void SetZ(double z_) { z = z_; }
84 
88  double GetAngle() const { return angle; }
89 
93  void SetAngle(double angle_) { angle = angle_; }
94 
98  double GetRotationX() const { return rotationX; }
99 
103  void SetRotationX(double rotationX_) { rotationX = rotationX_; }
104 
108  double GetRotationY() const { return rotationY; }
109 
113  void SetRotationY(double rotationY_) { rotationY = rotationY_; }
114 
118  int GetZOrder() const { return zOrder; }
119 
123  void SetZOrder(int zOrder_) { zOrder = zOrder_; }
124 
128  const gd::String& GetLayer() const { return layer; }
129 
133  void SetLayer(const gd::String& layer_) { layer = layer_; }
134 
141  bool HasCustomSize() const { return customSize; }
142 
149  bool HasCustomDepth() const { return customDepth; }
150 
158  void SetHasCustomSize(bool hasCustomSize_) {
159  customSize = hasCustomSize_;
160  }
161 
171  void SetHasCustomDepth(bool hasCustomDepth_) {
172  customDepth = hasCustomDepth_;
173  }
174 
175  double GetCustomWidth() const { return width; }
176  void SetCustomWidth(double width_) { width = width_; }
177  double GetCustomHeight() const { return height; }
178  void SetCustomHeight(double height_) { height = height_; }
179  double GetCustomDepth() const { return depth; }
180  void SetCustomDepth(double depth_) { depth = depth_; }
181 
186  bool IsLocked() const { return locked; };
187 
193  void SetLocked(bool enable = true) { locked = enable; }
194 
199  bool IsSealed() const { return sealed; };
200 
207  void SetSealed(bool enable = true) { sealed = enable; }
208 
213  bool ShouldKeepRatio() const { return keepRatio; };
214 
218  void SetShouldKeepRatio(bool enable = true) { keepRatio = enable; }
219 
221 
226 
232  return initialVariables;
233  }
234 
239  gd::VariablesContainer& GetVariables() { return initialVariables; }
241 
259 
266  std::map<gd::String, gd::PropertyDescriptor> GetCustomProperties(
267  gd::Project& project, gd::Layout& layout);
268 
274  bool UpdateCustomProperty(const gd::String& name,
275  const gd::String& value,
276  gd::Project& project,
277  gd::Layout& layout);
278 
286  double GetRawDoubleProperty(const gd::String& name) const;
287 
295  const gd::String& GetRawStringProperty(const gd::String& name) const;
296 
300  void SetRawDoubleProperty(const gd::String& name, double value);
301 
305  void SetRawStringProperty(const gd::String& name, const gd::String& value);
307 
312 
315  virtual void SerializeTo(SerializerElement& element) const;
316 
320  virtual void UnserializeFrom(const SerializerElement& element);
321 
326  InitialInstance& ResetPersistentUuid();
328 
329  private:
330  // More properties can be stored in numberProperties and stringProperties.
331  // These properties are then managed by the Object class.
332  std::map<gd::String, double>
333  numberProperties;
334  std::map<gd::String, gd::String>
335  stringProperties;
336 
337  gd::String objectName;
338  double x;
339  double y;
340  double z;
341  double angle;
342  double rotationX;
343  double rotationY;
344  int zOrder;
345  gd::String layer;
346  bool customSize;
347  bool customDepth;
348  double width;
349  double height;
350  double depth;
351  gd::VariablesContainer initialVariables;
352  bool locked;
353  bool sealed;
354  bool keepRatio;
356  mutable gd::String persistentUuid;
358 
359  static gd::String*
360  badStringPropertyValue;
361 };
362 
363 } // namespace gd
364 
365 #endif // GDCORE_INITIALINSTANCE_H
Represents an instance of an object to be created on a layout start up.
Definition: InitialInstance.h:25
double GetRotationY() const
Get the rotation of the instance on Y axis, in radians.
Definition: InitialInstance.h:108
double GetRotationX() const
Get the rotation of the instance on X axis, in radians.
Definition: InitialInstance.h:98
void SetY(double y_)
Set the Y position of the instance.
Definition: InitialInstance.h:73
bool ShouldKeepRatio() const
Return true if the dimensions (width, height and depth) should keep the same ratio.
Definition: InitialInstance.h:213
void SetAngle(double angle_)
Set the rotation of the instance on Z axis, in radians.
Definition: InitialInstance.h:93
void SetX(double x_)
Set the X position of the instance.
Definition: InitialInstance.h:63
gd::VariablesContainer & GetVariables()
Definition: InitialInstance.h:239
double GetZ() const
Get the Z position of the instance.
Definition: InitialInstance.h:78
void SetRotationY(double rotationY_)
Set the rotation of the instance on Y axis, in radians.
Definition: InitialInstance.h:113
bool IsLocked() const
Return true if the instance is locked and cannot be moved in the IDE.
Definition: InitialInstance.h:186
bool HasCustomDepth() const
Return true if the instance has a depth which is different from its object default depth....
Definition: InitialInstance.h:149
const gd::String & GetLayer() const
Get the layer the instance belongs to.
Definition: InitialInstance.h:128
void SetHasCustomSize(bool hasCustomSize_)
Set whether the instance has a width/height which is different from its object default width/height o...
Definition: InitialInstance.h:158
void SetObjectName(const gd::String &name)
Set the name of object instantiated on the layout.
Definition: InitialInstance.h:53
const gd::String & GetObjectName() const
Get the name of object instantiated on the layout.
Definition: InitialInstance.h:48
void SetZOrder(int zOrder_)
Set the Z order of the instance (for a 2D object).
Definition: InitialInstance.h:123
double GetY() const
Get the Y position of the instance.
Definition: InitialInstance.h:68
void SetRotationX(double rotationX_)
Set the rotation of the instance on X axis, in radians.
Definition: InitialInstance.h:103
void SetShouldKeepRatio(bool enable=true)
Define if instance's dimensions should keep the same ratio.
Definition: InitialInstance.h:218
void SetZ(double z_)
Set the Z position of the instance.
Definition: InitialInstance.h:83
bool IsSealed() const
Return true if the instance cannot be selected by clicking on it in the IDE (only applies if instance...
Definition: InitialInstance.h:199
void SetLayer(const gd::String &layer_)
Set the layer the instance belongs to.
Definition: InitialInstance.h:133
double GetAngle() const
Get the rotation of the instance on Z axis, in radians.
Definition: InitialInstance.h:88
InitialInstance * Clone() const
Definition: InitialInstance.h:38
bool HasCustomSize() const
Return true if the instance has a width/height which is different from its object default width/heigh...
Definition: InitialInstance.h:141
int GetZOrder() const
Get the Z order of the instance (for a 2D object).
Definition: InitialInstance.h:118
double GetX() const
Get the X position of the instance.
Definition: InitialInstance.h:58
void SetLocked(bool enable=true)
(Un)lock the initial instance.
Definition: InitialInstance.h:193
void SetHasCustomDepth(bool hasCustomDepth_)
Set whether the instance has a depth which is different from its object default depth or not....
Definition: InitialInstance.h:171
void SetSealed(bool enable=true)
(Un)seal the initial instance.
Definition: InitialInstance.h:207
const gd::VariablesContainer & GetVariables() const
Definition: InitialInstance.h:231
Represent a layout ( also called a scene ) of a project.
Definition: Layout.h:39
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:31
Class defining a container for gd::Variable.
Definition: VariablesContainer.h:30
Definition: CommonTools.h:24