mirror of
https://github.com/4ian/GDevelop.git
synced 2025-10-15 10:19:04 +00:00
Use only 1 object container for functions.
This commit is contained in:
@@ -22,12 +22,7 @@ void EventsFunctionTools::FreeEventsFunctionToObjectsContainer(
|
||||
const gd::Project& project,
|
||||
const gd::EventsFunctionsContainer functionContainer,
|
||||
const gd::EventsFunction& eventsFunction,
|
||||
gd::ObjectsContainer& outputGlobalObjectsContainer,
|
||||
gd::ObjectsContainer& outputObjectsContainer) {
|
||||
// Functions don't have access to objects from the "outer" scope.
|
||||
outputGlobalObjectsContainer.GetObjects().clear();
|
||||
outputGlobalObjectsContainer.GetObjectGroups().Clear();
|
||||
|
||||
// Functions scope for objects is defined according
|
||||
// to parameters
|
||||
outputObjectsContainer.GetObjects().clear();
|
||||
@@ -45,13 +40,11 @@ void EventsFunctionTools::BehaviorEventsFunctionToObjectsContainer(
|
||||
const gd::Project& project,
|
||||
const gd::EventsBasedBehavior& eventsBasedBehavior,
|
||||
const gd::EventsFunction& eventsFunction,
|
||||
gd::ObjectsContainer& outputGlobalObjectsContainer,
|
||||
gd::ObjectsContainer& outputObjectsContainer) {
|
||||
// The context is build the same way as free function...
|
||||
FreeEventsFunctionToObjectsContainer(project,
|
||||
eventsBasedBehavior.GetEventsFunctions(),
|
||||
eventsFunction,
|
||||
outputGlobalObjectsContainer,
|
||||
outputObjectsContainer);
|
||||
|
||||
// ...and has an "Object" by convention...
|
||||
@@ -83,13 +76,11 @@ void EventsFunctionTools::ObjectEventsFunctionToObjectsContainer(
|
||||
const gd::Project& project,
|
||||
const gd::EventsBasedObject& eventsBasedObject,
|
||||
const gd::EventsFunction& eventsFunction,
|
||||
gd::ObjectsContainer& outputGlobalObjectsContainer,
|
||||
gd::ObjectsContainer& outputObjectsContainer) {
|
||||
// The context is build the same way as free function...
|
||||
FreeEventsFunctionToObjectsContainer(project,
|
||||
eventsBasedObject.GetEventsFunctions(),
|
||||
eventsFunction,
|
||||
outputGlobalObjectsContainer,
|
||||
outputObjectsContainer);
|
||||
|
||||
// TODO EBO Use a constant instead a hard coded value "Object".
|
||||
|
@@ -3,11 +3,11 @@
|
||||
* Copyright 2008-present Florian Rival (Florian.Rival@gmail.com). All rights
|
||||
* reserved. This project is released under the MIT License.
|
||||
*/
|
||||
#if defined(GD_IDE_ONLY)
|
||||
#ifndef EventsFunctionTools_H
|
||||
#define EventsFunctionTools_H
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include "GDCore/String.h"
|
||||
|
||||
namespace gd {
|
||||
class Project;
|
||||
class EventsFunctionsContainer;
|
||||
@@ -37,8 +37,8 @@ class GD_CORE_API EventsFunctionTools {
|
||||
const gd::Project& project,
|
||||
const gd::EventsFunctionsContainer functionContainer,
|
||||
const gd::EventsFunction& eventsFunction,
|
||||
gd::ObjectsContainer& outputGlobalObjectsContainer,
|
||||
gd::ObjectsContainer& outputObjectsContainer);
|
||||
|
||||
/**
|
||||
* \brief Given a behavior events function, initialize the given objects container
|
||||
* with objects described in the events function parameters, in
|
||||
@@ -52,8 +52,8 @@ class GD_CORE_API EventsFunctionTools {
|
||||
const gd::Project& project,
|
||||
const gd::EventsBasedBehavior& eventsBasedBehavior,
|
||||
const gd::EventsFunction& eventsFunction,
|
||||
gd::ObjectsContainer& outputGlobalObjectsContainer,
|
||||
gd::ObjectsContainer& outputObjectsContainer);
|
||||
|
||||
/**
|
||||
* \brief Given a parent-object events function, initialize the given objects container
|
||||
* with objects described in the events function parameters, in
|
||||
@@ -67,10 +67,6 @@ class GD_CORE_API EventsFunctionTools {
|
||||
const gd::Project& project,
|
||||
const gd::EventsBasedObject& eventsBasedObject,
|
||||
const gd::EventsFunction& eventsFunction,
|
||||
gd::ObjectsContainer& outputGlobalObjectsContainer,
|
||||
gd::ObjectsContainer& outputObjectsContainer);
|
||||
};
|
||||
} // namespace gd
|
||||
|
||||
#endif // EventsFunctionTools_H
|
||||
#endif
|
||||
|
@@ -170,12 +170,11 @@ void ProjectBrowserHelper::ExposeEventsFunctionsExtensionEvents(
|
||||
gd::ArbitraryEventsWorkerWithContext &worker) {
|
||||
// Add (free) events functions
|
||||
for (auto &&eventsFunction : eventsFunctionsExtension.GetInternalVector()) {
|
||||
gd::ObjectsContainer globalObjectsAndGroups;
|
||||
gd::ObjectsContainer objectsAndGroups;
|
||||
gd::ObjectsContainer parameterObjectsContainer;
|
||||
auto projectScopedContainers = gd::ProjectScopedContainers::
|
||||
MakeNewProjectScopedContainersForFreeEventsFunction(
|
||||
project, eventsFunctionsExtension, *eventsFunction,
|
||||
globalObjectsAndGroups, objectsAndGroups);
|
||||
parameterObjectsContainer);
|
||||
|
||||
worker.Launch(eventsFunction->GetEvents(), projectScopedContainers);
|
||||
}
|
||||
@@ -208,12 +207,12 @@ void ProjectBrowserHelper::ExposeEventsBasedBehaviorEvents(
|
||||
gd::ArbitraryEventsWorkerWithContext &worker) {
|
||||
auto &behaviorEventsFunctions = eventsBasedBehavior.GetEventsFunctions();
|
||||
for (auto &&eventsFunction : behaviorEventsFunctions.GetInternalVector()) {
|
||||
gd::ObjectsContainer globalObjectsAndGroups;
|
||||
gd::ObjectsContainer objectsAndGroups;
|
||||
|
||||
gd::ObjectsContainer parameterObjectsContainers;
|
||||
auto projectScopedContainers = gd::ProjectScopedContainers::
|
||||
MakeNewProjectScopedContainersForBehaviorEventsFunction(
|
||||
project, eventsBasedBehavior, *eventsFunction,
|
||||
globalObjectsAndGroups, objectsAndGroups);
|
||||
project, eventsBasedBehavior,
|
||||
*eventsFunction, parameterObjectsContainers);
|
||||
|
||||
worker.Launch(eventsFunction->GetEvents(), projectScopedContainers);
|
||||
}
|
||||
@@ -233,12 +232,12 @@ void ProjectBrowserHelper::ExposeEventsBasedObjectEvents(
|
||||
gd::ArbitraryEventsWorkerWithContext &worker) {
|
||||
auto &objectEventsFunctions = eventsBasedObject.GetEventsFunctions();
|
||||
for (auto &&eventsFunction : objectEventsFunctions.GetInternalVector()) {
|
||||
gd::ObjectsContainer globalObjectsAndGroups;
|
||||
gd::ObjectsContainer objectsAndGroups;
|
||||
|
||||
gd::ObjectsContainer parameterObjectsContainers;
|
||||
auto projectScopedContainers = gd::ProjectScopedContainers::
|
||||
MakeNewProjectScopedContainersForObjectEventsFunction(
|
||||
project, eventsBasedObject, *eventsFunction, globalObjectsAndGroups,
|
||||
objectsAndGroups);
|
||||
project, eventsBasedObject,
|
||||
*eventsFunction, parameterObjectsContainers);
|
||||
|
||||
worker.Launch(eventsFunction->GetEvents(), projectScopedContainers);
|
||||
}
|
||||
|
@@ -31,6 +31,14 @@ ObjectsContainersList::MakeNewObjectsContainersListForContainers(
|
||||
return objectsContainersList;
|
||||
}
|
||||
|
||||
ObjectsContainersList
|
||||
ObjectsContainersList::MakeNewObjectsContainersListForContainer(
|
||||
const gd::ObjectsContainer& objectsContainer) {
|
||||
ObjectsContainersList objectsContainersList;
|
||||
objectsContainersList.Add(objectsContainer);
|
||||
return objectsContainersList;
|
||||
}
|
||||
|
||||
bool ObjectsContainersList::HasObjectOrGroupNamed(
|
||||
const gd::String& name) const {
|
||||
for (auto it = objectsContainers.rbegin(); it != objectsContainers.rend();
|
||||
@@ -370,7 +378,7 @@ void ObjectsContainersList::ForEachObject(
|
||||
|
||||
gd::String ObjectsContainersList::GetTypeOfObject(
|
||||
const gd::String& objectName) const {
|
||||
if (objectsContainers.size() != 2) {
|
||||
if (objectsContainers.size() > 2) {
|
||||
std::cout << this << std::endl;
|
||||
std::cout << objectsContainers.size() << std::endl;
|
||||
// TODO: rework forwarded methods so they can work with any number of
|
||||
@@ -379,19 +387,40 @@ gd::String ObjectsContainersList::GetTypeOfObject(
|
||||
"ObjectsContainersList::GetTypeOfObject called with objectsContainers "
|
||||
"not being exactly 2. This is a logical error and will crash.");
|
||||
}
|
||||
if (objectsContainers.size() == 0) {
|
||||
gd::LogWarning("ObjectsContainersList::GetTypeOfObject called without any "
|
||||
"objectsContainer");
|
||||
return "";
|
||||
}
|
||||
if (objectsContainers.size() == 1) {
|
||||
gd::ObjectsContainer emptyObjectsContainer;
|
||||
return gd::GetTypeOfObject(emptyObjectsContainer, *objectsContainers[0],
|
||||
objectName, true);
|
||||
}
|
||||
return gd::GetTypeOfObject(
|
||||
*objectsContainers[0], *objectsContainers[1], objectName, true);
|
||||
}
|
||||
|
||||
bool ObjectsContainersList::HasBehaviorInObjectOrGroup(
|
||||
const gd::String& objectOrGroupName, const gd::String& behaviorName) const {
|
||||
if (objectsContainers.size() != 2) {
|
||||
if (objectsContainers.size() > 2) {
|
||||
// TODO: rework forwarded methods so they can work with any number of
|
||||
// containers.
|
||||
gd::LogFatalError(
|
||||
"ObjectsContainersList::GetTypeOfObject called with objectsContainers "
|
||||
"ObjectsContainersList::HasBehaviorInObjectOrGroup called with objectsContainers "
|
||||
"not being exactly 2. This is a logical error and will crash.");
|
||||
}
|
||||
if (objectsContainers.size() == 0) {
|
||||
gd::LogWarning("ObjectsContainersList::HasBehaviorInObjectOrGroup called without any "
|
||||
"objectsContainer");
|
||||
return false;
|
||||
}
|
||||
if (objectsContainers.size() == 1) {
|
||||
gd::ObjectsContainer emptyObjectsContainer;
|
||||
return gd::HasBehaviorInObjectOrGroup(
|
||||
emptyObjectsContainer, *objectsContainers[0], objectOrGroupName,
|
||||
behaviorName, true);
|
||||
}
|
||||
return gd::HasBehaviorInObjectOrGroup(*objectsContainers[0],
|
||||
*objectsContainers[1],
|
||||
objectOrGroupName,
|
||||
@@ -403,13 +432,24 @@ gd::String ObjectsContainersList::GetTypeOfBehaviorInObjectOrGroup(
|
||||
const gd::String& objectOrGroupName,
|
||||
const gd::String& behaviorName,
|
||||
bool searchInGroups) const {
|
||||
if (objectsContainers.size() != 2) {
|
||||
if (objectsContainers.size() > 2) {
|
||||
// TODO: rework forwarded methods so they can work with any number of
|
||||
// containers.
|
||||
gd::LogFatalError(
|
||||
"ObjectsContainersList::GetTypeOfObject called with objectsContainers "
|
||||
"ObjectsContainersList::GetTypeOfBehaviorInObjectOrGroup called with objectsContainers "
|
||||
"not being exactly 2. This is a logical error and will crash.");
|
||||
}
|
||||
if (objectsContainers.size() == 0) {
|
||||
gd::LogWarning("ObjectsContainersList::GetTypeOfBehaviorInObjectOrGroup called without any "
|
||||
"objectsContainer");
|
||||
return "";
|
||||
}
|
||||
if (objectsContainers.size() == 1) {
|
||||
gd::ObjectsContainer emptyObjectsContainer;
|
||||
return gd::GetTypeOfBehaviorInObjectOrGroup(
|
||||
emptyObjectsContainer, *objectsContainers[0], objectOrGroupName,
|
||||
behaviorName, searchInGroups);
|
||||
}
|
||||
return gd::GetTypeOfBehaviorInObjectOrGroup(*objectsContainers[0],
|
||||
*objectsContainers[1],
|
||||
objectOrGroupName,
|
||||
@@ -419,13 +459,23 @@ gd::String ObjectsContainersList::GetTypeOfBehaviorInObjectOrGroup(
|
||||
|
||||
gd::String ObjectsContainersList::GetTypeOfBehavior(
|
||||
const gd::String& behaviorName, bool searchInGroups) const {
|
||||
if (objectsContainers.size() != 2) {
|
||||
if (objectsContainers.size() > 2) {
|
||||
// TODO: rework forwarded methods so they can work with any number of
|
||||
// containers.
|
||||
gd::LogFatalError(
|
||||
"ObjectsContainersList::GetTypeOfObject called with objectsContainers "
|
||||
"ObjectsContainersList::GetTypeOfBehavior called with objectsContainers "
|
||||
"not being exactly 2. This is a logical error and will crash.");
|
||||
}
|
||||
if (objectsContainers.size() == 0) {
|
||||
gd::LogWarning("ObjectsContainersList::GetTypeOfBehavior called without any "
|
||||
"objectsContainer");
|
||||
return "";
|
||||
}
|
||||
if (objectsContainers.size() == 1) {
|
||||
gd::ObjectsContainer emptyObjectsContainer;
|
||||
return gd::GetTypeOfBehavior(emptyObjectsContainer, *objectsContainers[0],
|
||||
behaviorName, searchInGroups);
|
||||
}
|
||||
return gd::GetTypeOfBehavior(*objectsContainers[0],
|
||||
*objectsContainers[1],
|
||||
behaviorName,
|
||||
@@ -434,14 +484,25 @@ gd::String ObjectsContainersList::GetTypeOfBehavior(
|
||||
|
||||
std::vector<gd::String> ObjectsContainersList::GetBehaviorsOfObject(
|
||||
const gd::String& objectName, bool searchInGroups) const {
|
||||
if (objectsContainers.size() != 2) {
|
||||
if (objectsContainers.size() > 2) {
|
||||
// TODO: rework forwarded methods so they can work with any number of
|
||||
// containers.
|
||||
gd::LogFatalError(
|
||||
"ObjectsContainersList::GetTypeOfObject called with objectsContainers "
|
||||
"ObjectsContainersList::GetBehaviorsOfObject called with objectsContainers "
|
||||
"not being exactly 2. This is a logical error and will crash.");
|
||||
}
|
||||
|
||||
if (objectsContainers.size() == 0) {
|
||||
gd::LogWarning("ObjectsContainersList::GetBehaviorsOfObject called without any "
|
||||
"objectsContainer");
|
||||
std::vector<gd::String> behaviors;
|
||||
return behaviors;
|
||||
}
|
||||
if (objectsContainers.size() == 1) {
|
||||
gd::ObjectsContainer emptyObjectsContainer;
|
||||
return gd::GetBehaviorsOfObject(emptyObjectsContainer,
|
||||
*objectsContainers[0], objectName,
|
||||
searchInGroups);
|
||||
}
|
||||
return gd::GetBehaviorsOfObject(
|
||||
*objectsContainers[0], *objectsContainers[1], objectName, searchInGroups);
|
||||
}
|
||||
|
@@ -37,6 +37,9 @@ class GD_CORE_API ObjectsContainersList {
|
||||
const gd::ObjectsContainer& globalObjectsContainer,
|
||||
const gd::ObjectsContainer& objectsContainer);
|
||||
|
||||
static ObjectsContainersList MakeNewObjectsContainersListForContainer(
|
||||
const gd::ObjectsContainer& objectsContainer);
|
||||
|
||||
/**
|
||||
* \brief Check if the specified object or group exists.
|
||||
*/
|
||||
|
@@ -14,35 +14,48 @@ ProjectScopedContainers::MakeNewProjectScopedContainersForFreeEventsFunction(
|
||||
const gd::Project &project,
|
||||
const gd::EventsFunctionsContainer &eventsFunctionsContainer,
|
||||
const gd::EventsFunction &eventsFunction,
|
||||
gd::ObjectsContainer &globalObjectsContainers,
|
||||
gd::ObjectsContainer &objectsContainers) {
|
||||
gd::ObjectsContainer ¶meterObjectsContainer) {
|
||||
|
||||
gd::EventsFunctionTools::FreeEventsFunctionToObjectsContainer(
|
||||
project, eventsFunctionsContainer, eventsFunction,
|
||||
globalObjectsContainers, objectsContainers);
|
||||
auto projectScopedContainers =
|
||||
gd::ProjectScopedContainers::MakeNewProjectScopedContainersFor(globalObjectsContainers, objectsContainers);
|
||||
projectScopedContainers.AddParameters(eventsFunction.GetParametersForEvents(eventsFunctionsContainer));
|
||||
gd::EventsFunctionTools::FreeEventsFunctionToObjectsContainer(
|
||||
project, eventsFunctionsContainer, eventsFunction, parameterObjectsContainer);
|
||||
|
||||
ProjectScopedContainers projectScopedContainers(
|
||||
ObjectsContainersList::MakeNewObjectsContainersListForContainer(
|
||||
parameterObjectsContainer),
|
||||
VariablesContainersList::MakeNewEmptyVariablesContainersList(),
|
||||
PropertiesContainersList::MakeNewEmptyPropertiesContainersList());
|
||||
|
||||
projectScopedContainers.AddParameters(
|
||||
eventsFunction.GetParametersForEvents(eventsFunctionsContainer));
|
||||
|
||||
return projectScopedContainers;
|
||||
}
|
||||
};
|
||||
|
||||
ProjectScopedContainers
|
||||
ProjectScopedContainers::MakeNewProjectScopedContainersForBehaviorEventsFunction(
|
||||
const gd::Project &project,
|
||||
const gd::EventsBasedBehavior& eventsBasedBehavior,
|
||||
const gd::EventsFunction &eventsFunction,
|
||||
gd::ObjectsContainer &globalObjectsContainers,
|
||||
gd::ObjectsContainer &objectsContainers) {
|
||||
gd::ObjectsContainer ¶meterObjectsContainer) {
|
||||
|
||||
gd::EventsFunctionTools::BehaviorEventsFunctionToObjectsContainer(
|
||||
project, eventsBasedBehavior, eventsFunction, globalObjectsContainers,
|
||||
objectsContainers);
|
||||
auto projectScopedContainers =
|
||||
gd::ProjectScopedContainers::MakeNewProjectScopedContainersFor(globalObjectsContainers, objectsContainers);
|
||||
projectScopedContainers.AddPropertiesContainer(eventsBasedBehavior.GetSharedPropertyDescriptors());
|
||||
projectScopedContainers.AddPropertiesContainer(eventsBasedBehavior.GetPropertyDescriptors());
|
||||
projectScopedContainers.AddParameters(eventsFunction.GetParametersForEvents(eventsBasedBehavior.GetEventsFunctions()));
|
||||
gd::EventsFunctionTools::BehaviorEventsFunctionToObjectsContainer(
|
||||
project,
|
||||
eventsBasedBehavior,
|
||||
eventsFunction,
|
||||
parameterObjectsContainer);
|
||||
|
||||
ProjectScopedContainers projectScopedContainers(
|
||||
ObjectsContainersList::MakeNewObjectsContainersListForContainer(
|
||||
parameterObjectsContainer),
|
||||
VariablesContainersList::MakeNewEmptyVariablesContainersList(),
|
||||
PropertiesContainersList::MakeNewEmptyPropertiesContainersList());
|
||||
|
||||
projectScopedContainers.AddPropertiesContainer(
|
||||
eventsBasedBehavior.GetSharedPropertyDescriptors());
|
||||
projectScopedContainers.AddPropertiesContainer(
|
||||
eventsBasedBehavior.GetPropertyDescriptors());
|
||||
projectScopedContainers.AddParameters(eventsFunction.GetParametersForEvents(
|
||||
eventsBasedBehavior.GetEventsFunctions()));
|
||||
|
||||
return projectScopedContainers;
|
||||
}
|
||||
@@ -52,16 +65,21 @@ ProjectScopedContainers::MakeNewProjectScopedContainersForObjectEventsFunction(
|
||||
const gd::Project &project,
|
||||
const gd::EventsBasedObject &eventsBasedObject,
|
||||
const gd::EventsFunction &eventsFunction,
|
||||
gd::ObjectsContainer &globalObjectsContainers,
|
||||
gd::ObjectsContainer &objectsContainers) {
|
||||
gd::ObjectsContainer ¶meterObjectsContainer) {
|
||||
|
||||
gd::EventsFunctionTools::ObjectEventsFunctionToObjectsContainer(
|
||||
project, eventsBasedObject, eventsFunction, globalObjectsContainers,
|
||||
objectsContainers);
|
||||
auto projectScopedContainers =
|
||||
gd::ProjectScopedContainers::MakeNewProjectScopedContainersFor(globalObjectsContainers, objectsContainers);
|
||||
projectScopedContainers.AddPropertiesContainer(eventsBasedObject.GetPropertyDescriptors());
|
||||
projectScopedContainers.AddParameters(eventsFunction.GetParametersForEvents(eventsBasedObject.GetEventsFunctions()));
|
||||
gd::EventsFunctionTools::ObjectEventsFunctionToObjectsContainer(
|
||||
project, eventsBasedObject, eventsFunction, parameterObjectsContainer);
|
||||
|
||||
ProjectScopedContainers projectScopedContainers(
|
||||
ObjectsContainersList::MakeNewObjectsContainersListForContainer(
|
||||
parameterObjectsContainer),
|
||||
VariablesContainersList::MakeNewEmptyVariablesContainersList(),
|
||||
PropertiesContainersList::MakeNewEmptyPropertiesContainersList());
|
||||
|
||||
projectScopedContainers.AddPropertiesContainer(
|
||||
eventsBasedObject.GetPropertyDescriptors());
|
||||
projectScopedContainers.AddParameters(eventsFunction.GetParametersForEvents(
|
||||
eventsBasedObject.GetEventsFunctions()));
|
||||
|
||||
return projectScopedContainers;
|
||||
}
|
||||
|
@@ -56,6 +56,9 @@ class ProjectScopedContainers {
|
||||
return projectScopedContainers;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use another method for an explicit context instead.
|
||||
*/
|
||||
static ProjectScopedContainers MakeNewProjectScopedContainersFor(
|
||||
const gd::ObjectsContainer &globalObjectsContainers,
|
||||
const gd::ObjectsContainer &objectsContainers) {
|
||||
@@ -73,24 +76,21 @@ class ProjectScopedContainers {
|
||||
const gd::Project &project,
|
||||
const gd::EventsFunctionsContainer &eventsFunctionsContainer,
|
||||
const gd::EventsFunction& eventsFunction,
|
||||
gd::ObjectsContainer &globalObjectsContainers,
|
||||
gd::ObjectsContainer &objectsContainers);
|
||||
gd::ObjectsContainer& parameterObjectsContainer);
|
||||
|
||||
static ProjectScopedContainers
|
||||
MakeNewProjectScopedContainersForBehaviorEventsFunction(
|
||||
const gd::Project &project,
|
||||
const gd::EventsBasedBehavior &eventsBasedBehavior,
|
||||
const gd::EventsFunction &eventsFunction,
|
||||
gd::ObjectsContainer &globalObjectsContainers,
|
||||
gd::ObjectsContainer &objectsContainers);
|
||||
gd::ObjectsContainer ¶meterObjectsContainer);
|
||||
|
||||
static ProjectScopedContainers
|
||||
MakeNewProjectScopedContainersForObjectEventsFunction(
|
||||
const gd::Project &project,
|
||||
const gd::EventsBasedObject &eventsBasedObject,
|
||||
const gd::EventsFunction &eventsFunction,
|
||||
gd::ObjectsContainer &globalObjectsContainers,
|
||||
gd::ObjectsContainer &objectsContainers);
|
||||
gd::ObjectsContainer ¶meterObjectsContainer);
|
||||
|
||||
static ProjectScopedContainers
|
||||
MakeNewProjectScopedContainersWithLocalVariables(
|
||||
|
@@ -6,6 +6,8 @@
|
||||
#include "BehaviorCodeGenerator.h"
|
||||
|
||||
#include "EventsCodeGenerator.h"
|
||||
#include "GDCore/Project/EventsFunctionsExtension.h"
|
||||
#include "GDCore/Project/EventsBasedBehavior.h"
|
||||
|
||||
namespace gdjs {
|
||||
|
||||
|
@@ -3,16 +3,19 @@
|
||||
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
|
||||
* reserved. This project is released under the MIT License.
|
||||
*/
|
||||
#ifndef GDJS_BEHAVIORCODEGENERATOR_H
|
||||
#define GDJS_BEHAVIORCODEGENERATOR_H
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "GDCore/Project/Project.h"
|
||||
#include "GDCore/Project/EventsBasedBehavior.h"
|
||||
|
||||
namespace gd {
|
||||
class NamedPropertyDescriptor;
|
||||
class EventsBasedBehavior;
|
||||
}
|
||||
|
||||
namespace gdjs {
|
||||
@@ -166,4 +169,3 @@ class BehaviorCodeGenerator {
|
||||
};
|
||||
|
||||
} // namespace gdjs
|
||||
#endif // GDJS_BEHAVIORCODEGENERATOR_H
|
||||
|
@@ -27,6 +27,7 @@
|
||||
#include "GDCore/Project/ObjectsContainer.h"
|
||||
#include "GDCore/Project/Project.h"
|
||||
#include "GDCore/Project/PropertiesContainer.h"
|
||||
#include "GDCore/Project/EventsFunctionsExtension.h"
|
||||
#include "GDJS/Events/CodeGeneration/BehaviorCodeGenerator.h"
|
||||
#include "GDJS/Events/CodeGeneration/EventsCodeGenerator.h"
|
||||
#include "GDJS/Extensions/JsPlatform.h"
|
||||
@@ -125,12 +126,10 @@ gd::String EventsCodeGenerator::GenerateEventsFunctionCode(
|
||||
const gd::String& codeNamespace,
|
||||
std::set<gd::String>& includeFiles,
|
||||
bool compilationForRuntime) {
|
||||
gd::ObjectsContainer globalObjectsAndGroups;
|
||||
gd::ObjectsContainer objectsAndGroups;
|
||||
auto projectScopedContainers = gd::ProjectScopedContainers::
|
||||
MakeNewProjectScopedContainersForFreeEventsFunction(
|
||||
project, functionsContainer, eventsFunction, globalObjectsAndGroups,
|
||||
objectsAndGroups);
|
||||
gd::ObjectsContainer parameterObjectsAndGroups;
|
||||
auto projectScopedContainers =
|
||||
gd::ProjectScopedContainers::MakeNewProjectScopedContainersForFreeEventsFunction(
|
||||
project, functionsContainer, eventsFunction, parameterObjectsAndGroups);
|
||||
|
||||
EventsCodeGenerator codeGenerator(projectScopedContainers);
|
||||
codeGenerator.SetCodeNamespace(codeNamespace);
|
||||
@@ -164,12 +163,12 @@ gd::String EventsCodeGenerator::GenerateBehaviorEventsFunctionCode(
|
||||
const gd::String& preludeCode,
|
||||
std::set<gd::String>& includeFiles,
|
||||
bool compilationForRuntime) {
|
||||
gd::ObjectsContainer globalObjectsAndGroups;
|
||||
gd::ObjectsContainer objectsAndGroups;
|
||||
|
||||
gd::ObjectsContainer parameterObjectsContainers;
|
||||
auto projectScopedContainers = gd::ProjectScopedContainers::
|
||||
MakeNewProjectScopedContainersForBehaviorEventsFunction(
|
||||
project, eventsBasedBehavior, eventsFunction, globalObjectsAndGroups,
|
||||
objectsAndGroups);
|
||||
project, eventsBasedBehavior,
|
||||
eventsFunction, parameterObjectsContainers);
|
||||
|
||||
EventsCodeGenerator codeGenerator(projectScopedContainers);
|
||||
codeGenerator.SetCodeNamespace(codeNamespace);
|
||||
@@ -230,12 +229,12 @@ gd::String EventsCodeGenerator::GenerateObjectEventsFunctionCode(
|
||||
const gd::String& endingCode,
|
||||
std::set<gd::String>& includeFiles,
|
||||
bool compilationForRuntime) {
|
||||
gd::ObjectsContainer globalObjectsAndGroups;
|
||||
gd::ObjectsContainer objectsAndGroups;
|
||||
|
||||
gd::ObjectsContainer parameterObjectsContainers;
|
||||
auto projectScopedContainers = gd::ProjectScopedContainers::
|
||||
MakeNewProjectScopedContainersForObjectEventsFunction(
|
||||
project, eventsBasedObject, eventsFunction, globalObjectsAndGroups,
|
||||
objectsAndGroups);
|
||||
project, eventsBasedObject,
|
||||
eventsFunction, parameterObjectsContainers);
|
||||
|
||||
EventsCodeGenerator codeGenerator(projectScopedContainers);
|
||||
codeGenerator.SetCodeNamespace(codeNamespace);
|
||||
|
@@ -3,8 +3,8 @@
|
||||
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
|
||||
* reserved. This project is released under the MIT License.
|
||||
*/
|
||||
#ifndef EVENTSCODEGENERATOR_H
|
||||
#define EVENTSCODEGENERATOR_H
|
||||
#pragma once
|
||||
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@@ -461,4 +461,3 @@ class EventsCodeGenerator : public gd::EventsCodeGenerator {
|
||||
};
|
||||
|
||||
} // namespace gdjs
|
||||
#endif // EVENTSCODEGENERATOR_H
|
||||
|
@@ -6,6 +6,8 @@
|
||||
#include "ObjectCodeGenerator.h"
|
||||
|
||||
#include "EventsCodeGenerator.h"
|
||||
#include "GDCore/Project/EventsBasedObject.h"
|
||||
#include "GDCore/Project/EventsFunctionsExtension.h"
|
||||
|
||||
namespace gdjs {
|
||||
|
||||
|
@@ -3,16 +3,18 @@
|
||||
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
|
||||
* reserved. This project is released under the MIT License.
|
||||
*/
|
||||
#ifndef GDJS_OBJECTCODEGENERATOR_H
|
||||
#define GDJS_OBJECTCODEGENERATOR_H
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "GDCore/Project/EventsBasedObject.h"
|
||||
#include "GDCore/Project/Project.h"
|
||||
|
||||
namespace gd {
|
||||
class NamedPropertyDescriptor;
|
||||
class EventsBasedObject;
|
||||
}
|
||||
|
||||
namespace gdjs {
|
||||
@@ -117,4 +119,3 @@ class ObjectCodeGenerator {
|
||||
};
|
||||
|
||||
} // namespace gdjs
|
||||
#endif // GDJS_OBJECTCODEGENERATOR_H
|
||||
|
@@ -327,10 +327,6 @@ interface VariablesContainer {
|
||||
};
|
||||
|
||||
interface VariablesContainersList {
|
||||
[Value] VariablesContainersList STATIC_MakeNewVariablesContainersListForProjectAndLayout(
|
||||
[Const, Ref] Project project,
|
||||
[Const, Ref] Layout layout);
|
||||
[Value] VariablesContainersList STATIC_MakeNewEmptyVariablesContainersList();
|
||||
boolean Has([Const] DOMString name);
|
||||
[Const, Ref] Variable Get([Const] DOMString name);
|
||||
[Const, Ref] VariablesContainer GetVariablesContainerFromVariableName([Const] DOMString variableName);
|
||||
@@ -650,27 +646,25 @@ interface ProjectScopedContainers {
|
||||
[Value] ProjectScopedContainers STATIC_MakeNewProjectScopedContainersForProjectAndLayout(
|
||||
[Const, Ref] Project project,
|
||||
[Const, Ref] Layout layout);
|
||||
[Value] ProjectScopedContainers STATIC_MakeNewProjectScopedContainersFor(
|
||||
[Const, Ref] ObjectsContainer globalObjectsContainer,
|
||||
[Const, Ref] ObjectsContainer objectsContainer);
|
||||
|
||||
[Value] ProjectScopedContainers STATIC_MakeNewProjectScopedContainersForFreeEventsFunction(
|
||||
[Const, Ref] Project project,
|
||||
[Const, Ref] Project project,
|
||||
[Const, Ref] EventsFunctionsContainer eventsFunctionsContainer,
|
||||
[Const, Ref] EventsFunction eventsFunction,
|
||||
[Ref] ObjectsContainer globalObjectsContainers,
|
||||
[Ref] ObjectsContainer objectsContainers);
|
||||
[Const, Ref] EventsFunction eventsFunction,
|
||||
[Ref] ObjectsContainer parameterObjectsContainer);
|
||||
|
||||
[Value] ProjectScopedContainers STATIC_MakeNewProjectScopedContainersForBehaviorEventsFunction(
|
||||
[Const, Ref] Project project,
|
||||
[Const, Ref] EventsBasedBehavior eventsBasedBehavior,
|
||||
[Const, Ref] EventsFunction eventsFunction,
|
||||
[Ref] ObjectsContainer globalObjectsContainers,
|
||||
[Ref] ObjectsContainer objectsContainers);
|
||||
[Const, Ref] Project project,
|
||||
[Const, Ref] EventsBasedBehavior eventsBasedBehavior,
|
||||
[Const, Ref] EventsFunction eventsFunction,
|
||||
[Ref] ObjectsContainer parameterObjectsContainer);
|
||||
|
||||
[Value] ProjectScopedContainers STATIC_MakeNewProjectScopedContainersForObjectEventsFunction(
|
||||
[Const, Ref] Project project,
|
||||
[Const, Ref] EventsBasedObject eventsBasedObject,
|
||||
[Const, Ref] EventsFunction eventsFunction,
|
||||
[Ref] ObjectsContainer globalObjectsContainers,
|
||||
[Ref] ObjectsContainer objectsContainers);
|
||||
[Const, Ref] Project project,
|
||||
[Const, Ref] EventsBasedObject eventsBasedObject,
|
||||
[Const, Ref] EventsFunction eventsFunction,
|
||||
[Ref] ObjectsContainer parameterObjectsContainer);
|
||||
|
||||
[Value] ProjectScopedContainers STATIC_MakeNewProjectScopedContainersWithLocalVariables(
|
||||
[Const, Ref] ProjectScopedContainers projectScopedContainers,
|
||||
[Const, Ref] BaseEvent event);
|
||||
@@ -1716,12 +1710,6 @@ interface ParameterMetadataTools {
|
||||
unsigned long STATIC_GetObjectParameterIndexFor([Const, Ref] VectorParameterMetadata parameters, unsigned long parameterIndex);
|
||||
};
|
||||
|
||||
interface EventsFunctionTools {
|
||||
void STATIC_FreeEventsFunctionToObjectsContainer([Ref] Project project, [Const, Ref] EventsFunctionsContainer functionsContainer, [Const, Ref] EventsFunction eventsFunction, [Ref] ObjectsContainer outputGlobalObjectsContainer, [Ref] ObjectsContainer outputObjectsContainer);
|
||||
void STATIC_BehaviorEventsFunctionToObjectsContainer([Ref] Project project, [Const, Ref] EventsBasedBehavior eventsBasedBehavior, [Const, Ref] EventsFunction eventsFunction, [Ref] ObjectsContainer outputGlobalObjectsContainer, [Ref] ObjectsContainer outputObjectsContainer);
|
||||
void STATIC_ObjectEventsFunctionToObjectsContainer([Ref] Project project, [Const, Ref] EventsBasedObject eventsBasedObject, [Const, Ref] EventsFunction eventsFunction, [Ref] ObjectsContainer outputGlobalObjectsContainer, [Ref] ObjectsContainer outputObjectsContainer);
|
||||
};
|
||||
|
||||
interface ObjectMetadata {
|
||||
[Const, Ref] DOMString GetName();
|
||||
[Const, Ref] DOMString GetFullName();
|
||||
|
@@ -559,10 +559,6 @@ typedef ExtensionAndMetadata<ExpressionMetadata> ExtensionAndExpressionMetadata;
|
||||
#define STATIC_Get Get
|
||||
#define STATIC_GetAllUseless GetAllUseless
|
||||
#define STATIC_RemoveAllUseless RemoveAllUseless
|
||||
#define STATIC_MakeNewVariablesContainersListForProjectAndLayout \
|
||||
MakeNewVariablesContainersListForProjectAndLayout
|
||||
#define STATIC_MakeNewEmptyVariablesContainersList \
|
||||
MakeNewEmptyVariablesContainersList
|
||||
#define STATIC_MakeNewObjectsContainersListForProjectAndLayout \
|
||||
MakeNewObjectsContainersListForProjectAndLayout
|
||||
#define STATIC_MakeNewObjectsContainersListForContainers \
|
||||
@@ -581,6 +577,12 @@ typedef ExtensionAndMetadata<ExpressionMetadata> ExtensionAndExpressionMetadata;
|
||||
MakeNewProjectScopedContainersForObjectEventsFunction
|
||||
#define STATIC_MakeNewProjectScopedContainersWithLocalVariables \
|
||||
MakeNewProjectScopedContainersWithLocalVariables
|
||||
#define STATIC_MakeNewProjectScopedContainersForFreeEventsFunction \
|
||||
MakeNewProjectScopedContainersForFreeEventsFunction
|
||||
#define STATIC_MakeNewProjectScopedContainersForBehaviorEventsFunction \
|
||||
MakeNewProjectScopedContainersForBehaviorEventsFunction
|
||||
#define STATIC_MakeNewProjectScopedContainersForObjectEventsFunction \
|
||||
MakeNewProjectScopedContainersForObjectEventsFunction
|
||||
|
||||
#define STATIC_GetExtensionAndBehaviorMetadata GetExtensionAndBehaviorMetadata
|
||||
#define STATIC_GetExtensionAndObjectMetadata GetExtensionAndObjectMetadata
|
||||
@@ -698,12 +700,6 @@ typedef ExtensionAndMetadata<ExpressionMetadata> ExtensionAndExpressionMetadata;
|
||||
#define STATIC_FoldAll FoldAll
|
||||
#define STATIC_UnfoldToLevel UnfoldToLevel
|
||||
|
||||
#define STATIC_FreeEventsFunctionToObjectsContainer \
|
||||
FreeEventsFunctionToObjectsContainer
|
||||
#define STATIC_BehaviorEventsFunctionToObjectsContainer \
|
||||
BehaviorEventsFunctionToObjectsContainer
|
||||
#define STATIC_ObjectEventsFunctionToObjectsContainer \
|
||||
ObjectEventsFunctionToObjectsContainer
|
||||
#define STATIC_ParametersToObjectsContainer ParametersToObjectsContainer
|
||||
#define STATIC_GetObjectParameterIndexFor GetObjectParameterIndexFor
|
||||
|
||||
|
15
GDevelop.js/types.d.ts
vendored
15
GDevelop.js/types.d.ts
vendored
@@ -318,8 +318,6 @@ export class VariablesContainer extends EmscriptenObject {
|
||||
}
|
||||
|
||||
export class VariablesContainersList extends EmscriptenObject {
|
||||
static makeNewVariablesContainersListForProjectAndLayout(project: Project, layout: Layout): VariablesContainersList;
|
||||
static makeNewEmptyVariablesContainersList(): VariablesContainersList;
|
||||
has(name: string): boolean;
|
||||
get(name: string): Variable;
|
||||
getVariablesContainerFromVariableName(variableName: string): VariablesContainer;
|
||||
@@ -594,10 +592,9 @@ export class ObjectsContainersList extends EmscriptenObject {
|
||||
|
||||
export class ProjectScopedContainers extends EmscriptenObject {
|
||||
static makeNewProjectScopedContainersForProjectAndLayout(project: Project, layout: Layout): ProjectScopedContainers;
|
||||
static makeNewProjectScopedContainersFor(globalObjectsContainer: ObjectsContainer, objectsContainer: ObjectsContainer): ProjectScopedContainers;
|
||||
static makeNewProjectScopedContainersForFreeEventsFunction(project: Project, eventsFunctionsContainer: EventsFunctionsContainer, eventsFunction: EventsFunction, globalObjectsContainers: ObjectsContainer, objectsContainers: ObjectsContainer): ProjectScopedContainers;
|
||||
static makeNewProjectScopedContainersForBehaviorEventsFunction(project: Project, eventsBasedBehavior: EventsBasedBehavior, eventsFunction: EventsFunction, globalObjectsContainers: ObjectsContainer, objectsContainers: ObjectsContainer): ProjectScopedContainers;
|
||||
static makeNewProjectScopedContainersForObjectEventsFunction(project: Project, eventsBasedObject: EventsBasedObject, eventsFunction: EventsFunction, globalObjectsContainers: ObjectsContainer, objectsContainers: ObjectsContainer): ProjectScopedContainers;
|
||||
static makeNewProjectScopedContainersForFreeEventsFunction(project: Project, eventsFunctionsContainer: EventsFunctionsContainer, eventsFunction: EventsFunction, parameterObjectsContainer: ObjectsContainer): ProjectScopedContainers;
|
||||
static makeNewProjectScopedContainersForBehaviorEventsFunction(project: Project, eventsBasedBehavior: EventsBasedBehavior, eventsFunction: EventsFunction, parameterObjectsContainer: ObjectsContainer): ProjectScopedContainers;
|
||||
static makeNewProjectScopedContainersForObjectEventsFunction(project: Project, eventsBasedObject: EventsBasedObject, eventsFunction: EventsFunction, parameterObjectsContainer: ObjectsContainer): ProjectScopedContainers;
|
||||
static makeNewProjectScopedContainersWithLocalVariables(projectScopedContainers: ProjectScopedContainers, event: BaseEvent): ProjectScopedContainers;
|
||||
addPropertiesContainer(propertiesContainer: PropertiesContainer): ProjectScopedContainers;
|
||||
addParameters(parameters: VectorParameterMetadata): ProjectScopedContainers;
|
||||
@@ -1450,12 +1447,6 @@ export class ParameterMetadataTools extends EmscriptenObject {
|
||||
static getObjectParameterIndexFor(parameters: VectorParameterMetadata, parameterIndex: number): number;
|
||||
}
|
||||
|
||||
export class EventsFunctionTools extends EmscriptenObject {
|
||||
static freeEventsFunctionToObjectsContainer(project: Project, functionsContainer: EventsFunctionsContainer, eventsFunction: EventsFunction, outputGlobalObjectsContainer: ObjectsContainer, outputObjectsContainer: ObjectsContainer): void;
|
||||
static behaviorEventsFunctionToObjectsContainer(project: Project, eventsBasedBehavior: EventsBasedBehavior, eventsFunction: EventsFunction, outputGlobalObjectsContainer: ObjectsContainer, outputObjectsContainer: ObjectsContainer): void;
|
||||
static objectEventsFunctionToObjectsContainer(project: Project, eventsBasedObject: EventsBasedObject, eventsFunction: EventsFunction, outputGlobalObjectsContainer: ObjectsContainer, outputObjectsContainer: ObjectsContainer): void;
|
||||
}
|
||||
|
||||
export class ObjectMetadata extends EmscriptenObject {
|
||||
getName(): string;
|
||||
getFullName(): string;
|
||||
|
@@ -1,8 +0,0 @@
|
||||
// Automatically generated by GDevelop.js/scripts/generate-types.js
|
||||
declare class gdEventsFunctionTools {
|
||||
static freeEventsFunctionToObjectsContainer(project: gdProject, functionsContainer: gdEventsFunctionsContainer, eventsFunction: gdEventsFunction, outputGlobalObjectsContainer: gdObjectsContainer, outputObjectsContainer: gdObjectsContainer): void;
|
||||
static behaviorEventsFunctionToObjectsContainer(project: gdProject, eventsBasedBehavior: gdEventsBasedBehavior, eventsFunction: gdEventsFunction, outputGlobalObjectsContainer: gdObjectsContainer, outputObjectsContainer: gdObjectsContainer): void;
|
||||
static objectEventsFunctionToObjectsContainer(project: gdProject, eventsBasedObject: gdEventsBasedObject, eventsFunction: gdEventsFunction, outputGlobalObjectsContainer: gdObjectsContainer, outputObjectsContainer: gdObjectsContainer): void;
|
||||
delete(): void;
|
||||
ptr: number;
|
||||
};
|
@@ -1,10 +1,9 @@
|
||||
// Automatically generated by GDevelop.js/scripts/generate-types.js
|
||||
declare class gdProjectScopedContainers {
|
||||
static makeNewProjectScopedContainersForProjectAndLayout(project: gdProject, layout: gdLayout): gdProjectScopedContainers;
|
||||
static makeNewProjectScopedContainersFor(globalObjectsContainer: gdObjectsContainer, objectsContainer: gdObjectsContainer): gdProjectScopedContainers;
|
||||
static makeNewProjectScopedContainersForFreeEventsFunction(project: gdProject, eventsFunctionsContainer: gdEventsFunctionsContainer, eventsFunction: gdEventsFunction, globalObjectsContainers: gdObjectsContainer, objectsContainers: gdObjectsContainer): gdProjectScopedContainers;
|
||||
static makeNewProjectScopedContainersForBehaviorEventsFunction(project: gdProject, eventsBasedBehavior: gdEventsBasedBehavior, eventsFunction: gdEventsFunction, globalObjectsContainers: gdObjectsContainer, objectsContainers: gdObjectsContainer): gdProjectScopedContainers;
|
||||
static makeNewProjectScopedContainersForObjectEventsFunction(project: gdProject, eventsBasedObject: gdEventsBasedObject, eventsFunction: gdEventsFunction, globalObjectsContainers: gdObjectsContainer, objectsContainers: gdObjectsContainer): gdProjectScopedContainers;
|
||||
static makeNewProjectScopedContainersForFreeEventsFunction(project: gdProject, eventsFunctionsContainer: gdEventsFunctionsContainer, eventsFunction: gdEventsFunction, parameterObjectsContainer: gdObjectsContainer): gdProjectScopedContainers;
|
||||
static makeNewProjectScopedContainersForBehaviorEventsFunction(project: gdProject, eventsBasedBehavior: gdEventsBasedBehavior, eventsFunction: gdEventsFunction, parameterObjectsContainer: gdObjectsContainer): gdProjectScopedContainers;
|
||||
static makeNewProjectScopedContainersForObjectEventsFunction(project: gdProject, eventsBasedObject: gdEventsBasedObject, eventsFunction: gdEventsFunction, parameterObjectsContainer: gdObjectsContainer): gdProjectScopedContainers;
|
||||
static makeNewProjectScopedContainersWithLocalVariables(projectScopedContainers: gdProjectScopedContainers, event: gdBaseEvent): gdProjectScopedContainers;
|
||||
addPropertiesContainer(propertiesContainer: gdPropertiesContainer): gdProjectScopedContainers;
|
||||
addParameters(parameters: gdVectorParameterMetadata): gdProjectScopedContainers;
|
||||
|
@@ -1,7 +1,5 @@
|
||||
// Automatically generated by GDevelop.js/scripts/generate-types.js
|
||||
declare class gdVariablesContainersList {
|
||||
static makeNewVariablesContainersListForProjectAndLayout(project: gdProject, layout: gdLayout): gdVariablesContainersList;
|
||||
static makeNewEmptyVariablesContainersList(): gdVariablesContainersList;
|
||||
has(name: string): boolean;
|
||||
get(name: string): gdVariable;
|
||||
getVariablesContainerFromVariableName(variableName: string): gdVariablesContainer;
|
||||
|
@@ -145,7 +145,6 @@ declare class libGDevelop {
|
||||
ValueTypeMetadata: Class<gdValueTypeMetadata>;
|
||||
VectorParameterMetadata: Class<gdVectorParameterMetadata>;
|
||||
ParameterMetadataTools: Class<gdParameterMetadataTools>;
|
||||
EventsFunctionTools: Class<gdEventsFunctionTools>;
|
||||
ObjectMetadata: Class<gdObjectMetadata>;
|
||||
BehaviorMetadata: Class<gdBehaviorMetadata>;
|
||||
EffectMetadata: Class<gdEffectMetadata>;
|
||||
|
@@ -18,7 +18,7 @@ export type EnumeratedBehaviorMetadata = {|
|
||||
export const enumerateBehaviorsMetadata = (
|
||||
platform: gdPlatform,
|
||||
project: gdProject,
|
||||
eventsFunctionsExtension?: gdEventsFunctionsExtension
|
||||
eventsFunctionsExtension?: ?gdEventsFunctionsExtension
|
||||
): Array<EnumeratedBehaviorMetadata> => {
|
||||
const extensionsList = platform.getAllPlatformExtensions();
|
||||
|
||||
|
@@ -27,7 +27,7 @@ const gd: libGDevelop = global.gd;
|
||||
|
||||
type Props = {|
|
||||
project: gdProject,
|
||||
eventsFunctionsExtension?: gdEventsFunctionsExtension,
|
||||
eventsFunctionsExtension?: ?gdEventsFunctionsExtension,
|
||||
objectType: string,
|
||||
objectBehaviorsTypes: Array<string>,
|
||||
open: boolean,
|
||||
|
@@ -129,6 +129,7 @@ export default class EventsFunctionsExtensionEditor extends React.Component<
|
||||
// (like ObjectGroupsList) because objects "ptr" changed.
|
||||
_globalObjectsContainer: gdObjectsContainer = new gd.ObjectsContainer();
|
||||
_objectsContainer: gdObjectsContainer = new gd.ObjectsContainer();
|
||||
_projectScopedContainersAccessor: ProjectScopedContainersAccessor | null = null;
|
||||
|
||||
componentDidMount() {
|
||||
if (this.props.initiallyFocusedFunctionName) {
|
||||
@@ -155,37 +156,28 @@ export default class EventsFunctionsExtensionEditor extends React.Component<
|
||||
eventsBasedObject: ?gdEventsBasedObject,
|
||||
eventsFunctionsExtension: ?gdEventsFunctionsExtension
|
||||
) => {
|
||||
// Initialize this "context" of objects with the function
|
||||
// (as done during code generation).
|
||||
if (eventsBasedBehavior) {
|
||||
gd.EventsFunctionTools.behaviorEventsFunctionToObjectsContainer(
|
||||
project,
|
||||
eventsBasedBehavior,
|
||||
eventsFunction,
|
||||
this._globalObjectsContainer,
|
||||
this._objectsContainer
|
||||
);
|
||||
} else if (eventsBasedObject) {
|
||||
gd.EventsFunctionTools.objectEventsFunctionToObjectsContainer(
|
||||
project,
|
||||
eventsBasedObject,
|
||||
eventsFunction,
|
||||
this._globalObjectsContainer,
|
||||
this._objectsContainer
|
||||
);
|
||||
} else if (eventsFunctionsExtension) {
|
||||
gd.EventsFunctionTools.freeEventsFunctionToObjectsContainer(
|
||||
project,
|
||||
eventsFunctionsExtension,
|
||||
eventsFunction,
|
||||
this._globalObjectsContainer,
|
||||
this._objectsContainer
|
||||
);
|
||||
} else {
|
||||
if (
|
||||
!eventsFunctionsExtension &&
|
||||
!eventsBasedBehavior &&
|
||||
!eventsBasedObject
|
||||
) {
|
||||
throw new Error(
|
||||
'No extension, behavior or object was specified when loading a function'
|
||||
);
|
||||
}
|
||||
const scope = {
|
||||
project,
|
||||
layout: null,
|
||||
externalEvents: null,
|
||||
eventsFunctionsExtension,
|
||||
eventsBasedBehavior,
|
||||
eventsBasedObject,
|
||||
eventsFunction,
|
||||
};
|
||||
this._projectScopedContainersAccessor = new ProjectScopedContainersAccessor(
|
||||
scope,
|
||||
this._objectsContainer
|
||||
);
|
||||
};
|
||||
|
||||
updateToolbar = () => {
|
||||
@@ -1131,11 +1123,6 @@ export default class EventsFunctionsExtensionEditor extends React.Component<
|
||||
eventsBasedObject: selectedEventsBasedObject,
|
||||
eventsFunction: selectedEventsFunction,
|
||||
};
|
||||
const projectScopedContainersAccessor = new ProjectScopedContainersAccessor(
|
||||
scope,
|
||||
this._globalObjectsContainer,
|
||||
this._objectsContainer
|
||||
);
|
||||
|
||||
const selectedEventsBasedEntity =
|
||||
selectedEventsBasedBehavior || selectedEventsBasedObject;
|
||||
@@ -1221,6 +1208,7 @@ export default class EventsFunctionsExtensionEditor extends React.Component<
|
||||
toolbarControls: [],
|
||||
renderEditor: () =>
|
||||
selectedEventsFunction &&
|
||||
this._projectScopedContainersAccessor &&
|
||||
this._globalObjectsContainer &&
|
||||
this._objectsContainer ? (
|
||||
<Background>
|
||||
@@ -1232,7 +1220,7 @@ export default class EventsFunctionsExtensionEditor extends React.Component<
|
||||
globalObjectsContainer={this._globalObjectsContainer}
|
||||
objectsContainer={this._objectsContainer}
|
||||
projectScopedContainersAccessor={
|
||||
projectScopedContainersAccessor
|
||||
this._projectScopedContainersAccessor
|
||||
}
|
||||
events={selectedEventsFunction.getEvents()}
|
||||
onOpenExternalEvents={() => {}}
|
||||
|
@@ -41,9 +41,7 @@ export const setupFunctionFromEvents = ({
|
||||
|
||||
// Analyze events...
|
||||
const projectScopedContainers = new ProjectScopedContainersAccessor(
|
||||
scope,
|
||||
globalObjectsContainer,
|
||||
objectsContainer
|
||||
scope
|
||||
).get();
|
||||
const eventsContextAnalyzer = new gd.EventsContextAnalyzer(
|
||||
gd.JsPlatform.get()
|
||||
|
@@ -74,9 +74,7 @@ describe('ExpressionAutocompletion', () => {
|
||||
|
||||
const expressionNode = parser.parseExpression('My').get();
|
||||
const projectScopedContainersAccessor = new ProjectScopedContainersAccessor(
|
||||
scope,
|
||||
project,
|
||||
testLayout
|
||||
scope
|
||||
);
|
||||
const completionDescriptions = gd.ExpressionCompletionFinder.getCompletionDescriptionsFor(
|
||||
gd.JsPlatform.get(),
|
||||
@@ -147,9 +145,7 @@ describe('ExpressionAutocompletion', () => {
|
||||
|
||||
const expressionNode = parser.parseExpression('To').get();
|
||||
const projectScopedContainersAccessor = new ProjectScopedContainersAccessor(
|
||||
scope,
|
||||
project,
|
||||
testLayout
|
||||
scope
|
||||
);
|
||||
const completionDescriptions = gd.ExpressionCompletionFinder.getCompletionDescriptionsFor(
|
||||
gd.JsPlatform.get(),
|
||||
@@ -204,9 +200,7 @@ describe('ExpressionAutocompletion', () => {
|
||||
|
||||
const expressionNode = parser.parseExpression('MouseX("Ba').get();
|
||||
const projectScopedContainersAccessor = new ProjectScopedContainersAccessor(
|
||||
scope,
|
||||
project,
|
||||
testLayout
|
||||
scope
|
||||
);
|
||||
const completionDescriptions = gd.ExpressionCompletionFinder.getCompletionDescriptionsFor(
|
||||
gd.JsPlatform.get(),
|
||||
@@ -241,9 +235,7 @@ describe('ExpressionAutocompletion', () => {
|
||||
|
||||
const expressionNode = parser.parseExpression('MySpriteObject.Ani').get();
|
||||
const projectScopedContainersAccessor = new ProjectScopedContainersAccessor(
|
||||
scope,
|
||||
project,
|
||||
testLayout
|
||||
scope
|
||||
);
|
||||
const completionDescriptions = gd.ExpressionCompletionFinder.getCompletionDescriptionsFor(
|
||||
gd.JsPlatform.get(),
|
||||
@@ -282,9 +274,7 @@ describe('ExpressionAutocompletion', () => {
|
||||
.parseExpression('MySpriteObjectWithBehaviors.Speed')
|
||||
.get();
|
||||
const projectScopedContainersAccessor = new ProjectScopedContainersAccessor(
|
||||
scope,
|
||||
project,
|
||||
testLayout
|
||||
scope
|
||||
);
|
||||
const completionDescriptions = gd.ExpressionCompletionFinder.getCompletionDescriptionsFor(
|
||||
gd.JsPlatform.get(),
|
||||
@@ -333,9 +323,7 @@ describe('ExpressionAutocompletion', () => {
|
||||
.parseExpression('MySpriteObject.PointX("He')
|
||||
.get();
|
||||
const projectScopedContainersAccessor = new ProjectScopedContainersAccessor(
|
||||
scope,
|
||||
project,
|
||||
testLayout
|
||||
scope
|
||||
);
|
||||
const completionDescriptions = gd.ExpressionCompletionFinder.getCompletionDescriptionsFor(
|
||||
gd.JsPlatform.get(),
|
||||
@@ -372,9 +360,7 @@ describe('ExpressionAutocompletion', () => {
|
||||
.parseExpression('MySpriteObjectWithBehaviors.Plat')
|
||||
.get();
|
||||
const projectScopedContainersAccessor = new ProjectScopedContainersAccessor(
|
||||
scope,
|
||||
project,
|
||||
testLayout
|
||||
scope
|
||||
);
|
||||
const completionDescriptions = gd.ExpressionCompletionFinder.getCompletionDescriptionsFor(
|
||||
gd.JsPlatform.get(),
|
||||
@@ -412,9 +398,7 @@ describe('ExpressionAutocompletion', () => {
|
||||
.parseExpression('MySpriteObjectWithBehaviors.a')
|
||||
.get();
|
||||
const projectScopedContainersAccessor = new ProjectScopedContainersAccessor(
|
||||
scope,
|
||||
project,
|
||||
testLayout
|
||||
scope
|
||||
);
|
||||
const completionDescriptions = gd.ExpressionCompletionFinder.getCompletionDescriptionsFor(
|
||||
gd.JsPlatform.get(),
|
||||
@@ -457,9 +441,7 @@ describe('ExpressionAutocompletion', () => {
|
||||
.parseExpression('MySpriteObjectWithBehaviors.PlatformerObject::Jum')
|
||||
.get();
|
||||
const projectScopedContainersAccessor = new ProjectScopedContainersAccessor(
|
||||
scope,
|
||||
project,
|
||||
testLayout
|
||||
scope
|
||||
);
|
||||
const completionDescriptions = gd.ExpressionCompletionFinder.getCompletionDescriptionsFor(
|
||||
gd.JsPlatform.get(),
|
||||
|
@@ -9,7 +9,7 @@ export type EventsScope = {|
|
||||
project: gdProject,
|
||||
layout?: ?gdLayout,
|
||||
externalEvents?: ?gdExternalEvents,
|
||||
eventsFunctionsExtension?: gdEventsFunctionsExtension,
|
||||
eventsFunctionsExtension?: ?gdEventsFunctionsExtension,
|
||||
eventsBasedBehavior?: ?gdEventsBasedBehavior,
|
||||
eventsBasedObject?: ?gdEventsBasedObject,
|
||||
eventsFunction?: ?gdEventsFunction,
|
||||
@@ -17,19 +17,16 @@ export type EventsScope = {|
|
||||
|
||||
export class ProjectScopedContainersAccessor {
|
||||
_scope: EventsScope;
|
||||
_globalObjectsContainer: gdObjectsContainer;
|
||||
_objectsContainer: gdObjectsContainer;
|
||||
_parameterObjectsContainer: gdObjectsContainer | null;
|
||||
_eventPath: Array<gdBaseEvent>;
|
||||
|
||||
constructor(
|
||||
scope: EventsScope,
|
||||
globalObjectsContainer: gdObjectsContainer,
|
||||
objectsContainer: gdObjectsContainer,
|
||||
parameterObjectsContainer: gdObjectsContainer | null = null,
|
||||
eventPath: Array<gdBaseEvent> = []
|
||||
) {
|
||||
this._scope = scope;
|
||||
this._globalObjectsContainer = globalObjectsContainer;
|
||||
this._objectsContainer = objectsContainer;
|
||||
this._parameterObjectsContainer = parameterObjectsContainer;
|
||||
this._eventPath = eventPath;
|
||||
}
|
||||
|
||||
@@ -48,30 +45,27 @@ export class ProjectScopedContainersAccessor {
|
||||
project,
|
||||
layout
|
||||
);
|
||||
} else if (eventsFunction) {
|
||||
} else if (eventsFunction && this._parameterObjectsContainer) {
|
||||
if (eventsBasedBehavior) {
|
||||
projectScopedContainers = gd.ProjectScopedContainers.makeNewProjectScopedContainersForBehaviorEventsFunction(
|
||||
project,
|
||||
eventsBasedBehavior,
|
||||
eventsFunction,
|
||||
this._globalObjectsContainer,
|
||||
this._objectsContainer
|
||||
this._parameterObjectsContainer
|
||||
);
|
||||
} else if (eventsBasedObject) {
|
||||
projectScopedContainers = gd.ProjectScopedContainers.makeNewProjectScopedContainersForObjectEventsFunction(
|
||||
project,
|
||||
eventsBasedObject,
|
||||
eventsFunction,
|
||||
this._globalObjectsContainer,
|
||||
this._objectsContainer
|
||||
this._parameterObjectsContainer
|
||||
);
|
||||
} else if (eventsFunctionsExtension) {
|
||||
projectScopedContainers = gd.ProjectScopedContainers.makeNewProjectScopedContainersForFreeEventsFunction(
|
||||
project,
|
||||
eventsFunctionsExtension,
|
||||
eventsFunction,
|
||||
this._globalObjectsContainer,
|
||||
this._objectsContainer
|
||||
this._parameterObjectsContainer
|
||||
);
|
||||
} else {
|
||||
throw new Error(
|
||||
@@ -80,7 +74,7 @@ export class ProjectScopedContainersAccessor {
|
||||
}
|
||||
} else {
|
||||
throw new Error(
|
||||
'Called `ProjectScopedContainers.get` without a layout or an eventsFunction'
|
||||
'Called `ProjectScopedContainers.get` without a layout or an eventsFunction and eventsFunctionsExtension'
|
||||
);
|
||||
}
|
||||
for (const event of this._eventPath) {
|
||||
@@ -96,8 +90,7 @@ export class ProjectScopedContainersAccessor {
|
||||
makeNewProjectScopedContainersWithLocalVariables(event: gdBaseEvent) {
|
||||
return new ProjectScopedContainersAccessor(
|
||||
this._scope,
|
||||
this._globalObjectsContainer,
|
||||
this._objectsContainer,
|
||||
this._parameterObjectsContainer,
|
||||
[...this._eventPath, event]
|
||||
);
|
||||
}
|
||||
|
@@ -84,9 +84,7 @@ export class EventsEditorContainer extends React.Component<RenderEditorContainer
|
||||
layout,
|
||||
};
|
||||
const projectScopedContainersAccessor = new ProjectScopedContainersAccessor(
|
||||
scope,
|
||||
project,
|
||||
layout
|
||||
scope
|
||||
);
|
||||
|
||||
return (
|
||||
|
@@ -183,7 +183,7 @@ export class ExternalEventsEditorContainer extends React.Component<
|
||||
globalObjectsContainer={project}
|
||||
objectsContainer={layout}
|
||||
projectScopedContainersAccessor={
|
||||
new ProjectScopedContainersAccessor(scope, project, layout)
|
||||
new ProjectScopedContainersAccessor(scope)
|
||||
}
|
||||
events={externalEvents.getEvents()}
|
||||
onOpenSettings={this.openExternalPropertiesDialog}
|
||||
|
@@ -911,18 +911,14 @@ export const makeTestProject = (gd /*: libGDevelop */) /*: TestProject */ => {
|
||||
{
|
||||
project,
|
||||
layout: testLayout,
|
||||
},
|
||||
project,
|
||||
testLayout
|
||||
}
|
||||
);
|
||||
|
||||
const emptySceneProjectScopedContainersAccessor = new ProjectScopedContainersAccessor(
|
||||
{
|
||||
project,
|
||||
layout: emptyLayout,
|
||||
},
|
||||
project,
|
||||
emptyLayout
|
||||
}
|
||||
);
|
||||
|
||||
return {
|
||||
|
Reference in New Issue
Block a user