GDevelop Core
Core library for developing platforms and tools compatible with GDevelop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Public Member Functions | Public Attributes | 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.
 
float GetX () const
 Get the X position of the instance.
 
void SetX (float x_)
 Set the X position of the instance.
 
float GetY () const
 Get the Y position of the instance.
 
void SetY (float y_)
 Set the Y position of the instance.
 
float GetAngle () const
 Get the rotation of the instance, in radians.
 
void SetAngle (float angle_)
 Set the rotation of the instance, in radians.
 
int GetZOrder () const
 Get the Z order of the instance.
 
void SetZOrder (int zOrder_)
 Set the Z order of the instance.
 
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 size which is different from its object default size. More...
 
void SetHasCustomSize (bool hasCustomSize_)
 Set whether the instance has a size which is different from its object default size or not. More...
 
float GetCustomWidth () const
 
void SetCustomWidth (float width_)
 
float GetCustomHeight () const
 
void SetCustomHeight (float height_)
 
bool IsLocked () const
 Return true if the instance is locked and cannot be selected by clicking on it in the IDE.
 
void SetLocked (bool enable=true)
 (Un)lock the initial instance. More...
 
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: these properties can be stored into floatInfos and stringInfos members. When the IDE want to get the custom properties, it will call GetProperties and UpdateProperty 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::PropertyDescriptor
GetCustomProperties (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...
 
float GetRawFloatProperty (const gd::String &name) const
 Get the value of a float 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 SetRawFloatProperty (const gd::String &name, float value)
 Set the value of a float 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.
 

Public Attributes

std::map< gd::String, float > floatInfos
 More data which can be used by the object.
 
std::map< gd::String, gd::StringstringInfos
 More data which can be used by the object.
 

Detailed Description

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

Member Function Documentation

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);
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
float gd::InitialInstance::GetRawFloatProperty ( const gd::String name) const

Get the value of a float 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.
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.
const gd::VariablesContainer& gd::InitialInstance::GetVariables ( ) const
inline

Must return a reference to the container storing the instance variables

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

Must return a reference to the container storing the instance variables

See also
gd::VariablesContainer
bool gd::InitialInstance::HasCustomSize ( ) const
inline

Return true if the instance has a size which is different from its object default size.

See also
gd::Object
void gd::InitialInstance::SetHasCustomSize ( bool  hasCustomSize_)
inline

Set whether the instance has a size which is different from its object default size or not.

Parameters
hasCustomSizetrue if the size is different from the object's default size.
See also
gd::Object
void gd::InitialInstance::SetLocked ( bool  enable = true)
inline

(Un)lock the initial instance.

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

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: