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 #pragma once
8 
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 class ObjectsContainer;
18 } // namespace gd
19 
20 namespace gd {
21 
26 class GD_CORE_API InitialInstance {
27  public:
32  virtual ~InitialInstance() {};
33 
39  InitialInstance* Clone() const { return new InitialInstance(*this); }
40 
45 
49  const gd::String& GetObjectName() const { return objectName; }
50 
54  void SetObjectName(const gd::String& name) { objectName = name; }
55 
59  double GetX() const { return x; }
60 
64  void SetX(double x_) { x = x_; }
65 
69  double GetY() const { return y; }
70 
74  void SetY(double y_) { y = y_; }
75 
79  double GetZ() const { return z; }
80 
84  void SetZ(double z_) { z = z_; }
85 
89  double GetAngle() const { return angle; }
90 
94  void SetAngle(double angle_) { angle = angle_; }
95 
99  double GetRotationX() const { return rotationX; }
100 
104  void SetRotationX(double rotationX_) { rotationX = rotationX_; }
105 
109  double GetRotationY() const { return rotationY; }
110 
114  void SetRotationY(double rotationY_) { rotationY = rotationY_; }
115 
119  int GetZOrder() const { return zOrder; }
120 
124  void SetZOrder(int zOrder_) { zOrder = zOrder_; }
125 
129  int GetOpacity() const { return opacity; }
130 
134  void SetOpacity(int opacity_) { opacity = opacity_; }
135 
139  bool IsFlippedX() const { return flippedX; }
140 
144  void SetFlippedX(bool flippedX_) { flippedX = flippedX_; }
145 
149  bool IsFlippedY() const { return flippedY; }
150 
154  void SetFlippedY(bool flippedY_) { flippedY = flippedY_; }
155 
159  bool IsFlippedZ() const { return flippedZ; }
160 
164  void SetFlippedZ(bool flippedZ_) { flippedZ = flippedZ_; }
165 
169  const gd::String& GetLayer() const { return layer; }
170 
174  void SetLayer(const gd::String& layer_) { layer = layer_; }
175 
183  bool HasCustomSize() const { return customSize; }
184 
191  bool HasCustomDepth() const { return customDepth; }
192 
200  void SetHasCustomSize(bool hasCustomSize_) { customSize = hasCustomSize_; }
201 
211  void SetHasCustomDepth(bool hasCustomDepth_) {
212  customDepth = hasCustomDepth_;
213  }
214 
215  double GetCustomWidth() const { return width; }
216  void SetCustomWidth(double width_) { width = width_; }
217  double GetCustomHeight() const { return height; }
218  void SetCustomHeight(double height_) { height = height_; }
219  double GetCustomDepth() const { return depth; }
220  void SetCustomDepth(double depth_) { depth = depth_; }
221 
226  bool IsLocked() const { return locked; };
227 
233  void SetLocked(bool enable = true) { locked = enable; }
234 
239  bool IsSealed() const { return sealed; };
240 
247  void SetSealed(bool enable = true) { sealed = enable; }
248 
253  bool ShouldKeepRatio() const { return keepRatio; };
254 
258  void SetShouldKeepRatio(bool enable = true) { keepRatio = enable; }
259 
261 
266 
272  return initialVariables;
273  }
274 
279  gd::VariablesContainer& GetVariables() { return initialVariables; }
281 
299 
306  std::map<gd::String, gd::PropertyDescriptor> GetCustomProperties(
307  gd::ObjectsContainer& globalObjectsContainer,
308  gd::ObjectsContainer& objectsContainer);
309 
315  bool UpdateCustomProperty(const gd::String& name,
316  const gd::String& value,
317  gd::ObjectsContainer& globalObjectsContainer,
318  gd::ObjectsContainer& objectsContainer);
319 
327  double GetRawDoubleProperty(const gd::String& name) const;
328 
336  const gd::String& GetRawStringProperty(const gd::String& name) const;
337 
341  void SetRawDoubleProperty(const gd::String& name, double value);
342 
346  void SetRawStringProperty(const gd::String& name, const gd::String& value);
348 
353 
356  virtual void SerializeTo(SerializerElement& element) const;
357 
361  virtual void UnserializeFrom(const SerializerElement& element);
362 
367  InitialInstance& ResetPersistentUuid();
369 
370  private:
371  // More properties can be stored in numberProperties and stringProperties.
372  // These properties are then managed by the Object class.
373  std::map<gd::String, double>
374  numberProperties;
375  std::map<gd::String, gd::String>
376  stringProperties;
377 
378  gd::String objectName;
379  double x;
380  double y;
381  double z;
382  double angle;
383  double rotationX;
384  double rotationY;
385  int zOrder;
386  int opacity;
387  bool flippedX;
388  bool flippedY;
389  bool flippedZ;
390  gd::String layer;
391  bool customSize;
392  bool customDepth;
393  double width;
394  double height;
395  double depth;
396  gd::VariablesContainer initialVariables;
397  bool locked;
398  bool sealed;
399  bool keepRatio;
401  mutable gd::String persistentUuid;
403 
404  static gd::String* badStringPropertyValue;
406 };
407 
408 } // namespace gd
Represents an instance of an object to be created on a layout start up.
Definition: InitialInstance.h:26
double GetRotationY() const
Get the rotation of the instance on Y axis, in radians.
Definition: InitialInstance.h:109
double GetRotationX() const
Get the rotation of the instance on X axis, in radians.
Definition: InitialInstance.h:99
void SetY(double y_)
Set the Y position of the instance.
Definition: InitialInstance.h:74
bool ShouldKeepRatio() const
Return true if the dimensions (width, height and depth) should keep the same ratio.
Definition: InitialInstance.h:253
void SetAngle(double angle_)
Set the rotation of the instance on Z axis, in radians.
Definition: InitialInstance.h:94
void SetX(double x_)
Set the X position of the instance.
Definition: InitialInstance.h:64
gd::VariablesContainer & GetVariables()
Definition: InitialInstance.h:279
double GetZ() const
Get the Z position of the instance.
Definition: InitialInstance.h:79
bool IsFlippedX() const
Return true if the instance is flipped on X axis.
Definition: InitialInstance.h:139
void SetRotationY(double rotationY_)
Set the rotation of the instance on Y axis, in radians.
Definition: InitialInstance.h:114
bool IsLocked() const
Return true if the instance is locked and cannot be moved in the IDE.
Definition: InitialInstance.h:226
void SetFlippedY(bool flippedY_)
Set whether the instance is flipped on Y axis.
Definition: InitialInstance.h:154
bool HasCustomDepth() const
Return true if the instance has a depth which is different from its object default depth....
Definition: InitialInstance.h:191
const gd::String & GetLayer() const
Get the layer the instance belongs to.
Definition: InitialInstance.h:169
void SetFlippedZ(bool flippedZ_)
Set whether the instance is flipped on Z axis.
Definition: InitialInstance.h:164
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:200
void SetObjectName(const gd::String &name)
Set the name of object instantiated on the layout.
Definition: InitialInstance.h:54
const gd::String & GetObjectName() const
Get the name of object instantiated on the layout.
Definition: InitialInstance.h:49
void SetZOrder(int zOrder_)
Set the Z order of the instance (for a 2D object).
Definition: InitialInstance.h:124
double GetY() const
Get the Y position of the instance.
Definition: InitialInstance.h:69
void SetOpacity(int opacity_)
Set the opacity of the instance.
Definition: InitialInstance.h:134
void SetRotationX(double rotationX_)
Set the rotation of the instance on X axis, in radians.
Definition: InitialInstance.h:104
void SetShouldKeepRatio(bool enable=true)
Define if instance's dimensions should keep the same ratio.
Definition: InitialInstance.h:258
void SetZ(double z_)
Set the Z position of the instance.
Definition: InitialInstance.h:84
void SetFlippedX(bool flippedX_)
Set whether the instance is flipped on X axis.
Definition: InitialInstance.h:144
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:239
void SetLayer(const gd::String &layer_)
Set the layer the instance belongs to.
Definition: InitialInstance.h:174
int GetOpacity() const
Get Opacity.
Definition: InitialInstance.h:129
double GetAngle() const
Get the rotation of the instance on Z axis, in radians.
Definition: InitialInstance.h:89
bool IsFlippedZ() const
Return true if the instance is flipped on Z axis.
Definition: InitialInstance.h:159
InitialInstance * Clone() const
Definition: InitialInstance.h:39
bool IsFlippedY() const
Return true if the instance is flipped on Y axis.
Definition: InitialInstance.h:149
bool HasCustomSize() const
Return true if the instance has a width/height which is different from its object default width/heigh...
Definition: InitialInstance.h:183
int GetZOrder() const
Get the Z order of the instance (for a 2D object).
Definition: InitialInstance.h:119
double GetX() const
Get the X position of the instance.
Definition: InitialInstance.h:59
void SetLocked(bool enable=true)
(Un)lock the initial instance.
Definition: InitialInstance.h:233
void SetHasCustomDepth(bool hasCustomDepth_)
Set whether the instance has a depth which is different from its object default depth or not....
Definition: InitialInstance.h:211
void SetSealed(bool enable=true)
(Un)seal the initial instance.
Definition: InitialInstance.h:247
const gd::VariablesContainer & GetVariables() const
Definition: InitialInstance.h:271
Used as a base class for classes that will own objects (see gd::Object).
Definition: ObjectsContainer.h:37
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
Class defining a container for gd::Variable.
Definition: VariablesContainer.h:28
Definition: CommonTools.h:24