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 | Protected Member Functions | Protected Attributes | List of all members

Base class used to represent an object of a platform. More...

#include <Object.h>

Inherited by gd::SpriteObject.

Public Member Functions

 Object (const gd::String &name)
 
 Object (const gd::Object &object)
 
Objectoperator= (const gd::Object &object)
 
virtual ~Object ()
 
virtual std::unique_ptr
< gd::Object
Clone () const
 
Common properties

Members functions related to common properties

void SetName (const gd::String &name_)
 Change the name of the object with the name passed as parameter.
 
const gd::StringGetName () const
 Return the name of the object.
 
void SetType (const gd::String &type_)
 Change the type of the object.
 
const gd::StringGetType () const
 Return the type of the object.
 
void SetTags (const gd::String &tags_)
 Change the tags of the object.
 
const gd::StringGetTags () const
 Return the tags of the object.
 
Resources management

Members functions related to managing resources used by the object

virtual void ExposeResources (gd::ArbitraryResourceWorker &worker)
 Called ( e.g. during compilation ) so as to inventory internal resources and sometimes update their filename. Implementation example: More...
 
virtual bool SupportShaders ()
 
Object properties

Reading and updating object properties

virtual std::map< gd::String,
gd::PropertyDescriptor
GetProperties (gd::Project &project) const
 Called when the IDE wants to know about the custom properties of the object. More...
 
virtual bool UpdateProperty (const gd::String &name, const gd::String &value, gd::Project &project)
 Called when the IDE wants to update a custom property of the object. More...
 
Drawing and editing initial instances

Members functions related to drawing and editing initial instances of this object

virtual std::map< gd::String,
gd::PropertyDescriptor
GetInitialInstanceProperties (const gd::InitialInstance &instance, gd::Project &project, gd::Layout &layout)
 Called when the IDE wants to know about the custom properties of an initial instance of this object. More...
 
virtual bool UpdateInitialInstanceProperty (gd::InitialInstance &instance, const gd::String &name, const gd::String &value, gd::Project &project, gd::Layout &layout)
 Called when the IDE wants to update a custom property of an initial instance of this object. More...
 
Behaviors management

Members functions related to behaviors management.

std::vector< gd::StringGetAllBehaviorNames () const
 Return a vector containing the names of all the behaviors used by the object.
 
BehaviorContentGetBehavior (const gd::String &name)
 Return a reference to the behavior called name.
 
const BehaviorContentGetBehavior (const gd::String &name) const
 Return a reference to the behavior called name.
 
bool HasBehaviorNamed (const gd::String &name) const
 Return true if object has a behavior called name.
 
void RemoveBehavior (const gd::String &name)
 Remove behavior called name.
 
bool RenameBehavior (const gd::String &name, const gd::String &newName)
 Change the name of behavior called name to newName. More...
 
gd::BehaviorContentAddBehavior (const gd::BehaviorContent &behavior)
 Add the specified behavior content to the object. More...
 
gd::BehaviorContentAddNewBehavior (gd::Project &project, const gd::String &type, const gd::String &name)
 Add the behavior of the specified type with the specified name. More...
 
const std::map< gd::String,
std::unique_ptr
< gd::BehaviorContent > > & 
GetAllBehaviorContents () const
 Get a read-only access to the map containing the behaviors with their properties.
 
Variable management

Members functions related to object variables management.

const gd::VariablesContainerGetVariables () const
 Provide access to the gd::VariablesContainer member containing the object variables.
 
gd::VariablesContainerGetVariables ()
 Provide access to the gd::VariablesContainer member containing the object variables.
 
Serialization

Members functions related to serialization of the object

void SerializeTo (SerializerElement &element) const
 Serialize the object. More...
 
void UnserializeFrom (gd::Project &project, const SerializerElement &element)
 Unserialize the object. More...
 

Protected Member Functions

virtual void DoUnserializeFrom (gd::Project &project, const SerializerElement &element)
 Derived objects can redefine this method to load custom attributes.
 
virtual void DoSerializeTo (SerializerElement &element) const
 Derived objects can redefine this method to save custom attributes.
 
void Init (const gd::Object &object)
 

Protected Attributes

gd::String name
 The full name of the object.
 
gd::String type
 
std::map< gd::String,
std::unique_ptr
< gd::BehaviorContent > > 
behaviors
 
gd::VariablesContainer objectVariables
 List of the variables of the object.
 
gd::String tags
 Comma-separated list of tags.
 

Detailed Description

Base class used to represent an object of a platform.

Constructor & Destructor Documentation

gd::Object::Object ( const gd::String name)

Create a new object with the name passed as argument.

Parameters
nameObject's name
gd::Object::Object ( const gd::Object object)
inline

Copy constructor. Calls Init().

gd::Object::~Object ( )
virtual

Destructor.

Member Function Documentation

gd::BehaviorContent & gd::Object::AddBehavior ( const gd::BehaviorContent behavior)

Add the specified behavior content to the object.

Returns
A reference to the newly added behavior content.
gd::BehaviorContent * gd::Object::AddNewBehavior ( gd::Project project,
const gd::String type,
const gd::String name 
)

Add the behavior of the specified type with the specified name.

The project's current platform is used to initialize the content.

Returns
A pointer to the newly added behavior content. NULL if the creation failed.
virtual std::unique_ptr<gd::Object> gd::Object::Clone ( ) const
inlinevirtual

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 gd::make_unique<MyObject>(*this);

Reimplemented in gd::SpriteObject.

virtual void gd::Object::ExposeResources ( gd::ArbitraryResourceWorker worker)
inlinevirtual

Called ( e.g. during compilation ) so as to inventory internal resources and sometimes update their filename. Implementation example:

worker.ExposeImage(myImage);
worker.ExposeFile(myResourceFile);
See also
ArbitraryResourceWorker

Reimplemented in gd::SpriteObject.

std::map< gd::String, gd::PropertyDescriptor > gd::Object::GetInitialInstanceProperties ( const gd::InitialInstance instance,
gd::Project project,
gd::Layout layout 
)
virtual

Called when the IDE wants to know about the custom properties of an initial instance of this object.

Returns
a std::map with properties names as key and values.
See also
gd::InitialInstance

Reimplemented in gd::SpriteObject.

std::map< gd::String, gd::PropertyDescriptor > gd::Object::GetProperties ( gd::Project project) const
virtual

Called when the IDE wants to know about the custom properties of the object.

Usage example:

std::map<gd::String, gd::PropertyDescriptor> properties;
properties[ToString(_("Text"))].SetValue("Hello world!");
return properties;
Returns
a std::map with properties names as key.
See also
gd::PropertyDescriptor

Reimplemented in gd::SpriteObject.

void gd::Object::Init ( const gd::Object object)
protected

Initialize object using another object. Used by copy-ctor and assign-op. Don't forget to update me if members were changed!

Object& gd::Object::operator= ( const gd::Object object)
inline

Assignment operator. Calls Init().

bool gd::Object::RenameBehavior ( const gd::String name,
const gd::String newName 
)

Change the name of behavior called name to newName.

Returns
true if name was successfully changed
void gd::Object::SerializeTo ( SerializerElement element) const

Serialize the object.

See also
DoSerializeTo
virtual bool gd::Object::SupportShaders ( )
inlinevirtual

Redefine this function to return true if your object can use shaders.

void gd::Object::UnserializeFrom ( gd::Project project,
const SerializerElement element 
)

Unserialize the object.

See also
DoUnserializeFrom
virtual bool gd::Object::UpdateInitialInstanceProperty ( gd::InitialInstance instance,
const gd::String name,
const gd::String value,
gd::Project project,
gd::Layout layout 
)
inlinevirtual

Called when the IDE wants to update a custom property of an initial instance of this object.

Returns
false if the new value cannot be set
See also
gd::InitialInstance

Reimplemented in gd::SpriteObject.

virtual bool gd::Object::UpdateProperty ( const gd::String name,
const gd::String value,
gd::Project project 
)
inlinevirtual

Called when the IDE wants to update a custom property of the object.

Returns
false if the new value cannot be set

Reimplemented in gd::SpriteObject.

Member Data Documentation

std::map<gd::String, std::unique_ptr<gd::BehaviorContent> > gd::Object::behaviors
protected

Contains all behaviors and their properties for the object. Behavior contents are the ownership of the object.

gd::String gd::Object::type
protected

Which type is the object. ( To test if we can do something reserved to some objects with it )


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