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

A list of objects containers, useful for accessing objects in a scoped way, along with methods to access them. More...

#include <ObjectsContainersList.h>

Public Types

enum  VariableExistence { DoesNotExist , Exists , GroupIsEmpty , ExistsOnlyOnSomeObjectsOfTheGroup }
 

Public Member Functions

bool HasObjectOrGroupNamed (const gd::String &name) const
 Check if the specified object or group exists.
 
bool HasObjectNamed (const gd::String &name) const
 Check if the specified object exists ignoring groups.
 
VariableExistence HasObjectOrGroupWithVariableNamed (const gd::String &objectOrGroupName, const gd::String &variableName) const
 Check if the specified object or group has the specified variable in its declared variables.
 
bool HasObjectOrGroupVariablesContainer (const gd::String &objectOrGroupName, const gd::VariablesContainer &variablesContainer) const
 Check if the specified object or group has the specified variables container.
 
const gd::VariablesContainerGetObjectOrGroupVariablesContainer (const gd::String &objectOrGroupName) const
 Return the container of the variables for the specified object or group of objects.
 
gd::Variable::Type GetTypeOfObjectOrGroupVariable (const gd::String &objectOrGroupName, const gd::String &variableName) const
 Get a type from an object/group variable.
 
gd::String GetTypeOfObject (const gd::String &objectName) const
 Get a type from an object/group name. More...
 
bool HasBehaviorInObjectOrGroup (const gd::String &objectOrGroupName, const gd::String &behaviorName) const
 Check if an object or all object of a group has a behavior.
 
gd::String GetTypeOfBehaviorInObjectOrGroup (const gd::String &objectOrGroupName, const gd::String &behaviorName, bool searchInGroups=true) const
 Get the type of a behavior if an object or all objects of a group has it.
 
gd::String GetTypeOfBehavior (const gd::String &behaviorName, bool searchInGroups=true) const
 Get a type from a behavior name. More...
 
std::vector< gd::StringGetBehaviorsOfObject (const gd::String &objectName, bool searchInGroups=true) const
 Get behaviors of an object/group. More...
 
std::vector< gd::StringGetBehaviorNamesInObjectOrGroup (const gd::String &objectOrGroupName, const gd::String &behaviorType, bool searchInGroups=true) const
 Get behaviors of an object/group of a given behavior type. More...
 
std::vector< gd::StringGetAnimationNamesOfObject (const gd::String &objectOrGroupName) const
 Get the animation names of an object/group. More...
 
std::vector< gd::StringExpandObjectName (const gd::String &objectOrGroupName, const gd::String &onlyObjectToSelectIfPresent="") const
 Return a list containing all objects referred to by the group. If an object name is passed, then only this object name is returned. More...
 
void ForEachObject (std::function< void(const gd::Object &object)> fn) const
 
void ForEachNameMatchingSearch (const gd::String &search, std::function< void(const gd::String &name, const gd::ObjectConfiguration *objectConfiguration)> fn) const
 Call the callback for each object or group name matching the search passed in parameter.
 
void ForEachObjectOrGroupVariableMatchingSearch (const gd::String &objectOrGroupName, const gd::String &search, std::function< void(const gd::String &variableName, const gd::Variable &variable)> fn) const
 Call the callback for each variable of the object (or group) matching the search passed in parameter.
 
const gd::ObjectsContainer::SourceType GetObjectsContainerSourceType (const gd::String &objectOrGroupName) const
 Return the source type of the container for the specified object or group of objects.
 
const ObjectsContainerGetObjectsContainerFromObjectName (const gd::String &objectOrGroupName) const
 
const gd::ObjectsContainerGetObjectsContainer (std::size_t index) const
 Return a the objects container at position index. More...
 
std::size_t GetObjectsContainersCount () const
 Return the number of objects containers.
 
 ObjectsContainersList ()
 

Static Public Member Functions

static ObjectsContainersList MakeNewEmptyObjectsContainersList ()
 
static ObjectsContainersList MakeNewObjectsContainersListForProjectAndLayout (const gd::Project &project, const gd::Layout &layout)
 
static ObjectsContainersList MakeNewObjectsContainersListForProject (const gd::Project &project)
 
static ObjectsContainersList MakeNewObjectsContainersListForContainers (const gd::ObjectsContainer &globalObjectsContainer, const gd::ObjectsContainer &objectsContainer)
 
static ObjectsContainersList MakeNewObjectsContainersListForContainer (const gd::ObjectsContainer &objectsContainer)
 

Detailed Description

A list of objects containers, useful for accessing objects in a scoped way, along with methods to access them.

See also
gd::Object
gd::ObjectsContainer
gd::Project
gd::Layout

Constructor & Destructor Documentation

◆ ObjectsContainersList()

gd::ObjectsContainersList::ObjectsContainersList ( )
inline

Do not use - should be private but accessible to let Emscripten create a temporary.

Member Function Documentation

◆ ExpandObjectName()

std::vector< gd::String > gd::ObjectsContainersList::ExpandObjectName ( const gd::String objectOrGroupName,
const gd::String onlyObjectToSelectIfPresent = "" 
) const

Return a list containing all objects referred to by the group. If an object name is passed, then only this object name is returned.

If onlyObjectToSelectIfPresent is set and present in the group(s), only this object will be returned. This is useful for considering this object as the "currently selected" object, when generating a condition or an action.

◆ GetAnimationNamesOfObject()

std::vector< gd::String > gd::ObjectsContainersList::GetAnimationNamesOfObject ( const gd::String objectOrGroupName) const

Get the animation names of an object/group.

Note
The animation names of a group are the animation names common to every object of the group.
Returns
The names of animations

◆ GetBehaviorNamesInObjectOrGroup()

std::vector< gd::String > gd::ObjectsContainersList::GetBehaviorNamesInObjectOrGroup ( const gd::String objectOrGroupName,
const gd::String behaviorType,
bool  searchInGroups = true 
) const

Get behaviors of an object/group of a given behavior type.

Note
The behaviors of a group are the behaviors which are found in common when looking all the objects of the group.
Returns
Vector containing names of behaviors

◆ GetBehaviorsOfObject()

std::vector< gd::String > gd::ObjectsContainersList::GetBehaviorsOfObject ( const gd::String objectName,
bool  searchInGroups = true 
) const

Get behaviors of an object/group.

Note
The behaviors of a group are the behaviors which are found in common when looking all the objects of the group.
Returns
Vector containing names of behaviors

◆ GetObjectsContainer()

const gd::ObjectsContainer & gd::ObjectsContainersList::GetObjectsContainer ( std::size_t  index) const

Return a the objects container at position index.

Warning
The returned ObjectsContainer may contain cloned objects (in the case of ProjectScopedContainers::MakeNewProjectScopedContainersForEventsBasedObject) or "fake" objects used by events like parameters. They must not be used to edit the objects. Search for "ProjectScopedContainers wrongly containing temporary objects containers or objects" in the codebase.

◆ GetObjectsContainerFromObjectName()

const ObjectsContainer * gd::ObjectsContainersList::GetObjectsContainerFromObjectName ( const gd::String objectOrGroupName) const

Get the objects container for for the specified object or group of objects.

◆ GetTypeOfBehavior()

gd::String gd::ObjectsContainersList::GetTypeOfBehavior ( const gd::String behaviorName,
bool  searchInGroups = true 
) const

Get a type from a behavior name.

Returns
Type of the behavior.
Deprecated:
  • Use GetTypeOfBehaviorInObjectOrGroup instead.

◆ GetTypeOfObject()

gd::String gd::ObjectsContainersList::GetTypeOfObject ( const gd::String objectName) const

Get a type from an object/group name.

Note
If a group contains only objects of a same type, then the group has this type. Otherwise, it is considered as an object without any specific type.
Returns
Type of the object/group.

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