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

Tool functions to do refactoring on the whole project after changes like deletion or renaming of an object. More...

#include <WholeProjectRefactorer.h>

Public Member Functions

void BehaviorsAddedToGlobalObject (gd::Project &project, const gd::String &objectName)
 Refactor the project after behaviors are added a global object. More...
 

Static Public Member Functions

static VariablesChangeset ComputeChangesetForVariablesContainer (const gd::SerializerElement &oldSerializedVariablesContainer, const gd::VariablesContainer &newVariablesContainer)
 Compute the changes made on the variables of a variable container.
 
static void ApplyRefactoringForVariablesContainer (gd::Project &project, gd::VariablesContainer &variablesContainer, const gd::VariablesChangeset &changeset, const gd::SerializerElement &originalSerializedVariables)
 Refactor the project according to the changes (renaming or deletion) made to variables.
 
static void ApplyRefactoringForGroupVariablesContainer (gd::Project &project, gd::ObjectsContainer &globalObjectsContainer, gd::ObjectsContainer &objectsContainer, const gd::VariablesContainer &groupVariablesContainer, const gd::ObjectGroup &objectGroup, const gd::VariablesChangeset &changeset, const gd::SerializerElement &originalSerializedVariables)
 Refactor the project according to the changes (renaming or deletion) made to variables of a group.
 
static void RenameEventsFunctionsExtension (gd::Project &project, const gd::EventsFunctionsExtension &eventsFunctionsExtension, const gd::String &oldName, const gd::String &newName)
 Refactor the project before an events function extension is renamed. More...
 
static void UpdateExtensionNameInEventsBasedBehavior (gd::Project &project, const gd::EventsFunctionsExtension &eventsFunctionsExtension, gd::EventsBasedBehavior &eventsBasedBehavior, const gd::String &sourceExtensionName)
 Refactor behavior events after the behavior has been placed in a new extension.
 
static void UpdateExtensionNameInEventsBasedObject (gd::Project &project, const gd::EventsFunctionsExtension &eventsFunctionsExtension, gd::EventsBasedObject &eventsBasedObject, const gd::String &sourceExtensionName)
 Refactor object events after the object has been placed in a new extension.
 
static void RenameEventsFunction (gd::Project &project, const gd::EventsFunctionsExtension &eventsFunctionsExtension, const gd::String &oldFunctionName, const gd::String &newFunctionName)
 Refactor the project before an events function is renamed. More...
 
static void RenameBehaviorEventsFunction (gd::Project &project, const gd::EventsFunctionsExtension &eventsFunctionsExtension, const gd::EventsBasedBehavior &eventsBasedBehavior, const gd::String &oldFunctionName, const gd::String &newFunctionName)
 Refactor the project before an events function of a behavior is renamed. More...
 
static void RenameObjectEventsFunction (gd::Project &project, const gd::EventsFunctionsExtension &eventsFunctionsExtension, const gd::EventsBasedObject &eventsBasedObject, const gd::String &oldFunctionName, const gd::String &newFunctionName)
 Refactor the project before an events function of an object is renamed. More...
 
static void RenameParameter (gd::Project &project, gd::ProjectScopedContainers &projectScopedContainers, gd::EventsFunction &eventsFunction, const gd::ObjectsContainer &parameterObjectsContainer, const gd::String &oldParameterName, const gd::String &newParameterName)
 Refactor the function before a parameter is renamed. More...
 
static void MoveEventsFunctionParameter (gd::Project &project, const gd::EventsFunctionsExtension &eventsFunctionsExtension, const gd::String &functionName, std::size_t oldIndex, std::size_t newIndex)
 Refactor the project before an events function parameter is moved. More...
 
static void MoveBehaviorEventsFunctionParameter (gd::Project &project, const gd::EventsFunctionsExtension &eventsFunctionsExtension, const gd::EventsBasedBehavior &eventsBasedBehavior, const gd::String &functionName, std::size_t oldIndex, std::size_t newIndex)
 Refactor the project before the parameter of an events function of a behavior is moved. More...
 
static void MoveObjectEventsFunctionParameter (gd::Project &project, const gd::EventsFunctionsExtension &eventsFunctionsExtension, const gd::EventsBasedObject &eventsBasedObject, const gd::String &functionName, std::size_t oldIndex, std::size_t newIndex)
 Refactor the project before the parameter of an events function of an object is moved. More...
 
static void RenameEventsBasedBehaviorProperty (gd::Project &project, const gd::EventsFunctionsExtension &eventsFunctionsExtension, const gd::EventsBasedBehavior &eventsBasedBehavior, const gd::String &oldPropertyName, const gd::String &newPropertyName)
 Refactor the project before a property of a behavior is renamed. More...
 
static void RenameEventsBasedBehaviorSharedProperty (gd::Project &project, const gd::EventsFunctionsExtension &eventsFunctionsExtension, const gd::EventsBasedBehavior &eventsBasedBehavior, const gd::String &oldPropertyName, const gd::String &newPropertyName)
 Refactor the project before a shared property of a behavior is renamed. More...
 
static void RenameEventsBasedObjectProperty (gd::Project &project, const gd::EventsFunctionsExtension &eventsFunctionsExtension, const gd::EventsBasedObject &eventsBasedObject, const gd::String &oldPropertyName, const gd::String &newPropertyName)
 Refactor the project before a property of an object is renamed. More...
 
static void AddBehaviorAndRequiredBehaviors (gd::Project &project, gd::Object &object, const gd::String &behaviorType, const gd::String &behaviorName)
 Add a behavior to an object and add required behaviors if necessary to fill every behavior properties of the added behaviors.
 
static void AddRequiredBehaviorsFor (gd::Project &project, gd::Object &object, const gd::String &behaviorName)
 Add required behaviors if necessary to fill every behavior properties of the given behaviors.
 
static std::vector< gd::StringFindDependentBehaviorNames (const gd::Project &project, const gd::Object &object, const gd::String &behaviorName)
 Find every behavior of the object that needs the given behaviors directly or indirectly (because of "required behavior" properties).
 
static std::vector< gd::StringGetBehaviorsWithType (const gd::Object &object, const gd::String &type)
 Find the names of the behaviors with the specified type on the object.
 
static std::vector< gd::UnfilledRequiredBehaviorPropertyProblemFindInvalidRequiredBehaviorProperties (const gd::Project &project)
 Find in the project objects having behaviors with "behavior" properties that don't have a valid value (i.e: pointing to a non existing behavior, or of a wrong type).
 
static bool FixInvalidRequiredBehaviorProperties (gd::Project &project)
 Fix in the project objects having behaviors with "behavior" properties that don't have a valid value (i.e: pointing to a non existing behavior, or of a wrong type), by setting a proper behavior, or adding missing behaviors to these objects.
 
static void RenameEventsBasedBehavior (gd::Project &project, const gd::EventsFunctionsExtension &eventsFunctionsExtension, const gd::String &oldBehaviorName, const gd::String &newBehaviorName)
 Refactor the project before a behavior is renamed. More...
 
static void UpdateBehaviorNameInEventsBasedBehavior (gd::Project &project, const gd::EventsFunctionsExtension &eventsFunctionsExtension, gd::EventsBasedBehavior &eventsBasedBehavior, const gd::String &sourceBehaviorName)
 Refactor events-based behavior events after the events-based behavior has been duplicated.
 
static void RenameEventsBasedObject (gd::Project &project, const gd::EventsFunctionsExtension &eventsFunctionsExtension, const gd::String &oldObjectName, const gd::String &newObjectName)
 Refactor the project before an object is renamed. More...
 
static void UpdateObjectNameInEventsBasedObject (gd::Project &project, const gd::EventsFunctionsExtension &eventsFunctionsExtension, gd::EventsBasedObject &eventsBasedObject, const gd::String &sourceObjectName)
 Refactor events-based object events after the events-based object has been duplicated.
 
static void RenameLayout (gd::Project &project, const gd::String &oldName, const gd::String &newName)
 Refactor the project after a layout is renamed.
 
static void RenameExternalLayout (gd::Project &project, const gd::String &oldName, const gd::String &newName)
 Refactor the project after an external layout is renamed.
 
static void RenameExternalEvents (gd::Project &project, const gd::String &oldName, const gd::String &newName)
 Refactor the project after external events are renamed.
 
static void RenameLayerInScene (gd::Project &project, gd::Layout &scene, const gd::String &oldName, const gd::String &newName)
 Refactor the project after a layer is renamed.
 
static void RenameLayerInEventsBasedObject (gd::Project &project, gd::EventsFunctionsExtension &eventsFunctionsExtension, gd::EventsBasedObject &eventsBasedObject, const gd::String &oldName, const gd::String &newName)
 Refactor the project after a layer is renamed.
 
static void RenameLayerEffectInScene (gd::Project &project, gd::Layout &scene, gd::Layer &layer, const gd::String &oldName, const gd::String &newName)
 Refactor the project after a layer effect is renamed.
 
static void RenameLayerEffectInEventsBasedObject (gd::Project &project, gd::EventsFunctionsExtension &eventsFunctionsExtension, gd::EventsBasedObject &eventsBasedObject, gd::Layer &layer, const gd::String &oldName, const gd::String &newName)
 Refactor the project after a layer effect is renamed.
 
static void RenameObjectAnimationInScene (gd::Project &project, gd::Layout &scene, gd::Object &object, const gd::String &oldName, const gd::String &newName)
 Refactor the project after an object animation is renamed.
 
static void RenameObjectAnimationInEventsBasedObject (gd::Project &project, gd::EventsFunctionsExtension &eventsFunctionsExtension, gd::EventsBasedObject &eventsBasedObject, gd::Object &object, const gd::String &oldName, const gd::String &newName)
 Refactor the project after an object animation is renamed.
 
static void RenameObjectPointInScene (gd::Project &project, gd::Layout &scene, gd::Object &object, const gd::String &oldName, const gd::String &newName)
 Refactor the project after an object point is renamed.
 
static void RenameObjectPointInEventsBasedObject (gd::Project &project, gd::EventsFunctionsExtension &eventsFunctionsExtension, gd::EventsBasedObject &eventsBasedObject, gd::Object &object, const gd::String &oldName, const gd::String &newName)
 Refactor the project after an object point is renamed.
 
static void RenameObjectEffectInScene (gd::Project &project, gd::Layout &scene, gd::Object &object, const gd::String &oldName, const gd::String &newName)
 Refactor the project after an object effect is renamed.
 
static void RenameObjectEffectInEventsBasedObject (gd::Project &project, gd::EventsFunctionsExtension &eventsFunctionsExtension, gd::EventsBasedObject &eventsBasedObject, gd::Object &object, const gd::String &oldName, const gd::String &newName)
 Refactor the project after an object effect is renamed.
 
static void ObjectOrGroupRenamedInScene (gd::Project &project, gd::Layout &scene, const gd::String &oldName, const gd::String &newName, bool isObjectGroup)
 Refactor the project after an object is renamed in a layout. More...
 
static void ObjectRemovedInScene (gd::Project &project, gd::Layout &scene, const gd::String &objectName)
 Refactor the project after an object is removed in a layout. More...
 
static void BehaviorsAddedToObjectInScene (gd::Project &project, gd::Layout &layout, const gd::String &objectName)
 Refactor the project after behaviors are added to an object in a layout. More...
 
static void ObjectRemovedInEventsBasedObject (gd::Project &project, gd::EventsBasedObject &eventsBasedObject, const gd::String &objectName)
 Refactor the project after an object is removed in an events-based object. More...
 
static void ObjectOrGroupRenamedInEventsBasedObject (gd::Project &project, const gd::ProjectScopedContainers &projectScopedContainers, gd::EventsBasedObject &eventsBasedObject, const gd::String &oldName, const gd::String &newName, bool isObjectGroup)
 Refactor the events function after an object or group is renamed. More...
 
static void ObjectOrGroupRenamedInEventsFunction (gd::Project &project, const gd::ProjectScopedContainers &projectScopedContainers, gd::EventsFunction &eventsFunction, const gd::ObjectsContainer &targetedObjectsContainer, const gd::String &oldName, const gd::String &newName, bool isObjectGroup)
 Refactor the events function after an object or group is renamed. More...
 
static void ObjectRemovedInEventsFunction (gd::Project &project, gd::EventsFunction &eventsFunction, const gd::String &objectName)
 Refactor the events function after an object or group is removed. More...
 
static void GlobalObjectOrGroupRenamed (gd::Project &project, const gd::String &oldName, const gd::String &newName, bool isObjectGroup)
 Refactor the project after a global object is renamed. More...
 
static void GlobalObjectRemoved (gd::Project &project, const gd::String &objectName)
 Refactor the project after a global object is removed. More...
 
static std::set< gd::StringGetAllObjectTypesUsingEventsBasedBehavior (const gd::Project &project, const gd::EventsFunctionsExtension &eventsFunctionsExtension, const gd::EventsBasedBehavior &eventsBasedBehavior)
 Return the set of all the types of the objects that are using the given behavior.
 
static void EnsureBehaviorEventsFunctionsProperParameters (const gd::EventsFunctionsExtension &eventsFunctionsExtension, const gd::EventsBasedBehavior &eventsBasedBehavior)
 Ensure (adding if necessary) that the functions of the given behavior have the proper mandatory parameters (the "Object" and "Behavior").
 
static void EnsureObjectEventsFunctionsProperParameters (const gd::EventsFunctionsExtension &eventsFunctionsExtension, const gd::EventsBasedObject &eventsBasedObject)
 Ensure (adding if necessary) that the functions of the given object have the proper mandatory parameters (the "Object").
 
static void RemoveLayerInScene (gd::Project &project, gd::Layout &scene, const gd::String &layerName)
 Remove all the instances from one layer.
 
static void MergeLayersInScene (gd::Project &project, gd::Layout &scene, const gd::String &originLayerName, const gd::String &targetLayerName)
 Move all the instances from one layer into another.
 
static void RemoveLayerInEventsBasedObject (gd::EventsBasedObject &eventsBasedObject, const gd::String &layerName)
 Remove all the instances from one layer.
 
static void MergeLayersInEventsBasedObject (gd::EventsBasedObject &eventsBasedObject, const gd::String &originLayerName, const gd::String &targetLayerName)
 Move all the instances from one layer into another.
 
static void RenameLeaderboards (gd::Project &project, const std::map< gd::String, gd::String > &leaderboardIdMap)
 Replace the leaderboard ids in the whole project.
 
static std::set< gd::StringFindAllLeaderboardIds (gd::Project &project)
 Find all the leaderboard identifiers in the whole project.
 
static size_t GetLayoutAndExternalLayoutLayerInstancesCount (gd::Project &project, gd::Layout &layout, const gd::String &layerName)
 Return the number of instances on the layer named layerName and all its associated layouts.
 

Detailed Description

Tool functions to do refactoring on the whole project after changes like deletion or renaming of an object.

\TODO Ideally ObjectOrGroupRenamedInScene, ObjectRemovedInScene, GlobalObjectOrGroupRenamed, GlobalObjectRemoved would be implemented using ExposeProjectEvents.

Member Function Documentation

◆ BehaviorsAddedToGlobalObject()

void gd::WholeProjectRefactorer::BehaviorsAddedToGlobalObject ( gd::Project project,
const gd::String objectName 
)

Refactor the project after behaviors are added a global object.

This will update all the layouts, all external events associated with them. The refactor is actually applied to all objects because it allow to handle groups.

◆ BehaviorsAddedToObjectInScene()

void gd::WholeProjectRefactorer::BehaviorsAddedToObjectInScene ( gd::Project project,
gd::Layout layout,
const gd::String objectName 
)
static

Refactor the project after behaviors are added to an object in a layout.

This will update the layout, all external events associated with it. The refactor is actually applied to all objects because it allow to handle groups.

◆ GlobalObjectOrGroupRenamed()

void gd::WholeProjectRefactorer::GlobalObjectOrGroupRenamed ( gd::Project project,
const gd::String oldName,
const gd::String newName,
bool  isObjectGroup 
)
static

Refactor the project after a global object is renamed.

This will update all the layouts, all external layouts associated with them and all external events used by the layouts.

◆ GlobalObjectRemoved()

void gd::WholeProjectRefactorer::GlobalObjectRemoved ( gd::Project project,
const gd::String objectName 
)
static

Refactor the project after a global object is removed.

This will update all the layouts, all external layouts associated with them and all external events used by the layouts.

◆ MoveBehaviorEventsFunctionParameter()

void gd::WholeProjectRefactorer::MoveBehaviorEventsFunctionParameter ( gd::Project project,
const gd::EventsFunctionsExtension eventsFunctionsExtension,
const gd::EventsBasedBehavior eventsBasedBehavior,
const gd::String functionName,
std::size_t  oldIndex,
std::size_t  newIndex 
)
static

Refactor the project before the parameter of an events function of a behavior is moved.

Warning
Do the move of the specified function parameters after calling this. This is because the function is expected to be in its old state for the refactoring.

◆ MoveEventsFunctionParameter()

void gd::WholeProjectRefactorer::MoveEventsFunctionParameter ( gd::Project project,
const gd::EventsFunctionsExtension eventsFunctionsExtension,
const gd::String functionName,
std::size_t  oldIndex,
std::size_t  newIndex 
)
static

Refactor the project before an events function parameter is moved.

Warning
Do the move of the specified function parameters after calling this. This is because the function is expected to be in its old state for the refactoring.

◆ MoveObjectEventsFunctionParameter()

void gd::WholeProjectRefactorer::MoveObjectEventsFunctionParameter ( gd::Project project,
const gd::EventsFunctionsExtension eventsFunctionsExtension,
const gd::EventsBasedObject eventsBasedObject,
const gd::String functionName,
std::size_t  oldIndex,
std::size_t  newIndex 
)
static

Refactor the project before the parameter of an events function of an object is moved.

Warning
Do the move of the specified function parameters after calling this. This is because the function is expected to be in its old state for the refactoring.

◆ ObjectOrGroupRenamedInEventsBasedObject()

void gd::WholeProjectRefactorer::ObjectOrGroupRenamedInEventsBasedObject ( gd::Project project,
const gd::ProjectScopedContainers projectScopedContainers,
gd::EventsBasedObject eventsBasedObject,
const gd::String oldName,
const gd::String newName,
bool  isObjectGroup 
)
static

Refactor the events function after an object or group is renamed.

This will update the events of the function and groups.

◆ ObjectOrGroupRenamedInEventsFunction()

void gd::WholeProjectRefactorer::ObjectOrGroupRenamedInEventsFunction ( gd::Project project,
const gd::ProjectScopedContainers projectScopedContainers,
gd::EventsFunction eventsFunction,
const gd::ObjectsContainer targetedObjectsContainer,
const gd::String oldName,
const gd::String newName,
bool  isObjectGroup 
)
static

Refactor the events function after an object or group is renamed.

This will update the events of the function and groups.

◆ ObjectOrGroupRenamedInScene()

void gd::WholeProjectRefactorer::ObjectOrGroupRenamedInScene ( gd::Project project,
gd::Layout scene,
const gd::String oldName,
const gd::String newName,
bool  isObjectGroup 
)
static

Refactor the project after an object is renamed in a layout.

This will update the layout, all external layouts associated with it and all external events associated with it.

◆ ObjectRemovedInEventsBasedObject()

void gd::WholeProjectRefactorer::ObjectRemovedInEventsBasedObject ( gd::Project project,
gd::EventsBasedObject eventsBasedObject,
const gd::String objectName 
)
static

Refactor the project after an object is removed in an events-based object.

This will update the events of the function and groups.

◆ ObjectRemovedInEventsFunction()

void gd::WholeProjectRefactorer::ObjectRemovedInEventsFunction ( gd::Project project,
gd::EventsFunction eventsFunction,
const gd::String objectName 
)
static

Refactor the events function after an object or group is removed.

This will update the events of the function and groups.

◆ ObjectRemovedInScene()

void gd::WholeProjectRefactorer::ObjectRemovedInScene ( gd::Project project,
gd::Layout scene,
const gd::String objectName 
)
static

Refactor the project after an object is removed in a layout.

This will update the layout, all external layouts associated with it and all external events associated with it.

◆ RenameBehaviorEventsFunction()

void gd::WholeProjectRefactorer::RenameBehaviorEventsFunction ( gd::Project project,
const gd::EventsFunctionsExtension eventsFunctionsExtension,
const gd::EventsBasedBehavior eventsBasedBehavior,
const gd::String oldFunctionName,
const gd::String newFunctionName 
)
static

Refactor the project before an events function of a behavior is renamed.

Warning
Do the renaming of the specified function after calling this. This is because the function is expected to have its old name for the refactoring.

◆ RenameEventsBasedBehavior()

void gd::WholeProjectRefactorer::RenameEventsBasedBehavior ( gd::Project project,
const gd::EventsFunctionsExtension eventsFunctionsExtension,
const gd::String oldBehaviorName,
const gd::String newBehaviorName 
)
static

Refactor the project before a behavior is renamed.

Warning
Do the renaming of the specified behavior after calling this. This is because the behavior is expected to have its old name for the refactoring.

◆ RenameEventsBasedBehaviorProperty()

void gd::WholeProjectRefactorer::RenameEventsBasedBehaviorProperty ( gd::Project project,
const gd::EventsFunctionsExtension eventsFunctionsExtension,
const gd::EventsBasedBehavior eventsBasedBehavior,
const gd::String oldPropertyName,
const gd::String newPropertyName 
)
static

Refactor the project before a property of a behavior is renamed.

Warning
Do the renaming of the specified property after calling this. This is because the property is expected to have its old name for the refactoring.

◆ RenameEventsBasedBehaviorSharedProperty()

void gd::WholeProjectRefactorer::RenameEventsBasedBehaviorSharedProperty ( gd::Project project,
const gd::EventsFunctionsExtension eventsFunctionsExtension,
const gd::EventsBasedBehavior eventsBasedBehavior,
const gd::String oldPropertyName,
const gd::String newPropertyName 
)
static

Refactor the project before a shared property of a behavior is renamed.

Warning
Do the renaming of the specified shared property after calling this. This is because the shared property is expected to have its old name for the refactoring.

◆ RenameEventsBasedObject()

void gd::WholeProjectRefactorer::RenameEventsBasedObject ( gd::Project project,
const gd::EventsFunctionsExtension eventsFunctionsExtension,
const gd::String oldObjectName,
const gd::String newObjectName 
)
static

Refactor the project before an object is renamed.

Warning
Do the renaming of the specified object after calling this. This is because the object is expected to have its old name for the refactoring.

◆ RenameEventsBasedObjectProperty()

void gd::WholeProjectRefactorer::RenameEventsBasedObjectProperty ( gd::Project project,
const gd::EventsFunctionsExtension eventsFunctionsExtension,
const gd::EventsBasedObject eventsBasedObject,
const gd::String oldPropertyName,
const gd::String newPropertyName 
)
static

Refactor the project before a property of an object is renamed.

Warning
Do the renaming of the specified property after calling this. This is because the property is expected to have its old name for the refactoring.

◆ RenameEventsFunction()

void gd::WholeProjectRefactorer::RenameEventsFunction ( gd::Project project,
const gd::EventsFunctionsExtension eventsFunctionsExtension,
const gd::String oldFunctionName,
const gd::String newFunctionName 
)
static

Refactor the project before an events function is renamed.

Warning
Do the renaming of the specified function after calling this. This is because the function is expected to have its old name for the refactoring.

◆ RenameEventsFunctionsExtension()

void gd::WholeProjectRefactorer::RenameEventsFunctionsExtension ( gd::Project project,
const gd::EventsFunctionsExtension eventsFunctionsExtension,
const gd::String oldName,
const gd::String newName 
)
static

Refactor the project before an events function extension is renamed.

Warning
Do the renaming of the specified extension after calling this. This is because the extension is expected to have its old name for the refactoring.

◆ RenameObjectEventsFunction()

void gd::WholeProjectRefactorer::RenameObjectEventsFunction ( gd::Project project,
const gd::EventsFunctionsExtension eventsFunctionsExtension,
const gd::EventsBasedObject eventsBasedObject,
const gd::String oldFunctionName,
const gd::String newFunctionName 
)
static

Refactor the project before an events function of an object is renamed.

Warning
Do the renaming of the specified function after calling this. This is because the function is expected to have its old name for the refactoring.

◆ RenameParameter()

void gd::WholeProjectRefactorer::RenameParameter ( gd::Project project,
gd::ProjectScopedContainers projectScopedContainers,
gd::EventsFunction eventsFunction,
const gd::ObjectsContainer parameterObjectsContainer,
const gd::String oldParameterName,
const gd::String newParameterName 
)
static

Refactor the function before a parameter is renamed.

Warning
Do the renaming of the specified parameter after calling this. This is because the function is expected to have its old name for the refactoring.

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