mirror of
https://github.com/4ian/GDevelop.git
synced 2025-10-15 10:19:04 +00:00
Compare commits
2 Commits
v5.1.158
...
limit-buil
Author | SHA1 | Date | |
---|---|---|---|
![]() |
ba4a37813e | ||
![]() |
3f36054d54 |
4
.github/workflows/build-storybook.yml
vendored
4
.github/workflows/build-storybook.yml
vendored
@@ -17,10 +17,6 @@ jobs:
|
||||
build-storybook:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 16
|
||||
|
||||
- name: Configure AWS Credentials
|
||||
uses: aws-actions/configure-aws-credentials@v1
|
||||
with:
|
||||
|
5
.github/workflows/extract-translations.yml
vendored
5
.github/workflows/extract-translations.yml
vendored
@@ -11,9 +11,6 @@ jobs:
|
||||
extract-translations:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 16
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
# Cache npm dependencies to speed up the workflow
|
||||
@@ -41,7 +38,7 @@ jobs:
|
||||
- name: Install Crowdin CLI
|
||||
if: github.ref == 'refs/heads/master'
|
||||
run: npm i -g @crowdin/cli
|
||||
|
||||
|
||||
- name: Upload translations to Crowdin
|
||||
run: crowdin upload sources
|
||||
if: github.ref == 'refs/heads/master'
|
||||
|
9
.github/workflows/update-translations.yml
vendored
9
.github/workflows/update-translations.yml
vendored
@@ -14,9 +14,6 @@ jobs:
|
||||
update-translations:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 16
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
# Cache npm dependencies to speed up the workflow
|
||||
@@ -47,7 +44,7 @@ jobs:
|
||||
# (Build and) download the most recent translations (PO files) from Crowdin.
|
||||
- name: Install Crowdin CLI
|
||||
run: npm i -g @crowdin/cli
|
||||
|
||||
|
||||
- name: Download new translations from Crowdin
|
||||
run: crowdin download
|
||||
env:
|
||||
@@ -69,8 +66,8 @@ jobs:
|
||||
commit-message: Update translations [skip ci]
|
||||
branch: chore/update-translations
|
||||
delete-branch: true
|
||||
title: "[Auto PR] Update translations"
|
||||
title: '[Auto PR] Update translations'
|
||||
body: |
|
||||
This updates the translations by downloading them from Crowdin and compiling them for usage by the app.
|
||||
|
||||
|
||||
Please double check the values in `newIDE/app/src/locales/LocalesMetadata.js` to ensure the changes are sensible.
|
||||
|
@@ -34,7 +34,6 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAdvancedExtension(
|
||||
"res/function32.png")
|
||||
.SetHelpPath("/events/functions/return")
|
||||
.AddParameter("expression", "The number to be returned")
|
||||
.SetRelevantForFunctionEventsOnly()
|
||||
.MarkAsAdvanced();
|
||||
|
||||
extension
|
||||
@@ -49,7 +48,6 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAdvancedExtension(
|
||||
"res/function32.png")
|
||||
.SetHelpPath("/events/functions/return")
|
||||
.AddParameter("string", "The text to be returned")
|
||||
.SetRelevantForFunctionEventsOnly()
|
||||
.MarkAsAdvanced();
|
||||
|
||||
extension
|
||||
@@ -63,7 +61,6 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAdvancedExtension(
|
||||
"res/function32.png")
|
||||
.SetHelpPath("/events/functions/return")
|
||||
.AddParameter("trueorfalse", "Should the condition be true or false?")
|
||||
.SetRelevantForFunctionEventsOnly()
|
||||
.MarkAsAdvanced();
|
||||
|
||||
extension
|
||||
@@ -78,7 +75,6 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAdvancedExtension(
|
||||
"res/function32.png",
|
||||
"res/function32.png")
|
||||
.AddParameter("functionParameterName", "Parameter name")
|
||||
.SetRelevantForFunctionEventsOnly()
|
||||
.MarkAsAdvanced();
|
||||
|
||||
extension
|
||||
@@ -88,8 +84,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAdvancedExtension(
|
||||
_("Get function parameter (also called \"argument\") value."),
|
||||
"",
|
||||
"res/function16.png")
|
||||
.AddParameter("functionParameterName", "Parameter name")
|
||||
.SetRelevantForFunctionEventsOnly();
|
||||
.AddParameter("functionParameterName", "Parameter name");
|
||||
|
||||
extension
|
||||
.AddStrExpression(
|
||||
@@ -98,8 +93,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAdvancedExtension(
|
||||
_("Get function parameter (also called \"argument\") text."),
|
||||
"",
|
||||
"res/function16.png")
|
||||
.AddParameter("functionParameterName", "Parameter name")
|
||||
.SetRelevantForFunctionEventsOnly();
|
||||
.AddParameter("functionParameterName", "Parameter name");
|
||||
|
||||
extension
|
||||
.AddCondition(
|
||||
@@ -112,8 +106,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAdvancedExtension(
|
||||
"res/function16.png")
|
||||
.AddParameter("functionParameterName", "Parameter name")
|
||||
.UseStandardRelationalOperatorParameters(
|
||||
"number", gd::ParameterOptions::MakeNewOptions())
|
||||
.SetRelevantForFunctionEventsOnly();
|
||||
"number", gd::ParameterOptions::MakeNewOptions());
|
||||
|
||||
extension
|
||||
.AddCondition(
|
||||
@@ -126,8 +119,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAdvancedExtension(
|
||||
"res/function16.png")
|
||||
.AddParameter("functionParameterName", "Parameter name")
|
||||
.UseStandardRelationalOperatorParameters(
|
||||
"string", gd::ParameterOptions::MakeNewOptions())
|
||||
.SetRelevantForFunctionEventsOnly();
|
||||
"string", gd::ParameterOptions::MakeNewOptions());
|
||||
}
|
||||
|
||||
} // namespace gd
|
||||
|
@@ -40,8 +40,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAsyncExtension(
|
||||
"",
|
||||
"res/actions/quit24.png",
|
||||
"res/actions/quit.png")
|
||||
.AddCodeOnlyParameter("eventsFunctionContext", "")
|
||||
.SetRelevantForAsynchronousFunctionEventsOnly();
|
||||
.AddCodeOnlyParameter("eventsFunctionContext", "");
|
||||
}
|
||||
|
||||
} // namespace gd
|
||||
|
@@ -27,10 +27,6 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
||||
.SetIcon("res/actions/create24.png");
|
||||
extension.AddInstructionOrExpressionGroupMetadata(_("Movement using forces"))
|
||||
.SetIcon("res/actions/force24.png");
|
||||
extension.AddInstructionOrExpressionGroupMetadata(_("Variables"))
|
||||
.SetIcon("res/conditions/var24.png");
|
||||
extension.AddInstructionOrExpressionGroupMetadata(_("Position"))
|
||||
.SetIcon("res/actions/position24_black.png");
|
||||
|
||||
gd::ObjectMetadata& obj = extension.AddObject<gd::ObjectConfiguration>(
|
||||
"", _("Base object"), _("Base object"), "res/objeticon24.png");
|
||||
@@ -1325,17 +1321,6 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
||||
.MarkAsSimple()
|
||||
.SetRequiresBaseObjectCapability("effect");
|
||||
|
||||
obj.AddAction("SetIncludedInParentCollisionMask",
|
||||
_("Include in parent collision mask"),
|
||||
_("Include or exclude a child from its parent collision mask."),
|
||||
_("Include _PARAM0_ in parent object collision mask: _PARAM1_"),
|
||||
_("Collision"),
|
||||
"res/function32.png",
|
||||
"res/function32.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddParameter("yesorno", "Include in parent collision mask")
|
||||
.SetRelevantForCustomObjectEventsOnly();
|
||||
|
||||
extension
|
||||
.AddAction("Create",
|
||||
_("Create an object"),
|
||||
|
@@ -23,8 +23,7 @@ ExpressionMetadata::ExpressionMetadata(const gd::String& returnType_,
|
||||
shown(true),
|
||||
smallIconFilename(smallicon_),
|
||||
extensionNamespace(extensionNamespace_),
|
||||
isPrivate(false),
|
||||
relevantContext("Any") {
|
||||
isPrivate(false) {
|
||||
}
|
||||
|
||||
ExpressionMetadata& ExpressionMetadata::SetHidden() {
|
||||
|
@@ -137,7 +137,7 @@ class GD_CORE_API ExpressionMetadata {
|
||||
* to fulfill std::map requirements.
|
||||
*/
|
||||
ExpressionMetadata()
|
||||
: returnType("unknown"), shown(false), isPrivate(false), relevantContext("Any"){};
|
||||
: returnType("unknown"), shown(false), isPrivate(false){};
|
||||
|
||||
virtual ~ExpressionMetadata(){};
|
||||
|
||||
@@ -184,67 +184,6 @@ class GD_CORE_API ExpressionMetadata {
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the instruction can be used in layouts or external events.
|
||||
*/
|
||||
bool IsRelevantForLayoutEvents() const {
|
||||
return relevantContext == "Any" || relevantContext == "Layout";
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the instruction can be used in function events.
|
||||
*/
|
||||
bool IsRelevantForFunctionEvents() const {
|
||||
return relevantContext == "Any" || relevantContext == "Function";
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the instruction can be used in asynchronous function events.
|
||||
*/
|
||||
bool IsRelevantForAsynchronousFunctionEvents() const {
|
||||
return relevantContext == "Any" || relevantContext == "Function" ||
|
||||
relevantContext == "AsynchronousFunction";
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the instruction can be used in custom object events.
|
||||
*/
|
||||
bool IsRelevantForCustomObjectEvents() const {
|
||||
return relevantContext == "Any" || relevantContext == "Object";
|
||||
}
|
||||
|
||||
/**
|
||||
* Set that the instruction can be used in layouts or external events.
|
||||
*/
|
||||
ExpressionMetadata &SetRelevantForLayoutEventsOnly() {
|
||||
relevantContext = "Layout";
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set that the instruction can be used in function events.
|
||||
*/
|
||||
ExpressionMetadata &SetRelevantForFunctionEventsOnly() {
|
||||
relevantContext = "Function";
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set that the instruction can be used in asynchronous function events.
|
||||
*/
|
||||
ExpressionMetadata &SetRelevantForAsynchronousFunctionEventsOnly() {
|
||||
relevantContext = "AsynchronousFunction";
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set that the instruction can be used in custom object events.
|
||||
*/
|
||||
ExpressionMetadata &SetRelevantForCustomObjectEventsOnly() {
|
||||
relevantContext = "Object";
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* \see gd::InstructionMetadata::AddParameter
|
||||
*/
|
||||
@@ -387,7 +326,6 @@ class GD_CORE_API ExpressionMetadata {
|
||||
gd::String extensionNamespace;
|
||||
bool isPrivate;
|
||||
gd::String requiredBaseObjectCapability;
|
||||
gd::String relevantContext;
|
||||
};
|
||||
|
||||
} // namespace gd
|
||||
|
@@ -47,8 +47,7 @@ InstructionMetadata::InstructionMetadata(const gd::String& extensionNamespace_,
|
||||
usageComplexity(5),
|
||||
isPrivate(false),
|
||||
isObjectInstruction(false),
|
||||
isBehaviorInstruction(false),
|
||||
relevantContext("Any") {}
|
||||
isBehaviorInstruction(false) {}
|
||||
|
||||
InstructionMetadata& InstructionMetadata::AddParameter(
|
||||
const gd::String& type,
|
||||
|
@@ -101,67 +101,6 @@ class GD_CORE_API InstructionMetadata {
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the instruction can be used in layouts or external events.
|
||||
*/
|
||||
bool IsRelevantForLayoutEvents() const {
|
||||
return relevantContext == "Any" || relevantContext == "Layout";
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the instruction can be used in function events.
|
||||
*/
|
||||
bool IsRelevantForFunctionEvents() const {
|
||||
return relevantContext == "Any" || relevantContext == "Function";
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the instruction can be used in asynchronous function events.
|
||||
*/
|
||||
bool IsRelevantForAsynchronousFunctionEvents() const {
|
||||
return relevantContext == "Any" || relevantContext == "Function" ||
|
||||
relevantContext == "AsynchronousFunction";
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the instruction can be used in custom object events.
|
||||
*/
|
||||
bool IsRelevantForCustomObjectEvents() const {
|
||||
return relevantContext == "Any" || relevantContext == "Object";
|
||||
}
|
||||
|
||||
/**
|
||||
* Set that the instruction can be used in layouts or external events.
|
||||
*/
|
||||
InstructionMetadata &SetRelevantForLayoutEventsOnly() {
|
||||
relevantContext = "Layout";
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set that the instruction can be used in function events.
|
||||
*/
|
||||
InstructionMetadata &SetRelevantForFunctionEventsOnly() {
|
||||
relevantContext = "Function";
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set that the instruction can be used in asynchronous function events.
|
||||
*/
|
||||
InstructionMetadata &SetRelevantForAsynchronousFunctionEventsOnly() {
|
||||
relevantContext = "AsynchronousFunction";
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set that the instruction can be used in custom object events.
|
||||
*/
|
||||
InstructionMetadata &SetRelevantForCustomObjectEventsOnly() {
|
||||
relevantContext = "Object";
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the instruction is asynchronous - it will be running in the
|
||||
* background, executing the instructions following it before the frame after
|
||||
@@ -600,7 +539,6 @@ class GD_CORE_API InstructionMetadata {
|
||||
bool isObjectInstruction;
|
||||
bool isBehaviorInstruction;
|
||||
gd::String requiredBaseObjectCapability;
|
||||
gd::String relevantContext;
|
||||
};
|
||||
|
||||
} // namespace gd
|
||||
|
@@ -1,49 +0,0 @@
|
||||
/*
|
||||
* GDevelop Core
|
||||
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
|
||||
* reserved. This project is released under the MIT License.
|
||||
*/
|
||||
#include "EventBasedBehaviorBrowser.h"
|
||||
|
||||
#include "GDCore/IDE/Events/ArbitraryEventsWorker.h"
|
||||
#include "GDCore/IDE/Project/ArbitraryEventBasedBehaviorsWorker.h"
|
||||
#include "GDCore/IDE/Project/ArbitraryEventsFunctionsWorker.h"
|
||||
#include "GDCore/IDE/Project/ArbitraryObjectsWorker.h"
|
||||
#include "GDCore/IDE/Project/ArbitraryBehaviorSharedDataWorker.h"
|
||||
#include "GDCore/IDE/ProjectBrowserHelper.h"
|
||||
#include "GDCore/Project/EventsBasedBehavior.h"
|
||||
#include "GDCore/Project/Project.h"
|
||||
#include "GDCore/String.h"
|
||||
|
||||
namespace gd {
|
||||
|
||||
void EventBasedBehaviorBrowser::ExposeEvents(
|
||||
gd::Project &project, gd::ArbitraryEventsWorker &worker) const {
|
||||
gd::ProjectBrowserHelper::ExposeEventsBasedBehaviorEvents(
|
||||
project, eventsBasedBehavior, worker);
|
||||
}
|
||||
|
||||
void EventBasedBehaviorBrowser::ExposeEvents(
|
||||
gd::Project &project, gd::ArbitraryEventsWorkerWithContext &worker) const {
|
||||
gd::ProjectBrowserHelper::ExposeEventsBasedBehaviorEvents(
|
||||
project, eventsBasedBehavior, worker);
|
||||
}
|
||||
|
||||
void EventBasedBehaviorBrowser::ExposeObjects(
|
||||
gd::Project &project, gd::ArbitraryObjectsWorker &worker) const {}
|
||||
|
||||
void EventBasedBehaviorBrowser::ExposeFunctions(
|
||||
gd::Project &project, gd::ArbitraryEventsFunctionsWorker &worker) const {
|
||||
worker.Launch(eventsBasedBehavior.GetEventsFunctions());
|
||||
}
|
||||
|
||||
void EventBasedBehaviorBrowser::ExposeEventBasedBehaviors(
|
||||
gd::Project &project,
|
||||
gd::ArbitraryEventBasedBehaviorsWorker &worker) const {
|
||||
worker.Launch(eventsBasedBehavior);
|
||||
}
|
||||
|
||||
void EventBasedBehaviorBrowser::ExposeBehaviorSharedDatas(
|
||||
gd::Project &project, gd::ArbitraryBehaviorSharedDataWorker &worker) const {}
|
||||
|
||||
} // namespace gd
|
@@ -1,86 +0,0 @@
|
||||
/*
|
||||
* GDevelop Core
|
||||
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
|
||||
* reserved. This project is released under the MIT License.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "GDCore/IDE/ProjectBrowser.h"
|
||||
|
||||
namespace gd {
|
||||
class Project;
|
||||
class String;
|
||||
class EventsFunctionsExtension;
|
||||
class EventsFunction;
|
||||
class EventsBasedBehavior;
|
||||
class EventsBasedObject;
|
||||
class ArbitraryEventsWorker;
|
||||
class ArbitraryEventsWorkerWithContext;
|
||||
class ArbitraryEventsFunctionsWorker;
|
||||
class ArbitraryObjectsWorker;
|
||||
class ArbitraryEventBasedBehaviorsWorker;
|
||||
class ArbitraryBehaviorSharedDataWorker;
|
||||
} // namespace gd
|
||||
|
||||
namespace gd {
|
||||
|
||||
/**
|
||||
* \brief Expose event-based behavior contents to workers.
|
||||
*/
|
||||
class GD_CORE_API EventBasedBehaviorBrowser : public ProjectBrowser {
|
||||
public:
|
||||
EventBasedBehaviorBrowser(gd::EventsBasedBehavior &eventsBasedBehavior_)
|
||||
: eventsBasedBehavior(eventsBasedBehavior_) {}
|
||||
|
||||
/**
|
||||
* \brief Call the specified worker on all events of the event-based
|
||||
* behavior.
|
||||
*
|
||||
* This should be the preferred way to traverse all the events of an event-based behavior.
|
||||
*/
|
||||
void ExposeEvents(gd::Project &project,
|
||||
gd::ArbitraryEventsWorker &worker) const override;
|
||||
|
||||
/**
|
||||
* \brief Call the specified worker on all events of the event-based
|
||||
* behavior.
|
||||
*
|
||||
* This should be the preferred way to traverse all the events of an event-based behavior.
|
||||
*/
|
||||
void
|
||||
ExposeEvents(gd::Project &project,
|
||||
gd::ArbitraryEventsWorkerWithContext &worker) const override;
|
||||
|
||||
/**
|
||||
* \brief Call the specified worker on all functions of the event-based behavior
|
||||
*
|
||||
* This should be the preferred way to traverse all the function signatures
|
||||
* of an event-based behavior.
|
||||
*/
|
||||
void ExposeFunctions(gd::Project &project,
|
||||
gd::ArbitraryEventsFunctionsWorker &worker) const override;
|
||||
|
||||
/**
|
||||
* \brief Do nothing.
|
||||
*/
|
||||
void ExposeObjects(gd::Project &project,
|
||||
gd::ArbitraryObjectsWorker &worker) const override;
|
||||
|
||||
/**
|
||||
* \brief Call the specified worker on the event-based behavior.
|
||||
*/
|
||||
void ExposeEventBasedBehaviors(
|
||||
gd::Project &project,
|
||||
gd::ArbitraryEventBasedBehaviorsWorker &worker) const override;
|
||||
|
||||
/**
|
||||
* \brief Do nothing.
|
||||
*/
|
||||
void ExposeBehaviorSharedDatas(gd::Project &project,
|
||||
gd::ArbitraryBehaviorSharedDataWorker &worker) const override;
|
||||
|
||||
private:
|
||||
gd::EventsBasedBehavior &eventsBasedBehavior;
|
||||
};
|
||||
|
||||
} // namespace gd
|
@@ -8,10 +8,13 @@
|
||||
#define GDCORE_BEHAVIORTYPERENAMER_H
|
||||
#include <set>
|
||||
|
||||
#include "GDCore/Events/Parsers/ExpressionParser2NodeWorker.h"
|
||||
#include "GDCore/IDE/Events/ArbitraryEventsWorker.h"
|
||||
#include "GDCore/IDE/Project/ArbitraryObjectsWorker.h"
|
||||
#include "GDCore/String.h"
|
||||
|
||||
namespace gd {
|
||||
class Project;
|
||||
class Object;
|
||||
class Behavior;
|
||||
} // namespace gd
|
||||
@@ -20,15 +23,17 @@ namespace gd {
|
||||
|
||||
class GD_CORE_API BehaviorTypeRenamer : public ArbitraryObjectsWorker {
|
||||
public:
|
||||
BehaviorTypeRenamer(const gd::String& oldType_,
|
||||
const gd::String& newType_)
|
||||
: oldType(oldType_), newType(newType_){};
|
||||
BehaviorTypeRenamer(const gd::Project& project_,
|
||||
const gd::String& oldType_,
|
||||
const gd::String& newType_)
|
||||
: project(project_), oldType(oldType_), newType(newType_){};
|
||||
virtual ~BehaviorTypeRenamer();
|
||||
|
||||
private:
|
||||
void DoVisitObject(gd::Object& object) override;
|
||||
void DoVisitBehavior(gd::Behavior& behavior) override;
|
||||
|
||||
const gd::Project& project;
|
||||
gd::String oldType;
|
||||
gd::String newType;
|
||||
};
|
||||
|
@@ -8,10 +8,13 @@
|
||||
#define GDCORE_CUSTOMOBJECTTYPERENAMER_H
|
||||
#include <set>
|
||||
|
||||
#include "GDCore/Events/Parsers/ExpressionParser2NodeWorker.h"
|
||||
#include "GDCore/IDE/Events/ArbitraryEventsWorker.h"
|
||||
#include "GDCore/IDE/Project/ArbitraryObjectsWorker.h"
|
||||
#include "GDCore/String.h"
|
||||
|
||||
namespace gd {
|
||||
class Project;
|
||||
class Object;
|
||||
class Behavior;
|
||||
} // namespace gd
|
||||
@@ -20,15 +23,17 @@ namespace gd {
|
||||
|
||||
class GD_CORE_API CustomObjectTypeRenamer : public ArbitraryObjectsWorker {
|
||||
public:
|
||||
CustomObjectTypeRenamer(const gd::String& oldType_,
|
||||
CustomObjectTypeRenamer(const gd::Project& project_,
|
||||
const gd::String& oldType_,
|
||||
const gd::String& newType_)
|
||||
: oldType(oldType_), newType(newType_){};
|
||||
: project(project_), oldType(oldType_), newType(newType_){};
|
||||
virtual ~CustomObjectTypeRenamer();
|
||||
|
||||
private:
|
||||
void DoVisitObject(gd::Object& object) override;
|
||||
void DoVisitBehavior(gd::Behavior& behavior) override;
|
||||
|
||||
const gd::Project& project;
|
||||
gd::String oldType;
|
||||
gd::String newType;
|
||||
};
|
||||
|
@@ -202,7 +202,7 @@ std::set<gd::String> EventsIdentifiersFinder::FindAllIdentifierExpressions(
|
||||
std::set<gd::String> results;
|
||||
|
||||
const bool isObjectIdentifier = identifierType.find("object") == 0;
|
||||
// The object from the context is only relevant for object identifiers.
|
||||
// The object from the context is only relevent for object identifiers.
|
||||
auto& actualObjectName = isObjectIdentifier ? contextObjectName : "";
|
||||
|
||||
FindArgumentsInEventsAndDependencies(
|
||||
|
@@ -1,24 +0,0 @@
|
||||
#include "InstructionsCountEvaluator.h"
|
||||
|
||||
#include "GDCore/Events/Instruction.h"
|
||||
#include "GDCore/Extensions/PlatformExtension.h"
|
||||
#include "GDCore/IDE/ProjectBrowserHelper.h"
|
||||
|
||||
namespace gd {
|
||||
|
||||
const int InstructionsCountEvaluator::ScanProject(gd::Project &project) {
|
||||
InstructionsCountEvaluator worker(project);
|
||||
gd::ProjectBrowserHelper::ExposeProjectEventsWithoutExtensions(project,
|
||||
worker);
|
||||
return worker.instructionCount;
|
||||
};
|
||||
|
||||
// Instructions scanner
|
||||
|
||||
bool InstructionsCountEvaluator::DoVisitInstruction(
|
||||
gd::Instruction &instruction, bool isCondition) {
|
||||
instructionCount++;
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace gd
|
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
* GDevelop Core
|
||||
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
|
||||
* reserved. This project is released under the MIT License.
|
||||
*/
|
||||
|
||||
#ifndef GDCORE_INSTRUCTIONS_COUNT_EVALUATOR_H
|
||||
#define GDCORE_INSTRUCTIONS_COUNT_EVALUATOR_H
|
||||
#include <set>
|
||||
|
||||
#include "GDCore/Events/Parsers/ExpressionParser2NodeWorker.h"
|
||||
#include "GDCore/IDE/Events/ArbitraryEventsWorker.h"
|
||||
#include "GDCore/IDE/Project/ArbitraryObjectsWorker.h"
|
||||
#include "GDCore/String.h"
|
||||
|
||||
namespace gd {
|
||||
class Project;
|
||||
class Object;
|
||||
class Behavior;
|
||||
} // namespace gd
|
||||
|
||||
namespace gd {
|
||||
|
||||
/**
|
||||
* @brief Count the number of instructions in a project excluding extensions.
|
||||
*
|
||||
* This is used by the examples repository to evaluate examples size.
|
||||
*
|
||||
*/
|
||||
class GD_CORE_API InstructionsCountEvaluator : public ArbitraryEventsWorker {
|
||||
public:
|
||||
/**
|
||||
* Return the number of instructions in the project excluding extensions.
|
||||
*/
|
||||
static const int ScanProject(gd::Project &project);
|
||||
|
||||
private:
|
||||
InstructionsCountEvaluator(gd::Project &project_)
|
||||
: project(project_), instructionCount(0){};
|
||||
gd::Project &project;
|
||||
int instructionCount;
|
||||
|
||||
// Instructions Visitor
|
||||
bool DoVisitInstruction(gd::Instruction &instruction,
|
||||
bool isCondition) override;
|
||||
};
|
||||
|
||||
}; // namespace gd
|
||||
|
||||
#endif
|
@@ -4,7 +4,6 @@
|
||||
#include "GDCore/Extensions/Metadata/MetadataProvider.h"
|
||||
#include "GDCore/Extensions/Metadata/ParameterMetadataTools.h"
|
||||
#include "GDCore/Extensions/PlatformExtension.h"
|
||||
#include "GDCore/IDE/ProjectBrowserHelper.h"
|
||||
#include "GDCore/IDE/WholeProjectRefactorer.h"
|
||||
#include "GDCore/IDE/Events/ExpressionTypeFinder.h"
|
||||
#include "GDCore/Project/Behavior.h"
|
||||
@@ -15,8 +14,8 @@ namespace gd {
|
||||
|
||||
const UsedExtensionsResult UsedExtensionsFinder::ScanProject(gd::Project& project) {
|
||||
UsedExtensionsFinder worker(project);
|
||||
gd::ProjectBrowserHelper::ExposeProjectObjects(project, worker);
|
||||
gd::ProjectBrowserHelper::ExposeProjectEvents(project, worker);
|
||||
gd::WholeProjectRefactorer::ExposeProjectObjects(project, worker);
|
||||
gd::WholeProjectRefactorer::ExposeProjectEvents(project, worker);
|
||||
return worker.result;
|
||||
};
|
||||
|
||||
|
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
* GDevelop Core
|
||||
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
|
||||
* reserved. This project is released under the MIT License.
|
||||
*/
|
||||
#include "ArbitraryBehaviorSharedDataWorker.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "GDCore/Project/BehaviorsSharedData.h"
|
||||
#include "GDCore/String.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace gd {
|
||||
|
||||
ArbitraryBehaviorSharedDataWorker::~ArbitraryBehaviorSharedDataWorker() {}
|
||||
|
||||
void ArbitraryBehaviorSharedDataWorker::VisitSharedDatas(
|
||||
const std::map<gd::String, std::unique_ptr<gd::BehaviorsSharedData>>
|
||||
&sharedDatas) {
|
||||
DoVisitSharedDatas(sharedDatas);
|
||||
|
||||
for (auto &behaviorSharedDataContent : sharedDatas) {
|
||||
VisitSharedData(*behaviorSharedDataContent.second);
|
||||
}
|
||||
}
|
||||
|
||||
void ArbitraryBehaviorSharedDataWorker::VisitSharedData(
|
||||
gd::BehaviorsSharedData &sharedData) {
|
||||
DoVisitSharedData(sharedData);
|
||||
}
|
||||
|
||||
} // namespace gd
|
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
* GDevelop Core
|
||||
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
|
||||
* reserved. This project is released under the MIT License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "GDCore/String.h"
|
||||
#include "GDCore/Tools/SerializableWithNameList.h"
|
||||
|
||||
namespace gd {
|
||||
class BehaviorsSharedData;
|
||||
} // namespace gd
|
||||
|
||||
namespace gd {
|
||||
|
||||
/**
|
||||
* \brief ArbitraryBehaviorSharedDataWorker is an abstract class used to browse
|
||||
* shared data and do some work on them. It can be used to implement
|
||||
* refactoring for example.
|
||||
*
|
||||
* \ingroup IDE
|
||||
*/
|
||||
class GD_CORE_API ArbitraryBehaviorSharedDataWorker {
|
||||
public:
|
||||
ArbitraryBehaviorSharedDataWorker(){};
|
||||
virtual ~ArbitraryBehaviorSharedDataWorker();
|
||||
|
||||
/**
|
||||
* \brief Launch the worker on the specified shared data.
|
||||
*/
|
||||
void Launch(const std::map<gd::String, std::unique_ptr<gd::BehaviorsSharedData>>& sharedDatas) { VisitSharedDatas(sharedDatas); };
|
||||
|
||||
private:
|
||||
void VisitSharedDatas(const std::map<gd::String, std::unique_ptr<gd::BehaviorsSharedData>>& sharedDatas);
|
||||
void VisitSharedData(gd::BehaviorsSharedData& behavior);
|
||||
|
||||
/**
|
||||
* Called to do some work on shared data.
|
||||
*/
|
||||
virtual void DoVisitSharedDatas(const std::map<gd::String, std::unique_ptr<gd::BehaviorsSharedData>>& sharedDatas){};
|
||||
|
||||
/**
|
||||
* Called to do some work on a shared data.
|
||||
*/
|
||||
virtual void DoVisitSharedData(gd::BehaviorsSharedData& sharedData){};
|
||||
};
|
||||
|
||||
} // namespace gd
|
||||
|
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
* GDevelop Core
|
||||
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
|
||||
* reserved. This project is released under the MIT License.
|
||||
*/
|
||||
#include "ArbitraryEventBasedBehaviorsWorker.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "GDCore/Project/EventsBasedBehavior.h"
|
||||
#include "GDCore/String.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace gd {
|
||||
|
||||
ArbitraryEventBasedBehaviorsWorker::~ArbitraryEventBasedBehaviorsWorker() {}
|
||||
|
||||
void ArbitraryEventBasedBehaviorsWorker::VisitEventBasedBehaviors(gd::SerializableWithNameList<gd::EventsBasedBehavior>& behaviors) {
|
||||
DoVisitEventBasedBehaviors(behaviors);
|
||||
|
||||
for (auto&& eventsBasedBehavior : behaviors.GetInternalVector()) {
|
||||
VisitEventBasedBehavior(*eventsBasedBehavior);
|
||||
}
|
||||
}
|
||||
|
||||
void ArbitraryEventBasedBehaviorsWorker::VisitEventBasedBehavior(gd::EventsBasedBehavior& behavior) {
|
||||
DoVisitEventBasedBehavior(behavior);
|
||||
}
|
||||
|
||||
} // namespace gd
|
@@ -1,59 +0,0 @@
|
||||
/*
|
||||
* GDevelop Core
|
||||
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
|
||||
* reserved. This project is released under the MIT License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "GDCore/String.h"
|
||||
#include "GDCore/Tools/SerializableWithNameList.h"
|
||||
|
||||
namespace gd {
|
||||
class EventsBasedBehavior;
|
||||
} // namespace gd
|
||||
|
||||
namespace gd {
|
||||
|
||||
/**
|
||||
* \brief ArbitraryEventsFunctionsWorker is an abstract class used to browse
|
||||
* event-based behaviors and do some work on them. It can be used to implement
|
||||
* refactoring for example.
|
||||
*
|
||||
* \ingroup IDE
|
||||
*/
|
||||
class GD_CORE_API ArbitraryEventBasedBehaviorsWorker {
|
||||
public:
|
||||
ArbitraryEventBasedBehaviorsWorker(){};
|
||||
virtual ~ArbitraryEventBasedBehaviorsWorker();
|
||||
|
||||
/**
|
||||
* \brief Launch the worker on the specified event-based behaviors.
|
||||
*/
|
||||
void Launch(gd::SerializableWithNameList<gd::EventsBasedBehavior>& behaviors) { VisitEventBasedBehaviors(behaviors); };
|
||||
|
||||
/**
|
||||
* \brief Launch the worker on the specified event-based behavior.
|
||||
*/
|
||||
void Launch(EventsBasedBehavior& behavior) { VisitEventBasedBehavior(behavior); };
|
||||
|
||||
private:
|
||||
void VisitEventBasedBehaviors(gd::SerializableWithNameList<gd::EventsBasedBehavior>& behaviors);
|
||||
void VisitEventBasedBehavior(gd::EventsBasedBehavior& behavior);
|
||||
|
||||
/**
|
||||
* Called to do some work on event-based behaviors.
|
||||
*/
|
||||
virtual void DoVisitEventBasedBehaviors(gd::SerializableWithNameList<gd::EventsBasedBehavior>& behaviors){};
|
||||
|
||||
/**
|
||||
* Called to do some work on an event-based behavior.
|
||||
*/
|
||||
virtual void DoVisitEventBasedBehavior(gd::EventsBasedBehavior& behavior){};
|
||||
};
|
||||
|
||||
} // namespace gd
|
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
* GDevelop Core
|
||||
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
|
||||
* reserved. This project is released under the MIT License.
|
||||
*/
|
||||
#include "ArbitraryEventsFunctionsWorker.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "GDCore/Project/EventsFunction.h"
|
||||
#include "GDCore/Project/EventsFunctionsContainer.h"
|
||||
#include "GDCore/Extensions/Metadata/ParameterMetadata.h"
|
||||
#include "GDCore/String.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace gd {
|
||||
|
||||
ArbitraryEventsFunctionsWorker::~ArbitraryEventsFunctionsWorker() {}
|
||||
|
||||
void ArbitraryEventsFunctionsWorker::VisitEventsFunctionContainer(
|
||||
gd::EventsFunctionsContainer& functions) {
|
||||
DoVisitEventsFunctionsContainer(functions);
|
||||
|
||||
for (auto&& function : functions.GetInternalVector()) {
|
||||
VisitEventsFunction(*function);
|
||||
}
|
||||
}
|
||||
|
||||
void ArbitraryEventsFunctionsWorker::VisitEventsFunction(gd::EventsFunction& eventsFunction) {
|
||||
DoVisitEventsFunction(eventsFunction);
|
||||
}
|
||||
|
||||
} // namespace gd
|
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
* GDevelop Core
|
||||
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
|
||||
* reserved. This project is released under the MIT License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "GDCore/String.h"
|
||||
|
||||
namespace gd {
|
||||
class EventsFunction;
|
||||
class EventsFunctionsContainer;
|
||||
class ParameterMetadata;
|
||||
} // namespace gd
|
||||
|
||||
namespace gd {
|
||||
|
||||
/**
|
||||
* \brief ArbitraryEventsFunctionsWorker is an abstract class used to browse
|
||||
* functions signatures and do some work on them. It can be used to implement
|
||||
* refactoring for example.
|
||||
*
|
||||
* \ingroup IDE
|
||||
*/
|
||||
class GD_CORE_API ArbitraryEventsFunctionsWorker {
|
||||
public:
|
||||
ArbitraryEventsFunctionsWorker(){};
|
||||
virtual ~ArbitraryEventsFunctionsWorker();
|
||||
|
||||
/**
|
||||
* \brief Launch the worker on the specified function container.
|
||||
*/
|
||||
void Launch(gd::EventsFunctionsContainer& functions) { VisitEventsFunctionContainer(functions); };
|
||||
|
||||
private:
|
||||
void VisitEventsFunctionContainer(gd::EventsFunctionsContainer& functions);
|
||||
void VisitEventsFunction(gd::EventsFunction& eventsFunction);
|
||||
|
||||
/**
|
||||
* Called to do some work on an function container.
|
||||
*/
|
||||
virtual void DoVisitEventsFunctionsContainer(gd::EventsFunctionsContainer& functions){};
|
||||
|
||||
/**
|
||||
* Called to do some work on a function.
|
||||
*/
|
||||
virtual void DoVisitEventsFunction(gd::EventsFunction& eventsFunction){};
|
||||
};
|
||||
|
||||
} // namespace gd
|
@@ -33,7 +33,7 @@ class GD_CORE_API ArbitraryObjectsWorker {
|
||||
virtual ~ArbitraryObjectsWorker();
|
||||
|
||||
/**
|
||||
* \brief Launch the worker on the specified object container.
|
||||
* \brief Launch the worker on the specified events list.
|
||||
*/
|
||||
void Launch(gd::ObjectsContainer& objects) { VisitObjectContainer(objects); };
|
||||
|
||||
|
@@ -1,25 +0,0 @@
|
||||
/*
|
||||
* GDevelop Core
|
||||
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
|
||||
* reserved. This project is released under the MIT License.
|
||||
*/
|
||||
#include "BehaviorObjectTypeRenamer.h"
|
||||
|
||||
#include "GDCore/Project/EventsBasedBehavior.h"
|
||||
#include "GDCore/String.h"
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
namespace gd {
|
||||
|
||||
void BehaviorObjectTypeRenamer::DoVisitEventBasedBehavior(
|
||||
gd::EventsBasedBehavior &eventsBasedBehavior) {
|
||||
if (eventsBasedBehavior.GetObjectType() == oldObjectType) {
|
||||
eventsBasedBehavior.SetObjectType(newObjectType);
|
||||
}
|
||||
}
|
||||
|
||||
BehaviorObjectTypeRenamer::~BehaviorObjectTypeRenamer() {}
|
||||
|
||||
} // namespace gd
|
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
* GDevelop Core
|
||||
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
|
||||
* reserved. This project is released under the MIT License.
|
||||
*/
|
||||
#ifndef GDCORE_BEHAVIOROBJECTTYPERENAMER_H
|
||||
#define GDCORE_BEHAVIOROBJECTTYPERENAMER_H
|
||||
|
||||
#include "GDCore/IDE/Project/ArbitraryEventBasedBehaviorsWorker.h"
|
||||
|
||||
#include "GDCore/String.h"
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
namespace gd {
|
||||
class BaseEvent;
|
||||
class Project;
|
||||
class EventsList;
|
||||
} // namespace gd
|
||||
|
||||
namespace gd {
|
||||
|
||||
/**
|
||||
* \brief Rename the object type in event-based behaviors.
|
||||
*
|
||||
* \ingroup IDE
|
||||
*/
|
||||
class GD_CORE_API BehaviorObjectTypeRenamer
|
||||
: public ArbitraryEventBasedBehaviorsWorker {
|
||||
public:
|
||||
BehaviorObjectTypeRenamer(const gd::String &oldObjectType_,
|
||||
const gd::String &newObjectType_)
|
||||
: oldObjectType(oldObjectType_), newObjectType(newObjectType_){};
|
||||
virtual ~BehaviorObjectTypeRenamer();
|
||||
|
||||
private:
|
||||
void DoVisitEventBasedBehavior(gd::EventsBasedBehavior &behavior) override;
|
||||
|
||||
gd::String oldObjectType;
|
||||
gd::String newObjectType;
|
||||
};
|
||||
|
||||
} // namespace gd
|
||||
|
||||
#endif // GDCORE_BEHAVIOROBJECTTYPERENAMER_H
|
@@ -1,24 +0,0 @@
|
||||
/*
|
||||
* GDevelop Core
|
||||
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
|
||||
* reserved. This project is released under the MIT License.
|
||||
*/
|
||||
#include "GDCore/IDE/Project/BehaviorsSharedDataBehaviorTypeRenamer.h"
|
||||
#include "GDCore/Project/BehaviorsSharedData.h"
|
||||
#include "GDCore/String.h"
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
namespace gd {
|
||||
|
||||
void BehaviorsSharedDataBehaviorTypeRenamer::DoVisitSharedData(
|
||||
gd::BehaviorsSharedData &sharedData) {
|
||||
if (sharedData.GetTypeName() == oldBehaviorType) {
|
||||
sharedData.SetTypeName(newBehaviorType);
|
||||
}
|
||||
}
|
||||
|
||||
BehaviorsSharedDataBehaviorTypeRenamer::~BehaviorsSharedDataBehaviorTypeRenamer() {}
|
||||
|
||||
} // namespace gd
|
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
* GDevelop Core
|
||||
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
|
||||
* reserved. This project is released under the MIT License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include "GDCore/IDE/Project/ArbitraryBehaviorSharedDataWorker.h"
|
||||
#include "GDCore/String.h"
|
||||
|
||||
namespace gd {
|
||||
class BaseEvent;
|
||||
class Project;
|
||||
class EventsList;
|
||||
} // namespace gd
|
||||
|
||||
namespace gd {
|
||||
|
||||
/**
|
||||
* \brief Rename the behavior type of shared data.
|
||||
*
|
||||
* \ingroup IDE
|
||||
*/
|
||||
class GD_CORE_API BehaviorsSharedDataBehaviorTypeRenamer : public ArbitraryBehaviorSharedDataWorker {
|
||||
public:
|
||||
BehaviorsSharedDataBehaviorTypeRenamer(const gd::String& oldBehaviorType_,
|
||||
const gd::String& newBehaviorType_)
|
||||
: oldBehaviorType(oldBehaviorType_), newBehaviorType(newBehaviorType_){};
|
||||
virtual ~BehaviorsSharedDataBehaviorTypeRenamer();
|
||||
|
||||
private:
|
||||
void DoVisitSharedData(gd::BehaviorsSharedData& behavior) override;
|
||||
|
||||
gd::String oldBehaviorType;
|
||||
gd::String newBehaviorType;
|
||||
};
|
||||
|
||||
} // namespace gd
|
@@ -1,28 +0,0 @@
|
||||
/*
|
||||
* GDevelop Core
|
||||
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
|
||||
* reserved. This project is released under the MIT License.
|
||||
*/
|
||||
#include "FunctionParameterBehaviorTypeRenamer.h"
|
||||
|
||||
#include "GDCore/Project/EventsFunction.h"
|
||||
#include "GDCore/String.h"
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
namespace gd {
|
||||
|
||||
void FunctionParameterBehaviorTypeRenamer::DoVisitEventsFunction(
|
||||
gd::EventsFunction &eventsFunction) {
|
||||
for (auto &¶meter : eventsFunction.GetParameters()) {
|
||||
if (gd::ParameterMetadata::IsBehavior(parameter.GetType()) &&
|
||||
parameter.GetExtraInfo() == oldBehaviorType) {
|
||||
parameter.SetExtraInfo(newBehaviorType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FunctionParameterBehaviorTypeRenamer::~FunctionParameterBehaviorTypeRenamer() {}
|
||||
|
||||
} // namespace gd
|
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
* GDevelop Core
|
||||
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
|
||||
* reserved. This project is released under the MIT License.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "GDCore/IDE/Project/ArbitraryEventsFunctionsWorker.h"
|
||||
#include "GDCore/String.h"
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
namespace gd {
|
||||
class BaseEvent;
|
||||
class Project;
|
||||
class EventsList;
|
||||
} // namespace gd
|
||||
|
||||
namespace gd {
|
||||
|
||||
/**
|
||||
* \brief Rename the type of behavior parameters in functions.
|
||||
*
|
||||
* \ingroup IDE
|
||||
*/
|
||||
class GD_CORE_API FunctionParameterBehaviorTypeRenamer
|
||||
: public ArbitraryEventsFunctionsWorker {
|
||||
public:
|
||||
FunctionParameterBehaviorTypeRenamer(const gd::String &oldBehaviorType_,
|
||||
const gd::String &newBehaviorType_)
|
||||
: oldBehaviorType(oldBehaviorType_), newBehaviorType(newBehaviorType_){};
|
||||
virtual ~FunctionParameterBehaviorTypeRenamer();
|
||||
|
||||
private:
|
||||
virtual void DoVisitEventsFunction(gd::EventsFunction &eventsFunction) override;
|
||||
|
||||
gd::String oldBehaviorType;
|
||||
gd::String newBehaviorType;
|
||||
};
|
||||
|
||||
} // namespace gd
|
@@ -1,28 +0,0 @@
|
||||
/*
|
||||
* GDevelop Core
|
||||
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
|
||||
* reserved. This project is released under the MIT License.
|
||||
*/
|
||||
#include "FunctionParameterObjectTypeRenamer.h"
|
||||
|
||||
#include "GDCore/Project/EventsFunction.h"
|
||||
#include "GDCore/String.h"
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
namespace gd {
|
||||
|
||||
void FunctionParameterObjectTypeRenamer::DoVisitEventsFunction(
|
||||
gd::EventsFunction &eventsFunction) {
|
||||
for (auto &¶meter : eventsFunction.GetParameters()) {
|
||||
if (gd::ParameterMetadata::IsObject(parameter.GetType()) &&
|
||||
parameter.GetExtraInfo() == oldObjectType) {
|
||||
parameter.SetExtraInfo(newObjectType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FunctionParameterObjectTypeRenamer::~FunctionParameterObjectTypeRenamer() {}
|
||||
|
||||
} // namespace gd
|
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
* GDevelop Core
|
||||
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
|
||||
* reserved. This project is released under the MIT License.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "GDCore/IDE/Project/ArbitraryEventsFunctionsWorker.h"
|
||||
#include "GDCore/String.h"
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
namespace gd {
|
||||
class BaseEvent;
|
||||
class Project;
|
||||
class EventsList;
|
||||
} // namespace gd
|
||||
|
||||
namespace gd {
|
||||
|
||||
/**
|
||||
* \brief Rename the type of object parameters in functions.
|
||||
*
|
||||
* \ingroup IDE
|
||||
*/
|
||||
class GD_CORE_API FunctionParameterObjectTypeRenamer
|
||||
: public ArbitraryEventsFunctionsWorker {
|
||||
public:
|
||||
FunctionParameterObjectTypeRenamer(const gd::String &oldObjectType_,
|
||||
const gd::String &newObjectType_)
|
||||
: oldObjectType(oldObjectType_), newObjectType(newObjectType_){};
|
||||
virtual ~FunctionParameterObjectTypeRenamer();
|
||||
|
||||
private:
|
||||
virtual void DoVisitEventsFunction(gd::EventsFunction &eventsFunction) override;
|
||||
|
||||
gd::String oldObjectType;
|
||||
gd::String newObjectType;
|
||||
};
|
||||
|
||||
} // namespace gd
|
@@ -1,35 +0,0 @@
|
||||
/*
|
||||
* GDevelop Core
|
||||
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
|
||||
* reserved. This project is released under the MIT License.
|
||||
*/
|
||||
#include "GDCore/IDE/Project/RequiredBehaviorRenamer.h"
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include "GDCore/Project/EventsBasedBehavior.h"
|
||||
#include "GDCore/String.h"
|
||||
|
||||
namespace gd {
|
||||
|
||||
void RequiredBehaviorRenamer::DoVisitEventBasedBehavior(gd::EventsBasedBehavior& eventsBasedBehavior) {
|
||||
for (size_t i = 0;
|
||||
i < eventsBasedBehavior.GetPropertyDescriptors().GetCount();
|
||||
i++) {
|
||||
NamedPropertyDescriptor& propertyDescriptor =
|
||||
eventsBasedBehavior.GetPropertyDescriptors().Get(i);
|
||||
|
||||
std::vector<gd::String>& extraInfo = propertyDescriptor.GetExtraInfo();
|
||||
if (propertyDescriptor.GetType() == "Behavior" &&
|
||||
extraInfo.size() > 0) {
|
||||
const gd::String& requiredBehaviorType = extraInfo[0];
|
||||
if (requiredBehaviorType == oldBehaviorType) {
|
||||
extraInfo[0] = newBehaviorType;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RequiredBehaviorRenamer::~RequiredBehaviorRenamer() {}
|
||||
|
||||
} // namespace gd
|
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
* GDevelop Core
|
||||
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
|
||||
* reserved. This project is released under the MIT License.
|
||||
*/
|
||||
#ifndef GDCORE_REQUIREDBEHAVIORRENAMER_H
|
||||
#define GDCORE_REQUIREDBEHAVIORRENAMER_H
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include "GDCore/IDE/Project/ArbitraryEventBasedBehaviorsWorker.h"
|
||||
#include "GDCore/String.h"
|
||||
namespace gd {
|
||||
class BaseEvent;
|
||||
class Project;
|
||||
class EventsList;
|
||||
} // namespace gd
|
||||
|
||||
namespace gd {
|
||||
|
||||
/**
|
||||
* \brief Rename the type of required behavior in event-based behaviors.
|
||||
*
|
||||
* \ingroup IDE
|
||||
*/
|
||||
class GD_CORE_API RequiredBehaviorRenamer : public ArbitraryEventBasedBehaviorsWorker {
|
||||
public:
|
||||
RequiredBehaviorRenamer(const gd::String& oldBehaviorType_,
|
||||
const gd::String& newBehaviorType_)
|
||||
: oldBehaviorType(oldBehaviorType_), newBehaviorType(newBehaviorType_){};
|
||||
virtual ~RequiredBehaviorRenamer();
|
||||
|
||||
private:
|
||||
void DoVisitEventBasedBehavior(gd::EventsBasedBehavior& behavior) override;
|
||||
|
||||
gd::String oldBehaviorType;
|
||||
gd::String newBehaviorType;
|
||||
};
|
||||
|
||||
} // namespace gd
|
||||
|
||||
#endif // GDCORE_REQUIREDBEHAVIORRENAMER_H
|
@@ -4,7 +4,9 @@
|
||||
* reserved. This project is released under the MIT License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#if defined(GD_IDE_ONLY)
|
||||
#ifndef GDCORE_RESOURCESRENAMER_H
|
||||
#define GDCORE_RESOURCESRENAMER_H
|
||||
|
||||
#include <set>
|
||||
#include <vector>
|
||||
@@ -70,3 +72,6 @@ class ResourcesRenamer : public gd::ArbitraryResourceWorker {
|
||||
};
|
||||
|
||||
} // namespace gd
|
||||
|
||||
#endif // GDCORE_RESOURCESRENAMER_H
|
||||
#endif
|
||||
|
@@ -1,89 +0,0 @@
|
||||
/*
|
||||
* GDevelop Core
|
||||
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
|
||||
* reserved. This project is released under the MIT License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace gd {
|
||||
class Project;
|
||||
class String;
|
||||
class EventsFunctionsExtension;
|
||||
class EventsFunction;
|
||||
class EventsBasedBehavior;
|
||||
class EventsBasedObject;
|
||||
class ArbitraryEventsWorker;
|
||||
class ArbitraryEventsWorkerWithContext;
|
||||
class ArbitraryEventsFunctionsWorker;
|
||||
class ArbitraryObjectsWorker;
|
||||
class ArbitraryEventBasedBehaviorsWorker;
|
||||
class ArbitraryBehaviorSharedDataWorker;
|
||||
} // namespace gd
|
||||
|
||||
namespace gd {
|
||||
|
||||
/**
|
||||
* \brief Expose a subset of the project to workers.
|
||||
*/
|
||||
class GD_CORE_API ProjectBrowser {
|
||||
public:
|
||||
/**
|
||||
* \brief Call the specified worker on all events of a project subset.
|
||||
*
|
||||
* This should be the preferred way to traverse events of a project.
|
||||
*/
|
||||
virtual void ExposeEvents(gd::Project &project,
|
||||
gd::ArbitraryEventsWorker &worker) const = 0;
|
||||
/**
|
||||
* \brief Call the specified worker on all events of a project subset.
|
||||
*
|
||||
* This should be the preferred way to traverse events of a project.
|
||||
*/
|
||||
virtual void
|
||||
ExposeEvents(gd::Project &project,
|
||||
gd::ArbitraryEventsWorkerWithContext &worker) const = 0;
|
||||
|
||||
/**
|
||||
* \brief Call the specified worker on all ObjectContainer of a project subset
|
||||
*
|
||||
* This should be the preferred way to traverse all the objects of a project.
|
||||
*/
|
||||
virtual void ExposeObjects(gd::Project &project,
|
||||
gd::ArbitraryObjectsWorker &worker) const = 0;
|
||||
|
||||
/**
|
||||
* \brief Call the specified worker on all FunctionsContainer of a project
|
||||
* subset.
|
||||
*
|
||||
* This should be the preferred way to traverse all the function signatures
|
||||
* of a project.
|
||||
*/
|
||||
virtual void ExposeFunctions(gd::Project &project,
|
||||
gd::ArbitraryEventsFunctionsWorker &worker) const = 0;
|
||||
|
||||
/**
|
||||
* \brief Call the specified worker on all EventBasedBehavior of a project
|
||||
* subset.
|
||||
*
|
||||
* This should be the preferred way to traverse all the event-based behavior
|
||||
* of a project.
|
||||
*/
|
||||
virtual void ExposeEventBasedBehaviors(
|
||||
gd::Project &project,
|
||||
gd::ArbitraryEventBasedBehaviorsWorker &worker) const = 0;
|
||||
|
||||
/**
|
||||
* \brief Call the specified worker on all SharedData of a project subset.
|
||||
*
|
||||
* This should be the preferred way to traverse all the shared data
|
||||
* of a project.
|
||||
*/
|
||||
virtual void
|
||||
ExposeBehaviorSharedDatas(gd::Project &project,
|
||||
gd::ArbitraryBehaviorSharedDataWorker &worker) const = 0;
|
||||
|
||||
virtual ~ProjectBrowser(){};
|
||||
};
|
||||
|
||||
} // namespace gd
|
@@ -1,224 +0,0 @@
|
||||
/*
|
||||
* GDevelop Core
|
||||
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
|
||||
* reserved. This project is released under the MIT License.
|
||||
*/
|
||||
#include "ProjectBrowserHelper.h"
|
||||
|
||||
#include "GDCore/IDE/Events/ArbitraryEventsWorker.h"
|
||||
#include "GDCore/IDE/EventsFunctionTools.h"
|
||||
#include "GDCore/IDE/Project/ArbitraryEventBasedBehaviorsWorker.h"
|
||||
#include "GDCore/IDE/Project/ArbitraryEventsFunctionsWorker.h"
|
||||
#include "GDCore/IDE/Project/ArbitraryObjectsWorker.h"
|
||||
#include "GDCore/IDE/Project/ArbitraryBehaviorSharedDataWorker.h"
|
||||
#include "GDCore/Project/EventsBasedBehavior.h"
|
||||
#include "GDCore/Project/EventsBasedObject.h"
|
||||
#include "GDCore/Project/EventsFunctionsExtension.h"
|
||||
#include "GDCore/Project/ExternalEvents.h"
|
||||
#include "GDCore/Project/Layout.h"
|
||||
#include "GDCore/Project/Project.h"
|
||||
#include "GDCore/String.h"
|
||||
|
||||
namespace gd {
|
||||
|
||||
void ProjectBrowserHelper::ExposeProjectEvents(
|
||||
gd::Project &project, gd::ArbitraryEventsWorker &worker) {
|
||||
// See also gd::Project::ExposeResources for a method that traverses the whole
|
||||
// project (this time for resources).
|
||||
|
||||
ExposeProjectEventsWithoutExtensions(project, worker);
|
||||
|
||||
// Add events based extensions
|
||||
for (std::size_t e = 0; e < project.GetEventsFunctionsExtensionsCount();
|
||||
e++) {
|
||||
// Add (free) events functions
|
||||
auto &eventsFunctionsExtension = project.GetEventsFunctionsExtension(e);
|
||||
for (auto &&eventsFunction : eventsFunctionsExtension.GetInternalVector()) {
|
||||
worker.Launch(eventsFunction->GetEvents());
|
||||
}
|
||||
|
||||
// Add (behavior) events functions
|
||||
for (auto &&eventsBasedBehavior :
|
||||
eventsFunctionsExtension.GetEventsBasedBehaviors()
|
||||
.GetInternalVector()) {
|
||||
ExposeEventsBasedBehaviorEvents(project, *eventsBasedBehavior, worker);
|
||||
}
|
||||
|
||||
// Add (object) events functions
|
||||
for (auto &&eventsBasedObject :
|
||||
eventsFunctionsExtension.GetEventsBasedObjects().GetInternalVector()) {
|
||||
auto &objectEventsFunctions = eventsBasedObject->GetEventsFunctions();
|
||||
for (auto &&eventsFunction : objectEventsFunctions.GetInternalVector()) {
|
||||
worker.Launch(eventsFunction->GetEvents());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ProjectBrowserHelper::ExposeProjectEventsWithoutExtensions(
|
||||
gd::Project& project, gd::ArbitraryEventsWorker& worker) {
|
||||
// Add layouts events
|
||||
for (std::size_t s = 0; s < project.GetLayoutsCount(); s++) {
|
||||
worker.Launch(project.GetLayout(s).GetEvents());
|
||||
}
|
||||
// Add external events events
|
||||
for (std::size_t s = 0; s < project.GetExternalEventsCount(); s++) {
|
||||
worker.Launch(project.GetExternalEvents(s).GetEvents());
|
||||
}
|
||||
}
|
||||
|
||||
void ProjectBrowserHelper::ExposeProjectEvents(
|
||||
gd::Project &project, gd::ArbitraryEventsWorkerWithContext &worker) {
|
||||
// See also gd::Project::ExposeResources for a method that traverse the whole
|
||||
// project (this time for resources) and ExposeProjectEffects (this time for
|
||||
// effects).
|
||||
|
||||
// Add layouts events
|
||||
for (std::size_t s = 0; s < project.GetLayoutsCount(); s++) {
|
||||
auto &layout = project.GetLayout(s);
|
||||
worker.Launch(layout.GetEvents(), project, layout);
|
||||
}
|
||||
// Add external events events
|
||||
for (std::size_t s = 0; s < project.GetExternalEventsCount(); s++) {
|
||||
const auto &externalEvents = project.GetExternalEvents(s);
|
||||
const gd::String &associatedLayout = externalEvents.GetAssociatedLayout();
|
||||
if (project.HasLayoutNamed(associatedLayout)) {
|
||||
worker.Launch(project.GetExternalEvents(s).GetEvents(), project,
|
||||
project.GetLayout(associatedLayout));
|
||||
}
|
||||
}
|
||||
// Add events based extensions
|
||||
for (std::size_t e = 0; e < project.GetEventsFunctionsExtensionsCount();
|
||||
e++) {
|
||||
// Add (free) events functions
|
||||
auto &eventsFunctionsExtension = project.GetEventsFunctionsExtension(e);
|
||||
for (auto &&eventsFunction : eventsFunctionsExtension.GetInternalVector()) {
|
||||
gd::ObjectsContainer globalObjectsAndGroups;
|
||||
gd::ObjectsContainer objectsAndGroups;
|
||||
gd::EventsFunctionTools::FreeEventsFunctionToObjectsContainer(
|
||||
project, eventsFunctionsExtension, *eventsFunction,
|
||||
globalObjectsAndGroups, objectsAndGroups);
|
||||
|
||||
worker.Launch(eventsFunction->GetEvents(), globalObjectsAndGroups,
|
||||
objectsAndGroups);
|
||||
}
|
||||
|
||||
// Add (behavior) events functions
|
||||
for (auto &&eventsBasedBehavior :
|
||||
eventsFunctionsExtension.GetEventsBasedBehaviors()
|
||||
.GetInternalVector()) {
|
||||
ExposeEventsBasedBehaviorEvents(project, *eventsBasedBehavior, worker);
|
||||
}
|
||||
|
||||
// Add (object) events functions
|
||||
for (auto &&eventsBasedObject :
|
||||
eventsFunctionsExtension.GetEventsBasedObjects().GetInternalVector()) {
|
||||
ExposeEventsBasedObjectEvents(project, *eventsBasedObject, worker);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ProjectBrowserHelper::ExposeEventsBasedBehaviorEvents(
|
||||
gd::Project &project, const gd::EventsBasedBehavior &eventsBasedBehavior,
|
||||
gd::ArbitraryEventsWorker &worker) {
|
||||
auto &behaviorEventsFunctions = eventsBasedBehavior.GetEventsFunctions();
|
||||
for (auto &&eventsFunction : behaviorEventsFunctions.GetInternalVector()) {
|
||||
worker.Launch(eventsFunction->GetEvents());
|
||||
}
|
||||
}
|
||||
|
||||
void ProjectBrowserHelper::ExposeEventsBasedBehaviorEvents(
|
||||
gd::Project &project, const gd::EventsBasedBehavior &eventsBasedBehavior,
|
||||
gd::ArbitraryEventsWorkerWithContext &worker) {
|
||||
auto &behaviorEventsFunctions = eventsBasedBehavior.GetEventsFunctions();
|
||||
for (auto &&eventsFunction : behaviorEventsFunctions.GetInternalVector()) {
|
||||
gd::ObjectsContainer globalObjectsAndGroups;
|
||||
gd::ObjectsContainer objectsAndGroups;
|
||||
gd::EventsFunctionTools::BehaviorEventsFunctionToObjectsContainer(
|
||||
project, eventsBasedBehavior, *eventsFunction, globalObjectsAndGroups,
|
||||
objectsAndGroups);
|
||||
|
||||
worker.Launch(eventsFunction->GetEvents(), globalObjectsAndGroups,
|
||||
objectsAndGroups);
|
||||
}
|
||||
}
|
||||
|
||||
void ProjectBrowserHelper::ExposeEventsBasedObjectEvents(
|
||||
gd::Project &project, const gd::EventsBasedObject &eventsBasedObject,
|
||||
gd::ArbitraryEventsWorkerWithContext &worker) {
|
||||
auto &objectEventsFunctions = eventsBasedObject.GetEventsFunctions();
|
||||
for (auto &&eventsFunction : objectEventsFunctions.GetInternalVector()) {
|
||||
gd::ObjectsContainer globalObjectsAndGroups;
|
||||
gd::ObjectsContainer objectsAndGroups;
|
||||
gd::EventsFunctionTools::ObjectEventsFunctionToObjectsContainer(
|
||||
project, eventsBasedObject, *eventsFunction, globalObjectsAndGroups,
|
||||
objectsAndGroups);
|
||||
|
||||
worker.Launch(eventsFunction->GetEvents(), globalObjectsAndGroups,
|
||||
objectsAndGroups);
|
||||
}
|
||||
}
|
||||
|
||||
void ProjectBrowserHelper::ExposeProjectObjects(
|
||||
gd::Project &project, gd::ArbitraryObjectsWorker &worker) {
|
||||
|
||||
// Global objects
|
||||
worker.Launch(project);
|
||||
|
||||
// Layers objects
|
||||
for (size_t i = 0; i < project.GetLayoutsCount(); i++) {
|
||||
worker.Launch(project.GetLayout(i));
|
||||
}
|
||||
|
||||
// Event based objects children
|
||||
for (std::size_t e = 0; e < project.GetEventsFunctionsExtensionsCount();
|
||||
e++) {
|
||||
auto &eventsFunctionsExtension = project.GetEventsFunctionsExtension(e);
|
||||
|
||||
for (auto &&eventsBasedObjectUniquePtr :
|
||||
eventsFunctionsExtension.GetEventsBasedObjects().GetInternalVector()) {
|
||||
auto eventsBasedObject = eventsBasedObjectUniquePtr.get();
|
||||
worker.Launch(*eventsBasedObject);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
void ProjectBrowserHelper::ExposeProjectFunctions(
|
||||
gd::Project &project, gd::ArbitraryEventsFunctionsWorker &worker) {
|
||||
|
||||
for (std::size_t e = 0; e < project.GetEventsFunctionsExtensionsCount();
|
||||
e++) {
|
||||
auto &eventsFunctionsExtension = project.GetEventsFunctionsExtension(e);
|
||||
worker.Launch(eventsFunctionsExtension);
|
||||
|
||||
for (auto &&eventsBasedBehavior :
|
||||
eventsFunctionsExtension.GetEventsBasedBehaviors()
|
||||
.GetInternalVector()) {
|
||||
worker.Launch(eventsBasedBehavior->GetEventsFunctions());
|
||||
}
|
||||
|
||||
for (auto &&eventsBasedObject :
|
||||
eventsFunctionsExtension.GetEventsBasedObjects().GetInternalVector()) {
|
||||
worker.Launch(eventsBasedObject->GetEventsFunctions());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
void ProjectBrowserHelper::ExposeProjectEventBasedBehaviors(
|
||||
gd::Project &project, gd::ArbitraryEventBasedBehaviorsWorker &worker) {
|
||||
for (std::size_t e = 0; e < project.GetEventsFunctionsExtensionsCount();
|
||||
e++) {
|
||||
auto &eventsFunctionsExtension = project.GetEventsFunctionsExtension(e);
|
||||
worker.Launch(eventsFunctionsExtension.GetEventsBasedBehaviors());
|
||||
}
|
||||
}
|
||||
|
||||
void ProjectBrowserHelper::ExposeProjectSharedDatas(
|
||||
gd::Project &project, gd::ArbitraryBehaviorSharedDataWorker &worker) {
|
||||
for (std::size_t i = 0; i < project.GetLayoutsCount(); ++i) {
|
||||
gd::Layout &layout = project.GetLayout(i);
|
||||
worker.Launch(layout.GetAllBehaviorSharedData());
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace gd
|
@@ -1,130 +0,0 @@
|
||||
/*
|
||||
* GDevelop Core
|
||||
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
|
||||
* reserved. This project is released under the MIT License.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
namespace gd {
|
||||
class Project;
|
||||
class String;
|
||||
class EventsFunctionsExtension;
|
||||
class EventsFunction;
|
||||
class EventsBasedBehavior;
|
||||
class EventsBasedObject;
|
||||
class ArbitraryEventsWorker;
|
||||
class ArbitraryEventsWorkerWithContext;
|
||||
class ArbitraryEventsFunctionsWorker;
|
||||
class ArbitraryObjectsWorker;
|
||||
class ArbitraryEventBasedBehaviorsWorker;
|
||||
class ArbitraryBehaviorSharedDataWorker;
|
||||
} // namespace gd
|
||||
|
||||
namespace gd {
|
||||
|
||||
/**
|
||||
* \brief Expose a subset of the project to workers.
|
||||
*/
|
||||
class GD_CORE_API ProjectBrowserHelper {
|
||||
public:
|
||||
/**
|
||||
* \brief Call the specified worker on all events of the project (layout,
|
||||
* external events, events functions...)
|
||||
*
|
||||
* This should be the preferred way to traverse all the events of a project.
|
||||
*/
|
||||
static void ExposeProjectEvents(gd::Project &project,
|
||||
gd::ArbitraryEventsWorker &worker);
|
||||
|
||||
/**
|
||||
* \brief Call the specified worker on all events of the project (layout,
|
||||
* external events, events functions...)
|
||||
*
|
||||
* This should be the preferred way to traverse all the events of a project.
|
||||
*/
|
||||
static void ExposeProjectEvents(gd::Project &project,
|
||||
gd::ArbitraryEventsWorkerWithContext &worker);
|
||||
|
||||
/**
|
||||
* \brief Call the specified worker on all events of the project (layout and
|
||||
* external events) but not events from extensions.
|
||||
*
|
||||
* Only use this for stats.
|
||||
*/
|
||||
static void
|
||||
ExposeProjectEventsWithoutExtensions(gd::Project &project,
|
||||
gd::ArbitraryEventsWorker &worker);
|
||||
|
||||
/**
|
||||
* \brief Call the specified worker on all events of the event-based
|
||||
* behavior
|
||||
*
|
||||
* This should be the preferred way to traverse all the events of an events
|
||||
* based behavior.
|
||||
*/
|
||||
static void ExposeEventsBasedBehaviorEvents(
|
||||
gd::Project &project, const gd::EventsBasedBehavior &eventsBasedBehavior,
|
||||
gd::ArbitraryEventsWorker &worker);
|
||||
|
||||
/**
|
||||
* \brief Call the specified worker on all events of the event-based
|
||||
* behavior.
|
||||
*
|
||||
* This should be the preferred way to traverse all the events of an
|
||||
* event-based behavior.
|
||||
*/
|
||||
static void ExposeEventsBasedBehaviorEvents(
|
||||
gd::Project &project, const gd::EventsBasedBehavior &eventsBasedBehavior,
|
||||
gd::ArbitraryEventsWorkerWithContext &worker);
|
||||
|
||||
/**
|
||||
* \brief Call the specified worker on all events of the event-based
|
||||
* behavior.
|
||||
*
|
||||
* This should be the preferred way to traverse all the events of an
|
||||
* event-based behavior.
|
||||
*/
|
||||
static void
|
||||
ExposeEventsBasedObjectEvents(gd::Project &project,
|
||||
const gd::EventsBasedObject &eventsBasedObject,
|
||||
gd::ArbitraryEventsWorkerWithContext &worker);
|
||||
|
||||
/**
|
||||
* \brief Call the specified worker on all ObjectContainers of the project
|
||||
* (global, layouts...)
|
||||
*
|
||||
* This should be the preferred way to traverse all the objects of a project.
|
||||
*/
|
||||
static void ExposeProjectObjects(gd::Project &project,
|
||||
gd::ArbitraryObjectsWorker &worker);
|
||||
|
||||
/**
|
||||
* \brief Call the specified worker on all FunctionsContainers of the project
|
||||
* (global, layouts...)
|
||||
*
|
||||
* This should be the preferred way to traverse all the function signatures
|
||||
* of a project.
|
||||
*/
|
||||
static void ExposeProjectFunctions(gd::Project &project,
|
||||
gd::ArbitraryEventsFunctionsWorker &worker);
|
||||
|
||||
/**
|
||||
* \brief Call the specified worker on all EventBasedBehavior of a project.
|
||||
*
|
||||
* This should be the preferred way to traverse all the event-based behavior
|
||||
* of a project.
|
||||
*/
|
||||
static void ExposeProjectEventBasedBehaviors(
|
||||
gd::Project &project, gd::ArbitraryEventBasedBehaviorsWorker &worker);
|
||||
|
||||
/**
|
||||
* \brief Call the specified worker on all SharedData of a project.
|
||||
*
|
||||
* This should be the preferred way to traverse all the shared data
|
||||
* of a project.
|
||||
*/
|
||||
static void ExposeProjectSharedDatas(gd::Project &project,
|
||||
gd::ArbitraryBehaviorSharedDataWorker &worker);
|
||||
};
|
||||
|
||||
} // namespace gd
|
@@ -1,49 +0,0 @@
|
||||
/*
|
||||
* GDevelop Core
|
||||
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
|
||||
* reserved. This project is released under the MIT License.
|
||||
*/
|
||||
#include "WholeProjectBrowser.h"
|
||||
|
||||
#include "GDCore/IDE/Events/ArbitraryEventsWorker.h"
|
||||
#include "GDCore/IDE/Project/ArbitraryEventBasedBehaviorsWorker.h"
|
||||
#include "GDCore/IDE/Project/ArbitraryEventsFunctionsWorker.h"
|
||||
#include "GDCore/IDE/Project/ArbitraryObjectsWorker.h"
|
||||
#include "GDCore/IDE/Project/ArbitraryBehaviorSharedDataWorker.h"
|
||||
#include "GDCore/IDE/ProjectBrowserHelper.h"
|
||||
#include "GDCore/Project/Project.h"
|
||||
#include "GDCore/String.h"
|
||||
|
||||
namespace gd {
|
||||
|
||||
void WholeProjectBrowser::ExposeEvents(
|
||||
gd::Project &project, gd::ArbitraryEventsWorker &worker) const {
|
||||
gd::ProjectBrowserHelper::ExposeProjectEvents(project, worker);
|
||||
}
|
||||
|
||||
void WholeProjectBrowser::ExposeEvents(
|
||||
gd::Project &project, gd::ArbitraryEventsWorkerWithContext &worker) const {
|
||||
gd::ProjectBrowserHelper::ExposeProjectEvents(project, worker);
|
||||
}
|
||||
|
||||
void WholeProjectBrowser::ExposeObjects(
|
||||
gd::Project &project, gd::ArbitraryObjectsWorker &worker) const {
|
||||
gd::ProjectBrowserHelper::ExposeProjectObjects(project, worker);
|
||||
}
|
||||
|
||||
void WholeProjectBrowser::ExposeFunctions(
|
||||
gd::Project &project, gd::ArbitraryEventsFunctionsWorker &worker) const {
|
||||
gd::ProjectBrowserHelper::ExposeProjectFunctions(project, worker);
|
||||
}
|
||||
|
||||
void WholeProjectBrowser::ExposeEventBasedBehaviors(
|
||||
gd::Project &project,
|
||||
gd::ArbitraryEventBasedBehaviorsWorker &worker) const {
|
||||
gd::ProjectBrowserHelper::ExposeProjectEventBasedBehaviors(project, worker);
|
||||
}
|
||||
|
||||
void WholeProjectBrowser::ExposeBehaviorSharedDatas(
|
||||
gd::Project &project, gd::ArbitraryBehaviorSharedDataWorker &worker) const {
|
||||
gd::ProjectBrowserHelper::ExposeProjectSharedDatas(project, worker);
|
||||
}
|
||||
} // namespace gd
|
@@ -1,90 +0,0 @@
|
||||
/*
|
||||
* GDevelop Core
|
||||
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
|
||||
* reserved. This project is released under the MIT License.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "GDCore/IDE/ProjectBrowser.h"
|
||||
|
||||
namespace gd {
|
||||
class Project;
|
||||
class String;
|
||||
class EventsFunctionsExtension;
|
||||
class EventsFunction;
|
||||
class EventsBasedBehavior;
|
||||
class EventsBasedObject;
|
||||
class ArbitraryEventsWorker;
|
||||
class ArbitraryEventsWorkerWithContext;
|
||||
class ArbitraryEventsFunctionsWorker;
|
||||
class ArbitraryObjectsWorker;
|
||||
class ArbitraryEventBasedBehaviorsWorker;
|
||||
class ArbitraryBehaviorSharedDataWorker;
|
||||
} // namespace gd
|
||||
|
||||
namespace gd {
|
||||
|
||||
/**
|
||||
* \brief Expose the whole project to workers.
|
||||
*/
|
||||
class GD_CORE_API WholeProjectBrowser : public ProjectBrowser {
|
||||
public:
|
||||
/**
|
||||
* \brief Call the specified worker on all events of the project (layout,
|
||||
* external events, events functions...)
|
||||
*
|
||||
* This should be the preferred way to traverse all the events of a project.
|
||||
*/
|
||||
void ExposeEvents(gd::Project &project,
|
||||
gd::ArbitraryEventsWorker &worker) const override;
|
||||
|
||||
/**
|
||||
* \brief Call the specified worker on all events of the project (layout,
|
||||
* external events, events functions...)
|
||||
*
|
||||
* This should be the preferred way to traverse all the events of a project.
|
||||
*/
|
||||
void
|
||||
ExposeEvents(gd::Project &project,
|
||||
gd::ArbitraryEventsWorkerWithContext &worker) const override;
|
||||
|
||||
/**
|
||||
* \brief Call the specified worker on all ObjectContainers of the project
|
||||
* (global, layouts...)
|
||||
*
|
||||
* This should be the preferred way to traverse all the objects of a project.
|
||||
*/
|
||||
void ExposeObjects(gd::Project &project,
|
||||
gd::ArbitraryObjectsWorker &worker) const override;
|
||||
|
||||
/**
|
||||
* \brief Call the specified worker on all FunctionsContainers of the project
|
||||
* (global, layouts...)
|
||||
*
|
||||
* This should be the preferred way to traverse all the function signatures
|
||||
* of a project.
|
||||
*/
|
||||
void ExposeFunctions(gd::Project &project,
|
||||
gd::ArbitraryEventsFunctionsWorker &worker) const override;
|
||||
|
||||
/**
|
||||
* \brief Call the specified worker on all EventBasedBehavior of a project.
|
||||
*
|
||||
* This should be the preferred way to traverse all the event-based behavior
|
||||
* of a project.
|
||||
*/
|
||||
void ExposeEventBasedBehaviors(
|
||||
gd::Project &project,
|
||||
gd::ArbitraryEventBasedBehaviorsWorker &worker) const override;
|
||||
|
||||
/**
|
||||
* \brief Call the specified worker on all SharedData of a project.
|
||||
*
|
||||
* This should be the preferred way to traverse all the shared data
|
||||
* of a project.
|
||||
*/
|
||||
void ExposeBehaviorSharedDatas(gd::Project &project,
|
||||
gd::ArbitraryBehaviorSharedDataWorker &worker) const override;
|
||||
};
|
||||
|
||||
} // namespace gd
|
@@ -18,20 +18,8 @@
|
||||
#include "GDCore/IDE/Events/ExpressionsRenamer.h"
|
||||
#include "GDCore/IDE/Events/InstructionsParameterMover.h"
|
||||
#include "GDCore/IDE/Events/InstructionsTypeRenamer.h"
|
||||
#include "GDCore/IDE/ProjectBrowser.h"
|
||||
#include "GDCore/IDE/ProjectBrowserHelper.h"
|
||||
#include "GDCore/IDE/WholeProjectBrowser.h"
|
||||
#include "GDCore/IDE/EventBasedBehaviorBrowser.h"
|
||||
#include "GDCore/IDE/EventsFunctionTools.h"
|
||||
#include "GDCore/IDE/Project/ArbitraryObjectsWorker.h"
|
||||
#include "GDCore/IDE/Project/ArbitraryEventsFunctionsWorker.h"
|
||||
#include "GDCore/IDE/Project/ArbitraryEventBasedBehaviorsWorker.h"
|
||||
#include "GDCore/IDE/Project/ArbitraryBehaviorSharedDataWorker.h"
|
||||
#include "GDCore/IDE/Project/RequiredBehaviorRenamer.h"
|
||||
#include "GDCore/IDE/Project/BehaviorObjectTypeRenamer.h"
|
||||
#include "GDCore/IDE/Project/BehaviorsSharedDataBehaviorTypeRenamer.h"
|
||||
#include "GDCore/IDE/Project/FunctionParameterBehaviorTypeRenamer.h"
|
||||
#include "GDCore/IDE/Project/FunctionParameterObjectTypeRenamer.h"
|
||||
#include "GDCore/IDE/UnfilledRequiredBehaviorPropertyProblem.h"
|
||||
#include "GDCore/Project/Behavior.h"
|
||||
#include "GDCore/Project/BehaviorConfigurationContainer.h"
|
||||
@@ -56,6 +44,174 @@ const gd::String WholeProjectRefactorer::behaviorObjectParameterName = "Object";
|
||||
// always called "Object".
|
||||
const gd::String WholeProjectRefactorer::parentObjectParameterName = "Object";
|
||||
|
||||
void WholeProjectRefactorer::ExposeProjectEvents(
|
||||
gd::Project& project, gd::ArbitraryEventsWorker& worker) {
|
||||
// See also gd::Project::ExposeResources for a method that traverse the whole
|
||||
// project (this time for resources).
|
||||
|
||||
// Add layouts events
|
||||
for (std::size_t s = 0; s < project.GetLayoutsCount(); s++) {
|
||||
worker.Launch(project.GetLayout(s).GetEvents());
|
||||
}
|
||||
// Add external events events
|
||||
for (std::size_t s = 0; s < project.GetExternalEventsCount(); s++) {
|
||||
worker.Launch(project.GetExternalEvents(s).GetEvents());
|
||||
}
|
||||
// Add events based extensions
|
||||
for (std::size_t e = 0; e < project.GetEventsFunctionsExtensionsCount();
|
||||
e++) {
|
||||
// Add (free) events functions
|
||||
auto& eventsFunctionsExtension = project.GetEventsFunctionsExtension(e);
|
||||
for (auto&& eventsFunction : eventsFunctionsExtension.GetInternalVector()) {
|
||||
worker.Launch(eventsFunction->GetEvents());
|
||||
}
|
||||
|
||||
// Add (behavior) events functions
|
||||
for (auto&& eventsBasedBehavior :
|
||||
eventsFunctionsExtension.GetEventsBasedBehaviors()
|
||||
.GetInternalVector()) {
|
||||
auto& behaviorEventsFunctions = eventsBasedBehavior->GetEventsFunctions();
|
||||
for (auto&& eventsFunction :
|
||||
behaviorEventsFunctions.GetInternalVector()) {
|
||||
worker.Launch(eventsFunction->GetEvents());
|
||||
}
|
||||
}
|
||||
|
||||
// Add (object) events functions
|
||||
for (auto&& eventsBasedObject :
|
||||
eventsFunctionsExtension.GetEventsBasedObjects()
|
||||
.GetInternalVector()) {
|
||||
auto& objectEventsFunctions = eventsBasedObject->GetEventsFunctions();
|
||||
for (auto&& eventsFunction :
|
||||
objectEventsFunctions.GetInternalVector()) {
|
||||
worker.Launch(eventsFunction->GetEvents());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WholeProjectRefactorer::ExposeProjectEvents(
|
||||
gd::Project& project, gd::ArbitraryEventsWorkerWithContext& worker) {
|
||||
// See also gd::Project::ExposeResources for a method that traverse the whole
|
||||
// project (this time for resources) and ExposeProjectEffects (this time for
|
||||
// effects).
|
||||
|
||||
// Add layouts events
|
||||
for (std::size_t s = 0; s < project.GetLayoutsCount(); s++) {
|
||||
auto& layout = project.GetLayout(s);
|
||||
worker.Launch(layout.GetEvents(), project, layout);
|
||||
}
|
||||
// Add external events events
|
||||
for (std::size_t s = 0; s < project.GetExternalEventsCount(); s++) {
|
||||
const auto& externalEvents = project.GetExternalEvents(s);
|
||||
const gd::String& associatedLayout = externalEvents.GetAssociatedLayout();
|
||||
if (project.HasLayoutNamed(associatedLayout)) {
|
||||
worker.Launch(project.GetExternalEvents(s).GetEvents(),
|
||||
project,
|
||||
project.GetLayout(associatedLayout));
|
||||
}
|
||||
}
|
||||
// Add events based extensions
|
||||
for (std::size_t e = 0; e < project.GetEventsFunctionsExtensionsCount();
|
||||
e++) {
|
||||
// Add (free) events functions
|
||||
auto& eventsFunctionsExtension = project.GetEventsFunctionsExtension(e);
|
||||
for (auto&& eventsFunction : eventsFunctionsExtension.GetInternalVector()) {
|
||||
gd::ObjectsContainer globalObjectsAndGroups;
|
||||
gd::ObjectsContainer objectsAndGroups;
|
||||
gd::EventsFunctionTools::FreeEventsFunctionToObjectsContainer(
|
||||
project,
|
||||
eventsFunctionsExtension,
|
||||
*eventsFunction,
|
||||
globalObjectsAndGroups,
|
||||
objectsAndGroups);
|
||||
|
||||
worker.Launch(eventsFunction->GetEvents(),
|
||||
globalObjectsAndGroups,
|
||||
objectsAndGroups);
|
||||
}
|
||||
|
||||
// Add (behavior) events functions
|
||||
for (auto&& eventsBasedBehavior :
|
||||
eventsFunctionsExtension.GetEventsBasedBehaviors()
|
||||
.GetInternalVector()) {
|
||||
ExposeEventsBasedBehaviorEvents(project, *eventsBasedBehavior, worker);
|
||||
}
|
||||
|
||||
// Add (object) events functions
|
||||
for (auto&& eventsBasedObject :
|
||||
eventsFunctionsExtension.GetEventsBasedObjects()
|
||||
.GetInternalVector()) {
|
||||
ExposeEventsBasedObjectEvents(project, *eventsBasedObject, worker);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WholeProjectRefactorer::ExposeEventsBasedBehaviorEvents(
|
||||
gd::Project& project,
|
||||
const gd::EventsBasedBehavior& eventsBasedBehavior,
|
||||
gd::ArbitraryEventsWorkerWithContext& worker) {
|
||||
auto& behaviorEventsFunctions = eventsBasedBehavior.GetEventsFunctions();
|
||||
for (auto&& eventsFunction : behaviorEventsFunctions.GetInternalVector()) {
|
||||
gd::ObjectsContainer globalObjectsAndGroups;
|
||||
gd::ObjectsContainer objectsAndGroups;
|
||||
gd::EventsFunctionTools::BehaviorEventsFunctionToObjectsContainer(
|
||||
project,
|
||||
eventsBasedBehavior,
|
||||
*eventsFunction,
|
||||
globalObjectsAndGroups,
|
||||
objectsAndGroups);
|
||||
|
||||
worker.Launch(
|
||||
eventsFunction->GetEvents(), globalObjectsAndGroups, objectsAndGroups);
|
||||
}
|
||||
}
|
||||
|
||||
void WholeProjectRefactorer::ExposeEventsBasedObjectEvents(
|
||||
gd::Project& project,
|
||||
const gd::EventsBasedObject& eventsBasedObject,
|
||||
gd::ArbitraryEventsWorkerWithContext& worker) {
|
||||
auto& objectEventsFunctions = eventsBasedObject.GetEventsFunctions();
|
||||
for (auto&& eventsFunction : objectEventsFunctions.GetInternalVector()) {
|
||||
gd::ObjectsContainer globalObjectsAndGroups;
|
||||
gd::ObjectsContainer objectsAndGroups;
|
||||
gd::EventsFunctionTools::ObjectEventsFunctionToObjectsContainer(
|
||||
project,
|
||||
eventsBasedObject,
|
||||
*eventsFunction,
|
||||
globalObjectsAndGroups,
|
||||
objectsAndGroups);
|
||||
|
||||
worker.Launch(
|
||||
eventsFunction->GetEvents(), globalObjectsAndGroups, objectsAndGroups);
|
||||
}
|
||||
}
|
||||
|
||||
void WholeProjectRefactorer::ExposeProjectObjects(
|
||||
gd::Project& project, gd::ArbitraryObjectsWorker& worker) {
|
||||
|
||||
// Global objects
|
||||
worker.Launch(project);
|
||||
|
||||
// Layers objects
|
||||
for (size_t i = 0; i < project.GetLayoutsCount(); i++) {
|
||||
worker.Launch(project.GetLayout(i));
|
||||
}
|
||||
|
||||
// Event based objects children
|
||||
for (std::size_t e = 0; e < project.GetEventsFunctionsExtensionsCount();
|
||||
e++) {
|
||||
auto& eventsFunctionsExtension = project.GetEventsFunctionsExtension(e);
|
||||
|
||||
for (auto&& eventsBasedObjectUniquePtr :
|
||||
eventsFunctionsExtension.GetEventsBasedObjects()
|
||||
.GetInternalVector()) {
|
||||
auto eventsBasedObject = eventsBasedObjectUniquePtr.get();
|
||||
worker.Launch(*eventsBasedObject);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
std::set<gd::String>
|
||||
WholeProjectRefactorer::GetAllObjectTypesUsingEventsBasedBehavior(
|
||||
const gd::Project& project,
|
||||
@@ -130,48 +286,22 @@ void WholeProjectRefactorer::EnsureObjectEventsFunctionsProperParameters(
|
||||
}
|
||||
}
|
||||
|
||||
void WholeProjectRefactorer::UpdateExtensionNameInEventsBasedBehavior(
|
||||
gd::Project& project,
|
||||
const gd::EventsFunctionsExtension& eventsFunctionsExtension,
|
||||
gd::EventsBasedBehavior& eventsBasedBehavior,
|
||||
const gd::String& sourceExtensionName) {
|
||||
const EventBasedBehaviorBrowser eventBasedBehaviorExposer(eventsBasedBehavior);
|
||||
WholeProjectRefactorer::RenameEventsFunctionsExtension(
|
||||
project,
|
||||
eventsFunctionsExtension,
|
||||
sourceExtensionName,
|
||||
eventsFunctionsExtension.GetName(),
|
||||
eventBasedBehaviorExposer);
|
||||
}
|
||||
|
||||
void WholeProjectRefactorer::RenameEventsFunctionsExtension(
|
||||
gd::Project &project,
|
||||
const gd::EventsFunctionsExtension &eventsFunctionsExtension,
|
||||
const gd::String &oldName, const gd::String &newName) {
|
||||
const WholeProjectBrowser wholeProjectExposer;
|
||||
RenameEventsFunctionsExtension(project, eventsFunctionsExtension, oldName,
|
||||
newName, wholeProjectExposer);
|
||||
}
|
||||
|
||||
void WholeProjectRefactorer::RenameEventsFunctionsExtension(
|
||||
gd::Project& project,
|
||||
const gd::EventsFunctionsExtension& eventsFunctionsExtension,
|
||||
const gd::String& oldName,
|
||||
const gd::String& newName,
|
||||
const gd::ProjectBrowser& projectBrowser
|
||||
) {
|
||||
const gd::String& newName) {
|
||||
auto renameEventsFunction =
|
||||
[&project, &oldName, &newName, &projectBrowser](const gd::EventsFunction& eventsFunction) {
|
||||
[&project, &oldName, &newName](const gd::EventsFunction& eventsFunction) {
|
||||
DoRenameEventsFunction(
|
||||
project,
|
||||
eventsFunction,
|
||||
gd::PlatformExtension::GetEventsFunctionFullType(oldName, eventsFunction.GetName()),
|
||||
gd::PlatformExtension::GetEventsFunctionFullType(newName, eventsFunction.GetName()),
|
||||
projectBrowser);
|
||||
gd::PlatformExtension::GetEventsFunctionFullType(newName, eventsFunction.GetName()));
|
||||
};
|
||||
|
||||
auto renameBehaviorEventsFunction =
|
||||
[&project, &oldName, &newName, &projectBrowser](
|
||||
[&project, &oldName, &newName](
|
||||
const gd::EventsBasedBehavior& eventsBasedBehavior,
|
||||
const gd::EventsFunction& eventsFunction) {
|
||||
if (eventsFunction.IsExpression()) {
|
||||
@@ -186,12 +316,12 @@ void WholeProjectRefactorer::RenameEventsFunctionsExtension(
|
||||
gd::PlatformExtension::GetBehaviorEventsFunctionFullType(newName,
|
||||
eventsBasedBehavior.GetName(),
|
||||
eventsFunction.GetName()));
|
||||
projectBrowser.ExposeEvents(project, renamer);
|
||||
ExposeProjectEvents(project, renamer);
|
||||
}
|
||||
};
|
||||
|
||||
auto renameBehaviorPropertyFunctions =
|
||||
[&project, &oldName, &newName, &projectBrowser](
|
||||
[&project, &oldName, &newName](
|
||||
const gd::EventsBasedBehavior& eventsBasedBehavior,
|
||||
const gd::NamedPropertyDescriptor& property) {
|
||||
gd::InstructionsTypeRenamer actionRenamer = gd::InstructionsTypeRenamer(
|
||||
@@ -206,7 +336,7 @@ void WholeProjectRefactorer::RenameEventsFunctionsExtension(
|
||||
eventsBasedBehavior.GetName(),
|
||||
gd::EventsBasedBehavior::GetPropertyActionName(
|
||||
property.GetName())));
|
||||
projectBrowser.ExposeEvents(project, actionRenamer);
|
||||
ExposeProjectEvents(project, actionRenamer);
|
||||
|
||||
gd::InstructionsTypeRenamer conditionRenamer =
|
||||
gd::InstructionsTypeRenamer(
|
||||
@@ -221,14 +351,14 @@ void WholeProjectRefactorer::RenameEventsFunctionsExtension(
|
||||
eventsBasedBehavior.GetName(),
|
||||
gd::EventsBasedBehavior::GetPropertyConditionName(
|
||||
property.GetName())));
|
||||
projectBrowser.ExposeEvents(project, conditionRenamer);
|
||||
ExposeProjectEvents(project, conditionRenamer);
|
||||
|
||||
// Nothing to do for expressions, expressions are not including the
|
||||
// extension name
|
||||
};
|
||||
|
||||
auto renameBehaviorSharedPropertyFunctions =
|
||||
[&project, &oldName, &newName, &projectBrowser](
|
||||
[&project, &oldName, &newName](
|
||||
const gd::EventsBasedBehavior& eventsBasedBehavior,
|
||||
const gd::NamedPropertyDescriptor& property) {
|
||||
gd::InstructionsTypeRenamer actionRenamer = gd::InstructionsTypeRenamer(
|
||||
@@ -243,7 +373,7 @@ void WholeProjectRefactorer::RenameEventsFunctionsExtension(
|
||||
eventsBasedBehavior.GetName(),
|
||||
gd::EventsBasedBehavior::GetSharedPropertyActionName(
|
||||
property.GetName())));
|
||||
projectBrowser.ExposeEvents(project, actionRenamer);
|
||||
ExposeProjectEvents(project, actionRenamer);
|
||||
|
||||
gd::InstructionsTypeRenamer conditionRenamer =
|
||||
gd::InstructionsTypeRenamer(
|
||||
@@ -258,14 +388,14 @@ void WholeProjectRefactorer::RenameEventsFunctionsExtension(
|
||||
eventsBasedBehavior.GetName(),
|
||||
gd::EventsBasedBehavior::GetSharedPropertyConditionName(
|
||||
property.GetName())));
|
||||
projectBrowser.ExposeEvents(project, conditionRenamer);
|
||||
ExposeProjectEvents(project, conditionRenamer);
|
||||
|
||||
// Nothing to do for expressions, expressions are not including the
|
||||
// extension name
|
||||
};
|
||||
|
||||
auto renameObjectEventsFunction =
|
||||
[&project, &oldName, &newName, &projectBrowser](
|
||||
[&project, &oldName, &newName](
|
||||
const gd::EventsBasedObject& eventsBasedObject,
|
||||
const gd::EventsFunction& eventsFunction) {
|
||||
if (eventsFunction.IsExpression()) {
|
||||
@@ -280,12 +410,12 @@ void WholeProjectRefactorer::RenameEventsFunctionsExtension(
|
||||
gd::PlatformExtension::GetObjectEventsFunctionFullType(newName,
|
||||
eventsBasedObject.GetName(),
|
||||
eventsFunction.GetName()));
|
||||
projectBrowser.ExposeEvents(project, renamer);
|
||||
ExposeProjectEvents(project, renamer);
|
||||
}
|
||||
};
|
||||
|
||||
auto renameObjectPropertyFunctions =
|
||||
[&project, &oldName, &newName, &projectBrowser](
|
||||
[&project, &oldName, &newName](
|
||||
const gd::EventsBasedObject& eventsBasedObject,
|
||||
const gd::NamedPropertyDescriptor& property) {
|
||||
gd::InstructionsTypeRenamer actionRenamer = gd::InstructionsTypeRenamer(
|
||||
@@ -300,7 +430,7 @@ void WholeProjectRefactorer::RenameEventsFunctionsExtension(
|
||||
eventsBasedObject.GetName(),
|
||||
gd::EventsBasedObject::GetPropertyActionName(
|
||||
property.GetName())));
|
||||
projectBrowser.ExposeEvents(project, actionRenamer);
|
||||
ExposeProjectEvents(project, actionRenamer);
|
||||
|
||||
gd::InstructionsTypeRenamer conditionRenamer =
|
||||
gd::InstructionsTypeRenamer(
|
||||
@@ -315,7 +445,7 @@ void WholeProjectRefactorer::RenameEventsFunctionsExtension(
|
||||
eventsBasedObject.GetName(),
|
||||
gd::EventsBasedObject::GetPropertyConditionName(
|
||||
property.GetName())));
|
||||
projectBrowser.ExposeEvents(project, conditionRenamer);
|
||||
ExposeProjectEvents(project, conditionRenamer);
|
||||
|
||||
// Nothing to do for expressions, expressions are not including the
|
||||
// extension name
|
||||
@@ -403,8 +533,7 @@ void WholeProjectRefactorer::RenameEventsFunctionsExtension(
|
||||
DoRenameBehavior(
|
||||
project,
|
||||
gd::PlatformExtension::GetBehaviorFullType(oldName, eventsBasedBehavior->GetName()),
|
||||
gd::PlatformExtension::GetBehaviorFullType(newName, eventsBasedBehavior->GetName()),
|
||||
projectBrowser);
|
||||
gd::PlatformExtension::GetBehaviorFullType(newName, eventsBasedBehavior->GetName()));
|
||||
}
|
||||
|
||||
// Finally, rename custom objects type
|
||||
@@ -413,8 +542,7 @@ void WholeProjectRefactorer::RenameEventsFunctionsExtension(
|
||||
DoRenameObject(
|
||||
project,
|
||||
gd::PlatformExtension::GetObjectFullType(oldName, eventsBasedObject->GetName()),
|
||||
gd::PlatformExtension::GetObjectFullType(newName, eventsBasedObject->GetName()),
|
||||
projectBrowser);
|
||||
gd::PlatformExtension::GetObjectFullType(newName, eventsBasedObject->GetName()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -428,15 +556,13 @@ void WholeProjectRefactorer::RenameEventsFunction(
|
||||
const gd::EventsFunction& eventsFunction =
|
||||
eventsFunctionsExtension.GetEventsFunction(oldFunctionName);
|
||||
|
||||
const WholeProjectBrowser wholeProjectExposer;
|
||||
DoRenameEventsFunction(
|
||||
project,
|
||||
eventsFunction,
|
||||
gd::PlatformExtension::GetEventsFunctionFullType(eventsFunctionsExtension.GetName(),
|
||||
oldFunctionName),
|
||||
gd::PlatformExtension::GetEventsFunctionFullType(eventsFunctionsExtension.GetName(),
|
||||
newFunctionName),
|
||||
wholeProjectExposer);
|
||||
newFunctionName));
|
||||
|
||||
if (eventsFunction.GetFunctionType() == gd::EventsFunction::ExpressionAndCondition) {
|
||||
for (auto&& otherFunction : eventsFunctionsExtension.GetInternalVector())
|
||||
@@ -472,7 +598,7 @@ void WholeProjectRefactorer::RenameBehaviorEventsFunction(
|
||||
eventsBasedBehavior.GetName()),
|
||||
oldFunctionName,
|
||||
newFunctionName);
|
||||
gd::ProjectBrowserHelper::ExposeProjectEvents(project, renamer);
|
||||
ExposeProjectEvents(project, renamer);
|
||||
}
|
||||
if (eventsFunction.IsAction() || eventsFunction.IsCondition()) {
|
||||
gd::InstructionsTypeRenamer renamer = gd::InstructionsTypeRenamer(
|
||||
@@ -483,7 +609,7 @@ void WholeProjectRefactorer::RenameBehaviorEventsFunction(
|
||||
gd::PlatformExtension::GetBehaviorEventsFunctionFullType(eventsFunctionsExtension.GetName(),
|
||||
eventsBasedBehavior.GetName(),
|
||||
newFunctionName));
|
||||
gd::ProjectBrowserHelper::ExposeProjectEvents(project, renamer);
|
||||
ExposeProjectEvents(project, renamer);
|
||||
}
|
||||
if (eventsFunction.GetFunctionType() == gd::EventsFunction::ExpressionAndCondition) {
|
||||
for (auto&& otherFunction : eventsBasedBehavior.GetEventsFunctions().GetInternalVector())
|
||||
@@ -516,7 +642,7 @@ void WholeProjectRefactorer::RenameObjectEventsFunction(
|
||||
eventsBasedObject.GetName()),
|
||||
oldFunctionName,
|
||||
newFunctionName);
|
||||
gd::ProjectBrowserHelper::ExposeProjectEvents(project, renamer);
|
||||
ExposeProjectEvents(project, renamer);
|
||||
}
|
||||
if (eventsFunction.IsAction() || eventsFunction.IsCondition()) {
|
||||
gd::InstructionsTypeRenamer renamer = gd::InstructionsTypeRenamer(
|
||||
@@ -527,7 +653,7 @@ void WholeProjectRefactorer::RenameObjectEventsFunction(
|
||||
gd::PlatformExtension::GetObjectEventsFunctionFullType(eventsFunctionsExtension.GetName(),
|
||||
eventsBasedObject.GetName(),
|
||||
newFunctionName));
|
||||
gd::ProjectBrowserHelper::ExposeProjectEvents(project, renamer);
|
||||
ExposeProjectEvents(project, renamer);
|
||||
}
|
||||
if (eventsFunction.GetFunctionType() == gd::EventsFunction::ExpressionAndCondition) {
|
||||
for (auto&& otherFunction : eventsBasedObject.GetEventsFunctions().GetInternalVector())
|
||||
@@ -559,7 +685,7 @@ void WholeProjectRefactorer::MoveEventsFunctionParameter(
|
||||
gd::ExpressionsParameterMover(project.GetCurrentPlatform());
|
||||
mover.SetFreeExpressionMovedParameter(
|
||||
eventsFunctionType, oldIndex, newIndex);
|
||||
gd::ProjectBrowserHelper::ExposeProjectEvents(project, mover);
|
||||
ExposeProjectEvents(project, mover);
|
||||
}
|
||||
if (eventsFunction.IsAction() || eventsFunction.IsCondition()) {
|
||||
const int operatorIndexOffset = eventsFunction.IsExpression() ? 2 : 0;
|
||||
@@ -568,7 +694,7 @@ void WholeProjectRefactorer::MoveEventsFunctionParameter(
|
||||
eventsFunctionType,
|
||||
oldIndex + operatorIndexOffset,
|
||||
newIndex + operatorIndexOffset);
|
||||
gd::ProjectBrowserHelper::ExposeProjectEvents(project, mover);
|
||||
ExposeProjectEvents(project, mover);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -599,7 +725,7 @@ void WholeProjectRefactorer::MoveBehaviorEventsFunctionParameter(
|
||||
functionName,
|
||||
oldIndex,
|
||||
newIndex);
|
||||
gd::ProjectBrowserHelper::ExposeProjectEvents(project, mover);
|
||||
ExposeProjectEvents(project, mover);
|
||||
}
|
||||
if (eventsFunction.IsAction() || eventsFunction.IsCondition()) {
|
||||
const int operatorIndexOffset = eventsFunction.IsExpression() ? 2 : 0;
|
||||
@@ -608,7 +734,7 @@ void WholeProjectRefactorer::MoveBehaviorEventsFunctionParameter(
|
||||
eventsFunctionType,
|
||||
oldIndex + operatorIndexOffset,
|
||||
newIndex + operatorIndexOffset);
|
||||
gd::ProjectBrowserHelper::ExposeProjectEvents(project, mover);
|
||||
ExposeProjectEvents(project, mover);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -639,7 +765,7 @@ void WholeProjectRefactorer::MoveObjectEventsFunctionParameter(
|
||||
functionName,
|
||||
oldIndex,
|
||||
newIndex);
|
||||
gd::ProjectBrowserHelper::ExposeProjectEvents(project, mover);
|
||||
ExposeProjectEvents(project, mover);
|
||||
}
|
||||
if (eventsFunction.IsAction() || eventsFunction.IsCondition()) {
|
||||
const int operatorIndexOffset = eventsFunction.IsExpression() ? 2 : 0;
|
||||
@@ -648,7 +774,7 @@ void WholeProjectRefactorer::MoveObjectEventsFunctionParameter(
|
||||
eventsFunctionType,
|
||||
oldIndex + operatorIndexOffset,
|
||||
newIndex + operatorIndexOffset);
|
||||
gd::ProjectBrowserHelper::ExposeProjectEvents(project, mover);
|
||||
ExposeProjectEvents(project, mover);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -674,7 +800,7 @@ void WholeProjectRefactorer::RenameEventsBasedBehaviorProperty(
|
||||
oldPropertyName,
|
||||
newPropertyName);
|
||||
|
||||
gd::ProjectBrowserHelper::ExposeEventsBasedBehaviorEvents(
|
||||
ExposeEventsBasedBehaviorEvents(
|
||||
project, eventsBasedBehavior, behaviorRenamer);
|
||||
} else {
|
||||
// Properties that represent primitive values will be used through
|
||||
@@ -690,7 +816,7 @@ void WholeProjectRefactorer::RenameEventsBasedBehaviorProperty(
|
||||
eventsBasedBehavior.GetName()),
|
||||
EventsBasedBehavior::GetPropertyExpressionName(oldPropertyName),
|
||||
EventsBasedBehavior::GetPropertyExpressionName(newPropertyName));
|
||||
gd::ProjectBrowserHelper::ExposeProjectEvents(project, expressionRenamer);
|
||||
ExposeProjectEvents(project, expressionRenamer);
|
||||
|
||||
gd::InstructionsTypeRenamer actionRenamer = gd::InstructionsTypeRenamer(
|
||||
project,
|
||||
@@ -702,7 +828,7 @@ void WholeProjectRefactorer::RenameEventsBasedBehaviorProperty(
|
||||
eventsFunctionsExtension.GetName(),
|
||||
eventsBasedBehavior.GetName(),
|
||||
EventsBasedBehavior::GetPropertyActionName(newPropertyName)));
|
||||
gd::ProjectBrowserHelper::ExposeProjectEvents(project, actionRenamer);
|
||||
ExposeProjectEvents(project, actionRenamer);
|
||||
|
||||
gd::InstructionsTypeRenamer conditionRenamer = gd::InstructionsTypeRenamer(
|
||||
project,
|
||||
@@ -714,7 +840,7 @@ void WholeProjectRefactorer::RenameEventsBasedBehaviorProperty(
|
||||
eventsFunctionsExtension.GetName(),
|
||||
eventsBasedBehavior.GetName(),
|
||||
EventsBasedBehavior::GetPropertyConditionName(newPropertyName)));
|
||||
gd::ProjectBrowserHelper::ExposeProjectEvents(project, conditionRenamer);
|
||||
ExposeProjectEvents(project, conditionRenamer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -740,7 +866,7 @@ void WholeProjectRefactorer::RenameEventsBasedBehaviorSharedProperty(
|
||||
oldPropertyName,
|
||||
newPropertyName);
|
||||
|
||||
gd::ProjectBrowserHelper::ExposeEventsBasedBehaviorEvents(
|
||||
ExposeEventsBasedBehaviorEvents(
|
||||
project, eventsBasedBehavior, behaviorRenamer);
|
||||
} else {
|
||||
// Properties that represent primitive values will be used through
|
||||
@@ -756,7 +882,7 @@ void WholeProjectRefactorer::RenameEventsBasedBehaviorSharedProperty(
|
||||
eventsBasedBehavior.GetName()),
|
||||
EventsBasedBehavior::GetSharedPropertyExpressionName(oldPropertyName),
|
||||
EventsBasedBehavior::GetSharedPropertyExpressionName(newPropertyName));
|
||||
gd::ProjectBrowserHelper::ExposeProjectEvents(project, expressionRenamer);
|
||||
ExposeProjectEvents(project, expressionRenamer);
|
||||
|
||||
gd::InstructionsTypeRenamer actionRenamer = gd::InstructionsTypeRenamer(
|
||||
project,
|
||||
@@ -768,7 +894,7 @@ void WholeProjectRefactorer::RenameEventsBasedBehaviorSharedProperty(
|
||||
eventsFunctionsExtension.GetName(),
|
||||
eventsBasedBehavior.GetName(),
|
||||
EventsBasedBehavior::GetSharedPropertyActionName(newPropertyName)));
|
||||
gd::ProjectBrowserHelper::ExposeProjectEvents(project, actionRenamer);
|
||||
ExposeProjectEvents(project, actionRenamer);
|
||||
|
||||
gd::InstructionsTypeRenamer conditionRenamer = gd::InstructionsTypeRenamer(
|
||||
project,
|
||||
@@ -780,7 +906,7 @@ void WholeProjectRefactorer::RenameEventsBasedBehaviorSharedProperty(
|
||||
eventsFunctionsExtension.GetName(),
|
||||
eventsBasedBehavior.GetName(),
|
||||
EventsBasedBehavior::GetSharedPropertyConditionName(newPropertyName)));
|
||||
gd::ProjectBrowserHelper::ExposeProjectEvents(project, conditionRenamer);
|
||||
ExposeProjectEvents(project, conditionRenamer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -806,7 +932,7 @@ void WholeProjectRefactorer::RenameEventsBasedObjectProperty(
|
||||
eventsBasedObject.GetName()),
|
||||
EventsBasedObject::GetPropertyExpressionName(oldPropertyName),
|
||||
EventsBasedObject::GetPropertyExpressionName(newPropertyName));
|
||||
gd::ProjectBrowserHelper::ExposeProjectEvents(project, expressionRenamer);
|
||||
ExposeProjectEvents(project, expressionRenamer);
|
||||
|
||||
gd::InstructionsTypeRenamer actionRenamer = gd::InstructionsTypeRenamer(
|
||||
project,
|
||||
@@ -818,7 +944,7 @@ void WholeProjectRefactorer::RenameEventsBasedObjectProperty(
|
||||
eventsFunctionsExtension.GetName(),
|
||||
eventsBasedObject.GetName(),
|
||||
EventsBasedObject::GetPropertyActionName(newPropertyName)));
|
||||
gd::ProjectBrowserHelper::ExposeProjectEvents(project, actionRenamer);
|
||||
ExposeProjectEvents(project, actionRenamer);
|
||||
|
||||
gd::InstructionsTypeRenamer conditionRenamer = gd::InstructionsTypeRenamer(
|
||||
project,
|
||||
@@ -830,7 +956,7 @@ void WholeProjectRefactorer::RenameEventsBasedObjectProperty(
|
||||
eventsFunctionsExtension.GetName(),
|
||||
eventsBasedObject.GetName(),
|
||||
EventsBasedObject::GetPropertyConditionName(newPropertyName)));
|
||||
gd::ProjectBrowserHelper::ExposeProjectEvents(project, conditionRenamer);
|
||||
ExposeProjectEvents(project, conditionRenamer);
|
||||
}
|
||||
|
||||
void WholeProjectRefactorer::AddBehaviorAndRequiredBehaviors(
|
||||
@@ -1071,7 +1197,7 @@ void WholeProjectRefactorer::RenameEventsBasedBehavior(
|
||||
eventsFunctionsExtension.GetName(),
|
||||
newBehaviorName,
|
||||
eventsFunction.GetName()));
|
||||
gd::ProjectBrowserHelper::ExposeProjectEvents(project, renamer);
|
||||
ExposeProjectEvents(project, renamer);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1091,7 +1217,7 @@ void WholeProjectRefactorer::RenameEventsBasedBehavior(
|
||||
eventsFunctionsExtension.GetName(),
|
||||
newBehaviorName,
|
||||
EventsBasedBehavior::GetPropertyActionName(property.GetName())));
|
||||
gd::ProjectBrowserHelper::ExposeProjectEvents(project, actionRenamer);
|
||||
ExposeProjectEvents(project, actionRenamer);
|
||||
|
||||
gd::InstructionsTypeRenamer conditionRenamer = gd::InstructionsTypeRenamer(
|
||||
project,
|
||||
@@ -1103,7 +1229,7 @@ void WholeProjectRefactorer::RenameEventsBasedBehavior(
|
||||
eventsFunctionsExtension.GetName(),
|
||||
newBehaviorName,
|
||||
EventsBasedBehavior::GetPropertyConditionName(property.GetName())));
|
||||
gd::ProjectBrowserHelper::ExposeProjectEvents(project, conditionRenamer);
|
||||
ExposeProjectEvents(project, conditionRenamer);
|
||||
|
||||
// Nothing to do for expression, expressions are not including the name of
|
||||
// the behavior
|
||||
@@ -1125,7 +1251,7 @@ void WholeProjectRefactorer::RenameEventsBasedBehavior(
|
||||
eventsFunctionsExtension.GetName(),
|
||||
newBehaviorName,
|
||||
EventsBasedBehavior::GetSharedPropertyActionName(property.GetName())));
|
||||
gd::ProjectBrowserHelper::ExposeProjectEvents(project, actionRenamer);
|
||||
ExposeProjectEvents(project, actionRenamer);
|
||||
|
||||
gd::InstructionsTypeRenamer conditionRenamer = gd::InstructionsTypeRenamer(
|
||||
project,
|
||||
@@ -1137,7 +1263,7 @@ void WholeProjectRefactorer::RenameEventsBasedBehavior(
|
||||
eventsFunctionsExtension.GetName(),
|
||||
newBehaviorName,
|
||||
EventsBasedBehavior::GetSharedPropertyConditionName(property.GetName())));
|
||||
gd::ProjectBrowserHelper::ExposeProjectEvents(project, conditionRenamer);
|
||||
ExposeProjectEvents(project, conditionRenamer);
|
||||
|
||||
// Nothing to do for expression, expressions are not including the name of
|
||||
// the behavior
|
||||
@@ -1170,12 +1296,10 @@ void WholeProjectRefactorer::RenameEventsBasedBehavior(
|
||||
renameBehaviorSharedProperty(*property);
|
||||
}
|
||||
|
||||
const WholeProjectBrowser wholeProjectExposer;
|
||||
DoRenameBehavior(
|
||||
project,
|
||||
gd::PlatformExtension::GetBehaviorFullType(eventsFunctionsExtension.GetName(), oldBehaviorName),
|
||||
gd::PlatformExtension::GetBehaviorFullType(eventsFunctionsExtension.GetName(), newBehaviorName),
|
||||
wholeProjectExposer);
|
||||
gd::PlatformExtension::GetBehaviorFullType(eventsFunctionsExtension.GetName(), newBehaviorName));
|
||||
}
|
||||
|
||||
void WholeProjectRefactorer::RenameEventsBasedObject(
|
||||
@@ -1212,7 +1336,7 @@ void WholeProjectRefactorer::RenameEventsBasedObject(
|
||||
eventsFunctionsExtension.GetName(),
|
||||
newObjectName,
|
||||
eventsFunction.GetName()));
|
||||
gd::ProjectBrowserHelper::ExposeProjectEvents(project, renamer);
|
||||
ExposeProjectEvents(project, renamer);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1232,7 +1356,7 @@ void WholeProjectRefactorer::RenameEventsBasedObject(
|
||||
eventsFunctionsExtension.GetName(),
|
||||
newObjectName,
|
||||
EventsBasedObject::GetPropertyActionName(property.GetName())));
|
||||
gd::ProjectBrowserHelper::ExposeProjectEvents(project, actionRenamer);
|
||||
ExposeProjectEvents(project, actionRenamer);
|
||||
|
||||
gd::InstructionsTypeRenamer conditionRenamer = gd::InstructionsTypeRenamer(
|
||||
project,
|
||||
@@ -1244,7 +1368,7 @@ void WholeProjectRefactorer::RenameEventsBasedObject(
|
||||
eventsFunctionsExtension.GetName(),
|
||||
newObjectName,
|
||||
EventsBasedObject::GetPropertyConditionName(property.GetName())));
|
||||
gd::ProjectBrowserHelper::ExposeProjectEvents(project, conditionRenamer);
|
||||
ExposeProjectEvents(project, conditionRenamer);
|
||||
|
||||
// Nothing to do for expression, expressions are not including the name of
|
||||
// the object
|
||||
@@ -1275,20 +1399,17 @@ void WholeProjectRefactorer::RenameEventsBasedObject(
|
||||
renameObjectProperty(*property);
|
||||
}
|
||||
|
||||
const WholeProjectBrowser wholeProjectExposer;
|
||||
DoRenameObject(
|
||||
project,
|
||||
gd::PlatformExtension::GetObjectFullType(eventsFunctionsExtension.GetName(), oldObjectName),
|
||||
gd::PlatformExtension::GetObjectFullType(eventsFunctionsExtension.GetName(), newObjectName),
|
||||
wholeProjectExposer);
|
||||
gd::PlatformExtension::GetObjectFullType(eventsFunctionsExtension.GetName(), newObjectName));
|
||||
}
|
||||
|
||||
void WholeProjectRefactorer::DoRenameEventsFunction(
|
||||
gd::Project& project,
|
||||
const gd::EventsFunction& eventsFunction,
|
||||
const gd::String& oldFullType,
|
||||
const gd::String& newFullType,
|
||||
const gd::ProjectBrowser& projectBrowser) {
|
||||
const gd::String& newFullType) {
|
||||
// Order is important: we first rename the expressions then the instructions,
|
||||
// to avoid being unable to fetch the metadata (the types of parameters) of
|
||||
// instructions after they are renamed.
|
||||
@@ -1296,61 +1417,165 @@ void WholeProjectRefactorer::DoRenameEventsFunction(
|
||||
gd::ExpressionsRenamer renamer =
|
||||
gd::ExpressionsRenamer(project.GetCurrentPlatform());
|
||||
renamer.SetReplacedFreeExpression(oldFullType, newFullType);
|
||||
projectBrowser.ExposeEvents(project, renamer);
|
||||
ExposeProjectEvents(project, renamer);
|
||||
}
|
||||
if (eventsFunction.IsAction() || eventsFunction.IsCondition()) {
|
||||
gd::InstructionsTypeRenamer renamer =
|
||||
gd::InstructionsTypeRenamer(project, oldFullType, newFullType);
|
||||
projectBrowser.ExposeEvents(project, renamer);
|
||||
ExposeProjectEvents(project, renamer);
|
||||
}
|
||||
}
|
||||
|
||||
void WholeProjectRefactorer::DoRenameBehavior(
|
||||
gd::Project &project, const gd::String &oldBehaviorType,
|
||||
const gd::String &newBehaviorType,
|
||||
const gd::ProjectBrowser &projectBrowser) {
|
||||
gd::Project& project,
|
||||
const gd::String& oldBehaviorType,
|
||||
const gd::String& newBehaviorType) {
|
||||
auto renameBehaviorTypeInBehaviorContent =
|
||||
[&oldBehaviorType,
|
||||
&newBehaviorType](gd::BehaviorConfigurationContainer& behavior) {
|
||||
if (behavior.GetTypeName() == oldBehaviorType) {
|
||||
behavior.SetTypeName(newBehaviorType);
|
||||
}
|
||||
};
|
||||
auto renameBehaviorTypeInParameters =
|
||||
[&oldBehaviorType, &newBehaviorType](gd::EventsFunction& eventsFunction) {
|
||||
for (auto& parameter : eventsFunction.GetParameters()) {
|
||||
if (gd::ParameterMetadata::IsBehavior(parameter.GetType()) &&
|
||||
parameter.GetExtraInfo() == oldBehaviorType) {
|
||||
parameter.SetExtraInfo(newBehaviorType);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Rename behavior in required behavior properties
|
||||
auto requiredBehaviorRenamer =
|
||||
gd::RequiredBehaviorRenamer(oldBehaviorType, newBehaviorType);
|
||||
projectBrowser.ExposeEventBasedBehaviors(project, requiredBehaviorRenamer);
|
||||
for (std::size_t e = 0; e < project.GetEventsFunctionsExtensionsCount();
|
||||
e++) {
|
||||
auto& eventsFunctionsExtension = project.GetEventsFunctionsExtension(e);
|
||||
|
||||
for (auto&& eventsBasedBehavior :
|
||||
eventsFunctionsExtension.GetEventsBasedBehaviors()
|
||||
.GetInternalVector()) {
|
||||
for (size_t i = 0;
|
||||
i < eventsBasedBehavior->GetPropertyDescriptors().GetCount();
|
||||
i++) {
|
||||
NamedPropertyDescriptor& propertyDescriptor =
|
||||
eventsBasedBehavior->GetPropertyDescriptors().Get(i);
|
||||
std::vector<gd::String>& extraInfo = propertyDescriptor.GetExtraInfo();
|
||||
if (propertyDescriptor.GetType() == "Behavior" &&
|
||||
extraInfo.size() > 0) {
|
||||
const gd::String& requiredBehaviorType = extraInfo[0];
|
||||
if (requiredBehaviorType == oldBehaviorType) {
|
||||
extraInfo[0] = newBehaviorType;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Rename behavior in objects lists.
|
||||
auto behaviorTypeRenamer =
|
||||
gd::BehaviorTypeRenamer(oldBehaviorType, newBehaviorType);
|
||||
projectBrowser.ExposeObjects(project, behaviorTypeRenamer);
|
||||
auto behaviorTypeRenamer = gd::BehaviorTypeRenamer(
|
||||
project,
|
||||
oldBehaviorType,
|
||||
newBehaviorType);
|
||||
ExposeProjectObjects(project, behaviorTypeRenamer);
|
||||
|
||||
// Rename behavior in layout behavior shared data.
|
||||
auto sharedDataBehaviorTypeRenamer =
|
||||
gd::BehaviorsSharedDataBehaviorTypeRenamer(oldBehaviorType, newBehaviorType);
|
||||
projectBrowser.ExposeBehaviorSharedDatas(project, sharedDataBehaviorTypeRenamer);
|
||||
for (std::size_t i = 0; i < project.GetLayoutsCount(); ++i) {
|
||||
gd::Layout& layout = project.GetLayout(i);
|
||||
|
||||
for (auto& behaviorSharedDataContent : layout.GetAllBehaviorSharedData()) {
|
||||
renameBehaviorTypeInBehaviorContent(*behaviorSharedDataContent.second);
|
||||
}
|
||||
}
|
||||
|
||||
// Rename in parameters of (free/behavior) events function
|
||||
auto behaviorParameterRenamer = gd::FunctionParameterBehaviorTypeRenamer(
|
||||
oldBehaviorType, newBehaviorType);
|
||||
projectBrowser.ExposeFunctions(project, behaviorParameterRenamer);
|
||||
for (std::size_t e = 0; e < project.GetEventsFunctionsExtensionsCount();
|
||||
e++) {
|
||||
auto& eventsFunctionsExtension = project.GetEventsFunctionsExtension(e);
|
||||
for (auto&& eventsFunction : eventsFunctionsExtension.GetInternalVector()) {
|
||||
renameBehaviorTypeInParameters(*eventsFunction);
|
||||
}
|
||||
|
||||
for (auto&& eventsBasedBehavior :
|
||||
eventsFunctionsExtension.GetEventsBasedBehaviors()
|
||||
.GetInternalVector()) {
|
||||
auto& behaviorEventsFunctions = eventsBasedBehavior->GetEventsFunctions();
|
||||
for (auto&& eventsFunction :
|
||||
behaviorEventsFunctions.GetInternalVector()) {
|
||||
renameBehaviorTypeInParameters(*eventsFunction);
|
||||
}
|
||||
}
|
||||
|
||||
for (auto&& eventsBasedObject :
|
||||
eventsFunctionsExtension.GetEventsBasedObjects()
|
||||
.GetInternalVector()) {
|
||||
auto& behaviorEventsFunctions = eventsBasedObject->GetEventsFunctions();
|
||||
for (auto&& eventsFunction :
|
||||
behaviorEventsFunctions.GetInternalVector()) {
|
||||
renameBehaviorTypeInParameters(*eventsFunction);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WholeProjectRefactorer::DoRenameObject(
|
||||
gd::Project& project,
|
||||
const gd::String& oldObjectType,
|
||||
const gd::String& newObjectType,
|
||||
const gd::ProjectBrowser& projectBrowser) {
|
||||
const gd::String& newObjectType) {
|
||||
|
||||
// Rename object type in objects lists.
|
||||
auto customObjectTypeRenamer =
|
||||
gd::CustomObjectTypeRenamer(oldObjectType, newObjectType);
|
||||
projectBrowser.ExposeObjects(project, customObjectTypeRenamer);
|
||||
auto customObjectTypeRenamer = gd::CustomObjectTypeRenamer(
|
||||
project,
|
||||
oldObjectType,
|
||||
newObjectType);
|
||||
ExposeProjectObjects(project, customObjectTypeRenamer);
|
||||
|
||||
// Rename in behaviors object type.
|
||||
auto behaviorObjectTypeRenamer =
|
||||
gd::BehaviorObjectTypeRenamer(oldObjectType, newObjectType);
|
||||
projectBrowser.ExposeEventBasedBehaviors(project, behaviorObjectTypeRenamer);
|
||||
auto renameObjectTypeInParameters =
|
||||
[&oldObjectType, &newObjectType](gd::EventsFunction& eventsFunction) {
|
||||
for (auto& parameter : eventsFunction.GetParameters()) {
|
||||
if (gd::ParameterMetadata::IsObject(parameter.GetType()) &&
|
||||
parameter.GetExtraInfo() == oldObjectType) {
|
||||
parameter.SetExtraInfo(newObjectType);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Rename in parameters of (free/behavior) events function
|
||||
auto objectParameterRenamer =
|
||||
gd::FunctionParameterObjectTypeRenamer(oldObjectType, newObjectType);
|
||||
projectBrowser.ExposeFunctions(project, objectParameterRenamer);
|
||||
for (std::size_t e = 0; e < project.GetEventsFunctionsExtensionsCount();
|
||||
e++) {
|
||||
auto& eventsFunctionsExtension = project.GetEventsFunctionsExtension(e);
|
||||
|
||||
// Behavior object types
|
||||
for (auto&& eventsBasedBehavior :
|
||||
eventsFunctionsExtension.GetEventsBasedBehaviors().GetInternalVector()) {
|
||||
if (eventsBasedBehavior->GetObjectType() == oldObjectType) {
|
||||
eventsBasedBehavior->SetObjectType(newObjectType);
|
||||
}
|
||||
}
|
||||
|
||||
for (auto&& eventsFunction : eventsFunctionsExtension.GetInternalVector()) {
|
||||
renameObjectTypeInParameters(*eventsFunction);
|
||||
}
|
||||
|
||||
for (auto&& eventsBasedBehavior :
|
||||
eventsFunctionsExtension.GetEventsBasedBehaviors()
|
||||
.GetInternalVector()) {
|
||||
auto& behaviorEventsFunctions = eventsBasedBehavior->GetEventsFunctions();
|
||||
for (auto&& eventsFunction :
|
||||
behaviorEventsFunctions.GetInternalVector()) {
|
||||
renameObjectTypeInParameters(*eventsFunction);
|
||||
}
|
||||
}
|
||||
|
||||
for (auto&& eventsBasedObject :
|
||||
eventsFunctionsExtension.GetEventsBasedObjects()
|
||||
.GetInternalVector()) {
|
||||
auto& behaviorEventsFunctions = eventsBasedObject->GetEventsFunctions();
|
||||
for (auto&& eventsFunction :
|
||||
behaviorEventsFunctions.GetInternalVector()) {
|
||||
renameObjectTypeInParameters(*eventsFunction);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WholeProjectRefactorer::ObjectOrGroupRemovedInLayout(
|
||||
|
@@ -3,8 +3,8 @@
|
||||
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
|
||||
* reserved. This project is released under the MIT License.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#ifndef GDCORE_WHOLEPROJECTREFACTORER_H
|
||||
#define GDCORE_WHOLEPROJECTREFACTORER_H
|
||||
#include <set>
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
@@ -21,14 +21,10 @@ class EventsBasedBehavior;
|
||||
class EventsBasedObject;
|
||||
class ArbitraryEventsWorker;
|
||||
class ArbitraryObjectsWorker;
|
||||
class ArbitraryEventsFunctionsWorker;
|
||||
class ArbitraryEventsWorkerWithContext;
|
||||
class ArbitraryEventBasedBehaviorsWorker;
|
||||
class ArbitraryBehaviorSharedDataWorker;
|
||||
class Behavior;
|
||||
class BehaviorMetadata;
|
||||
class UnfilledRequiredBehaviorPropertyProblem;
|
||||
class ProjectBrowser;
|
||||
} // namespace gd
|
||||
|
||||
namespace gd {
|
||||
@@ -43,6 +39,54 @@ namespace gd {
|
||||
*/
|
||||
class GD_CORE_API WholeProjectRefactorer {
|
||||
public:
|
||||
/**
|
||||
* \brief Call the specified worker on all events of the project (layout,
|
||||
* external events, events functions...)
|
||||
*
|
||||
* This should be the preferred way to traverse all the events of a project.
|
||||
*/
|
||||
static void ExposeProjectEvents(gd::Project& project,
|
||||
gd::ArbitraryEventsWorker& worker);
|
||||
|
||||
/**
|
||||
* \brief Call the specified worker on all events of the project (layout,
|
||||
* external events, events functions...)
|
||||
*
|
||||
* This should be the preferred way to traverse all the events of a project.
|
||||
*/
|
||||
static void ExposeProjectEvents(gd::Project& project,
|
||||
gd::ArbitraryEventsWorkerWithContext& worker);
|
||||
|
||||
/**
|
||||
* \brief Call the specified worker on all events of the events based behavior
|
||||
*
|
||||
* This should be the preferred way to traverse all the events of an events
|
||||
* based behavior.
|
||||
*/
|
||||
static void ExposeEventsBasedBehaviorEvents(
|
||||
gd::Project& project,
|
||||
const gd::EventsBasedBehavior& eventsBasedBehavior,
|
||||
gd::ArbitraryEventsWorkerWithContext& worker);
|
||||
|
||||
/**
|
||||
* \brief Call the specified worker on all events of the events based object
|
||||
*
|
||||
* This should be the preferred way to traverse all the events of an events
|
||||
* based object.
|
||||
*/
|
||||
static void ExposeEventsBasedObjectEvents(
|
||||
gd::Project& project,
|
||||
const gd::EventsBasedObject& eventsBasedObject,
|
||||
gd::ArbitraryEventsWorkerWithContext& worker);
|
||||
|
||||
/**
|
||||
* \brief Call the specified worker on all ObjectContainers of the project
|
||||
* (global, layouts...)
|
||||
*
|
||||
* This should be the preferred way to traverse all the objects of a project.
|
||||
*/
|
||||
static void ExposeProjectObjects(gd::Project& project,
|
||||
gd::ArbitraryObjectsWorker& worker);
|
||||
|
||||
/**
|
||||
* \brief Refactor the project **before** an events function extension is
|
||||
@@ -58,16 +102,6 @@ class GD_CORE_API WholeProjectRefactorer {
|
||||
const gd::String& oldName,
|
||||
const gd::String& newName);
|
||||
|
||||
/**
|
||||
* \brief Refactor behavior events after the extension was placed in a new
|
||||
* extension.
|
||||
*/
|
||||
static void UpdateExtensionNameInEventsBasedBehavior(
|
||||
gd::Project& project,
|
||||
const gd::EventsFunctionsExtension& eventsFunctionsExtension,
|
||||
gd::EventsBasedBehavior& eventsBasedBehavior,
|
||||
const gd::String& sourceExtensionName);
|
||||
|
||||
/**
|
||||
* \brief Refactor the project **before** an events function is renamed.
|
||||
*
|
||||
@@ -405,33 +439,15 @@ class GD_CORE_API WholeProjectRefactorer {
|
||||
static void DoRenameEventsFunction(gd::Project& project,
|
||||
const gd::EventsFunction& eventsFunction,
|
||||
const gd::String& oldFullType,
|
||||
const gd::String& newFullType,
|
||||
const gd::ProjectBrowser& projectBrowser);
|
||||
const gd::String& newFullType);
|
||||
|
||||
static void DoRenameBehavior(gd::Project& project,
|
||||
const gd::String& oldBehaviorType,
|
||||
const gd::String& newBehaviorType,
|
||||
const gd::ProjectBrowser& projectBrowser);
|
||||
const gd::String& newBehaviorType);
|
||||
|
||||
static void DoRenameObject(gd::Project& project,
|
||||
const gd::String& oldObjectType,
|
||||
const gd::String& newObjectType,
|
||||
const gd::ProjectBrowser& projectBrowser);
|
||||
|
||||
/**
|
||||
* \brief 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.
|
||||
*/
|
||||
static void RenameEventsFunctionsExtension(
|
||||
gd::Project& project,
|
||||
const gd::EventsFunctionsExtension& eventsFunctionsExtension,
|
||||
const gd::String& oldName,
|
||||
const gd::String& newName,
|
||||
const gd::ProjectBrowser& projectBrowser);
|
||||
const gd::String& newObjectType);
|
||||
|
||||
static void FindDependentBehaviorNames(
|
||||
const gd::Project& project,
|
||||
@@ -446,3 +462,5 @@ class GD_CORE_API WholeProjectRefactorer {
|
||||
};
|
||||
|
||||
} // namespace gd
|
||||
|
||||
#endif // GDCORE_WHOLEPROJECTREFACTORER_H
|
||||
|
@@ -151,7 +151,6 @@ class GD_CORE_API AbstractEventsBasedEntity {
|
||||
gd::String description;
|
||||
gd::EventsFunctionsContainer eventsFunctionsContainer;
|
||||
SerializableWithNameList<NamedPropertyDescriptor> propertyDescriptors;
|
||||
gd::String extensionName;
|
||||
};
|
||||
|
||||
} // namespace gd
|
||||
|
@@ -43,10 +43,18 @@ std::map<gd::String, gd::PropertyDescriptor> CustomConfigurationHelper::GetPrope
|
||||
const auto &propertyName = property->GetName();
|
||||
const auto &propertyType = property->GetType();
|
||||
|
||||
// Copy the property
|
||||
behaviorProperties[propertyName] = *property;
|
||||
// TODO Move this into a PropertyDescriptor copy method.
|
||||
auto &newProperty = behaviorProperties[propertyName]
|
||||
.SetType(property->GetType())
|
||||
.SetDescription(property->GetDescription())
|
||||
.SetGroup(property->GetGroup())
|
||||
.SetLabel(property->GetLabel())
|
||||
.SetValue(property->GetValue())
|
||||
.SetHidden(property->IsHidden());
|
||||
|
||||
auto &newProperty = behaviorProperties[propertyName];
|
||||
for (auto &extraInfo : property->GetExtraInfo()) {
|
||||
newProperty.AddExtraInfo(extraInfo);
|
||||
}
|
||||
|
||||
if (configurationContent.HasChild(propertyName)) {
|
||||
if (propertyType == "String" || propertyType == "Choice" ||
|
||||
|
@@ -11,7 +11,7 @@
|
||||
namespace gd {
|
||||
|
||||
LoadingScreen::LoadingScreen()
|
||||
: showGDevelopLogoDuringLoadingScreen(true),
|
||||
: showGDevelopLogoDuringLoadingScreen(false),
|
||||
gdevelopLogoStyle("light"),
|
||||
backgroundImageResourceName(""),
|
||||
backgroundColor(0),
|
||||
@@ -27,18 +27,16 @@ LoadingScreen::LoadingScreen()
|
||||
progressBarColor(0xFFFFFF){};
|
||||
|
||||
void LoadingScreen::SerializeTo(SerializerElement& element) const {
|
||||
element.SetAttribute("showGDevelopSplash",
|
||||
showGDevelopLogoDuringLoadingScreen);
|
||||
element.SetAttribute("gdevelopLogoStyle", gdevelopLogoStyle);
|
||||
element.SetAttribute("showGDevelopSplash", showGDevelopLogoDuringLoadingScreen);
|
||||
element.SetAttribute("gdevelopLogoStyle",
|
||||
gdevelopLogoStyle);
|
||||
element.SetAttribute("backgroundImageResourceName",
|
||||
backgroundImageResourceName);
|
||||
element.SetAttribute("backgroundColor", backgroundColor);
|
||||
element.SetAttribute("backgroundFadeInDuration", backgroundFadeInDuration);
|
||||
element.SetAttribute("minDuration", minDuration);
|
||||
element.SetAttribute("logoAndProgressFadeInDuration",
|
||||
logoAndProgressFadeInDuration);
|
||||
element.SetAttribute("logoAndProgressLogoFadeInDelay",
|
||||
logoAndProgressLogoFadeInDelay);
|
||||
element.SetAttribute("logoAndProgressFadeInDuration", logoAndProgressFadeInDuration);
|
||||
element.SetAttribute("logoAndProgressLogoFadeInDelay", logoAndProgressLogoFadeInDelay);
|
||||
element.SetAttribute("showProgressBar", showProgressBar);
|
||||
element.SetAttribute("progressBarMinWidth", progressBarMinWidth);
|
||||
element.SetAttribute("progressBarMaxWidth", progressBarMaxWidth);
|
||||
@@ -48,24 +46,21 @@ void LoadingScreen::SerializeTo(SerializerElement& element) const {
|
||||
}
|
||||
|
||||
void LoadingScreen::UnserializeFrom(const SerializerElement& element) {
|
||||
showGDevelopLogoDuringLoadingScreen =
|
||||
element.GetBoolAttribute("showGDevelopSplash", true);
|
||||
gdevelopLogoStyle = element.GetStringAttribute("gdevelopLogoStyle", "light");
|
||||
showGDevelopLogoDuringLoadingScreen = element.GetBoolAttribute("showGDevelopSplash", true);
|
||||
gdevelopLogoStyle =
|
||||
element.GetStringAttribute("gdevelopLogoStyle", "light");
|
||||
backgroundImageResourceName =
|
||||
element.GetStringAttribute("backgroundImageResourceName");
|
||||
backgroundColor = element.GetIntAttribute("backgroundColor", 0);
|
||||
backgroundFadeInDuration =
|
||||
element.GetDoubleAttribute("backgroundFadeInDuration", 0.2);
|
||||
minDuration = element.GetDoubleAttribute("minDuration", 1.5);
|
||||
logoAndProgressFadeInDuration =
|
||||
element.GetDoubleAttribute("logoAndProgressFadeInDuration", 0.2);
|
||||
logoAndProgressLogoFadeInDelay =
|
||||
element.GetDoubleAttribute("logoAndProgressLogoFadeInDelay", 0.2);
|
||||
logoAndProgressFadeInDuration = element.GetDoubleAttribute("logoAndProgressFadeInDuration", 0.2);
|
||||
logoAndProgressLogoFadeInDelay = element.GetDoubleAttribute("logoAndProgressLogoFadeInDelay", 0.2);
|
||||
showProgressBar = element.GetBoolAttribute("showProgressBar", true);
|
||||
progressBarMinWidth = element.GetDoubleAttribute("progressBarMinWidth", 40);
|
||||
progressBarMaxWidth = element.GetDoubleAttribute("progressBarMaxWidth", 200);
|
||||
progressBarWidthPercent =
|
||||
element.GetDoubleAttribute("progressBarWidthPercent", 30);
|
||||
progressBarWidthPercent = element.GetDoubleAttribute("progressBarWidthPercent", 30);
|
||||
progressBarHeight = element.GetDoubleAttribute("progressBarHeight", 20);
|
||||
progressBarColor = element.GetIntAttribute("progressBarColor", 0xFFFFFF);
|
||||
}
|
||||
|
@@ -7,7 +7,6 @@
|
||||
#include "GDCore/Serialization/SerializerElement.h"
|
||||
#include "GDCore/String.h"
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
||||
namespace gd {
|
||||
|
||||
@@ -23,49 +22,6 @@ gd::MeasurementUnit MeasurementUnit::pixelAcceleration =
|
||||
CreatePixelAcceleration();
|
||||
gd::MeasurementUnit MeasurementUnit::newton = CreateNewton();
|
||||
gd::MeasurementUnit MeasurementUnit::angularSpeed = CreateAngularSpeed();
|
||||
std::vector<const gd::MeasurementUnit*> MeasurementUnit::defaultMeasurementUnits;
|
||||
|
||||
const std::vector<const gd::MeasurementUnit*> &
|
||||
MeasurementUnit::GetDefaultMeasurementUnits() {
|
||||
if (defaultMeasurementUnits.size() == 0) {
|
||||
defaultMeasurementUnits.push_back(&undefined);
|
||||
defaultMeasurementUnits.push_back(&dimensionless);
|
||||
defaultMeasurementUnits.push_back(°reeAngle);
|
||||
defaultMeasurementUnits.push_back(&second);
|
||||
defaultMeasurementUnits.push_back(&pixel);
|
||||
defaultMeasurementUnits.push_back(&pixelSpeed);
|
||||
defaultMeasurementUnits.push_back(&pixelAcceleration);
|
||||
defaultMeasurementUnits.push_back(&angularSpeed);
|
||||
defaultMeasurementUnits.push_back(&newton);
|
||||
}
|
||||
return defaultMeasurementUnits;
|
||||
}
|
||||
|
||||
std::size_t MeasurementUnit::GetDefaultMeasurementUnitsCount() {
|
||||
return GetDefaultMeasurementUnits().size();
|
||||
}
|
||||
|
||||
const gd::MeasurementUnit &
|
||||
MeasurementUnit::GetDefaultMeasurementUnitAtIndex(std::size_t index) {
|
||||
return *GetDefaultMeasurementUnits().at(index);
|
||||
}
|
||||
|
||||
bool MeasurementUnit::HasDefaultMeasurementUnitNamed(const gd::String &name) {
|
||||
auto units = GetDefaultMeasurementUnits();
|
||||
return std::find_if(units.begin(), units.end(),
|
||||
[name](const gd::MeasurementUnit *unit) -> bool {
|
||||
return unit->GetName() == name;
|
||||
}) != units.end();
|
||||
}
|
||||
|
||||
const gd::MeasurementUnit &
|
||||
MeasurementUnit::GetDefaultMeasurementUnitByName(const gd::String &name) {
|
||||
auto units = GetDefaultMeasurementUnits();
|
||||
return **std::find_if(units.begin(), units.end(),
|
||||
[name](const gd::MeasurementUnit *unit) -> bool {
|
||||
return unit->GetName() == name;
|
||||
});
|
||||
}
|
||||
|
||||
void MeasurementUnit::ApplyTranslation() {
|
||||
undefined = CreateUndefined();
|
||||
@@ -77,7 +33,6 @@ void MeasurementUnit::ApplyTranslation() {
|
||||
pixelAcceleration = CreatePixelAcceleration();
|
||||
newton = CreateNewton();
|
||||
angularSpeed = CreateAngularSpeed();
|
||||
defaultMeasurementUnits.clear();
|
||||
}
|
||||
|
||||
} // namespace gd
|
||||
|
@@ -74,40 +74,31 @@ public:
|
||||
return elements.at(elementIndex).GetBaseUnit();
|
||||
}
|
||||
|
||||
bool IsUndefined() const {
|
||||
return this == &gd::MeasurementUnit::undefined || name == "Undefined";
|
||||
}
|
||||
bool IsUndefined() const { return this == &gd::MeasurementUnit::undefined; }
|
||||
|
||||
static void ApplyTranslation();
|
||||
|
||||
static const gd::MeasurementUnit &GetUndefined() { return undefined; }
|
||||
static gd::MeasurementUnit &GetUndefined() { return undefined; }
|
||||
|
||||
static const gd::MeasurementUnit &GetDimensionless() { return dimensionless; }
|
||||
static gd::MeasurementUnit &GetDimensionless() { return dimensionless; }
|
||||
|
||||
static const gd::MeasurementUnit &GetDegreeAngle() { return degreeAngle; }
|
||||
static gd::MeasurementUnit &GetDegreeAngle() { return degreeAngle; }
|
||||
|
||||
static const gd::MeasurementUnit &GetSecond() { return second; }
|
||||
static gd::MeasurementUnit &GetSecond() { return second; }
|
||||
|
||||
static const gd::MeasurementUnit &GetPixel() { return pixel; }
|
||||
static gd::MeasurementUnit &GetPixel() { return pixel; }
|
||||
|
||||
static const gd::MeasurementUnit &GetPixelSpeed() { return pixelSpeed; }
|
||||
static gd::MeasurementUnit &GetPixelSpeed() { return pixelSpeed; }
|
||||
|
||||
static const gd::MeasurementUnit &GetPixelAcceleration() {
|
||||
static gd::MeasurementUnit &GetPixelAcceleration() {
|
||||
return pixelAcceleration;
|
||||
}
|
||||
|
||||
static const gd::MeasurementUnit &GetAngularSpeed() { return angularSpeed; }
|
||||
static gd::MeasurementUnit &GetAngularSpeed() { return angularSpeed; }
|
||||
|
||||
static const gd::MeasurementUnit &GetNewton() { return newton; }
|
||||
|
||||
static const std::vector<const gd::MeasurementUnit*> &GetDefaultMeasurementUnits();
|
||||
static std::size_t GetDefaultMeasurementUnitsCount();
|
||||
static const gd::MeasurementUnit &GetDefaultMeasurementUnitAtIndex(std::size_t index);
|
||||
static bool HasDefaultMeasurementUnitNamed(const gd::String &name);
|
||||
static const gd::MeasurementUnit &GetDefaultMeasurementUnitByName(const gd::String &name);
|
||||
static gd::MeasurementUnit &GetNewton() { return newton; }
|
||||
|
||||
private:
|
||||
static std::vector<const gd::MeasurementUnit*> defaultMeasurementUnits;
|
||||
static gd::MeasurementUnit undefined;
|
||||
static gd::MeasurementUnit dimensionless;
|
||||
static gd::MeasurementUnit degreeAngle;
|
||||
|
@@ -991,7 +991,7 @@ bool Project::ValidateName(const gd::String& name) {
|
||||
}
|
||||
|
||||
void Project::ExposeResources(gd::ArbitraryResourceWorker& worker) {
|
||||
// See also gd::ProjectBrowserHelper::ExposeProjectEvents for a method that
|
||||
// See also gd::WholeProjectRefactorer::ExposeProjectEvents for a method that
|
||||
// traverse the whole project (this time for events) and ExposeProjectEffects
|
||||
// (this time for effects). Ideally, this method could be moved outside of
|
||||
// gd::Project.
|
||||
|
@@ -17,9 +17,6 @@ PropertyDescriptor::~PropertyDescriptor() {}
|
||||
void PropertyDescriptor::SerializeTo(SerializerElement& element) const {
|
||||
element.AddChild("value").SetStringValue(currentValue);
|
||||
element.AddChild("type").SetStringValue(type);
|
||||
if (type == "Number" && !measurementUnit.IsUndefined()) {
|
||||
element.AddChild("unit").SetStringValue(measurementUnit.GetName());
|
||||
}
|
||||
element.AddChild("label").SetStringValue(label);
|
||||
element.AddChild("description").SetStringValue(description);
|
||||
element.AddChild("group").SetStringValue(group);
|
||||
@@ -35,14 +32,6 @@ void PropertyDescriptor::SerializeTo(SerializerElement& element) const {
|
||||
void PropertyDescriptor::UnserializeFrom(const SerializerElement& element) {
|
||||
currentValue = element.GetChild("value").GetStringValue();
|
||||
type = element.GetChild("type").GetStringValue();
|
||||
if (type == "Number") {
|
||||
gd::String unitName = element.GetChild("unit").GetStringValue();
|
||||
measurementUnit =
|
||||
gd::MeasurementUnit::HasDefaultMeasurementUnitNamed(unitName)
|
||||
? measurementUnit =
|
||||
gd::MeasurementUnit::GetDefaultMeasurementUnitByName(unitName)
|
||||
: gd::MeasurementUnit::GetUndefined();
|
||||
}
|
||||
label = element.GetChild("label").GetStringValue();
|
||||
description = element.GetChild("description").GetStringValue();
|
||||
group = element.GetChild("group").GetStringValue();
|
||||
|
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
* GDevelop Core
|
||||
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
|
||||
* reserved. This project is released under the MIT License.
|
||||
*/
|
||||
#include "GDCore/IDE/Events/InstructionsCountEvaluator.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "DummyPlatform.h"
|
||||
#include "GDCore/Events/Builtin/StandardEvent.h"
|
||||
#include "GDCore/Events/Event.h"
|
||||
#include "GDCore/Extensions/Platform.h"
|
||||
#include "GDCore/Project/Layout.h"
|
||||
#include "GDCore/Project/Project.h"
|
||||
#include "catch.hpp"
|
||||
|
||||
namespace {
|
||||
|
||||
TEST_CASE("InstructionsCountEvaluator", "[events]") {
|
||||
|
||||
SECTION("Can count 1 action in a layout") {
|
||||
gd::Project project;
|
||||
gd::Platform platform;
|
||||
SetupProjectWithDummyPlatform(project, platform);
|
||||
auto &layout1 = project.InsertNewLayout("Layout1", 0);
|
||||
|
||||
// Add an event with an action.
|
||||
gd::StandardEvent event;
|
||||
gd::Instruction instruction;
|
||||
instruction.SetType("MyExtension::DoSomething");
|
||||
instruction.SetParametersCount(1);
|
||||
event.GetActions().Insert(instruction);
|
||||
layout1.GetEvents().InsertEvent(event);
|
||||
|
||||
REQUIRE(gd::InstructionsCountEvaluator::ScanProject(project) == 1);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
@@ -15,7 +15,6 @@
|
||||
#include "GDCore/Events/Builtin/StandardEvent.h"
|
||||
#include "GDCore/Extensions/Builtin/SpriteExtension/SpriteObject.h"
|
||||
#include "GDCore/Extensions/Platform.h"
|
||||
#include "GDCore/IDE/ProjectBrowserHelper.h"
|
||||
#include "GDCore/IDE/Project/ArbitraryResourceWorker.h"
|
||||
#include "GDCore/IDE/Project/ProjectResourcesAdder.h"
|
||||
#include "GDCore/IDE/WholeProjectRefactorer.h"
|
||||
@@ -52,7 +51,7 @@ TEST_CASE("InstructionsParameterMover", "[common][events]") {
|
||||
gd::InstructionsParameterMover mover(
|
||||
project, "MyExtension::DoSomething", 0, 2);
|
||||
|
||||
gd::ProjectBrowserHelper::ExposeProjectEvents(project, mover);
|
||||
gd::WholeProjectRefactorer::ExposeProjectEvents(project, mover);
|
||||
REQUIRE(insertedInstruction.GetParameter(0).GetPlainString() == "Param2");
|
||||
REQUIRE(insertedInstruction.GetParameter(1).GetPlainString() == "Param3");
|
||||
REQUIRE(insertedInstruction.GetParameter(2).GetPlainString() == "Param1");
|
||||
@@ -61,7 +60,7 @@ TEST_CASE("InstructionsParameterMover", "[common][events]") {
|
||||
gd::InstructionsParameterMover mover(
|
||||
project, "MyExtension::DoSomething", 0, 99);
|
||||
|
||||
gd::ProjectBrowserHelper::ExposeProjectEvents(project, mover);
|
||||
gd::WholeProjectRefactorer::ExposeProjectEvents(project, mover);
|
||||
REQUIRE(insertedInstruction.GetParameter(0).GetPlainString() == "Param2");
|
||||
REQUIRE(insertedInstruction.GetParameter(1).GetPlainString() == "Param3");
|
||||
REQUIRE(insertedInstruction.GetParameter(2).GetPlainString() == "Param1");
|
||||
@@ -70,7 +69,7 @@ TEST_CASE("InstructionsParameterMover", "[common][events]") {
|
||||
gd::InstructionsParameterMover mover(
|
||||
project, "MyExtension::DoSomething", 99, 2);
|
||||
|
||||
gd::ProjectBrowserHelper::ExposeProjectEvents(project, mover);
|
||||
gd::WholeProjectRefactorer::ExposeProjectEvents(project, mover);
|
||||
REQUIRE(insertedInstruction.GetParameter(0).GetPlainString() == "Param1");
|
||||
REQUIRE(insertedInstruction.GetParameter(1).GetPlainString() == "Param2");
|
||||
REQUIRE(insertedInstruction.GetParameter(2).GetPlainString() == "Param3");
|
||||
|
@@ -30,9 +30,6 @@
|
||||
#include "GDCore/Project/Variable.h"
|
||||
#include "catch.hpp"
|
||||
|
||||
// TODO Extract test data in another file to allow to read them side by side
|
||||
// with the test cases more easily.
|
||||
|
||||
// TODO EBO Add a test where a child is removed form the EventsBasedObject
|
||||
// and check the configuration still gives access to other child configuration.
|
||||
namespace {
|
||||
@@ -112,27 +109,16 @@ const std::vector<const gd::EventsList *> GetEventsLists(gd::Project &project) {
|
||||
auto &scene = project.GetLayout("Scene").GetEvents();
|
||||
auto &externalEvents =
|
||||
project.GetExternalEvents("ExternalEvents").GetEvents();
|
||||
auto &eventsExtension = project.GetEventsFunctionsExtension("MyEventsExtension");
|
||||
auto &objectFunctionEvents =
|
||||
eventsExtension
|
||||
project.GetEventsFunctionsExtension("MyEventsExtension")
|
||||
.GetEventsBasedObjects()
|
||||
.Get("MyOtherEventsBasedObject")
|
||||
.GetEventsFunctions()
|
||||
.GetEventsFunction("MyObjectEventsFunction")
|
||||
.GetEvents();
|
||||
auto &behaviorFunctionEvents =
|
||||
eventsExtension.GetEventsBasedBehaviors()
|
||||
.Get("MyOtherEventsBasedBehavior")
|
||||
.GetEventsFunctions()
|
||||
.GetEventsFunction("MyBehaviorEventsFunction")
|
||||
.GetEvents();
|
||||
auto &freeFunctionEvents =
|
||||
eventsExtension.GetEventsFunction("MyOtherEventsFunction").GetEvents();
|
||||
eventLists.push_back(&scene);
|
||||
eventLists.push_back(&externalEvents);
|
||||
eventLists.push_back(&objectFunctionEvents);
|
||||
eventLists.push_back(&behaviorFunctionEvents);
|
||||
eventLists.push_back(&freeFunctionEvents);
|
||||
return eventLists;
|
||||
}
|
||||
|
||||
@@ -944,48 +930,6 @@ SetupProjectWithEventsFunctionExtension(gd::Project &project) {
|
||||
.SetType("Number");
|
||||
}
|
||||
|
||||
// Add another events based behavior that uses previously defined events based
|
||||
// object and behavior.
|
||||
{
|
||||
auto &eventsBasedBehavior =
|
||||
eventsExtension.GetEventsBasedBehaviors().InsertNew(
|
||||
"MyOtherEventsBasedBehavior", 0);
|
||||
eventsBasedBehavior.SetFullName("My events based behavior");
|
||||
eventsBasedBehavior.SetDescription("An events based behavior for test");
|
||||
eventsBasedBehavior.SetObjectType("MyEventsExtension::MyEventsBasedObject");
|
||||
|
||||
// Add functions, and parameters that should be there by convention.
|
||||
auto &behaviorEventsFunctions = eventsBasedBehavior.GetEventsFunctions();
|
||||
auto &behaviorAction = behaviorEventsFunctions.InsertNewEventsFunction(
|
||||
"MyBehaviorEventsFunction", 0);
|
||||
behaviorAction.GetParameters().push_back(
|
||||
gd::ParameterMetadata()
|
||||
.SetName("Object")
|
||||
.SetType("object")
|
||||
.SetExtraInfo("MyEventsExtension::MyEventsBasedObject"));
|
||||
behaviorAction.GetParameters().push_back(
|
||||
gd::ParameterMetadata()
|
||||
.SetName("Behavior")
|
||||
.SetType("behavior")
|
||||
.SetExtraInfo("MyEventsExtension::MyEventsBasedBehavior"));
|
||||
// Define the same objects as in the layout to be consistent with events.
|
||||
behaviorAction.GetParameters().push_back(
|
||||
gd::ParameterMetadata()
|
||||
.SetName("ObjectWithMyBehavior")
|
||||
.SetType("object")
|
||||
.SetExtraInfo("MyExtension::Sprite"));
|
||||
behaviorAction.GetParameters().push_back(
|
||||
gd::ParameterMetadata()
|
||||
.SetName("MyBehavior")
|
||||
.SetType("behavior")
|
||||
.SetExtraInfo("MyEventsExtension::MyEventsBasedBehavior"));
|
||||
behaviorAction.GetParameters().push_back(
|
||||
gd::ParameterMetadata()
|
||||
.SetName("MyCustomObject")
|
||||
.SetType("object")
|
||||
.SetExtraInfo("MyEventsExtension::MyEventsBasedObject"));
|
||||
}
|
||||
|
||||
// Add an other events based object that uses previously defined events based
|
||||
// object and behavior.
|
||||
{
|
||||
@@ -1057,30 +1001,6 @@ SetupProjectWithEventsFunctionExtension(gd::Project &project) {
|
||||
.SetGetterName("MyEventsFunctionExpressionAndCondition");
|
||||
}
|
||||
|
||||
// Add another free function that uses previously defined events based
|
||||
// object and behavior.
|
||||
{
|
||||
// Add functions, and parameters that should be there by convention.
|
||||
auto &action =
|
||||
eventsExtension.InsertNewEventsFunction("MyOtherEventsFunction", 0);
|
||||
// Define the same objects as in the layout to be consistent with events.
|
||||
action.GetParameters().push_back(
|
||||
gd::ParameterMetadata()
|
||||
.SetName("ObjectWithMyBehavior")
|
||||
.SetType("object")
|
||||
.SetExtraInfo("MyExtension::Sprite"));
|
||||
action.GetParameters().push_back(
|
||||
gd::ParameterMetadata()
|
||||
.SetName("MyBehavior")
|
||||
.SetType("behavior")
|
||||
.SetExtraInfo("MyEventsExtension::MyEventsBasedBehavior"));
|
||||
action.GetParameters().push_back(
|
||||
gd::ParameterMetadata()
|
||||
.SetName("MyCustomObject")
|
||||
.SetType("object")
|
||||
.SetExtraInfo("MyEventsExtension::MyEventsBasedObject"));
|
||||
}
|
||||
|
||||
// Add some usages in events
|
||||
{
|
||||
auto &layout = project.InsertNewLayout("Scene", 0);
|
||||
@@ -1110,13 +1030,6 @@ SetupProjectWithEventsFunctionExtension(gd::Project &project) {
|
||||
.GetEventsFunctions()
|
||||
.GetEventsFunction("MyObjectEventsFunction")
|
||||
.GetEvents());
|
||||
SetupEvents(eventsExtension.GetEventsBasedBehaviors()
|
||||
.Get("MyOtherEventsBasedBehavior")
|
||||
.GetEventsFunctions()
|
||||
.GetEventsFunction("MyBehaviorEventsFunction")
|
||||
.GetEvents());
|
||||
SetupEvents(eventsExtension.GetEventsFunction("MyOtherEventsFunction")
|
||||
.GetEvents());
|
||||
}
|
||||
|
||||
return eventsExtension;
|
||||
@@ -1643,50 +1556,6 @@ TEST_CASE("WholeProjectRefactorer", "[common]") {
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("Events extension renamed in instructions scoped to one behavior") {
|
||||
gd::Project project;
|
||||
gd::Platform platform;
|
||||
SetupProjectWithDummyPlatform(project, platform);
|
||||
auto &eventsExtension = SetupProjectWithEventsFunctionExtension(project);
|
||||
|
||||
// A behavior is copied from one extension to another.
|
||||
|
||||
auto &destinationExtension =
|
||||
project.InsertNewEventsFunctionsExtension("DestinationExtension", 0);
|
||||
// Add the function used by the instruction that is checked in this test.
|
||||
// When the function doesn't exist the destination extension, the
|
||||
// instruction keeps pointing to the old extension.
|
||||
destinationExtension.InsertNewEventsFunction("MyEventsFunction", 0);
|
||||
|
||||
auto &copiedBehavior =
|
||||
destinationExtension.GetEventsBasedBehaviors().InsertNew(
|
||||
"MyOtherEventsBasedBehavior", 0);
|
||||
copiedBehavior.SetFullName("My events based behavior");
|
||||
copiedBehavior.SetDescription("An events based behavior for test");
|
||||
copiedBehavior.SetObjectType("MyEventsExtension::MyEventsBasedObject");
|
||||
|
||||
// Add the copied events.
|
||||
auto &behaviorEventsFunctions = copiedBehavior.GetEventsFunctions();
|
||||
auto &behaviorAction = behaviorEventsFunctions.InsertNewEventsFunction(
|
||||
"MyBehaviorEventsFunction", 0);
|
||||
SetupEvents(behaviorAction.GetEvents());
|
||||
|
||||
gd::WholeProjectRefactorer::UpdateExtensionNameInEventsBasedBehavior(
|
||||
project, destinationExtension, copiedBehavior, "MyEventsExtension");
|
||||
|
||||
// Check that events function calls in instructions have been renamed
|
||||
REQUIRE(GetEventFirstActionType(behaviorAction.GetEvents().GetEvent(
|
||||
FreeFunctionAction)) == "DestinationExtension::MyEventsFunction");
|
||||
|
||||
for (auto *eventsList : GetEventsLists(project)) {
|
||||
// Check that events function calls in instructions have NOT been renamed
|
||||
// outside of the copied behavior.
|
||||
REQUIRE(
|
||||
GetEventFirstActionType(eventsList->GetEvent(FreeFunctionAction)) ==
|
||||
"MyEventsExtension::MyEventsFunction");
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("Events extension renamed in parameters") {
|
||||
gd::Project project;
|
||||
gd::Platform platform;
|
||||
|
@@ -75,8 +75,7 @@ module.exports = {
|
||||
)
|
||||
.getCodeExtraInformation()
|
||||
.setIncludeFile('Extensions/FileSystem/filesystemtools.js')
|
||||
.setFunctionName('gdjs.fileSystem.makeDirectory')
|
||||
.setAsyncFunctionName('gdjs.fileSystem.makeDirectoryAsync');
|
||||
.setFunctionName('gdjs.fileSystem.makeDirectory');
|
||||
|
||||
extension
|
||||
.addAction(
|
||||
@@ -128,8 +127,7 @@ module.exports = {
|
||||
)
|
||||
.getCodeExtraInformation()
|
||||
.setIncludeFile('Extensions/FileSystem/filesystemtools.js')
|
||||
.setFunctionName('gdjs.fileSystem.saveStringToFileAsync')
|
||||
.setAsyncFunctionName('gdjs.fileSystem.saveStringToFileAsyncTask');
|
||||
.setFunctionName('gdjs.fileSystem.saveStringToFileAsync');
|
||||
|
||||
extension
|
||||
.addAction(
|
||||
@@ -181,8 +179,7 @@ module.exports = {
|
||||
)
|
||||
.getCodeExtraInformation()
|
||||
.setIncludeFile('Extensions/FileSystem/filesystemtools.js')
|
||||
.setFunctionName('gdjs.fileSystem.saveVariableToJSONFileAsync')
|
||||
.setAsyncFunctionName('gdjs.fileSystem.saveVariableToJSONFileAsyncTask');
|
||||
.setFunctionName('gdjs.fileSystem.saveVariableToJSONFileAsync');
|
||||
|
||||
extension
|
||||
.addAction(
|
||||
@@ -220,8 +217,7 @@ module.exports = {
|
||||
.setDefaultValue('yes')
|
||||
.getCodeExtraInformation()
|
||||
.setIncludeFile('Extensions/FileSystem/filesystemtools.js')
|
||||
.setFunctionName('gdjs.fileSystem.loadStringFromFileAsync')
|
||||
.setAsyncFunctionName('gdjs.fileSystem.loadStringFromFileAsyncTask');
|
||||
.setFunctionName('gdjs.fileSystem.loadStringFromFileAsync');
|
||||
|
||||
extension
|
||||
.addAction(
|
||||
@@ -335,10 +331,7 @@ module.exports = {
|
||||
.setDefaultValue('yes')
|
||||
.getCodeExtraInformation()
|
||||
.setIncludeFile('Extensions/FileSystem/filesystemtools.js')
|
||||
.setFunctionName('gdjs.fileSystem.loadVariableFromJSONFileAsync')
|
||||
.setAsyncFunctionName(
|
||||
'gdjs.fileSystem.loadVariableFromJSONFileAsyncTask'
|
||||
);
|
||||
.setFunctionName('gdjs.fileSystem.loadVariableFromJSONFileAsync');
|
||||
|
||||
extension
|
||||
.addAction(
|
||||
@@ -386,8 +379,7 @@ module.exports = {
|
||||
)
|
||||
.getCodeExtraInformation()
|
||||
.setIncludeFile('Extensions/FileSystem/filesystemtools.js')
|
||||
.setFunctionName('gdjs.fileSystem.deleteFileAsync')
|
||||
.setAsyncFunctionName('gdjs.fileSystem.deleteFileAsyncTask');
|
||||
.setFunctionName('gdjs.fileSystem.deleteFileAsync');
|
||||
|
||||
extension
|
||||
.addStrExpression(
|
||||
|
@@ -2,20 +2,28 @@ namespace gdjs {
|
||||
const logger = new gdjs.Logger('Filesystem');
|
||||
export namespace fileSystem {
|
||||
// The Node.js path module, or null if it can't be loaded.
|
||||
const path: typeof import('path') | null =
|
||||
typeof require !== 'undefined' ? require('path') : null;
|
||||
export let _path: any = null;
|
||||
// The Node.js fs module, or null if it can't be loaded.
|
||||
const fs: typeof import('fs') | null =
|
||||
typeof require !== 'undefined' ? require('fs') : null;
|
||||
const asyncFs: typeof import('fs/promises') | null =
|
||||
typeof require !== 'undefined' ? require('fs/promises') : null;
|
||||
export let _fs: any = null;
|
||||
|
||||
if (!fs)
|
||||
logger.warn(
|
||||
'Filesystem is not supported on this platform! Only PC builds support filesystem access.'
|
||||
);
|
||||
/** Get the Node.js path module, or null if it can't be loaded */
|
||||
export const _getPath = function () {
|
||||
if (!_path) {
|
||||
_path = typeof require !== 'undefined' ? require('path') : null;
|
||||
}
|
||||
return _path;
|
||||
};
|
||||
|
||||
/** Get the Node.js fs module, or null if it can't be loaded */
|
||||
export const _getFs = function () {
|
||||
if (!_fs) {
|
||||
_fs = typeof require !== 'undefined' ? require('fs') : null;
|
||||
}
|
||||
return _fs;
|
||||
};
|
||||
|
||||
export const getDirectoryName = function (fileOrFolderPath: string) {
|
||||
const path = gdjs.fileSystem._getPath();
|
||||
if (!path) {
|
||||
return '';
|
||||
}
|
||||
@@ -23,6 +31,7 @@ namespace gdjs {
|
||||
};
|
||||
|
||||
export const getFileName = function (filePath: string) {
|
||||
const path = gdjs.fileSystem._getPath();
|
||||
if (!path) {
|
||||
return '';
|
||||
}
|
||||
@@ -30,6 +39,7 @@ namespace gdjs {
|
||||
};
|
||||
|
||||
export const getExtensionName = function (filePath: string) {
|
||||
const path = gdjs.fileSystem._getPath();
|
||||
if (!path) {
|
||||
return '';
|
||||
}
|
||||
@@ -124,7 +134,10 @@ namespace gdjs {
|
||||
export const getExecutableFolderPath = function (
|
||||
instanceContainer: gdjs.RuntimeInstanceContainer
|
||||
): string {
|
||||
const executablePath = getExecutablePath(instanceContainer);
|
||||
const path = gdjs.fileSystem._getPath();
|
||||
const executablePath = gdjs.fileSystem.getExecutablePath(
|
||||
instanceContainer
|
||||
);
|
||||
if (!path) {
|
||||
return '';
|
||||
}
|
||||
@@ -195,6 +208,7 @@ namespace gdjs {
|
||||
* @return The path delimiter
|
||||
*/
|
||||
export const getPathDelimiter = function (): string {
|
||||
const path = gdjs.fileSystem._getPath();
|
||||
if (path) {
|
||||
return path.sep || '/';
|
||||
} else {
|
||||
@@ -211,10 +225,11 @@ namespace gdjs {
|
||||
directory: string,
|
||||
resultVar: gdjs.Variable
|
||||
) {
|
||||
const fileSystem = gdjs.fileSystem._getFs();
|
||||
let result = 'error';
|
||||
if (fs) {
|
||||
if (fileSystem) {
|
||||
try {
|
||||
fs.mkdirSync(directory);
|
||||
fileSystem.mkdirSync(directory);
|
||||
result = 'ok';
|
||||
} catch (err) {
|
||||
logger.error(
|
||||
@@ -226,27 +241,6 @@ namespace gdjs {
|
||||
resultVar.setString(result);
|
||||
};
|
||||
|
||||
export const makeDirectoryAsync = (
|
||||
directory: string,
|
||||
resultVar: gdjs.Variable
|
||||
) =>
|
||||
asyncFs
|
||||
? new gdjs.PromiseTask(
|
||||
asyncFs
|
||||
.mkdir(directory, { recursive: true })
|
||||
.then(() => {
|
||||
resultVar.setString('ok');
|
||||
})
|
||||
.catch((err) => {
|
||||
resultVar.setString('error');
|
||||
logger.error(
|
||||
"Unable to create directory at: '" + directory + "': ",
|
||||
err
|
||||
);
|
||||
})
|
||||
)
|
||||
: (resultVar.setString('error'), new gdjs.ResolveTask());
|
||||
|
||||
/**
|
||||
* Save a string into a file, asynchronously.
|
||||
* @param text The string to be saved
|
||||
@@ -258,8 +252,9 @@ namespace gdjs {
|
||||
savePath: string,
|
||||
resultVar: gdjs.Variable
|
||||
) {
|
||||
if (fs) {
|
||||
fs.writeFile(savePath, text, 'utf8', (err) => {
|
||||
const fileSystem = gdjs.fileSystem._getFs();
|
||||
if (fileSystem) {
|
||||
fileSystem.writeFile(savePath, text, 'utf8', (err) => {
|
||||
resultVar.setString('ok');
|
||||
if (err) {
|
||||
logger.error(
|
||||
@@ -272,28 +267,6 @@ namespace gdjs {
|
||||
}
|
||||
};
|
||||
|
||||
export const saveStringToFileAsyncTask = (
|
||||
text: string,
|
||||
savePath: string,
|
||||
resultVar: gdjs.Variable
|
||||
) =>
|
||||
asyncFs
|
||||
? new gdjs.PromiseTask(
|
||||
asyncFs
|
||||
.writeFile(savePath, text, { encoding: 'utf8' })
|
||||
.then(() => {
|
||||
resultVar.setString('ok');
|
||||
})
|
||||
.catch((err) => {
|
||||
resultVar.setString('error');
|
||||
logger.error(
|
||||
"Unable to save the text to path: '" + savePath + "': ",
|
||||
err
|
||||
);
|
||||
})
|
||||
)
|
||||
: (resultVar.setString('error'), new gdjs.ResolveTask());
|
||||
|
||||
/**
|
||||
* Save a string into a file.
|
||||
* @param text The string to be saved
|
||||
@@ -305,10 +278,11 @@ namespace gdjs {
|
||||
savePath: string,
|
||||
resultVar: gdjs.Variable
|
||||
) {
|
||||
const fileSystem = gdjs.fileSystem._getFs();
|
||||
let result = 'error';
|
||||
if (fs) {
|
||||
if (fileSystem) {
|
||||
try {
|
||||
fs.writeFileSync(savePath, text, 'utf8');
|
||||
fileSystem.writeFileSync(savePath, text, 'utf8');
|
||||
result = 'ok';
|
||||
} catch (err) {
|
||||
logger.error(
|
||||
@@ -331,10 +305,11 @@ namespace gdjs {
|
||||
savePath: string,
|
||||
resultVar: gdjs.Variable
|
||||
) {
|
||||
const fileSystem = gdjs.fileSystem._getFs();
|
||||
let result = 'error';
|
||||
if (fs) {
|
||||
if (fileSystem) {
|
||||
try {
|
||||
fs.writeFileSync(
|
||||
fileSystem.writeFileSync(
|
||||
savePath,
|
||||
JSON.stringify(variable.toJSObject()),
|
||||
'utf8'
|
||||
@@ -361,8 +336,9 @@ namespace gdjs {
|
||||
savePath: string,
|
||||
resultVar: gdjs.Variable
|
||||
) {
|
||||
if (fs) {
|
||||
fs.writeFile(
|
||||
const fileSystem = gdjs.fileSystem._getFs();
|
||||
if (fileSystem) {
|
||||
fileSystem.writeFile(
|
||||
savePath,
|
||||
JSON.stringify(variable.toJSObject()),
|
||||
'utf8',
|
||||
@@ -380,30 +356,6 @@ namespace gdjs {
|
||||
}
|
||||
};
|
||||
|
||||
export const saveVariableToJSONFileAsyncTask = (
|
||||
variable: gdjs.Variable,
|
||||
savePath: string,
|
||||
resultVar: gdjs.Variable
|
||||
) =>
|
||||
asyncFs
|
||||
? new gdjs.PromiseTask(
|
||||
asyncFs
|
||||
.writeFile(savePath, JSON.stringify(variable.toJSObject()), {
|
||||
encoding: 'utf8',
|
||||
})
|
||||
.then(() => {
|
||||
resultVar.setString('ok');
|
||||
})
|
||||
.catch((err) => {
|
||||
resultVar.setString('error');
|
||||
logger.error(
|
||||
"Unable to save the text to path: '" + savePath + "': ",
|
||||
err
|
||||
);
|
||||
})
|
||||
)
|
||||
: (resultVar.setString('error'), new gdjs.ResolveTask());
|
||||
|
||||
/**
|
||||
* Load a string from a file into a scene variable.
|
||||
* @param stringVar Variable where to store the content
|
||||
@@ -417,10 +369,11 @@ namespace gdjs {
|
||||
resultVar: gdjs.Variable,
|
||||
removeCRCharacters: boolean
|
||||
) {
|
||||
const fileSystem = gdjs.fileSystem._getFs();
|
||||
let result = 'error';
|
||||
if (fs) {
|
||||
if (fileSystem) {
|
||||
try {
|
||||
const data = fs.readFileSync(loadPath, 'utf8');
|
||||
const data = fileSystem.readFileSync(loadPath, 'utf8');
|
||||
if (data) {
|
||||
stringVar.setString(
|
||||
removeCRCharacters ? data.replace(/\r/g, '') : data
|
||||
@@ -450,10 +403,11 @@ namespace gdjs {
|
||||
resultVar: gdjs.Variable,
|
||||
removeCRCharacters: boolean
|
||||
) {
|
||||
const fileSystem = gdjs.fileSystem._getFs();
|
||||
let result = 'error';
|
||||
if (fs) {
|
||||
if (fileSystem) {
|
||||
try {
|
||||
const data = fs.readFileSync(loadPath, 'utf8');
|
||||
const data = fileSystem.readFileSync(loadPath, 'utf8');
|
||||
if (data) {
|
||||
variable.fromJSON(
|
||||
removeCRCharacters ? data.replace(/\r/g, '') : data
|
||||
@@ -485,8 +439,9 @@ namespace gdjs {
|
||||
resultVar: gdjs.Variable,
|
||||
removeCRCharacters: boolean
|
||||
) {
|
||||
if (fs) {
|
||||
fs.readFile(loadPath, 'utf8', (err, data) => {
|
||||
const fileSystem = gdjs.fileSystem._getFs();
|
||||
if (fileSystem) {
|
||||
fileSystem.readFile(loadPath, 'utf8', (err, data) => {
|
||||
if (data) {
|
||||
variable.fromJSON(
|
||||
removeCRCharacters ? data.replace(/\r/g, '') : data
|
||||
@@ -506,35 +461,6 @@ namespace gdjs {
|
||||
}
|
||||
};
|
||||
|
||||
export const loadVariableFromJSONFileAsyncTask = (
|
||||
variable: gdjs.Variable,
|
||||
loadPath: string,
|
||||
resultVar: gdjs.Variable,
|
||||
removeCRCharacters: boolean
|
||||
) =>
|
||||
asyncFs
|
||||
? new gdjs.PromiseTask(
|
||||
asyncFs
|
||||
.readFile(loadPath, { encoding: 'utf8' })
|
||||
.then((data) => {
|
||||
if (data)
|
||||
variable.fromJSON(
|
||||
removeCRCharacters ? data.replace(/\r/g, '') : data
|
||||
);
|
||||
resultVar.setString('ok');
|
||||
})
|
||||
.catch((err) => {
|
||||
resultVar.setString('error');
|
||||
logger.error(
|
||||
"Unable to load the JSON file from path: '" +
|
||||
loadPath +
|
||||
"': ",
|
||||
err
|
||||
);
|
||||
})
|
||||
)
|
||||
: (resultVar.setString('error'), new gdjs.ResolveTask());
|
||||
|
||||
/**
|
||||
* Load a string from a file into a scene variable, asynchronously.
|
||||
* @param stringVar Variable where to store the content
|
||||
@@ -548,8 +474,9 @@ namespace gdjs {
|
||||
resultVar: gdjs.Variable,
|
||||
removeCRCharacters: boolean
|
||||
) {
|
||||
if (fs) {
|
||||
fs.readFile(loadPath, 'utf8', (err, data) => {
|
||||
const fileSystem = gdjs.fileSystem._getFs();
|
||||
if (fileSystem) {
|
||||
fileSystem.readFile(loadPath, 'utf8', (err, data) => {
|
||||
if (data) {
|
||||
stringVar.setString(
|
||||
removeCRCharacters ? data.replace(/\r/g, '') : data
|
||||
@@ -567,35 +494,6 @@ namespace gdjs {
|
||||
}
|
||||
};
|
||||
|
||||
export const loadStringFromFileAsyncTask = (
|
||||
variable: gdjs.Variable,
|
||||
loadPath: string,
|
||||
resultVar: gdjs.Variable,
|
||||
removeCRCharacters: boolean
|
||||
) =>
|
||||
asyncFs
|
||||
? new gdjs.PromiseTask(
|
||||
asyncFs
|
||||
.readFile(loadPath, { encoding: 'utf8' })
|
||||
.then((data) => {
|
||||
if (data)
|
||||
variable.setString(
|
||||
removeCRCharacters ? data.replace(/\r/g, '') : data
|
||||
);
|
||||
resultVar.setString('ok');
|
||||
})
|
||||
.catch((err) => {
|
||||
resultVar.setString('error');
|
||||
logger.error(
|
||||
"Unable to load the text file from path: '" +
|
||||
loadPath +
|
||||
"': ",
|
||||
err
|
||||
);
|
||||
})
|
||||
)
|
||||
: (resultVar.setString('error'), new gdjs.ResolveTask());
|
||||
|
||||
/**
|
||||
* Delete a file from the filesystem.
|
||||
* @param filePath Path to the file
|
||||
@@ -605,10 +503,11 @@ namespace gdjs {
|
||||
filePath: string,
|
||||
resultVar: gdjs.Variable
|
||||
) {
|
||||
const fileSystem = gdjs.fileSystem._getFs();
|
||||
let result = 'error';
|
||||
if (fs) {
|
||||
if (fileSystem) {
|
||||
try {
|
||||
fs.unlinkSync(filePath);
|
||||
fileSystem.unlinkSync(filePath);
|
||||
result = 'ok';
|
||||
} catch (err) {
|
||||
logger.error("Unable to delete the file: '" + filePath + "': ", err);
|
||||
@@ -627,8 +526,9 @@ namespace gdjs {
|
||||
filePath: string,
|
||||
resultVar: gdjs.Variable
|
||||
) {
|
||||
if (fs) {
|
||||
fs.unlink(filePath, (err) => {
|
||||
const fileSystem = gdjs.fileSystem._getFs();
|
||||
if (fileSystem) {
|
||||
fileSystem.unlink(filePath, (err) => {
|
||||
resultVar.setString('ok');
|
||||
if (err) {
|
||||
logger.error(
|
||||
@@ -641,35 +541,15 @@ namespace gdjs {
|
||||
}
|
||||
};
|
||||
|
||||
export const deleteFileAsyncTask = (
|
||||
filePath: string,
|
||||
resultVar: gdjs.Variable
|
||||
) =>
|
||||
asyncFs
|
||||
? new gdjs.PromiseTask(
|
||||
asyncFs
|
||||
.rm(filePath, { recursive: true })
|
||||
.then(() => {
|
||||
resultVar.setString('ok');
|
||||
})
|
||||
.catch((err) => {
|
||||
resultVar.setString('error');
|
||||
logger.error(
|
||||
"Unable to delete the file: '" + filePath + "': ",
|
||||
err
|
||||
);
|
||||
})
|
||||
)
|
||||
: (resultVar.setString('error'), new gdjs.ResolveTask());
|
||||
|
||||
/**
|
||||
* Check if the file or directory exists.
|
||||
* @param filePath The path to the file or directory
|
||||
* @return true if fhe file or directory exists
|
||||
*/
|
||||
export const pathExists = function (filePath: string): boolean {
|
||||
if (fs) {
|
||||
return fs.existsSync(filePath);
|
||||
const fileSystem = gdjs.fileSystem._getFs();
|
||||
if (fileSystem) {
|
||||
return fileSystem.existsSync(filePath);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
@@ -686,7 +686,7 @@ namespace gdjs {
|
||||
const isDev = runtimeScene
|
||||
.getGame()
|
||||
.isUsingGDevelopDevelopmentEnvironment();
|
||||
const targetUrl = `https://gd.games/games/${gameId}/leaderboard/${leaderboardId}?inGameEmbedded=true${
|
||||
const targetUrl = `https://liluo.io/games/${gameId}/leaderboard/${leaderboardId}?inGameEmbedded=true${
|
||||
isDev ? '&dev=true' : ''
|
||||
}`;
|
||||
checkLeaderboardAvailability(targetUrl).then(
|
||||
|
@@ -372,15 +372,4 @@ void ExtensionSubDeclaration3(gd::ObjectMetadata& obj) {
|
||||
_("Setup"),
|
||||
"CppPlatform/Extensions/particleSystemicon16.png")
|
||||
.AddParameter("object", _("Object"), "ParticleEmitter", false);
|
||||
|
||||
obj.AddAction("JumpEmitterForwardInTime",
|
||||
_("Jump emitter forward in time"),
|
||||
_("Simulate the passage of time for an emitter, "
|
||||
"including creating and moving particles"),
|
||||
_("Jump _PARAM0_ forward in time by _PARAM1_ seconds"),
|
||||
_("Advanced"),
|
||||
"CppPlatform/Extensions/particleSystemicon24.png",
|
||||
"CppPlatform/Extensions/particleSystemicon16.png")
|
||||
.AddParameter("object", _("Object"), "ParticleEmitter")
|
||||
.AddParameter("number", _("Seconds of time"));
|
||||
}
|
||||
|
@@ -178,8 +178,6 @@ class ParticleSystemJsExtension : public gd::PlatformExtension {
|
||||
.SetFunctionName("setTexture")
|
||||
.SetGetter("getTexture");
|
||||
conditions["ParticleSystem::Texture"].SetFunctionName("getTexture");
|
||||
actions["ParticleSystem::JumpEmitterForwardInTime"].SetFunctionName(
|
||||
"jumpEmitterForwardInTime");
|
||||
|
||||
strExpressions["Texture"].SetFunctionName("getTexture");
|
||||
expressions["CurrentParticleCount"].SetFunctionName("getParticleCount");
|
||||
|
@@ -849,10 +849,6 @@ namespace gdjs {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
jumpEmitterForwardInTime(timeSkipped: number): void {
|
||||
this._renderer.update(timeSkipped);
|
||||
}
|
||||
}
|
||||
gdjs.registerObject(
|
||||
'ParticleSystem::ParticleEmitter',
|
||||
|
@@ -34,7 +34,6 @@ namespace gdjs {
|
||||
): {
|
||||
rootContainer: HTMLDivElement;
|
||||
loaderContainer: HTMLDivElement;
|
||||
iframeContainer: HTMLDivElement;
|
||||
} {
|
||||
const rootContainer = document.createElement('div');
|
||||
rootContainer.id = 'authentication-root-container';
|
||||
@@ -46,17 +45,17 @@ namespace gdjs {
|
||||
rootContainer.style.zIndex = '2';
|
||||
rootContainer.style.pointerEvents = 'all';
|
||||
|
||||
const frameContainer = document.createElement('div');
|
||||
frameContainer.id = 'authentication-frame-container';
|
||||
frameContainer.style.backgroundColor = '#FFFFFF';
|
||||
frameContainer.style.position = 'absolute';
|
||||
frameContainer.style.top = '16px';
|
||||
frameContainer.style.bottom = '16px';
|
||||
frameContainer.style.left = '16px';
|
||||
frameContainer.style.right = '16px';
|
||||
frameContainer.style.borderRadius = '8px';
|
||||
frameContainer.style.boxShadow = '0px 4px 4px rgba(0, 0, 0, 0.25)';
|
||||
frameContainer.style.padding = '16px';
|
||||
const subContainer = document.createElement('div');
|
||||
subContainer.id = 'authentication-sub-container';
|
||||
subContainer.style.backgroundColor = '#FFFFFF';
|
||||
subContainer.style.position = 'absolute';
|
||||
subContainer.style.top = '16px';
|
||||
subContainer.style.bottom = '16px';
|
||||
subContainer.style.left = '16px';
|
||||
subContainer.style.right = '16px';
|
||||
subContainer.style.borderRadius = '8px';
|
||||
subContainer.style.boxShadow = '0px 4px 4px rgba(0, 0, 0, 0.25)';
|
||||
subContainer.style.padding = '16px';
|
||||
|
||||
const _closeContainer: HTMLDivElement = document.createElement('div');
|
||||
_closeContainer.style.cursor = 'pointer';
|
||||
@@ -107,57 +106,11 @@ namespace gdjs {
|
||||
|
||||
loaderContainer.appendChild(_loader);
|
||||
|
||||
const iframeContainer: HTMLDivElement = document.createElement('div');
|
||||
iframeContainer.style.display = 'flex';
|
||||
iframeContainer.style.flexDirection = 'column';
|
||||
iframeContainer.style.height = '100%';
|
||||
iframeContainer.style.width = '100%';
|
||||
iframeContainer.style.justifyContent = 'stretch';
|
||||
iframeContainer.style.alignItems = 'stretch';
|
||||
iframeContainer.style.display = 'none';
|
||||
subContainer.appendChild(_closeContainer);
|
||||
subContainer.appendChild(loaderContainer);
|
||||
rootContainer.appendChild(subContainer);
|
||||
|
||||
frameContainer.appendChild(_closeContainer);
|
||||
frameContainer.appendChild(loaderContainer);
|
||||
frameContainer.appendChild(iframeContainer);
|
||||
rootContainer.appendChild(frameContainer);
|
||||
|
||||
return { rootContainer, loaderContainer, iframeContainer };
|
||||
};
|
||||
|
||||
export const displayIframeInsideAuthenticationContainer = (
|
||||
iframeContainer: HTMLDivElement,
|
||||
loaderContainer: HTMLDivElement,
|
||||
textContainer: HTMLDivElement,
|
||||
url: string
|
||||
) => {
|
||||
const iframe = document.createElement('iframe');
|
||||
iframe.setAttribute(
|
||||
'sandbox',
|
||||
'allow-forms allow-modals allow-orientation-lock allow-popups allow-same-origin allow-scripts'
|
||||
);
|
||||
iframe.addEventListener('load', () => {
|
||||
iframeContainer.style.display = 'flex';
|
||||
loaderContainer.style.display = 'none';
|
||||
});
|
||||
iframe.addEventListener('loaderror', () => {
|
||||
addAuthenticationUrlToTextsContainer(() => {
|
||||
// Try again.
|
||||
iframeContainer.removeChild(iframe);
|
||||
iframeContainer.style.display = 'none';
|
||||
loaderContainer.style.display = 'flex';
|
||||
displayIframeInsideAuthenticationContainer(
|
||||
iframeContainer,
|
||||
loaderContainer,
|
||||
textContainer,
|
||||
url
|
||||
);
|
||||
}, textContainer);
|
||||
});
|
||||
iframe.src = url;
|
||||
iframe.style.flex = '1';
|
||||
iframe.style.border = '0';
|
||||
|
||||
iframeContainer.appendChild(iframe);
|
||||
return { rootContainer, loaderContainer };
|
||||
};
|
||||
|
||||
/**
|
||||
|
@@ -18,7 +18,6 @@ namespace gdjs {
|
||||
let _authenticationInAppWindow: Window | null = null; // For Cordova.
|
||||
let _authenticationRootContainer: HTMLDivElement | null = null;
|
||||
let _authenticationLoaderContainer: HTMLDivElement | null = null;
|
||||
let _authenticationIframeContainer: HTMLDivElement | null = null;
|
||||
let _authenticationTextContainer: HTMLDivElement | null = null;
|
||||
let _authenticationBanner: HTMLDivElement | null = null;
|
||||
let _initialAuthenticationTimeoutId: NodeJS.Timeout | null = null;
|
||||
@@ -39,12 +38,12 @@ namespace gdjs {
|
||||
});
|
||||
|
||||
// If the extension is used, register an eventlistener to know if the user is
|
||||
// logged in while playing the game on GDevelop games platform.
|
||||
// logged in while playing the game on Liluo.io.
|
||||
// Then send a message to the parent iframe to say that the player auth is ready.
|
||||
gdjs.registerFirstRuntimeSceneLoadedCallback(
|
||||
(runtimeScene: RuntimeScene) => {
|
||||
if (getPlatform(runtimeScene) !== 'web') {
|
||||
// Automatic authentication is only valid when the game is hosted on GDevelop games platform.
|
||||
// Automatic authentication is only valid when the game is hosted in Liluo.io.
|
||||
return;
|
||||
}
|
||||
removeAuthenticationCallbacks(); // Remove any callback that could have been registered before.
|
||||
@@ -65,9 +64,9 @@ namespace gdjs {
|
||||
{
|
||||
id: 'playerAuthReady',
|
||||
},
|
||||
'*' // We could restrict to GDevelop games platform but it's not necessary as the message is not sensitive, and it allows easy debugging.
|
||||
'*' // We could restrict to liluo.io but it's not necessary as the message is not sensitive, and it allows easy debugging.
|
||||
);
|
||||
// If no answer after 3 seconds, assume that the game is not embedded in GDevelop games platform, and remove the listener.
|
||||
// If no answer after 3 seconds, assume that the game is not embedded in Liluo.io, and remove the listener.
|
||||
_initialAuthenticationTimeoutId = setTimeout(() => {
|
||||
logger.info('Removing initial authentication listener.');
|
||||
removeAuthenticationCallbacks();
|
||||
@@ -86,16 +85,12 @@ namespace gdjs {
|
||||
runtimeGame: gdjs.RuntimeGame;
|
||||
gameId: string;
|
||||
connectionId?: string;
|
||||
}) => {
|
||||
// Uncomment to test the case of a failing loading:
|
||||
// return 'https://gd.games.wronglink';
|
||||
|
||||
return `https://gd.games/auth?gameId=${gameId}${
|
||||
}) =>
|
||||
`https://liluo.io/auth?gameId=${gameId}${
|
||||
connectionId ? `&connectionId=${connectionId}` : ''
|
||||
}${
|
||||
runtimeGame.isUsingGDevelopDevelopmentEnvironment() ? '&dev=true' : ''
|
||||
}`;
|
||||
};
|
||||
|
||||
/**
|
||||
* Helper returning the platform.
|
||||
@@ -103,31 +98,14 @@ namespace gdjs {
|
||||
const getPlatform = (
|
||||
runtimeScene: RuntimeScene
|
||||
): 'electron' | 'cordova' | 'web' => {
|
||||
const runtimeGame = runtimeScene.getGame();
|
||||
const electron = runtimeGame.getRenderer().getElectron();
|
||||
const electron = runtimeScene.getGame().getRenderer().getElectron();
|
||||
if (electron) {
|
||||
return 'electron';
|
||||
}
|
||||
if (typeof cordova !== 'undefined') return 'cordova';
|
||||
|
||||
return 'web';
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if, in some exceptional cases, we allow authentication
|
||||
* to be done through a iframe.
|
||||
* This is usually discouraged as the user can't verify that the authentication
|
||||
* window is a genuine one. It's only to be used in trusted contexts.
|
||||
*/
|
||||
const shouldAuthenticationUseIframe = (runtimeScene: RuntimeScene) => {
|
||||
const runtimeGameOptions = runtimeScene.getGame().getAdditionalOptions();
|
||||
return (
|
||||
runtimeGameOptions &&
|
||||
runtimeGameOptions.isPreview &&
|
||||
runtimeGameOptions.allowAuthenticationUsingIframeForPreview
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns true if a user token is present in the local storage.
|
||||
*/
|
||||
@@ -531,7 +509,7 @@ namespace gdjs {
|
||||
|
||||
/**
|
||||
* Helper to recompute the authentication banner.
|
||||
* This is useful if the user is already logged on GDevelop games platform
|
||||
* This is useful if the user is already logged in on Liluo.io
|
||||
* and we want to display the banner with the username.
|
||||
*/
|
||||
const refreshAuthenticationBannerIfAny = function (
|
||||
@@ -707,47 +685,6 @@ namespace gdjs {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Helper to handle authentication iframe on web.
|
||||
* We open an iframe, and listen to messages posted back to the game window.
|
||||
*/
|
||||
const openAuthenticationIframeForWeb = (
|
||||
runtimeScene: gdjs.RuntimeScene,
|
||||
gameId: string
|
||||
) => {
|
||||
if (
|
||||
!_authenticationIframeContainer ||
|
||||
!_authenticationLoaderContainer ||
|
||||
!_authenticationTextContainer
|
||||
) {
|
||||
console.error(
|
||||
"Can't open an authentication iframe - no iframe container, loader container or text container was opened for it."
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
const targetUrl = getAuthWindowUrl({
|
||||
runtimeGame: runtimeScene.getGame(),
|
||||
gameId,
|
||||
});
|
||||
|
||||
// Listen to messages posted by the authentication window, so that we can
|
||||
// know when the user is authenticated.
|
||||
_authenticationMessageCallback = (event: MessageEvent) => {
|
||||
receiveAuthenticationMessage(runtimeScene, event, {
|
||||
checkOrigin: true,
|
||||
});
|
||||
};
|
||||
window.addEventListener('message', _authenticationMessageCallback, true);
|
||||
|
||||
authComponents.displayIframeInsideAuthenticationContainer(
|
||||
_authenticationIframeContainer,
|
||||
_authenticationLoaderContainer,
|
||||
_authenticationTextContainer,
|
||||
targetUrl
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Action to display the authentication window to the user.
|
||||
*/
|
||||
@@ -788,13 +725,11 @@ namespace gdjs {
|
||||
const {
|
||||
rootContainer,
|
||||
loaderContainer,
|
||||
iframeContainer,
|
||||
} = authComponents.computeAuthenticationContainer(
|
||||
onAuthenticationContainerDismissed
|
||||
);
|
||||
_authenticationRootContainer = rootContainer;
|
||||
_authenticationLoaderContainer = loaderContainer;
|
||||
_authenticationIframeContainer = iframeContainer;
|
||||
|
||||
// Display the authentication window right away, to show a loader
|
||||
// while the call for game registration is happening.
|
||||
@@ -834,11 +769,7 @@ namespace gdjs {
|
||||
break;
|
||||
case 'web':
|
||||
default:
|
||||
if (shouldAuthenticationUseIframe(runtimeScene)) {
|
||||
openAuthenticationIframeForWeb(runtimeScene, _gameId);
|
||||
} else {
|
||||
openAuthenticationWindowForWeb(runtimeScene, _gameId);
|
||||
}
|
||||
openAuthenticationWindowForWeb(runtimeScene, _gameId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -884,7 +815,6 @@ namespace gdjs {
|
||||
|
||||
_authenticationRootContainer = null;
|
||||
_authenticationLoaderContainer = null;
|
||||
_authenticationIframeContainer = null;
|
||||
_authenticationTextContainer = null;
|
||||
};
|
||||
|
||||
|
@@ -722,7 +722,7 @@ void DeclarePrimitiveDrawingExtension(gd::PlatformExtension& extension) {
|
||||
_("Center of rotation"),
|
||||
_("Change the center of rotation of an object relatively to the "
|
||||
"object origin."),
|
||||
_("Change the center of rotation of _PARAM0_ to _PARAM1_, _PARAM2_"),
|
||||
_("Change the center of rotation of _PARAM0_: _PARAM1_; _PARAM2_"),
|
||||
_("Angle"),
|
||||
"res/actions/position24_black.png",
|
||||
"res/actions/position_black.png")
|
||||
|
@@ -474,7 +474,7 @@ namespace gdjs {
|
||||
/**
|
||||
* The center of rotation is defined relatively
|
||||
* to the drawing origin (the object position).
|
||||
* This avoids the center to move on the drawing
|
||||
* This avoid the center to move on the drawing
|
||||
* when new shapes push the bounds.
|
||||
*
|
||||
* When no custom center is defined, it will move
|
||||
|
@@ -45,10 +45,6 @@ namespace gdjs {
|
||||
private _basisTransformation: gdjs.TopDownMovementRuntimeBehavior.BasisTransformation | null;
|
||||
private _temporaryPointForTransformations: FloatPoint = [0, 0];
|
||||
|
||||
private _topDownMovementHooks: Array<
|
||||
gdjs.TopDownMovementRuntimeBehavior.TopDownMovementHook
|
||||
> = [];
|
||||
|
||||
constructor(
|
||||
instanceContainer: gdjs.RuntimeInstanceContainer,
|
||||
behaviorData,
|
||||
@@ -339,17 +335,6 @@ namespace gdjs {
|
||||
}
|
||||
}
|
||||
|
||||
const hookContext =
|
||||
gdjs.TopDownMovementRuntimeBehavior._topDownMovementHookContext;
|
||||
for (const topDownMovementHook of this._topDownMovementHooks) {
|
||||
hookContext._setDirection(direction);
|
||||
direction = topDownMovementHook.overrideDirection(hookContext);
|
||||
}
|
||||
hookContext._setDirection(direction);
|
||||
for (const topDownMovementHook of this._topDownMovementHooks) {
|
||||
topDownMovementHook.beforeSpeedUpdate(hookContext);
|
||||
}
|
||||
|
||||
const object = this.owner;
|
||||
const timeDelta = this.owner.getElapsedTime() / 1000;
|
||||
const previousVelocityX = this._xVelocity;
|
||||
@@ -434,10 +419,6 @@ namespace gdjs {
|
||||
// No acceleration for angular speed for now.
|
||||
this._angularSpeed = this._angularMaxSpeed;
|
||||
|
||||
for (const topDownMovementHook of this._topDownMovementHooks) {
|
||||
topDownMovementHook.beforePositionUpdate(hookContext);
|
||||
}
|
||||
|
||||
// Position object.
|
||||
// This is a Verlet integration considering the acceleration as constant.
|
||||
// If you expand deltaX or deltaY, it gives, thanks to the usage of both
|
||||
@@ -542,68 +523,8 @@ namespace gdjs {
|
||||
getLastStickInputAngle() {
|
||||
return this._stickAngle;
|
||||
}
|
||||
|
||||
/**
|
||||
* A hook must typically be registered by a behavior that requires this one
|
||||
* in its onCreate function.
|
||||
* The hook must stay forever to avoid side effects like a hooks order
|
||||
* change. To handle deactivated behavior, the hook can check that its
|
||||
* behavior is activated before doing anything.
|
||||
*/
|
||||
registerHook(
|
||||
hook: gdjs.TopDownMovementRuntimeBehavior.TopDownMovementHook
|
||||
) {
|
||||
this._topDownMovementHooks.push(hook);
|
||||
}
|
||||
}
|
||||
|
||||
export namespace TopDownMovementRuntimeBehavior {
|
||||
export class TopDownMovementHookContext {
|
||||
private direction: integer = -1;
|
||||
|
||||
/**
|
||||
* @returns The movement direction from 0 for left to 7 for up-left and
|
||||
* -1 for no direction.
|
||||
*/
|
||||
getDirection(): integer {
|
||||
return this.direction;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method won't change the direction used by the top-down movement
|
||||
* behavior.
|
||||
*/
|
||||
_setDirection(direction: integer): void {
|
||||
this.direction = direction;
|
||||
}
|
||||
}
|
||||
|
||||
// This should be a static attribute but it's not possible because of
|
||||
// declaration order.
|
||||
export const _topDownMovementHookContext = new gdjs.TopDownMovementRuntimeBehavior.TopDownMovementHookContext();
|
||||
|
||||
/**
|
||||
* Allow extensions relying on the top-down movement to customize its
|
||||
* behavior a bit.
|
||||
*/
|
||||
export interface TopDownMovementHook {
|
||||
/**
|
||||
* Return the direction to use instead of the direction given in
|
||||
* parameter.
|
||||
*/
|
||||
overrideDirection(hookContext: TopDownMovementHookContext): integer;
|
||||
/**
|
||||
* Called before the acceleration and new direction is applied to the
|
||||
* velocity.
|
||||
*/
|
||||
beforeSpeedUpdate(hookContext: TopDownMovementHookContext): void;
|
||||
/**
|
||||
* Called before the velocity is applied to the object position and
|
||||
* angle.
|
||||
*/
|
||||
beforePositionUpdate(hookContext: TopDownMovementHookContext): void;
|
||||
}
|
||||
|
||||
export interface BasisTransformation {
|
||||
toScreen(worldPoint: FloatPoint, screenPoint: FloatPoint): void;
|
||||
}
|
||||
|
@@ -855,9 +855,9 @@ module.exports = {
|
||||
.addParameter('expression', _('To Hue'), '', false)
|
||||
.addParameter('yesorno', _('Animate Hue'), '', false)
|
||||
.setDefaultValue('yes')
|
||||
.addParameter('expression', _('To Saturation (0 to 100, -1 to ignore)'), '', false)
|
||||
.addParameter('expression', _('To Saturation (-1 to ignore)'), '', false)
|
||||
.setDefaultValue('-1')
|
||||
.addParameter('expression', _('To Lightness (0 to 100, -1 to ignore)'), '', false)
|
||||
.addParameter('expression', _('To Lightness (-1 to ignore)'), '', false)
|
||||
.setDefaultValue('-1')
|
||||
.addParameter('stringWithSelector', _('Easing'), easingChoices, false)
|
||||
.setDefaultValue('linear')
|
||||
|
@@ -197,9 +197,6 @@ BaseObjectExtension::BaseObjectExtension() {
|
||||
objectActions["SetEffectBooleanParameter"]
|
||||
.SetFunctionName("setEffectBooleanParameter")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectActions["SetIncludedInParentCollisionMask"]
|
||||
.SetFunctionName("setIncludedInParentCollisionMask")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
|
||||
objectExpressions["X"].SetFunctionName("getX");
|
||||
objectExpressions["Y"].SetFunctionName("getY");
|
||||
|
@@ -190,8 +190,6 @@ bool ExporterHelper::ExportProjectForPixiPreview(
|
||||
runtimeGameOptions.AddChild("gdevelopResourceToken")
|
||||
.SetStringValue(options.gdevelopResourceToken);
|
||||
}
|
||||
runtimeGameOptions.AddChild("allowAuthenticationUsingIframeForPreview")
|
||||
.SetBoolValue(options.allowAuthenticationUsingIframeForPreview);
|
||||
|
||||
// Pass in the options the list of scripts files - useful for hot-reloading.
|
||||
auto &scriptFilesElement = runtimeGameOptions.AddChild("scriptFiles");
|
||||
@@ -591,9 +589,8 @@ void ExporterHelper::AddLibsInclude(bool pixiRenderers,
|
||||
InsertUnique(includesFiles, "runtimescene.js");
|
||||
InsertUnique(includesFiles, "scenestack.js");
|
||||
InsertUnique(includesFiles, "force.js");
|
||||
InsertUnique(includesFiles, "RuntimeLayer.js");
|
||||
InsertUnique(includesFiles, "layer.js");
|
||||
InsertUnique(includesFiles, "RuntimeCustomObjectLayer.js");
|
||||
InsertUnique(includesFiles, "RuntimeSceneLayer.js");
|
||||
InsertUnique(includesFiles, "timer.js");
|
||||
InsertUnique(includesFiles, "runtimewatermark.js");
|
||||
InsertUnique(includesFiles, "runtimegame.js");
|
||||
|
@@ -40,8 +40,7 @@ struct PreviewExportOptions {
|
||||
isDevelopmentEnvironment(false),
|
||||
nonRuntimeScriptsCacheBurst(0),
|
||||
fallbackAuthorId(""),
|
||||
fallbackAuthorUsername(""),
|
||||
allowAuthenticationUsingIframeForPreview(false){};
|
||||
fallbackAuthorUsername(""){};
|
||||
|
||||
/**
|
||||
* \brief Set the address of the debugger server that the game should reach
|
||||
@@ -161,20 +160,6 @@ struct PreviewExportOptions {
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set if, in some exceptional cases, we allow authentication
|
||||
* to be done through a iframe.
|
||||
* This is usually discouraged as the user can't verify that the
|
||||
* authentication window is a genuine one. It's only to be used in trusted
|
||||
* contexts.
|
||||
*/
|
||||
PreviewExportOptions &SetAllowAuthenticationUsingIframeForPreview(
|
||||
bool allowAuthenticationUsingIframeForPreview_) {
|
||||
allowAuthenticationUsingIframeForPreview =
|
||||
allowAuthenticationUsingIframeForPreview_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
gd::Project &project;
|
||||
gd::String exportPath;
|
||||
gd::String websocketDebuggerServerAddress;
|
||||
@@ -191,7 +176,6 @@ struct PreviewExportOptions {
|
||||
unsigned int nonRuntimeScriptsCacheBurst;
|
||||
gd::String electronRemoteRequirePath;
|
||||
gd::String gdevelopResourceToken;
|
||||
bool allowAuthenticationUsingIframeForPreview;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@@ -27,15 +27,11 @@ namespace gdjs {
|
||||
_untransformedHitBoxes: gdjs.Polygon[] = [];
|
||||
/** The dimension of this object is calculated from its children AABBs. */
|
||||
_unrotatedAABB: AABB = { min: [0, 0], max: [0, 0] };
|
||||
_scaleX: float = 1;
|
||||
_scaleY: float = 1;
|
||||
_scaleX: number = 1;
|
||||
_scaleY: number = 1;
|
||||
_flippedX: boolean = false;
|
||||
_flippedY: boolean = false;
|
||||
opacity: float = 255;
|
||||
_customCenter: FloatPoint | null = null;
|
||||
_localTransformation: gdjs.AffineTransformation = new gdjs.AffineTransformation();
|
||||
_localInverseTransformation: gdjs.AffineTransformation = new gdjs.AffineTransformation();
|
||||
_isLocalTransformationDirty: boolean = true;
|
||||
|
||||
/**
|
||||
* @param parent The container the object belongs to
|
||||
@@ -153,9 +149,8 @@ namespace gdjs {
|
||||
this._updateUntransformedHitBoxes();
|
||||
}
|
||||
|
||||
// Update the current hitboxes with the frame custom hit boxes
|
||||
// and apply transformations.
|
||||
const localTransformation = this.getLocalTransformation();
|
||||
//Update the current hitboxes with the frame custom hit boxes
|
||||
//and apply transformations.
|
||||
for (let i = 0; i < this._untransformedHitBoxes.length; ++i) {
|
||||
if (i >= this.hitBoxes.length) {
|
||||
this.hitBoxes.push(new gdjs.Polygon());
|
||||
@@ -168,8 +163,9 @@ namespace gdjs {
|
||||
if (j >= this.hitBoxes[i].vertices.length) {
|
||||
this.hitBoxes[i].vertices.push([0, 0]);
|
||||
}
|
||||
localTransformation.transform(
|
||||
this._untransformedHitBoxes[i].vertices[j],
|
||||
this.applyObjectTransformation(
|
||||
this._untransformedHitBoxes[i].vertices[j][0],
|
||||
this._untransformedHitBoxes[i].vertices[j][1],
|
||||
this.hitBoxes[i].vertices[j]
|
||||
);
|
||||
}
|
||||
@@ -185,6 +181,11 @@ namespace gdjs {
|
||||
_updateUntransformedHitBoxes() {
|
||||
this._isUntransformedHitBoxesDirty = false;
|
||||
|
||||
const oldUnrotatedMinX = this._unrotatedAABB.min[0];
|
||||
const oldUnrotatedMinY = this._unrotatedAABB.min[1];
|
||||
const oldUnrotatedMaxX = this._unrotatedAABB.max[0];
|
||||
const oldUnrotatedMaxY = this._unrotatedAABB.max[1];
|
||||
|
||||
this._untransformedHitBoxes.length = 0;
|
||||
if (this._instanceContainer.getAdhocListOfAllInstances().length === 0) {
|
||||
this._unrotatedAABB.min[0] = 0;
|
||||
@@ -197,9 +198,6 @@ namespace gdjs {
|
||||
let maxX = -Number.MAX_VALUE;
|
||||
let maxY = -Number.MAX_VALUE;
|
||||
for (const childInstance of this._instanceContainer.getAdhocListOfAllInstances()) {
|
||||
if (!childInstance.isIncludedInParentCollisionMask()) {
|
||||
continue;
|
||||
}
|
||||
Array.prototype.push.apply(
|
||||
this._untransformedHitBoxes,
|
||||
childInstance.getHitBoxes()
|
||||
@@ -220,6 +218,20 @@ namespace gdjs {
|
||||
}
|
||||
this.hitBoxes.length = this._untransformedHitBoxes.length;
|
||||
}
|
||||
|
||||
// The default camera center depends on the object dimensions so checking
|
||||
// the AABB center is not enough.
|
||||
if (
|
||||
this._unrotatedAABB.min[0] !== oldUnrotatedMinX ||
|
||||
this._unrotatedAABB.min[1] !== oldUnrotatedMinY ||
|
||||
this._unrotatedAABB.max[0] !== oldUnrotatedMaxX ||
|
||||
this._unrotatedAABB.max[1] !== oldUnrotatedMaxY
|
||||
) {
|
||||
this._instanceContainer.onObjectUnscaledCenterChanged(
|
||||
(oldUnrotatedMinX + oldUnrotatedMaxX) / 2,
|
||||
(oldUnrotatedMinY + oldUnrotatedMaxY) / 2
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Position:
|
||||
@@ -234,52 +246,37 @@ namespace gdjs {
|
||||
* @param result Array that will be updated with the result
|
||||
* (x and y position of the point in parent coordinates).
|
||||
*/
|
||||
applyObjectTransformation(x: float, y: float, destination: FloatPoint) {
|
||||
const source = destination;
|
||||
source[0] = x;
|
||||
source[1] = y;
|
||||
this.getLocalTransformation().transform(source, destination);
|
||||
}
|
||||
applyObjectTransformation(x: float, y: float, result: number[]) {
|
||||
let cx = this.getCenterX();
|
||||
let cy = this.getCenterY();
|
||||
|
||||
/**
|
||||
* Return the affine transformation that represents
|
||||
* flipping, scale, rotation and translation of the object.
|
||||
* @returns the affine transformation.
|
||||
*/
|
||||
getLocalTransformation(): gdjs.AffineTransformation {
|
||||
if (this._isLocalTransformationDirty) {
|
||||
this._updateLocalTransformation();
|
||||
}
|
||||
return this._localTransformation;
|
||||
}
|
||||
|
||||
getLocalInverseTransformation(): gdjs.AffineTransformation {
|
||||
if (this._isLocalTransformationDirty) {
|
||||
this._updateLocalTransformation();
|
||||
}
|
||||
return this._localInverseTransformation;
|
||||
}
|
||||
|
||||
_updateLocalTransformation() {
|
||||
const absScaleX = Math.abs(this._scaleX);
|
||||
const absScaleY = Math.abs(this._scaleY);
|
||||
const centerX = this.getUnscaledCenterX() * absScaleX;
|
||||
const centerY = this.getUnscaledCenterY() * absScaleY;
|
||||
const angleInRadians = (this.angle * Math.PI) / 180;
|
||||
|
||||
this._localTransformation.setToTranslation(this.x, this.y);
|
||||
this._localTransformation.rotateAround(angleInRadians, centerX, centerY);
|
||||
// Flipping
|
||||
if (this._flippedX) {
|
||||
this._localTransformation.flipX(centerX);
|
||||
x = x + (cx - x) * 2;
|
||||
}
|
||||
if (this._flippedY) {
|
||||
this._localTransformation.flipY(centerY);
|
||||
y = y + (cy - y) * 2;
|
||||
}
|
||||
this._localTransformation.scale(absScaleX, absScaleY);
|
||||
|
||||
this._localInverseTransformation.copyFrom(this._localTransformation);
|
||||
this._localInverseTransformation.invert();
|
||||
this._isLocalTransformationDirty = false;
|
||||
// Scale
|
||||
const absScaleX = Math.abs(this._scaleX);
|
||||
const absScaleY = Math.abs(this._scaleY);
|
||||
x *= absScaleX;
|
||||
y *= absScaleY;
|
||||
cx *= absScaleX;
|
||||
cy *= absScaleY;
|
||||
|
||||
// Rotation
|
||||
const angleInRadians = (this.angle / 180) * Math.PI;
|
||||
const cosValue = Math.cos(angleInRadians);
|
||||
const sinValue = Math.sin(angleInRadians);
|
||||
const xToCenterXDelta = x - cx;
|
||||
const yToCenterYDelta = y - cy;
|
||||
x = cx + cosValue * xToCenterXDelta - sinValue * yToCenterYDelta;
|
||||
y = cy + sinValue * xToCenterXDelta + cosValue * yToCenterYDelta;
|
||||
result.length = 2;
|
||||
result[0] = x + this.x;
|
||||
result[1] = y + this.y;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -293,51 +290,53 @@ namespace gdjs {
|
||||
* @param result Array that will be updated with the result
|
||||
* (x and y position of the point in object coordinates).
|
||||
*/
|
||||
applyObjectInverseTransformation(
|
||||
x: float,
|
||||
y: float,
|
||||
destination: FloatPoint
|
||||
) {
|
||||
const source = destination;
|
||||
source[0] = x;
|
||||
source[1] = y;
|
||||
this.getLocalInverseTransformation().transform(source, destination);
|
||||
applyObjectInverseTransformation(x: float, y: float, result: number[]) {
|
||||
x -= this.getCenterXInScene();
|
||||
y -= this.getCenterYInScene();
|
||||
|
||||
const absScaleX = Math.abs(this._scaleX);
|
||||
const absScaleY = Math.abs(this._scaleY);
|
||||
|
||||
// Rotation
|
||||
const angleInRadians = (this.angle / 180) * Math.PI;
|
||||
const cosValue = Math.cos(-angleInRadians);
|
||||
const sinValue = Math.sin(-angleInRadians);
|
||||
const oldX = x;
|
||||
x = cosValue * x - sinValue * y;
|
||||
y = sinValue * oldX + cosValue * y;
|
||||
|
||||
// Scale
|
||||
x /= absScaleX;
|
||||
y /= absScaleY;
|
||||
|
||||
// Flipping
|
||||
if (this._flippedX) {
|
||||
x = -x;
|
||||
}
|
||||
if (this._flippedY) {
|
||||
y = -y;
|
||||
}
|
||||
|
||||
const positionToCenterX =
|
||||
this.getUnscaledWidth() / 2 + this._unrotatedAABB.min[0];
|
||||
const positionToCenterY =
|
||||
this.getUnscaledHeight() / 2 + this._unrotatedAABB.min[1];
|
||||
result[0] = x + positionToCenterX;
|
||||
result[1] = y + positionToCenterY;
|
||||
}
|
||||
|
||||
getDrawableX(): float {
|
||||
if (this._isUntransformedHitBoxesDirty) {
|
||||
this._updateUntransformedHitBoxes();
|
||||
}
|
||||
const absScaleX = this.getScaleX();
|
||||
if (!this._flippedX) {
|
||||
return this.x + this._unrotatedAABB.min[0] * absScaleX;
|
||||
} else {
|
||||
return (
|
||||
this.x +
|
||||
(-this._unrotatedAABB.min[0] -
|
||||
this.getUnscaledWidth() +
|
||||
2 * this.getUnscaledCenterX()) *
|
||||
absScaleX
|
||||
);
|
||||
}
|
||||
return this.x + this._unrotatedAABB.min[0] * this._scaleX;
|
||||
}
|
||||
|
||||
getDrawableY(): float {
|
||||
if (this._isUntransformedHitBoxesDirty) {
|
||||
this._updateUntransformedHitBoxes();
|
||||
}
|
||||
const absScaleY = this.getScaleY();
|
||||
if (!this._flippedY) {
|
||||
return this.y + this._unrotatedAABB.min[1] * absScaleY;
|
||||
} else {
|
||||
return (
|
||||
this.y +
|
||||
(-this._unrotatedAABB.min[1] -
|
||||
this.getUnscaledHeight() +
|
||||
2 * this.getUnscaledCenterY()) *
|
||||
absScaleY
|
||||
);
|
||||
}
|
||||
return this.y + this._unrotatedAABB.min[1] * this._scaleY;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -364,9 +363,6 @@ namespace gdjs {
|
||||
* @returns the center X from the local origin (0;0).
|
||||
*/
|
||||
getUnscaledCenterX(): float {
|
||||
if (this._customCenter) {
|
||||
return this._customCenter[0];
|
||||
}
|
||||
if (this._isUntransformedHitBoxesDirty) {
|
||||
this._updateUntransformedHitBoxes();
|
||||
}
|
||||
@@ -377,57 +373,12 @@ namespace gdjs {
|
||||
* @returns the center Y from the local origin (0;0).
|
||||
*/
|
||||
getUnscaledCenterY(): float {
|
||||
if (this._customCenter) {
|
||||
return this._customCenter[1];
|
||||
}
|
||||
if (this._isUntransformedHitBoxesDirty) {
|
||||
this._updateUntransformedHitBoxes();
|
||||
}
|
||||
return (this._unrotatedAABB.min[1] + this._unrotatedAABB.max[1]) / 2;
|
||||
}
|
||||
|
||||
/**
|
||||
* The center of rotation is defined relatively to the origin (the object
|
||||
* position).
|
||||
* This avoids the center to move when children push the bounds.
|
||||
*
|
||||
* When no custom center is defined, it will move
|
||||
* to stay at the center of the children bounds.
|
||||
*
|
||||
* @param x coordinate of the custom center
|
||||
* @param y coordinate of the custom center
|
||||
*/
|
||||
setRotationCenter(x: float, y: float) {
|
||||
if (!this._customCenter) {
|
||||
this._customCenter = [0, 0];
|
||||
}
|
||||
this._customCenter[0] = x;
|
||||
this._customCenter[1] = y;
|
||||
|
||||
this._isLocalTransformationDirty = true;
|
||||
this.invalidateHitboxes();
|
||||
}
|
||||
|
||||
getCenterX(): float {
|
||||
if (this._isUntransformedHitBoxesDirty) {
|
||||
this._updateUntransformedHitBoxes();
|
||||
}
|
||||
return (
|
||||
(this.getUnscaledCenterX() - this._unrotatedAABB.min[0]) *
|
||||
this.getScaleX()
|
||||
);
|
||||
}
|
||||
|
||||
getCenterY(): float {
|
||||
if (this._isUntransformedHitBoxesDirty) {
|
||||
this._updateUntransformedHitBoxes();
|
||||
}
|
||||
return (
|
||||
(this.getUnscaledCenterY() - this._unrotatedAABB.min[1]) *
|
||||
this.getScaleY()
|
||||
);
|
||||
}
|
||||
|
||||
getWidth(): float {
|
||||
return this.getUnscaledWidth() * this.getScaleX();
|
||||
}
|
||||
@@ -466,7 +417,6 @@ namespace gdjs {
|
||||
return;
|
||||
}
|
||||
this.x = x;
|
||||
this._isLocalTransformationDirty = true;
|
||||
this.invalidateHitboxes();
|
||||
this.getRenderer().updateX();
|
||||
}
|
||||
@@ -476,7 +426,6 @@ namespace gdjs {
|
||||
return;
|
||||
}
|
||||
this.y = y;
|
||||
this._isLocalTransformationDirty = true;
|
||||
this.invalidateHitboxes();
|
||||
this.getRenderer().updateY();
|
||||
}
|
||||
@@ -486,7 +435,6 @@ namespace gdjs {
|
||||
return;
|
||||
}
|
||||
this.angle = angle;
|
||||
this._isLocalTransformationDirty = true;
|
||||
this.invalidateHitboxes();
|
||||
this.getRenderer().updateAngle();
|
||||
}
|
||||
@@ -508,7 +456,6 @@ namespace gdjs {
|
||||
}
|
||||
this._scaleX = newScale * (this._flippedX ? -1 : 1);
|
||||
this._scaleY = newScale * (this._flippedY ? -1 : 1);
|
||||
this._isLocalTransformationDirty = true;
|
||||
this.invalidateHitboxes();
|
||||
this.getRenderer().update();
|
||||
}
|
||||
@@ -526,7 +473,6 @@ namespace gdjs {
|
||||
return;
|
||||
}
|
||||
this._scaleX = newScale * (this._flippedX ? -1 : 1);
|
||||
this._isLocalTransformationDirty = true;
|
||||
this.invalidateHitboxes();
|
||||
this.getRenderer().update();
|
||||
}
|
||||
|
@@ -43,13 +43,6 @@ namespace gdjs {
|
||||
this._debuggerRenderer = new gdjs.DebuggerRenderer(this);
|
||||
}
|
||||
|
||||
addLayer(layerData: LayerData) {
|
||||
this._layers.put(
|
||||
layerData.name,
|
||||
new gdjs.RuntimeCustomObjectLayer(layerData, this)
|
||||
);
|
||||
}
|
||||
|
||||
createObject(objectName: string): gdjs.RuntimeObject | null {
|
||||
const result = super.createObject(objectName);
|
||||
this._customObject.onChildrenLocationChanged();
|
||||
@@ -300,6 +293,21 @@ namespace gdjs {
|
||||
this._customObject.onChildrenLocationChanged();
|
||||
}
|
||||
|
||||
/**
|
||||
* Triggered when the object dimensions are changed.
|
||||
*
|
||||
* It adapts the layers camera positions.
|
||||
*/
|
||||
onObjectUnscaledCenterChanged(oldOriginX: float, oldOriginY: float): void {
|
||||
for (const name in this._layers.items) {
|
||||
if (this._layers.items.hasOwnProperty(name)) {
|
||||
/** @type gdjs.Layer */
|
||||
const theLayer: gdjs.Layer = this._layers.items[name];
|
||||
theLayer.onGameResolutionResized(oldOriginX, oldOriginY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
convertCoords(x: float, y: float, result: FloatPoint): FloatPoint {
|
||||
// The result parameter used to be optional.
|
||||
let position = result || [0, 0];
|
||||
|
@@ -1,104 +0,0 @@
|
||||
/*
|
||||
* GDevelop JS Platform
|
||||
* Copyright 2013-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
|
||||
* This project is released under the MIT License.
|
||||
*/
|
||||
namespace gdjs {
|
||||
/**
|
||||
* Represents a layer of a custom object. It doesn't allow to move any camera
|
||||
* because it doesn't make sense inside an object.
|
||||
*/
|
||||
export class RuntimeCustomObjectLayer extends gdjs.RuntimeLayer {
|
||||
/**
|
||||
* @param layerData The data used to initialize the layer
|
||||
* @param instanceContainer The container in which the layer is used
|
||||
*/
|
||||
constructor(
|
||||
layerData: LayerData,
|
||||
instanceContainer: gdjs.RuntimeInstanceContainer
|
||||
) {
|
||||
super(layerData, instanceContainer);
|
||||
}
|
||||
|
||||
onGameResolutionResized(
|
||||
oldGameResolutionOriginX: float,
|
||||
oldGameResolutionOriginY: float
|
||||
): void {}
|
||||
|
||||
getCameraX(cameraId?: integer): float {
|
||||
return 0;
|
||||
}
|
||||
|
||||
getCameraY(cameraId?: integer): float {
|
||||
return 0;
|
||||
}
|
||||
|
||||
setCameraX(x: float, cameraId?: integer): void {}
|
||||
|
||||
setCameraY(y: float, cameraId?: integer): void {}
|
||||
|
||||
getCameraWidth(cameraId?: integer): float {
|
||||
return 0;
|
||||
}
|
||||
|
||||
getCameraHeight(cameraId?: integer): float {
|
||||
return 0;
|
||||
}
|
||||
|
||||
setCameraZoom(newZoom: float, cameraId?: integer): void {}
|
||||
|
||||
getCameraZoom(cameraId?: integer): float {
|
||||
return 0;
|
||||
}
|
||||
|
||||
getCameraRotation(cameraId?: integer): float {
|
||||
return 0;
|
||||
}
|
||||
|
||||
setCameraRotation(rotation: float, cameraId?: integer): void {}
|
||||
|
||||
convertCoords(
|
||||
x: float,
|
||||
y: float,
|
||||
cameraId: integer,
|
||||
result: FloatPoint
|
||||
): FloatPoint {
|
||||
// TODO EBO use an AffineTransformation to avoid chained calls.
|
||||
// The result parameter used to be optional.
|
||||
return this._runtimeScene.convertCoords(x, y, result || [0, 0]);
|
||||
}
|
||||
|
||||
convertInverseCoords(
|
||||
x: float,
|
||||
y: float,
|
||||
cameraId: integer,
|
||||
result: FloatPoint
|
||||
): FloatPoint {
|
||||
// TODO EBO use an AffineTransformation to avoid chained calls.
|
||||
// The result parameter used to be optional.
|
||||
return this._runtimeScene.convertInverseCoords(x, y, result || [0, 0]);
|
||||
}
|
||||
|
||||
applyLayerInverseTransformation(
|
||||
x: float,
|
||||
y: float,
|
||||
cameraId: integer,
|
||||
result: FloatPoint
|
||||
): FloatPoint {
|
||||
result[0] = x;
|
||||
result[1] = y;
|
||||
return result;
|
||||
}
|
||||
|
||||
applyLayerTransformation(
|
||||
x: float,
|
||||
y: float,
|
||||
cameraId: integer,
|
||||
result: FloatPoint
|
||||
): FloatPoint {
|
||||
result[0] = x;
|
||||
result[1] = y;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
@@ -32,7 +32,7 @@ namespace gdjs {
|
||||
_objects: Hashtable<ObjectData>;
|
||||
_objectsCtor: Hashtable<typeof RuntimeObject>;
|
||||
|
||||
_layers: Hashtable<RuntimeLayer>;
|
||||
_layers: Hashtable<Layer>;
|
||||
_layersCameraCoordinates: Record<string, [float, float, float, float]> = {};
|
||||
|
||||
// Options for the debug draw:
|
||||
@@ -601,7 +601,7 @@ namespace gdjs {
|
||||
* @param name The name of the layer
|
||||
* @returns The layer, or the base layer if not found
|
||||
*/
|
||||
getLayer(name: string): gdjs.RuntimeLayer {
|
||||
getLayer(name: string): gdjs.Layer {
|
||||
if (this._layers.containsKey(name)) {
|
||||
return this._layers.get(name);
|
||||
}
|
||||
@@ -620,7 +620,9 @@ namespace gdjs {
|
||||
* Add a layer.
|
||||
* @param layerData The data to construct the layer
|
||||
*/
|
||||
abstract addLayer(layerData: LayerData);
|
||||
addLayer(layerData: LayerData) {
|
||||
this._layers.put(layerData.name, new gdjs.Layer(layerData, this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a layer. All {@link gdjs.RuntimeObject} on this layer will
|
||||
@@ -645,7 +647,7 @@ namespace gdjs {
|
||||
* @param index The new position in the list of layers
|
||||
*/
|
||||
setLayerIndex(layerName: string, index: integer): void {
|
||||
const layer: gdjs.RuntimeLayer = this._layers.get(layerName);
|
||||
const layer: gdjs.Layer = this._layers.get(layerName);
|
||||
if (!layer) {
|
||||
return;
|
||||
}
|
||||
|
@@ -1,490 +0,0 @@
|
||||
/*
|
||||
* GDevelop JS Platform
|
||||
* Copyright 2013-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
|
||||
* This project is released under the MIT License.
|
||||
*/
|
||||
namespace gdjs {
|
||||
/**
|
||||
* Represents a layer of a container, used to display objects.
|
||||
*
|
||||
* Viewports and multiple cameras are not supported.
|
||||
*/
|
||||
export abstract class RuntimeLayer implements EffectsTarget {
|
||||
_name: string;
|
||||
_timeScale: float = 1;
|
||||
_defaultZOrder: integer = 0;
|
||||
_hidden: boolean;
|
||||
_initialEffectsData: Array<EffectData>;
|
||||
|
||||
_runtimeScene: gdjs.RuntimeInstanceContainer;
|
||||
_effectsManager: gdjs.EffectsManager;
|
||||
|
||||
// Lighting layer properties.
|
||||
_isLightingLayer: boolean;
|
||||
_followBaseLayerCamera: boolean;
|
||||
_clearColor: Array<integer>;
|
||||
|
||||
_rendererEffects: Record<string, PixiFiltersTools.Filter> = {};
|
||||
_renderer: gdjs.LayerRenderer;
|
||||
|
||||
/**
|
||||
* @param layerData The data used to initialize the layer
|
||||
* @param instanceContainer The container in which the layer is used
|
||||
*/
|
||||
constructor(
|
||||
layerData: LayerData,
|
||||
instanceContainer: gdjs.RuntimeInstanceContainer
|
||||
) {
|
||||
this._name = layerData.name;
|
||||
this._hidden = !layerData.visibility;
|
||||
this._initialEffectsData = layerData.effects || [];
|
||||
this._runtimeScene = instanceContainer;
|
||||
this._effectsManager = instanceContainer.getGame().getEffectsManager();
|
||||
this._isLightingLayer = layerData.isLightingLayer;
|
||||
this._followBaseLayerCamera = layerData.followBaseLayerCamera;
|
||||
this._clearColor = [
|
||||
layerData.ambientLightColorR / 255,
|
||||
layerData.ambientLightColorG / 255,
|
||||
layerData.ambientLightColorB / 255,
|
||||
1.0,
|
||||
];
|
||||
this._renderer = new gdjs.LayerRenderer(
|
||||
this,
|
||||
instanceContainer.getRenderer(),
|
||||
instanceContainer.getGame().getRenderer().getPIXIRenderer()
|
||||
);
|
||||
this.show(!this._hidden);
|
||||
for (let i = 0; i < layerData.effects.length; ++i) {
|
||||
this.addEffect(layerData.effects[i]);
|
||||
}
|
||||
}
|
||||
|
||||
getRenderer(): gdjs.LayerRenderer {
|
||||
return this._renderer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default Z order to be attributed to objects created on this layer
|
||||
* (usually from events generated code).
|
||||
*/
|
||||
getDefaultZOrder(): float {
|
||||
return this._defaultZOrder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the default Z order to be attributed to objects created on this layer.
|
||||
* @param defaultZOrder The Z order to use when creating a new object from events.
|
||||
*/
|
||||
setDefaultZOrder(defaultZOrder: integer): void {
|
||||
this._defaultZOrder = defaultZOrder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by the RuntimeScene whenever the game resolution size is changed.
|
||||
* Updates the layer width/height and position.
|
||||
*/
|
||||
abstract onGameResolutionResized(
|
||||
oldGameResolutionOriginX: float,
|
||||
oldGameResolutionOriginY: float
|
||||
): void;
|
||||
|
||||
/**
|
||||
* Returns the scene the layer belongs to directly or indirectly
|
||||
* @returns the scene the layer belongs to directly or indirectly
|
||||
*/
|
||||
getRuntimeScene(): gdjs.RuntimeScene {
|
||||
return this._runtimeScene.getScene();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called at each frame, after events are run and before rendering.
|
||||
*/
|
||||
updatePreRender(instanceContainer?: gdjs.RuntimeInstanceContainer): void {
|
||||
if (this._followBaseLayerCamera) {
|
||||
this.followBaseLayer();
|
||||
}
|
||||
this._renderer.updatePreRender();
|
||||
this._effectsManager.updatePreRender(this._rendererEffects, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the layer
|
||||
* @return The name of the layer
|
||||
*/
|
||||
getName(): string {
|
||||
return this._name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the camera center X position.
|
||||
*
|
||||
* @param cameraId The camera number. Currently ignored.
|
||||
* @return The x position of the camera
|
||||
*/
|
||||
abstract getCameraX(cameraId?: integer): float;
|
||||
|
||||
/**
|
||||
* Change the camera center Y position.
|
||||
*
|
||||
* @param cameraId The camera number. Currently ignored.
|
||||
* @return The y position of the camera
|
||||
*/
|
||||
abstract getCameraY(cameraId?: integer): float;
|
||||
|
||||
/**
|
||||
* Set the camera center X position.
|
||||
*
|
||||
* @param x The new x position
|
||||
* @param cameraId The camera number. Currently ignored.
|
||||
*/
|
||||
abstract setCameraX(x: float, cameraId?: integer): void;
|
||||
|
||||
/**
|
||||
* Set the camera center Y position.
|
||||
*
|
||||
* @param y The new y position
|
||||
* @param cameraId The camera number. Currently ignored.
|
||||
*/
|
||||
abstract setCameraY(y: float, cameraId?: integer): void;
|
||||
|
||||
/**
|
||||
* Get the camera width (which can be different than the game resolution width
|
||||
* if the camera is zoomed).
|
||||
*
|
||||
* @param cameraId The camera number. Currently ignored.
|
||||
* @return The width of the camera
|
||||
*/
|
||||
abstract getCameraWidth(cameraId?: integer): float;
|
||||
|
||||
/**
|
||||
* Get the camera height (which can be different than the game resolution height
|
||||
* if the camera is zoomed).
|
||||
*
|
||||
* @param cameraId The camera number. Currently ignored.
|
||||
* @return The height of the camera
|
||||
*/
|
||||
abstract getCameraHeight(cameraId?: integer): float;
|
||||
|
||||
/**
|
||||
* Show (or hide) the layer.
|
||||
* @param enable true to show the layer, false to hide it.
|
||||
*/
|
||||
show(enable: boolean): void {
|
||||
this._hidden = !enable;
|
||||
this._renderer.updateVisibility(enable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the layer is visible.
|
||||
*
|
||||
* @return true if the layer is visible.
|
||||
*/
|
||||
isVisible(): boolean {
|
||||
return !this._hidden;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the zoom of a camera.
|
||||
*
|
||||
* @param newZoom The new zoom. Must be superior to 0. 1 is the default zoom.
|
||||
* @param cameraId The camera number. Currently ignored.
|
||||
*/
|
||||
abstract setCameraZoom(newZoom: float, cameraId?: integer): void;
|
||||
|
||||
/**
|
||||
* Get the zoom of a camera.
|
||||
*
|
||||
* @param cameraId The camera number. Currently ignored.
|
||||
* @return The zoom.
|
||||
*/
|
||||
abstract getCameraZoom(cameraId?: integer): float;
|
||||
|
||||
/**
|
||||
* Get the rotation of the camera, expressed in degrees.
|
||||
*
|
||||
* @param cameraId The camera number. Currently ignored.
|
||||
* @return The rotation, in degrees.
|
||||
*/
|
||||
abstract getCameraRotation(cameraId?: integer): float;
|
||||
|
||||
/**
|
||||
* Set the rotation of the camera, expressed in degrees.
|
||||
* The rotation is made around the camera center.
|
||||
*
|
||||
* @param rotation The new rotation, in degrees.
|
||||
* @param cameraId The camera number. Currently ignored.
|
||||
*/
|
||||
abstract setCameraRotation(rotation: float, cameraId?: integer): void;
|
||||
|
||||
/**
|
||||
* Convert a point from the canvas coordinates (for example,
|
||||
* the mouse position) to the container coordinates.
|
||||
*
|
||||
* @param x The x position, in canvas coordinates.
|
||||
* @param y The y position, in canvas coordinates.
|
||||
* @param cameraId The camera number. Currently ignored.
|
||||
* @param result The point instance that is used to return the result.
|
||||
*/
|
||||
abstract convertCoords(
|
||||
x: float,
|
||||
y: float,
|
||||
cameraId: integer,
|
||||
result: FloatPoint
|
||||
): FloatPoint;
|
||||
|
||||
/**
|
||||
* Return an array containing the coordinates of the point passed as parameter
|
||||
* in parent coordinate coordinates (as opposed to the layer local coordinates).
|
||||
*
|
||||
* All transformations (scale, rotation) are supported.
|
||||
*
|
||||
* @param x The X position of the point, in layer coordinates.
|
||||
* @param y The Y position of the point, in layer coordinates.
|
||||
* @param result Array that will be updated with the result
|
||||
* (x and y position of the point in parent coordinates).
|
||||
*/
|
||||
abstract applyLayerTransformation(
|
||||
x: float,
|
||||
y: float,
|
||||
cameraId: integer,
|
||||
result: FloatPoint
|
||||
): FloatPoint;
|
||||
|
||||
/**
|
||||
* Convert a point from the container coordinates (for example,
|
||||
* an object position) to the canvas coordinates.
|
||||
*
|
||||
* @param x The x position, in container coordinates.
|
||||
* @param y The y position, in container coordinates.
|
||||
* @param cameraId The camera number. Currently ignored.
|
||||
* @param result The point instance that is used to return the result.
|
||||
*/
|
||||
abstract convertInverseCoords(
|
||||
x: float,
|
||||
y: float,
|
||||
cameraId: integer,
|
||||
result: FloatPoint
|
||||
): FloatPoint;
|
||||
|
||||
/**
|
||||
* Return an array containing the coordinates of the point passed as parameter
|
||||
* in layer local coordinates (as opposed to the parent coordinates).
|
||||
*
|
||||
* All transformations (scale, rotation) are supported.
|
||||
*
|
||||
* @param x The X position of the point, in parent coordinates.
|
||||
* @param y The Y position of the point, in parent coordinates.
|
||||
* @param result Array that will be updated with the result
|
||||
* @param result The point instance that is used to return the result.
|
||||
* (x and y position of the point in layer coordinates).
|
||||
*/
|
||||
abstract applyLayerInverseTransformation(
|
||||
x: float,
|
||||
y: float,
|
||||
cameraId: integer,
|
||||
result: FloatPoint
|
||||
): FloatPoint;
|
||||
|
||||
getWidth(): float {
|
||||
return this._runtimeScene.getViewportWidth();
|
||||
}
|
||||
|
||||
getHeight(): float {
|
||||
return this._runtimeScene.getViewportHeight();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the initial effects data for the layer. Only to
|
||||
* be used by renderers.
|
||||
* @deprecated
|
||||
*/
|
||||
getInitialEffectsData(): EffectData[] {
|
||||
return this._initialEffectsData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new effect, or replace the one with the same name.
|
||||
* @param effectData The data of the effect to add.
|
||||
*/
|
||||
addEffect(effectData: EffectData): void {
|
||||
this._effectsManager.addEffect(
|
||||
effectData,
|
||||
this._rendererEffects,
|
||||
this._renderer.getRendererObject(),
|
||||
this
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the effect with the specified name
|
||||
* @param effectName The name of the effect.
|
||||
*/
|
||||
removeEffect(effectName: string): void {
|
||||
this._effectsManager.removeEffect(
|
||||
this._rendererEffects,
|
||||
this._renderer.getRendererObject(),
|
||||
effectName
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change an effect parameter value (for parameters that are numbers).
|
||||
* @param name The name of the effect to update.
|
||||
* @param parameterName The name of the parameter to update.
|
||||
* @param value The new value (number).
|
||||
*/
|
||||
setEffectDoubleParameter(
|
||||
name: string,
|
||||
parameterName: string,
|
||||
value: float
|
||||
): void {
|
||||
this._effectsManager.setEffectDoubleParameter(
|
||||
this._rendererEffects,
|
||||
name,
|
||||
parameterName,
|
||||
value
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change an effect parameter value (for parameters that are strings).
|
||||
* @param name The name of the effect to update.
|
||||
* @param parameterName The name of the parameter to update.
|
||||
* @param value The new value (string).
|
||||
*/
|
||||
setEffectStringParameter(
|
||||
name: string,
|
||||
parameterName: string,
|
||||
value: string
|
||||
): void {
|
||||
this._effectsManager.setEffectStringParameter(
|
||||
this._rendererEffects,
|
||||
name,
|
||||
parameterName,
|
||||
value
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change an effect parameter value (for parameters that are booleans).
|
||||
* @param name The name of the effect to update.
|
||||
* @param parameterName The name of the parameter to update.
|
||||
* @param value The new value (boolean).
|
||||
*/
|
||||
setEffectBooleanParameter(
|
||||
name: string,
|
||||
parameterName: string,
|
||||
value: boolean
|
||||
): void {
|
||||
this._effectsManager.setEffectBooleanParameter(
|
||||
this._rendererEffects,
|
||||
name,
|
||||
parameterName,
|
||||
value
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable or disable an effect.
|
||||
* @param name The name of the effect to enable or disable.
|
||||
* @param enable true to enable, false to disable
|
||||
*/
|
||||
enableEffect(name: string, enable: boolean): void {
|
||||
this._effectsManager.enableEffect(this._rendererEffects, name, enable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if an effect is enabled
|
||||
* @param name The name of the effect
|
||||
* @return true if the effect is enabled, false otherwise.
|
||||
*/
|
||||
isEffectEnabled(name: string): boolean {
|
||||
return this._effectsManager.isEffectEnabled(this._rendererEffects, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if an effect exists on this layer
|
||||
* @param name The name of the effect
|
||||
* @return true if the effect exists, false otherwise.
|
||||
*/
|
||||
hasEffect(name: string): boolean {
|
||||
return this._effectsManager.hasEffect(this._rendererEffects, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the time scale for the objects on the layer:
|
||||
* time will be slower if time scale is < 1, faster if > 1.
|
||||
* @param timeScale The new time scale (must be positive).
|
||||
*/
|
||||
setTimeScale(timeScale: float): void {
|
||||
if (timeScale >= 0) {
|
||||
this._timeScale = timeScale;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the time scale for the objects on the layer.
|
||||
*/
|
||||
getTimeScale(): float {
|
||||
return this._timeScale;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the time elapsed since the last frame,
|
||||
* in milliseconds, for objects on the layer.
|
||||
*
|
||||
* @param instanceContainer The instance container the layer belongs to (deprecated - can be omitted).
|
||||
*/
|
||||
getElapsedTime(instanceContainer?: gdjs.RuntimeInstanceContainer): float {
|
||||
const container = instanceContainer || this._runtimeScene;
|
||||
return container.getElapsedTime() * this._timeScale;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the position, rotation and scale (zoom) of the layer camera to be the same as the base layer camera.
|
||||
*/
|
||||
followBaseLayer(): void {
|
||||
const baseLayer = this._runtimeScene.getLayer('');
|
||||
this.setCameraX(baseLayer.getCameraX());
|
||||
this.setCameraY(baseLayer.getCameraY());
|
||||
this.setCameraRotation(baseLayer.getCameraRotation());
|
||||
this.setCameraZoom(baseLayer.getCameraZoom());
|
||||
}
|
||||
|
||||
/**
|
||||
* The clear color is defined in the format [r, g, b], with components in the range of 0 to 1.
|
||||
* @return the clear color of layer in the range of [0, 1].
|
||||
*/
|
||||
getClearColor(): Array<integer> {
|
||||
return this._clearColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the clear color in format [r, g, b], with components in the range of 0 to 1.;
|
||||
* @param r Red color component in the range 0-255.
|
||||
* @param g Green color component in the range 0-255.
|
||||
* @param b Blue color component in the range 0-255.
|
||||
*/
|
||||
setClearColor(r: integer, g: integer, b: integer): void {
|
||||
this._clearColor[0] = r / 255;
|
||||
this._clearColor[1] = g / 255;
|
||||
this._clearColor[2] = b / 255;
|
||||
this._renderer.updateClearColor();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether layer's camera follows base layer's camera or not.
|
||||
*/
|
||||
setFollowBaseLayerCamera(follow: boolean): void {
|
||||
this._followBaseLayerCamera = follow;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the layer is a lighting layer, false otherwise.
|
||||
* @return true if it is a lighting layer, false otherwise.
|
||||
*/
|
||||
isLightingLayer(): boolean {
|
||||
return this._isLightingLayer;
|
||||
}
|
||||
}
|
||||
}
|
74
GDJS/Runtime/RuntimeSceneLayer.ts
Normal file
74
GDJS/Runtime/RuntimeSceneLayer.ts
Normal file
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* GDevelop JS Platform
|
||||
* Copyright 2013-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
|
||||
* This project is released under the MIT License.
|
||||
*/
|
||||
namespace gdjs {
|
||||
/**
|
||||
* Represents a layer of a scene, used to display objects.
|
||||
*
|
||||
* Viewports and multiple cameras are not supported.
|
||||
*
|
||||
* It does some optimizations but works exactly the same as
|
||||
* {@link gdjs.Layer}.
|
||||
*/
|
||||
export class RuntimeSceneLayer extends gdjs.Layer {
|
||||
/**
|
||||
* @param layerData The data used to initialize the layer
|
||||
* @param scene The scene in which the layer is used
|
||||
*/
|
||||
constructor(layerData: LayerData, scene: gdjs.RuntimeScene) {
|
||||
super(layerData, scene);
|
||||
}
|
||||
|
||||
convertCoords(
|
||||
x: float,
|
||||
y: float,
|
||||
cameraId: integer = 0,
|
||||
result: FloatPoint
|
||||
): FloatPoint {
|
||||
// The result parameter used to be optional.
|
||||
let position = result || [0, 0];
|
||||
x -= this.getRuntimeScene()._cachedGameResolutionWidth / 2;
|
||||
y -= this.getRuntimeScene()._cachedGameResolutionHeight / 2;
|
||||
x /= Math.abs(this._zoomFactor);
|
||||
y /= Math.abs(this._zoomFactor);
|
||||
|
||||
// Only compute angle and cos/sin once (allow heavy optimization from JS engines).
|
||||
const angleInRadians = (this._cameraRotation / 180) * Math.PI;
|
||||
const tmp = x;
|
||||
const cosValue = Math.cos(angleInRadians);
|
||||
const sinValue = Math.sin(angleInRadians);
|
||||
x = cosValue * x - sinValue * y;
|
||||
y = sinValue * tmp + cosValue * y;
|
||||
position[0] = x + this.getCameraX(cameraId);
|
||||
position[1] = y + this.getCameraY(cameraId);
|
||||
return position;
|
||||
}
|
||||
|
||||
convertInverseCoords(
|
||||
x: float,
|
||||
y: float,
|
||||
cameraId: integer = 0,
|
||||
result: FloatPoint
|
||||
): FloatPoint {
|
||||
// The result parameter used to be optional.
|
||||
let position = result || [0, 0];
|
||||
x -= this.getCameraX(cameraId);
|
||||
y -= this.getCameraY(cameraId);
|
||||
|
||||
// Only compute angle and cos/sin once (allow heavy optimization from JS engines).
|
||||
const angleInRadians = (this._cameraRotation / 180) * Math.PI;
|
||||
const tmp = x;
|
||||
const cosValue = Math.cos(-angleInRadians);
|
||||
const sinValue = Math.sin(-angleInRadians);
|
||||
x = cosValue * x - sinValue * y;
|
||||
y = sinValue * tmp + cosValue * y;
|
||||
x *= Math.abs(this._zoomFactor);
|
||||
y *= Math.abs(this._zoomFactor);
|
||||
position[0] = x + this.getRuntimeScene()._cachedGameResolutionWidth / 2;
|
||||
position[1] = y + this.getRuntimeScene()._cachedGameResolutionHeight / 2;
|
||||
return position;
|
||||
}
|
||||
}
|
||||
}
|
@@ -339,7 +339,6 @@ namespace gdjs {
|
||||
// Avoid circular reference from behavior to parent runtimeObject
|
||||
// Exclude rendering related objects:
|
||||
'_renderer',
|
||||
'_gameRenderer',
|
||||
'_imageManager',
|
||||
// Exclude PIXI textures:
|
||||
'baseTexture',
|
||||
|
@@ -1037,7 +1037,7 @@ namespace gdjs {
|
||||
_hotReloadRuntimeLayer(
|
||||
oldLayer: LayerData,
|
||||
newLayer: LayerData,
|
||||
runtimeLayer: gdjs.RuntimeLayer
|
||||
runtimeLayer: gdjs.Layer
|
||||
): void {
|
||||
// Properties
|
||||
if (oldLayer.visibility !== newLayer.visibility) {
|
||||
@@ -1073,7 +1073,7 @@ namespace gdjs {
|
||||
_hotReloadRuntimeLayerEffects(
|
||||
oldEffectsData: EffectData[],
|
||||
newEffectsData: EffectData[],
|
||||
runtimeLayer: gdjs.RuntimeLayer
|
||||
runtimeLayer: gdjs.Layer
|
||||
): void {
|
||||
oldEffectsData.forEach((oldEffectData) => {
|
||||
const name = oldEffectData.name;
|
||||
@@ -1115,7 +1115,7 @@ namespace gdjs {
|
||||
_hotReloadRuntimeLayerEffect(
|
||||
oldEffectData: EffectData,
|
||||
newEffectData: EffectData,
|
||||
runtimeLayer: gdjs.RuntimeLayer,
|
||||
runtimeLayer: gdjs.Layer,
|
||||
effectName: string
|
||||
): void {
|
||||
// We consider oldEffectData.effectType and newEffectData.effectType
|
||||
|
@@ -5,16 +5,32 @@
|
||||
*/
|
||||
namespace gdjs {
|
||||
/**
|
||||
* Represents a layer of a scene, used to display objects.
|
||||
* Represents a layer of a container, used to display objects.
|
||||
*
|
||||
* Viewports and multiple cameras are not supported.
|
||||
*/
|
||||
export class Layer extends gdjs.RuntimeLayer {
|
||||
export class Layer implements EffectsTarget {
|
||||
_name: string;
|
||||
_cameraRotation: float = 0;
|
||||
_zoomFactor: float = 1;
|
||||
_timeScale: float = 1;
|
||||
_defaultZOrder: integer = 0;
|
||||
_hidden: boolean;
|
||||
_initialEffectsData: Array<EffectData>;
|
||||
_cameraX: float;
|
||||
_cameraY: float;
|
||||
|
||||
_runtimeScene: gdjs.RuntimeInstanceContainer;
|
||||
_effectsManager: gdjs.EffectsManager;
|
||||
|
||||
// Lighting layer properties.
|
||||
_isLightingLayer: boolean;
|
||||
_followBaseLayerCamera: boolean;
|
||||
_clearColor: Array<integer>;
|
||||
|
||||
_rendererEffects: Record<string, PixiFiltersTools.Filter> = {};
|
||||
_renderer: gdjs.LayerRenderer;
|
||||
|
||||
/**
|
||||
* @param layerData The data used to initialize the layer
|
||||
* @param instanceContainer The container in which the layer is used
|
||||
@@ -23,10 +39,50 @@ namespace gdjs {
|
||||
layerData: LayerData,
|
||||
instanceContainer: gdjs.RuntimeInstanceContainer
|
||||
) {
|
||||
super(layerData, instanceContainer);
|
||||
|
||||
this._name = layerData.name;
|
||||
this._hidden = !layerData.visibility;
|
||||
this._initialEffectsData = layerData.effects || [];
|
||||
this._runtimeScene = instanceContainer;
|
||||
this._cameraX = this.getWidth() / 2;
|
||||
this._cameraY = this.getHeight() / 2;
|
||||
this._effectsManager = instanceContainer.getGame().getEffectsManager();
|
||||
this._isLightingLayer = layerData.isLightingLayer;
|
||||
this._followBaseLayerCamera = layerData.followBaseLayerCamera;
|
||||
this._clearColor = [
|
||||
layerData.ambientLightColorR / 255,
|
||||
layerData.ambientLightColorG / 255,
|
||||
layerData.ambientLightColorB / 255,
|
||||
1.0,
|
||||
];
|
||||
this._renderer = new gdjs.LayerRenderer(
|
||||
this,
|
||||
instanceContainer.getRenderer(),
|
||||
instanceContainer.getGame().getRenderer().getPIXIRenderer()
|
||||
);
|
||||
this.show(!this._hidden);
|
||||
for (let i = 0; i < layerData.effects.length; ++i) {
|
||||
this.addEffect(layerData.effects[i]);
|
||||
}
|
||||
}
|
||||
|
||||
getRenderer(): gdjs.LayerRenderer {
|
||||
return this._renderer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default Z order to be attributed to objects created on this layer
|
||||
* (usually from events generated code).
|
||||
*/
|
||||
getDefaultZOrder(): float {
|
||||
return this._defaultZOrder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the default Z order to be attributed to objects created on this layer.
|
||||
* @param defaultZOrder The Z order to use when creating a new object from events.
|
||||
*/
|
||||
setDefaultZOrder(defaultZOrder: integer): void {
|
||||
this._defaultZOrder = defaultZOrder;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -51,6 +107,33 @@ namespace gdjs {
|
||||
this._renderer.updatePosition();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the scene the layer belongs to directly or indirectly
|
||||
* @returns the scene the layer belongs to directly or indirectly
|
||||
*/
|
||||
getRuntimeScene(): gdjs.RuntimeScene {
|
||||
return this._runtimeScene.getScene();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called at each frame, after events are run and before rendering.
|
||||
*/
|
||||
updatePreRender(instanceContainer?: gdjs.RuntimeInstanceContainer): void {
|
||||
if (this._followBaseLayerCamera) {
|
||||
this.followBaseLayer();
|
||||
}
|
||||
this._renderer.updatePreRender();
|
||||
this._effectsManager.updatePreRender(this._rendererEffects, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the layer
|
||||
* @return The name of the layer
|
||||
*/
|
||||
getName(): string {
|
||||
return this._name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the camera center X position.
|
||||
*
|
||||
@@ -119,6 +202,24 @@ namespace gdjs {
|
||||
return this.getHeight() / this._zoomFactor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show (or hide) the layer.
|
||||
* @param enable true to show the layer, false to hide it.
|
||||
*/
|
||||
show(enable: boolean): void {
|
||||
this._hidden = !enable;
|
||||
this._renderer.updateVisibility(enable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the layer is visible.
|
||||
*
|
||||
* @return true if the layer is visible.
|
||||
*/
|
||||
isVisible(): boolean {
|
||||
return !this._hidden;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the zoom of a camera.
|
||||
*
|
||||
@@ -177,25 +278,16 @@ namespace gdjs {
|
||||
cameraId: integer = 0,
|
||||
result: FloatPoint
|
||||
): FloatPoint {
|
||||
// This code duplicates applyLayerInverseTransformation for performance reasons;
|
||||
|
||||
// The result parameter used to be optional.
|
||||
let position = result || [0, 0];
|
||||
x -= this.getRuntimeScene()._cachedGameResolutionWidth / 2;
|
||||
y -= this.getRuntimeScene()._cachedGameResolutionHeight / 2;
|
||||
x /= Math.abs(this._zoomFactor);
|
||||
y /= Math.abs(this._zoomFactor);
|
||||
|
||||
// Only compute angle and cos/sin once (allow heavy optimization from JS engines).
|
||||
const angleInRadians = (this._cameraRotation / 180) * Math.PI;
|
||||
const tmp = x;
|
||||
const cosValue = Math.cos(angleInRadians);
|
||||
const sinValue = Math.sin(angleInRadians);
|
||||
x = cosValue * x - sinValue * y;
|
||||
y = sinValue * tmp + cosValue * y;
|
||||
position[0] = x + this.getCameraX(cameraId);
|
||||
position[1] = y + this.getCameraY(cameraId);
|
||||
return position;
|
||||
// TODO EBO use an AffineTransformation to avoid chained calls.
|
||||
position = this._runtimeScene.convertCoords(x, y, position);
|
||||
return this.applyLayerInverseTransformation(
|
||||
position[0],
|
||||
position[1],
|
||||
cameraId,
|
||||
position
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -249,25 +341,14 @@ namespace gdjs {
|
||||
cameraId: integer = 0,
|
||||
result: FloatPoint
|
||||
): FloatPoint {
|
||||
// This code duplicates applyLayerTransformation for performance reasons;
|
||||
|
||||
// The result parameter used to be optional.
|
||||
let position = result || [0, 0];
|
||||
x -= this.getCameraX(cameraId);
|
||||
y -= this.getCameraY(cameraId);
|
||||
|
||||
// Only compute angle and cos/sin once (allow heavy optimization from JS engines).
|
||||
const angleInRadians = (this._cameraRotation / 180) * Math.PI;
|
||||
const tmp = x;
|
||||
const cosValue = Math.cos(-angleInRadians);
|
||||
const sinValue = Math.sin(-angleInRadians);
|
||||
x = cosValue * x - sinValue * y;
|
||||
y = sinValue * tmp + cosValue * y;
|
||||
x *= Math.abs(this._zoomFactor);
|
||||
y *= Math.abs(this._zoomFactor);
|
||||
position[0] = x + this.getRuntimeScene()._cachedGameResolutionWidth / 2;
|
||||
position[1] = y + this.getRuntimeScene()._cachedGameResolutionHeight / 2;
|
||||
return position;
|
||||
// TODO EBO use an AffineTransformation to avoid chained calls.
|
||||
this.applyLayerTransformation(x, y, cameraId, position);
|
||||
return this._runtimeScene.convertInverseCoords(
|
||||
position[0],
|
||||
position[1],
|
||||
position
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -307,6 +388,14 @@ namespace gdjs {
|
||||
return result;
|
||||
}
|
||||
|
||||
getWidth(): float {
|
||||
return this._runtimeScene.getViewportWidth();
|
||||
}
|
||||
|
||||
getHeight(): float {
|
||||
return this._runtimeScene.getViewportHeight();
|
||||
}
|
||||
|
||||
/**
|
||||
* This ensure that the viewport dimensions are up to date.
|
||||
*
|
||||
@@ -317,5 +406,199 @@ namespace gdjs {
|
||||
// This will update dimensions.
|
||||
this._runtimeScene.getViewportWidth();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the initial effects data for the layer. Only to
|
||||
* be used by renderers.
|
||||
* @deprecated
|
||||
*/
|
||||
getInitialEffectsData(): EffectData[] {
|
||||
return this._initialEffectsData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new effect, or replace the one with the same name.
|
||||
* @param effectData The data of the effect to add.
|
||||
*/
|
||||
addEffect(effectData: EffectData): void {
|
||||
this._effectsManager.addEffect(
|
||||
effectData,
|
||||
this._rendererEffects,
|
||||
this._renderer.getRendererObject(),
|
||||
this
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the effect with the specified name
|
||||
* @param effectName The name of the effect.
|
||||
*/
|
||||
removeEffect(effectName: string): void {
|
||||
this._effectsManager.removeEffect(
|
||||
this._rendererEffects,
|
||||
this._renderer.getRendererObject(),
|
||||
effectName
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change an effect parameter value (for parameters that are numbers).
|
||||
* @param name The name of the effect to update.
|
||||
* @param parameterName The name of the parameter to update.
|
||||
* @param value The new value (number).
|
||||
*/
|
||||
setEffectDoubleParameter(
|
||||
name: string,
|
||||
parameterName: string,
|
||||
value: float
|
||||
): void {
|
||||
this._effectsManager.setEffectDoubleParameter(
|
||||
this._rendererEffects,
|
||||
name,
|
||||
parameterName,
|
||||
value
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change an effect parameter value (for parameters that are strings).
|
||||
* @param name The name of the effect to update.
|
||||
* @param parameterName The name of the parameter to update.
|
||||
* @param value The new value (string).
|
||||
*/
|
||||
setEffectStringParameter(
|
||||
name: string,
|
||||
parameterName: string,
|
||||
value: string
|
||||
): void {
|
||||
this._effectsManager.setEffectStringParameter(
|
||||
this._rendererEffects,
|
||||
name,
|
||||
parameterName,
|
||||
value
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change an effect parameter value (for parameters that are booleans).
|
||||
* @param name The name of the effect to update.
|
||||
* @param parameterName The name of the parameter to update.
|
||||
* @param value The new value (boolean).
|
||||
*/
|
||||
setEffectBooleanParameter(
|
||||
name: string,
|
||||
parameterName: string,
|
||||
value: boolean
|
||||
): void {
|
||||
this._effectsManager.setEffectBooleanParameter(
|
||||
this._rendererEffects,
|
||||
name,
|
||||
parameterName,
|
||||
value
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable or disable an effect.
|
||||
* @param name The name of the effect to enable or disable.
|
||||
* @param enable true to enable, false to disable
|
||||
*/
|
||||
enableEffect(name: string, enable: boolean): void {
|
||||
this._effectsManager.enableEffect(this._rendererEffects, name, enable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if an effect is enabled
|
||||
* @param name The name of the effect
|
||||
* @return true if the effect is enabled, false otherwise.
|
||||
*/
|
||||
isEffectEnabled(name: string): boolean {
|
||||
return this._effectsManager.isEffectEnabled(this._rendererEffects, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if an effect exists on this layer
|
||||
* @param name The name of the effect
|
||||
* @return true if the effect exists, false otherwise.
|
||||
*/
|
||||
hasEffect(name: string): boolean {
|
||||
return this._effectsManager.hasEffect(this._rendererEffects, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the time scale for the objects on the layer:
|
||||
* time will be slower if time scale is < 1, faster if > 1.
|
||||
* @param timeScale The new time scale (must be positive).
|
||||
*/
|
||||
setTimeScale(timeScale: float): void {
|
||||
if (timeScale >= 0) {
|
||||
this._timeScale = timeScale;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the time scale for the objects on the layer.
|
||||
*/
|
||||
getTimeScale(): float {
|
||||
return this._timeScale;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the time elapsed since the last frame,
|
||||
* in milliseconds, for objects on the layer.
|
||||
*
|
||||
* @param instanceContainer The instance container the layer belongs to (deprecated - can be omitted).
|
||||
*/
|
||||
getElapsedTime(instanceContainer?: gdjs.RuntimeInstanceContainer): float {
|
||||
const container = instanceContainer || this._runtimeScene;
|
||||
return container.getElapsedTime() * this._timeScale;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the position, rotation and scale (zoom) of the layer camera to be the same as the base layer camera.
|
||||
*/
|
||||
followBaseLayer(): void {
|
||||
const baseLayer = this._runtimeScene.getLayer('');
|
||||
this.setCameraX(baseLayer.getCameraX());
|
||||
this.setCameraY(baseLayer.getCameraY());
|
||||
this.setCameraRotation(baseLayer.getCameraRotation());
|
||||
this.setCameraZoom(baseLayer.getCameraZoom());
|
||||
}
|
||||
|
||||
/**
|
||||
* The clear color is defined in the format [r, g, b], with components in the range of 0 to 1.
|
||||
* @return the clear color of layer in the range of [0, 1].
|
||||
*/
|
||||
getClearColor(): Array<integer> {
|
||||
return this._clearColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the clear color in format [r, g, b], with components in the range of 0 to 1.;
|
||||
* @param r Red color component in the range 0-255.
|
||||
* @param g Green color component in the range 0-255.
|
||||
* @param b Blue color component in the range 0-255.
|
||||
*/
|
||||
setClearColor(r: integer, g: integer, b: integer): void {
|
||||
this._clearColor[0] = r / 255;
|
||||
this._clearColor[1] = g / 255;
|
||||
this._clearColor[2] = b / 255;
|
||||
this._renderer.updateClearColor();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether layer's camera follows base layer's camera or not.
|
||||
*/
|
||||
setFollowBaseLayerCamera(follow: boolean): void {
|
||||
this._followBaseLayerCamera = follow;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the layer is a lighting layer, false otherwise.
|
||||
* @return true if it is a lighting layer, false otherwise.
|
||||
*/
|
||||
isLightingLayer(): boolean {
|
||||
return this._isLightingLayer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -67,12 +67,11 @@ namespace gdjs {
|
||||
this._pixiContainer.pivot.x = this._object.getUnscaledCenterX();
|
||||
this._pixiContainer.pivot.y = this._object.getUnscaledCenterY();
|
||||
this._pixiContainer.position.x =
|
||||
this._object.getX() +
|
||||
this._object.getDrawableX() +
|
||||
this._pixiContainer.pivot.x * Math.abs(this._object._scaleX);
|
||||
this._pixiContainer.position.y =
|
||||
this._object.getY() +
|
||||
this._object.getDrawableY() +
|
||||
this._pixiContainer.pivot.y * Math.abs(this._object._scaleY);
|
||||
|
||||
this._pixiContainer.rotation = gdjs.toRad(this._object.angle);
|
||||
this._pixiContainer.scale.x = this._object._scaleX;
|
||||
this._pixiContainer.scale.y = this._object._scaleY;
|
||||
@@ -127,7 +126,7 @@ namespace gdjs {
|
||||
return null;
|
||||
}
|
||||
|
||||
setLayerIndex(layer: gdjs.RuntimeLayer, index: float): void {
|
||||
setLayerIndex(layer: gdjs.Layer, index: float): void {
|
||||
const layerPixiRenderer: gdjs.LayerPixiRenderer = layer.getRenderer();
|
||||
let layerPixiObject:
|
||||
| PIXI.Container
|
||||
|
@@ -20,7 +20,7 @@ namespace gdjs {
|
||||
*
|
||||
* @see gdjs.RuntimeInstanceContainer.setLayerIndex
|
||||
*/
|
||||
setLayerIndex(layer: gdjs.RuntimeLayer, index: integer): void;
|
||||
setLayerIndex(layer: gdjs.Layer, index: integer): void;
|
||||
|
||||
getRendererObject(): PIXI.Container;
|
||||
}
|
||||
|
@@ -13,7 +13,7 @@ namespace gdjs {
|
||||
export class LayerPixiRenderer {
|
||||
_pixiContainer: PIXI.Container;
|
||||
|
||||
_layer: gdjs.RuntimeLayer;
|
||||
_layer: gdjs.Layer;
|
||||
_renderTexture: PIXI.RenderTexture | null = null;
|
||||
_lightingSprite: PIXI.Sprite | null = null;
|
||||
_runtimeSceneRenderer: gdjs.RuntimeInstanceContainerRenderer;
|
||||
@@ -35,7 +35,7 @@ namespace gdjs {
|
||||
* @param runtimeInstanceContainerRenderer The scene renderer
|
||||
*/
|
||||
constructor(
|
||||
layer: gdjs.RuntimeLayer,
|
||||
layer: gdjs.Layer,
|
||||
runtimeInstanceContainerRenderer: gdjs.RuntimeInstanceContainerRenderer,
|
||||
pixiRenderer: PIXI.Renderer | null
|
||||
) {
|
||||
|
@@ -104,7 +104,7 @@ namespace gdjs {
|
||||
return this._pixiRenderer;
|
||||
}
|
||||
|
||||
setLayerIndex(layer: gdjs.RuntimeLayer, index: float): void {
|
||||
setLayerIndex(layer: gdjs.Layer, index: float): void {
|
||||
const layerPixiRenderer: gdjs.LayerPixiRenderer = layer.getRenderer();
|
||||
let layerPixiObject:
|
||||
| PIXI.Container
|
||||
|
@@ -48,14 +48,6 @@ namespace gdjs {
|
||||
*/
|
||||
gdevelopResourceToken?: string;
|
||||
|
||||
/**
|
||||
* Check if, in some exceptional cases, we allow authentication
|
||||
* to be done through a iframe.
|
||||
* This is usually discouraged as the user can't verify that the authentication
|
||||
* window is a genuine one. It's only to be used in trusted contexts.
|
||||
*/
|
||||
allowAuthenticationUsingIframeForPreview?: boolean;
|
||||
|
||||
/**
|
||||
* If set, the game should use the specified environment for making calls
|
||||
* to GDevelop APIs ("dev" = development APIs).
|
||||
|
@@ -187,7 +187,6 @@ namespace gdjs {
|
||||
protected hitBoxes: gdjs.Polygon[];
|
||||
protected hitBoxesDirty: boolean = true;
|
||||
protected aabb: AABB = { min: [0, 0], max: [0, 0] };
|
||||
protected _isIncludedInParentCollisionMask = true;
|
||||
|
||||
//Variables:
|
||||
protected _variables: gdjs.VariablesContainer;
|
||||
@@ -1567,18 +1566,6 @@ namespace gdjs {
|
||||
);
|
||||
}
|
||||
|
||||
isIncludedInParentCollisionMask(): boolean {
|
||||
return this._isIncludedInParentCollisionMask;
|
||||
}
|
||||
|
||||
setIncludedInParentCollisionMask(isIncluded: boolean): void {
|
||||
const wasIncluded = this._isIncludedInParentCollisionMask;
|
||||
this._isIncludedInParentCollisionMask = isIncluded;
|
||||
if (wasIncluded !== isIncluded) {
|
||||
this._runtimeScene.onChildrenLocationChanged();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the AABB (axis aligned bounding box) for the object.
|
||||
*
|
||||
|
@@ -71,10 +71,6 @@ namespace gdjs {
|
||||
this.onGameResolutionResized();
|
||||
}
|
||||
|
||||
addLayer(layerData: LayerData) {
|
||||
this._layers.put(layerData.name, new gdjs.Layer(layerData, this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Should be called when the canvas where the scene is rendered has been resized.
|
||||
* See gdjs.RuntimeGame.startGameLoop in particular.
|
||||
@@ -90,7 +86,8 @@ namespace gdjs {
|
||||
: 0;
|
||||
for (const name in this._layers.items) {
|
||||
if (this._layers.items.hasOwnProperty(name)) {
|
||||
const theLayer: gdjs.RuntimeLayer = this._layers.items[name];
|
||||
/** @type gdjs.Layer */
|
||||
const theLayer: gdjs.Layer = this._layers.items[name];
|
||||
theLayer.onGameResolutionResized(
|
||||
oldGameResolutionOriginX,
|
||||
oldGameResolutionOriginY
|
||||
@@ -196,6 +193,13 @@ namespace gdjs {
|
||||
return behaviorSharedData;
|
||||
}
|
||||
|
||||
addLayer(layerData: LayerData) {
|
||||
this._layers.put(
|
||||
layerData.name,
|
||||
new gdjs.RuntimeSceneLayer(layerData, this)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a scene is "paused", i.e it will be not be rendered again
|
||||
* for some time, until it's resumed or unloaded.
|
||||
|
@@ -277,8 +277,8 @@ namespace gdjs {
|
||||
linkElement.id = 'watermark-link';
|
||||
|
||||
let targetUrl = this._authorUsername
|
||||
? new URL(`https://gd.games/${this._authorUsername}`)
|
||||
: new URL('https://gd.games');
|
||||
? new URL(`https://liluo.io/${this._authorUsername}`)
|
||||
: new URL('https://liluo.io');
|
||||
|
||||
if (this._isDevEnvironment) {
|
||||
targetUrl.searchParams.set('dev', 'true');
|
||||
|
@@ -6,7 +6,7 @@ describe('gdjs.Layer', function() {
|
||||
|
||||
it('benchmark convertCoords and convertInverseCoords', function() {
|
||||
this.timeout(30000);
|
||||
var layer = new gdjs.Layer(
|
||||
var layer = new gdjs.RuntimeSceneLayer(
|
||||
{ name: 'My layer',
|
||||
visibility: true,
|
||||
effects: [],
|
||||
|
@@ -55,9 +55,8 @@ module.exports = function (config) {
|
||||
'./newIDE/app/resources/GDJS/Runtime/scenestack.js',
|
||||
'./newIDE/app/resources/GDJS/Runtime/profiler.js',
|
||||
'./newIDE/app/resources/GDJS/Runtime/force.js',
|
||||
'./newIDE/app/resources/GDJS/Runtime/RuntimeLayer.js',
|
||||
'./newIDE/app/resources/GDJS/Runtime/layer.js',
|
||||
'./newIDE/app/resources/GDJS/Runtime/RuntimeCustomObjectLayer.js',
|
||||
'./newIDE/app/resources/GDJS/Runtime/RuntimeSceneLayer.js',
|
||||
'./newIDE/app/resources/GDJS/Runtime/timer.js',
|
||||
'./newIDE/app/resources/GDJS/Runtime/inputmanager.js',
|
||||
'./newIDE/app/resources/GDJS/Runtime/runtimegame.js',
|
||||
|
@@ -198,8 +198,8 @@ describe('gdjs.CustomRuntimeObject', function () {
|
||||
expect(customObject.getHitBoxes().length).to.be(2);
|
||||
expect(customObject.getHitBoxes()[0].vertices).to.eql([
|
||||
[32, 32],
|
||||
[32, -32],
|
||||
[96, 32],
|
||||
[31.999999999999993, -31.999999999999996],
|
||||
[96, 31.999999999999996],
|
||||
]);
|
||||
expect(customObject.getHitBoxes()[1].vertices).to.eql([
|
||||
[32, 96],
|
||||
@@ -245,12 +245,6 @@ describe('gdjs.CustomRuntimeObject', function () {
|
||||
customObject.setWidth(32);
|
||||
customObject.setHeight(96);
|
||||
|
||||
// To draw the transformed shapes:
|
||||
// - draw 2 squares side-by-side
|
||||
// - scale them and keep the top-left corner in place
|
||||
// - rotate the shape keeping the center of the scaled drawing in place
|
||||
// - translate it according to the object new position.
|
||||
|
||||
expect(customObject.getWidth()).to.be(32);
|
||||
expect(customObject.getHeight()).to.be(96);
|
||||
|
||||
@@ -259,14 +253,14 @@ describe('gdjs.CustomRuntimeObject', function () {
|
||||
|
||||
expect(customObject.getHitBoxes().length).to.be(2);
|
||||
expect(customObject.getHitBoxes()[0].vertices).to.eql([
|
||||
[-24, 64],
|
||||
[-24, 48],
|
||||
[72, 64],
|
||||
[-12, 100],
|
||||
[-12, 84],
|
||||
[84, 100],
|
||||
]);
|
||||
expect(customObject.getHitBoxes()[1].vertices).to.eql([
|
||||
[-24, 80],
|
||||
[-24, 64],
|
||||
[72, 80],
|
||||
[-12, 116],
|
||||
[-12, 100],
|
||||
[84, 116],
|
||||
]);
|
||||
});
|
||||
|
||||
|
@@ -9,7 +9,7 @@ describe('gdjs.Layer', function() {
|
||||
var runtimeScene = new gdjs.RuntimeScene(runtimeGame);
|
||||
|
||||
it('can convert coordinates', function(){
|
||||
var layer = new gdjs.Layer({name: 'My layer', visibility: true, effects:[]}, runtimeScene)
|
||||
var layer = new gdjs.RuntimeSceneLayer({name: 'My layer', visibility: true, effects:[]}, runtimeScene)
|
||||
layer.setCameraX(100, 0);
|
||||
layer.setCameraY(200, 0);
|
||||
layer.setCameraRotation(90, 0);
|
||||
@@ -18,7 +18,7 @@ describe('gdjs.Layer', function() {
|
||||
expect(layer.convertCoords(350, 450, 0)[1]).to.be.within(149.9999, 150.001);
|
||||
});
|
||||
it('can convert inverse coordinates', function(){
|
||||
var layer = new gdjs.Layer({name: 'My layer', visibility: true, effects:[]}, runtimeScene)
|
||||
var layer = new gdjs.RuntimeSceneLayer({name: 'My layer', visibility: true, effects:[]}, runtimeScene)
|
||||
layer.setCameraX(100, 0);
|
||||
layer.setCameraY(200, 0);
|
||||
layer.setCameraRotation(90, 0);
|
||||
|
@@ -55,7 +55,7 @@ describe('gdjs.RuntimeWatermark integration tests', () => {
|
||||
)
|
||||
throw new Error('Watermark DOM elements could not be found.');
|
||||
expect(watermark._linkElement.href).to.be(
|
||||
'https://gd.games/HelperWesley?utm_source=gdevelop-game&utm_medium=game-watermark&utm_campaign=project-uuid'
|
||||
'https://liluo.io/HelperWesley?utm_source=gdevelop-game&utm_medium=game-watermark&utm_campaign=project-uuid'
|
||||
);
|
||||
expect(watermark._containerElement.style.opacity).to.be('0');
|
||||
expect(watermark._backgroundElement.style.opacity).to.be('0');
|
||||
@@ -146,7 +146,7 @@ describe('gdjs.RuntimeWatermark integration tests', () => {
|
||||
throw new Error('Watermark DOM elements could not be found.');
|
||||
|
||||
expect(watermark._linkElement.href).to.be(
|
||||
'https://gd.games/?utm_source=gdevelop-game&utm_medium=game-watermark&utm_campaign=project-uuid'
|
||||
'https://liluo.io/?utm_source=gdevelop-game&utm_medium=game-watermark&utm_campaign=project-uuid'
|
||||
);
|
||||
expect(watermark._containerElement.style.opacity).to.be('0');
|
||||
expect(watermark._backgroundElement.style.opacity).to.be('0');
|
||||
|
@@ -864,19 +864,13 @@ interface MeasurementUnit {
|
||||
|
||||
void STATIC_ApplyTranslation();
|
||||
|
||||
[Const, Ref] MeasurementUnit STATIC_GetUndefined();
|
||||
[Const, Ref] MeasurementUnit STATIC_GetDimensionless();
|
||||
[Const, Ref] MeasurementUnit STATIC_GetDegreeAngle();
|
||||
[Const, Ref] MeasurementUnit STATIC_GetSecond();
|
||||
[Const, Ref] MeasurementUnit STATIC_GetPixel();
|
||||
[Const, Ref] MeasurementUnit STATIC_GetPixelSpeed();
|
||||
[Const, Ref] MeasurementUnit STATIC_GetPixelAcceleration();
|
||||
[Const, Ref] MeasurementUnit STATIC_GetNewton();
|
||||
|
||||
long STATIC_GetDefaultMeasurementUnitsCount();
|
||||
[Const, Ref] MeasurementUnit STATIC_GetDefaultMeasurementUnitAtIndex(long index);
|
||||
[Const, Ref] MeasurementUnit STATIC_GetDefaultMeasurementUnitByName([Const] DOMString name);
|
||||
boolean STATIC_HasDefaultMeasurementUnitNamed([Const] DOMString name);
|
||||
[Ref] MeasurementUnit STATIC_GetDimensionless();
|
||||
[Ref] MeasurementUnit STATIC_GetDegreeAngle();
|
||||
[Ref] MeasurementUnit STATIC_GetSecond();
|
||||
[Ref] MeasurementUnit STATIC_GetPixel();
|
||||
[Ref] MeasurementUnit STATIC_GetPixelSpeed();
|
||||
[Ref] MeasurementUnit STATIC_GetPixelAcceleration();
|
||||
[Ref] MeasurementUnit STATIC_GetNewton();
|
||||
};
|
||||
|
||||
interface MeasurementBaseUnit {
|
||||
@@ -1263,19 +1257,11 @@ interface InstructionMetadata {
|
||||
boolean IsPrivate();
|
||||
boolean IsAsync();
|
||||
boolean IsOptionallyAsync();
|
||||
boolean IsRelevantForLayoutEvents();
|
||||
boolean IsRelevantForFunctionEvents();
|
||||
boolean IsRelevantForAsynchronousFunctionEvents();
|
||||
boolean IsRelevantForCustomObjectEvents();
|
||||
|
||||
[Ref] InstructionMetadata SetCanHaveSubInstructions();
|
||||
[Ref] InstructionMetadata SetHelpPath([Const] DOMString helpPath);
|
||||
[Ref] InstructionMetadata SetHidden();
|
||||
[Ref] InstructionMetadata SetPrivate();
|
||||
[Ref] InstructionMetadata SetRelevantForLayoutEventsOnly();
|
||||
[Ref] InstructionMetadata SetRelevantForFunctionEventsOnly();
|
||||
[Ref] InstructionMetadata SetRelevantForAsynchronousFunctionEventsOnly();
|
||||
[Ref] InstructionMetadata SetRelevantForCustomObjectEventsOnly();
|
||||
[Ref] InstructionMetadata AddParameter([Const] DOMString type,
|
||||
[Const] DOMString description,
|
||||
[Const] DOMString optionalObjectType,
|
||||
@@ -1324,20 +1310,12 @@ interface ExpressionMetadata {
|
||||
[Const, Ref] DOMString GetHelpPath();
|
||||
boolean IsShown();
|
||||
boolean IsPrivate();
|
||||
boolean IsRelevantForLayoutEvents();
|
||||
boolean IsRelevantForFunctionEvents();
|
||||
boolean IsRelevantForAsynchronousFunctionEvents();
|
||||
boolean IsRelevantForCustomObjectEvents();
|
||||
[Ref] ParameterMetadata GetParameter(unsigned long id);
|
||||
unsigned long GetParametersCount();
|
||||
[Const, Ref] VectorParameterMetadata GetParameters();
|
||||
|
||||
[Ref] ExpressionMetadata SetHidden();
|
||||
[Ref] ExpressionMetadata SetPrivate();
|
||||
[Ref] ExpressionMetadata SetRelevantForLayoutEventsOnly();
|
||||
[Ref] ExpressionMetadata SetRelevantForFunctionEventsOnly();
|
||||
[Ref] ExpressionMetadata SetRelevantForAsynchronousFunctionEventsOnly();
|
||||
[Ref] ExpressionMetadata SetRelevantForCustomObjectEventsOnly();
|
||||
[Ref] ExpressionMetadata AddParameter(
|
||||
[Const] DOMString type,
|
||||
[Const] DOMString description,
|
||||
@@ -2167,21 +2145,13 @@ interface VectorUnfilledRequiredBehaviorPropertyProblem {
|
||||
[Const, Ref] UnfilledRequiredBehaviorPropertyProblem at(unsigned long index);
|
||||
};
|
||||
|
||||
interface ProjectBrowserHelper {
|
||||
void STATIC_ExposeProjectEvents([Ref] Project project, [Ref] ArbitraryEventsWorker worker);
|
||||
};
|
||||
|
||||
interface WholeProjectRefactorer {
|
||||
void STATIC_ExposeProjectEvents([Ref] Project project, [Ref] ArbitraryEventsWorker worker);
|
||||
void STATIC_RenameEventsFunctionsExtension(
|
||||
[Ref] Project project,
|
||||
[Const, Ref] EventsFunctionsExtension eventsFunctionsExtension,
|
||||
[Const] DOMString oldName,
|
||||
[Const] DOMString newName);
|
||||
void STATIC_UpdateExtensionNameInEventsBasedBehavior(
|
||||
[Ref] Project project,
|
||||
[Const, Ref] EventsFunctionsExtension eventsFunctionsExtension,
|
||||
[Ref] EventsBasedBehavior eventsBasedBehavior,
|
||||
[Const] DOMString sourceExtensionName);
|
||||
void STATIC_RenameEventsFunction(
|
||||
[Ref] Project project,
|
||||
[Const, Ref] EventsFunctionsExtension eventsFunctionsExtension,
|
||||
@@ -2281,10 +2251,6 @@ interface UsedExtensionsFinder {
|
||||
[Value] UsedExtensionsResult STATIC_ScanProject([Ref] Project project);
|
||||
};
|
||||
|
||||
interface InstructionsCountEvaluator {
|
||||
long STATIC_ScanProject([Ref] Project project);
|
||||
};
|
||||
|
||||
interface ExtensionAndBehaviorMetadata {
|
||||
[Const, Ref] PlatformExtension GetExtension();
|
||||
[Const, Ref] BehaviorMetadata GetMetadata();
|
||||
@@ -3184,7 +3150,6 @@ interface PreviewExportOptions {
|
||||
[Ref] PreviewExportOptions SetNonRuntimeScriptsCacheBurst(unsigned long value);
|
||||
[Ref] PreviewExportOptions SetElectronRemoteRequirePath([Const] DOMString electronRemoteRequirePath);
|
||||
[Ref] PreviewExportOptions SetGDevelopResourceToken([Const] DOMString gdevelopResourceToken);
|
||||
[Ref] PreviewExportOptions SetAllowAuthenticationUsingIframeForPreview(boolean enable);
|
||||
};
|
||||
|
||||
[Prefix="gdjs::"]
|
||||
|
@@ -40,7 +40,6 @@
|
||||
#include <GDCore/IDE/Events/InstructionsTypeRenamer.h>
|
||||
#include <GDCore/IDE/Events/TextFormatting.h>
|
||||
#include <GDCore/IDE/Events/UsedExtensionsFinder.h>
|
||||
#include <GDCore/IDE/Events/InstructionsCountEvaluator.h>
|
||||
#include <GDCore/IDE/EventsFunctionTools.h>
|
||||
#include <GDCore/IDE/Events/EventsVariablesFinder.h>
|
||||
#include <GDCore/IDE/Events/EventsIdentifiersFinder.h>
|
||||
@@ -51,7 +50,6 @@
|
||||
#include <GDCore/IDE/Project/ResourcesMergingHelper.h>
|
||||
#include <GDCore/IDE/Project/ResourcesRenamer.h>
|
||||
#include <GDCore/IDE/PropertyFunctionGenerator.h>
|
||||
#include <GDCore/IDE/ProjectBrowserHelper.h>
|
||||
#include <GDCore/IDE/WholeProjectRefactorer.h>
|
||||
#include <GDCore/IDE/UnfilledRequiredBehaviorPropertyProblem.h>
|
||||
#include <GDCore/Project/Behavior.h>
|
||||
@@ -632,7 +630,6 @@ typedef ExtensionAndMetadata<ExpressionMetadata> ExtensionAndExpressionMetadata;
|
||||
|
||||
#define STATIC_GetNamespaceSeparator GetNamespaceSeparator
|
||||
#define STATIC_RenameEventsFunctionsExtension RenameEventsFunctionsExtension
|
||||
#define STATIC_UpdateExtensionNameInEventsBasedBehavior UpdateExtensionNameInEventsBasedBehavior
|
||||
#define STATIC_RenameEventsFunction RenameEventsFunction
|
||||
#define STATIC_RenameBehaviorEventsFunction RenameBehaviorEventsFunction
|
||||
#define STATIC_RenameObjectEventsFunction RenameObjectEventsFunction
|
||||
@@ -677,7 +674,6 @@ typedef ExtensionAndMetadata<ExpressionMetadata> ExtensionAndExpressionMetadata;
|
||||
#define STATIC_ScanProject ScanProject
|
||||
|
||||
#define STATIC_ApplyTranslation ApplyTranslation
|
||||
#define STATIC_GetUndefined GetUndefined
|
||||
#define STATIC_GetDimensionless GetDimensionless
|
||||
#define STATIC_GetDegreeAngle GetDegreeAngle
|
||||
#define STATIC_GetSecond GetSecond
|
||||
@@ -685,10 +681,6 @@ typedef ExtensionAndMetadata<ExpressionMetadata> ExtensionAndExpressionMetadata;
|
||||
#define STATIC_GetPixelSpeed GetPixelSpeed
|
||||
#define STATIC_GetPixelAcceleration GetPixelAcceleration
|
||||
#define STATIC_GetNewton GetNewton
|
||||
#define STATIC_GetDefaultMeasurementUnitsCount GetDefaultMeasurementUnitsCount
|
||||
#define STATIC_GetDefaultMeasurementUnitAtIndex GetDefaultMeasurementUnitAtIndex
|
||||
#define STATIC_GetDefaultMeasurementUnitByName GetDefaultMeasurementUnitByName
|
||||
#define STATIC_HasDefaultMeasurementUnitNamed HasDefaultMeasurementUnitNamed
|
||||
|
||||
// We postfix some methods with "At" as Javascript does not support overloading
|
||||
#define GetLayoutAt GetLayout
|
||||
|
@@ -9,19 +9,11 @@ declare class gdExpressionMetadata {
|
||||
getHelpPath(): string;
|
||||
isShown(): boolean;
|
||||
isPrivate(): boolean;
|
||||
isRelevantForLayoutEvents(): boolean;
|
||||
isRelevantForFunctionEvents(): boolean;
|
||||
isRelevantForAsynchronousFunctionEvents(): boolean;
|
||||
isRelevantForCustomObjectEvents(): boolean;
|
||||
getParameter(id: number): gdParameterMetadata;
|
||||
getParametersCount(): number;
|
||||
getParameters(): gdVectorParameterMetadata;
|
||||
setHidden(): gdExpressionMetadata;
|
||||
setPrivate(): gdExpressionMetadata;
|
||||
setRelevantForLayoutEventsOnly(): gdExpressionMetadata;
|
||||
setRelevantForFunctionEventsOnly(): gdExpressionMetadata;
|
||||
setRelevantForAsynchronousFunctionEventsOnly(): gdExpressionMetadata;
|
||||
setRelevantForCustomObjectEventsOnly(): gdExpressionMetadata;
|
||||
addParameter(type: string, description: string, optionalObjectType?: string, parameterIsOptional?: boolean): gdExpressionMetadata;
|
||||
addCodeOnlyParameter(type: string, supplementaryInformation: string): gdExpressionMetadata;
|
||||
setDefaultValue(defaultValue: string): gdExpressionMetadata;
|
||||
|
@@ -17,18 +17,10 @@ declare class gdInstructionMetadata {
|
||||
isPrivate(): boolean;
|
||||
isAsync(): boolean;
|
||||
isOptionallyAsync(): boolean;
|
||||
isRelevantForLayoutEvents(): boolean;
|
||||
isRelevantForFunctionEvents(): boolean;
|
||||
isRelevantForAsynchronousFunctionEvents(): boolean;
|
||||
isRelevantForCustomObjectEvents(): boolean;
|
||||
setCanHaveSubInstructions(): gdInstructionMetadata;
|
||||
setHelpPath(helpPath: string): gdInstructionMetadata;
|
||||
setHidden(): gdInstructionMetadata;
|
||||
setPrivate(): gdInstructionMetadata;
|
||||
setRelevantForLayoutEventsOnly(): gdInstructionMetadata;
|
||||
setRelevantForFunctionEventsOnly(): gdInstructionMetadata;
|
||||
setRelevantForAsynchronousFunctionEventsOnly(): gdInstructionMetadata;
|
||||
setRelevantForCustomObjectEventsOnly(): gdInstructionMetadata;
|
||||
addParameter(type: string, description: string, optionalObjectType?: string, parameterIsOptional?: boolean): gdInstructionMetadata;
|
||||
addCodeOnlyParameter(type: string, supplementaryInformation: string): gdInstructionMetadata;
|
||||
setDefaultValue(defaultValue: string): gdInstructionMetadata;
|
||||
|
@@ -1,6 +0,0 @@
|
||||
// Automatically generated by GDevelop.js/scripts/generate-types.js
|
||||
declare class gdInstructionsCountEvaluator {
|
||||
static scanProject(project: gdProject): number;
|
||||
delete(): void;
|
||||
ptr: number;
|
||||
};
|
@@ -10,7 +10,6 @@ declare class gdMeasurementUnit {
|
||||
getElementBaseUnit(elementIndex: number): gdMeasurementBaseUnit;
|
||||
isUndefined(): boolean;
|
||||
static applyTranslation(): void;
|
||||
static getUndefined(): gdMeasurementUnit;
|
||||
static getDimensionless(): gdMeasurementUnit;
|
||||
static getDegreeAngle(): gdMeasurementUnit;
|
||||
static getSecond(): gdMeasurementUnit;
|
||||
@@ -18,10 +17,6 @@ declare class gdMeasurementUnit {
|
||||
static getPixelSpeed(): gdMeasurementUnit;
|
||||
static getPixelAcceleration(): gdMeasurementUnit;
|
||||
static getNewton(): gdMeasurementUnit;
|
||||
static getDefaultMeasurementUnitsCount(): number;
|
||||
static getDefaultMeasurementUnitAtIndex(index: number): gdMeasurementUnit;
|
||||
static getDefaultMeasurementUnitByName(name: string): gdMeasurementUnit;
|
||||
static hasDefaultMeasurementUnitNamed(name: string): boolean;
|
||||
delete(): void;
|
||||
ptr: number;
|
||||
};
|
@@ -13,7 +13,6 @@ declare class gdPreviewExportOptions {
|
||||
setNonRuntimeScriptsCacheBurst(value: number): gdPreviewExportOptions;
|
||||
setElectronRemoteRequirePath(electronRemoteRequirePath: string): gdPreviewExportOptions;
|
||||
setGDevelopResourceToken(gdevelopResourceToken: string): gdPreviewExportOptions;
|
||||
setAllowAuthenticationUsingIframeForPreview(enable: boolean): gdPreviewExportOptions;
|
||||
delete(): void;
|
||||
ptr: number;
|
||||
};
|
@@ -1,6 +0,0 @@
|
||||
// Automatically generated by GDevelop.js/scripts/generate-types.js
|
||||
declare class gdProjectBrowserHelper {
|
||||
static exposeProjectEvents(project: gdProject, worker: gdArbitraryEventsWorker): void;
|
||||
delete(): void;
|
||||
ptr: number;
|
||||
};
|
@@ -1,7 +1,7 @@
|
||||
// Automatically generated by GDevelop.js/scripts/generate-types.js
|
||||
declare class gdWholeProjectRefactorer {
|
||||
static exposeProjectEvents(project: gdProject, worker: gdArbitraryEventsWorker): void;
|
||||
static renameEventsFunctionsExtension(project: gdProject, eventsFunctionsExtension: gdEventsFunctionsExtension, oldName: string, newName: string): void;
|
||||
static updateExtensionNameInEventsBasedBehavior(project: gdProject, eventsFunctionsExtension: gdEventsFunctionsExtension, eventsBasedBehavior: gdEventsBasedBehavior, sourceExtensionName: string): void;
|
||||
static renameEventsFunction(project: gdProject, eventsFunctionsExtension: gdEventsFunctionsExtension, oldName: string, newName: string): void;
|
||||
static renameBehaviorEventsFunction(project: gdProject, eventsFunctionsExtension: gdEventsFunctionsExtension, eventsBasedBehavior: gdEventsBasedBehavior, oldName: string, newName: string): void;
|
||||
static renameObjectEventsFunction(project: gdProject, eventsFunctionsExtension: gdEventsFunctionsExtension, eventsBasedObject: gdEventsBasedObject, oldName: string, newName: string): void;
|
||||
|
@@ -151,12 +151,10 @@ declare class libGDevelop {
|
||||
EventsRefactorer: Class<gdEventsRefactorer>;
|
||||
UnfilledRequiredBehaviorPropertyProblem: Class<gdUnfilledRequiredBehaviorPropertyProblem>;
|
||||
VectorUnfilledRequiredBehaviorPropertyProblem: Class<gdVectorUnfilledRequiredBehaviorPropertyProblem>;
|
||||
ProjectBrowserHelper: Class<gdProjectBrowserHelper>;
|
||||
WholeProjectRefactorer: Class<gdWholeProjectRefactorer>;
|
||||
PropertyFunctionGenerator: Class<gdPropertyFunctionGenerator>;
|
||||
UsedExtensionsResult: Class<gdUsedExtensionsResult>;
|
||||
UsedExtensionsFinder: Class<gdUsedExtensionsFinder>;
|
||||
InstructionsCountEvaluator: Class<gdInstructionsCountEvaluator>;
|
||||
ExtensionAndBehaviorMetadata: Class<gdExtensionAndBehaviorMetadata>;
|
||||
ExtensionAndObjectMetadata: Class<gdExtensionAndObjectMetadata>;
|
||||
ExtensionAndEffectMetadata: Class<gdExtensionAndEffectMetadata>;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user