4 #include "GDCore/Extensions/Metadata/ParameterMetadataTools.h"
5 #include "ObjectsContainersList.h"
6 #include "PropertiesContainersList.h"
7 #include "VariablesContainersList.h"
8 #include "ResourcesContainersList.h"
9 #include "VariablesContainer.h"
13 class ObjectsContainer;
14 class NamedPropertyDescriptor;
15 class ParameterMetadataContainer;
17 class EventsFunctionsExtension;
19 class EventsBasedBehavior;
20 class EventsBasedObject;
44 : objectsContainersList(objectsContainersList_),
45 variablesContainersList(variablesContainersList_),
46 legacyGlobalVariables(legacyGlobalVariables_),
47 legacySceneVariables(legacySceneVariables_),
48 propertiesContainersList(propertiesContainersList_),
49 resourcesContainersList(resourcesContainersList_){};
53 MakeNewProjectScopedContainersForProjectAndLayout(
const gd::Project &project,
57 MakeNewProjectScopedContainersForProject(
const gd::Project &project);
60 MakeNewProjectScopedContainersForEventsFunctionsExtension(
65 MakeNewProjectScopedContainersForFreeEventsFunction(
74 MakeNewProjectScopedContainersForBehaviorEventsFunction(
86 MakeNewProjectScopedContainersForObjectEventsFunction(
98 MakeNewProjectScopedContainersForEventsBasedObject(
105 MakeNewProjectScopedContainersWithLocalVariables(
111 propertiesContainersList.
Add(container);
118 parametersVectorsList.push_back(¶meters);
123 template <
class ReturnType>
124 ReturnType MatchIdentifierWithName(
126 std::function<ReturnType()> objectCallback,
127 std::function<ReturnType()> variableCallback,
128 std::function<ReturnType()> propertyCallback,
129 std::function<ReturnType()> parameterCallback,
130 std::function<ReturnType()> notFoundCallback)
const {
132 return objectCallback();
133 else if (variablesContainersList.
Has(name)) {
134 const auto &variablesContainer =
136 const auto sourceType = variablesContainer.GetSourceType();
137 if (sourceType == gd::VariablesContainer::SourceType::Properties) {
138 return propertyCallback();
139 }
else if (sourceType == gd::VariablesContainer::SourceType::Parameters) {
140 return parameterCallback();
142 return variableCallback();
143 }
else if (ParameterMetadataTools::Has(parametersVectorsList, name))
144 return parameterCallback();
145 else if (propertiesContainersList.
Has(name))
146 return propertyCallback();
148 return notFoundCallback();
151 void ForEachIdentifierMatchingSearch(
161 parameterCallback)
const {
162 std::set<gd::String> namesAlreadySeen;
168 if (namesAlreadySeen.count(name) == 0) {
169 namesAlreadySeen.insert(name);
170 objectCallback(name, objectConfiguration);
175 if (namesAlreadySeen.count(name) == 0) {
176 namesAlreadySeen.insert(name);
177 variableCallback(name, variable);
180 gd::ParameterMetadataTools::ForEachParameterMatchingSearch(
181 parametersVectorsList,
184 if (namesAlreadySeen.count(parameter.
GetName()) == 0) {
185 namesAlreadySeen.insert(parameter.GetName());
186 parameterCallback(parameter);
191 if (namesAlreadySeen.count(property.
GetName()) == 0) {
192 namesAlreadySeen.insert(property.GetName());
193 propertyCallback(property);
199 return objectsContainersList;
203 return variablesContainersList;
211 return variablesContainersList;
220 return legacyGlobalVariables;
229 return legacySceneVariables;
233 return propertiesContainersList;
236 const std::vector<const ParameterMetadataContainer *> &GetParametersVectorsList()
const {
237 return parametersVectorsList;
241 return resourcesContainersList;
247 : legacyGlobalVariables(nullptr), legacySceneVariables(nullptr){};
255 std::vector<const ParameterMetadataContainer *> parametersVectorsList;
Base class defining an event.
Definition: Event.h:43
Represents a behavior that is implemented with events.
Definition: EventsBasedBehavior.h:31
Represents an object that is implemented with events.
Definition: EventsBasedObject.h:32
Events that can be generated as a stand-alone function, and used as a condition, action or expression...
Definition: EventsFunction.h:38
Hold a list of Events Functions (gd::EventsFunction) and Events Based Behaviors.
Definition: EventsFunctionsExtension.h:41
Represent a layout ( also called a scene ) of a project.
Definition: Layout.h:40
Used to describe a property shown in a property grid.
Definition: NamedPropertyDescriptor.h:21
const gd::String & GetName() const
Get the name of the property.
Definition: NamedPropertyDescriptor.h:47
Base class used to represent an object configuration. For example, this can be the animations in a sp...
Definition: ObjectConfiguration.h:38
Used as a base class for classes that will own objects (see gd::Object).
Definition: ObjectsContainer.h:37
A list of objects containers, useful for accessing objects in a scoped way, along with methods to acc...
Definition: ObjectsContainersList.h:29
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.
Definition: ObjectsContainersList.cpp:332
bool HasObjectOrGroupNamed(const gd::String &name) const
Check if the specified object or group exists.
Definition: ObjectsContainersList.cpp:56
Base class representing a project (game), including all resources, scenes, objects,...
Definition: Project.h:50
Holds references to variables, objects, properties and other containers.
Definition: ProjectScopedContainers.h:35
gd::VariablesContainersList & GetVariablesContainersList()
Allow modification of the variables containers list. This is used by code generation which does push ...
Definition: ProjectScopedContainers.h:210
const gd::VariablesContainer * GetLegacyGlobalVariables() const
Return the global variables of the current scene or the current extension. It allows legacy "globalva...
Definition: ProjectScopedContainers.h:219
ProjectScopedContainers()
Definition: ProjectScopedContainers.h:246
const gd::VariablesContainer * GetLegacySceneVariables() const
Return the scene variables of the current scene or the current extension. It allows legacy "scenevar"...
Definition: ProjectScopedContainers.h:228
A container of properties, used for custom behaviors, custom objects, extensions.....
Definition: PropertiesContainer.h:17
A list of property containers, useful for accessing properties in a scoped way.
Definition: PropertiesContainersList.h:26
bool Has(const gd::String &name) const
Return true if the specified property is in one of the containers.
Definition: PropertiesContainersList.cpp:27
void Add(const gd::PropertiesContainer &propertiesContainer)
Add a new container of properties in the list. Add containers in order from the most global one to th...
Definition: PropertiesContainersList.h:38
void ForEachPropertyMatchingSearch(const gd::String &search, std::function< void(const gd::NamedPropertyDescriptor &property)> fn) const
Call the callback for each property having a name matching the specified search.
Definition: PropertiesContainersList.cpp:58
Inventory all resources used by a project.
Definition: ResourcesContainer.h:628
A list of resources containers, useful for accessing resources in a scoped way, along with methods to...
Definition: ResourcesContainersList.h:36
String represents an UTF8 encoded string.
Definition: String.h:33
Defines a variable which can be used by an object, a layout or a project.
Definition: Variable.h:29
Class defining a container for gd::Variable.
Definition: VariablesContainer.h:28
A list of variables containers, useful for accessing variables in a scoped way.
Definition: VariablesContainersList.h:29
const VariablesContainer & GetVariablesContainerFromVariableOrPropertyOrParameterName(const gd::String &variableName) const
Definition: VariablesContainersList.cpp:150
bool Has(const gd::String &name) const
Return true if the specified variable is in one of the containers.
Definition: VariablesContainersList.cpp:131
void ForEachVariableMatchingSearch(const gd::String &search, std::function< void(const gd::String &name, const gd::Variable &variable)> fn) const
Call the callback for each variable having a name matching the specified search.
Definition: VariablesContainersList.cpp:217
Definition: CommonTools.h:24