GDevelop Core
Core library for developing platforms and tools compatible with GDevelop.
|
Used as a base class for classes that will own objects (see gd::Object). More...
#include <ObjectsContainer.h>
Public Types | |
enum | SourceType { Unknown , Global , Scene , Object , Function } |
Public Member Functions | |
ObjectsContainer (const SourceType sourceType) | |
Constructor creating a container without any objects. | |
ObjectsContainer (const ObjectsContainer &) | |
ObjectsContainer & | operator= (const ObjectsContainer &rhs) |
SourceType | GetSourceType () const |
std::vector< const ObjectFolderOrObject * > | GetAllObjectFolderOrObjects () const |
gd::ObjectFolderOrObject & | GetRootFolder () |
void | AddMissingObjectsInRootFolder () |
Objects management | |
Members functions related to objects management. | |
bool | HasObjectNamed (const gd::String &name) const |
Return true if object called name exists. | |
gd::Object & | GetObject (const gd::String &name) |
Return a reference to the object called name. | |
const gd::Object & | GetObject (const gd::String &name) const |
Return a reference to the object called name. | |
gd::Object & | GetObject (std::size_t index) |
Return a reference to the object at position index in the objects list. | |
const gd::Object & | GetObject (std::size_t index) const |
Return a reference to the object at position index in the objects list. | |
std::size_t | GetObjectPosition (const gd::String &name) const |
Return the position of the object called name in the objects list. More... | |
std::size_t | GetObjectsCount () const |
Return the number of object. | |
gd::Object & | InsertNewObject (const gd::Project &project, const gd::String &objectType, const gd::String &name, std::size_t position) |
Add a new empty object of type objectType called name at the specified position in the list. More... | |
gd::Object & | InsertNewObjectInFolder (const gd::Project &project, const gd::String &objectType, const gd::String &name, gd::ObjectFolderOrObject &objectFolderOrObject, std::size_t position) |
Add a new empty object of type objectType called name in the given folder at the specified position. More... | |
gd::Object & | InsertObject (const gd::Object &object, std::size_t position) |
Add a new object to the list. More... | |
void | RemoveObject (const gd::String &name) |
Delete an object. More... | |
void | MoveObject (std::size_t oldIndex, std::size_t newIndex) |
void | MoveObjectFolderOrObjectToAnotherContainerInFolder (gd::ObjectFolderOrObject &objectFolderOrObject, gd::ObjectsContainer &newContainer, gd::ObjectFolderOrObject &newParentFolder, std::size_t newPosition) |
std::vector< std::unique_ptr< gd::Object > > & | GetObjects () |
const std::vector< std::unique_ptr< gd::Object > > & | GetObjects () const |
std::set< gd::String > | GetAllObjectNames () const |
Saving and loading | |
Members functions related to saving and loading the objects of the class. | |
void | SerializeObjectsTo (SerializerElement &element) const |
Serialize the objects container. | |
void | UnserializeObjectsFrom (gd::Project &project, const SerializerElement &element) |
Unserialize the objects container. | |
void | SerializeFoldersTo (SerializerElement &element) const |
Serialize folder structure. | |
void | UnserializeFoldersFrom (gd::Project &project, const SerializerElement &element) |
Unserialize folder structure. | |
Objects groups management | |
Members functions related to global objects groups management. | |
ObjectGroupsContainer & | GetObjectGroups () |
Return a reference to the project's objects groups. | |
const ObjectGroupsContainer & | GetObjectGroups () const |
Return a const reference to the project's objects groups. | |
Protected Attributes | |
std::vector< std::unique_ptr< gd::Object > > | initialObjects |
Objects contained. | |
gd::ObjectGroupsContainer | objectGroups |
Used as a base class for classes that will own objects (see gd::Object).
For example, gd::Project inherits from this class as it have global objects.
gd::Layout also inherits from this class as each layout has specific objects.
std::vector< const ObjectFolderOrObject * > gd::ObjectsContainer::GetAllObjectFolderOrObjects | ( | ) | const |
Returns a vector containing all object and folders in this container. Only use this for checking if you hold a valid ObjectFolderOrObject
- don't use this for rendering or anything else.
std::size_t gd::ObjectsContainer::GetObjectPosition | ( | const gd::String & | name | ) | const |
Return the position of the object called name in the objects list.
|
inline |
Provide a raw access to the vector containing the objects
|
inline |
Provide a raw access to the vector containing the objects
gd::Object & gd::ObjectsContainer::InsertNewObject | ( | const gd::Project & | project, |
const gd::String & | objectType, | ||
const gd::String & | name, | ||
std::size_t | position | ||
) |
Add a new empty object of type objectType called name at the specified position in the list.
gd::Object & gd::ObjectsContainer::InsertNewObjectInFolder | ( | const gd::Project & | project, |
const gd::String & | objectType, | ||
const gd::String & | name, | ||
gd::ObjectFolderOrObject & | objectFolderOrObject, | ||
std::size_t | position | ||
) |
Add a new empty object of type objectType called name in the given folder at the specified position.
gd::Object & gd::ObjectsContainer::InsertObject | ( | const gd::Object & | object, |
std::size_t | position | ||
) |
Add a new object to the list.
object | The object that must be copied and inserted into the project |
position | Insertion position. If the position is invalid, the object is inserted at the end of the objects list. |
void gd::ObjectsContainer::MoveObject | ( | std::size_t | oldIndex, |
std::size_t | newIndex | ||
) |
Change the position of the specified object.
void gd::ObjectsContainer::MoveObjectFolderOrObjectToAnotherContainerInFolder | ( | gd::ObjectFolderOrObject & | objectFolderOrObject, |
gd::ObjectsContainer & | newContainer, | ||
gd::ObjectFolderOrObject & | newParentFolder, | ||
std::size_t | newPosition | ||
) |
Move the specified object to another container, removing it from the current one and adding it to the new one at the specified position in the given folder.
void gd::ObjectsContainer::RemoveObject | ( | const gd::String & | name | ) |
Delete an object.
name | The name of the object to be deleted. |