4 #include "GDCore/Extensions/Metadata/ParameterMetadataTools.h"
5 #include "GDCore/String.h"
6 #include "ObjectsContainersList.h"
7 #include "PropertiesContainersList.h"
8 #include "VariablesContainersList.h"
9 #include "ResourcesContainersList.h"
10 #include "VariablesContainer.h"
14 class ObjectsContainer;
15 class NamedPropertyDescriptor;
16 class ParameterMetadataContainer;
18 class EventsFunctionsExtension;
20 class EventsBasedBehavior;
21 class EventsBasedObject;
45 : objectsContainersList(objectsContainersList_),
46 variablesContainersList(variablesContainersList_),
47 legacyGlobalVariables(legacyGlobalVariables_),
48 legacySceneVariables(legacySceneVariables_),
49 propertiesContainersList(propertiesContainersList_),
50 resourcesContainersList(resourcesContainersList_){};
54 MakeNewProjectScopedContainersForProjectAndLayout(
const gd::Project &project,
58 MakeNewProjectScopedContainersForProject(
const gd::Project &project);
61 MakeNewProjectScopedContainersForEventsFunctionsExtension(
66 MakeNewProjectScopedContainersForFreeEventsFunction(
75 MakeNewProjectScopedContainersForBehaviorEventsFunction(
87 MakeNewProjectScopedContainersForObjectEventsFunction(
99 MakeNewProjectScopedContainersForEventsBasedObject(
106 MakeNewProjectScopedContainersWithLocalVariables(
112 propertiesContainersList.
Add(container);
119 parametersVectorsList.push_back(¶meters);
124 template <
class ReturnType>
125 ReturnType MatchIdentifierWithName(
127 std::function<ReturnType()> objectCallback,
128 std::function<ReturnType()> variableCallback,
129 std::function<ReturnType()> propertyCallback,
130 std::function<ReturnType()> parameterCallback,
131 std::function<ReturnType()> notFoundCallback)
const {
133 return objectCallback();
134 else if (variablesContainersList.
Has(name)) {
135 const auto &variablesContainer =
137 const auto sourceType = variablesContainer.GetSourceType();
138 if (sourceType == gd::VariablesContainer::SourceType::Properties) {
139 return propertyCallback();
140 }
else if (sourceType == gd::VariablesContainer::SourceType::Parameters) {
141 return parameterCallback();
143 return variableCallback();
144 }
else if (ParameterMetadataTools::Has(parametersVectorsList, name))
145 return parameterCallback();
146 else if (propertiesContainersList.
Has(name))
147 return propertyCallback();
149 return notFoundCallback();
152 void ForEachIdentifierMatchingSearch(
162 parameterCallback)
const {
163 std::set<gd::String> namesAlreadySeen;
169 if (namesAlreadySeen.count(name) == 0) {
170 namesAlreadySeen.insert(name);
171 objectCallback(name, objectConfiguration);
176 if (namesAlreadySeen.count(name) == 0) {
177 namesAlreadySeen.insert(name);
178 variableCallback(name, variable);
181 gd::ParameterMetadataTools::ForEachParameterMatchingSearch(
182 parametersVectorsList,
185 if (namesAlreadySeen.count(parameter.
GetName()) == 0) {
186 namesAlreadySeen.insert(parameter.GetName());
187 parameterCallback(parameter);
192 if (namesAlreadySeen.count(property.
GetName()) == 0) {
193 namesAlreadySeen.insert(property.GetName());
194 propertyCallback(property);
200 return objectsContainersList;
204 return variablesContainersList;
212 return variablesContainersList;
221 return legacyGlobalVariables;
230 return legacySceneVariables;
234 return propertiesContainersList;
237 const std::vector<const ParameterMetadataContainer *> &GetParametersVectorsList()
const {
238 return parametersVectorsList;
242 return resourcesContainersList;
250 return scopeSceneName;
258 return scopeExternalEventsName;
267 scopeExternalEventsName = externalEventsName;
276 return scopeExtensionName;
284 return scopeFunctionName;
292 return scopeBehaviorName;
300 return scopeObjectName;
306 : legacyGlobalVariables(nullptr), legacySceneVariables(nullptr){};
314 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:41
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:38
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:51
Holds references to variables, objects, properties and other containers.
Definition: ProjectScopedContainers.h:36
const gd::String & GetScopeExtensionName() const
Return the name of the extension in scope, or an empty string if the scope is not an extension functi...
Definition: ProjectScopedContainers.h:275
ProjectScopedContainers & SetScopeExternalEventsName(const gd::String &externalEventsName)
Set the external events name for the scope. Used by ProjectBrowserHelper when scanning external event...
Definition: ProjectScopedContainers.h:265
gd::VariablesContainersList & GetVariablesContainersList()
Allow modification of the variables containers list. This is used by code generation which does push ...
Definition: ProjectScopedContainers.h:211
const gd::VariablesContainer * GetLegacyGlobalVariables() const
Return the global variables of the current scene or the current extension. It allows legacy "globalva...
Definition: ProjectScopedContainers.h:220
const gd::String & GetScopeBehaviorName() const
Return the name of the custom behavior in scope, or an empty string if the scope is not a behavior fu...
Definition: ProjectScopedContainers.h:291
const gd::String & GetScopeObjectName() const
Return the name of the custom object in scope, or an empty string if the scope is not an object funct...
Definition: ProjectScopedContainers.h:299
ProjectScopedContainers()
Definition: ProjectScopedContainers.h:305
const gd::String & GetScopeSceneName() const
Return the name of the scene (layout) in scope, or an empty string if the scope is not a scene.
Definition: ProjectScopedContainers.h:249
const gd::String & GetScopeExternalEventsName() const
Return the name of the external events in scope, or an empty string if the scope is not external even...
Definition: ProjectScopedContainers.h:257
const gd::VariablesContainer * GetLegacySceneVariables() const
Return the scene variables of the current scene or the current extension. It allows legacy "scenevar"...
Definition: ProjectScopedContainers.h:229
const gd::String & GetScopeFunctionName() const
Return the name of the function in scope, or an empty string if the scope is not an extension functio...
Definition: ProjectScopedContainers.h:283
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:29
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:148
bool Has(const gd::String &name) const
Return true if the specified variable is in one of the containers.
Definition: VariablesContainersList.cpp:129
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:215
Definition: CommonTools.h:24