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

Base class used to represent an object configuration. For example, this can be the animations in a sprite, the text, its font, its color in a Text object, etc... More...

#include <ObjectConfiguration.h>

Inherited by gd::CustomObjectConfiguration, and gd::SpriteObject.

Public Member Functions

 ObjectConfiguration ()
 
virtual ~ObjectConfiguration ()
 
virtual std::unique_ptr< gd::ObjectConfigurationClone () const
 
void SetType (const gd::String &type_)
 Change the type of the object.
 
const gd::StringGetType () const
 Return the type of the object.
 
Object properties

Reading and updating object configuration properties

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

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

virtual std::map< gd::String, gd::PropertyDescriptorGetInitialInstanceProperties (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 configuration. 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 configuration. More...
 
Resources management

Members functions related to managing resources used by the object configuration

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...
 
Serialization

Members functions related to serialization of the object configuration

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

Protected Member Functions

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

Protected Attributes

gd::String type
 

Detailed Description

Base class used to represent an object configuration. For example, this can be the animations in a sprite, the text, its font, its color in a Text object, etc...

Constructor & Destructor Documentation

◆ ObjectConfiguration()

gd::ObjectConfiguration::ObjectConfiguration ( )

Create a new object configuration.

◆ ~ObjectConfiguration()

gd::ObjectConfiguration::~ObjectConfiguration ( )
virtual

Destructor.

Member Function Documentation

◆ Clone()

virtual std::unique_ptr<gd::ObjectConfiguration> gd::ObjectConfiguration::Clone ( ) const
inlinevirtual

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

return gd::make_unique<MyObjectConfiguration>(*this);

Reimplemented in gd::CustomObjectConfiguration, and gd::SpriteObject.

◆ ExposeResources()

virtual void gd::ObjectConfiguration::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::CustomObjectConfiguration, and gd::SpriteObject.

◆ GetInitialInstanceProperties()

std::map< gd::String, gd::PropertyDescriptor > gd::ObjectConfiguration::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 configuration.

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

Reimplemented in gd::SpriteObject, and gd::CustomObjectConfiguration.

◆ GetProperties()

std::map< gd::String, gd::PropertyDescriptor > gd::ObjectConfiguration::GetProperties ( ) const
virtual

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

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::CustomObjectConfiguration, and gd::SpriteObject.

◆ SerializeTo()

void gd::ObjectConfiguration::SerializeTo ( SerializerElement element) const

Serialize the object configuration.

See also
DoSerializeTo

◆ UnserializeFrom()

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

Unserialize the object configuration.

See also
DoUnserializeFrom

◆ UpdateInitialInstanceProperty()

virtual bool gd::ObjectConfiguration::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 configuration.

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

Reimplemented in gd::SpriteObject, and gd::CustomObjectConfiguration.

◆ UpdateProperty()

virtual bool gd::ObjectConfiguration::UpdateProperty ( const gd::String name,
const gd::String value 
)
inlinevirtual

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

Returns
false if the new value cannot be set

Reimplemented in gd::CustomObjectConfiguration, and gd::SpriteObject.

Member Data Documentation

◆ type

gd::String gd::ObjectConfiguration::type
protected

Which type of object is represented by this configuration.


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