GDevelop Core
Core library for developing platforms and tools compatible with GDevelop.
Public Member Functions | List of all members
gd::InitialInstance Class Reference

Represents an instance of an object to be created on a layout start up. More...

#include <InitialInstance.h>

Public Member Functions

 InitialInstance ()
 Create an initial instance pointing to no object, at position (0,0).
 
InitialInstanceClone () const
 
Common properties

Members functions related to common properties

const gd::StringGetObjectName () const
 Get the name of object instantiated on the layout.
 
void SetObjectName (const gd::String &name)
 Set the name of object instantiated on the layout.
 
double GetX () const
 Get the X position of the instance.
 
void SetX (double x_)
 Set the X position of the instance.
 
double GetY () const
 Get the Y position of the instance.
 
void SetY (double y_)
 Set the Y position of the instance.
 
double GetZ () const
 Get the Z position of the instance.
 
void SetZ (double z_)
 Set the Z position of the instance.
 
double GetAngle () const
 Get the rotation of the instance on Z axis, in radians.
 
void SetAngle (double angle_)
 Set the rotation of the instance on Z axis, in radians.
 
double GetRotationX () const
 Get the rotation of the instance on X axis, in radians.
 
void SetRotationX (double rotationX_)
 Set the rotation of the instance on X axis, in radians.
 
double GetRotationY () const
 Get the rotation of the instance on Y axis, in radians.
 
void SetRotationY (double rotationY_)
 Set the rotation of the instance on Y axis, in radians.
 
int GetZOrder () const
 Get the Z order of the instance (for a 2D object).
 
void SetZOrder (int zOrder_)
 Set the Z order of the instance (for a 2D object).
 
const gd::StringGetLayer () const
 Get the layer the instance belongs to.
 
void SetLayer (const gd::String &layer_)
 Set the layer the instance belongs to.
 
bool HasCustomSize () const
 Return true if the instance has a width/height which is different from its object default width/height. This is independent from HasCustomDepth. More...
 
bool HasCustomDepth () const
 Return true if the instance has a depth which is different from its object default depth. This is independent from HasCustomSize. More...
 
void SetHasCustomSize (bool hasCustomSize_)
 Set whether the instance has a width/height which is different from its object default width/height or not. This is independent from SetHasCustomDepth. More...
 
void SetHasCustomDepth (bool hasCustomDepth_)
 Set whether the instance has a depth which is different from its object default depth or not. This is independent from SetHasCustomSize. More...
 
double GetCustomWidth () const
 
void SetCustomWidth (double width_)
 
double GetCustomHeight () const
 
void SetCustomHeight (double height_)
 
double GetCustomDepth () const
 
void SetCustomDepth (double depth_)
 
bool IsLocked () const
 Return true if the instance is locked and cannot be moved in the IDE.
 
void SetLocked (bool enable=true)
 (Un)lock the initial instance. More...
 
bool IsSealed () const
 Return true if the instance cannot be selected by clicking on it in the IDE (only applies if instance is also locked).
 
void SetSealed (bool enable=true)
 (Un)seal the initial instance. More...
 
bool ShouldKeepRatio () const
 Return true if the dimensions (width, height and depth) should keep the same ratio.
 
void SetShouldKeepRatio (bool enable=true)
 Define if instance's dimensions should keep the same ratio.
 
Variable management

Members functions related to initial instance variables management.

const gd::VariablesContainerGetVariables () const
 
gd::VariablesContainerGetVariables ()
 
Others properties management

Members functions related to exposing others properties of the instance.

Note
Extensions writers: even if we can define new types of object by inheriting from gd::Object class, we cannot define new gd::InitialInstance classes.

However, objects can store custom properties for their associated initial instances. When the IDE want to get the custom properties, it will call GetCustomProperties and UpdateCustomProperty methods. These methods are here defined to forward the call to the gd::Object associated to the gd::InitialInstance (by looking at the value returned by GetObjectName()).

See also
gd::Object
std::map< gd::String, gd::PropertyDescriptorGetCustomProperties (gd::Project &project, gd::Layout &layout)
 Return a map containing the properties names (as keys) and their values. More...
 
bool UpdateCustomProperty (const gd::String &name, const gd::String &value, gd::Project &project, gd::Layout &layout)
 Update the property called name with the new value. More...
 
double GetRawDoubleProperty (const gd::String &name) const
 Get the value of a double property stored in the instance. More...
 
const gd::StringGetRawStringProperty (const gd::String &name) const
 Get the value of a string property stored in the instance. More...
 
void SetRawDoubleProperty (const gd::String &name, double value)
 Set the value of a double property stored in the instance.
 
void SetRawStringProperty (const gd::String &name, const gd::String &value)
 Set the value of a string property stored in the instance.
 
Saving and loading

Members functions related to serialization.

virtual void SerializeTo (SerializerElement &element) const
 Serialize instances container.
 
virtual void UnserializeFrom (const SerializerElement &element)
 Unserialize the instances container.
 
InitialInstanceResetPersistentUuid ()
 Reset the persistent UUID used to recognize the same initial instance between serialization.
 

Detailed Description

Represents an instance of an object to be created on a layout start up.

Member Function Documentation

◆ Clone()

InitialInstance* gd::InitialInstance::Clone ( ) const
inline

Must return a pointer to a copy of the object. A such method is needed to do polymorphic copies. Just redefine this method in your derived object class like this:

return new MyInitialInstanceClass(*this);

◆ GetCustomProperties()

std::map< gd::String, gd::PropertyDescriptor > gd::InitialInstance::GetCustomProperties ( gd::Project project,
gd::Layout layout 
)

Return a map containing the properties names (as keys) and their values.

Note
Common properties ( name, position... ) do not need to be inserted in this map

◆ GetRawDoubleProperty()

double gd::InitialInstance::GetRawDoubleProperty ( const gd::String name) const

Get the value of a double property stored in the instance.

Note
Only use this when GetCustomProperties is too slow (when rendering instances for example).
Returns
the value of the property, or 0 if it does not exists.

◆ GetRawStringProperty()

const gd::String & gd::InitialInstance::GetRawStringProperty ( const gd::String name) const

Get the value of a string property stored in the instance.

Note
Only use this when GetCustomProperties is too slow (when rendering instances for example).
Returns
the value of the propety, or an empty string if it does not exists.

◆ GetVariables() [1/2]

gd::VariablesContainer& gd::InitialInstance::GetVariables ( )
inline

Must return a reference to the container storing the instance variables

See also
gd::VariablesContainer

◆ GetVariables() [2/2]

const gd::VariablesContainer& gd::InitialInstance::GetVariables ( ) const
inline

Must return a reference to the container storing the instance variables

See also
gd::VariablesContainer

◆ HasCustomDepth()

bool gd::InitialInstance::HasCustomDepth ( ) const
inline

Return true if the instance has a depth which is different from its object default depth. This is independent from HasCustomSize.

See also
gd::Object

◆ HasCustomSize()

bool gd::InitialInstance::HasCustomSize ( ) const
inline

Return true if the instance has a width/height which is different from its object default width/height. This is independent from HasCustomDepth.

See also
gd::Object

◆ SetHasCustomDepth()

void gd::InitialInstance::SetHasCustomDepth ( bool  hasCustomDepth_)
inline

Set whether the instance has a depth which is different from its object default depth or not. This is independent from SetHasCustomSize.

Parameters
hasCustomSizetrue if the depth is different from the object's default depth.
See also
gd::Object

◆ SetHasCustomSize()

void gd::InitialInstance::SetHasCustomSize ( bool  hasCustomSize_)
inline

Set whether the instance has a width/height which is different from its object default width/height or not. This is independent from SetHasCustomDepth.

See also
gd::Object

◆ SetLocked()

void gd::InitialInstance::SetLocked ( bool  enable = true)
inline

(Un)lock the initial instance.

An instance which is locked cannot be moved with actions in the IDE.

◆ SetSealed()

void gd::InitialInstance::SetSealed ( bool  enable = true)
inline

(Un)seal the initial instance.

An instance which is sealed cannot be selected by clicking on it in a layout editor canvas.

◆ UpdateCustomProperty()

bool gd::InitialInstance::UpdateCustomProperty ( const gd::String name,
const gd::String value,
gd::Project project,
gd::Layout layout 
)

Update the property called name with the new value.

Returns
false if the property could not be updated.

The documentation for this class was generated from the following files: