mirror of
https://github.com/4ian/GDevelop.git
synced 2025-10-15 10:19:04 +00:00
Compare commits
53 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
e916662ad4 | ||
![]() |
d7ca46455e | ||
![]() |
d193b9375e | ||
![]() |
90b830853a | ||
![]() |
f6b4cab966 | ||
![]() |
0ebec6fa02 | ||
![]() |
ab2b46adad | ||
![]() |
29fedf2efb | ||
![]() |
c0cd196a74 | ||
![]() |
18e8020bf5 | ||
![]() |
2ac85dff02 | ||
![]() |
5919c4ae20 | ||
![]() |
de12838b3f | ||
![]() |
b55f56dbd6 | ||
![]() |
c8eed6e472 | ||
![]() |
7a360b07f6 | ||
![]() |
f86fcf4190 | ||
![]() |
e4cbdd4f45 | ||
![]() |
4b5448cf00 | ||
![]() |
72e7949faf | ||
![]() |
63f9f40e3d | ||
![]() |
dfbb3515cb | ||
![]() |
7985be10cd | ||
![]() |
6de8324943 | ||
![]() |
79a14e220d | ||
![]() |
4575935a42 | ||
![]() |
134886eedc | ||
![]() |
da308bb104 | ||
![]() |
5087526066 | ||
![]() |
b6f98ad667 | ||
![]() |
b4a6b73146 | ||
![]() |
2ccdc1aad8 | ||
![]() |
68f13297ef | ||
![]() |
6a26e2cf32 | ||
![]() |
9532a42558 | ||
![]() |
f23bc5dfd9 | ||
![]() |
4a4bf6d761 | ||
![]() |
68968b603a | ||
![]() |
eb723b2a0e | ||
![]() |
c51e6fa04e | ||
![]() |
a0ad9200cf | ||
![]() |
99804f366a | ||
![]() |
71fead702d | ||
![]() |
54c9177b03 | ||
![]() |
8157d3c9db | ||
![]() |
03e0da8619 | ||
![]() |
be84b2153f | ||
![]() |
10591a41e6 | ||
![]() |
d41cc18be2 | ||
![]() |
fb6e09d0e3 | ||
![]() |
8766f73333 | ||
![]() |
b32a9006c6 | ||
![]() |
2d613e7281 |
14
.devcontainer/devcontainer.json
Normal file
14
.devcontainer/devcontainer.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"image": "mcr.microsoft.com/devcontainers/universal:2",
|
||||
"onCreateCommand": "cd newIDE/app && npm install && cd ../electron-app && npm install",
|
||||
"forwardPorts": [3000],
|
||||
"customizations": {
|
||||
"vscode": {
|
||||
"extensions": [
|
||||
"esbenp.prettier-vscode",
|
||||
"ms-vscode.cpptools",
|
||||
"flowtype.flow-for-vscode"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
@@ -15,16 +15,48 @@
|
||||
#include "GDCore/Project/Layout.h"
|
||||
#include "GDCore/Project/Object.h"
|
||||
#include "GDCore/Project/Project.h"
|
||||
#include "GDCore/IDE/ProjectBrowserHelper.h"
|
||||
|
||||
namespace gd {
|
||||
|
||||
void ExposeProjectEffects(
|
||||
const gd::Project& project,
|
||||
const std::function<void(const gd::Effect& effect)>& worker) {
|
||||
void EffectsCodeGenerator::DoVisitObject(gd::Object &object) {
|
||||
auto &effects = object.GetEffects();
|
||||
for (std::size_t e = 0; e < effects.GetEffectsCount(); e++) {
|
||||
auto &effect = effects.GetEffect(e);
|
||||
AddEffectIncludeFiles(effect);
|
||||
}
|
||||
};
|
||||
|
||||
void EffectsCodeGenerator::AddEffectIncludeFiles(const gd::Effect &effect) {
|
||||
// TODO: this browse all the extensions every time we're trying to find
|
||||
// a new effect. Might be a good idea to rework MetadataProvider to be
|
||||
// faster (not sure if it is a bottleneck at all though - but could be
|
||||
// for events code generation).
|
||||
const gd::EffectMetadata &effectMetadata =
|
||||
MetadataProvider::GetEffectMetadata(platform, effect.GetEffectType());
|
||||
|
||||
for (auto &includeFile : effectMetadata.GetIncludeFiles())
|
||||
includeFiles.insert(includeFile);
|
||||
};
|
||||
|
||||
void EffectsCodeGenerator::GenerateEffectsIncludeFiles(
|
||||
const gd::Platform &platform,
|
||||
gd::Project &project,
|
||||
std::set<gd::String> &includeFiles) {
|
||||
// TODO Add unit tests on this function.
|
||||
|
||||
// TODO Merge with UsedExtensionsFinder.
|
||||
// Default lights rely on the fact that UsedExtensionsFinder doesn't find
|
||||
// extension usages for effects. This has the happy side effect of not
|
||||
// including Three.js when no 3D object are in the scenes.
|
||||
// We need to make something explicit to avoid future bugs.
|
||||
|
||||
// See also gd::Project::ExposeResources for a method that traverse the whole
|
||||
// project (this time for resources) and
|
||||
// WholeProjectRefactorer::ExposeProjectEvents.
|
||||
|
||||
EffectsCodeGenerator effectsCodeGenerator(platform, includeFiles);
|
||||
|
||||
// Add layouts effects
|
||||
for (std::size_t s = 0; s < project.GetLayoutsCount(); s++) {
|
||||
auto& layout = project.GetLayout(s);
|
||||
@@ -33,47 +65,13 @@ void ExposeProjectEffects(
|
||||
auto& effects = layout.GetLayer(l).GetEffects();
|
||||
for (std::size_t e = 0; e < effects.GetEffectsCount(); ++e) {
|
||||
auto& effect = effects.GetEffect(e);
|
||||
worker(effect);
|
||||
}
|
||||
}
|
||||
|
||||
for (std::size_t i = 0; i < layout.GetObjectsCount(); i++) {
|
||||
auto& object = layout.GetObject(i);
|
||||
auto& effects = object.GetEffects();
|
||||
for (std::size_t e = 0; e < effects.GetEffectsCount(); e++) {
|
||||
auto& effect = effects.GetEffect(e);
|
||||
worker(effect);
|
||||
effectsCodeGenerator.AddEffectIncludeFiles(effect);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add global object effects
|
||||
for (std::size_t s = 0; s < project.GetObjectsCount(); s++) {
|
||||
auto& effects = project.GetObject(s).GetEffects();
|
||||
for (std::size_t e = 0; e < effects.GetEffectsCount(); e++) {
|
||||
auto& effect = effects.GetEffect(e);
|
||||
worker(effect);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EffectsCodeGenerator::GenerateEffectsIncludeFiles(
|
||||
const gd::Platform& platform,
|
||||
const gd::Project& project,
|
||||
std::set<gd::String>& includeFiles) {
|
||||
ExposeProjectEffects(
|
||||
project, [&platform, &includeFiles](const gd::Effect& effect) {
|
||||
// TODO: this browse all the extensions every time we're trying to find
|
||||
// a new effect. Might be a good idea to rework MetadataProvider to be
|
||||
// faster (not sure if it is a bottleneck at all though - but could be
|
||||
// for events code generation).
|
||||
const gd::EffectMetadata& effectMetadata =
|
||||
MetadataProvider::GetEffectMetadata(platform,
|
||||
effect.GetEffectType());
|
||||
|
||||
for (auto& includeFile : effectMetadata.GetIncludeFiles())
|
||||
includeFiles.insert(includeFile);
|
||||
});
|
||||
// Add objects effects
|
||||
gd::ProjectBrowserHelper::ExposeProjectObjects(project, effectsCodeGenerator);
|
||||
}
|
||||
|
||||
} // namespace gd
|
||||
|
@@ -3,16 +3,18 @@
|
||||
* Copyright 2008-present Florian Rival (Florian.Rival@gmail.com). All rights
|
||||
* reserved. This project is released under the MIT License.
|
||||
*/
|
||||
#ifndef GDCORE_EffectsCodeGenerator_H
|
||||
#define GDCORE_EffectsCodeGenerator_H
|
||||
#pragma once
|
||||
|
||||
#include <set>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
#include "GDCore/String.h"
|
||||
#include "GDCore/IDE/Project/ArbitraryObjectsWorker.h"
|
||||
|
||||
namespace gd {
|
||||
class Project;
|
||||
class Platform;
|
||||
class Effect;
|
||||
} // namespace gd
|
||||
|
||||
namespace gd {
|
||||
@@ -20,16 +22,26 @@ namespace gd {
|
||||
/**
|
||||
* \brief Internal class used to generate code from events
|
||||
*/
|
||||
class GD_CORE_API EffectsCodeGenerator {
|
||||
public:
|
||||
class GD_CORE_API EffectsCodeGenerator : public ArbitraryObjectsWorker {
|
||||
public:
|
||||
/**
|
||||
* \brief Add all the include files required by the project effects.
|
||||
*/
|
||||
static void GenerateEffectsIncludeFiles(const gd::Platform& platform,
|
||||
const gd::Project& project,
|
||||
gd::Project& project,
|
||||
std::set<gd::String>& includeFiles);
|
||||
|
||||
private:
|
||||
EffectsCodeGenerator(const gd::Platform &platform_,
|
||||
std::set<gd::String> &includeFiles_)
|
||||
: platform(platform_), includeFiles(includeFiles_){};
|
||||
|
||||
void AddEffectIncludeFiles(const gd::Effect& effect);
|
||||
|
||||
void DoVisitObject(gd::Object &object) override;
|
||||
|
||||
const gd::Platform &platform;
|
||||
std::set<gd::String> &includeFiles;
|
||||
};
|
||||
|
||||
} // namespace gd
|
||||
|
||||
#endif // GDCORE_EffectsCodeGenerator_H
|
||||
|
@@ -323,11 +323,6 @@ gd::String EventsCodeGenerator::GenerateConditionCode(
|
||||
const ObjectMetadata& objInfo =
|
||||
MetadataProvider::GetObjectMetadata(platform, objectType);
|
||||
|
||||
if (objInfo.IsUnsupportedBaseObjectCapability(
|
||||
instrInfos.GetRequiredBaseObjectCapability())) {
|
||||
conditionCode +=
|
||||
"/* Object with unsupported capability - skipped. */\n";
|
||||
} else {
|
||||
AddIncludeFiles(objInfo.includeFiles);
|
||||
context.SetCurrentObject(realObjects[i]);
|
||||
context.ObjectsListNeeded(realObjects[i]);
|
||||
@@ -344,7 +339,6 @@ gd::String EventsCodeGenerator::GenerateConditionCode(
|
||||
context);
|
||||
|
||||
context.SetNoCurrentObject();
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (instrInfos.IsBehaviorInstruction()) {
|
||||
@@ -515,10 +509,6 @@ gd::String EventsCodeGenerator::GenerateActionCode(
|
||||
const ObjectMetadata& objInfo =
|
||||
MetadataProvider::GetObjectMetadata(platform, objectType);
|
||||
|
||||
if (objInfo.IsUnsupportedBaseObjectCapability(
|
||||
instrInfos.GetRequiredBaseObjectCapability())) {
|
||||
actionCode += "/* Object with unsupported capability - skipped. */\n";
|
||||
} else {
|
||||
AddIncludeFiles(objInfo.includeFiles);
|
||||
context.SetCurrentObject(realObjects[i]);
|
||||
context.ObjectsListNeeded(realObjects[i]);
|
||||
@@ -535,7 +525,6 @@ gd::String EventsCodeGenerator::GenerateActionCode(
|
||||
optionalAsyncCallbackName);
|
||||
|
||||
context.SetNoCurrentObject();
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (instrInfos.IsBehaviorInstruction()) {
|
||||
|
@@ -270,11 +270,6 @@ gd::String ExpressionCodeGenerator::GenerateObjectFunctionCode(
|
||||
const ObjectMetadata& objInfo = MetadataProvider::GetObjectMetadata(
|
||||
codeGenerator.GetPlatform(), objectType);
|
||||
|
||||
if (objInfo.IsUnsupportedBaseObjectCapability(
|
||||
expressionMetadata.GetRequiredBaseObjectCapability())) {
|
||||
// Do nothing, skipping objects not supporting the capability required by
|
||||
// this expression.
|
||||
} else {
|
||||
codeGenerator.AddIncludeFiles(objInfo.includeFiles);
|
||||
functionOutput = codeGenerator.GenerateObjectFunctionCall(
|
||||
realObjects[i],
|
||||
@@ -283,7 +278,6 @@ gd::String ExpressionCodeGenerator::GenerateObjectFunctionCode(
|
||||
parametersCode,
|
||||
functionOutput,
|
||||
context);
|
||||
}
|
||||
}
|
||||
|
||||
return functionOutput;
|
||||
|
@@ -19,8 +19,10 @@
|
||||
#include "GDCore/Project/Project.h"
|
||||
#include "GDCore/Tools/Localization.h"
|
||||
#include "GDCore/Tools/MakeUnique.h"
|
||||
#include "GrammarTerminals.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace gd::GrammarTerminals;
|
||||
|
||||
namespace gd {
|
||||
|
||||
|
@@ -18,6 +18,7 @@
|
||||
#include "GDCore/String.h"
|
||||
#include "GDCore/Tools/Localization.h"
|
||||
#include "GDCore/Tools/MakeUnique.h"
|
||||
#include "GrammarTerminals.h"
|
||||
namespace gd {
|
||||
class Expression;
|
||||
class ObjectsContainer;
|
||||
@@ -28,6 +29,8 @@ class ExpressionMetadata;
|
||||
|
||||
namespace gd {
|
||||
|
||||
using namespace gd::GrammarTerminals;
|
||||
|
||||
/** \brief Parse an expression, returning a tree of node corresponding
|
||||
* to the parsed expression.
|
||||
*
|
||||
@@ -211,7 +214,7 @@ class GD_CORE_API ExpressionParser2 {
|
||||
}
|
||||
SkipIfChar(IsClosingParenthesis);
|
||||
return factor;
|
||||
} else if (IsIdentifierAllowedChar()) {
|
||||
} else if (CheckIfChar(IsAllowedInIdentifier)) {
|
||||
return Identifier();
|
||||
}
|
||||
|
||||
@@ -606,95 +609,6 @@ class GD_CORE_API ExpressionParser2 {
|
||||
return predicate(character);
|
||||
}
|
||||
|
||||
bool IsIdentifierAllowedChar() {
|
||||
if (currentPosition >= expression.size()) return false;
|
||||
gd::String::value_type character = expression[currentPosition];
|
||||
|
||||
// Quickly compare if the character is a number or ASCII character.
|
||||
if ((character >= '0' && character <= '9') ||
|
||||
(character >= 'A' && character <= 'Z') ||
|
||||
(character >= 'a' && character <= 'z'))
|
||||
return true;
|
||||
|
||||
// Otherwise do the full check against separators forbidden in identifiers.
|
||||
if (!IsParameterSeparator(character) && !IsDot(character) &&
|
||||
!IsQuote(character) && !IsBracket(character) &&
|
||||
!IsExpressionOperator(character) && !IsTermOperator(character)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool IsWhitespace(gd::String::value_type character) {
|
||||
return character == ' ' || character == '\n' || character == '\r';
|
||||
}
|
||||
|
||||
static bool IsParameterSeparator(gd::String::value_type character) {
|
||||
return character == ',';
|
||||
}
|
||||
|
||||
static bool IsDot(gd::String::value_type character) {
|
||||
return character == '.';
|
||||
}
|
||||
|
||||
static bool IsQuote(gd::String::value_type character) {
|
||||
return character == '"';
|
||||
}
|
||||
|
||||
static bool IsBracket(gd::String::value_type character) {
|
||||
return character == '(' || character == ')' || character == '[' ||
|
||||
character == ']' || character == '{' || character == '}';
|
||||
}
|
||||
|
||||
static bool IsOpeningParenthesis(gd::String::value_type character) {
|
||||
return character == '(';
|
||||
}
|
||||
|
||||
static bool IsClosingParenthesis(gd::String::value_type character) {
|
||||
return character == ')';
|
||||
}
|
||||
|
||||
static bool IsOpeningSquareBracket(gd::String::value_type character) {
|
||||
return character == '[';
|
||||
}
|
||||
|
||||
static bool IsClosingSquareBracket(gd::String::value_type character) {
|
||||
return character == ']';
|
||||
}
|
||||
|
||||
static bool IsExpressionEndingChar(gd::String::value_type character) {
|
||||
return character == ',' || IsClosingParenthesis(character) ||
|
||||
IsClosingSquareBracket(character);
|
||||
}
|
||||
|
||||
static bool IsExpressionOperator(gd::String::value_type character) {
|
||||
return character == '+' || character == '-' || character == '<' ||
|
||||
character == '>' || character == '?' || character == '^' ||
|
||||
character == '=' || character == '\\' || character == ':' ||
|
||||
character == '!';
|
||||
}
|
||||
|
||||
static bool IsUnaryOperator(gd::String::value_type character) {
|
||||
return character == '+' || character == '-';
|
||||
}
|
||||
|
||||
static bool IsTermOperator(gd::String::value_type character) {
|
||||
return character == '/' || character == '*';
|
||||
}
|
||||
|
||||
static bool IsNumberFirstChar(gd::String::value_type character) {
|
||||
return character == '.' || (character >= '0' && character <= '9');
|
||||
}
|
||||
|
||||
static bool IsNonZeroDigit(gd::String::value_type character) {
|
||||
return (character >= '1' && character <= '9');
|
||||
}
|
||||
|
||||
static bool IsZeroDigit(gd::String::value_type character) {
|
||||
return character == '0';
|
||||
}
|
||||
|
||||
bool IsNamespaceSeparator() {
|
||||
// Namespace separator is a special kind of delimiter as it is 2 characters
|
||||
// long
|
||||
@@ -715,7 +629,7 @@ class GD_CORE_API ExpressionParser2 {
|
||||
gd::String name;
|
||||
size_t startPosition = currentPosition;
|
||||
while (currentPosition < expression.size() &&
|
||||
(IsIdentifierAllowedChar()
|
||||
(CheckIfChar(IsAllowedInIdentifier)
|
||||
// Allow whitespace in identifier name for compatibility
|
||||
|| expression[currentPosition] == ' ')) {
|
||||
name += expression[currentPosition];
|
||||
|
107
Core/GDCore/Events/Parsers/GrammarTerminals.h
Normal file
107
Core/GDCore/Events/Parsers/GrammarTerminals.h
Normal file
@@ -0,0 +1,107 @@
|
||||
#pragma once
|
||||
#include "GDCore/String.h"
|
||||
|
||||
namespace gd {
|
||||
|
||||
/**
|
||||
* Contains functions to handle the grammar of the expressions accepted by GDevelop.
|
||||
*/
|
||||
namespace GrammarTerminals {
|
||||
|
||||
inline bool IsWhitespace(gd::String::value_type character) {
|
||||
return character == ' ' || character == '\n' || character == '\r';
|
||||
}
|
||||
|
||||
inline bool IsParameterSeparator(gd::String::value_type character) {
|
||||
return character == ',';
|
||||
}
|
||||
|
||||
inline bool IsDot(gd::String::value_type character) { return character == '.'; }
|
||||
|
||||
inline bool IsQuote(gd::String::value_type character) {
|
||||
return character == '"';
|
||||
}
|
||||
|
||||
inline bool IsBracket(gd::String::value_type character) {
|
||||
return character == '(' || character == ')' || character == '[' ||
|
||||
character == ']' || character == '{' || character == '}';
|
||||
}
|
||||
|
||||
inline bool IsOpeningParenthesis(gd::String::value_type character) {
|
||||
return character == '(';
|
||||
}
|
||||
|
||||
inline bool IsClosingParenthesis(gd::String::value_type character) {
|
||||
return character == ')';
|
||||
}
|
||||
|
||||
inline bool IsOpeningSquareBracket(gd::String::value_type character) {
|
||||
return character == '[';
|
||||
}
|
||||
|
||||
inline bool IsClosingSquareBracket(gd::String::value_type character) {
|
||||
return character == ']';
|
||||
}
|
||||
|
||||
inline bool IsExpressionEndingChar(gd::String::value_type character) {
|
||||
return character == ',' || IsClosingParenthesis(character) ||
|
||||
IsClosingSquareBracket(character);
|
||||
}
|
||||
|
||||
inline bool IsExpressionOperator(gd::String::value_type character) {
|
||||
return character == '+' || character == '-' || character == '<' ||
|
||||
character == '>' || character == '?' || character == '^' ||
|
||||
character == '=' || character == '\\' || character == ':' ||
|
||||
character == '!';
|
||||
}
|
||||
|
||||
inline bool IsUnaryOperator(gd::String::value_type character) {
|
||||
return character == '+' || character == '-';
|
||||
}
|
||||
|
||||
inline bool IsTermOperator(gd::String::value_type character) {
|
||||
return character == '/' || character == '*';
|
||||
}
|
||||
|
||||
inline bool IsNumberFirstChar(gd::String::value_type character) {
|
||||
return character == '.' || (character >= '0' && character <= '9');
|
||||
}
|
||||
|
||||
inline bool IsNonZeroDigit(gd::String::value_type character) {
|
||||
return (character >= '1' && character <= '9');
|
||||
}
|
||||
|
||||
inline bool IsZeroDigit(gd::String::value_type character) {
|
||||
return character == '0';
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the given character can be used in an identifier. This is
|
||||
* any unicode character, except for:
|
||||
* `, . " () [] {} + - < > ? ^ = \ : ! / *` and whitespaces (space, line break, carriage return).
|
||||
*
|
||||
* This is loosely based on what is allowed in languages like JavaScript
|
||||
* (see https://mathiasbynens.be/notes/javascript-properties), without support
|
||||
* for unicode escape syntax, and allowing all unicode ranges. The only
|
||||
* disallowed characters are the one used for the grammar.
|
||||
*/
|
||||
inline bool IsAllowedInIdentifier(gd::String::value_type character) {
|
||||
// Quickly compare if the character is a number or ASCII character.
|
||||
if ((character >= '0' && character <= '9') ||
|
||||
(character >= 'A' && character <= 'Z') ||
|
||||
(character >= 'a' && character <= 'z'))
|
||||
return true;
|
||||
|
||||
// Otherwise do the full check against separators forbidden in identifiers.
|
||||
if (!IsParameterSeparator(character) && !IsDot(character) &&
|
||||
!IsQuote(character) && !IsBracket(character) &&
|
||||
!IsExpressionOperator(character) && !IsTermOperator(character) &&
|
||||
!IsWhitespace(character)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace GrammarTerminals
|
||||
} // namespace gd
|
@@ -43,6 +43,12 @@ class GD_CORE_API BuiltinExtensionsImplementer {
|
||||
static void ImplementsVariablesExtension(gd::PlatformExtension& extension);
|
||||
static void ImplementsWindowExtension(gd::PlatformExtension& extension);
|
||||
static void ImplementsAsyncExtension(gd::PlatformExtension& extension);
|
||||
static void ImplementsResizableExtension(gd::PlatformExtension& extension);
|
||||
static void ImplementsScalableExtension(gd::PlatformExtension& extension);
|
||||
static void ImplementsFlippableExtension(gd::PlatformExtension& extension);
|
||||
static void ImplementsAnimatableExtension(gd::PlatformExtension& extension);
|
||||
static void ImplementsEffectExtension(gd::PlatformExtension& extension);
|
||||
static void ImplementsOpacityExtension(gd::PlatformExtension& extension);
|
||||
};
|
||||
|
||||
} // namespace gd
|
||||
|
@@ -29,8 +29,16 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
||||
.SetIcon("res/actions/force24.png");
|
||||
extension.AddInstructionOrExpressionGroupMetadata(_("Variables"))
|
||||
.SetIcon("res/conditions/var24.png");
|
||||
extension.AddInstructionOrExpressionGroupMetadata(_("Timers"))
|
||||
.SetIcon("res/actions/timer24.png");
|
||||
extension.AddInstructionOrExpressionGroupMetadata(_("Visibility"))
|
||||
.SetIcon("res/actions/visibilite24.png");
|
||||
extension.AddInstructionOrExpressionGroupMetadata(_("Position"))
|
||||
.SetIcon("res/actions/position24_black.png");
|
||||
extension.AddInstructionOrExpressionGroupMetadata(_("Angle"))
|
||||
.SetIcon("res/actions/direction24_black.png");
|
||||
extension.AddInstructionOrExpressionGroupMetadata(_("Size"))
|
||||
.SetIcon("res/actions/scale24_black.png");
|
||||
|
||||
gd::ObjectMetadata& obj = extension.AddObject<gd::ObjectConfiguration>(
|
||||
"", _("Base object"), _("Base object"), "res/objeticon24.png");
|
||||
@@ -1101,6 +1109,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
||||
"res/actions/scaleWidth_black.png")
|
||||
.AddParameter("object", _("Object"));
|
||||
|
||||
// Deprecated
|
||||
obj.AddExpression("Largeur",
|
||||
_("Width"),
|
||||
_("Width of the object"),
|
||||
@@ -1116,6 +1125,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
||||
"res/actions/scaleHeight_black.png")
|
||||
.AddParameter("object", _("Object"));
|
||||
|
||||
// Deprecated
|
||||
obj.AddExpression("Hauteur",
|
||||
_("Height"),
|
||||
_("Height of the object"),
|
||||
@@ -1201,7 +1211,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
||||
obj.AddExpression("ObjectTimerElapsedTime",
|
||||
_("Object timer value"),
|
||||
_("Value of an object timer"),
|
||||
_("Object timers"),
|
||||
_("Timers"),
|
||||
"res/actions/time.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddParameter("identifier", _("Timer's name"), "objectTimer");
|
||||
@@ -1251,6 +1261,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
||||
.AddParameter("expression", _("Target X position"))
|
||||
.AddParameter("expression", _("Target Y position"));
|
||||
|
||||
// Deprecated
|
||||
obj.AddAction("EnableEffect",
|
||||
_("Enable an object effect"),
|
||||
_("Enable an effect on the object"),
|
||||
@@ -1262,8 +1273,9 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
||||
.AddParameter("objectEffectName", _("Effect name"))
|
||||
.AddParameter("yesorno", _("Enable?"))
|
||||
.MarkAsSimple()
|
||||
.SetRequiresBaseObjectCapability("effect");
|
||||
.SetHidden();
|
||||
|
||||
// Deprecated
|
||||
obj.AddAction("SetEffectDoubleParameter",
|
||||
_("Effect parameter (number)"),
|
||||
_("Change the value of a parameter of an effect.") + "\n" +
|
||||
@@ -1278,8 +1290,9 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
||||
.AddParameter("objectEffectParameterName", _("Parameter name"))
|
||||
.AddParameter("expression", _("New value"))
|
||||
.MarkAsSimple()
|
||||
.SetRequiresBaseObjectCapability("effect");
|
||||
.SetHidden();
|
||||
|
||||
// Deprecated
|
||||
obj.AddAction("SetEffectStringParameter",
|
||||
_("Effect parameter (string)"),
|
||||
_("Change the value (string) of a parameter of an effect.") +
|
||||
@@ -1295,8 +1308,9 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
||||
.AddParameter("objectEffectParameterName", _("Parameter name"))
|
||||
.AddParameter("string", _("New value"))
|
||||
.MarkAsSimple()
|
||||
.SetRequiresBaseObjectCapability("effect");
|
||||
.SetHidden();
|
||||
|
||||
// Deprecated
|
||||
obj.AddAction("SetEffectBooleanParameter",
|
||||
_("Effect parameter (enable or disable)"),
|
||||
_("Enable or disable a parameter of an effect.") + "\n" +
|
||||
@@ -1311,8 +1325,9 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
||||
.AddParameter("objectEffectParameterName", _("Parameter name"))
|
||||
.AddParameter("yesorno", _("Enable?"))
|
||||
.MarkAsSimple()
|
||||
.SetRequiresBaseObjectCapability("effect");
|
||||
.SetHidden();
|
||||
|
||||
// Deprecated
|
||||
obj.AddCondition("IsEffectEnabled",
|
||||
_("Effect is enabled"),
|
||||
_("Check if the effect on an object is enabled."),
|
||||
@@ -1323,7 +1338,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddParameter("objectEffectName", _("Effect name"))
|
||||
.MarkAsSimple()
|
||||
.SetRequiresBaseObjectCapability("effect");
|
||||
.SetHidden();
|
||||
|
||||
obj.AddAction("SetIncludedInParentCollisionMask",
|
||||
_("Include in parent collision mask"),
|
||||
|
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
* GDevelop Core
|
||||
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
|
||||
* reserved. This project is released under the GNU Lesser General Public
|
||||
* License.
|
||||
*/
|
||||
#include "GDCore/Extensions/Builtin/AllBuiltinExtensions.h"
|
||||
#include "GDCore/Extensions/Metadata/MultipleInstructionMetadata.h"
|
||||
#include "GDCore/Project/Behavior.h"
|
||||
#include "GDCore/Project/BehaviorsSharedData.h"
|
||||
#include "GDCore/Project/Object.h"
|
||||
#include "GDCore/Tools/Localization.h"
|
||||
|
||||
using namespace std;
|
||||
namespace gd {
|
||||
|
||||
void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAnimatableExtension(
|
||||
gd::PlatformExtension& extension) {
|
||||
extension
|
||||
.SetExtensionInformation("AnimatableCapability",
|
||||
_("Animatable capability"),
|
||||
_("Animate objects."),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)")
|
||||
.SetExtensionHelpPath("/objects");
|
||||
extension.AddInstructionOrExpressionGroupMetadata(_("Animations and images"))
|
||||
.SetIcon("res/actions/animation24.png");
|
||||
|
||||
gd::BehaviorMetadata& aut = extension.AddBehavior(
|
||||
"AnimatableBehavior",
|
||||
_("Animatable capability"),
|
||||
"Animation",
|
||||
_("Animate objects."),
|
||||
"",
|
||||
"res/actions/animation24.png",
|
||||
"AnimatableBehavior",
|
||||
std::make_shared<gd::Behavior>(),
|
||||
std::make_shared<gd::BehaviorsSharedData>())
|
||||
.SetHidden();
|
||||
|
||||
aut.AddExpressionAndConditionAndAction(
|
||||
"number",
|
||||
"Index",
|
||||
_("Animation (by number)"),
|
||||
_("the number of the animation played by the object (the number from "
|
||||
"the animations list)"),
|
||||
_("the number of the animation"),
|
||||
_("Animations and images"),
|
||||
"res/actions/animation24.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddParameter("behavior", _("Behavior"), "AnimatableBehavior")
|
||||
.UseStandardParameters(
|
||||
"number", gd::ParameterOptions::MakeNewOptions().SetDescription(
|
||||
_("Animation index")))
|
||||
.MarkAsSimple();
|
||||
|
||||
aut.AddExpressionAndConditionAndAction(
|
||||
"string",
|
||||
"Name",
|
||||
_("Animation (by name)"),
|
||||
_("the animation played by the object using the name of the "
|
||||
"animation."),
|
||||
_("the animation"),
|
||||
_("Animations and images"),
|
||||
"res/actions/animation24.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddParameter("behavior", _("Behavior"), "AnimatableBehavior")
|
||||
.UseStandardParameters(
|
||||
"objectAnimationName", gd::ParameterOptions::MakeNewOptions().SetDescription(
|
||||
_("Animation name")))
|
||||
.MarkAsSimple();
|
||||
|
||||
aut.AddScopedAction("PauseAnimation",
|
||||
_("Pause the animation"),
|
||||
_("Pause the animation of the object"),
|
||||
_("Pause the animation of _PARAM0_"),
|
||||
_("Animations and images"),
|
||||
"res/actions/animation24.png",
|
||||
"res/actions/animation.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddParameter("behavior", _("Behavior"), "AnimatableBehavior")
|
||||
.MarkAsSimple();
|
||||
|
||||
aut.AddScopedAction("PlayAnimation",
|
||||
_("Resume the animation"),
|
||||
_("Resume the animation of the object"),
|
||||
_("Resume the animation of _PARAM0_"),
|
||||
_("Animations and images"),
|
||||
"res/actions/animation24.png",
|
||||
"res/actions/animation.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddParameter("behavior", _("Behavior"), "AnimatableBehavior")
|
||||
.MarkAsSimple();
|
||||
|
||||
aut.AddExpressionAndConditionAndAction(
|
||||
"number",
|
||||
"SpeedScale",
|
||||
_("Animation speed scale"),
|
||||
_("the animation speed scale (1 = the default speed, >1 = faster and "
|
||||
"<1 = slower)"),
|
||||
_("the animation speed scale"),
|
||||
_("Animations and images"),
|
||||
"res/actions/animation24.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddParameter("behavior", _("Behavior"), "AnimatableBehavior")
|
||||
.UseStandardParameters(
|
||||
"number", gd::ParameterOptions::MakeNewOptions().SetDescription(
|
||||
_("Speed scale")))
|
||||
.MarkAsSimple();
|
||||
|
||||
aut.AddScopedCondition("IsAnimationPaused",
|
||||
_("Animation paused"),
|
||||
_("Check if the animation of an object is paused."),
|
||||
_("The animation of _PARAM0_ is paused"),
|
||||
_("Animations and images"),
|
||||
"res/conditions/animation24.png",
|
||||
"res/conditions/animation.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddParameter("behavior", _("Behavior"), "AnimatableBehavior")
|
||||
.MarkAsSimple();
|
||||
|
||||
aut.AddScopedCondition("HasAnimationEnded",
|
||||
_("Animation finished"),
|
||||
_("Check if the animation being played by the Sprite object "
|
||||
"is finished."),
|
||||
_("The animation of _PARAM0_ is finished"),
|
||||
_("Animations and images"),
|
||||
"res/conditions/animation24.png",
|
||||
"res/conditions/animation.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddParameter("behavior", _("Behavior"), "AnimatableBehavior")
|
||||
.MarkAsSimple();
|
||||
}
|
||||
|
||||
} // namespace gd
|
116
Core/GDCore/Extensions/Builtin/Capabilities/EffectExtension.cpp
Normal file
116
Core/GDCore/Extensions/Builtin/Capabilities/EffectExtension.cpp
Normal file
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* GDevelop Core
|
||||
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
|
||||
* reserved. This project is released under the GNU Lesser General Public
|
||||
* License.
|
||||
*/
|
||||
#include "GDCore/Extensions/Builtin/AllBuiltinExtensions.h"
|
||||
#include "GDCore/Extensions/Metadata/MultipleInstructionMetadata.h"
|
||||
#include "GDCore/Project/Behavior.h"
|
||||
#include "GDCore/Project/BehaviorsSharedData.h"
|
||||
#include "GDCore/Project/Object.h"
|
||||
#include "GDCore/Tools/Localization.h"
|
||||
|
||||
using namespace std;
|
||||
namespace gd {
|
||||
|
||||
void GD_CORE_API BuiltinExtensionsImplementer::ImplementsEffectExtension(
|
||||
gd::PlatformExtension& extension) {
|
||||
extension
|
||||
.SetExtensionInformation("EffectCapability",
|
||||
_("Effect capability"),
|
||||
_("Apply visual effects to objects."),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)")
|
||||
.SetExtensionHelpPath("/objects");
|
||||
extension.AddInstructionOrExpressionGroupMetadata(_("Effects"))
|
||||
.SetIcon("res/actions/effect24.png");
|
||||
|
||||
gd::BehaviorMetadata& aut = extension.AddBehavior(
|
||||
"EffectBehavior",
|
||||
_("Effect capability"),
|
||||
"Effect",
|
||||
_("Apply visual effects to objects."),
|
||||
"",
|
||||
"res/actions/effect24.png",
|
||||
"EffectBehavior",
|
||||
std::make_shared<gd::Behavior>(),
|
||||
std::make_shared<gd::BehaviorsSharedData>())
|
||||
.SetHidden();
|
||||
|
||||
aut.AddScopedAction("EnableEffect",
|
||||
_("Enable an object effect"),
|
||||
_("Enable an effect on the object"),
|
||||
_("Enable effect _PARAM2_ on _PARAM0_: _PARAM3_"),
|
||||
_("Effects"),
|
||||
"res/actions/effect24.png",
|
||||
"res/actions/effect.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddParameter("behavior", _("Behavior"), "EffectBehavior")
|
||||
.AddParameter("objectEffectName", _("Effect name"))
|
||||
.AddParameter("yesorno", _("Enable?"))
|
||||
.MarkAsSimple();
|
||||
|
||||
aut.AddScopedAction("SetEffectDoubleParameter",
|
||||
_("Effect parameter (number)"),
|
||||
_("Change the value of a parameter of an effect.") + "\n" +
|
||||
_("You can find the parameter names (and change the effect "
|
||||
"names) in the effects window."),
|
||||
_("Set _PARAM3_ to _PARAM4_ for effect _PARAM2_ of _PARAM0_"),
|
||||
_("Effects"),
|
||||
"res/actions/effect24.png",
|
||||
"res/actions/effect.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddParameter("behavior", _("Behavior"), "EffectBehavior")
|
||||
.AddParameter("objectEffectName", _("Effect name"))
|
||||
.AddParameter("objectEffectParameterName", _("Parameter name"))
|
||||
.AddParameter("expression", _("New value"))
|
||||
.MarkAsSimple();
|
||||
|
||||
aut.AddScopedAction("SetEffectStringParameter",
|
||||
_("Effect parameter (string)"),
|
||||
_("Change the value (string) of a parameter of an effect.") +
|
||||
"\n" +
|
||||
_("You can find the parameter names (and change the effect "
|
||||
"names) in the effects window."),
|
||||
_("Set _PARAM3_ to _PARAM4_ for effect _PARAM2_ of _PARAM0_"),
|
||||
_("Effects"),
|
||||
"res/actions/effect24.png",
|
||||
"res/actions/effect.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddParameter("behavior", _("Behavior"), "EffectBehavior")
|
||||
.AddParameter("objectEffectName", _("Effect name"))
|
||||
.AddParameter("objectEffectParameterName", _("Parameter name"))
|
||||
.AddParameter("string", _("New value"))
|
||||
.MarkAsSimple();
|
||||
|
||||
aut.AddScopedAction("SetEffectBooleanParameter",
|
||||
_("Effect parameter (enable or disable)"),
|
||||
_("Enable or disable a parameter of an effect.") + "\n" +
|
||||
_("You can find the parameter names (and change the effect "
|
||||
"names) in the effects window."),
|
||||
_("Enable _PARAM3_ for effect _PARAM2_ of _PARAM0_: _PARAM4_"),
|
||||
_("Effects"),
|
||||
"res/actions/effect24.png",
|
||||
"res/actions/effect.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddParameter("behavior", _("Behavior"), "EffectBehavior")
|
||||
.AddParameter("objectEffectName", _("Effect name"))
|
||||
.AddParameter("objectEffectParameterName", _("Parameter name"))
|
||||
.AddParameter("yesorno", _("Enable?"))
|
||||
.MarkAsSimple();
|
||||
|
||||
aut.AddScopedCondition("IsEffectEnabled",
|
||||
_("Effect is enabled"),
|
||||
_("Check if the effect on an object is enabled."),
|
||||
_("Effect _PARAM2_ of _PARAM0_ is enabled"),
|
||||
_("Effects"),
|
||||
"res/actions/effect24.png",
|
||||
"res/actions/effect.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddParameter("behavior", _("Behavior"), "EffectBehavior")
|
||||
.AddParameter("objectEffectName", _("Effect name"))
|
||||
.MarkAsSimple();
|
||||
}
|
||||
|
||||
} // namespace gd
|
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* GDevelop Core
|
||||
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
|
||||
* reserved. This project is released under the GNU Lesser General Public
|
||||
* License.
|
||||
*/
|
||||
#include "GDCore/Extensions/Builtin/AllBuiltinExtensions.h"
|
||||
#include "GDCore/Extensions/Metadata/MultipleInstructionMetadata.h"
|
||||
#include "GDCore/Project/Behavior.h"
|
||||
#include "GDCore/Project/BehaviorsSharedData.h"
|
||||
#include "GDCore/Project/Object.h"
|
||||
#include "GDCore/Tools/Localization.h"
|
||||
|
||||
using namespace std;
|
||||
namespace gd {
|
||||
|
||||
void GD_CORE_API BuiltinExtensionsImplementer::ImplementsFlippableExtension(
|
||||
gd::PlatformExtension& extension) {
|
||||
extension
|
||||
.SetExtensionInformation("FlippableCapability",
|
||||
_("Flippable capability"),
|
||||
_("Flip objects."),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)")
|
||||
.SetExtensionHelpPath("/objects");
|
||||
extension.AddInstructionOrExpressionGroupMetadata(_("Effects"))
|
||||
.SetIcon("res/actions/effect24.png");
|
||||
|
||||
gd::BehaviorMetadata& aut = extension.AddBehavior(
|
||||
"FlippableBehavior",
|
||||
_("Flippable capability"),
|
||||
"Flippable",
|
||||
_("Flip objects."),
|
||||
"",
|
||||
"res/actions/flipX24.png",
|
||||
"FlippableBehavior",
|
||||
std::make_shared<gd::Behavior>(),
|
||||
std::make_shared<gd::BehaviorsSharedData>())
|
||||
.SetHidden();
|
||||
|
||||
aut.AddScopedAction("FlipX",
|
||||
_("Flip the object horizontally"),
|
||||
_("Flip the object horizontally"),
|
||||
_("Flip horizontally _PARAM0_: _PARAM2_"),
|
||||
_("Effects"),
|
||||
"res/actions/flipX24.png",
|
||||
"res/actions/flipX.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddParameter("behavior", _("Behavior"), "FlippableBehavior")
|
||||
.AddParameter("yesorno", _("Activate flipping"))
|
||||
.MarkAsSimple();
|
||||
|
||||
aut.AddScopedAction("FlipY",
|
||||
_("Flip the object vertically"),
|
||||
_("Flip the object vertically"),
|
||||
_("Flip vertically _PARAM0_: _PARAM2_"),
|
||||
_("Effects"),
|
||||
"res/actions/flipY24.png",
|
||||
"res/actions/flipY.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddParameter("behavior", _("Behavior"), "FlippableBehavior")
|
||||
.AddParameter("yesorno", _("Activate flipping"))
|
||||
.MarkAsSimple();
|
||||
|
||||
aut.AddScopedCondition("FlippedX",
|
||||
_("Horizontally flipped"),
|
||||
_("Check if the object is horizontally flipped"),
|
||||
_("_PARAM0_ is horizontally flipped"),
|
||||
_("Effects"),
|
||||
"res/actions/flipX24.png",
|
||||
"res/actions/flipX.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddParameter("behavior", _("Behavior"), "FlippableBehavior");
|
||||
|
||||
aut.AddScopedCondition("FlippedY",
|
||||
_("Vertically flipped"),
|
||||
_("Check if the object is vertically flipped"),
|
||||
_("_PARAM0_ is vertically flipped"),
|
||||
_("Effects"),
|
||||
"res/actions/flipY24.png",
|
||||
"res/actions/flipY.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddParameter("behavior", _("Behavior"), "FlippableBehavior");
|
||||
}
|
||||
|
||||
} // namespace gd
|
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* GDevelop Core
|
||||
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
|
||||
* reserved. This project is released under the GNU Lesser General Public
|
||||
* License.
|
||||
*/
|
||||
#include "GDCore/Extensions/Builtin/AllBuiltinExtensions.h"
|
||||
#include "GDCore/Extensions/Metadata/MultipleInstructionMetadata.h"
|
||||
#include "GDCore/Project/Behavior.h"
|
||||
#include "GDCore/Project/BehaviorsSharedData.h"
|
||||
#include "GDCore/Project/Object.h"
|
||||
#include "GDCore/Tools/Localization.h"
|
||||
|
||||
using namespace std;
|
||||
namespace gd {
|
||||
|
||||
void GD_CORE_API BuiltinExtensionsImplementer::ImplementsOpacityExtension(
|
||||
gd::PlatformExtension& extension) {
|
||||
extension
|
||||
.SetExtensionInformation("OpacityCapability",
|
||||
_("Opacity capability"),
|
||||
_("Change the object opacity."),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)")
|
||||
.SetExtensionHelpPath("/objects");
|
||||
extension.AddInstructionOrExpressionGroupMetadata(_("Visibility"))
|
||||
.SetIcon("res/actions/opacity24.png");
|
||||
|
||||
gd::BehaviorMetadata& aut = extension.AddBehavior(
|
||||
"OpacityBehavior",
|
||||
_("Opacity capability"),
|
||||
"Opacity",
|
||||
_("Change the object opacity."),
|
||||
"",
|
||||
"res/actions/opacity24.png",
|
||||
"OpacityBehavior",
|
||||
std::make_shared<gd::Behavior>(),
|
||||
std::make_shared<gd::BehaviorsSharedData>())
|
||||
.SetHidden();
|
||||
|
||||
aut.AddExpressionAndConditionAndAction(
|
||||
"number",
|
||||
"Value",
|
||||
_("Opacity"),
|
||||
_("the opacity of an object, between 0 (fully transparent) to 255 "
|
||||
"(opaque)"),
|
||||
_("the opacity"),
|
||||
_("Visibility"),
|
||||
"res/actions/opacity24.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddParameter("behavior", _("Behavior"), "OpacityBehavior")
|
||||
.UseStandardParameters(
|
||||
"number", gd::ParameterOptions::MakeNewOptions().SetDescription(
|
||||
_("Opacity (0-255)")))
|
||||
.SetFunctionName("setOpacity")
|
||||
.SetGetter("getOpacity");
|
||||
}
|
||||
|
||||
} // namespace gd
|
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* GDevelop Core
|
||||
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
|
||||
* reserved. This project is released under the GNU Lesser General Public
|
||||
* License.
|
||||
*/
|
||||
#include "GDCore/Extensions/Builtin/AllBuiltinExtensions.h"
|
||||
#include "GDCore/Project/Behavior.h"
|
||||
#include "GDCore/Project/BehaviorsSharedData.h"
|
||||
#include "GDCore/Project/Object.h"
|
||||
#include "GDCore/Tools/Localization.h"
|
||||
|
||||
using namespace std;
|
||||
namespace gd {
|
||||
|
||||
void GD_CORE_API BuiltinExtensionsImplementer::ImplementsResizableExtension(
|
||||
gd::PlatformExtension& extension) {
|
||||
extension
|
||||
.SetExtensionInformation("ResizableCapability",
|
||||
_("Resizable capability"),
|
||||
_("Change the object dimensions."),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)")
|
||||
.SetExtensionHelpPath("/objects");
|
||||
extension.AddInstructionOrExpressionGroupMetadata(_("Size"))
|
||||
.SetIcon("res/actions/scale24_black.png");
|
||||
|
||||
gd::BehaviorMetadata& aut = extension.AddBehavior(
|
||||
"ResizableBehavior",
|
||||
_("Resizable capability"),
|
||||
"Resizable",
|
||||
_("Change the object dimensions."),
|
||||
"",
|
||||
"res/actions/scale24_black.png",
|
||||
"ResizableBehavior",
|
||||
std::make_shared<gd::Behavior>(),
|
||||
std::make_shared<gd::BehaviorsSharedData>())
|
||||
.SetHidden();
|
||||
|
||||
aut.AddScopedAction("SetWidth",
|
||||
_("Width"),
|
||||
_("Change the width of the object."),
|
||||
_("the width"),
|
||||
_("Size"),
|
||||
"res/actions/scaleWidth24_black.png",
|
||||
"res/actions/scaleWidth_black.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddParameter("behavior", _("Behavior"), "ResizableBehavior")
|
||||
.UseStandardOperatorParameters("number",
|
||||
ParameterOptions::MakeNewOptions().SetDescription(
|
||||
_("Width")))
|
||||
.MarkAsAdvanced();
|
||||
|
||||
aut.AddScopedCondition("Width",
|
||||
_("Width"),
|
||||
_("Compare the width of the object."),
|
||||
_("the width"),
|
||||
_("Size"),
|
||||
"res/conditions/scaleWidth24_black.png",
|
||||
"res/conditions/scaleWidth_black.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddParameter("behavior", _("Behavior"), "ResizableBehavior")
|
||||
.UseStandardRelationalOperatorParameters(
|
||||
"number", ParameterOptions::MakeNewOptions().SetDescription(
|
||||
_("Width")))
|
||||
.MarkAsAdvanced();
|
||||
|
||||
aut.AddScopedAction("SetHeight",
|
||||
_("Height"),
|
||||
_("Change the height of the object."),
|
||||
_("the height"),
|
||||
_("Size"),
|
||||
"res/actions/scaleHeight24_black.png",
|
||||
"res/actions/scaleHeight_black.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddParameter("behavior", _("Behavior"), "ResizableBehavior")
|
||||
.UseStandardOperatorParameters("number",
|
||||
ParameterOptions::MakeNewOptions().SetDescription(
|
||||
_("Height")))
|
||||
.MarkAsAdvanced();
|
||||
|
||||
aut.AddScopedCondition("Height",
|
||||
_("Height"),
|
||||
_("Compare the height of the object."),
|
||||
_("the height"),
|
||||
_("Size"),
|
||||
"res/conditions/scaleHeight24_black.png",
|
||||
"res/conditions/scaleHeight_black.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddParameter("behavior", _("Behavior"), "ResizableBehavior")
|
||||
.UseStandardRelationalOperatorParameters(
|
||||
"number", ParameterOptions::MakeNewOptions().SetDescription(
|
||||
_("Height")))
|
||||
.MarkAsAdvanced();
|
||||
|
||||
aut.AddScopedAction("SetSize",
|
||||
_("Size"),
|
||||
_("Change the size of an object."),
|
||||
_("Change the size of _PARAM0_: set to _PARAM1_ x _PARAM2_"),
|
||||
_("Size"),
|
||||
"res/actions/scale24_black.png",
|
||||
"res/actions/scale_black.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddParameter("behavior", _("Behavior"), "ResizableBehavior")
|
||||
.AddParameter("expression", _("Width"))
|
||||
.AddParameter("expression", _("Height"))
|
||||
.MarkAsAdvanced();
|
||||
}
|
||||
|
||||
} // namespace gd
|
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* GDevelop Core
|
||||
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
|
||||
* reserved. This project is released under the GNU Lesser General Public
|
||||
* License.
|
||||
*/
|
||||
#include "GDCore/Extensions/Builtin/AllBuiltinExtensions.h"
|
||||
#include "GDCore/Extensions/Metadata/MultipleInstructionMetadata.h"
|
||||
#include "GDCore/Project/Behavior.h"
|
||||
#include "GDCore/Project/BehaviorsSharedData.h"
|
||||
#include "GDCore/Project/Object.h"
|
||||
#include "GDCore/Tools/Localization.h"
|
||||
|
||||
using namespace std;
|
||||
namespace gd {
|
||||
|
||||
void GD_CORE_API BuiltinExtensionsImplementer::ImplementsScalableExtension(
|
||||
gd::PlatformExtension& extension) {
|
||||
extension
|
||||
.SetExtensionInformation("ScalableCapability",
|
||||
_("Scalable capability"),
|
||||
_("Change the object scale."),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)")
|
||||
.SetExtensionHelpPath("/objects");
|
||||
extension.AddInstructionOrExpressionGroupMetadata(_("Size"))
|
||||
.SetIcon("res/actions/scale24_black.png");
|
||||
|
||||
gd::BehaviorMetadata& aut = extension.AddBehavior(
|
||||
"ScalableBehavior",
|
||||
_("Scalable capability"),
|
||||
"Scale",
|
||||
_("Change the object scale."),
|
||||
"",
|
||||
"res/actions/scale24_black.png",
|
||||
"ResizableBehavior",
|
||||
std::make_shared<gd::Behavior>(),
|
||||
std::make_shared<gd::BehaviorsSharedData>())
|
||||
.SetHidden();
|
||||
|
||||
aut.AddExpressionAndConditionAndAction(
|
||||
"number",
|
||||
"Value",
|
||||
_("Scale"),
|
||||
_("the scale of the object (default scale is 1)"),
|
||||
_("the scale"),
|
||||
_("Scale"),
|
||||
"res/actions/scale24_black.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddParameter("behavior", _("Behavior"), "ScalableBehavior")
|
||||
.UseStandardParameters(
|
||||
"number",
|
||||
gd::ParameterOptions::MakeNewOptions().SetDescription(
|
||||
_("Scale (1 by default)")))
|
||||
.MarkAsAdvanced();
|
||||
|
||||
aut.AddExpressionAndConditionAndAction(
|
||||
"number",
|
||||
"X",
|
||||
_("Scale on X axis"),
|
||||
_("the scale on X axis of the object (default scale is 1)"),
|
||||
_("the scale on X axis"),
|
||||
_("Scale"),
|
||||
"res/actions/scale24_black.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddParameter("behavior", _("Behavior"), "ScalableBehavior")
|
||||
.UseStandardParameters(
|
||||
"number",
|
||||
gd::ParameterOptions::MakeNewOptions().SetDescription(
|
||||
_("Scale (1 by default)")))
|
||||
.MarkAsAdvanced();
|
||||
|
||||
aut.AddExpressionAndConditionAndAction(
|
||||
"number",
|
||||
"Y",
|
||||
_("Scale on Y axis"),
|
||||
_("the scale on Y axis of the object (default scale is 1)"),
|
||||
_("the scale on Y axis"),
|
||||
_("Scale"),
|
||||
"res/actions/scale24_black.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddParameter("behavior", _("Behavior"), "ScalableBehavior")
|
||||
.UseStandardParameters(
|
||||
"number",
|
||||
gd::ParameterOptions::MakeNewOptions().SetDescription(
|
||||
_("Scale (1 by default)")))
|
||||
.MarkAsAdvanced();
|
||||
}
|
||||
|
||||
} // namespace gd
|
@@ -2,7 +2,7 @@
|
||||
* GDevelop Core
|
||||
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
|
||||
* reserved. This project is released under the GNU Lesser General Public
|
||||
* LicenFse.
|
||||
* License.
|
||||
*/
|
||||
#include "GDCore/Extensions/Builtin/AllBuiltinExtensions.h"
|
||||
#include "GDCore/Extensions/Builtin/SpriteExtension/SpriteObject.h"
|
||||
@@ -32,8 +32,15 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
_("Animated object which can be used for "
|
||||
"most elements of a game"),
|
||||
"CppPlatform/Extensions/spriteicon.png")
|
||||
.SetCategoryFullName(_("General"));
|
||||
.SetCategoryFullName(_("General"))
|
||||
.AddDefaultBehavior("EffectCapability::EffectBehavior")
|
||||
.AddDefaultBehavior("ResizableCapability::ResizableBehavior")
|
||||
.AddDefaultBehavior("ScalableCapability::ScalableBehavior")
|
||||
.AddDefaultBehavior("FlippableCapability::FlippableBehavior")
|
||||
.AddDefaultBehavior("OpacityCapability::OpacityBehavior")
|
||||
.AddDefaultBehavior("AnimatableCapability::AnimatableBehavior");
|
||||
|
||||
// Deprecated
|
||||
obj.AddAction("Opacity",
|
||||
_("Sprite opacity"),
|
||||
_("Change the opacity of a Sprite. 0 is fully transparent, 255 "
|
||||
@@ -48,8 +55,10 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
"number",
|
||||
ParameterOptions::MakeNewOptions().SetDescription(
|
||||
_("Opacity (0-255)")))
|
||||
.MarkAsSimple();
|
||||
.MarkAsSimple()
|
||||
.SetHidden();
|
||||
|
||||
// Deprecated
|
||||
obj.AddAction("ChangeAnimation",
|
||||
_("Change the animation"),
|
||||
_("Change the animation of the object, using the animation "
|
||||
@@ -62,8 +71,10 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
.AddParameter("object", _("Object"), "Sprite")
|
||||
.UseStandardOperatorParameters("number",
|
||||
ParameterOptions::MakeNewOptions())
|
||||
.SetHidden()
|
||||
.MarkAsSimple();
|
||||
|
||||
// Deprecated
|
||||
obj.AddAction("SetAnimationName",
|
||||
_("Change the animation (by name)"),
|
||||
_("Change the animation of the object, using the name of the "
|
||||
@@ -75,6 +86,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
|
||||
.AddParameter("object", _("Object"), "Sprite")
|
||||
.AddParameter("objectAnimationName", _("Animation name"))
|
||||
.SetHidden()
|
||||
.MarkAsAdvanced();
|
||||
|
||||
obj.AddAction(
|
||||
@@ -107,6 +119,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
ParameterOptions::MakeNewOptions())
|
||||
.MarkAsAdvanced();
|
||||
|
||||
// Deprecated
|
||||
obj.AddAction("PauseAnimation",
|
||||
_("Pause the animation"),
|
||||
_("Pause the animation of the object"),
|
||||
@@ -116,8 +129,10 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
"res/actions/animation.png")
|
||||
|
||||
.AddParameter("object", _("Object"), "Sprite")
|
||||
.SetHidden()
|
||||
.MarkAsSimple();
|
||||
|
||||
// Deprecated
|
||||
obj.AddAction("PlayAnimation",
|
||||
_("Play the animation"),
|
||||
_("Play the animation of the object"),
|
||||
@@ -127,8 +142,10 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
"res/actions/animation.png")
|
||||
|
||||
.AddParameter("object", _("Object"), "Sprite")
|
||||
.SetHidden()
|
||||
.MarkAsSimple();
|
||||
|
||||
// Deprecated
|
||||
obj.AddAction(
|
||||
"ChangeAnimationSpeedScale",
|
||||
_("Animation speed scale"),
|
||||
@@ -143,8 +160,10 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
.UseStandardOperatorParameters(
|
||||
"number",
|
||||
ParameterOptions::MakeNewOptions().SetDescription(_("Speed scale")))
|
||||
.SetHidden()
|
||||
.MarkAsSimple();
|
||||
|
||||
// Deprecated
|
||||
obj.AddAction("TourneVersPos",
|
||||
"Rotate an object toward a position",
|
||||
"Rotate an object towards a position.",
|
||||
@@ -159,8 +178,9 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
.AddParameter("expression", _("Angular speed (degrees per second)"))
|
||||
.SetDefaultValue("0")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.SetHidden(); // Deprecated
|
||||
.SetHidden();
|
||||
|
||||
// Deprecated
|
||||
obj.AddAction("ChangeScale",
|
||||
_("Scale"),
|
||||
_("Modify the scale of the specified object."),
|
||||
@@ -174,8 +194,10 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
"number",
|
||||
ParameterOptions::MakeNewOptions().SetDescription(
|
||||
_("Scale (1 by default)")))
|
||||
.MarkAsAdvanced();
|
||||
.MarkAsAdvanced()
|
||||
.SetHidden();
|
||||
|
||||
// Deprecated
|
||||
obj.AddAction("ChangeScaleWidth",
|
||||
_("Scale on X axis"),
|
||||
_("Modify the scale of the width of an object."),
|
||||
@@ -189,8 +211,10 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
"number",
|
||||
ParameterOptions::MakeNewOptions().SetDescription(
|
||||
_("Scale (1 by default)")))
|
||||
.MarkAsAdvanced();
|
||||
.MarkAsAdvanced()
|
||||
.SetHidden();
|
||||
|
||||
// Deprecated
|
||||
obj.AddAction("ChangeScaleHeight",
|
||||
_("Scale on Y axis"),
|
||||
_("Modify the scale of the height of an object."),
|
||||
@@ -204,8 +228,10 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
"number",
|
||||
ParameterOptions::MakeNewOptions().SetDescription(
|
||||
_("Scale (1 by default)")))
|
||||
.MarkAsAdvanced();
|
||||
.MarkAsAdvanced()
|
||||
.SetHidden();
|
||||
|
||||
// Deprecated
|
||||
obj.AddAction("ChangeWidth",
|
||||
_("Width"),
|
||||
_("Change the width of a Sprite object."),
|
||||
@@ -217,8 +243,10 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
.AddParameter("object", _("Object"), "Sprite")
|
||||
.UseStandardOperatorParameters("number",
|
||||
ParameterOptions::MakeNewOptions())
|
||||
.MarkAsAdvanced();
|
||||
.MarkAsAdvanced()
|
||||
.SetHidden();
|
||||
|
||||
// Deprecated
|
||||
obj.AddCondition("Width",
|
||||
_("Width"),
|
||||
_("Compare the width of a Sprite object."),
|
||||
@@ -230,8 +258,10 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
.AddParameter("object", _("Object"), "Sprite")
|
||||
.UseStandardRelationalOperatorParameters(
|
||||
"number", ParameterOptions::MakeNewOptions())
|
||||
.MarkAsAdvanced();
|
||||
.MarkAsAdvanced()
|
||||
.SetHidden();
|
||||
|
||||
// Deprecated
|
||||
obj.AddAction("ChangeHeight",
|
||||
_("Height"),
|
||||
_("Change the height of a Sprite object."),
|
||||
@@ -243,8 +273,10 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
.AddParameter("object", _("Object"), "Sprite")
|
||||
.UseStandardOperatorParameters("number",
|
||||
ParameterOptions::MakeNewOptions())
|
||||
.MarkAsAdvanced();
|
||||
.MarkAsAdvanced()
|
||||
.SetHidden();
|
||||
|
||||
// Deprecated
|
||||
obj.AddCondition("Height",
|
||||
_("Height"),
|
||||
_("Compare the height of a Sprite object."),
|
||||
@@ -256,8 +288,10 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
.AddParameter("object", _("Object"), "Sprite")
|
||||
.UseStandardRelationalOperatorParameters(
|
||||
"number", ParameterOptions::MakeNewOptions())
|
||||
.MarkAsAdvanced();
|
||||
.MarkAsAdvanced()
|
||||
.SetHidden();
|
||||
|
||||
// Deprecated
|
||||
obj.AddAction("SetSize",
|
||||
_("Size"),
|
||||
_("Change the size of an object."),
|
||||
@@ -269,8 +303,10 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddParameter("expression", _("Width"))
|
||||
.AddParameter("expression", _("Height"))
|
||||
.MarkAsAdvanced();
|
||||
.MarkAsAdvanced()
|
||||
.SetHidden();
|
||||
|
||||
// Deprecated
|
||||
obj.AddCondition(
|
||||
"Animation",
|
||||
_("Current animation"),
|
||||
@@ -283,8 +319,10 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
.AddParameter("object", _("Object"), "Sprite")
|
||||
.UseStandardRelationalOperatorParameters(
|
||||
"number", ParameterOptions::MakeNewOptions())
|
||||
.SetHidden()
|
||||
.MarkAsAdvanced();
|
||||
|
||||
// Deprecated
|
||||
obj.AddCondition("AnimationName",
|
||||
_("Current animation name"),
|
||||
_("Check the animation played by the object."),
|
||||
@@ -295,6 +333,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
|
||||
.AddParameter("object", _("Object"), "Sprite")
|
||||
.AddParameter("objectAnimationName", _("Animation name"))
|
||||
.SetHidden()
|
||||
.MarkAsAdvanced();
|
||||
|
||||
obj.AddCondition(
|
||||
@@ -328,6 +367,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
"number", ParameterOptions::MakeNewOptions())
|
||||
.MarkAsAdvanced();
|
||||
|
||||
// Deprecated
|
||||
obj.AddCondition("AnimStopped",
|
||||
_("Animation paused"),
|
||||
_("Check if the animation of an object is paused."),
|
||||
@@ -337,8 +377,10 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
"res/conditions/animation.png")
|
||||
|
||||
.AddParameter("object", _("Object"), "Sprite")
|
||||
.SetHidden()
|
||||
.MarkAsSimple();
|
||||
|
||||
// Deprecated
|
||||
obj.AddCondition("AnimationEnded",
|
||||
_("Animation finished"),
|
||||
_("Check if the animation being played by the Sprite object "
|
||||
@@ -352,6 +394,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
.MarkAsSimple()
|
||||
.SetHidden();
|
||||
|
||||
// Deprecated
|
||||
obj.AddCondition("AnimationEnded2",
|
||||
_("Animation finished"),
|
||||
_("Check if the animation being played by the Sprite object "
|
||||
@@ -362,6 +405,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
"res/conditions/animation.png")
|
||||
|
||||
.AddParameter("object", _("Object"), "Sprite")
|
||||
.SetHidden()
|
||||
.MarkAsSimple();
|
||||
|
||||
obj.AddCondition("ScaleWidth",
|
||||
@@ -394,6 +438,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
_("Scale (1 by default)")))
|
||||
.MarkAsAdvanced();
|
||||
|
||||
// Deprecated
|
||||
obj.AddCondition("Opacity",
|
||||
_("Opacity"),
|
||||
_("Compare the opacity of a Sprite, between 0 (fully "
|
||||
@@ -408,7 +453,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
"number",
|
||||
ParameterOptions::MakeNewOptions().SetDescription(
|
||||
_("Opacity to compare to (0-255)")))
|
||||
.MarkAsSimple();
|
||||
.MarkAsSimple()
|
||||
.SetHidden();
|
||||
|
||||
obj.AddCondition(
|
||||
"BlendMode",
|
||||
@@ -456,9 +502,9 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
_("Effects"),
|
||||
"res/actions/flipX24.png",
|
||||
"res/actions/flipX.png")
|
||||
|
||||
.AddParameter("object", _("Object"), "Sprite")
|
||||
.AddParameter("yesorno", _("Activate flipping"))
|
||||
.SetHidden()
|
||||
.MarkAsSimple();
|
||||
|
||||
obj.AddAction("FlipY",
|
||||
@@ -468,9 +514,9 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
_("Effects"),
|
||||
"res/actions/flipY24.png",
|
||||
"res/actions/flipY.png")
|
||||
|
||||
.AddParameter("object", _("Object"), "Sprite")
|
||||
.AddParameter("yesorno", _("Activate flipping"))
|
||||
.SetHidden()
|
||||
.MarkAsSimple();
|
||||
|
||||
obj.AddCondition("FlippedX",
|
||||
@@ -480,8 +526,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
_("Effects"),
|
||||
"res/actions/flipX24.png",
|
||||
"res/actions/flipX.png")
|
||||
|
||||
.AddParameter("object", _("Object"), "Sprite");
|
||||
.AddParameter("object", _("Object"), "Sprite")
|
||||
.SetHidden();
|
||||
|
||||
obj.AddCondition("FlippedY",
|
||||
_("Vertically flipped"),
|
||||
@@ -490,9 +536,10 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
_("Effects"),
|
||||
"res/actions/flipY24.png",
|
||||
"res/actions/flipY.png")
|
||||
.AddParameter("object", _("Object"), "Sprite")
|
||||
.SetHidden();
|
||||
|
||||
.AddParameter("object", _("Object"), "Sprite");
|
||||
|
||||
// Deprecated
|
||||
obj.AddAction("TourneVers",
|
||||
"Rotate an object toward another",
|
||||
"Rotate an object towards another.",
|
||||
@@ -504,7 +551,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
.AddParameter("object", _("Object"), "Sprite")
|
||||
.AddParameter("objectPtr", "Rotate toward this object")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.SetHidden(); // Deprecated
|
||||
.SetHidden();
|
||||
|
||||
obj.AddExpression("X",
|
||||
_("X position of a point"),
|
||||
@@ -542,6 +589,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
.AddParameter("object", _("Object"), "Sprite")
|
||||
.AddParameter("objectPointName", _("Name of the point"));
|
||||
|
||||
// Deprecated
|
||||
obj.AddExpression("Direc",
|
||||
_("Direction"),
|
||||
_("Direction of the object"),
|
||||
@@ -550,6 +598,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
.SetHidden()
|
||||
.AddParameter("object", _("Object"), "Sprite");
|
||||
|
||||
// Deprecated
|
||||
obj.AddExpression("Direction",
|
||||
_("Direction"),
|
||||
_("Direction of the object"),
|
||||
@@ -559,6 +608,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
// interface.
|
||||
.AddParameter("object", _("Object"), "Sprite");
|
||||
|
||||
// Deprecated
|
||||
obj.AddExpression("Anim",
|
||||
_("Animation"),
|
||||
_("Animation of the object"),
|
||||
@@ -567,18 +617,22 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
.SetHidden()
|
||||
.AddParameter("object", _("Object"), "Sprite");
|
||||
|
||||
// Deprecated
|
||||
obj.AddExpression("Animation",
|
||||
_("Animation"),
|
||||
_("Animation of the object"),
|
||||
_("Animations and images"),
|
||||
"res/actions/animation.png")
|
||||
.SetHidden()
|
||||
.AddParameter("object", _("Object"), "Sprite");
|
||||
|
||||
// Deprecated
|
||||
obj.AddStrExpression("AnimationName",
|
||||
_("Animation name"),
|
||||
_("Name of the animation of the object"),
|
||||
_("Animations and images"),
|
||||
"res/actions/animation.png")
|
||||
.SetHidden()
|
||||
.AddParameter("object", _("Object"), "Sprite");
|
||||
|
||||
obj.AddExpression("Sprite",
|
||||
@@ -595,11 +649,13 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
"res/actions/sprite.png")
|
||||
.AddParameter("object", _("Object"), "Sprite");
|
||||
|
||||
// Deprecated
|
||||
obj.AddExpression("AnimationSpeedScale",
|
||||
_("Animation speed scale"),
|
||||
_("Animation speed scale"),
|
||||
_("Animations and images"),
|
||||
"res/actions/animation.png")
|
||||
.SetHidden()
|
||||
.AddParameter("object", _("Object"), "Sprite");
|
||||
|
||||
obj.AddExpression("ScaleX",
|
||||
@@ -607,6 +663,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
_("Scale of the width of an object"),
|
||||
_("Size"),
|
||||
"res/actions/scaleWidth_black.png")
|
||||
.SetHidden()
|
||||
.AddParameter("object", _("Object"), "Sprite");
|
||||
|
||||
obj.AddExpression("ScaleY",
|
||||
@@ -614,14 +671,17 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
_("Scale of the height of an object"),
|
||||
_("Size"),
|
||||
"res/actions/scaleHeight_black.png")
|
||||
.SetHidden()
|
||||
.AddParameter("object", _("Object"), "Sprite");
|
||||
|
||||
// Deprecated
|
||||
obj.AddExpression("Opacity",
|
||||
_("Opacity"),
|
||||
_("Opacity"),
|
||||
_("Opacity"),
|
||||
"res/actions/opacity.png")
|
||||
.AddParameter("object", _("Object"), "Sprite");
|
||||
.AddParameter("object", _("Object"), "Sprite")
|
||||
.SetHidden();
|
||||
|
||||
extension
|
||||
.AddCondition("Collision",
|
||||
|
@@ -34,8 +34,7 @@ BehaviorMetadata::BehaviorMetadata(
|
||||
className(className_),
|
||||
iconFilename(icon24x24),
|
||||
instance(instance_),
|
||||
sharedDatasInstance(sharedDatasInstance_),
|
||||
isEventBased(false) {
|
||||
sharedDatasInstance(sharedDatasInstance_) {
|
||||
SetFullName(gd::String(fullname_));
|
||||
SetDescription(gd::String(description_));
|
||||
SetDefaultName(gd::String(defaultName_));
|
||||
@@ -52,29 +51,6 @@ BehaviorMetadata::BehaviorMetadata(
|
||||
if (sharedDatasInstance) sharedDatasInstance->SetTypeName(nameWithNamespace);
|
||||
}
|
||||
|
||||
BehaviorMetadata::BehaviorMetadata(
|
||||
const gd::String& extensionNamespace,
|
||||
const gd::String& nameWithNamespace,
|
||||
const gd::String& fullname_,
|
||||
const gd::String& defaultName_,
|
||||
const gd::String& description_,
|
||||
const gd::String& group_,
|
||||
const gd::String& icon24x24_): BehaviorMetadata(
|
||||
extensionNamespace,
|
||||
nameWithNamespace,
|
||||
fullname_,
|
||||
defaultName_,
|
||||
description_,
|
||||
group_,
|
||||
icon24x24_,
|
||||
// Class name is the name, actually unused
|
||||
defaultName_,
|
||||
// It is only used to get the name for GetName.
|
||||
gd::make_unique<gd::Behavior>("", nameWithNamespace),
|
||||
nullptr){
|
||||
isEventBased = true;
|
||||
};
|
||||
|
||||
gd::InstructionMetadata& BehaviorMetadata::AddCondition(
|
||||
const gd::String& name,
|
||||
const gd::String& fullname,
|
||||
@@ -420,10 +396,6 @@ const gd::String& BehaviorMetadata::GetName() const {
|
||||
}
|
||||
|
||||
gd::Behavior& BehaviorMetadata::Get() const {
|
||||
if (isEventBased) {
|
||||
gd::LogFatalError("Error: Event-based behaviors don't have blueprint. "
|
||||
"This method should not never be called.");
|
||||
}
|
||||
if (!instance) {
|
||||
gd::LogFatalError(
|
||||
"Trying to get a behavior from a BehaviorMetadata that has no "
|
||||
@@ -434,11 +406,20 @@ gd::Behavior& BehaviorMetadata::Get() const {
|
||||
}
|
||||
|
||||
gd::BehaviorsSharedData* BehaviorMetadata::GetSharedDataInstance() const {
|
||||
if (isEventBased) {
|
||||
gd::LogFatalError("Error: Event-based behaviors don't have blueprint. "
|
||||
"This method should not never be called.");
|
||||
}
|
||||
return sharedDatasInstance.get();
|
||||
}
|
||||
|
||||
const std::vector<gd::String>& BehaviorMetadata::GetRequiredBehaviorTypes() const {
|
||||
requiredBehaviors.clear();
|
||||
for (auto& property : Get().GetProperties()) {
|
||||
const String& propertyName = property.first;
|
||||
const gd::PropertyDescriptor& propertyDescriptor = property.second;
|
||||
|
||||
if (propertyDescriptor.GetType() == "Behavior") {
|
||||
requiredBehaviors.push_back(propertyDescriptor.GetExtraInfo()[0]);
|
||||
}
|
||||
}
|
||||
return requiredBehaviors;
|
||||
}
|
||||
|
||||
} // namespace gd
|
||||
|
@@ -259,6 +259,11 @@ class GD_CORE_API BehaviorMetadata : public InstructionOrExpressionContainerMeta
|
||||
*/
|
||||
const gd::String& GetObjectType() const { return objectType; }
|
||||
|
||||
/**
|
||||
* \brief Get the types of the behaviors that are required by this behavior.
|
||||
*/
|
||||
const std::vector<gd::String>& GetRequiredBehaviorTypes() const;
|
||||
|
||||
/**
|
||||
* Check if the behavior is private - it can't be used outside of its
|
||||
* extension.
|
||||
@@ -274,6 +279,21 @@ class GD_CORE_API BehaviorMetadata : public InstructionOrExpressionContainerMeta
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the behavior is hidden - it can be used but not attached to
|
||||
* objects by users.
|
||||
*/
|
||||
bool IsHidden() const { return isHidden; }
|
||||
|
||||
/**
|
||||
* Set that the behavior is hidden - it can be used but not attached to
|
||||
* objects by users.
|
||||
*/
|
||||
BehaviorMetadata &SetHidden() {
|
||||
isHidden = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Return the associated gd::Behavior, handling behavior contents.
|
||||
*
|
||||
@@ -330,12 +350,13 @@ class GD_CORE_API BehaviorMetadata : public InstructionOrExpressionContainerMeta
|
||||
gd::String group;
|
||||
gd::String iconFilename;
|
||||
gd::String objectType;
|
||||
mutable std::vector<gd::String> requiredBehaviors;
|
||||
bool isPrivate = false;
|
||||
bool isHidden = false;
|
||||
|
||||
// TODO: Nitpicking: convert these to std::unique_ptr to clarify ownership.
|
||||
std::shared_ptr<gd::Behavior> instance;
|
||||
std::shared_ptr<gd::BehaviorsSharedData> sharedDatasInstance;
|
||||
bool isEventBased;
|
||||
};
|
||||
|
||||
} // namespace gd
|
||||
|
@@ -275,6 +275,10 @@ class GD_CORE_API MetadataProvider {
|
||||
return &metadata == &badBehaviorMetadata;
|
||||
}
|
||||
|
||||
static bool IsBadObjectMetadata(const gd::ObjectMetadata& metadata) {
|
||||
return &metadata == &badObjectInfo;
|
||||
}
|
||||
|
||||
virtual ~MetadataProvider();
|
||||
|
||||
private:
|
||||
|
@@ -224,32 +224,28 @@ class GD_CORE_API ObjectMetadata : public InstructionOrExpressionContainerMetada
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief The "capabilities" that are offered by the base object that are
|
||||
* *not* supported by this object, and should be hidden in the editor
|
||||
* interface.
|
||||
* \brief The "capabilities" that are offered by through behaviors.
|
||||
*/
|
||||
const std::set<gd::String>& GetUnsupportedBaseObjectCapabilities() const {
|
||||
return unsupportedBaseObjectCapabilities;
|
||||
const std::set<gd::String>& GetDefaultBehaviors() const {
|
||||
return defaultBehaviorTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Add a "capability" that is offered by the base object that is *not*
|
||||
* supported by this object, and should be hidden in the editor interface.
|
||||
* \brief Return true if object has a default behavior of the given type.
|
||||
*/
|
||||
ObjectMetadata& AddUnsupportedBaseObjectCapability(
|
||||
const gd::String& capability) {
|
||||
unsupportedBaseObjectCapabilities.insert(capability);
|
||||
bool HasDefaultBehavior(const gd::String& behaviorType) const {
|
||||
return defaultBehaviorTypes.find(behaviorType) != defaultBehaviorTypes.end();
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Add a "capability" that is offered by through a behavior.
|
||||
*/
|
||||
ObjectMetadata& AddDefaultBehavior(
|
||||
const gd::String& behaviorType) {
|
||||
defaultBehaviorTypes.insert(behaviorType);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Check if a "capability" that is offered by the base object is *not*
|
||||
* supported by this object, and should be hidden in the editor interface.
|
||||
*/
|
||||
bool IsUnsupportedBaseObjectCapability(const gd::String& capability) const {
|
||||
return unsupportedBaseObjectCapabilities.find(capability) != unsupportedBaseObjectCapabilities.end();
|
||||
}
|
||||
|
||||
const gd::String& GetName() const override { return name; }
|
||||
const gd::String& GetFullName() const override { return fullname; }
|
||||
const gd::String& GetCategoryFullName() const { return categoryFullName; }
|
||||
@@ -331,7 +327,7 @@ class GD_CORE_API ObjectMetadata : public InstructionOrExpressionContainerMetada
|
||||
gd::String description;
|
||||
gd::String iconFilename;
|
||||
gd::String categoryFullName;
|
||||
std::set<gd::String> unsupportedBaseObjectCapabilities;
|
||||
std::set<gd::String> defaultBehaviorTypes;
|
||||
bool hidden = false;
|
||||
|
||||
std::shared_ptr<gd::ObjectConfiguration>
|
||||
|
@@ -273,25 +273,6 @@ gd::BehaviorMetadata& PlatformExtension::AddBehavior(
|
||||
return behaviorsInfo[nameWithNamespace];
|
||||
}
|
||||
|
||||
gd::BehaviorMetadata& PlatformExtension::AddEventsBasedBehavior(
|
||||
const gd::String& name,
|
||||
const gd::String& fullname,
|
||||
const gd::String& description,
|
||||
const gd::String& group,
|
||||
const gd::String& icon24x24) {
|
||||
gd::String nameWithNamespace = GetNameSpace() + name;
|
||||
behaviorsInfo[nameWithNamespace] = BehaviorMetadata(GetNameSpace(),
|
||||
nameWithNamespace,
|
||||
fullname,
|
||||
// Default name is the name
|
||||
name,
|
||||
description,
|
||||
group,
|
||||
icon24x24)
|
||||
.SetHelpPath(GetHelpPath());
|
||||
return behaviorsInfo[nameWithNamespace];
|
||||
}
|
||||
|
||||
gd::EffectMetadata& PlatformExtension::AddEffect(const gd::String& name) {
|
||||
gd::String nameWithNamespace = GetNameSpace() + name;
|
||||
effectsMetadata[nameWithNamespace] = EffectMetadata(nameWithNamespace);
|
||||
|
@@ -421,6 +421,32 @@ class GD_CORE_API PlatformExtension {
|
||||
*/
|
||||
const gd::String& GetIconUrl() const { return iconUrl; }
|
||||
|
||||
/**
|
||||
* \brief Return keywords that help search engines find this extension.
|
||||
*/
|
||||
const std::vector<gd::String>& GetTags() const { return tags; }
|
||||
|
||||
/**
|
||||
* \brief Set keywords that help search engines find this extension.
|
||||
*/
|
||||
PlatformExtension& SetTags(const gd::String& csvTags) {
|
||||
tags.clear();
|
||||
tags = csvTags.Split(',');
|
||||
for (size_t i = 0; i < tags.size(); i++)
|
||||
{
|
||||
tags[i] = tags[i].Trim().LowerCase();
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Add a keyword that help search engines find this extension.
|
||||
*/
|
||||
PlatformExtension& AddTag(const gd::String& tag) {
|
||||
tags.push_back(tag);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Check if the extension is flagged as being deprecated.
|
||||
*/
|
||||
@@ -661,6 +687,7 @@ private:
|
||||
gd::String helpPath; ///< The relative path to the help for this extension in
|
||||
///< the documentation.
|
||||
gd::String iconUrl; ///< The URL to the icon to be shown for this extension.
|
||||
std::vector<gd::String> tags;
|
||||
|
||||
std::map<gd::String, gd::ObjectMetadata> objectsInfos;
|
||||
std::map<gd::String, gd::BehaviorMetadata> behaviorsInfo;
|
||||
|
23
Core/GDCore/IDE/Events/BehaviorDefaultFlagClearer.cpp
Normal file
23
Core/GDCore/IDE/Events/BehaviorDefaultFlagClearer.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
#include "BehaviorDefaultFlagClearer.h"
|
||||
|
||||
#include "GDCore/Events/Instruction.h"
|
||||
#include "GDCore/Extensions/Metadata/MetadataProvider.h"
|
||||
#include "GDCore/Extensions/PlatformExtension.h"
|
||||
#include "GDCore/IDE/WholeProjectRefactorer.h"
|
||||
#include "GDCore/IDE/Events/ExpressionTypeFinder.h"
|
||||
#include "GDCore/Project/Behavior.h"
|
||||
#include "GDCore/Project/Object.h"
|
||||
#include "GDCore/Project/Project.h"
|
||||
|
||||
namespace gd {
|
||||
|
||||
void BehaviorDefaultFlagClearer::DoVisitObject(gd::Object& object) {
|
||||
};
|
||||
|
||||
void BehaviorDefaultFlagClearer::DoVisitBehavior(gd::Behavior& behavior) {
|
||||
behavior.SetDefaultBehavior(false);
|
||||
};
|
||||
|
||||
BehaviorDefaultFlagClearer::~BehaviorDefaultFlagClearer() {}
|
||||
|
||||
} // namespace gd
|
34
Core/GDCore/IDE/Events/BehaviorDefaultFlagClearer.h
Normal file
34
Core/GDCore/IDE/Events/BehaviorDefaultFlagClearer.h
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* 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 <set>
|
||||
|
||||
#include "GDCore/IDE/Project/ArbitraryObjectsWorker.h"
|
||||
#include "GDCore/String.h"
|
||||
|
||||
namespace gd {
|
||||
class Object;
|
||||
class Behavior;
|
||||
} // namespace gd
|
||||
|
||||
namespace gd {
|
||||
|
||||
/**
|
||||
* @brief This is used for project exports to keep default behaviors in
|
||||
* serialized data used by Runtime.
|
||||
*/
|
||||
class GD_CORE_API BehaviorDefaultFlagClearer : public ArbitraryObjectsWorker {
|
||||
public:
|
||||
BehaviorDefaultFlagClearer() {};
|
||||
virtual ~BehaviorDefaultFlagClearer();
|
||||
|
||||
private:
|
||||
void DoVisitObject(gd::Object& object) override;
|
||||
void DoVisitBehavior(gd::Behavior& behavior) override;
|
||||
};
|
||||
|
||||
}; // namespace gd
|
@@ -104,14 +104,6 @@ ExpressionValidator::Type ExpressionValidator::ValidateFunction(const gd::Functi
|
||||
!metadata.GetRequiredBaseObjectCapability().empty()) {
|
||||
const gd::ObjectMetadata &objectMetadata =
|
||||
MetadataProvider::GetObjectMetadata(platform, objectType);
|
||||
|
||||
if (objectMetadata.IsUnsupportedBaseObjectCapability(
|
||||
metadata.GetRequiredBaseObjectCapability())) {
|
||||
RaiseTypeError(
|
||||
_("This expression exists, but it can't be used on this object."),
|
||||
function.objectNameLocation);
|
||||
return returnType;
|
||||
}
|
||||
}
|
||||
|
||||
if (gd::MetadataProvider::IsBadExpressionMetadata(metadata)) {
|
||||
|
@@ -17,9 +17,11 @@
|
||||
#include "GDCore/Extensions/Metadata/ParameterMetadataTools.h"
|
||||
#include "GDCore/Extensions/Platform.h"
|
||||
#include "GDCore/Extensions/PlatformExtension.h"
|
||||
#include "GDCore/IDE/Events/ArbitraryEventsWorker.h"
|
||||
#include "GDCore/Project/Project.h"
|
||||
#include "GDCore/Project/ResourcesManager.h"
|
||||
#include "GDCore/Project/Effect.h"
|
||||
#include "GDCore/Tools/Log.h"
|
||||
#include "GDCore/IDE/ResourceExposer.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -131,29 +133,9 @@ void ArbitraryResourceWorker::ExposeEmbeddeds(gd::String& resourceName) {
|
||||
std::cout << targetResourceName << std::endl;
|
||||
gd::Resource& targetResource =
|
||||
resourcesManager->GetResource(targetResourceName);
|
||||
const gd::String& targetResourceKind = targetResource.GetKind();
|
||||
|
||||
gd::String potentiallyUpdatedTargetResourceName = targetResourceName;
|
||||
|
||||
if (targetResourceKind == "audio") {
|
||||
ExposeAudio(potentiallyUpdatedTargetResourceName);
|
||||
} else if (targetResourceKind == "bitmapFont") {
|
||||
ExposeBitmapFont(potentiallyUpdatedTargetResourceName);
|
||||
} else if (targetResourceKind == "font") {
|
||||
ExposeFont(potentiallyUpdatedTargetResourceName);
|
||||
} else if (targetResourceKind == "image") {
|
||||
ExposeImage(potentiallyUpdatedTargetResourceName);
|
||||
} else if (targetResourceKind == "json") {
|
||||
ExposeJson(potentiallyUpdatedTargetResourceName);
|
||||
} else if (targetResourceKind == "tilemap") {
|
||||
ExposeTilemap(potentiallyUpdatedTargetResourceName);
|
||||
} else if (targetResourceKind == "tileset") {
|
||||
ExposeTileset(potentiallyUpdatedTargetResourceName);
|
||||
} else if (targetResourceKind == "video") {
|
||||
ExposeVideo(potentiallyUpdatedTargetResourceName);
|
||||
} else if (targetResourceKind == "model3D") {
|
||||
ExposeModel3D(potentiallyUpdatedTargetResourceName);
|
||||
}
|
||||
ExposeResourceWithType(targetResource.GetKind(), potentiallyUpdatedTargetResourceName);
|
||||
|
||||
if (potentiallyUpdatedTargetResourceName != targetResourceName) {
|
||||
// The resource name was renamed. Also update the mapping.
|
||||
@@ -170,6 +152,48 @@ void ArbitraryResourceWorker::ExposeEmbeddeds(gd::String& resourceName) {
|
||||
}
|
||||
}
|
||||
|
||||
void ArbitraryResourceWorker::ExposeResourceWithType(
|
||||
const gd::String &resourceType, gd::String &resourceName) {
|
||||
if (resourceType == "image") {
|
||||
ExposeImage(resourceName);
|
||||
return;
|
||||
}
|
||||
if (resourceType == "model3D") {
|
||||
ExposeModel3D(resourceName);
|
||||
return;
|
||||
}
|
||||
if (resourceType == "audio") {
|
||||
ExposeAudio(resourceName);
|
||||
return;
|
||||
}
|
||||
if (resourceType == "font") {
|
||||
ExposeFont(resourceName);
|
||||
return;
|
||||
}
|
||||
if (resourceType == "bitmapFont") {
|
||||
ExposeBitmapFont(resourceName);
|
||||
return;
|
||||
}
|
||||
if (resourceType == "tilemap") {
|
||||
ExposeTilemap(resourceName);
|
||||
return;
|
||||
}
|
||||
if (resourceType == "tileset") {
|
||||
ExposeTileset(resourceName);
|
||||
return;
|
||||
}
|
||||
if (resourceType == "json") {
|
||||
ExposeJson(resourceName);
|
||||
return;
|
||||
}
|
||||
if (resourceType == "video") {
|
||||
ExposeVideo(resourceName);
|
||||
return;
|
||||
}
|
||||
gd::LogError("Unexpected resource type: " + resourceType + " for: " + resourceName);
|
||||
return;
|
||||
}
|
||||
|
||||
void ArbitraryResourceWorker::ExposeResource(gd::Resource& resource) {
|
||||
if (!resource.UseFile()) return;
|
||||
|
||||
@@ -180,86 +204,98 @@ void ArbitraryResourceWorker::ExposeResource(gd::Resource& resource) {
|
||||
|
||||
ArbitraryResourceWorker::~ArbitraryResourceWorker() {}
|
||||
|
||||
/**
|
||||
* Launch the specified resource worker on every resource referenced in the
|
||||
* events.
|
||||
*/
|
||||
class ResourceWorkerInEventsWorker : public ArbitraryEventsWorker {
|
||||
public:
|
||||
ResourceWorkerInEventsWorker(const gd::Project& project_,
|
||||
gd::ArbitraryResourceWorker& worker_)
|
||||
: project(project_), worker(worker_){};
|
||||
virtual ~ResourceWorkerInEventsWorker(){};
|
||||
bool ResourceWorkerInEventsWorker::DoVisitInstruction(gd::Instruction& instruction, bool isCondition) {
|
||||
const auto& platform = project.GetCurrentPlatform();
|
||||
const auto& metadata = isCondition
|
||||
? gd::MetadataProvider::GetConditionMetadata(
|
||||
platform, instruction.GetType())
|
||||
: gd::MetadataProvider::GetActionMetadata(
|
||||
platform, instruction.GetType());
|
||||
|
||||
private:
|
||||
bool DoVisitInstruction(gd::Instruction& instruction, bool isCondition) {
|
||||
const auto& platform = project.GetCurrentPlatform();
|
||||
const auto& metadata = isCondition
|
||||
? gd::MetadataProvider::GetConditionMetadata(
|
||||
platform, instruction.GetType())
|
||||
: gd::MetadataProvider::GetActionMetadata(
|
||||
platform, instruction.GetType());
|
||||
gd::ParameterMetadataTools::IterateOverParametersWithIndex(
|
||||
instruction.GetParameters(),
|
||||
metadata.GetParameters(),
|
||||
[this, &instruction](const gd::ParameterMetadata& parameterMetadata,
|
||||
const gd::Expression& parameterExpression,
|
||||
size_t parameterIndex,
|
||||
const gd::String& lastObjectName) {
|
||||
const String& parameterValue = parameterExpression.GetPlainString();
|
||||
if (parameterMetadata.GetType() ==
|
||||
"police" || // Should be renamed fontResource
|
||||
parameterMetadata.GetType() == "fontResource") {
|
||||
gd::String updatedParameterValue = parameterValue;
|
||||
worker.ExposeFont(updatedParameterValue);
|
||||
instruction.SetParameter(parameterIndex, updatedParameterValue);
|
||||
} else if (parameterMetadata.GetType() == "soundfile" ||
|
||||
parameterMetadata.GetType() ==
|
||||
"musicfile") { // Should be renamed audioResource
|
||||
gd::String updatedParameterValue = parameterValue;
|
||||
worker.ExposeAudio(updatedParameterValue);
|
||||
instruction.SetParameter(parameterIndex, updatedParameterValue);
|
||||
} else if (parameterMetadata.GetType() == "bitmapFontResource") {
|
||||
gd::String updatedParameterValue = parameterValue;
|
||||
worker.ExposeBitmapFont(updatedParameterValue);
|
||||
instruction.SetParameter(parameterIndex, updatedParameterValue);
|
||||
} else if (parameterMetadata.GetType() == "imageResource") {
|
||||
gd::String updatedParameterValue = parameterValue;
|
||||
worker.ExposeImage(updatedParameterValue);
|
||||
instruction.SetParameter(parameterIndex, updatedParameterValue);
|
||||
} else if (parameterMetadata.GetType() == "jsonResource") {
|
||||
gd::String updatedParameterValue = parameterValue;
|
||||
worker.ExposeJson(updatedParameterValue);
|
||||
instruction.SetParameter(parameterIndex, updatedParameterValue);
|
||||
} else if (parameterMetadata.GetType() == "tilemapResource") {
|
||||
gd::String updatedParameterValue = parameterValue;
|
||||
worker.ExposeTilemap(updatedParameterValue);
|
||||
instruction.SetParameter(parameterIndex, updatedParameterValue);
|
||||
} else if (parameterMetadata.GetType() == "tilesetResource") {
|
||||
gd::String updatedParameterValue = parameterValue;
|
||||
worker.ExposeTileset(updatedParameterValue);
|
||||
instruction.SetParameter(parameterIndex, updatedParameterValue);
|
||||
} else if (parameterMetadata.GetType() == "model3DResource") {
|
||||
gd::String updatedParameterValue = parameterValue;
|
||||
worker.ExposeModel3D(updatedParameterValue);
|
||||
instruction.SetParameter(parameterIndex, updatedParameterValue);
|
||||
}
|
||||
});
|
||||
|
||||
gd::ParameterMetadataTools::IterateOverParametersWithIndex(
|
||||
instruction.GetParameters(),
|
||||
metadata.GetParameters(),
|
||||
[this, &instruction](const gd::ParameterMetadata& parameterMetadata,
|
||||
const gd::Expression& parameterExpression,
|
||||
size_t parameterIndex,
|
||||
const gd::String& lastObjectName) {
|
||||
const String& parameterValue = parameterExpression.GetPlainString();
|
||||
if (parameterMetadata.GetType() ==
|
||||
"police" || // Should be renamed fontResource
|
||||
parameterMetadata.GetType() == "fontResource") {
|
||||
gd::String updatedParameterValue = parameterValue;
|
||||
worker.ExposeFont(updatedParameterValue);
|
||||
instruction.SetParameter(parameterIndex, updatedParameterValue);
|
||||
} else if (parameterMetadata.GetType() == "soundfile" ||
|
||||
parameterMetadata.GetType() ==
|
||||
"musicfile") { // Should be renamed audioResource
|
||||
gd::String updatedParameterValue = parameterValue;
|
||||
worker.ExposeAudio(updatedParameterValue);
|
||||
instruction.SetParameter(parameterIndex, updatedParameterValue);
|
||||
} else if (parameterMetadata.GetType() == "bitmapFontResource") {
|
||||
gd::String updatedParameterValue = parameterValue;
|
||||
worker.ExposeBitmapFont(updatedParameterValue);
|
||||
instruction.SetParameter(parameterIndex, updatedParameterValue);
|
||||
} else if (parameterMetadata.GetType() == "imageResource") {
|
||||
gd::String updatedParameterValue = parameterValue;
|
||||
worker.ExposeImage(updatedParameterValue);
|
||||
instruction.SetParameter(parameterIndex, updatedParameterValue);
|
||||
} else if (parameterMetadata.GetType() == "jsonResource") {
|
||||
gd::String updatedParameterValue = parameterValue;
|
||||
worker.ExposeJson(updatedParameterValue);
|
||||
instruction.SetParameter(parameterIndex, updatedParameterValue);
|
||||
} else if (parameterMetadata.GetType() == "tilemapResource") {
|
||||
gd::String updatedParameterValue = parameterValue;
|
||||
worker.ExposeTilemap(updatedParameterValue);
|
||||
instruction.SetParameter(parameterIndex, updatedParameterValue);
|
||||
} else if (parameterMetadata.GetType() == "tilesetResource") {
|
||||
gd::String updatedParameterValue = parameterValue;
|
||||
worker.ExposeTileset(updatedParameterValue);
|
||||
instruction.SetParameter(parameterIndex, updatedParameterValue);
|
||||
} else if (parameterMetadata.GetType() == "model3DResource") {
|
||||
gd::String updatedParameterValue = parameterValue;
|
||||
worker.ExposeModel3D(updatedParameterValue);
|
||||
instruction.SetParameter(parameterIndex, updatedParameterValue);
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
const gd::Project& project;
|
||||
gd::ArbitraryResourceWorker& worker;
|
||||
return false;
|
||||
};
|
||||
|
||||
void LaunchResourceWorkerOnEvents(const gd::Project& project,
|
||||
gd::EventsList& events,
|
||||
gd::ArbitraryResourceWorker& worker) {
|
||||
ResourceWorkerInEventsWorker eventsWorker(project, worker);
|
||||
gd::ResourceWorkerInEventsWorker eventsWorker(project, worker);
|
||||
eventsWorker.Launch(events);
|
||||
}
|
||||
|
||||
gd::ResourceWorkerInEventsWorker
|
||||
GetResourceWorkerOnEvents(const gd::Project &project,
|
||||
gd::ArbitraryResourceWorker &worker) {
|
||||
gd::ResourceWorkerInEventsWorker eventsWorker(project, worker);
|
||||
return eventsWorker;
|
||||
}
|
||||
|
||||
void ResourceWorkerInObjectsWorker::DoVisitObject(gd::Object &object) {
|
||||
object.GetConfiguration().ExposeResources(worker);
|
||||
auto& effects = object.GetEffects();
|
||||
for (size_t effectIndex = 0; effectIndex < effects.GetEffectsCount(); effectIndex++)
|
||||
{
|
||||
auto& effect = effects.GetEffect(effectIndex);
|
||||
gd::ResourceExposer::ExposeEffectResources(project.GetCurrentPlatform(), effect, worker);
|
||||
}
|
||||
};
|
||||
|
||||
void ResourceWorkerInObjectsWorker::DoVisitBehavior(gd::Behavior &behavior){
|
||||
// TODO Allow behaviors to expose resources
|
||||
};
|
||||
|
||||
gd::ResourceWorkerInObjectsWorker
|
||||
GetResourceWorkerOnObjects(const gd::Project &project,
|
||||
gd::ArbitraryResourceWorker &worker) {
|
||||
gd::ResourceWorkerInObjectsWorker eventsWorker(project, worker);
|
||||
return eventsWorker;
|
||||
}
|
||||
|
||||
} // namespace gd
|
||||
#endif
|
||||
|
@@ -4,13 +4,14 @@
|
||||
* reserved. This project is released under the MIT License.
|
||||
*/
|
||||
|
||||
#ifndef ARBITRARYRESOURCEWORKER_H
|
||||
#define ARBITRARYRESOURCEWORKER_H
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include "GDCore/String.h"
|
||||
#include "GDCore/IDE/Events/ArbitraryEventsWorker.h"
|
||||
#include "GDCore/IDE/Project/ArbitraryObjectsWorker.h"
|
||||
namespace gd {
|
||||
class BaseEvent;
|
||||
}
|
||||
@@ -53,6 +54,11 @@ class GD_CORE_API ArbitraryResourceWorker {
|
||||
*/
|
||||
void ExposeResources(gd::ResourcesManager *resourcesManager);
|
||||
|
||||
/**
|
||||
* \brief Expose a resource from a given type.
|
||||
*/
|
||||
void ExposeResourceWithType(const gd::String& resourceType, gd::String& resourceName);
|
||||
|
||||
/**
|
||||
* \brief Expose an image, which is always a reference to a "image" resource.
|
||||
*/
|
||||
@@ -132,18 +138,47 @@ class GD_CORE_API ArbitraryResourceWorker {
|
||||
};
|
||||
|
||||
/**
|
||||
* Tool function iterating over each event and calling
|
||||
* Expose(Actions/Conditions)Resources for each actions and conditions with the
|
||||
* ArbitraryResourceWorker passed as argument.
|
||||
*
|
||||
* \see gd::ArbitraryResourceWorker
|
||||
* \ingroup IDE
|
||||
* Launch the specified resource worker on every resource referenced in the
|
||||
* events.
|
||||
*/
|
||||
void GD_CORE_API
|
||||
LaunchResourceWorkerOnEvents(const gd::Project &project,
|
||||
gd::EventsList &events,
|
||||
gd::ArbitraryResourceWorker &worker);
|
||||
class ResourceWorkerInEventsWorker : public gd::ArbitraryEventsWorker {
|
||||
public:
|
||||
ResourceWorkerInEventsWorker(const gd::Project &project_,
|
||||
gd::ArbitraryResourceWorker &worker_)
|
||||
: project(project_), worker(worker_){};
|
||||
virtual ~ResourceWorkerInEventsWorker(){};
|
||||
|
||||
private:
|
||||
bool DoVisitInstruction(gd::Instruction &instruction,
|
||||
bool isCondition) override;
|
||||
|
||||
const gd::Project &project;
|
||||
gd::ArbitraryResourceWorker &worker;
|
||||
};
|
||||
|
||||
ResourceWorkerInEventsWorker GD_CORE_API GetResourceWorkerOnEvents(
|
||||
const gd::Project &project, gd::ArbitraryResourceWorker &worker);
|
||||
|
||||
/**
|
||||
* Launch the specified resource worker on every resource referenced in the
|
||||
* objects.
|
||||
*/
|
||||
class GD_CORE_API ResourceWorkerInObjectsWorker
|
||||
: public gd::ArbitraryObjectsWorker {
|
||||
public:
|
||||
ResourceWorkerInObjectsWorker(const gd::Project &project_, gd::ArbitraryResourceWorker &worker_)
|
||||
: project(project_), worker(worker_){};
|
||||
~ResourceWorkerInObjectsWorker() {}
|
||||
|
||||
private:
|
||||
void DoVisitObject(gd::Object &object) override;
|
||||
void DoVisitBehavior(gd::Behavior &behavior) override;
|
||||
|
||||
const gd::Project &project;
|
||||
gd::ArbitraryResourceWorker &worker;
|
||||
};
|
||||
|
||||
gd::ResourceWorkerInObjectsWorker GD_CORE_API
|
||||
GetResourceWorkerOnObjects(const gd::Project &project, gd::ArbitraryResourceWorker &worker);
|
||||
|
||||
} // namespace gd
|
||||
|
||||
#endif // ARBITRARYRESOURCEWORKER_H
|
||||
|
@@ -9,6 +9,7 @@
|
||||
#include "GDCore/Project/Project.h"
|
||||
#include "GDCore/Tools/Localization.h"
|
||||
#include "GDCore/Tools/Log.h"
|
||||
#include "GDCore/IDE/ResourceExposer.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -19,7 +20,7 @@ std::vector<gd::String> ProjectResourcesAdder::GetAllUseless(
|
||||
std::vector<gd::String> unusedResources;
|
||||
// Search for resources used in the project
|
||||
gd::ResourcesInUseHelper resourcesInUse;
|
||||
project.ExposeResources(resourcesInUse);
|
||||
gd::ResourceExposer::ExposeWholeProjectResources(project, resourcesInUse);
|
||||
std::set<gd::String>& usedResources = resourcesInUse.GetAll(resourceType);
|
||||
|
||||
// Search all resources not used
|
||||
|
@@ -12,6 +12,7 @@
|
||||
#include "GDCore/Project/Project.h"
|
||||
#include "GDCore/Tools/Localization.h"
|
||||
#include "GDCore/Tools/Log.h"
|
||||
#include "GDCore/IDE/ResourceExposer.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -26,7 +27,7 @@ bool ProjectResourcesCopier::CopyAllResourcesTo(
|
||||
bool preserveDirectoryStructure) {
|
||||
// Check if there are some resources with absolute filenames
|
||||
gd::ResourcesAbsolutePathChecker absolutePathChecker(fs);
|
||||
originalProject.ExposeResources(absolutePathChecker);
|
||||
gd::ResourceExposer::ExposeWholeProjectResources(originalProject, absolutePathChecker);
|
||||
|
||||
auto projectDirectory = fs.DirNameFrom(originalProject.GetProjectFile());
|
||||
std::cout << "Copying all resources from " << projectDirectory << " to "
|
||||
@@ -41,10 +42,10 @@ bool ProjectResourcesCopier::CopyAllResourcesTo(
|
||||
preserveAbsoluteFilenames);
|
||||
|
||||
if (updateOriginalProject) {
|
||||
originalProject.ExposeResources(resourcesMergingHelper);
|
||||
gd::ResourceExposer::ExposeWholeProjectResources(originalProject, resourcesMergingHelper);
|
||||
} else {
|
||||
std::shared_ptr<gd::Project> project(new gd::Project(originalProject));
|
||||
project->ExposeResources(resourcesMergingHelper);
|
||||
gd::ResourceExposer::ExposeWholeProjectResources(*project, resourcesMergingHelper);
|
||||
}
|
||||
|
||||
// Copy resources
|
||||
|
@@ -13,6 +13,7 @@
|
||||
|
||||
#include "GDCore/IDE/Project/ArbitraryResourceWorker.h"
|
||||
#include "GDCore/String.h"
|
||||
#include "GDCore/IDE/ResourceExposer.h"
|
||||
|
||||
namespace gd {
|
||||
|
||||
@@ -23,7 +24,7 @@ namespace gd {
|
||||
* Usage example:
|
||||
\code
|
||||
gd::ResourcesInUseHelper resourcesInUse;
|
||||
project.ExposeResources(resourcesInUse);
|
||||
gd::ResourceExposer::ExposeWholeProjectResources(project, resourcesInUse);
|
||||
|
||||
//Get a set with the name of all images in the project:
|
||||
std::set<gd::String> & usedImages = resourcesInUse.GetAllImages();
|
||||
|
@@ -197,7 +197,7 @@ void ProjectBrowserHelper::ExposeProjectObjects(
|
||||
// Global objects
|
||||
worker.Launch(project);
|
||||
|
||||
// Layers objects
|
||||
// Layout objects
|
||||
for (size_t i = 0; i < project.GetLayoutsCount(); i++) {
|
||||
worker.Launch(project.GetLayout(i));
|
||||
}
|
||||
|
@@ -11,6 +11,8 @@
|
||||
#include "GDCore/Project/ExternalLayout.h"
|
||||
#include "GDCore/Project/Layout.h"
|
||||
#include "GDCore/Project/Project.h"
|
||||
#include "GDCore/IDE/WholeProjectBrowser.h"
|
||||
#include "GDCore/IDE/Events/BehaviorDefaultFlagClearer.h"
|
||||
|
||||
namespace gd {
|
||||
|
||||
@@ -19,6 +21,10 @@ void GD_CORE_API ProjectStripper::StripProjectForExport(gd::Project &project) {
|
||||
while (project.GetExternalEventsCount() > 0)
|
||||
project.RemoveExternalEvents(project.GetExternalEvents(0).GetName());
|
||||
|
||||
gd::BehaviorDefaultFlagClearer behaviorDefaultFlagClearer;
|
||||
gd::WholeProjectBrowser wholeProjectBrowser;
|
||||
wholeProjectBrowser.ExposeObjects(project, behaviorDefaultFlagClearer);
|
||||
|
||||
for (unsigned int i = 0; i < project.GetLayoutsCount(); ++i) {
|
||||
project.GetLayout(i).GetObjectGroups().Clear();
|
||||
project.GetLayout(i).GetEvents().Clear();
|
||||
|
101
Core/GDCore/IDE/ResourceExposer.cpp
Normal file
101
Core/GDCore/IDE/ResourceExposer.cpp
Normal file
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* GDevelop Core
|
||||
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
|
||||
* reserved. This project is released under the MIT License.
|
||||
*/
|
||||
#include "ResourceExposer.h"
|
||||
|
||||
#include "GDCore/IDE/Events/ArbitraryEventsWorker.h"
|
||||
#include "GDCore/IDE/EventsFunctionTools.h"
|
||||
#include "GDCore/IDE/Project/ArbitraryBehaviorSharedDataWorker.h"
|
||||
#include "GDCore/IDE/Project/ArbitraryEventBasedBehaviorsWorker.h"
|
||||
#include "GDCore/IDE/Project/ArbitraryEventsFunctionsWorker.h"
|
||||
#include "GDCore/IDE/Project/ArbitraryObjectsWorker.h"
|
||||
#include "GDCore/IDE/Project/ArbitraryResourceWorker.h"
|
||||
#include "GDCore/IDE/ProjectBrowserHelper.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/Project/Effect.h"
|
||||
#include "GDCore/String.h"
|
||||
#include "GDCore/Extensions/Platform.h"
|
||||
#include "GDCore/Extensions/Metadata/MetadataProvider.h"
|
||||
#include "GDCore/Extensions/Metadata/EffectMetadata.h"
|
||||
|
||||
namespace gd {
|
||||
|
||||
void ResourceExposer::ExposeWholeProjectResources(gd::Project& project, gd::ArbitraryResourceWorker& worker) {
|
||||
// See also gd::ProjectBrowserHelper::ExposeProjectEvents for a method that
|
||||
// traverse the whole project (this time for events) and ExposeProjectEffects
|
||||
// (this time for effects).
|
||||
|
||||
gd::ResourcesManager* resourcesManager = &(project.GetResourcesManager());
|
||||
|
||||
// Expose any project resources as files.
|
||||
worker.ExposeResources(resourcesManager);
|
||||
project.GetPlatformSpecificAssets().ExposeResources(worker);
|
||||
|
||||
// Expose event resources
|
||||
auto eventWorker = gd::GetResourceWorkerOnEvents(project, worker);
|
||||
gd::ProjectBrowserHelper::ExposeProjectEvents(
|
||||
project, eventWorker);
|
||||
|
||||
// Expose object configuration resources
|
||||
auto objectWorker = gd::GetResourceWorkerOnObjects(project, worker);
|
||||
gd::ProjectBrowserHelper::ExposeProjectObjects(
|
||||
project, objectWorker);
|
||||
|
||||
// Expose layer effect resources
|
||||
for (std::size_t layoutIndex = 0; layoutIndex < project.GetLayoutsCount();
|
||||
layoutIndex++) {
|
||||
auto &layout = project.GetLayout(layoutIndex);
|
||||
|
||||
for (std::size_t layerIndex = 0; layerIndex < layout.GetLayersCount();
|
||||
layerIndex++) {
|
||||
auto &layer = layout.GetLayer(layerIndex);
|
||||
|
||||
auto &effects = layer.GetEffects();
|
||||
for (size_t effectIndex = 0; effectIndex < effects.GetEffectsCount();
|
||||
effectIndex++) {
|
||||
auto &effect = effects.GetEffect(effectIndex);
|
||||
gd::ResourceExposer::ExposeEffectResources(project.GetCurrentPlatform(),
|
||||
effect, worker);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Expose loading screen background image if present
|
||||
auto& loadingScreen = project.GetLoadingScreen();
|
||||
if (loadingScreen.GetBackgroundImageResourceName() != "")
|
||||
worker.ExposeImage(loadingScreen.GetBackgroundImageResourceName());
|
||||
}
|
||||
|
||||
void ResourceExposer::ExposeEffectResources(
|
||||
gd::Platform &platform, gd::Effect &effect,
|
||||
gd::ArbitraryResourceWorker &worker) {
|
||||
auto &effectMetadata =
|
||||
MetadataProvider::GetEffectMetadata(platform, effect.GetEffectType());
|
||||
|
||||
for (auto &propertyPair : effectMetadata.GetProperties()) {
|
||||
auto &propertyName = propertyPair.first;
|
||||
auto &propertyDescriptor = propertyPair.second;
|
||||
|
||||
if (propertyDescriptor.GetType() == "resource" &&
|
||||
propertyDescriptor.GetExtraInfo().size() > 0) {
|
||||
auto &resourceType = propertyDescriptor.GetExtraInfo()[0];
|
||||
|
||||
const gd::String &resourceName = effect.GetStringParameter(propertyName);
|
||||
gd::String potentiallyUpdatedResourceName = resourceName;
|
||||
worker.ExposeResourceWithType(resourceType,
|
||||
potentiallyUpdatedResourceName);
|
||||
if (potentiallyUpdatedResourceName != resourceName) {
|
||||
effect.SetStringParameter(propertyName, potentiallyUpdatedResourceName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace gd
|
38
Core/GDCore/IDE/ResourceExposer.h
Normal file
38
Core/GDCore/IDE/ResourceExposer.h
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* 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 Platform;
|
||||
class Project;
|
||||
class ArbitraryResourceWorker;
|
||||
class Effect;
|
||||
} // namespace gd
|
||||
|
||||
namespace gd {
|
||||
|
||||
/**
|
||||
* \brief
|
||||
*/
|
||||
class GD_CORE_API ResourceExposer {
|
||||
public:
|
||||
/**
|
||||
* \brief Called ( e.g. during compilation ) so as to inventory internal
|
||||
* resources, sometimes update their filename or any other work or resources.
|
||||
*
|
||||
* See WholeProjectRefactorer for the same thing for events.
|
||||
*
|
||||
* \see WholeProjectRefactorer
|
||||
* \see ArbitraryResourceWorker
|
||||
*/
|
||||
static void ExposeWholeProjectResources(gd::Project &project,
|
||||
gd::ArbitraryResourceWorker &worker);
|
||||
|
||||
static void ExposeEffectResources(gd::Platform &platform, gd::Effect &effect,
|
||||
gd::ArbitraryResourceWorker &worker);
|
||||
};
|
||||
|
||||
} // namespace gd
|
@@ -1599,6 +1599,54 @@ void WholeProjectRefactorer::GlobalObjectOrGroupRemoved(
|
||||
}
|
||||
}
|
||||
|
||||
void WholeProjectRefactorer::RemoveLayer(gd::Project &project,
|
||||
gd::Layout &layout,
|
||||
const gd::String &layerName) {
|
||||
if (layerName.empty())
|
||||
return;
|
||||
|
||||
layout.GetInitialInstances().RemoveAllInstancesOnLayer(layerName);
|
||||
|
||||
std::vector<gd::String> externalLayoutsNames =
|
||||
GetAssociatedExternalLayouts(project, layout);
|
||||
for (gd::String name : externalLayoutsNames) {
|
||||
auto &externalLayout = project.GetExternalLayout(name);
|
||||
externalLayout.GetInitialInstances().RemoveAllInstancesOnLayer(layerName);
|
||||
}
|
||||
}
|
||||
|
||||
void WholeProjectRefactorer::MergeLayers(gd::Project &project,
|
||||
gd::Layout &layout,
|
||||
const gd::String &originLayerName,
|
||||
const gd::String &targetLayerName) {
|
||||
if (originLayerName == targetLayerName || originLayerName.empty())
|
||||
return;
|
||||
|
||||
layout.GetInitialInstances().MoveInstancesToLayer(originLayerName,
|
||||
targetLayerName);
|
||||
|
||||
std::vector<gd::String> externalLayoutsNames =
|
||||
GetAssociatedExternalLayouts(project, layout);
|
||||
for (gd::String name : externalLayoutsNames) {
|
||||
auto &externalLayout = project.GetExternalLayout(name);
|
||||
externalLayout.GetInitialInstances().MoveInstancesToLayer(originLayerName,
|
||||
targetLayerName);
|
||||
}
|
||||
}
|
||||
|
||||
size_t WholeProjectRefactorer::GetLayoutAndExternalLayoutLayerInstancesCount(
|
||||
gd::Project &project, gd::Layout &layout, const gd::String &layerName) {
|
||||
size_t count = layout.GetInitialInstances().GetLayerInstancesCount(layerName);
|
||||
|
||||
std::vector<gd::String> externalLayoutsNames =
|
||||
GetAssociatedExternalLayouts(project, layout);
|
||||
for (gd::String name : externalLayoutsNames) {
|
||||
auto &externalLayout = project.GetExternalLayout(name);
|
||||
count += externalLayout.GetInitialInstances().GetLayerInstancesCount(layerName);
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
std::vector<gd::String>
|
||||
WholeProjectRefactorer::GetAssociatedExternalLayouts(gd::Project &project,
|
||||
gd::Layout &layout) {
|
||||
|
@@ -456,6 +456,26 @@ class GD_CORE_API WholeProjectRefactorer {
|
||||
const gd::EventsFunctionsExtension& eventsFunctionsExtension,
|
||||
const gd::EventsBasedObject& eventsBasedObject);
|
||||
|
||||
/**
|
||||
* \brief Remove all the instances from one layer.
|
||||
*/
|
||||
static void RemoveLayer(gd::Project &project, gd::Layout &layout,
|
||||
const gd::String &layerName);
|
||||
|
||||
/**
|
||||
* \brief Move all the instances from one layer into another.
|
||||
*/
|
||||
static void MergeLayers(gd::Project &project, gd::Layout &layout,
|
||||
const gd::String &originLayerName,
|
||||
const gd::String &targetLayerName);
|
||||
|
||||
/**
|
||||
* \brief Return the number of instances on the layer named \a layerName and
|
||||
* all its associated layouts.
|
||||
*/
|
||||
static size_t GetLayoutAndExternalLayoutLayerInstancesCount(
|
||||
gd::Project &project, gd::Layout &layout, const gd::String &layerName);
|
||||
|
||||
virtual ~WholeProjectRefactorer(){};
|
||||
|
||||
private:
|
||||
|
@@ -23,11 +23,23 @@ namespace gd {
|
||||
class GD_CORE_API Behavior: public BehaviorConfigurationContainer {
|
||||
public:
|
||||
|
||||
Behavior(): BehaviorConfigurationContainer() {};
|
||||
Behavior(): BehaviorConfigurationContainer(), isDefaultBehavior(false) {};
|
||||
Behavior(const gd::String& name_, const gd::String& type_)
|
||||
: BehaviorConfigurationContainer(name_, type_) {};
|
||||
: BehaviorConfigurationContainer(name_, type_),
|
||||
isDefaultBehavior(false) {};
|
||||
virtual ~Behavior();
|
||||
virtual Behavior* Clone() const override { return new Behavior(*this); }
|
||||
|
||||
bool IsDefaultBehavior() const {
|
||||
return isDefaultBehavior;
|
||||
}
|
||||
|
||||
void SetDefaultBehavior(bool isDefaultBehavior_) {
|
||||
isDefaultBehavior = isDefaultBehavior_;
|
||||
}
|
||||
|
||||
private:
|
||||
bool isDefaultBehavior;
|
||||
};
|
||||
|
||||
} // namespace gd
|
||||
|
@@ -134,8 +134,19 @@ void InitialInstancesContainer::MoveInstancesToLayer(
|
||||
}
|
||||
}
|
||||
|
||||
std::size_t InitialInstancesContainer::GetLayerInstancesCount(
|
||||
const gd::String &layerName) const {
|
||||
std::size_t count = 0;
|
||||
for (const gd::InitialInstance &instance : initialInstances) {
|
||||
if (instance.GetLayer() == layerName) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
bool InitialInstancesContainer::SomeInstancesAreOnLayer(
|
||||
const gd::String& layerName) {
|
||||
const gd::String& layerName) const {
|
||||
return std::any_of(initialInstances.begin(),
|
||||
initialInstances.end(),
|
||||
[&layerName](const InitialInstance& currentInstance) {
|
||||
@@ -144,7 +155,7 @@ bool InitialInstancesContainer::SomeInstancesAreOnLayer(
|
||||
}
|
||||
|
||||
bool InitialInstancesContainer::HasInstancesOfObject(
|
||||
const gd::String& objectName) {
|
||||
const gd::String& objectName) const {
|
||||
return std::any_of(initialInstances.begin(),
|
||||
initialInstances.end(),
|
||||
[&objectName](const InitialInstance& currentInstance) {
|
||||
|
@@ -4,8 +4,8 @@
|
||||
* reserved. This project is released under the MIT License.
|
||||
*/
|
||||
|
||||
#ifndef GDCORE_INITIALINSTANCESCONTAINER_H
|
||||
#define GDCORE_INITIALINSTANCESCONTAINER_H
|
||||
#pragma once
|
||||
|
||||
#include <list>
|
||||
#include "GDCore/Project/InitialInstance.h"
|
||||
#include "GDCore/String.h"
|
||||
@@ -54,7 +54,6 @@ class GD_CORE_API InitialInstancesContainer {
|
||||
return new InitialInstancesContainer(*this);
|
||||
};
|
||||
|
||||
#if defined(GD_IDE_ONLY)
|
||||
/**
|
||||
* Must construct the class from the source
|
||||
* A such method is needed as the IDE may want to store copies of some
|
||||
@@ -71,7 +70,6 @@ class GD_CORE_API InitialInstancesContainer {
|
||||
* from an object which is not a MyContainer"; } \endcode
|
||||
*/
|
||||
void Create(const InitialInstancesContainer &source);
|
||||
#endif
|
||||
|
||||
/** \name Instances management
|
||||
* Members functions related to managing the instances
|
||||
@@ -100,7 +98,6 @@ class GD_CORE_API InitialInstancesContainer {
|
||||
void IterateOverInstancesWithZOrdering(InitialInstanceFunctor &func,
|
||||
const gd::String &layer);
|
||||
|
||||
#if defined(GD_IDE_ONLY)
|
||||
/**
|
||||
* \brief Insert the specified \a instance into the list and return a
|
||||
* a reference to the newly added instance.
|
||||
@@ -140,22 +137,27 @@ class GD_CORE_API InitialInstancesContainer {
|
||||
void RenameInstancesOfObject(const gd::String &oldName,
|
||||
const gd::String &newName);
|
||||
|
||||
/**
|
||||
* \brief Return the number of instances on the layer named \a layerName.
|
||||
*/
|
||||
std::size_t GetLayerInstancesCount(const gd::String &layerName) const;
|
||||
|
||||
/**
|
||||
* \brief Return true if there is at least one instance on the layer named \a
|
||||
* layerName.
|
||||
*/
|
||||
bool SomeInstancesAreOnLayer(const gd::String &layerName);
|
||||
bool SomeInstancesAreOnLayer(const gd::String &layerName) const;
|
||||
|
||||
/**
|
||||
* \brief Return true if there is at least one instance of the given object.
|
||||
*/
|
||||
bool HasInstancesOfObject(const gd::String &objectName);
|
||||
bool HasInstancesOfObject(const gd::String &objectName) const;
|
||||
|
||||
/**
|
||||
* \brief Remove all instances
|
||||
*/
|
||||
void Clear();
|
||||
#endif
|
||||
|
||||
///@}
|
||||
|
||||
/** \name Saving and loading
|
||||
@@ -163,12 +165,10 @@ class GD_CORE_API InitialInstancesContainer {
|
||||
*/
|
||||
///@{
|
||||
|
||||
#if defined(GD_IDE_ONLY)
|
||||
/**
|
||||
* \brief Serialize instances container.
|
||||
*/
|
||||
virtual void SerializeTo(SerializerElement &element) const;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief Unserialize the instances container.
|
||||
@@ -265,5 +265,3 @@ class GD_CORE_API HighestZOrderFinder : public gd::InitialInstanceFunctor {
|
||||
};
|
||||
|
||||
} // namespace gd
|
||||
|
||||
#endif // GDCORE_INITIALINSTANCESCONTAINER_H
|
||||
|
@@ -507,6 +507,81 @@ gd::String GD_CORE_API GetTypeOfObject(const gd::ObjectsContainer& project,
|
||||
return type;
|
||||
}
|
||||
|
||||
void GD_CORE_API FilterBehaviorNamesFromObject(
|
||||
const gd::Object &object, const gd::String &behaviorType,
|
||||
std::vector<gd::String> &behaviorNames) {
|
||||
for (size_t i = 0; i < behaviorNames.size(); i++) {
|
||||
auto &behaviorName = behaviorNames[i];
|
||||
if (!object.HasBehaviorNamed(behaviorName) ||
|
||||
object.GetBehavior(behaviorName).GetTypeName() != behaviorType) {
|
||||
behaviorNames.erase(behaviorNames.begin() + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<gd::String> GD_CORE_API GetBehaviorNamesInObjectOrGroup(
|
||||
const gd::ObjectsContainer &project, const gd::ObjectsContainer &layout,
|
||||
const gd::String &objectOrGroupName, const gd::String &behaviorType,
|
||||
bool searchInGroups) {
|
||||
// Search in objects
|
||||
if (layout.HasObjectNamed(objectOrGroupName)) {
|
||||
auto &object = layout.GetObject(objectOrGroupName);
|
||||
auto behaviorNames = object.GetAllBehaviorNames();
|
||||
FilterBehaviorNamesFromObject(object, behaviorType, behaviorNames);
|
||||
return behaviorNames;
|
||||
}
|
||||
if (project.HasObjectNamed(objectOrGroupName)) {
|
||||
auto &object = project.GetObject(objectOrGroupName);
|
||||
auto behaviorNames = object.GetAllBehaviorNames();
|
||||
FilterBehaviorNamesFromObject(object, behaviorType, behaviorNames);
|
||||
return behaviorNames;
|
||||
}
|
||||
|
||||
if (!searchInGroups) {
|
||||
std::vector<gd::String> behaviorNames;
|
||||
return behaviorNames;
|
||||
}
|
||||
|
||||
// Search in groups
|
||||
const gd::ObjectsContainer *container;
|
||||
if (layout.GetObjectGroups().Has(objectOrGroupName)) {
|
||||
container = &layout;
|
||||
} else if (project.GetObjectGroups().Has(objectOrGroupName)) {
|
||||
container = &project;
|
||||
} else {
|
||||
std::vector<gd::String> behaviorNames;
|
||||
return behaviorNames;
|
||||
}
|
||||
const vector<gd::String> &groupsObjects =
|
||||
container->GetObjectGroups().Get(objectOrGroupName).GetAllObjectsNames();
|
||||
// Empty groups don't contain any behavior.
|
||||
if (groupsObjects.empty()) {
|
||||
std::vector<gd::String> behaviorNames;
|
||||
return behaviorNames;
|
||||
}
|
||||
|
||||
auto behaviorNames = GetBehaviorNamesInObjectOrGroup(
|
||||
project, layout, groupsObjects[0], behaviorType, false);
|
||||
for (size_t i = 1; i < groupsObjects.size(); i++) {
|
||||
auto &objectName = groupsObjects[i];
|
||||
|
||||
if (layout.HasObjectNamed(objectName)) {
|
||||
auto &object = layout.GetObject(objectName);
|
||||
FilterBehaviorNamesFromObject(object, behaviorType, behaviorNames);
|
||||
return behaviorNames;
|
||||
}
|
||||
if (project.HasObjectNamed(objectName)) {
|
||||
auto &object = project.GetObject(objectName);
|
||||
FilterBehaviorNamesFromObject(object, behaviorType, behaviorNames);
|
||||
return behaviorNames;
|
||||
}
|
||||
if (behaviorNames.size() == 0) {
|
||||
return behaviorNames;
|
||||
}
|
||||
}
|
||||
return behaviorNames;
|
||||
}
|
||||
|
||||
bool GD_CORE_API HasBehaviorInObjectOrGroup(const gd::ObjectsContainer &project,
|
||||
const gd::ObjectsContainer &layout,
|
||||
const gd::String &objectOrGroupName,
|
||||
@@ -520,6 +595,56 @@ bool GD_CORE_API HasBehaviorInObjectOrGroup(const gd::ObjectsContainer &project,
|
||||
return project.GetObject(objectOrGroupName).HasBehaviorNamed(behaviorName);
|
||||
}
|
||||
|
||||
if (!searchInGroups) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Search in groups
|
||||
const gd::ObjectsContainer *container;
|
||||
if (layout.GetObjectGroups().Has(objectOrGroupName)) {
|
||||
container = &layout;
|
||||
} else if (project.GetObjectGroups().Has(objectOrGroupName)) {
|
||||
container = &project;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
const vector<gd::String> &groupsObjects =
|
||||
container->GetObjectGroups().Get(objectOrGroupName).GetAllObjectsNames();
|
||||
// Empty groups don't contain any behavior.
|
||||
if (groupsObjects.empty()) {
|
||||
return false;
|
||||
}
|
||||
// Check that all objects have the behavior.
|
||||
for (auto &&object : groupsObjects) {
|
||||
if (!HasBehaviorInObjectOrGroup(project, layout, object, behaviorName,
|
||||
false)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GD_CORE_API IsDefaultBehavior(const gd::ObjectsContainer& project,
|
||||
const gd::ObjectsContainer& layout,
|
||||
gd::String objectOrGroupName,
|
||||
gd::String behaviorName,
|
||||
bool searchInGroups) {
|
||||
// Search in objects
|
||||
if (layout.HasObjectNamed(objectOrGroupName)) {
|
||||
auto &object = layout.GetObject(objectOrGroupName);
|
||||
return object.HasBehaviorNamed(behaviorName) &&
|
||||
object.GetBehavior(behaviorName).IsDefaultBehavior();
|
||||
}
|
||||
if (project.HasObjectNamed(objectOrGroupName)) {
|
||||
auto &object = project.GetObject(objectOrGroupName);
|
||||
return object.HasBehaviorNamed(behaviorName) &&
|
||||
object.GetBehavior(behaviorName).IsDefaultBehavior();
|
||||
}
|
||||
|
||||
if (!searchInGroups) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Search in groups
|
||||
const gd::ObjectsContainer *container;
|
||||
if (layout.GetObjectGroups().Has(objectOrGroupName)) {
|
||||
@@ -537,7 +662,7 @@ bool GD_CORE_API HasBehaviorInObjectOrGroup(const gd::ObjectsContainer &project,
|
||||
}
|
||||
// Check that all objects have the same type.
|
||||
for (auto &&object : groupsObjects) {
|
||||
if (!HasBehaviorInObjectOrGroup(project, layout, object, behaviorName,
|
||||
if (!IsDefaultBehavior(project, layout, object, behaviorName,
|
||||
false)) {
|
||||
return false;
|
||||
}
|
||||
@@ -545,6 +670,54 @@ bool GD_CORE_API HasBehaviorInObjectOrGroup(const gd::ObjectsContainer &project,
|
||||
return true;
|
||||
}
|
||||
|
||||
gd::String GD_CORE_API GetTypeOfBehaviorInObjectOrGroup(const gd::ObjectsContainer& project,
|
||||
const gd::ObjectsContainer& layout,
|
||||
const gd::String& objectOrGroupName,
|
||||
const gd::String& behaviorName,
|
||||
bool searchInGroups) {
|
||||
// Search in objects
|
||||
if (layout.HasObjectNamed(objectOrGroupName)) {
|
||||
auto &object = layout.GetObject(objectOrGroupName);
|
||||
return object.HasBehaviorNamed(behaviorName) ?
|
||||
object.GetBehavior(behaviorName).GetTypeName() : "";
|
||||
}
|
||||
if (project.HasObjectNamed(objectOrGroupName)) {
|
||||
auto &object = project.GetObject(objectOrGroupName);
|
||||
return object.HasBehaviorNamed(behaviorName) ?
|
||||
object.GetBehavior(behaviorName).GetTypeName() : "";
|
||||
}
|
||||
|
||||
if (!searchInGroups) {
|
||||
return "";
|
||||
}
|
||||
|
||||
// Search in groups
|
||||
const gd::ObjectsContainer *container;
|
||||
if (layout.GetObjectGroups().Has(objectOrGroupName)) {
|
||||
container = &layout;
|
||||
} else if (project.GetObjectGroups().Has(objectOrGroupName)) {
|
||||
container = &project;
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
const vector<gd::String> &groupsObjects =
|
||||
container->GetObjectGroups().Get(objectOrGroupName).GetAllObjectsNames();
|
||||
// Empty groups don't contain any behavior.
|
||||
if (groupsObjects.empty()) {
|
||||
return "";
|
||||
}
|
||||
// Check that all objects have the behavior with the same type.
|
||||
auto behaviorType = GetTypeOfBehaviorInObjectOrGroup(
|
||||
project, layout, groupsObjects[0], behaviorName, false);
|
||||
for (auto &&object : groupsObjects) {
|
||||
if (GetTypeOfBehaviorInObjectOrGroup(project, layout, object, behaviorName,
|
||||
false) != behaviorType) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
return behaviorType;
|
||||
}
|
||||
|
||||
gd::String GD_CORE_API GetTypeOfBehavior(const gd::ObjectsContainer& project,
|
||||
const gd::ObjectsContainer& layout,
|
||||
gd::String name,
|
||||
|
@@ -443,13 +443,39 @@ gd::String GD_CORE_API GetTypeOfObject(const ObjectsContainer& game,
|
||||
gd::String objectName,
|
||||
bool searchInGroups = true);
|
||||
/**
|
||||
* \brief Check if an object or all object of a group has a behavior.
|
||||
* \brief Check if an object or all objects of a group has a behavior.
|
||||
*/
|
||||
bool GD_CORE_API HasBehaviorInObjectOrGroup(const gd::ObjectsContainer &project,
|
||||
const gd::ObjectsContainer &layout,
|
||||
const gd::String &objectOrGroupName,
|
||||
const gd::String &behaviorName,
|
||||
bool searchInGroups = true);
|
||||
/**
|
||||
* \brief Get the names of behavior of a given type if an object or all objects of a group has it.
|
||||
*/
|
||||
std::vector<gd::String> GD_CORE_API GetBehaviorNamesInObjectOrGroup(
|
||||
const gd::ObjectsContainer &project, const gd::ObjectsContainer &layout,
|
||||
const gd::String &objectOrGroupName, const gd::String &behaviorType,
|
||||
bool searchInGroups);
|
||||
|
||||
/**
|
||||
* \brief Check if a behavior is a default one or doesn't exist in an object or
|
||||
* all objects of a group.
|
||||
*/
|
||||
bool GD_CORE_API IsDefaultBehavior(const gd::ObjectsContainer& project,
|
||||
const gd::ObjectsContainer& layout,
|
||||
gd::String objectOrGroupName,
|
||||
gd::String behaviorName,
|
||||
bool searchInGroups = true);
|
||||
|
||||
/**
|
||||
* \brief Get the type of a behavior if an object or all objects of a group has it.
|
||||
*/
|
||||
gd::String GD_CORE_API GetTypeOfBehaviorInObjectOrGroup(const gd::ObjectsContainer &project,
|
||||
const gd::ObjectsContainer &layout,
|
||||
const gd::String &objectOrGroupName,
|
||||
const gd::String &behaviorName,
|
||||
bool searchInGroups = true);
|
||||
/**
|
||||
* \brief Get a type from a behavior name
|
||||
* @return Type of the behavior.
|
||||
|
@@ -134,7 +134,6 @@ void Object::UnserializeFrom(gd::Project& project,
|
||||
|
||||
objectVariables.UnserializeFrom(
|
||||
element.GetChild("variables", 0, "Variables"));
|
||||
behaviors.clear();
|
||||
|
||||
if (element.HasChild("effects")) {
|
||||
const SerializerElement& effectsElement = element.GetChild("effects");
|
||||
@@ -210,6 +209,11 @@ void Object::SerializeTo(SerializerElement& element) const {
|
||||
std::vector<gd::String> allBehaviors = GetAllBehaviorNames();
|
||||
for (std::size_t i = 0; i < allBehaviors.size(); ++i) {
|
||||
const gd::Behavior& behavior = GetBehavior(allBehaviors[i]);
|
||||
// Default behaviors are added at the object creation according to metadata.
|
||||
// They don't need to be serialized.
|
||||
if (behavior.IsDefaultBehavior()) {
|
||||
continue;
|
||||
}
|
||||
SerializerElement& behaviorElement = behaviorsElement.AddChild("behavior");
|
||||
|
||||
behavior.SerializeTo(behaviorElement);
|
||||
|
@@ -15,13 +15,12 @@
|
||||
#include <vector>
|
||||
|
||||
#include "GDCore/CommonTools.h"
|
||||
#include "GDCore/Events/Parsers/GrammarTerminals.h"
|
||||
#include "GDCore/Extensions/Metadata/ExpressionMetadata.h"
|
||||
#include "GDCore/Extensions/Metadata/MetadataProvider.h"
|
||||
#include "GDCore/Extensions/Platform.h"
|
||||
#include "GDCore/Extensions/PlatformExtension.h"
|
||||
#include "GDCore/IDE/Events/UsedExtensionsFinder.h"
|
||||
#include "GDCore/IDE/PlatformManager.h"
|
||||
#include "GDCore/IDE/Project/ArbitraryResourceWorker.h"
|
||||
#include "GDCore/Project/CustomObjectConfiguration.h"
|
||||
#include "GDCore/Project/EventsFunctionsExtension.h"
|
||||
#include "GDCore/Project/ExternalEvents.h"
|
||||
@@ -49,6 +48,11 @@ using namespace std;
|
||||
|
||||
namespace gd {
|
||||
|
||||
// By default, disallow unicode in identifiers, but this can be set to true
|
||||
// by the IDE. In the future, this will be set to true by default, keeping backward compatibility.
|
||||
// We keep it disabled by default to progressively ask users to test it in real projects.
|
||||
bool Project::allowUsageOfUnicodeIdentifierNames = false;
|
||||
|
||||
Project::Project()
|
||||
: name(_("Project")),
|
||||
version("1.0.0"),
|
||||
@@ -82,9 +86,47 @@ Project::~Project() {}
|
||||
|
||||
void Project::ResetProjectUuid() { projectUuid = UUID::MakeUuid4(); }
|
||||
|
||||
std::unique_ptr<gd::Object> Project::CreateObject(
|
||||
const gd::String& type, const gd::String& name) const {
|
||||
return gd::make_unique<Object>(name, type, CreateObjectConfiguration(type));
|
||||
std::unique_ptr<gd::Object>
|
||||
Project::CreateObject(const gd::String &objectType, const gd::String &name) const {
|
||||
std::unique_ptr<gd::Object> object =
|
||||
gd::make_unique<Object>(name, objectType, CreateObjectConfiguration(objectType));
|
||||
|
||||
auto &platform = GetCurrentPlatform();
|
||||
auto &project = *this;
|
||||
auto addDefaultBehavior =
|
||||
[&platform,
|
||||
&project,
|
||||
&object,
|
||||
&objectType](const gd::String& behaviorType) {
|
||||
auto &behaviorMetadata =
|
||||
gd::MetadataProvider::GetBehaviorMetadata(platform, behaviorType);
|
||||
if (MetadataProvider::IsBadBehaviorMetadata(behaviorMetadata)) {
|
||||
gd::LogWarning("Object: " + objectType + " has an unknown default behavior: " + behaviorType);
|
||||
return;
|
||||
}
|
||||
auto* behavior = object->AddNewBehavior(project, behaviorType,
|
||||
behaviorMetadata.GetDefaultName());
|
||||
behavior->SetDefaultBehavior(true);
|
||||
};
|
||||
|
||||
if (Project::HasEventsBasedObject(objectType)) {
|
||||
addDefaultBehavior("EffectCapability::EffectBehavior");
|
||||
addDefaultBehavior("ResizableCapability::ResizableBehavior");
|
||||
addDefaultBehavior("ScalableCapability::ScalableBehavior");
|
||||
addDefaultBehavior("FlippableCapability::FlippableBehavior");
|
||||
}
|
||||
else {
|
||||
auto &objectMetadata = gd::MetadataProvider::GetObjectMetadata(platform, objectType);
|
||||
if (MetadataProvider::IsBadObjectMetadata(objectMetadata)) {
|
||||
gd::LogWarning("Object: " + name + " has an unknown type: " + objectType);
|
||||
}
|
||||
for (auto &behaviorType : objectMetadata.GetDefaultBehaviors()) {
|
||||
addDefaultBehavior(behaviorType);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return std::move(object);
|
||||
}
|
||||
|
||||
std::unique_ptr<gd::ObjectConfiguration> Project::CreateObjectConfiguration(
|
||||
@@ -630,8 +672,10 @@ void Project::UnserializeFrom(const SerializerElement& element) {
|
||||
SetAdaptGameResolutionAtRuntime(
|
||||
propElement.GetBoolAttribute("adaptGameResolutionAtRuntime", false));
|
||||
SetSizeOnStartupMode(propElement.GetStringAttribute("sizeOnStartupMode", ""));
|
||||
SetAntialiasingMode(propElement.GetStringAttribute("antialiasingMode", "MSAA"));
|
||||
SetAntialisingEnabledOnMobile(propElement.GetBoolAttribute("antialisingEnabledOnMobile", false));
|
||||
SetAntialiasingMode(
|
||||
propElement.GetStringAttribute("antialiasingMode", "MSAA"));
|
||||
SetAntialisingEnabledOnMobile(
|
||||
propElement.GetBoolAttribute("antialisingEnabledOnMobile", false));
|
||||
SetProjectUuid(propElement.GetStringAttribute("projectUuid", ""));
|
||||
SetAuthor(propElement.GetChild("author", 0, "Auteur").GetValue().GetString());
|
||||
SetPackageName(propElement.GetStringAttribute("packageName"));
|
||||
@@ -887,7 +931,8 @@ void Project::SerializeTo(SerializerElement& element) const {
|
||||
adaptGameResolutionAtRuntime);
|
||||
propElement.SetAttribute("sizeOnStartupMode", sizeOnStartupMode);
|
||||
propElement.SetAttribute("antialiasingMode", antialiasingMode);
|
||||
propElement.SetAttribute("antialisingEnabledOnMobile", isAntialisingEnabledOnMobile);
|
||||
propElement.SetAttribute("antialisingEnabledOnMobile",
|
||||
isAntialisingEnabledOnMobile);
|
||||
propElement.SetAttribute("projectUuid", projectUuid);
|
||||
propElement.SetAttribute("folderProject", folderProject);
|
||||
propElement.SetAttribute("packageName", packageName);
|
||||
@@ -993,58 +1038,57 @@ void Project::SerializeTo(SerializerElement& element) const {
|
||||
externalSourceFilesElement.AddChild("sourceFile"));
|
||||
}
|
||||
|
||||
bool Project::ValidateName(const gd::String& name) {
|
||||
void Project::AllowUsageOfUnicodeIdentifierNames(bool enable) {
|
||||
allowUsageOfUnicodeIdentifierNames = enable;
|
||||
}
|
||||
|
||||
bool Project::IsNameSafe(const gd::String& name) {
|
||||
if (name.empty()) return false;
|
||||
|
||||
if (isdigit(name[0])) return false;
|
||||
|
||||
gd::String allowedCharacters =
|
||||
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_";
|
||||
return !(name.find_first_not_of(allowedCharacters) != gd::String::npos);
|
||||
if (!allowUsageOfUnicodeIdentifierNames) {
|
||||
gd::String legacyAllowedCharacters =
|
||||
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_";
|
||||
return !(name.find_first_not_of(legacyAllowedCharacters) != gd::String::npos);
|
||||
} else {
|
||||
for (auto character : name) {
|
||||
if (!GrammarTerminals::IsAllowedInIdentifier(character)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void Project::ExposeResources(gd::ArbitraryResourceWorker& worker) {
|
||||
// See also gd::ProjectBrowserHelper::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.
|
||||
gd::String Project::GetSafeName(const gd::String& name) {
|
||||
if (name.empty()) return "Unnamed";
|
||||
|
||||
gd::ResourcesManager* resourcesManager = &GetResourcesManager();
|
||||
gd::String newName = name;
|
||||
|
||||
// Add project resources
|
||||
worker.ExposeResources(resourcesManager);
|
||||
platformSpecificAssets.ExposeResources(worker);
|
||||
if (isdigit(name[0])) newName = "_" + newName;
|
||||
|
||||
// Add layouts resources
|
||||
for (std::size_t s = 0; s < GetLayoutsCount(); s++) {
|
||||
for (std::size_t j = 0; j < GetLayout(s).GetObjectsCount();
|
||||
++j) { // Add objects resources
|
||||
GetLayout(s).GetObject(j).GetConfiguration().ExposeResources(worker);
|
||||
}
|
||||
gd::String legacyAllowedCharacters =
|
||||
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_";
|
||||
|
||||
LaunchResourceWorkerOnEvents(*this, GetLayout(s).GetEvents(), worker);
|
||||
}
|
||||
// Add external events resources
|
||||
for (std::size_t s = 0; s < GetExternalEventsCount(); s++) {
|
||||
LaunchResourceWorkerOnEvents(
|
||||
*this, GetExternalEvents(s).GetEvents(), worker);
|
||||
}
|
||||
// Add events functions extensions resources
|
||||
for (std::size_t e = 0; e < GetEventsFunctionsExtensionsCount(); e++) {
|
||||
auto& eventsFunctionsExtension = GetEventsFunctionsExtension(e);
|
||||
for (auto&& eventsFunction : eventsFunctionsExtension.GetInternalVector()) {
|
||||
LaunchResourceWorkerOnEvents(*this, eventsFunction->GetEvents(), worker);
|
||||
for (size_t i = 0;i < newName.size();++i) {
|
||||
// Note that iterating on the characters is not super efficient (O(n^2), which
|
||||
// could be avoided with an iterator), but this function is not critical for performance
|
||||
// (only used to generate a name when a user creates a new entity or rename one).
|
||||
auto character = newName[i];
|
||||
bool isAllowed =
|
||||
allowUsageOfUnicodeIdentifierNames
|
||||
? GrammarTerminals::IsAllowedInIdentifier(character)
|
||||
: legacyAllowedCharacters.find(character) != gd::String::npos;
|
||||
|
||||
// Replace all unallowed letters by an underscore.
|
||||
if (!isAllowed) {
|
||||
newName.replace(i, 1, '_');
|
||||
}
|
||||
}
|
||||
|
||||
// Add global objects resources
|
||||
for (std::size_t j = 0; j < GetObjectsCount(); ++j) {
|
||||
GetObject(j).GetConfiguration().ExposeResources(worker);
|
||||
}
|
||||
|
||||
// Add loading screen background image if present
|
||||
if (loadingScreen.GetBackgroundImageResourceName() != "")
|
||||
worker.ExposeImage(loadingScreen.GetBackgroundImageResourceName());
|
||||
return newName;
|
||||
}
|
||||
|
||||
bool Project::HasSourceFile(gd::String name, gd::String language) const {
|
||||
|
@@ -942,16 +942,6 @@ class GD_CORE_API Project : public ObjectsContainer {
|
||||
*/
|
||||
ResourcesManager& GetResourcesManager() { return resourcesManager; }
|
||||
|
||||
/**
|
||||
* \brief Called ( e.g. during compilation ) so as to inventory internal
|
||||
* resources, sometimes update their filename or any other work or resources.
|
||||
*
|
||||
* See WholeProjectRefactorer for the same thing for events.
|
||||
*
|
||||
* \see WholeProjectRefactorer
|
||||
* \see ArbitraryResourceWorker
|
||||
*/
|
||||
void ExposeResources(gd::ArbitraryResourceWorker& worker);
|
||||
///@}
|
||||
|
||||
/** \name Variable management
|
||||
@@ -975,15 +965,35 @@ class GD_CORE_API Project : public ObjectsContainer {
|
||||
|
||||
///@}
|
||||
|
||||
/** \name Other
|
||||
/** \name Identifier names
|
||||
*/
|
||||
///@{
|
||||
|
||||
/**
|
||||
* Check if unicode names are allowed in identifier names.
|
||||
* \see IsNameSafe
|
||||
* \see GetSafeName
|
||||
*/
|
||||
static bool IsUsageOfUnicodeIdentifierNamesAllowed() { return allowUsageOfUnicodeIdentifierNames; };
|
||||
|
||||
/**
|
||||
* Set if unicode names are allowed in identifier names.
|
||||
* \see IsNameSafe
|
||||
* \see GetSafeName
|
||||
*/
|
||||
static void AllowUsageOfUnicodeIdentifierNames(bool enable);
|
||||
|
||||
/**
|
||||
* Return true if \a name is valid (can be used safely for an object,
|
||||
* behavior, events function name, etc...).
|
||||
*/
|
||||
static bool ValidateName(const gd::String& name);
|
||||
static bool IsNameSafe(const gd::String& name);
|
||||
|
||||
/**
|
||||
* Return a name, based on the one passed in parameter, that can be safely used
|
||||
* for an object, behavior, events function name, etc...
|
||||
*/
|
||||
static gd::String GetSafeName(const gd::String& name);
|
||||
///@}
|
||||
|
||||
/** \name External source files
|
||||
@@ -1118,6 +1128,8 @@ class GD_CORE_API Project : public ObjectsContainer {
|
||||
///< time the project was saved.
|
||||
mutable unsigned int gdBuildVersion; ///< The GD build version used the last
|
||||
///< time the project was saved.
|
||||
|
||||
static bool allowUsageOfUnicodeIdentifierNames;
|
||||
};
|
||||
|
||||
} // namespace gd
|
||||
|
@@ -22,6 +22,10 @@
|
||||
#include "DummyPlatform.h"
|
||||
#include "GDCore/Extensions/Builtin/SpriteExtension/SpriteObject.h"
|
||||
#include "catch.hpp"
|
||||
#include "GDCore/IDE/ResourceExposer.h"
|
||||
#include "GDCore/Project/Effect.h"
|
||||
#include "GDCore/Project/EventsFunctionsExtension.h"
|
||||
#include "GDCore/Project/ExternalEvents.h"
|
||||
|
||||
class ArbitraryResourceWorkerTest : public gd::ArbitraryResourceWorker {
|
||||
public:
|
||||
@@ -55,7 +59,7 @@ TEST_CASE("ArbitraryResourceWorker", "[common][resources]") {
|
||||
"res4", "path/to/file4.png", "audio");
|
||||
ArbitraryResourceWorkerTest worker;
|
||||
|
||||
project.ExposeResources(worker);
|
||||
gd::ResourceExposer::ExposeWholeProjectResources(project, worker);
|
||||
REQUIRE(worker.files.size() == 4);
|
||||
REQUIRE(std::find(worker.files.begin(),
|
||||
worker.files.end(),
|
||||
@@ -78,7 +82,7 @@ TEST_CASE("ArbitraryResourceWorker", "[common][resources]") {
|
||||
|
||||
worker.files.clear();
|
||||
worker.images.clear();
|
||||
project.ExposeResources(worker);
|
||||
gd::ResourceExposer::ExposeWholeProjectResources(project, worker);
|
||||
REQUIRE(worker.files.size() == 4);
|
||||
REQUIRE(worker.images.size() == 1);
|
||||
REQUIRE(worker.images[0] == "res1");
|
||||
@@ -124,7 +128,7 @@ TEST_CASE("ArbitraryResourceWorker", "[common][resources]") {
|
||||
standardEvent.GetActions().Insert(instruction);
|
||||
layout.GetEvents().InsertEvent(standardEvent);
|
||||
|
||||
project.ExposeResources(worker);
|
||||
gd::ResourceExposer::ExposeWholeProjectResources(project, worker);
|
||||
REQUIRE(worker.bitmapFonts.size() == 1);
|
||||
REQUIRE(worker.bitmapFonts[0] == "res3");
|
||||
REQUIRE(worker.images.size() == 1);
|
||||
@@ -132,4 +136,207 @@ TEST_CASE("ArbitraryResourceWorker", "[common][resources]") {
|
||||
REQUIRE(worker.audios.size() == 1);
|
||||
REQUIRE(worker.audios[0] == "res4");
|
||||
}
|
||||
|
||||
SECTION("Can find resource usage in external events") {
|
||||
gd::Platform platform;
|
||||
gd::Project project;
|
||||
SetupProjectWithDummyPlatform(project, platform);
|
||||
project.GetResourcesManager().AddResource(
|
||||
"res1", "path/to/file1.png", "image");
|
||||
project.GetResourcesManager().AddResource(
|
||||
"res2", "path/to/file2.png", "image");
|
||||
project.GetResourcesManager().AddResource(
|
||||
"res3", "path/to/file3.fnt", "bitmapFont");
|
||||
project.GetResourcesManager().AddResource(
|
||||
"res4", "path/to/file4.png", "audio");
|
||||
ArbitraryResourceWorkerTest worker;
|
||||
|
||||
auto& externalEvents = project.InsertNewExternalEvents("MyExternalEvents", 0);
|
||||
|
||||
gd::StandardEvent standardEvent;
|
||||
gd::Instruction instruction;
|
||||
instruction.SetType("MyExtension::DoSomethingWithResources");
|
||||
instruction.SetParametersCount(3);
|
||||
instruction.SetParameter(0, "res3");
|
||||
instruction.SetParameter(1, "res1");
|
||||
instruction.SetParameter(2, "res4");
|
||||
standardEvent.GetActions().Insert(instruction);
|
||||
externalEvents.GetEvents().InsertEvent(standardEvent);
|
||||
|
||||
// MyExternalEvents doesn't need to be used in any layout events.
|
||||
|
||||
gd::ResourceExposer::ExposeWholeProjectResources(project, worker);
|
||||
REQUIRE(worker.bitmapFonts.size() == 1);
|
||||
REQUIRE(worker.bitmapFonts[0] == "res3");
|
||||
REQUIRE(worker.images.size() == 1);
|
||||
REQUIRE(worker.images[0] == "res1");
|
||||
REQUIRE(worker.audios.size() == 1);
|
||||
REQUIRE(worker.audios[0] == "res4");
|
||||
}
|
||||
|
||||
SECTION("Can find resource usage in event-based functions") {
|
||||
gd::Project project;
|
||||
gd::Platform platform;
|
||||
SetupProjectWithDummyPlatform(project, platform);
|
||||
|
||||
project.GetResourcesManager().AddResource(
|
||||
"res1", "path/to/file1.png", "image");
|
||||
project.GetResourcesManager().AddResource(
|
||||
"res2", "path/to/file2.png", "image");
|
||||
project.GetResourcesManager().AddResource(
|
||||
"res3", "path/to/file3.png", "image");
|
||||
ArbitraryResourceWorkerTest worker;
|
||||
|
||||
auto& extension = project.InsertNewEventsFunctionsExtension("MyEventExtention", 0);
|
||||
auto& function = extension.InsertNewEventsFunction("MyFreeFunction", 0);
|
||||
|
||||
gd::StandardEvent standardEvent;
|
||||
gd::Instruction instruction;
|
||||
instruction.SetType("MyExtension::DoSomethingWithResources");
|
||||
instruction.SetParametersCount(3);
|
||||
instruction.SetParameter(0, "res3");
|
||||
instruction.SetParameter(1, "res1");
|
||||
instruction.SetParameter(2, "res4");
|
||||
standardEvent.GetActions().Insert(instruction);
|
||||
function.GetEvents().InsertEvent(standardEvent);
|
||||
|
||||
// MyEventExtention::MyFreeFunction doesn't need to be actually used in events.
|
||||
|
||||
gd::ResourceExposer::ExposeWholeProjectResources(project, worker);
|
||||
REQUIRE(worker.bitmapFonts.size() == 1);
|
||||
REQUIRE(worker.bitmapFonts[0] == "res3");
|
||||
REQUIRE(worker.images.size() == 1);
|
||||
REQUIRE(worker.images[0] == "res1");
|
||||
REQUIRE(worker.audios.size() == 1);
|
||||
REQUIRE(worker.audios[0] == "res4");
|
||||
}
|
||||
|
||||
SECTION("Can find resource usage in event-based behavior functions") {
|
||||
gd::Project project;
|
||||
gd::Platform platform;
|
||||
SetupProjectWithDummyPlatform(project, platform);
|
||||
|
||||
project.GetResourcesManager().AddResource(
|
||||
"res1", "path/to/file1.png", "image");
|
||||
project.GetResourcesManager().AddResource(
|
||||
"res2", "path/to/file2.png", "image");
|
||||
project.GetResourcesManager().AddResource(
|
||||
"res3", "path/to/file3.png", "image");
|
||||
ArbitraryResourceWorkerTest worker;
|
||||
|
||||
auto& extension = project.InsertNewEventsFunctionsExtension("MyEventExtention", 0);
|
||||
auto& behavior = extension.GetEventsBasedBehaviors().InsertNew("MyBehavior", 0);
|
||||
auto& function = behavior.GetEventsFunctions().InsertNewEventsFunction("MyFunction", 0);
|
||||
|
||||
gd::StandardEvent standardEvent;
|
||||
gd::Instruction instruction;
|
||||
instruction.SetType("MyExtension::DoSomethingWithResources");
|
||||
instruction.SetParametersCount(3);
|
||||
instruction.SetParameter(0, "res3");
|
||||
instruction.SetParameter(1, "res1");
|
||||
instruction.SetParameter(2, "res4");
|
||||
standardEvent.GetActions().Insert(instruction);
|
||||
function.GetEvents().InsertEvent(standardEvent);
|
||||
|
||||
// MyEventExtention::MyBehavior::MyFunction doesn't need to be actually used in events.
|
||||
|
||||
gd::ResourceExposer::ExposeWholeProjectResources(project, worker);
|
||||
REQUIRE(worker.bitmapFonts.size() == 1);
|
||||
REQUIRE(worker.bitmapFonts[0] == "res3");
|
||||
REQUIRE(worker.images.size() == 1);
|
||||
REQUIRE(worker.images[0] == "res1");
|
||||
REQUIRE(worker.audios.size() == 1);
|
||||
REQUIRE(worker.audios[0] == "res4");
|
||||
}
|
||||
|
||||
SECTION("Can find resource usage in event-based object functions") {
|
||||
gd::Project project;
|
||||
gd::Platform platform;
|
||||
SetupProjectWithDummyPlatform(project, platform);
|
||||
|
||||
project.GetResourcesManager().AddResource(
|
||||
"res1", "path/to/file1.png", "image");
|
||||
project.GetResourcesManager().AddResource(
|
||||
"res2", "path/to/file2.png", "image");
|
||||
project.GetResourcesManager().AddResource(
|
||||
"res3", "path/to/file3.png", "image");
|
||||
ArbitraryResourceWorkerTest worker;
|
||||
|
||||
auto& extension = project.InsertNewEventsFunctionsExtension("MyEventExtention", 0);
|
||||
auto& object = extension.GetEventsBasedObjects().InsertNew("MyObject", 0);
|
||||
auto& function = object.GetEventsFunctions().InsertNewEventsFunction("MyFunction", 0);
|
||||
|
||||
gd::StandardEvent standardEvent;
|
||||
gd::Instruction instruction;
|
||||
instruction.SetType("MyExtension::DoSomethingWithResources");
|
||||
instruction.SetParametersCount(3);
|
||||
instruction.SetParameter(0, "res3");
|
||||
instruction.SetParameter(1, "res1");
|
||||
instruction.SetParameter(2, "res4");
|
||||
standardEvent.GetActions().Insert(instruction);
|
||||
function.GetEvents().InsertEvent(standardEvent);
|
||||
|
||||
// MyEventExtention::MyObject::MyFunction doesn't need to be actually used in events.
|
||||
|
||||
gd::ResourceExposer::ExposeWholeProjectResources(project, worker);
|
||||
REQUIRE(worker.bitmapFonts.size() == 1);
|
||||
REQUIRE(worker.bitmapFonts[0] == "res3");
|
||||
REQUIRE(worker.images.size() == 1);
|
||||
REQUIRE(worker.images[0] == "res1");
|
||||
REQUIRE(worker.audios.size() == 1);
|
||||
REQUIRE(worker.audios[0] == "res4");
|
||||
}
|
||||
|
||||
SECTION("Can find resource usage in layer effects") {
|
||||
gd::Project project;
|
||||
gd::Platform platform;
|
||||
SetupProjectWithDummyPlatform(project, platform);
|
||||
|
||||
project.GetResourcesManager().AddResource(
|
||||
"res1", "path/to/file1.png", "image");
|
||||
project.GetResourcesManager().AddResource(
|
||||
"res2", "path/to/file2.png", "image");
|
||||
project.GetResourcesManager().AddResource(
|
||||
"res3", "path/to/file3.png", "image");
|
||||
ArbitraryResourceWorkerTest worker;
|
||||
|
||||
auto& layout = project.InsertNewLayout("Scene", 0);
|
||||
layout.InsertNewLayer("MyLayer", 0);
|
||||
auto& layer = layout.GetLayer("MyLayer");
|
||||
auto& effect = layer.GetEffects().InsertNewEffect("MyEffect", 0);
|
||||
effect.SetEffectType("MyExtension::EffectWithResource");
|
||||
effect.SetStringParameter("texture", "res1");
|
||||
|
||||
gd::ResourceExposer::ExposeWholeProjectResources(project, worker);
|
||||
REQUIRE(worker.files.size() == 3);
|
||||
REQUIRE(worker.images.size() == 1);
|
||||
REQUIRE(worker.images[0] == "res1");
|
||||
}
|
||||
|
||||
SECTION("Can find resource usage in object effects") {
|
||||
gd::Project project;
|
||||
gd::Platform platform;
|
||||
SetupProjectWithDummyPlatform(project, platform);
|
||||
|
||||
project.GetResourcesManager().AddResource(
|
||||
"res1", "path/to/file1.png", "image");
|
||||
project.GetResourcesManager().AddResource(
|
||||
"res2", "path/to/file2.png", "image");
|
||||
project.GetResourcesManager().AddResource(
|
||||
"res3", "path/to/file3.png", "image");
|
||||
ArbitraryResourceWorkerTest worker;
|
||||
|
||||
auto& layout = project.InsertNewLayout("Scene", 0);
|
||||
layout.InsertNewLayer("MyLayer", 0);
|
||||
auto& layer = layout.GetLayer("MyLayer");
|
||||
auto& object = layout.InsertNewObject(project, "MyExtension::Sprite", "MyObject", 0);
|
||||
auto& effect = object.GetEffects().InsertNewEffect("MyEffect", 0);
|
||||
effect.SetEffectType("MyExtension::EffectWithResource");
|
||||
effect.SetStringParameter("texture", "res1");
|
||||
|
||||
gd::ResourceExposer::ExposeWholeProjectResources(project, worker);
|
||||
REQUIRE(worker.files.size() == 3);
|
||||
REQUIRE(worker.images.size() == 1);
|
||||
REQUIRE(worker.images[0] == "res1");
|
||||
}
|
||||
}
|
||||
|
@@ -113,17 +113,6 @@ void SetupProjectWithDummyPlatform(gd::Project& project,
|
||||
auto& baseObject = baseObjectExtension->AddObject<gd::ObjectConfiguration>(
|
||||
"", "Dummy Base Object", "Dummy Base Object", "");
|
||||
|
||||
// Add this expression for all objects. But it requires a "capability".
|
||||
baseObject
|
||||
.AddStrExpression("GetSomethingRequiringEffectCapability",
|
||||
"Get something, but this requires the effect capability for the object.",
|
||||
"",
|
||||
"",
|
||||
"")
|
||||
.AddParameter("object", _("Object"), "")
|
||||
.AddParameter("expression", _("Number parameter"))
|
||||
.SetRequiresBaseObjectCapability("effect")
|
||||
.SetFunctionName("getSomethingRequiringEffectCapability");
|
||||
baseObject
|
||||
.AddExpression("GetFromBaseExpression",
|
||||
"This works on any object.",
|
||||
@@ -133,6 +122,84 @@ void SetupProjectWithDummyPlatform(gd::Project& project,
|
||||
.AddParameter("object", _("Object"), "")
|
||||
.SetFunctionName("getFromBaseExpression");
|
||||
|
||||
// Declare default behaviors that are used by event-based objects to avoid
|
||||
// warnings.
|
||||
{
|
||||
std::shared_ptr<gd::PlatformExtension> extension =
|
||||
std::shared_ptr<gd::PlatformExtension>(new gd::PlatformExtension);
|
||||
extension
|
||||
->SetExtensionInformation("ResizableCapability",
|
||||
_("Resizable capability"),
|
||||
_("Change the object dimensions."),
|
||||
"", "");
|
||||
gd::BehaviorMetadata& aut = extension->AddBehavior(
|
||||
"ResizableBehavior",
|
||||
_("Resizable capability"),
|
||||
"Resizable",
|
||||
_("Change the object dimensions."),
|
||||
"", "", "",
|
||||
std::make_shared<gd::Behavior>(),
|
||||
std::make_shared<gd::BehaviorsSharedData>())
|
||||
.SetHidden();
|
||||
platform.AddExtension(extension);
|
||||
}
|
||||
{
|
||||
std::shared_ptr<gd::PlatformExtension> extension =
|
||||
std::shared_ptr<gd::PlatformExtension>(new gd::PlatformExtension);
|
||||
extension
|
||||
->SetExtensionInformation("ScalableCapability",
|
||||
_("Scalable capability"),
|
||||
_("Change the object scale."),
|
||||
"", "");
|
||||
gd::BehaviorMetadata& aut = extension->AddBehavior(
|
||||
"ScalableBehavior",
|
||||
_("Scalable capability"),
|
||||
"Scale",
|
||||
_("Change the object scale."),
|
||||
"", "", "",
|
||||
std::make_shared<gd::Behavior>(),
|
||||
std::make_shared<gd::BehaviorsSharedData>())
|
||||
.SetHidden();
|
||||
platform.AddExtension(extension);
|
||||
}
|
||||
{
|
||||
std::shared_ptr<gd::PlatformExtension> extension =
|
||||
std::shared_ptr<gd::PlatformExtension>(new gd::PlatformExtension);
|
||||
extension
|
||||
->SetExtensionInformation("FlippableCapability",
|
||||
_("Flippable capability"),
|
||||
_("Flip objects."),
|
||||
"", "");
|
||||
gd::BehaviorMetadata& aut = extension->AddBehavior(
|
||||
"FlippableBehavior",
|
||||
_("Flippable capability"),
|
||||
"Flippable",
|
||||
_("Flip objects."),
|
||||
"", "", "",
|
||||
std::make_shared<gd::Behavior>(),
|
||||
std::make_shared<gd::BehaviorsSharedData>())
|
||||
.SetHidden();
|
||||
platform.AddExtension(extension);
|
||||
}
|
||||
{
|
||||
std::shared_ptr<gd::PlatformExtension> extension =
|
||||
std::shared_ptr<gd::PlatformExtension>(new gd::PlatformExtension);
|
||||
extension
|
||||
->SetExtensionInformation("EffectCapability",
|
||||
_("Effect capability"),
|
||||
_("Apply visual effects to objects."),
|
||||
"", "");
|
||||
gd::BehaviorMetadata& aut = extension->AddBehavior(
|
||||
"EffectBehavior",
|
||||
_("Effect capability"),
|
||||
"Effect",
|
||||
_("Apply visual effects to objects."),
|
||||
"", "", "",
|
||||
std::make_shared<gd::Behavior>(),
|
||||
std::make_shared<gd::BehaviorsSharedData>())
|
||||
.SetHidden();
|
||||
platform.AddExtension(extension);
|
||||
}
|
||||
// Create an extension with various stuff inside.
|
||||
std::shared_ptr<gd::PlatformExtension> extension =
|
||||
std::shared_ptr<gd::PlatformExtension>(new gd::PlatformExtension);
|
||||
@@ -396,14 +463,53 @@ void SetupProjectWithDummyPlatform(gd::Project& project,
|
||||
gd::make_unique<gd::BehaviorsSharedData>());
|
||||
}
|
||||
|
||||
{
|
||||
gd::BehaviorMetadata &effectBehavior =
|
||||
extension
|
||||
->AddBehavior("EffectBehavior",
|
||||
_("Effect capability"),
|
||||
"Effect",
|
||||
_("Apply visual effects to objects."),
|
||||
"",
|
||||
"res/actions/effect24.png", "EffectBehavior",
|
||||
std::make_shared<gd::Behavior>(),
|
||||
std::make_shared<gd::BehaviorsSharedData>())
|
||||
.SetHidden();
|
||||
|
||||
// Add this expression for the effect capability.
|
||||
effectBehavior
|
||||
.AddStrExpression("GetSomethingRequiringEffectCapability",
|
||||
"Get something, but this requires the effect "
|
||||
"capability for the object.",
|
||||
"",
|
||||
"",
|
||||
"")
|
||||
.AddParameter("object", _("Object"), "")
|
||||
.AddParameter("behavior", _("Behavior"), "EffectBehavior")
|
||||
.AddParameter("expression", _("Number parameter"))
|
||||
.SetFunctionName("getSomethingRequiringEffectCapability");
|
||||
}
|
||||
{
|
||||
auto& object = extension
|
||||
->AddObject<gd::ObjectConfiguration>(
|
||||
"FakeObjectWithUnsupportedCapability",
|
||||
"FakeObjectWithUnsupportedCapability",
|
||||
"This is FakeObjectWithUnsupportedCapability",
|
||||
"FakeObjectWithDefaultBehavior",
|
||||
"FakeObjectWithDefaultBehavior",
|
||||
"This is FakeObjectWithDefaultBehavior",
|
||||
"")
|
||||
.AddUnsupportedBaseObjectCapability("effect");
|
||||
.AddDefaultBehavior("MyExtension::EffectBehavior");
|
||||
}
|
||||
|
||||
// Declare an event-based behavior to avoid warnings.
|
||||
{
|
||||
extension->AddBehavior("MyEventsBasedBehavior",
|
||||
"My event-based behavior",
|
||||
"MyEventsBasedBehavior",
|
||||
"Avoid warnings",
|
||||
"Group",
|
||||
"Icon.png",
|
||||
"MyEventsBasedBehavior",
|
||||
gd::make_unique<gd::Behavior>(),
|
||||
gd::make_unique<gd::BehaviorsSharedData>());
|
||||
}
|
||||
|
||||
// Actions and expressions with several parameter types.
|
||||
@@ -465,6 +571,17 @@ void SetupProjectWithDummyPlatform(gd::Project& project,
|
||||
.AddParameter("layerEffectParameterName", _("Parameter name"));
|
||||
}
|
||||
|
||||
{
|
||||
auto& effect = extension
|
||||
->AddEffect("EffectWithResource")
|
||||
.SetFullName("Effect with resource")
|
||||
.MarkAsOnlyWorkingFor2D();
|
||||
auto& effectProperties = effect.GetProperties();
|
||||
effectProperties["texture"]
|
||||
.SetType("resource")
|
||||
.AddExtraInfo("image");
|
||||
}
|
||||
|
||||
platform.AddExtension(commonInstructionsExtension);
|
||||
platform.AddExtension(baseObjectExtension);
|
||||
platform.AddExtension(extension);
|
||||
|
@@ -24,13 +24,13 @@ TEST_CASE("ExpressionCodeGenerator", "[common][events]") {
|
||||
layout1.InsertNewObject(
|
||||
project, "MyExtension::Sprite", "MyOtherSpriteObject", 1);
|
||||
layout1.InsertNewObject(project,
|
||||
"MyExtension::FakeObjectWithUnsupportedCapability",
|
||||
"MyFakeObjectWithUnsupportedCapability",
|
||||
"MyExtension::FakeObjectWithDefaultBehavior",
|
||||
"FakeObjectWithDefaultBehavior",
|
||||
2);
|
||||
auto &group = layout1.GetObjectGroups().InsertNew("AllObjects");
|
||||
group.AddObject("MySpriteObject");
|
||||
group.AddObject("MyOtherSpriteObject");
|
||||
group.AddObject("MyFakeObjectWithUnsupportedCapability");
|
||||
group.AddObject("FakeObjectWithDefaultBehavior");
|
||||
|
||||
gd::ExpressionParser2 parser;
|
||||
|
||||
@@ -342,7 +342,7 @@ TEST_CASE("ExpressionCodeGenerator", "[common][events]") {
|
||||
SECTION("supported capability") {
|
||||
// Capability is supported, so the expression is valid.
|
||||
auto node = parser.ParseExpression(
|
||||
"MySpriteObject.GetSomethingRequiringEffectCapability(123)");
|
||||
"FakeObjectWithDefaultBehavior.Effect::GetSomethingRequiringEffectCapability(123)");
|
||||
gd::ExpressionCodeGenerator expressionCodeGenerator("string",
|
||||
"",
|
||||
codeGenerator,
|
||||
@@ -352,12 +352,12 @@ TEST_CASE("ExpressionCodeGenerator", "[common][events]") {
|
||||
node->Visit(expressionCodeGenerator);
|
||||
REQUIRE(
|
||||
expressionCodeGenerator.GetOutput() ==
|
||||
"MySpriteObject.getSomethingRequiringEffectCapability(123) ?? \"\"");
|
||||
"FakeObjectWithDefaultBehavior::Effect.getSomethingRequiringEffectCapability(123) ?? \"\"");
|
||||
}
|
||||
SECTION("unsupported capability") {
|
||||
// Capability is not supported, so the expression is not even valid.
|
||||
auto node =
|
||||
parser.ParseExpression("MyFakeObjectWithUnsupportedCapability."
|
||||
parser.ParseExpression("MySpriteObject::Effect."
|
||||
"GetSomethingRequiringEffectCapability(123)");
|
||||
gd::ExpressionCodeGenerator expressionCodeGenerator("string",
|
||||
"",
|
||||
@@ -366,14 +366,16 @@ TEST_CASE("ExpressionCodeGenerator", "[common][events]") {
|
||||
|
||||
REQUIRE(node);
|
||||
node->Visit(expressionCodeGenerator);
|
||||
REQUIRE(expressionCodeGenerator.GetOutput() == "\"\"");
|
||||
REQUIRE(
|
||||
expressionCodeGenerator.GetOutput() ==
|
||||
"/* Error during generation, function not found: GetSomethingRequiringEffectCapability */ \"\"");
|
||||
}
|
||||
SECTION("group with partial support") {
|
||||
// We use a group, capability is supported only by one object of the
|
||||
// group. The expression itself is valid, but code generation should skip
|
||||
// the objects with unsupported capability.
|
||||
auto node = parser.ParseExpression(
|
||||
"AllObjects.GetSomethingRequiringEffectCapability(123)");
|
||||
"AllObjects.Effect::GetSomethingRequiringEffectCapability(123)");
|
||||
gd::ExpressionCodeGenerator expressionCodeGenerator("string",
|
||||
"",
|
||||
codeGenerator,
|
||||
@@ -381,10 +383,13 @@ TEST_CASE("ExpressionCodeGenerator", "[common][events]") {
|
||||
|
||||
REQUIRE(node);
|
||||
node->Visit(expressionCodeGenerator);
|
||||
REQUIRE(
|
||||
expressionCodeGenerator.GetOutput() ==
|
||||
"MyOtherSpriteObject.getSomethingRequiringEffectCapability(123) ?? "
|
||||
"MySpriteObject.getSomethingRequiringEffectCapability(123) ?? \"\"");
|
||||
REQUIRE(expressionCodeGenerator.GetOutput() ==
|
||||
"FakeObjectWithDefaultBehavior::Effect."
|
||||
"getSomethingRequiringEffectCapability(123) ?? "
|
||||
"MyOtherSpriteObject::Effect."
|
||||
"getSomethingRequiringEffectCapability(123) ?? "
|
||||
"MySpriteObject::Effect.getSomethingRequiringEffectCapability("
|
||||
"123) ?? \"\"");
|
||||
}
|
||||
}
|
||||
SECTION("Function name") {
|
||||
|
@@ -21,16 +21,18 @@ TEST_CASE("ExpressionParser2", "[common][events]") {
|
||||
SetupProjectWithDummyPlatform(project, platform);
|
||||
auto &layout1 = project.InsertNewLayout("Layout1", 0);
|
||||
|
||||
auto &myObject = layout1.InsertNewObject(project, "BuiltinObject", "MyObject", 0);
|
||||
// Create an instance of BuiltinObject.
|
||||
// This is not possible in practice.
|
||||
auto &myObject = layout1.InsertNewObject(project, "", "MyObject", 0);
|
||||
myObject.AddNewBehavior(project, "MyExtension::MyBehavior", "MyBehavior");
|
||||
|
||||
auto &myGroup = layout1.GetObjectGroups().InsertNew("MyGroup", 0);
|
||||
myGroup.AddObject(myObject.GetName());
|
||||
|
||||
|
||||
layout1.InsertNewObject(project, "MyExtension::Sprite", "MySpriteObject", 1);
|
||||
layout1.InsertNewObject(project,
|
||||
"MyExtension::FakeObjectWithUnsupportedCapability",
|
||||
"MyFakeObjectWithUnsupportedCapability",
|
||||
"MyExtension::FakeObjectWithDefaultBehavior",
|
||||
"FakeObjectWithDefaultBehavior",
|
||||
2);
|
||||
|
||||
gd::ExpressionParser2 parser;
|
||||
@@ -340,6 +342,20 @@ TEST_CASE("ExpressionParser2", "[common][events]") {
|
||||
"Cannot find an expression with this name: Idontexist\n"
|
||||
"Double check that you've not made any typo in the name.");
|
||||
}
|
||||
{
|
||||
auto node = parser.ParseExpression("🅸🅳🅾🅽🆃🅴🆇🅸🆂🆃😄(\"hello\"");
|
||||
REQUIRE(node != nullptr);
|
||||
|
||||
gd::ExpressionValidator validator(platform, project, layout1, "string");
|
||||
node->Visit(validator);
|
||||
REQUIRE(validator.GetFatalErrors().size() == 2);
|
||||
REQUIRE(validator.GetFatalErrors()[0]->GetMessage() ==
|
||||
"The list of parameters is not terminated. Add a closing "
|
||||
"parenthesis to end the parameters.");
|
||||
REQUIRE(validator.GetFatalErrors()[1]->GetMessage() ==
|
||||
"Cannot find an expression with this name: 🅸🅳🅾🅽🆃🅴🆇🅸🆂🆃😄\n"
|
||||
"Double check that you've not made any typo in the name.");
|
||||
}
|
||||
{
|
||||
auto node = parser.ParseExpression("=\"test\"");
|
||||
REQUIRE(node != nullptr);
|
||||
@@ -694,6 +710,17 @@ TEST_CASE("ExpressionParser2", "[common][events]") {
|
||||
"You must enter a number.");
|
||||
REQUIRE(validator.GetFatalErrors()[0]->GetStartPosition() == 0);
|
||||
}
|
||||
{
|
||||
auto node = parser.ParseExpression("ab😊d");
|
||||
REQUIRE(node != nullptr);
|
||||
|
||||
gd::ExpressionValidator validator(platform, project, layout1, "number");
|
||||
node->Visit(validator);
|
||||
REQUIRE(validator.GetFatalErrors().size() == 1);
|
||||
REQUIRE(validator.GetFatalErrors()[0]->GetMessage() ==
|
||||
"You must enter a number.");
|
||||
REQUIRE(validator.GetFatalErrors()[0]->GetStartPosition() == 0);
|
||||
}
|
||||
{
|
||||
auto node = parser.ParseExpression("abcd[0]");
|
||||
REQUIRE(node != nullptr);
|
||||
@@ -917,6 +944,26 @@ TEST_CASE("ExpressionParser2", "[common][events]") {
|
||||
node->Visit(validator);
|
||||
REQUIRE(validator.GetFatalErrors().size() == 0);
|
||||
}
|
||||
{
|
||||
auto node = parser.ParseExpression("😅");
|
||||
REQUIRE(node != nullptr);
|
||||
auto &identifierNode = dynamic_cast<gd::IdentifierNode &>(*node);
|
||||
REQUIRE(identifierNode.identifierName == "😅");
|
||||
|
||||
gd::ExpressionValidator validator(platform, project, layout1, "object");
|
||||
node->Visit(validator);
|
||||
REQUIRE(validator.GetFatalErrors().size() == 0);
|
||||
}
|
||||
{
|
||||
auto node = parser.ParseExpression("中文");
|
||||
REQUIRE(node != nullptr);
|
||||
auto &identifierNode = dynamic_cast<gd::IdentifierNode &>(*node);
|
||||
REQUIRE(identifierNode.identifierName == "中文");
|
||||
|
||||
gd::ExpressionValidator validator(platform, project, layout1, "object");
|
||||
node->Visit(validator);
|
||||
REQUIRE(validator.GetFatalErrors().size() == 0);
|
||||
}
|
||||
|
||||
{
|
||||
auto node = parser.ParseExpression("Hello World 1");
|
||||
@@ -1092,6 +1139,46 @@ TEST_CASE("ExpressionParser2", "[common][events]") {
|
||||
REQUIRE(textNode.text == "2");
|
||||
REQUIRE(identifierNode.identifierName == "three");
|
||||
}
|
||||
SECTION("identifier parameter (unicode)") {
|
||||
auto node = parser.ParseExpression(
|
||||
"WhateverObject.WhateverBehavior::WhateverFunction(1, \"2\", 😄)");
|
||||
REQUIRE(node != nullptr);
|
||||
auto &functionNode = dynamic_cast<gd::FunctionCallNode &>(*node);
|
||||
REQUIRE(functionNode.functionName == "WhateverFunction");
|
||||
REQUIRE(functionNode.objectName == "WhateverObject");
|
||||
REQUIRE(functionNode.behaviorName == "WhateverBehavior");
|
||||
REQUIRE(functionNode.parameters.size() == 3);
|
||||
auto &numberNode =
|
||||
dynamic_cast<gd::NumberNode &>(*functionNode.parameters[0]);
|
||||
auto &textNode =
|
||||
dynamic_cast<gd::TextNode &>(*functionNode.parameters[1]);
|
||||
auto &identifierNode =
|
||||
dynamic_cast<gd::IdentifierNode &>(*functionNode.parameters[2]);
|
||||
|
||||
REQUIRE(numberNode.number == "1");
|
||||
REQUIRE(textNode.text == "2");
|
||||
REQUIRE(identifierNode.identifierName == "😄");
|
||||
}
|
||||
SECTION("unicode for object, behavior and function") {
|
||||
auto node = parser.ParseExpression(
|
||||
"🧸.🗣️::🔔(1, \"2\", 😄)");
|
||||
REQUIRE(node != nullptr);
|
||||
auto &functionNode = dynamic_cast<gd::FunctionCallNode &>(*node);
|
||||
REQUIRE(functionNode.functionName == "🔔");
|
||||
REQUIRE(functionNode.objectName == "🧸");
|
||||
REQUIRE(functionNode.behaviorName == "🗣️");
|
||||
REQUIRE(functionNode.parameters.size() == 3);
|
||||
auto &numberNode =
|
||||
dynamic_cast<gd::NumberNode &>(*functionNode.parameters[0]);
|
||||
auto &textNode =
|
||||
dynamic_cast<gd::TextNode &>(*functionNode.parameters[1]);
|
||||
auto &identifierNode =
|
||||
dynamic_cast<gd::IdentifierNode &>(*functionNode.parameters[2]);
|
||||
|
||||
REQUIRE(numberNode.number == "1");
|
||||
REQUIRE(textNode.text == "2");
|
||||
REQUIRE(identifierNode.identifierName == "😄");
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("Valid function calls ('number|string' type)") {
|
||||
@@ -1669,7 +1756,7 @@ TEST_CASE("ExpressionParser2", "[common][events]") {
|
||||
auto &identifierNode = dynamic_cast<gd::IdentifierNode &>(*node);
|
||||
REQUIRE(identifierNode.identifierName == "myVariable");
|
||||
REQUIRE(identifierNode.childIdentifierName == "myChild");
|
||||
|
||||
|
||||
gd::ExpressionValidator validator(platform, project, layout1, "scenevar");
|
||||
node->Visit(validator);
|
||||
REQUIRE(validator.GetFatalErrors().size() == 0);
|
||||
@@ -1766,14 +1853,14 @@ TEST_CASE("ExpressionParser2", "[common][events]") {
|
||||
REQUIRE(identifierObject2Node.identifierName == "MyObject2");
|
||||
REQUIRE(variable1Node.identifierName == "MyVar1");
|
||||
REQUIRE(variable2Node.identifierName == "MyVar2");
|
||||
|
||||
|
||||
auto variable1ObjectName = gd::ExpressionVariableOwnerFinder::GetObjectName(
|
||||
platform, project, layout1, "", variable1Node);
|
||||
REQUIRE(variable1ObjectName == "MyObject1");
|
||||
auto variable2ObjectName = gd::ExpressionVariableOwnerFinder::GetObjectName(
|
||||
platform, project, layout1, "", variable2Node);
|
||||
REQUIRE(variable2ObjectName == "MyObject2");
|
||||
|
||||
|
||||
gd::ExpressionValidator validator(platform, project, layout1, "string");
|
||||
node->Visit(validator);
|
||||
REQUIRE(validator.GetFatalErrors().size() == 0);
|
||||
@@ -1797,14 +1884,14 @@ TEST_CASE("ExpressionParser2", "[common][events]") {
|
||||
REQUIRE(identifierObject1Node.identifierName == "MyObject1");
|
||||
REQUIRE(variable1Node.identifierName == "MyVar1");
|
||||
REQUIRE(variable2Node.identifierName == "MyVar2");
|
||||
|
||||
|
||||
auto variable1ObjectName = gd::ExpressionVariableOwnerFinder::GetObjectName(
|
||||
platform, project, layout1, "", variable1Node);
|
||||
REQUIRE(variable1ObjectName == "MyObject1");
|
||||
auto variable2ObjectName = gd::ExpressionVariableOwnerFinder::GetObjectName(
|
||||
platform, project, layout1, "", variable2Node);
|
||||
REQUIRE(variable2ObjectName == "MyObject1");
|
||||
|
||||
|
||||
gd::ExpressionValidator validator(platform, project, layout1, "string");
|
||||
node->Visit(validator);
|
||||
REQUIRE(validator.GetFatalErrors().size() == 0);
|
||||
@@ -1821,11 +1908,11 @@ TEST_CASE("ExpressionParser2", "[common][events]") {
|
||||
dynamic_cast<gd::IdentifierNode &>(*functionNode.parameters[0]);
|
||||
|
||||
REQUIRE(variable1Node.identifierName == "MyVar1");
|
||||
|
||||
|
||||
auto variable1ObjectName = gd::ExpressionVariableOwnerFinder::GetObjectName(
|
||||
platform, project, layout1, "MySpriteObject", variable1Node);
|
||||
REQUIRE(variable1ObjectName == "MySpriteObject");
|
||||
|
||||
|
||||
gd::ExpressionValidator validator(platform, project, layout1, "number");
|
||||
node->Visit(validator);
|
||||
REQUIRE(validator.GetFatalErrors().size() == 0);
|
||||
@@ -1843,11 +1930,11 @@ TEST_CASE("ExpressionParser2", "[common][events]") {
|
||||
|
||||
REQUIRE(variable1Node.identifierName == "MyVar1");
|
||||
REQUIRE(variable1Node.childIdentifierName == "MyChild");
|
||||
|
||||
|
||||
auto variable1ObjectName = gd::ExpressionVariableOwnerFinder::GetObjectName(
|
||||
platform, project, layout1, "MySpriteObject", variable1Node);
|
||||
REQUIRE(variable1ObjectName == "MySpriteObject");
|
||||
|
||||
|
||||
gd::ExpressionValidator validator(platform, project, layout1, "number");
|
||||
node->Visit(validator);
|
||||
REQUIRE(validator.GetFatalErrors().size() == 0);
|
||||
@@ -1899,29 +1986,29 @@ TEST_CASE("ExpressionParser2", "[common][events]") {
|
||||
}
|
||||
|
||||
SECTION(
|
||||
"Valid function call with an object expression requiring a capability") {
|
||||
"Valid function call with a default behavior") {
|
||||
auto node = parser.ParseExpression(
|
||||
"MySpriteObject.GetSomethingRequiringEffectCapability(123)");
|
||||
"FakeObjectWithDefaultBehavior.Effect::GetSomethingRequiringEffectCapability(123)");
|
||||
REQUIRE(node != nullptr);
|
||||
|
||||
gd::ExpressionValidator validator(platform, project, layout1, "string");
|
||||
node->Visit(validator);
|
||||
REQUIRE(validator.GetFatalErrors().size() == 0);
|
||||
REQUIRE(validator.GetAllErrors().size() == 0);
|
||||
}
|
||||
|
||||
SECTION(
|
||||
"Invalid function call with an object expression requiring a "
|
||||
"capability") {
|
||||
"Invalid function call with an object that doesn't have a default behavior") {
|
||||
auto node =
|
||||
parser.ParseExpression("MyFakeObjectWithUnsupportedCapability."
|
||||
parser.ParseExpression("MySpriteObject.Effect::"
|
||||
"GetSomethingRequiringEffectCapability(123)");
|
||||
REQUIRE(node != nullptr);
|
||||
|
||||
gd::ExpressionValidator validator(platform, project, layout1, "string");
|
||||
node->Visit(validator);
|
||||
REQUIRE(validator.GetFatalErrors().size() == 1);
|
||||
REQUIRE(validator.GetFatalErrors()[0]->GetMessage() ==
|
||||
"This expression exists, but it can't be used on this object.");
|
||||
REQUIRE(validator.GetFatalErrors().size() == 0);
|
||||
REQUIRE(validator.GetAllErrors().size() == 1);
|
||||
REQUIRE(validator.GetAllErrors()[0]->GetMessage() ==
|
||||
"This behavior is not attached to this object.");
|
||||
}
|
||||
|
||||
SECTION("Fuzzy/random tests") {
|
||||
|
133
Core/tests/Layout.cpp
Normal file
133
Core/tests/Layout.cpp
Normal file
@@ -0,0 +1,133 @@
|
||||
/*
|
||||
* GDevelop Core
|
||||
* Copyright 2008-2023 Florian Rival (Florian.Rival@gmail.com). All rights
|
||||
* reserved. This project is released under the MIT License.
|
||||
*/
|
||||
/**
|
||||
* @file Tests covering layout content helper methods.
|
||||
*/
|
||||
#include "GDCore/Project/Layout.h"
|
||||
#include "DummyPlatform.h"
|
||||
#include "GDCore/CommonTools.h"
|
||||
#include "GDCore/Extensions/Platform.h"
|
||||
#include "GDCore/Project/Object.h"
|
||||
#include "GDCore/Project/ObjectsContainer.h"
|
||||
#include "GDCore/Project/Project.h"
|
||||
#include "catch.hpp"
|
||||
|
||||
using namespace gd;
|
||||
|
||||
namespace {
|
||||
|
||||
void SetupProject(gd::Project &project, gd::Platform &platform){
|
||||
|
||||
};
|
||||
} // namespace
|
||||
|
||||
TEST_CASE("Layout", "[common]") {
|
||||
|
||||
SECTION("Find the type of a behavior in a object") {
|
||||
gd::Platform platform;
|
||||
gd::Project project;
|
||||
SetupProjectWithDummyPlatform(project, platform);
|
||||
|
||||
gd::Layout &layout = project.InsertNewLayout("Scene", 0);
|
||||
gd::Object &object =
|
||||
layout.InsertNewObject(project, "MyExtension::Sprite", "MyObject", 0);
|
||||
object.AddNewBehavior(project, "MyExtension::MyBehavior", "MyBehavior");
|
||||
|
||||
REQUIRE(GetTypeOfBehaviorInObjectOrGroup(project, layout, "MyObject",
|
||||
"MyBehavior", true) ==
|
||||
"MyExtension::MyBehavior");
|
||||
}
|
||||
|
||||
SECTION("Give an empty type for an object that doesn't have the behavior") {
|
||||
gd::Platform platform;
|
||||
gd::Project project;
|
||||
SetupProjectWithDummyPlatform(project, platform);
|
||||
|
||||
gd::Layout &layout = project.InsertNewLayout("Scene", 0);
|
||||
gd::Object &object =
|
||||
layout.InsertNewObject(project, "MyExtension::Sprite", "MyObject", 0);
|
||||
|
||||
REQUIRE(GetTypeOfBehaviorInObjectOrGroup(project, layout, "MyObject",
|
||||
"MyBehavior", true) == "");
|
||||
}
|
||||
|
||||
SECTION("Find the type of a behavior in a group") {
|
||||
gd::Platform platform;
|
||||
gd::Project project;
|
||||
SetupProjectWithDummyPlatform(project, platform);
|
||||
|
||||
gd::Layout &layout = project.InsertNewLayout("Scene", 0);
|
||||
gd::Object &object1 =
|
||||
layout.InsertNewObject(project, "MyExtension::Sprite", "MyObject1", 0);
|
||||
object1.AddNewBehavior(project, "MyExtension::MyBehavior", "MyBehavior");
|
||||
gd::Object &object2 =
|
||||
layout.InsertNewObject(project, "MyExtension::Sprite", "MyObject2", 0);
|
||||
object2.AddNewBehavior(project, "MyExtension::MyBehavior", "MyBehavior");
|
||||
|
||||
auto &group = layout.GetObjectGroups().InsertNew("MyGroup", 0);
|
||||
group.AddObject(object1.GetName());
|
||||
group.AddObject(object2.GetName());
|
||||
|
||||
REQUIRE(GetTypeOfBehaviorInObjectOrGroup(project, layout, "MyGroup",
|
||||
"MyBehavior", true) ==
|
||||
"MyExtension::MyBehavior");
|
||||
}
|
||||
|
||||
SECTION("Give an empty type for a group with an object missing the behavior") {
|
||||
gd::Platform platform;
|
||||
gd::Project project;
|
||||
SetupProjectWithDummyPlatform(project, platform);
|
||||
|
||||
gd::Layout &layout = project.InsertNewLayout("Scene", 0);
|
||||
gd::Object &object1 =
|
||||
layout.InsertNewObject(project, "MyExtension::Sprite", "MyObject1", 0);
|
||||
object1.AddNewBehavior(project, "MyExtension::MyBehavior", "MyBehavior");
|
||||
gd::Object &object2 =
|
||||
layout.InsertNewObject(project, "MyExtension::Sprite", "MyObject2", 0);
|
||||
// object2 doesn't have the behavior.
|
||||
|
||||
auto &group = layout.GetObjectGroups().InsertNew("MyGroup", 0);
|
||||
group.AddObject(object1.GetName());
|
||||
group.AddObject(object2.GetName());
|
||||
|
||||
REQUIRE(GetTypeOfBehaviorInObjectOrGroup(project, layout, "MyGroup",
|
||||
"MyBehavior", true) == "");
|
||||
}
|
||||
|
||||
SECTION("Give an empty type for a group with behaviors of same name but different types") {
|
||||
gd::Platform platform;
|
||||
gd::Project project;
|
||||
SetupProjectWithDummyPlatform(project, platform);
|
||||
|
||||
gd::Layout &layout = project.InsertNewLayout("Scene", 0);
|
||||
gd::Object &object1 =
|
||||
layout.InsertNewObject(project, "MyExtension::Sprite", "MyObject1", 0);
|
||||
object1.AddNewBehavior(project, "MyExtension::MyBehavior", "MyBehavior");
|
||||
gd::Object &object2 =
|
||||
layout.InsertNewObject(project, "MyExtension::Sprite", "MyObject2", 0);
|
||||
object2.AddNewBehavior(project, "MyExtension::MyOtherBehavior",
|
||||
"MyBehavior");
|
||||
|
||||
auto &group = layout.GetObjectGroups().InsertNew("MyGroup", 0);
|
||||
group.AddObject(object1.GetName());
|
||||
group.AddObject(object2.GetName());
|
||||
|
||||
REQUIRE(GetTypeOfBehaviorInObjectOrGroup(project, layout, "MyGroup",
|
||||
"MyBehavior", true) == "");
|
||||
}
|
||||
|
||||
SECTION("Give an empty type for an empty group") {
|
||||
gd::Platform platform;
|
||||
gd::Project project;
|
||||
SetupProjectWithDummyPlatform(project, platform);
|
||||
|
||||
gd::Layout &layout = project.InsertNewLayout("Scene", 0);
|
||||
auto &group = layout.GetObjectGroups().InsertNew("MyGroup", 0);
|
||||
|
||||
REQUIRE(GetTypeOfBehaviorInObjectOrGroup(project, layout, "MyGroup",
|
||||
"MyBehavior", true) == "");
|
||||
}
|
||||
}
|
45
Core/tests/Object.cpp
Normal file
45
Core/tests/Object.cpp
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* GDevelop Core
|
||||
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
|
||||
* reserved. This project is released under the MIT License.
|
||||
*/
|
||||
/**
|
||||
* @file Tests covering serialization to JSON.
|
||||
*/
|
||||
#include "GDCore/Project/Object.h"
|
||||
#include "DummyPlatform.h"
|
||||
#include "GDCore/CommonTools.h"
|
||||
#include "GDCore/Events/Builtin/StandardEvent.h"
|
||||
#include "GDCore/Events/Event.h"
|
||||
#include "GDCore/Events/EventsList.h"
|
||||
#include "GDCore/Events/Serialization.h"
|
||||
#include "GDCore/Extensions/Builtin/SpriteExtension/SpriteObject.h"
|
||||
#include "GDCore/Extensions/Platform.h"
|
||||
#include "GDCore/Project/CustomObjectConfiguration.h"
|
||||
#include "GDCore/Project/EventsFunctionsExtension.h"
|
||||
#include "GDCore/Project/Layout.h"
|
||||
#include "GDCore/Project/ObjectsContainer.h"
|
||||
#include "GDCore/Project/Project.h"
|
||||
#include "GDCore/Project/Variable.h"
|
||||
#include "GDCore/Serialization/Serializer.h"
|
||||
#include "GDCore/Tools/SystemStats.h"
|
||||
#include "GDCore/Tools/VersionWrapper.h"
|
||||
#include "catch.hpp"
|
||||
|
||||
using namespace gd;
|
||||
|
||||
TEST_CASE("Object", "[common]") {
|
||||
|
||||
SECTION("Create an object with default behaviors") {
|
||||
gd::Platform platform;
|
||||
gd::Project project;
|
||||
SetupProjectWithDummyPlatform(project, platform);
|
||||
|
||||
gd::Layout &layout = project.InsertNewLayout("Scene", 0);
|
||||
gd::Object &object = layout.InsertNewObject(
|
||||
project, "MyExtension::FakeObjectWithDefaultBehavior", "MyObject", 0);
|
||||
|
||||
REQUIRE(object.HasBehaviorNamed("Effect"));
|
||||
REQUIRE(object.GetBehavior("Effect").IsDefaultBehavior());
|
||||
}
|
||||
}
|
@@ -225,4 +225,41 @@ TEST_CASE("ObjectSerialization", "[common]") {
|
||||
auto clonedObject = object.Clone();
|
||||
CheckCustomObjectConfiguration(*(clonedObject.get()));
|
||||
}
|
||||
|
||||
SECTION("Exclude default behaviors from serialization") {
|
||||
gd::Platform platform;
|
||||
gd::Project project;
|
||||
SetupProjectWithDummyPlatform(project, platform);
|
||||
|
||||
gd::Layout &layout = project.InsertNewLayout("Scene", 0);
|
||||
gd::Object &object = layout.InsertNewObject(
|
||||
project, "MyExtension::FakeObjectWithDefaultBehavior", "MyObject", 0);
|
||||
REQUIRE(object.HasBehaviorNamed("Effect"));
|
||||
|
||||
object.AddNewBehavior(project, "MyExtension::MyBehavior", "MyBehavior");
|
||||
REQUIRE(object.HasBehaviorNamed("MyBehavior"));
|
||||
|
||||
SerializerElement projectElement;
|
||||
project.SerializeTo(projectElement);
|
||||
|
||||
// Check serialized behaviors.
|
||||
auto &layoutsElement = projectElement.GetChild("layouts");
|
||||
layoutsElement.ConsiderAsArrayOf("layout");
|
||||
REQUIRE(layoutsElement.GetChildrenCount() == 1);
|
||||
auto &layoutElement = layoutsElement.GetChild(0);
|
||||
|
||||
REQUIRE(layoutElement.GetStringAttribute("name") == "Scene");
|
||||
REQUIRE(layoutElement.HasChild("objects"));
|
||||
|
||||
auto &objectsElement = layoutElement.GetChild("objects");
|
||||
objectsElement.ConsiderAsArrayOf("object");
|
||||
REQUIRE(objectsElement.GetChildrenCount() == 1);
|
||||
auto &objectElement = objectsElement.GetChild(0);
|
||||
|
||||
auto &behaviorsElement = objectElement.GetChild("behaviors");
|
||||
behaviorsElement.ConsiderAsArrayOf("behavior");
|
||||
REQUIRE(behaviorsElement.GetChildrenCount() == 1);
|
||||
auto &behaviorElement = behaviorsElement.GetChild(0);
|
||||
REQUIRE(behaviorElement.GetStringAttribute("name") == "MyBehavior");
|
||||
}
|
||||
}
|
@@ -16,6 +16,7 @@
|
||||
#include "GDCore/Tools/SystemStats.h"
|
||||
#include "GDCore/Tools/VersionWrapper.h"
|
||||
#include "catch.hpp"
|
||||
#include "GDCore/IDE/ResourceExposer.h"
|
||||
|
||||
class MockFileSystem : public gd::AbstractFileSystem {
|
||||
public:
|
||||
@@ -75,7 +76,7 @@ TEST_CASE("ResourcesMergingHelper", "[common]") {
|
||||
project.GetResourcesManager().AddResource(
|
||||
"Image3", "subfolder/image3.png", "image");
|
||||
|
||||
project.ExposeResources(resourcesMerger);
|
||||
gd::ResourceExposer::ExposeWholeProjectResources(project, resourcesMerger);
|
||||
|
||||
auto resourcesFilenames =
|
||||
resourcesMerger.GetAllResourcesOldAndNewFilename();
|
||||
@@ -101,7 +102,7 @@ TEST_CASE("ResourcesMergingHelper", "[common]") {
|
||||
project.GetResourcesManager().AddResource(
|
||||
"Image3", "subfolder/image3.png", "image");
|
||||
|
||||
project.ExposeResources(resourcesMerger);
|
||||
gd::ResourceExposer::ExposeWholeProjectResources(project, resourcesMerger);
|
||||
|
||||
auto resourcesFilenames =
|
||||
resourcesMerger.GetAllResourcesOldAndNewFilename();
|
||||
|
@@ -11,6 +11,7 @@
|
||||
#include "GDCore/CommonTools.h"
|
||||
#include "GDCore/Project/Project.h"
|
||||
#include "catch.hpp"
|
||||
#include "GDCore/IDE/ResourceExposer.h"
|
||||
|
||||
TEST_CASE("ResourcesRenamer", "[common]") {
|
||||
SECTION("It renames resources that are exposed") {
|
||||
@@ -34,7 +35,7 @@ TEST_CASE("ResourcesRenamer", "[common]") {
|
||||
project.GetPlatformSpecificAssets().Set(
|
||||
"android", "some-other-icon", "Resource2");
|
||||
|
||||
project.ExposeResources(resourcesRenamer);
|
||||
gd::ResourceExposer::ExposeWholeProjectResources(project, resourcesRenamer);
|
||||
|
||||
// Check that resources were renamed were used.
|
||||
REQUIRE(project.GetPlatformSpecificAssets().Get("android", "some-icon") ==
|
||||
@@ -72,7 +73,7 @@ TEST_CASE("ResourcesRenamer", "[common]") {
|
||||
project.GetPlatformSpecificAssets().Set(
|
||||
"android", "some-other-icon", "Resource2");
|
||||
|
||||
project.ExposeResources(resourcesRenamer);
|
||||
gd::ResourceExposer::ExposeWholeProjectResources(project, resourcesRenamer);
|
||||
|
||||
// TODO: This should not be necessary, but for now not all resources support embeddeds,
|
||||
// so we must call it manually:
|
||||
|
@@ -3687,7 +3687,6 @@ TEST_CASE("RenameLayerEffect", "[common]") {
|
||||
auto &wrongLayerExpression =
|
||||
CreateExpressionWithLayerEffectParameter(project, layout.GetEvents(), "My layer 2");
|
||||
|
||||
std::cout << "RenameLayerEffect" << std::endl;
|
||||
gd::WholeProjectRefactorer::RenameLayerEffect(project, layout, layer, "My effect",
|
||||
"My renamed effect");
|
||||
|
||||
@@ -3721,3 +3720,129 @@ TEST_CASE("RenameLayerEffect", "[common]") {
|
||||
"MyExtension::LayerEffectParameter(\"My layer 2\", \"My effect\")");
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("RemoveLayer", "[common]") {
|
||||
SECTION("Can remove instances in a layout and its associated external layouts") {
|
||||
gd::Project project;
|
||||
gd::Platform platform;
|
||||
SetupProjectWithDummyPlatform(project, platform);
|
||||
|
||||
auto &layout = project.InsertNewLayout("My layout", 0);
|
||||
auto &otherLayout = project.InsertNewLayout("My other layout", 1);
|
||||
|
||||
layout.InsertNewLayer("My layer", 0);
|
||||
otherLayout.InsertNewLayer("My layer", 0);
|
||||
|
||||
auto &externalLayout =
|
||||
project.InsertNewExternalLayout("My external layout", 0);
|
||||
auto &otherExternalLayout =
|
||||
project.InsertNewExternalLayout("My other external layout", 0);
|
||||
externalLayout.SetAssociatedLayout("My layout");
|
||||
otherExternalLayout.SetAssociatedLayout("My other layout");
|
||||
|
||||
auto &initialInstances = layout.GetInitialInstances();
|
||||
initialInstances.InsertNewInitialInstance().SetLayer("My layer");
|
||||
initialInstances.InsertNewInitialInstance().SetLayer("My layer");
|
||||
initialInstances.InsertNewInitialInstance().SetLayer("My layer");
|
||||
initialInstances.InsertNewInitialInstance().SetLayer("");
|
||||
initialInstances.InsertNewInitialInstance().SetLayer("");
|
||||
|
||||
auto &externalInitialInstances = externalLayout.GetInitialInstances();
|
||||
externalInitialInstances.InsertNewInitialInstance().SetLayer("My layer");
|
||||
externalInitialInstances.InsertNewInitialInstance().SetLayer("My layer");
|
||||
externalInitialInstances.InsertNewInitialInstance().SetLayer("");
|
||||
|
||||
auto &otherInitialInstances = otherLayout.GetInitialInstances();
|
||||
otherInitialInstances.InsertNewInitialInstance().SetLayer("My layer");
|
||||
|
||||
auto &otherExternalInitialInstances = otherExternalLayout.GetInitialInstances();
|
||||
otherExternalInitialInstances.InsertNewInitialInstance().SetLayer("My layer");
|
||||
|
||||
REQUIRE(initialInstances.GetInstancesCount() == 5);
|
||||
REQUIRE(externalInitialInstances.GetInstancesCount() == 3);
|
||||
REQUIRE(otherInitialInstances.GetInstancesCount() == 1);
|
||||
REQUIRE(otherExternalInitialInstances.GetInstancesCount() == 1);
|
||||
|
||||
REQUIRE(initialInstances.GetLayerInstancesCount("My layer") == 3);
|
||||
REQUIRE(externalInitialInstances.GetLayerInstancesCount("My layer") == 2);
|
||||
|
||||
gd::WholeProjectRefactorer::RemoveLayer(project, layout, "My layer");
|
||||
|
||||
REQUIRE(initialInstances.GetInstancesCount() == 2);
|
||||
REQUIRE(externalInitialInstances.GetInstancesCount() == 1);
|
||||
REQUIRE(otherInitialInstances.GetInstancesCount() == 1);
|
||||
REQUIRE(otherExternalInitialInstances.GetInstancesCount() == 1);
|
||||
|
||||
REQUIRE(initialInstances.GetLayerInstancesCount("My layer") == 0);
|
||||
REQUIRE(externalInitialInstances.GetLayerInstancesCount("My layer") == 0);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("MergeLayers", "[common]") {
|
||||
SECTION("Can merge instances from a layout into another layout (and their associated external layouts)") {
|
||||
gd::Project project;
|
||||
gd::Platform platform;
|
||||
SetupProjectWithDummyPlatform(project, platform);
|
||||
|
||||
auto &layout = project.InsertNewLayout("My layout", 0);
|
||||
auto &otherLayout = project.InsertNewLayout("My other layout", 1);
|
||||
|
||||
layout.InsertNewLayer("My layer", 0);
|
||||
otherLayout.InsertNewLayer("My layer", 0);
|
||||
|
||||
auto &externalLayout =
|
||||
project.InsertNewExternalLayout("My external layout", 0);
|
||||
auto &otherExternalLayout =
|
||||
project.InsertNewExternalLayout("My other external layout", 0);
|
||||
externalLayout.SetAssociatedLayout("My layout");
|
||||
otherExternalLayout.SetAssociatedLayout("My other layout");
|
||||
|
||||
auto &initialInstances = layout.GetInitialInstances();
|
||||
initialInstances.InsertNewInitialInstance().SetLayer("My layer");
|
||||
initialInstances.InsertNewInitialInstance().SetLayer("My layer");
|
||||
initialInstances.InsertNewInitialInstance().SetLayer("My layer");
|
||||
initialInstances.InsertNewInitialInstance().SetLayer("");
|
||||
initialInstances.InsertNewInitialInstance().SetLayer("");
|
||||
initialInstances.InsertNewInitialInstance().SetLayer("My other layer");
|
||||
|
||||
auto &externalInitialInstances = externalLayout.GetInitialInstances();
|
||||
externalInitialInstances.InsertNewInitialInstance().SetLayer("My layer");
|
||||
externalInitialInstances.InsertNewInitialInstance().SetLayer("My layer");
|
||||
externalInitialInstances.InsertNewInitialInstance().SetLayer("");
|
||||
externalInitialInstances.InsertNewInitialInstance().SetLayer("My other layer");
|
||||
|
||||
auto &otherInitialInstances = otherLayout.GetInitialInstances();
|
||||
otherInitialInstances.InsertNewInitialInstance().SetLayer("My layer");
|
||||
|
||||
auto &otherExternalInitialInstances = otherExternalLayout.GetInitialInstances();
|
||||
otherExternalInitialInstances.InsertNewInitialInstance().SetLayer("My layer");
|
||||
|
||||
REQUIRE(initialInstances.GetInstancesCount() == 6);
|
||||
REQUIRE(externalInitialInstances.GetInstancesCount() == 4);
|
||||
REQUIRE(otherInitialInstances.GetInstancesCount() == 1);
|
||||
REQUIRE(otherExternalInitialInstances.GetInstancesCount() == 1);
|
||||
|
||||
REQUIRE(initialInstances.GetLayerInstancesCount("My layer") == 3);
|
||||
REQUIRE(externalInitialInstances.GetLayerInstancesCount("My layer") == 2);
|
||||
|
||||
gd::WholeProjectRefactorer::MergeLayers(project, layout, "My layer", "");
|
||||
|
||||
// No instance was removed.
|
||||
REQUIRE(initialInstances.GetInstancesCount() == 6);
|
||||
REQUIRE(externalInitialInstances.GetInstancesCount() == 4);
|
||||
REQUIRE(otherInitialInstances.GetInstancesCount() == 1);
|
||||
REQUIRE(otherExternalInitialInstances.GetInstancesCount() == 1);
|
||||
|
||||
// No instance remain in "My layer".
|
||||
REQUIRE(initialInstances.GetLayerInstancesCount("My layer") == 0);
|
||||
REQUIRE(externalInitialInstances.GetLayerInstancesCount("My layer") == 0);
|
||||
|
||||
// Layers with the same name in other layouts are untouched.
|
||||
REQUIRE(otherInitialInstances.GetLayerInstancesCount("My layer") == 1);
|
||||
REQUIRE(otherExternalInitialInstances.GetLayerInstancesCount("My layer") == 1);
|
||||
|
||||
// Other layers from the same layout are untouched.
|
||||
REQUIRE(initialInstances.GetLayerInstancesCount("My other layer") == 1);
|
||||
REQUIRE(externalInitialInstances.GetLayerInstancesCount("My other layer") == 1);
|
||||
}
|
||||
}
|
||||
|
@@ -16,7 +16,13 @@ namespace gdjs {
|
||||
/**
|
||||
* Base class for 3D objects.
|
||||
*/
|
||||
export abstract class RuntimeObject3D extends gdjs.RuntimeObject {
|
||||
export abstract class RuntimeObject3D
|
||||
extends gdjs.RuntimeObject
|
||||
implements
|
||||
gdjs.Resizable,
|
||||
gdjs.Scalable,
|
||||
gdjs.Flippable,
|
||||
gdjs.Base3DHandler {
|
||||
/**
|
||||
* Position on the Z axis.
|
||||
*/
|
||||
@@ -257,6 +263,11 @@ namespace gdjs {
|
||||
this.invalidateHitboxes();
|
||||
}
|
||||
|
||||
setSize(newWidth: number, newHeight: number): void {
|
||||
this.setWidth(newWidth);
|
||||
this.setHeight(newHeight);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the object size on the Z axis (called "depth").
|
||||
*/
|
||||
|
@@ -6,6 +6,9 @@ namespace gdjs {
|
||||
target: EffectsTarget,
|
||||
effectData: EffectData
|
||||
): gdjs.PixiFiltersTools.Filter {
|
||||
if (typeof THREE === 'undefined') {
|
||||
return new gdjs.PixiFiltersTools.EmptyFilter();
|
||||
}
|
||||
return new (class implements gdjs.PixiFiltersTools.Filter {
|
||||
light: THREE.AmbientLight;
|
||||
_isEnabled: boolean;
|
||||
|
189
Extensions/3D/Base3DBehavior.ts
Normal file
189
Extensions/3D/Base3DBehavior.ts
Normal file
@@ -0,0 +1,189 @@
|
||||
/*
|
||||
* GDevelop JS Platform
|
||||
* Copyright 2013-2023 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
|
||||
* This project is released under the MIT License.
|
||||
*/
|
||||
namespace gdjs {
|
||||
export interface Base3DHandler {
|
||||
/**
|
||||
* Set the object position on the Z axis.
|
||||
*/
|
||||
setZ(z: float): void;
|
||||
|
||||
/**
|
||||
* Get the object position on the Z axis.
|
||||
*/
|
||||
getZ(): float;
|
||||
|
||||
/**
|
||||
* Set the object rotation on the X axis.
|
||||
*
|
||||
* This is an Euler angle. Objects use the `ZYX` order.
|
||||
*
|
||||
* @param angle the rotation angle on the X axis in degree
|
||||
*/
|
||||
setRotationX(angle: float): void;
|
||||
|
||||
/**
|
||||
* Set the object rotation on the Y axis.
|
||||
*
|
||||
* This is an Euler angle. Objects use the `ZYX` order.
|
||||
*
|
||||
* @param angle the rotation angle on the Y axis in degree
|
||||
*/
|
||||
setRotationY(angle: float): void;
|
||||
|
||||
/**
|
||||
* Get the object rotation on the X axis in degree.
|
||||
*
|
||||
* This is an Euler angle. Objects use the `ZYX` order.
|
||||
*/
|
||||
getRotationX(): float;
|
||||
|
||||
/**
|
||||
* Get the object rotation on the Y axis in degree.
|
||||
*
|
||||
* This is an Euler angle. Objects use the `ZYX` order.
|
||||
*/
|
||||
getRotationY(): float;
|
||||
|
||||
/**
|
||||
* Turn the object around the scene X axis at its center.
|
||||
* @param deltaAngle the rotation angle in degree
|
||||
*/
|
||||
turnAroundX(deltaAngle: float): void;
|
||||
|
||||
/**
|
||||
* Turn the object around the scene Y axis at its center.
|
||||
* @param deltaAngle the rotation angle in degree
|
||||
*/
|
||||
turnAroundY(deltaAngle: float): void;
|
||||
|
||||
/**
|
||||
* Turn the object around the scene Z axis at its center.
|
||||
* @param deltaAngle the rotation angle in degree
|
||||
*/
|
||||
turnAroundZ(deltaAngle: float): void;
|
||||
|
||||
/**
|
||||
* Get the object size on the Z axis (called "depth").
|
||||
*/
|
||||
getDepth(): float;
|
||||
|
||||
/**
|
||||
* Set the object size on the Z axis (called "depth").
|
||||
*/
|
||||
setDepth(depth: float): void;
|
||||
|
||||
/**
|
||||
* Change the scale on Z axis of the object (changing its depth).
|
||||
*
|
||||
* @param newScale The new scale (must be greater than 0).
|
||||
*/
|
||||
setScaleZ(newScale: number): void;
|
||||
|
||||
/**
|
||||
* Get the scale of the object on Z axis.
|
||||
*
|
||||
* @return the scale of the object on Z axis
|
||||
*/
|
||||
getScaleZ(): float;
|
||||
|
||||
flipZ(enable: boolean): void;
|
||||
|
||||
isFlippedZ(): boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* A behavior that forwards the Base3D interface to its object.
|
||||
*/
|
||||
export class Base3DBehavior
|
||||
extends gdjs.RuntimeBehavior
|
||||
implements Base3DHandler {
|
||||
private object: gdjs.RuntimeObject & Base3DHandler;
|
||||
|
||||
constructor(
|
||||
instanceContainer: gdjs.RuntimeInstanceContainer,
|
||||
behaviorData,
|
||||
owner: gdjs.RuntimeObject & Base3DHandler
|
||||
) {
|
||||
super(instanceContainer, behaviorData, owner);
|
||||
this.object = owner;
|
||||
}
|
||||
|
||||
updateFromBehaviorData(oldBehaviorData, newBehaviorData): boolean {
|
||||
// Nothing to update.
|
||||
return true;
|
||||
}
|
||||
|
||||
onDeActivate() {}
|
||||
|
||||
onDestroy() {}
|
||||
|
||||
doStepPreEvents(instanceContainer: gdjs.RuntimeInstanceContainer) {}
|
||||
|
||||
doStepPostEvents(instanceContainer: gdjs.RuntimeInstanceContainer) {}
|
||||
|
||||
setZ(z: float): void {
|
||||
this.object.setZ(z);
|
||||
}
|
||||
|
||||
getZ(): float {
|
||||
return this.object.getZ();
|
||||
}
|
||||
|
||||
setRotationX(angle: float): void {
|
||||
this.object.setRotationX(angle);
|
||||
}
|
||||
|
||||
setRotationY(angle: float): void {
|
||||
this.object.setRotationY(angle);
|
||||
}
|
||||
|
||||
getRotationX(): float {
|
||||
return this.object.getRotationX();
|
||||
}
|
||||
|
||||
getRotationY(): float {
|
||||
return this.object.getRotationY();
|
||||
}
|
||||
|
||||
turnAroundX(deltaAngle: float): void {
|
||||
this.object.turnAroundX(deltaAngle);
|
||||
}
|
||||
|
||||
turnAroundY(deltaAngle: float): void {
|
||||
this.object.turnAroundY(deltaAngle);
|
||||
}
|
||||
|
||||
turnAroundZ(deltaAngle: float): void {
|
||||
this.object.turnAroundZ(deltaAngle);
|
||||
}
|
||||
|
||||
getDepth(): float {
|
||||
return this.object.getDepth();
|
||||
}
|
||||
|
||||
setDepth(depth: float): void {
|
||||
this.object.setDepth(depth);
|
||||
}
|
||||
|
||||
setScaleZ(newScale: number): void {
|
||||
this.object.setScaleZ(newScale);
|
||||
}
|
||||
|
||||
getScaleZ(): float {
|
||||
return this.object.getScaleZ();
|
||||
}
|
||||
|
||||
flipZ(enable: boolean): void {
|
||||
this.object.flipZ(enable);
|
||||
}
|
||||
|
||||
isFlippedZ(): boolean {
|
||||
return this.object.isFlippedZ();
|
||||
}
|
||||
}
|
||||
|
||||
gdjs.registerBehavior('Scene3D::Base3DBehavior', gdjs.Base3DBehavior);
|
||||
}
|
@@ -6,6 +6,9 @@ namespace gdjs {
|
||||
target: EffectsTarget,
|
||||
effectData: EffectData
|
||||
): gdjs.PixiFiltersTools.Filter {
|
||||
if (typeof THREE === 'undefined') {
|
||||
return new gdjs.PixiFiltersTools.EmptyFilter();
|
||||
}
|
||||
return new (class implements gdjs.PixiFiltersTools.Filter {
|
||||
light: THREE.DirectionalLight;
|
||||
rotationObject: THREE.Group;
|
||||
|
@@ -6,6 +6,9 @@ namespace gdjs {
|
||||
target: EffectsTarget,
|
||||
effectData: EffectData
|
||||
): gdjs.PixiFiltersTools.Filter {
|
||||
if (typeof THREE === 'undefined') {
|
||||
return new gdjs.PixiFiltersTools.EmptyFilter();
|
||||
}
|
||||
return new (class implements gdjs.PixiFiltersTools.Filter {
|
||||
fog: THREE.FogExp2;
|
||||
|
||||
|
@@ -6,6 +6,9 @@ namespace gdjs {
|
||||
target: EffectsTarget,
|
||||
effectData: EffectData
|
||||
): gdjs.PixiFiltersTools.Filter {
|
||||
if (typeof THREE === 'undefined') {
|
||||
return new gdjs.PixiFiltersTools.EmptyFilter();
|
||||
}
|
||||
return new (class implements gdjs.PixiFiltersTools.Filter {
|
||||
light: THREE.HemisphereLight;
|
||||
rotationObject: THREE.Group;
|
||||
|
@@ -38,6 +38,191 @@ module.exports = {
|
||||
.addInstructionOrExpressionGroupMetadata(_('3D'))
|
||||
.setIcon('res/conditions/3d_box.svg');
|
||||
|
||||
{
|
||||
const base3D = extension.addBehavior(
|
||||
"Base3DBehavior",
|
||||
_("3D capability"),
|
||||
"Object3D",
|
||||
_("Move the object in 3D space."),
|
||||
"",
|
||||
"res/conditions/3d_box.svg",
|
||||
"Base3DBehavior",
|
||||
new gd.Behavior(),
|
||||
new gd.BehaviorsSharedData())
|
||||
.setHidden()
|
||||
.setIncludeFile('Extensions/3D/Base3DBehavior.js');
|
||||
|
||||
base3D
|
||||
.addExpressionAndConditionAndAction(
|
||||
'number',
|
||||
'Z',
|
||||
_('Z (elevation)'),
|
||||
_('the Z position (the "elevation")'),
|
||||
_('the Z position'),
|
||||
_('Position'),
|
||||
'res/conditions/3d_box.svg'
|
||||
)
|
||||
.addParameter('object', _('3D object'))
|
||||
.addParameter("behavior", _("Behavior"), "Base3DBehavior")
|
||||
.useStandardParameters('number', gd.ParameterOptions.makeNewOptions())
|
||||
.setFunctionName('setZ')
|
||||
.setGetter('getZ');
|
||||
|
||||
base3D
|
||||
.addExpressionAndConditionAndAction(
|
||||
'number',
|
||||
'Depth',
|
||||
_('Depth (size on Z axis)'),
|
||||
_('the depth (size on Z axis)'),
|
||||
_('the depth'),
|
||||
_('Size'),
|
||||
'res/conditions/3d_box.svg'
|
||||
)
|
||||
.addParameter('object', _('3D object'))
|
||||
.addParameter("behavior", _("Behavior"), "Base3DBehavior")
|
||||
.useStandardParameters('number', gd.ParameterOptions.makeNewOptions())
|
||||
.setFunctionName('setDepth')
|
||||
.setGetter('getDepth');
|
||||
|
||||
base3D
|
||||
.addExpressionAndConditionAndAction(
|
||||
'number',
|
||||
'ScaleZ',
|
||||
_('Scale on Z axis'),
|
||||
_("the scale on Z axis of an object (default scale is 1)"),
|
||||
_("the scale on Z axis scale"),
|
||||
_('Scale'),
|
||||
'res/conditions/3d_box.svg'
|
||||
)
|
||||
.addParameter('object', _('3D object'))
|
||||
.addParameter("behavior", _("Behavior"), "Base3DBehavior")
|
||||
.useStandardParameters(
|
||||
'number',
|
||||
gd.ParameterOptions.makeNewOptions().setDescription(
|
||||
_('Scale (1 by default)')
|
||||
)
|
||||
)
|
||||
.markAsAdvanced()
|
||||
.setFunctionName('setScaleZ')
|
||||
.setGetter('getScaleZ');
|
||||
|
||||
base3D
|
||||
.addScopedAction(
|
||||
'FlipZ',
|
||||
_('Flip the object on Z'),
|
||||
_('Flip the object on Z axis'),
|
||||
_('Flip on Z axis _PARAM0_: _PARAM2_'),
|
||||
_('Effects'),
|
||||
'res/conditions/3d_box.svg',
|
||||
'res/conditions/3d_box.svg'
|
||||
)
|
||||
.addParameter('object', _('3D object'))
|
||||
.addParameter("behavior", _("Behavior"), "Base3DBehavior")
|
||||
.addParameter('yesorno', _('Activate flipping'))
|
||||
.markAsSimple()
|
||||
.setFunctionName('flipZ');
|
||||
|
||||
base3D
|
||||
.addScopedCondition(
|
||||
'FlippedZ',
|
||||
_('Flipped on Z'),
|
||||
_('Check if the object is flipped on Z axis'),
|
||||
_('_PARAM0_ is flipped on Z axis'),
|
||||
_('Effects'),
|
||||
'res/conditions/3d_box.svg',
|
||||
'res/conditions/3d_box.svg'
|
||||
)
|
||||
.addParameter('object', _('3D object'))
|
||||
.addParameter("behavior", _("Behavior"), "Base3DBehavior")
|
||||
.setFunctionName('isFlippedZ');
|
||||
|
||||
base3D
|
||||
.addExpressionAndConditionAndAction(
|
||||
'number',
|
||||
'RotationX',
|
||||
_('Rotation on X axis'),
|
||||
_('the rotation on X axis'),
|
||||
_('the rotation on X axis'),
|
||||
_('Angle'),
|
||||
'res/conditions/3d_box.svg'
|
||||
)
|
||||
.addParameter('object', _('3D object'))
|
||||
.addParameter("behavior", _("Behavior"), "Base3DBehavior")
|
||||
.useStandardParameters('number', gd.ParameterOptions.makeNewOptions())
|
||||
.setFunctionName('setRotationX')
|
||||
.setGetter('getRotationX');
|
||||
|
||||
base3D
|
||||
.addExpressionAndConditionAndAction(
|
||||
'number',
|
||||
'RotationY',
|
||||
_('Rotation on Y axis'),
|
||||
_('the rotation on Y axis'),
|
||||
_('the rotation on Y axis'),
|
||||
_('Angle'),
|
||||
'res/conditions/3d_box.svg'
|
||||
)
|
||||
.addParameter('object', _('3D object'))
|
||||
.addParameter("behavior", _("Behavior"), "Base3DBehavior")
|
||||
.useStandardParameters('number', gd.ParameterOptions.makeNewOptions())
|
||||
.setFunctionName('setRotationY')
|
||||
.setGetter('getRotationY');
|
||||
|
||||
base3D
|
||||
.addScopedAction(
|
||||
'TurnAroundX',
|
||||
_('Turn around X axis'),
|
||||
_(
|
||||
"Turn the object around X axis. This axis doesn't move with the object rotation."
|
||||
),
|
||||
_('Turn _PARAM0_ from _PARAM2_° around X axis'),
|
||||
_('Angle'),
|
||||
'res/conditions/3d_box.svg',
|
||||
'res/conditions/3d_box.svg'
|
||||
)
|
||||
.addParameter('object', _('3D object'))
|
||||
.addParameter("behavior", _("Behavior"), "Base3DBehavior")
|
||||
.addParameter('number', _('Rotation angle'), '', false)
|
||||
.markAsAdvanced()
|
||||
.setFunctionName('turnAroundX');
|
||||
|
||||
base3D
|
||||
.addScopedAction(
|
||||
'TurnAroundY',
|
||||
_('Turn around Y axis'),
|
||||
_(
|
||||
"Turn the object around Y axis. This axis doesn't move with the object rotation."
|
||||
),
|
||||
_('Turn _PARAM0_ from _PARAM2_° around Y axis'),
|
||||
_('Angle'),
|
||||
'res/conditions/3d_box.svg',
|
||||
'res/conditions/3d_box.svg'
|
||||
)
|
||||
.addParameter('object', _('3D object'))
|
||||
.addParameter("behavior", _("Behavior"), "Base3DBehavior")
|
||||
.addParameter('number', _('Rotation angle'), '', false)
|
||||
.markAsAdvanced()
|
||||
.setFunctionName('turnAroundY');
|
||||
|
||||
base3D
|
||||
.addScopedAction(
|
||||
'TurnAroundZ',
|
||||
_('Turn around Z axis'),
|
||||
_(
|
||||
"Turn the object around Z axis. This axis doesn't move with the object rotation."
|
||||
),
|
||||
_('Turn _PARAM0_ from _PARAM2_° around Z axis'),
|
||||
_('Angle'),
|
||||
'res/conditions/3d_box.svg',
|
||||
'res/conditions/3d_box.svg'
|
||||
)
|
||||
.addParameter('object', _('3D object'))
|
||||
.addParameter("behavior", _("Behavior"), "Base3DBehavior")
|
||||
.addParameter('number', _('Rotation angle'), '', false)
|
||||
.markAsAdvanced()
|
||||
.setFunctionName('turnAroundZ');
|
||||
}
|
||||
|
||||
{
|
||||
const object = extension
|
||||
.addObject(
|
||||
@@ -48,13 +233,20 @@ module.exports = {
|
||||
new gd.Model3DObjectConfiguration()
|
||||
)
|
||||
.setCategoryFullName(_('3D'))
|
||||
.addUnsupportedBaseObjectCapability('effect')
|
||||
// Effects are unsupported because the object is not rendered with PIXI.
|
||||
.addDefaultBehavior('ResizableCapability::ResizableBehavior')
|
||||
.addDefaultBehavior('ScalableCapability::ScalableBehavior')
|
||||
.addDefaultBehavior('FlippableCapability::FlippableBehavior')
|
||||
.addDefaultBehavior('AnimatableCapability::AnimatableBehavior')
|
||||
.addDefaultBehavior('Scene3D::Base3DBehavior')
|
||||
.setIncludeFile('Extensions/3D/A_RuntimeObject3D.js')
|
||||
.addIncludeFile('Extensions/3D/A_RuntimeObject3DRenderer.js')
|
||||
.addIncludeFile('Extensions/3D/Model3DRuntimeObject.js')
|
||||
.addIncludeFile('Extensions/3D/Model3DRuntimeObject3DRenderer.js');
|
||||
|
||||
// Properties expressions/conditions/actions:
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addExpressionAndConditionAndAction(
|
||||
'number',
|
||||
@@ -67,9 +259,12 @@ module.exports = {
|
||||
)
|
||||
.addParameter('object', _('3D model'), 'Model3DObject', false)
|
||||
.useStandardParameters('number', gd.ParameterOptions.makeNewOptions())
|
||||
.setHidden()
|
||||
.setFunctionName('setZ')
|
||||
.setGetter('getZ');
|
||||
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addExpressionAndConditionAndAction(
|
||||
'number',
|
||||
@@ -82,9 +277,11 @@ module.exports = {
|
||||
)
|
||||
.addParameter('object', _('3D model'), 'Model3DObject', false)
|
||||
.useStandardParameters('number', gd.ParameterOptions.makeNewOptions())
|
||||
.setHidden()
|
||||
.setFunctionName('setDepth')
|
||||
.setGetter('getDepth');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addScopedAction(
|
||||
'SetWidth',
|
||||
@@ -100,10 +297,12 @@ module.exports = {
|
||||
'number',
|
||||
gd.ParameterOptions.makeNewOptions()
|
||||
)
|
||||
.setHidden()
|
||||
.markAsAdvanced()
|
||||
.setFunctionName('setWidth')
|
||||
.setGetter('getWidth');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addScopedCondition(
|
||||
'Width',
|
||||
@@ -119,9 +318,11 @@ module.exports = {
|
||||
'number',
|
||||
gd.ParameterOptions.makeNewOptions()
|
||||
)
|
||||
.setHidden()
|
||||
.markAsAdvanced()
|
||||
.setFunctionName('getWidth');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addScopedAction(
|
||||
'SetHeight',
|
||||
@@ -137,10 +338,12 @@ module.exports = {
|
||||
'number',
|
||||
gd.ParameterOptions.makeNewOptions()
|
||||
)
|
||||
.setHidden()
|
||||
.markAsAdvanced()
|
||||
.setFunctionName('setHeight')
|
||||
.setGetter('getHeight');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addScopedCondition(
|
||||
'Height',
|
||||
@@ -156,9 +359,11 @@ module.exports = {
|
||||
'number',
|
||||
gd.ParameterOptions.makeNewOptions()
|
||||
)
|
||||
.setHidden()
|
||||
.markAsAdvanced()
|
||||
.setFunctionName('getHeight');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addExpressionAndConditionAndAction(
|
||||
'number',
|
||||
@@ -171,9 +376,11 @@ module.exports = {
|
||||
)
|
||||
.addParameter('object', _('3D model'), 'Model3DObject', false)
|
||||
.useStandardParameters('number', gd.ParameterOptions.makeNewOptions())
|
||||
.setHidden()
|
||||
.setFunctionName('setHeight')
|
||||
.setGetter('getHeight');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addScopedAction(
|
||||
'Scale',
|
||||
@@ -191,10 +398,12 @@ module.exports = {
|
||||
_('Scale (1 by default)')
|
||||
)
|
||||
)
|
||||
.setHidden()
|
||||
.markAsAdvanced()
|
||||
.setFunctionName('setScale')
|
||||
.setGetter('getScale');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addExpressionAndConditionAndAction(
|
||||
'number',
|
||||
@@ -212,10 +421,12 @@ module.exports = {
|
||||
_('Scale (1 by default)')
|
||||
)
|
||||
)
|
||||
.setHidden()
|
||||
.markAsAdvanced()
|
||||
.setFunctionName('setScaleX')
|
||||
.setGetter('getScaleX');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addExpressionAndConditionAndAction(
|
||||
'number',
|
||||
@@ -233,10 +444,12 @@ module.exports = {
|
||||
_('Scale (1 by default)')
|
||||
)
|
||||
)
|
||||
.setHidden()
|
||||
.markAsAdvanced()
|
||||
.setFunctionName('setScaleY')
|
||||
.setGetter('getScaleY');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addExpressionAndConditionAndAction(
|
||||
'number',
|
||||
@@ -255,9 +468,11 @@ module.exports = {
|
||||
)
|
||||
)
|
||||
.markAsAdvanced()
|
||||
.setHidden()
|
||||
.setFunctionName('setScaleZ')
|
||||
.setGetter('getScaleZ');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addScopedAction(
|
||||
'FlipX',
|
||||
@@ -270,9 +485,11 @@ module.exports = {
|
||||
)
|
||||
.addParameter('object', _('3D model'), 'Model3DObject')
|
||||
.addParameter('yesorno', _('Activate flipping'))
|
||||
.setHidden()
|
||||
.markAsSimple()
|
||||
.setFunctionName('flipX');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addScopedAction(
|
||||
'FlipY',
|
||||
@@ -285,9 +502,11 @@ module.exports = {
|
||||
)
|
||||
.addParameter('object', _('3D model'), 'Model3DObject')
|
||||
.addParameter('yesorno', _('Activate flipping'))
|
||||
.setHidden()
|
||||
.markAsSimple()
|
||||
.setFunctionName('flipY');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addScopedAction(
|
||||
'FlipZ',
|
||||
@@ -301,8 +520,10 @@ module.exports = {
|
||||
.addParameter('object', _('3D model'), 'Model3DObject')
|
||||
.addParameter('yesorno', _('Activate flipping'))
|
||||
.markAsSimple()
|
||||
.setHidden()
|
||||
.setFunctionName('flipZ');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addScopedCondition(
|
||||
'FlippedX',
|
||||
@@ -314,8 +535,10 @@ module.exports = {
|
||||
'res/actions/flipX.png'
|
||||
)
|
||||
.addParameter('object', _('3D model'), 'Model3DObject')
|
||||
.setHidden()
|
||||
.setFunctionName('isFlippedX');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addScopedCondition(
|
||||
'FlippedY',
|
||||
@@ -327,8 +550,10 @@ module.exports = {
|
||||
'res/actions/flipY.png'
|
||||
)
|
||||
.addParameter('object', _('3D model'), 'Model3DObject')
|
||||
.setHidden()
|
||||
.setFunctionName('isFlippedY');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addScopedCondition(
|
||||
'FlippedZ',
|
||||
@@ -340,8 +565,10 @@ module.exports = {
|
||||
'res/conditions/3d_box.svg'
|
||||
)
|
||||
.addParameter('object', _('3D model'), 'Model3DObject')
|
||||
.setHidden()
|
||||
.setFunctionName('isFlippedZ');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addExpressionAndConditionAndAction(
|
||||
'number',
|
||||
@@ -354,9 +581,11 @@ module.exports = {
|
||||
)
|
||||
.addParameter('object', _('3D model'), 'Model3DObject', false)
|
||||
.useStandardParameters('number', gd.ParameterOptions.makeNewOptions())
|
||||
.setHidden()
|
||||
.setFunctionName('setRotationX')
|
||||
.setGetter('getRotationX');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addExpressionAndConditionAndAction(
|
||||
'number',
|
||||
@@ -369,9 +598,11 @@ module.exports = {
|
||||
)
|
||||
.addParameter('object', _('3D model'), 'Model3DObject', false)
|
||||
.useStandardParameters('number', gd.ParameterOptions.makeNewOptions())
|
||||
.setHidden()
|
||||
.setFunctionName('setRotationY')
|
||||
.setGetter('getRotationY');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addScopedAction(
|
||||
'TurnAroundX',
|
||||
@@ -387,8 +618,10 @@ module.exports = {
|
||||
.addParameter('object', _('3D model'), 'Model3DObject', false)
|
||||
.addParameter('number', _('Rotation angle'), '', false)
|
||||
.markAsAdvanced()
|
||||
.setHidden()
|
||||
.setFunctionName('turnAroundX');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addScopedAction(
|
||||
'TurnAroundY',
|
||||
@@ -404,8 +637,10 @@ module.exports = {
|
||||
.addParameter('object', _('3D model'), 'Model3DObject', false)
|
||||
.addParameter('number', _('Rotation angle'), '', false)
|
||||
.markAsAdvanced()
|
||||
.setHidden()
|
||||
.setFunctionName('turnAroundY');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addScopedAction(
|
||||
'TurnAroundZ',
|
||||
@@ -421,8 +656,10 @@ module.exports = {
|
||||
.addParameter('object', _('3D model'), 'Model3DObject', false)
|
||||
.addParameter('number', _('Rotation angle'), '', false)
|
||||
.markAsAdvanced()
|
||||
.setHidden()
|
||||
.setFunctionName('turnAroundZ');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addExpressionAndConditionAndAction(
|
||||
'number',
|
||||
@@ -438,9 +675,11 @@ module.exports = {
|
||||
.addParameter('object', _('3D model'), 'Model3DObject')
|
||||
.useStandardParameters('number', gd.ParameterOptions.makeNewOptions())
|
||||
.markAsSimple()
|
||||
.setHidden()
|
||||
.setFunctionName('setAnimationIndex')
|
||||
.setGetter('getAnimationIndex');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addExpressionAndConditionAndAction(
|
||||
'string',
|
||||
@@ -459,9 +698,11 @@ module.exports = {
|
||||
)
|
||||
)
|
||||
.markAsAdvanced()
|
||||
.setHidden()
|
||||
.setFunctionName('setAnimationName')
|
||||
.setGetter('getAnimationName');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addAction(
|
||||
'PauseAnimation',
|
||||
@@ -474,8 +715,10 @@ module.exports = {
|
||||
)
|
||||
.addParameter('object', _('3D model'), 'Model3DObject')
|
||||
.markAsSimple()
|
||||
.setHidden()
|
||||
.setFunctionName('pauseAnimation');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addAction(
|
||||
'ResumeAnimation',
|
||||
@@ -488,8 +731,10 @@ module.exports = {
|
||||
)
|
||||
.addParameter('object', _('3D model'), 'Model3DObject')
|
||||
.markAsSimple()
|
||||
.setHidden()
|
||||
.setFunctionName('resumeAnimation');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addExpressionAndConditionAndAction(
|
||||
'number',
|
||||
@@ -508,9 +753,11 @@ module.exports = {
|
||||
gd.ParameterOptions.makeNewOptions().setDescription(_('Speed scale'))
|
||||
)
|
||||
.markAsSimple()
|
||||
.setHidden()
|
||||
.setFunctionName('setAnimationSpeedScale')
|
||||
.setGetter('getAnimationSpeedScale');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addCondition(
|
||||
'IsAnimationPaused',
|
||||
@@ -523,8 +770,10 @@ module.exports = {
|
||||
)
|
||||
.addParameter('object', _('3D model'), 'Model3DObject')
|
||||
.markAsSimple()
|
||||
.setHidden()
|
||||
.setFunctionName('isAnimationPaused');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addCondition(
|
||||
'HasAnimationEnded',
|
||||
@@ -539,6 +788,7 @@ module.exports = {
|
||||
)
|
||||
.addParameter('object', _('3D model'), 'Model3DObject')
|
||||
.markAsSimple()
|
||||
.setHidden()
|
||||
.setFunctionName('hasAnimationEnded');
|
||||
}
|
||||
|
||||
@@ -864,13 +1114,19 @@ module.exports = {
|
||||
Cube3DObject
|
||||
)
|
||||
.setCategoryFullName(_('3D'))
|
||||
.addUnsupportedBaseObjectCapability('effect')
|
||||
// Effects are unsupported because the object is not rendered with PIXI.
|
||||
.addDefaultBehavior('ResizableCapability::ResizableBehavior')
|
||||
.addDefaultBehavior('ScalableCapability::ScalableBehavior')
|
||||
.addDefaultBehavior('FlippableCapability::FlippableBehavior')
|
||||
.addDefaultBehavior('Scene3D::Base3DBehavior')
|
||||
.setIncludeFile('Extensions/3D/A_RuntimeObject3D.js')
|
||||
.addIncludeFile('Extensions/3D/A_RuntimeObject3DRenderer.js')
|
||||
.addIncludeFile('Extensions/3D/Cube3DRuntimeObject.js')
|
||||
.addIncludeFile('Extensions/3D/Cube3DRuntimeObjectPixiRenderer.js');
|
||||
|
||||
// Properties expressions/conditions/actions:
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addExpressionAndConditionAndAction(
|
||||
'number',
|
||||
@@ -883,9 +1139,11 @@ module.exports = {
|
||||
)
|
||||
.addParameter('object', _('3D cube'), 'Cube3DObject', false)
|
||||
.useStandardParameters('number', gd.ParameterOptions.makeNewOptions())
|
||||
.setHidden()
|
||||
.setFunctionName('setZ')
|
||||
.setGetter('getZ');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addExpressionAndConditionAndAction(
|
||||
'number',
|
||||
@@ -898,9 +1156,11 @@ module.exports = {
|
||||
)
|
||||
.addParameter('object', _('3D cube'), 'Cube3DObject', false)
|
||||
.useStandardParameters('number', gd.ParameterOptions.makeNewOptions())
|
||||
.setHidden()
|
||||
.setFunctionName('setDepth')
|
||||
.setGetter('getDepth');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addScopedAction(
|
||||
'SetWidth',
|
||||
@@ -916,10 +1176,12 @@ module.exports = {
|
||||
'number',
|
||||
gd.ParameterOptions.makeNewOptions()
|
||||
)
|
||||
.setHidden()
|
||||
.markAsAdvanced()
|
||||
.setFunctionName('setWidth')
|
||||
.setGetter('getWidth');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addScopedCondition(
|
||||
'Width',
|
||||
@@ -935,9 +1197,11 @@ module.exports = {
|
||||
'number',
|
||||
gd.ParameterOptions.makeNewOptions()
|
||||
)
|
||||
.setHidden()
|
||||
.markAsAdvanced()
|
||||
.setFunctionName('getWidth');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addScopedAction(
|
||||
'SetHeight',
|
||||
@@ -953,10 +1217,12 @@ module.exports = {
|
||||
'number',
|
||||
gd.ParameterOptions.makeNewOptions()
|
||||
)
|
||||
.setHidden()
|
||||
.markAsAdvanced()
|
||||
.setFunctionName('setHeight')
|
||||
.setGetter('getHeight');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addScopedCondition(
|
||||
'Height',
|
||||
@@ -972,9 +1238,11 @@ module.exports = {
|
||||
'number',
|
||||
gd.ParameterOptions.makeNewOptions()
|
||||
)
|
||||
.setHidden()
|
||||
.markAsAdvanced()
|
||||
.setFunctionName('getHeight');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addScopedAction(
|
||||
'Scale',
|
||||
@@ -992,10 +1260,12 @@ module.exports = {
|
||||
_('Scale (1 by default)')
|
||||
)
|
||||
)
|
||||
.setHidden()
|
||||
.markAsAdvanced()
|
||||
.setFunctionName('setScale')
|
||||
.setGetter('getScale');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addExpressionAndConditionAndAction(
|
||||
'number',
|
||||
@@ -1013,10 +1283,12 @@ module.exports = {
|
||||
_('Scale (1 by default)')
|
||||
)
|
||||
)
|
||||
.setHidden()
|
||||
.markAsAdvanced()
|
||||
.setFunctionName('setScaleX')
|
||||
.setGetter('getScaleX');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addExpressionAndConditionAndAction(
|
||||
'number',
|
||||
@@ -1034,10 +1306,12 @@ module.exports = {
|
||||
_('Scale (1 by default)')
|
||||
)
|
||||
)
|
||||
.setHidden()
|
||||
.markAsAdvanced()
|
||||
.setFunctionName('setScaleY')
|
||||
.setGetter('getScaleY');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addExpressionAndConditionAndAction(
|
||||
'number',
|
||||
@@ -1056,9 +1330,11 @@ module.exports = {
|
||||
)
|
||||
)
|
||||
.markAsAdvanced()
|
||||
.setHidden()
|
||||
.setFunctionName('setScaleZ')
|
||||
.setGetter('getScaleZ');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addScopedAction(
|
||||
'FlipX',
|
||||
@@ -1072,8 +1348,10 @@ module.exports = {
|
||||
.addParameter('object', _('3D cube'), 'Cube3DObject')
|
||||
.addParameter('yesorno', _('Activate flipping'))
|
||||
.markAsSimple()
|
||||
.setHidden()
|
||||
.setFunctionName('flipX');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addScopedAction(
|
||||
'FlipY',
|
||||
@@ -1087,8 +1365,10 @@ module.exports = {
|
||||
.addParameter('object', _('3D cube'), 'Cube3DObject')
|
||||
.addParameter('yesorno', _('Activate flipping'))
|
||||
.markAsSimple()
|
||||
.setHidden()
|
||||
.setFunctionName('flipY');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addScopedAction(
|
||||
'FlipZ',
|
||||
@@ -1102,8 +1382,10 @@ module.exports = {
|
||||
.addParameter('object', _('3D cube'), 'Cube3DObject')
|
||||
.addParameter('yesorno', _('Activate flipping'))
|
||||
.markAsSimple()
|
||||
.setHidden()
|
||||
.setFunctionName('flipZ');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addScopedCondition(
|
||||
'FlippedX',
|
||||
@@ -1115,8 +1397,10 @@ module.exports = {
|
||||
'res/actions/flipX.png'
|
||||
)
|
||||
.addParameter('object', _('3D cube'), 'Cube3DObject')
|
||||
.setHidden()
|
||||
.setFunctionName('isFlippedX');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addScopedCondition(
|
||||
'FlippedY',
|
||||
@@ -1128,8 +1412,10 @@ module.exports = {
|
||||
'res/actions/flipY.png'
|
||||
)
|
||||
.addParameter('object', _('3D cube'), 'Cube3DObject')
|
||||
.setHidden()
|
||||
.setFunctionName('isFlippedY');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addScopedCondition(
|
||||
'FlippedZ',
|
||||
@@ -1141,8 +1427,10 @@ module.exports = {
|
||||
'res/conditions/3d_box.svg'
|
||||
)
|
||||
.addParameter('object', _('3D cube'), 'Cube3DObject')
|
||||
.setHidden()
|
||||
.setFunctionName('isFlippedZ');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addExpressionAndConditionAndAction(
|
||||
'number',
|
||||
@@ -1156,8 +1444,10 @@ module.exports = {
|
||||
.addParameter('object', _('3D cube'), 'Cube3DObject', false)
|
||||
.useStandardParameters('number', gd.ParameterOptions.makeNewOptions())
|
||||
.setFunctionName('setRotationX')
|
||||
.setHidden()
|
||||
.setGetter('getRotationX');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addExpressionAndConditionAndAction(
|
||||
'number',
|
||||
@@ -1171,6 +1461,7 @@ module.exports = {
|
||||
.addParameter('object', _('3D cube'), 'Cube3DObject', false)
|
||||
.useStandardParameters('number', gd.ParameterOptions.makeNewOptions())
|
||||
.setFunctionName('setRotationY')
|
||||
.setHidden()
|
||||
.setGetter('getRotationY');
|
||||
|
||||
object
|
||||
@@ -1197,6 +1488,7 @@ module.exports = {
|
||||
.setFunctionName('setFaceVisibility')
|
||||
.setGetter('isFaceVisible');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addScopedAction(
|
||||
'TurnAroundX',
|
||||
@@ -1212,8 +1504,10 @@ module.exports = {
|
||||
.addParameter('object', _('3D cube'), 'Cube3DObject', false)
|
||||
.addParameter('number', _('Rotation angle'), '', false)
|
||||
.markAsAdvanced()
|
||||
.setHidden()
|
||||
.setFunctionName('turnAroundX');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addScopedAction(
|
||||
'TurnAroundY',
|
||||
@@ -1229,8 +1523,10 @@ module.exports = {
|
||||
.addParameter('object', _('3D cube'), 'Cube3DObject', false)
|
||||
.addParameter('number', _('Rotation angle'), '', false)
|
||||
.markAsAdvanced()
|
||||
.setHidden()
|
||||
.setFunctionName('turnAroundY');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addScopedAction(
|
||||
'TurnAroundZ',
|
||||
@@ -1246,6 +1542,7 @@ module.exports = {
|
||||
.addParameter('object', _('3D cube'), 'Cube3DObject', false)
|
||||
.addParameter('number', _('Rotation angle'), '', false)
|
||||
.markAsAdvanced()
|
||||
.setHidden()
|
||||
.setFunctionName('turnAroundZ');
|
||||
|
||||
object
|
||||
|
@@ -6,6 +6,9 @@ namespace gdjs {
|
||||
target: EffectsTarget,
|
||||
effectData: EffectData
|
||||
): gdjs.PixiFiltersTools.Filter {
|
||||
if (typeof THREE === 'undefined') {
|
||||
return new gdjs.PixiFiltersTools.EmptyFilter();
|
||||
}
|
||||
return new (class implements gdjs.PixiFiltersTools.Filter {
|
||||
fog: THREE.Fog;
|
||||
|
||||
|
@@ -21,7 +21,7 @@ using namespace std;
|
||||
|
||||
Model3DObjectConfiguration::Model3DObjectConfiguration()
|
||||
: width(100), height(100), depth(100), rotationX(0), rotationY(0),
|
||||
rotationZ(0), modelResourceName(""), materialType("Basic"),
|
||||
rotationZ(0), modelResourceName(""), materialType("StandardWithoutMetalness"),
|
||||
originLocation("ModelOrigin"), centerLocation("ModelOrigin"),
|
||||
keepAspectRatio(true) {}
|
||||
|
||||
|
@@ -48,7 +48,9 @@ namespace gdjs {
|
||||
/**
|
||||
* A 3D object which displays a 3D model.
|
||||
*/
|
||||
export class Model3DRuntimeObject extends gdjs.RuntimeObject3D {
|
||||
export class Model3DRuntimeObject
|
||||
extends gdjs.RuntimeObject3D
|
||||
implements gdjs.Animatable {
|
||||
_renderer: gdjs.Model3DRuntimeObjectRenderer;
|
||||
|
||||
_modelResourceName: string;
|
||||
|
@@ -18,6 +18,7 @@ void DeclareAnchorBehaviorExtension(gd::PlatformExtension& extension) {
|
||||
"Victor Levasseur",
|
||||
"Open source (MIT License)")
|
||||
.SetCategory("User interface")
|
||||
.SetTags("anchor, ui, layout")
|
||||
.SetExtensionHelpPath("/behaviors/anchor");
|
||||
|
||||
gd::BehaviorMetadata& aut = extension.AddBehavior(
|
||||
|
@@ -174,7 +174,8 @@ module.exports = {
|
||||
.addIncludeFile(
|
||||
'Extensions/BBText/pixi-multistyle-text/dist/pixi-multistyle-text.umd.js'
|
||||
)
|
||||
.setCategoryFullName(_('Text'));
|
||||
.setCategoryFullName(_('Text'))
|
||||
.addDefaultBehavior("OpacityCapability::OpacityBehavior");
|
||||
|
||||
/**
|
||||
* Utility function to add both a setter and a getter to a property from a list.
|
||||
@@ -434,6 +435,14 @@ module.exports = {
|
||||
|
||||
addSettersAndGettersToObject(object, setterAndGetterProperties, 'BBText');
|
||||
|
||||
const actions = object.getAllActions();
|
||||
const conditions = object.getAllConditions();
|
||||
const expressions = object.getAllExpressions();
|
||||
|
||||
actions.get('BBText::SetOpacity').setHidden();
|
||||
conditions.get('BBText::IsOpacity').setHidden();
|
||||
expressions.get('GetOpacity').setHidden();
|
||||
|
||||
return extension;
|
||||
},
|
||||
|
||||
|
@@ -175,7 +175,9 @@ module.exports = {
|
||||
.addIncludeFile(
|
||||
'Extensions/BitmapText/bitmaptextruntimeobject-pixi-renderer.js'
|
||||
)
|
||||
.setCategoryFullName(_('Text'));
|
||||
.setCategoryFullName(_('Text'))
|
||||
.addDefaultBehavior('OpacityCapability::OpacityBehavior')
|
||||
.addDefaultBehavior('ScalableCapability::ScalableBehavior');
|
||||
|
||||
object
|
||||
.addExpressionAndConditionAndAction(
|
||||
@@ -192,6 +194,7 @@ module.exports = {
|
||||
.setFunctionName('setText')
|
||||
.setGetter('getText');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addExpressionAndConditionAndAction(
|
||||
'number',
|
||||
@@ -210,7 +213,8 @@ module.exports = {
|
||||
)
|
||||
)
|
||||
.setFunctionName('setOpacity')
|
||||
.setGetter('getOpacity');
|
||||
.setGetter('getOpacity')
|
||||
.setHidden();
|
||||
|
||||
object
|
||||
.addExpressionAndCondition(
|
||||
@@ -226,6 +230,7 @@ module.exports = {
|
||||
.useStandardParameters('number', gd.ParameterOptions.makeNewOptions())
|
||||
.setFunctionName('getFontSize');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addExpressionAndConditionAndAction(
|
||||
'number',
|
||||
@@ -243,6 +248,7 @@ module.exports = {
|
||||
_('Scale (1 by default)')
|
||||
)
|
||||
)
|
||||
.setHidden()
|
||||
.setFunctionName('setScale')
|
||||
.setGetter('getScale');
|
||||
|
||||
|
@@ -120,7 +120,10 @@ namespace gdjs {
|
||||
}
|
||||
|
||||
updateScale(): void {
|
||||
this._pixiObject.scale.set(Math.max(this._object._scale, 0));
|
||||
this._pixiObject.scale.set(
|
||||
Math.max(this._object._scaleX, 0),
|
||||
Math.max(this._object._scaleY, 0)
|
||||
);
|
||||
this.updatePosition();
|
||||
}
|
||||
|
||||
@@ -131,7 +134,7 @@ namespace gdjs {
|
||||
updateWrappingWidth(): void {
|
||||
if (this._object._wordWrap) {
|
||||
this._pixiObject.maxWidth =
|
||||
this._object._wrappingWidth / this._object._scale;
|
||||
this._object._wrappingWidth / this._object._scaleX;
|
||||
this._pixiObject.dirty = true;
|
||||
} else {
|
||||
this._pixiObject.maxWidth = 0;
|
||||
|
@@ -35,14 +35,17 @@ namespace gdjs {
|
||||
* * Glyph Designer (OS X, commercial): http://www.71squared.com/en/glyphdesigner|http://www.71squared.com/en/glyphdesigner
|
||||
* * Littera (Web-based, free): http://kvazars.com/littera/|http://kvazars.com/littera/
|
||||
*/
|
||||
export class BitmapTextRuntimeObject extends gdjs.RuntimeObject {
|
||||
export class BitmapTextRuntimeObject
|
||||
extends gdjs.RuntimeObject
|
||||
implements gdjs.OpacityHandler, gdjs.Scalable {
|
||||
_opacity: float;
|
||||
_text: string;
|
||||
/** color in format [r, g, b], where each component is in the range [0, 255] */
|
||||
_tint: integer[];
|
||||
_bitmapFontResourceName: string;
|
||||
_textureAtlasResourceName: string;
|
||||
_scale: number;
|
||||
_scaleX: number;
|
||||
_scaleY: number;
|
||||
_wordWrap: boolean;
|
||||
_wrappingWidth: float;
|
||||
_align: string;
|
||||
@@ -66,7 +69,8 @@ namespace gdjs {
|
||||
this._bitmapFontResourceName = objectData.content.bitmapFontResourceName; // fnt/xml files
|
||||
this._textureAtlasResourceName =
|
||||
objectData.content.textureAtlasResourceName; // texture file used with fnt/xml (bitmap font file)
|
||||
this._scale = objectData.content.scale;
|
||||
this._scaleX = objectData.content.scale;
|
||||
this._scaleY = objectData.content.scale;
|
||||
this._wordWrap = objectData.content.wordWrap;
|
||||
this._wrappingWidth = 0;
|
||||
this._align = objectData.content.align;
|
||||
@@ -167,14 +171,45 @@ namespace gdjs {
|
||||
return this._tint[0] + ';' + this._tint[1] + ';' + this._tint[2];
|
||||
}
|
||||
|
||||
getScale(): number {
|
||||
const scaleX = this.getScaleX();
|
||||
const scaleY = this.getScaleY();
|
||||
return scaleX === scaleY ? scaleX : Math.sqrt(scaleX * scaleY);
|
||||
}
|
||||
|
||||
getScaleX(): float {
|
||||
return this._scaleX;
|
||||
}
|
||||
|
||||
getScaleY(): float {
|
||||
return this._scaleY;
|
||||
}
|
||||
|
||||
setScale(scale: float): void {
|
||||
this._scale = scale;
|
||||
this.setScaleX(scale);
|
||||
this.setScaleY(scale);
|
||||
}
|
||||
|
||||
setScaleX(scaleX: float): void {
|
||||
if (scaleX < 0) {
|
||||
scaleX = 0;
|
||||
}
|
||||
if (this._scaleX === scaleX) return;
|
||||
|
||||
this._scaleX = scaleX;
|
||||
this._renderer.updateScale();
|
||||
this.invalidateHitboxes();
|
||||
}
|
||||
|
||||
getScale(): float {
|
||||
return this._scale;
|
||||
setScaleY(scaleY: float): void {
|
||||
if (scaleY < 0) {
|
||||
scaleY = 0;
|
||||
}
|
||||
if (this._scaleY === scaleY) return;
|
||||
|
||||
this._scaleY = scaleY;
|
||||
this._renderer.updateScale();
|
||||
this.invalidateHitboxes();
|
||||
}
|
||||
|
||||
getFontSize(): float {
|
||||
|
@@ -21,6 +21,7 @@ void DeclareDestroyOutsideBehaviorExtension(gd::PlatformExtension& extension) {
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)")
|
||||
.SetCategory("Game mechanic")
|
||||
.SetTags("screen")
|
||||
.SetExtensionHelpPath("/behaviors/destroyoutside");
|
||||
|
||||
gd::BehaviorMetadata& aut =
|
||||
|
@@ -21,6 +21,7 @@ void DeclareDraggableBehaviorExtension(gd::PlatformExtension& extension) {
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)")
|
||||
.SetCategory("User interface")
|
||||
.SetTags("drag")
|
||||
.SetExtensionHelpPath("/behaviors/draggable");
|
||||
|
||||
gd::BehaviorMetadata& aut = extension.AddBehavior(
|
||||
|
@@ -33,7 +33,8 @@ module.exports = {
|
||||
'Harsimran Virk',
|
||||
'MIT'
|
||||
)
|
||||
.setCategory('Visual effect');
|
||||
.setCategory('Visual effect')
|
||||
.setTags("light");
|
||||
|
||||
const lightObstacleBehavior = new gd.BehaviorJsImplementation();
|
||||
// $FlowExpectedError - ignore Flow warning as we're creating a behavior
|
||||
|
@@ -38,7 +38,10 @@ void DeclarePanelSpriteObjectExtension(gd::PlatformExtension& extension) {
|
||||
"from "
|
||||
"the full image."),
|
||||
"CppPlatform/Extensions/PanelSpriteIcon.png")
|
||||
.SetCategoryFullName(_("General"));
|
||||
.SetCategoryFullName(_("General"))
|
||||
.AddDefaultBehavior("EffectCapability::EffectBehavior")
|
||||
.AddDefaultBehavior("ResizableCapability::ResizableBehavior")
|
||||
.AddDefaultBehavior("OpacityCapability::OpacityBehavior");
|
||||
|
||||
obj.AddCondition("Opacity",
|
||||
_("Opacity"),
|
||||
@@ -90,6 +93,7 @@ void DeclarePanelSpriteObjectExtension(gd::PlatformExtension& extension) {
|
||||
.AddParameter("object", _("Object"), "PanelSprite")
|
||||
.AddParameter("color", _("Tint"));
|
||||
|
||||
// Deprecated
|
||||
obj.AddAction("Width",
|
||||
_("Width"),
|
||||
_("Modify the width of a Panel Sprite."),
|
||||
@@ -101,9 +105,11 @@ void DeclarePanelSpriteObjectExtension(gd::PlatformExtension& extension) {
|
||||
.AddParameter("object", _("Object"), "PanelSprite")
|
||||
.UseStandardOperatorParameters("number",
|
||||
gd::ParameterOptions::MakeNewOptions())
|
||||
.SetHidden()
|
||||
.SetFunctionName("SetWidth")
|
||||
.SetGetter("GetWidth");
|
||||
|
||||
// Deprecated
|
||||
obj.AddCondition("Width",
|
||||
_("Width"),
|
||||
_("Check the width of a Panel Sprite."),
|
||||
@@ -115,8 +121,10 @@ void DeclarePanelSpriteObjectExtension(gd::PlatformExtension& extension) {
|
||||
.AddParameter("object", _("Object"), "PanelSprite")
|
||||
.UseStandardRelationalOperatorParameters(
|
||||
"number", gd::ParameterOptions::MakeNewOptions())
|
||||
.SetHidden()
|
||||
.SetFunctionName("GetWidth");
|
||||
|
||||
// Deprecated
|
||||
obj.AddAction("Height",
|
||||
_("Height"),
|
||||
_("Modify the height of a Panel Sprite."),
|
||||
@@ -128,9 +136,11 @@ void DeclarePanelSpriteObjectExtension(gd::PlatformExtension& extension) {
|
||||
.AddParameter("object", _("Object"), "PanelSprite")
|
||||
.UseStandardOperatorParameters("number",
|
||||
gd::ParameterOptions::MakeNewOptions())
|
||||
.SetHidden()
|
||||
.SetFunctionName("SetHeight")
|
||||
.SetGetter("GetHeight");
|
||||
|
||||
// Deprecated
|
||||
obj.AddCondition("Height",
|
||||
_("Height"),
|
||||
_("Check the height of a Panel Sprite."),
|
||||
@@ -142,6 +152,7 @@ void DeclarePanelSpriteObjectExtension(gd::PlatformExtension& extension) {
|
||||
.AddParameter("object", _("Object"), "PanelSprite")
|
||||
.UseStandardRelationalOperatorParameters(
|
||||
"number", gd::ParameterOptions::MakeNewOptions())
|
||||
.SetHidden()
|
||||
.SetFunctionName("SetHeight")
|
||||
.SetGetter("GetHeight");
|
||||
|
||||
@@ -179,8 +190,9 @@ void DeclarePanelSpriteObjectExtension(gd::PlatformExtension& extension) {
|
||||
.SetFunctionName("SetAngle")
|
||||
.SetGetter("GetAngle");
|
||||
|
||||
// Deprecated
|
||||
obj.AddAction("Image",
|
||||
_("Image name"),
|
||||
_("Image name (deprecated)"),
|
||||
_("Change the image of a Panel Sprite."),
|
||||
_("Set image _PARAM1_ on _PARAM0_"),
|
||||
_("Image"),
|
||||
@@ -189,5 +201,18 @@ void DeclarePanelSpriteObjectExtension(gd::PlatformExtension& extension) {
|
||||
.AddParameter("object", _("Object"), "PanelSprite")
|
||||
.AddParameter("string", _("Image name"))
|
||||
.AddCodeOnlyParameter("currentScene", "0")
|
||||
.SetHidden()
|
||||
.SetFunctionName("ChangeAndReloadImage");
|
||||
|
||||
obj.AddAction("SetImageFromResource",
|
||||
_("Image name"),
|
||||
_("Change the image of a Panel Sprite."),
|
||||
_("Set image _PARAM1_ on _PARAM0_"),
|
||||
_("Image"),
|
||||
"res/imageicon24.png",
|
||||
"res/imageicon.png")
|
||||
.AddParameter("object", _("Object"), "PanelSprite")
|
||||
.AddParameter("imageResource", _("Image file (or image resource name)"))
|
||||
.AddCodeOnlyParameter("currentScene", "0")
|
||||
.SetFunctionName("ChangeAndReloadImage");
|
||||
}
|
||||
|
@@ -61,6 +61,9 @@ class PanelSpriteObjectJsExtension : public gd::PlatformExtension {
|
||||
GetAllActionsForObject(
|
||||
"PanelSpriteObject::PanelSprite")["PanelSpriteObject::Image"]
|
||||
.SetFunctionName("setTexture");
|
||||
GetAllActionsForObject(
|
||||
"PanelSpriteObject::PanelSprite")["PanelSpriteObject::SetImageFromResource"]
|
||||
.SetFunctionName("setTexture");
|
||||
|
||||
GD_COMPLETE_EXTENSION_COMPILATION_INFORMATION();
|
||||
};
|
||||
|
@@ -27,7 +27,9 @@ namespace gdjs {
|
||||
/**
|
||||
* The PanelSpriteRuntimeObject displays a tiled texture.
|
||||
*/
|
||||
export class PanelSpriteRuntimeObject extends gdjs.RuntimeObject {
|
||||
export class PanelSpriteRuntimeObject
|
||||
extends gdjs.RuntimeObject
|
||||
implements gdjs.Resizable, gdjs.OpacityHandler {
|
||||
_rBorder: integer;
|
||||
_lBorder: integer;
|
||||
_tBorder: integer;
|
||||
@@ -190,10 +192,6 @@ namespace gdjs {
|
||||
return this._height;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the width of the panel sprite.
|
||||
* @param width The new width in pixels.
|
||||
*/
|
||||
setWidth(width: float): void {
|
||||
if (this._width === width) return;
|
||||
|
||||
@@ -202,10 +200,6 @@ namespace gdjs {
|
||||
this.invalidateHitboxes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the height of the panel sprite.
|
||||
* @param height The new height in pixels.
|
||||
*/
|
||||
setHeight(height: float): void {
|
||||
if (this._height === height) return;
|
||||
|
||||
@@ -214,10 +208,11 @@ namespace gdjs {
|
||||
this.invalidateHitboxes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the transparency of the object.
|
||||
* @param opacity The new opacity, between 0 (transparent) and 255 (opaque).
|
||||
*/
|
||||
setSize(newWidth: float, newHeight: float): void {
|
||||
this.setWidth(newWidth);
|
||||
this.setHeight(newHeight);
|
||||
}
|
||||
|
||||
setOpacity(opacity: float): void {
|
||||
if (opacity < 0) {
|
||||
opacity = 0;
|
||||
@@ -229,10 +224,6 @@ namespace gdjs {
|
||||
this._renderer.updateOpacity();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the transparency of the object.
|
||||
* @return The opacity, between 0 (transparent) and 255 (opaque).
|
||||
*/
|
||||
getOpacity(): number {
|
||||
return this.opacity;
|
||||
}
|
||||
@@ -258,10 +249,14 @@ namespace gdjs {
|
||||
// Implement support for get/set scale:
|
||||
|
||||
/**
|
||||
* Get scale of the tiled sprite object.
|
||||
* Get the scale of the object (or the geometric mean of the X and Y scale in case they are different).
|
||||
*
|
||||
* @return the scale of the object (or the geometric mean of the X and Y scale in case they are different).
|
||||
*/
|
||||
getScale(): float {
|
||||
return (this.getScaleX() + this.getScaleY()) / 2.0;
|
||||
const scaleX = Math.abs(this.getScaleX());
|
||||
const scaleY = Math.abs(this.getScaleY());
|
||||
return scaleX === scaleY ? scaleX : Math.sqrt(scaleX * scaleY);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -148,8 +148,9 @@ void ExtensionSubDeclaration3(gd::ObjectMetadata& obj) {
|
||||
gd::ParameterOptions::MakeNewOptions().SetDescription(
|
||||
_("Flow to compare to (in particles per second)")));
|
||||
|
||||
// Deprecated
|
||||
obj.AddAction("Texture",
|
||||
_("Particle image (using an expression)"),
|
||||
_("Particle image (deprecated)"),
|
||||
_("Change the image of particles (if displayed)."),
|
||||
_("Change the image of particles of _PARAM0_ to _PARAM1_"),
|
||||
_("Advanced"),
|
||||
@@ -157,7 +158,8 @@ void ExtensionSubDeclaration3(gd::ObjectMetadata& obj) {
|
||||
"CppPlatform/Extensions/particleSystemicon16.png")
|
||||
.AddParameter("object", _("Object"), "ParticleEmitter")
|
||||
.AddParameter("string", _("Image to use"))
|
||||
.SetParameterLongDescription("Indicate the name of the resource");
|
||||
.SetParameterLongDescription("Indicate the name of the resource")
|
||||
.SetHidden();
|
||||
|
||||
obj.AddAction("SetTextureFromResource",
|
||||
_("Particle image"),
|
||||
|
@@ -22,6 +22,7 @@ void DeclarePathfindingBehaviorExtension(gd::PlatformExtension& extension) {
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)")
|
||||
.SetCategory("Movement")
|
||||
.SetTags("pathfinding, obstacle, collision")
|
||||
.SetExtensionHelpPath("/behaviors/pathfinding");
|
||||
extension.AddInstructionOrExpressionGroupMetadata(_("Pathfinding behavior"))
|
||||
.SetIcon("CppPlatform/Extensions/AStaricon16.png");
|
||||
|
@@ -34,7 +34,8 @@ module.exports = {
|
||||
'MIT'
|
||||
)
|
||||
.setExtensionHelpPath('/behaviors/physics2')
|
||||
.setCategory('Movement');
|
||||
.setCategory('Movement')
|
||||
.setTags("physics, gravity, obstacle, collision");
|
||||
extension
|
||||
.addInstructionOrExpressionGroupMetadata(_('Physics Engine 2.0'))
|
||||
.setIcon('res/physics32.png');
|
||||
|
@@ -27,6 +27,7 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)")
|
||||
.SetCategory("Movement")
|
||||
.SetTags("platformer, platform, character, jump, obstacle, collision")
|
||||
.SetExtensionHelpPath("/behaviors/platformer");
|
||||
extension.AddInstructionOrExpressionGroupMetadata(_("Platform behavior"))
|
||||
.SetIcon("CppPlatform/Extensions/platformerobjecticon.png");
|
||||
|
@@ -31,7 +31,11 @@ void DeclarePrimitiveDrawingExtension(gd::PlatformExtension& extension) {
|
||||
_("Allows you to draw simple shapes on the screen using the "
|
||||
"events."),
|
||||
"CppPlatform/Extensions/primitivedrawingicon.png")
|
||||
.SetCategoryFullName(_("Advanced"));
|
||||
.SetCategoryFullName(_("Advanced"))
|
||||
.AddDefaultBehavior("EffectCapability::EffectBehavior")
|
||||
.AddDefaultBehavior("ResizableCapability::ResizableBehavior")
|
||||
.AddDefaultBehavior("ScalableCapability::ScalableBehavior")
|
||||
.AddDefaultBehavior("FlippableCapability::FlippableBehavior");
|
||||
|
||||
#if defined(GD_IDE_ONLY)
|
||||
obj.AddAction(
|
||||
@@ -612,6 +616,7 @@ void DeclarePrimitiveDrawingExtension(gd::PlatformExtension& extension) {
|
||||
.AddParameter("object", _("Shape Painter object"), "Drawer")
|
||||
.SetFunctionName("AreCoordinatesRelative");
|
||||
|
||||
// Deprecated
|
||||
obj.AddAction("Scale",
|
||||
_("Scale"),
|
||||
_("Modify the scale of the specified object."),
|
||||
@@ -624,8 +629,10 @@ void DeclarePrimitiveDrawingExtension(gd::PlatformExtension& extension) {
|
||||
"number",
|
||||
gd::ParameterOptions::MakeNewOptions().SetDescription(
|
||||
_("Scale (1 by default)")))
|
||||
.SetHidden()
|
||||
.MarkAsAdvanced();
|
||||
|
||||
// Deprecated
|
||||
obj.AddExpressionAndConditionAndAction("number",
|
||||
"ScaleX",
|
||||
_("Scale on X axis"),
|
||||
@@ -638,8 +645,10 @@ void DeclarePrimitiveDrawingExtension(gd::PlatformExtension& extension) {
|
||||
"number",
|
||||
gd::ParameterOptions::MakeNewOptions().SetDescription(
|
||||
_("Scale (1 by default)")))
|
||||
.SetHidden()
|
||||
.MarkAsAdvanced();
|
||||
|
||||
// Deprecated
|
||||
obj.AddExpressionAndConditionAndAction("number",
|
||||
"ScaleY",
|
||||
_("Scale on Y axis"),
|
||||
@@ -652,6 +661,7 @@ void DeclarePrimitiveDrawingExtension(gd::PlatformExtension& extension) {
|
||||
"number",
|
||||
gd::ParameterOptions::MakeNewOptions().SetDescription(
|
||||
_("Scale (1 by default)")))
|
||||
.SetHidden()
|
||||
.MarkAsAdvanced();
|
||||
|
||||
obj.AddAction("FlipX",
|
||||
@@ -663,6 +673,7 @@ void DeclarePrimitiveDrawingExtension(gd::PlatformExtension& extension) {
|
||||
"res/actions/flipX.png")
|
||||
.AddParameter("object", _("Object"), "Drawer")
|
||||
.AddParameter("yesorno", _("Activate flipping"))
|
||||
.SetHidden()
|
||||
.MarkAsSimple();
|
||||
|
||||
obj.AddAction("FlipY",
|
||||
@@ -674,6 +685,7 @@ void DeclarePrimitiveDrawingExtension(gd::PlatformExtension& extension) {
|
||||
"res/actions/flipY.png")
|
||||
.AddParameter("object", _("Object"), "Drawer")
|
||||
.AddParameter("yesorno", _("Activate flipping"))
|
||||
.SetHidden()
|
||||
.MarkAsSimple();
|
||||
|
||||
obj.AddCondition("FlippedX",
|
||||
@@ -683,7 +695,8 @@ void DeclarePrimitiveDrawingExtension(gd::PlatformExtension& extension) {
|
||||
_("Effects"),
|
||||
"res/actions/flipX24.png",
|
||||
"res/actions/flipX.png")
|
||||
.AddParameter("object", _("Object"), "Drawer");
|
||||
.AddParameter("object", _("Object"), "Drawer")
|
||||
.SetHidden();
|
||||
|
||||
obj.AddCondition("FlippedY",
|
||||
_("Vertically flipped"),
|
||||
@@ -692,8 +705,10 @@ void DeclarePrimitiveDrawingExtension(gd::PlatformExtension& extension) {
|
||||
_("Effects"),
|
||||
"res/actions/flipY24.png",
|
||||
"res/actions/flipY.png")
|
||||
.AddParameter("object", _("Object"), "Drawer");
|
||||
.AddParameter("object", _("Object"), "Drawer")
|
||||
.SetHidden();
|
||||
|
||||
// Deprecated
|
||||
obj.AddAction("Width",
|
||||
_("Width"),
|
||||
_("Change the width of an object."),
|
||||
@@ -704,8 +719,10 @@ void DeclarePrimitiveDrawingExtension(gd::PlatformExtension& extension) {
|
||||
.AddParameter("object", _("Object"), "Drawer")
|
||||
.UseStandardOperatorParameters("number",
|
||||
gd::ParameterOptions::MakeNewOptions())
|
||||
.SetHidden()
|
||||
.MarkAsAdvanced();
|
||||
|
||||
// Deprecated
|
||||
obj.AddAction("Height",
|
||||
_("Height"),
|
||||
_("Change the height of an object."),
|
||||
@@ -716,6 +733,7 @@ void DeclarePrimitiveDrawingExtension(gd::PlatformExtension& extension) {
|
||||
.AddParameter("object", _("Object"), "Drawer")
|
||||
.UseStandardOperatorParameters("number",
|
||||
gd::ParameterOptions::MakeNewOptions())
|
||||
.SetHidden()
|
||||
.MarkAsAdvanced();
|
||||
|
||||
obj.AddAction(
|
||||
|
@@ -40,7 +40,9 @@ namespace gdjs {
|
||||
/**
|
||||
* The ShapePainterRuntimeObject allows to draw graphics shapes on screen.
|
||||
*/
|
||||
export class ShapePainterRuntimeObject extends gdjs.RuntimeObject {
|
||||
export class ShapePainterRuntimeObject
|
||||
extends gdjs.RuntimeObject
|
||||
implements gdjs.Resizable, gdjs.Scalable, gdjs.Flippable {
|
||||
_scaleX: number = 1;
|
||||
_scaleY: number = 1;
|
||||
_blendMode: number = 0;
|
||||
@@ -555,11 +557,6 @@ namespace gdjs {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the width of the object. This changes the scale on X axis of the object.
|
||||
*
|
||||
* @param newWidth The new width of the object, in pixels.
|
||||
*/
|
||||
setWidth(newWidth: float): void {
|
||||
const unscaledWidth = this._renderer.getUnscaledWidth();
|
||||
if (unscaledWidth !== 0) {
|
||||
@@ -567,11 +564,6 @@ namespace gdjs {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the height of the object. This changes the scale on Y axis of the object.
|
||||
*
|
||||
* @param newHeight The new height of the object, in pixels.
|
||||
*/
|
||||
setHeight(newHeight: float): void {
|
||||
const unscaledHeight = this._renderer.getUnscaledHeight();
|
||||
if (unscaledHeight !== 0) {
|
||||
@@ -579,6 +571,11 @@ namespace gdjs {
|
||||
}
|
||||
}
|
||||
|
||||
setSize(newWidth: float, newHeight: float): void {
|
||||
this.setWidth(newWidth);
|
||||
this.setHeight(newHeight);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the scale on X and Y axis of the object.
|
||||
*
|
||||
|
@@ -283,11 +283,13 @@ module.exports = {
|
||||
textInputObject
|
||||
)
|
||||
.setCategoryFullName(_('User interface'))
|
||||
.addUnsupportedBaseObjectCapability('effect')
|
||||
// Effects are unsupported because the object is not rendered with PIXI.
|
||||
.setIncludeFile('Extensions/TextInput/textinputruntimeobject.js')
|
||||
.addIncludeFile(
|
||||
'Extensions/TextInput/textinputruntimeobject-pixi-renderer.js'
|
||||
);
|
||||
)
|
||||
.addDefaultBehavior('ResizableCapability::ResizableBehavior')
|
||||
.addDefaultBehavior('OpacityCapability::OpacityBehavior');
|
||||
|
||||
// Properties expressions/conditions/actions:
|
||||
object
|
||||
@@ -525,6 +527,8 @@ module.exports = {
|
||||
.setGetter('isDisabled');
|
||||
|
||||
// Other expressions/conditions/actions:
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addExpressionAndConditionAndAction(
|
||||
'number',
|
||||
@@ -543,7 +547,8 @@ module.exports = {
|
||||
)
|
||||
)
|
||||
.setFunctionName('setOpacity')
|
||||
.setGetter('getOpacity');
|
||||
.setGetter('getOpacity')
|
||||
.setHidden();
|
||||
|
||||
object
|
||||
.addScopedCondition(
|
||||
|
@@ -48,7 +48,9 @@ namespace gdjs {
|
||||
/**
|
||||
* Shows a text input on the screen the player can type text into.
|
||||
*/
|
||||
export class TextInputRuntimeObject extends gdjs.RuntimeObject {
|
||||
export class TextInputRuntimeObject
|
||||
extends gdjs.RuntimeObject
|
||||
implements gdjs.Resizable, gdjs.OpacityHandler {
|
||||
private _string: string;
|
||||
private _placeholder: string;
|
||||
private opacity: float = 255;
|
||||
@@ -202,33 +204,24 @@ namespace gdjs {
|
||||
this._renderer.onDestroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set object opacity.
|
||||
*/
|
||||
setOpacity(opacity): void {
|
||||
setOpacity(opacity: float): void {
|
||||
this.opacity = Math.max(0, Math.min(255, opacity));
|
||||
this._renderer.updateOpacity();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get object opacity.
|
||||
*/
|
||||
getOpacity() {
|
||||
getOpacity(): float {
|
||||
return this.opacity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the width of the object, if applicable.
|
||||
* @param width The new width in pixels.
|
||||
*/
|
||||
setSize(width: number, height: number): void {
|
||||
this.setWidth(width);
|
||||
this.setHeight(height);
|
||||
}
|
||||
|
||||
setWidth(width: float): void {
|
||||
this._width = width;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the height of the object, if applicable.
|
||||
* @param height The new height in pixels.
|
||||
*/
|
||||
setHeight(height: float): void {
|
||||
this._height = height;
|
||||
}
|
||||
|
@@ -34,7 +34,10 @@ void DeclareTextObjectExtension(gd::PlatformExtension& extension) {
|
||||
_("Text"),
|
||||
_("Displays a text on the screen."),
|
||||
"CppPlatform/Extensions/texticon.png")
|
||||
.SetCategoryFullName(_("Text"));
|
||||
.SetCategoryFullName(_("Text"))
|
||||
.AddDefaultBehavior("EffectCapability::EffectBehavior")
|
||||
.AddDefaultBehavior("ScalableCapability::ScalableBehavior")
|
||||
.AddDefaultBehavior("OpacityCapability::OpacityBehavior");
|
||||
|
||||
obj.AddAction("String",
|
||||
_("Modify the text"),
|
||||
@@ -78,6 +81,7 @@ void DeclareTextObjectExtension(gd::PlatformExtension& extension) {
|
||||
.AddParameter("police", _("Font"))
|
||||
.SetFunctionName("ChangeFont");
|
||||
|
||||
// Deprecated
|
||||
obj.AddCondition("ScaleX",
|
||||
_("Scale on X axis"),
|
||||
_("Compare the scale of the text on the X axis"),
|
||||
@@ -91,8 +95,10 @@ void DeclareTextObjectExtension(gd::PlatformExtension& extension) {
|
||||
"number",
|
||||
gd::ParameterOptions::MakeNewOptions().SetDescription(
|
||||
_("Scale to compare to (1 by default)")))
|
||||
.SetHidden()
|
||||
.SetFunctionName("GetScaleX");
|
||||
|
||||
// Deprecated
|
||||
obj.AddAction(
|
||||
"ScaleX",
|
||||
_("Scale on X axis"),
|
||||
@@ -107,8 +113,10 @@ void DeclareTextObjectExtension(gd::PlatformExtension& extension) {
|
||||
"number",
|
||||
gd::ParameterOptions::MakeNewOptions().SetDescription(
|
||||
_("Scale (1 by default)")))
|
||||
.SetHidden()
|
||||
.SetFunctionName("SetScaleX");
|
||||
|
||||
// Deprecated
|
||||
obj.AddCondition("ScaleY",
|
||||
_("Scale on Y axis"),
|
||||
_("Compare the scale of the text on the Y axis"),
|
||||
@@ -122,8 +130,10 @@ void DeclareTextObjectExtension(gd::PlatformExtension& extension) {
|
||||
"number",
|
||||
gd::ParameterOptions::MakeNewOptions().SetDescription(
|
||||
_("Scale to compare to (1 by default)")))
|
||||
.SetHidden()
|
||||
.SetFunctionName("GetScaleY");
|
||||
|
||||
// Deprecated
|
||||
obj.AddAction(
|
||||
"ScaleY",
|
||||
_("Scale on Y axis"),
|
||||
@@ -138,8 +148,10 @@ void DeclareTextObjectExtension(gd::PlatformExtension& extension) {
|
||||
"number",
|
||||
gd::ParameterOptions::MakeNewOptions().SetDescription(
|
||||
_("Scale (1 by default)")))
|
||||
.SetHidden()
|
||||
.SetFunctionName("SetScaleY");
|
||||
|
||||
// Deprecated
|
||||
obj.AddAction(
|
||||
"Scale",
|
||||
_("Scale"),
|
||||
@@ -154,6 +166,7 @@ void DeclareTextObjectExtension(gd::PlatformExtension& extension) {
|
||||
"number",
|
||||
gd::ParameterOptions::MakeNewOptions().SetDescription(
|
||||
_("Scale (1 by default)")))
|
||||
.SetHidden()
|
||||
.SetFunctionName("SetScale");
|
||||
|
||||
obj.AddAction(
|
||||
@@ -228,6 +241,7 @@ void DeclareTextObjectExtension(gd::PlatformExtension& extension) {
|
||||
.AddParameter("object", _("Object"), "Text")
|
||||
.AddParameter("yesorno", _("Show the shadow"));
|
||||
|
||||
// Deprecated
|
||||
obj.AddAction("Opacity",
|
||||
_("Text opacity"),
|
||||
_("Change the opacity of a Text. 0 is fully transparent, 255 "
|
||||
@@ -245,6 +259,7 @@ void DeclareTextObjectExtension(gd::PlatformExtension& extension) {
|
||||
.SetFunctionName("SetOpacity")
|
||||
.SetGetter("GetOpacity");
|
||||
|
||||
// Deprecated
|
||||
obj.AddCondition("Opacity",
|
||||
_("Opacity"),
|
||||
_("Compare the opacity of a Text object, between 0 (fully "
|
||||
@@ -497,22 +512,27 @@ void DeclareTextObjectExtension(gd::PlatformExtension& extension) {
|
||||
"res/actions/textPadding_black.png")
|
||||
.AddParameter("object", _("Object"), "Text");
|
||||
|
||||
// Deprecated
|
||||
obj.AddExpression("ScaleX",
|
||||
_("X Scale of a Text object"),
|
||||
_("X Scale of a Text object"),
|
||||
_("Scale"),
|
||||
"res/actions/scaleWidth_black.png")
|
||||
.AddParameter("object", _("Object"), "Text")
|
||||
.SetHidden()
|
||||
.SetFunctionName("GetScaleX");
|
||||
|
||||
// Deprecated
|
||||
obj.AddExpression("ScaleY",
|
||||
_("Y Scale of a Text object"),
|
||||
_("Y Scale of a Text object"),
|
||||
_("Scale"),
|
||||
"res/actions/scaleHeight_black.png")
|
||||
.AddParameter("object", _("Object"), "Text")
|
||||
.SetHidden()
|
||||
.SetFunctionName("GetScaleY");
|
||||
|
||||
// Deprecated
|
||||
obj.AddExpression("Opacity",
|
||||
_("Opacity of a Text object"),
|
||||
_("Opacity of a Text object"),
|
||||
|
@@ -31,7 +31,7 @@ class TextObjectJsExtension : public gd::PlatformExtension {
|
||||
"Extensions/TextObject/textruntimeobject-pixi-renderer.js");
|
||||
GetAllActionsForObject("TextObject::Text")["TextObject::Scale"]
|
||||
.SetFunctionName("setScale")
|
||||
.SetGetter("getScale");
|
||||
.SetGetter("getScaleMean");
|
||||
GetAllActionsForObject("TextObject::Text")["TextObject::ScaleX"]
|
||||
.SetFunctionName("setScaleX")
|
||||
.SetGetter("getScaleX");
|
||||
|
@@ -34,7 +34,9 @@ namespace gdjs {
|
||||
/**
|
||||
* Displays a text.
|
||||
*/
|
||||
export class TextRuntimeObject extends gdjs.RuntimeObject {
|
||||
export class TextRuntimeObject
|
||||
extends gdjs.RuntimeObject
|
||||
implements gdjs.OpacityHandler {
|
||||
_characterSize: number;
|
||||
_fontName: string;
|
||||
_bold: boolean;
|
||||
@@ -304,10 +306,24 @@ namespace gdjs {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get scale of the text.
|
||||
* Get the scale of the object (or the arithmetic mean of the X and Y scale in case they are different).
|
||||
*
|
||||
* @return the scale of the object (or the arithmetic mean of the X and Y scale in case they are different).
|
||||
* @deprecated Use `getScale` instead.
|
||||
*/
|
||||
getScaleMean(): float {
|
||||
return (Math.abs(this._scaleX) + Math.abs(this._scaleY)) / 2.0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the scale of the object (or the geometric mean of the X and Y scale in case they are different).
|
||||
*
|
||||
* @return the scale of the object (or the geometric mean of the X and Y scale in case they are different).
|
||||
*/
|
||||
getScale(): float {
|
||||
return (Math.abs(this._scaleX) + Math.abs(this._scaleY)) / 2.0;
|
||||
const scaleX = Math.abs(this._scaleX);
|
||||
const scaleY = Math.abs(this._scaleY);
|
||||
return scaleX === scaleY ? scaleX : Math.sqrt(scaleX * scaleY);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -205,6 +205,10 @@ const defineTileMap = function (
|
||||
objectTileMap
|
||||
)
|
||||
.setCategoryFullName(_('Advanced'))
|
||||
.addDefaultBehavior('EffectCapability::EffectBehavior')
|
||||
.addDefaultBehavior('ResizableCapability::ResizableBehavior')
|
||||
.addDefaultBehavior('ScalableCapability::ScalableBehavior')
|
||||
.addDefaultBehavior('OpacityCapability::OpacityBehavior')
|
||||
.setIncludeFile('Extensions/TileMap/tilemapruntimeobject.js')
|
||||
.addIncludeFile('Extensions/TileMap/TileMapRuntimeManager.js')
|
||||
.addIncludeFile('Extensions/TileMap/tilemapruntimeobject-pixi-renderer.js')
|
||||
@@ -495,6 +499,7 @@ const defineTileMap = function (
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('getAnimationFps');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addAction(
|
||||
'Scale',
|
||||
@@ -513,10 +518,12 @@ const defineTileMap = function (
|
||||
)
|
||||
)
|
||||
.markAsAdvanced()
|
||||
.setHidden()
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('setScale')
|
||||
.setGetter('getScale');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addExpressionAndConditionAndAction(
|
||||
'number',
|
||||
@@ -535,9 +542,11 @@ const defineTileMap = function (
|
||||
)
|
||||
)
|
||||
.markAsAdvanced()
|
||||
.setHidden()
|
||||
.setFunctionName('setScaleX')
|
||||
.setGetter('getScaleX');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addExpressionAndConditionAndAction(
|
||||
'number',
|
||||
@@ -556,9 +565,11 @@ const defineTileMap = function (
|
||||
)
|
||||
)
|
||||
.markAsAdvanced()
|
||||
.setHidden()
|
||||
.setFunctionName('setScaleY')
|
||||
.setGetter('getScaleY');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addAction(
|
||||
'Width',
|
||||
@@ -575,9 +586,11 @@ const defineTileMap = function (
|
||||
gd.ParameterOptions.makeNewOptions()
|
||||
)
|
||||
.markAsAdvanced()
|
||||
.setHidden()
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('setWidth');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addAction(
|
||||
'Height',
|
||||
@@ -594,6 +607,7 @@ const defineTileMap = function (
|
||||
gd.ParameterOptions.makeNewOptions()
|
||||
)
|
||||
.markAsAdvanced()
|
||||
.setHidden()
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('setHeight');
|
||||
};
|
||||
@@ -789,6 +803,9 @@ const defineCollisionMask = function (
|
||||
collisionMaskObject
|
||||
)
|
||||
.setCategoryFullName(_('Advanced'))
|
||||
.addDefaultBehavior('EffectCapability::EffectBehavior')
|
||||
.addDefaultBehavior('ResizableCapability::ResizableBehavior')
|
||||
.addDefaultBehavior('ScalableCapability::ScalableBehavior')
|
||||
.setIncludeFile('Extensions/TileMap/tilemapcollisionmaskruntimeobject.js')
|
||||
.addIncludeFile('Extensions/TileMap/TileMapRuntimeManager.js')
|
||||
.addIncludeFile('Extensions/TileMap/pako/dist/pako.min.js')
|
||||
@@ -882,6 +899,7 @@ const defineCollisionMask = function (
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('setTilesetJsonFile');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addScopedAction(
|
||||
'Scale',
|
||||
@@ -905,10 +923,12 @@ const defineCollisionMask = function (
|
||||
)
|
||||
)
|
||||
.markAsAdvanced()
|
||||
.setHidden()
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('setScale')
|
||||
.setGetter('getScale');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addExpressionAndConditionAndAction(
|
||||
'number',
|
||||
@@ -932,9 +952,11 @@ const defineCollisionMask = function (
|
||||
)
|
||||
)
|
||||
.markAsAdvanced()
|
||||
.setHidden()
|
||||
.setFunctionName('setScaleX')
|
||||
.setGetter('getScaleX');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addExpressionAndConditionAndAction(
|
||||
'number',
|
||||
@@ -958,9 +980,11 @@ const defineCollisionMask = function (
|
||||
)
|
||||
)
|
||||
.markAsAdvanced()
|
||||
.setHidden()
|
||||
.setFunctionName('setScaleY')
|
||||
.setGetter('getScaleY');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addScopedAction(
|
||||
'Width',
|
||||
@@ -982,9 +1006,11 @@ const defineCollisionMask = function (
|
||||
gd.ParameterOptions.makeNewOptions()
|
||||
)
|
||||
.markAsAdvanced()
|
||||
.setHidden()
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('setWidth');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addScopedAction(
|
||||
'Height',
|
||||
@@ -1006,6 +1032,7 @@ const defineCollisionMask = function (
|
||||
gd.ParameterOptions.makeNewOptions()
|
||||
)
|
||||
.markAsAdvanced()
|
||||
.setHidden()
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('setHeight');
|
||||
};
|
||||
|
@@ -4,7 +4,9 @@ namespace gdjs {
|
||||
* An object that handle hitboxes for a tile map.
|
||||
* @extends gdjs.RuntimeObject
|
||||
*/
|
||||
export class TileMapCollisionMaskRuntimeObject extends gdjs.RuntimeObject {
|
||||
export class TileMapCollisionMaskRuntimeObject
|
||||
extends gdjs.RuntimeObject
|
||||
implements gdjs.Resizable, gdjs.Scalable {
|
||||
private _tilemapJsonFile: string;
|
||||
private _tilesetJsonFile: string;
|
||||
private _renderer: gdjs.TileMap.TileMapCollisionMaskRenderer;
|
||||
@@ -460,11 +462,6 @@ namespace gdjs {
|
||||
this._transformationIsUpToDate = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the width of the object. This changes the scale on X axis of the object.
|
||||
*
|
||||
* @param width The new width of the object, in pixels.
|
||||
*/
|
||||
setWidth(width: float): void {
|
||||
if (this._width === width) {
|
||||
return;
|
||||
@@ -475,11 +472,6 @@ namespace gdjs {
|
||||
this.invalidateHitboxes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the height of the object. This changes the scale on Y axis of the object.
|
||||
*
|
||||
* @param height The new height of the object, in pixels.
|
||||
*/
|
||||
setHeight(height: float): void {
|
||||
if (this._height === height) {
|
||||
return;
|
||||
@@ -490,12 +482,17 @@ namespace gdjs {
|
||||
this.invalidateHitboxes();
|
||||
}
|
||||
|
||||
setSize(newWidth: float, newHeight: float): void {
|
||||
this.setWidth(newWidth);
|
||||
this.setHeight(newHeight);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the scale of the object (or the geometric mean of the X and Y scale in case they are different).
|
||||
*
|
||||
* @return the scale of the object (or the geometric mean of the X and Y scale in case they are different).
|
||||
*/
|
||||
getScale(): number {
|
||||
getScale(): float {
|
||||
const scaleX = this.getScaleX();
|
||||
const scaleY = this.getScaleY();
|
||||
return scaleX === scaleY ? scaleX : Math.sqrt(scaleX * scaleY);
|
||||
|
@@ -5,7 +5,9 @@ namespace gdjs {
|
||||
/**
|
||||
* Displays a Tilemap object (mapeditor.org supported).
|
||||
*/
|
||||
export class TileMapRuntimeObject extends gdjs.RuntimeObject {
|
||||
export class TileMapRuntimeObject
|
||||
extends gdjs.RuntimeObject
|
||||
implements gdjs.Resizable, gdjs.Scalable, gdjs.OpacityHandler {
|
||||
_frameElapsedTime: float = 0;
|
||||
_opacity: float;
|
||||
_tilemapJsonFile: string;
|
||||
@@ -234,11 +236,6 @@ namespace gdjs {
|
||||
return this._animationSpeedScale;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the width of the object. This changes the scale on X axis of the object.
|
||||
*
|
||||
* @param width The new width of the object, in pixels.
|
||||
*/
|
||||
setWidth(width: float): void {
|
||||
if (this.getWidth() === width) return;
|
||||
|
||||
@@ -246,11 +243,6 @@ namespace gdjs {
|
||||
this.invalidateHitboxes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the height of the object. This changes the scale on Y axis of the object.
|
||||
*
|
||||
* @param height The new height of the object, in pixels.
|
||||
*/
|
||||
setHeight(height: float): void {
|
||||
if (this.getHeight() === height) return;
|
||||
|
||||
@@ -258,12 +250,17 @@ namespace gdjs {
|
||||
this.invalidateHitboxes();
|
||||
}
|
||||
|
||||
setSize(newWidth: float, newHeight: float): void {
|
||||
this.setWidth(newWidth);
|
||||
this.setHeight(newHeight);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the scale of the object (or the geometric mean of the X and Y scale in case they are different).
|
||||
*
|
||||
* @return the scale of the object (or the geometric mean of the X and Y scale in case they are different).
|
||||
*/
|
||||
getScale(): number {
|
||||
getScale(): float {
|
||||
const scaleX = this.getScaleX();
|
||||
const scaleY = this.getScaleY();
|
||||
return scaleX === scaleY ? scaleX : Math.sqrt(scaleX * scaleY);
|
||||
@@ -324,18 +321,11 @@ namespace gdjs {
|
||||
this._renderer.updateAngle();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set object opacity.
|
||||
* @param opacity The new opacity of the object (0-255).
|
||||
*/
|
||||
setOpacity(opacity: float): void {
|
||||
this._opacity = opacity;
|
||||
this._renderer.updateOpacity();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get object opacity.
|
||||
*/
|
||||
getOpacity(): float {
|
||||
return this._opacity;
|
||||
}
|
||||
|
@@ -34,8 +34,12 @@ void DeclareTiledSpriteObjectExtension(gd::PlatformExtension& extension) {
|
||||
_("Tiled Sprite"),
|
||||
_("Displays an image repeated over an area."),
|
||||
"CppPlatform/Extensions/TiledSpriteIcon.png")
|
||||
.AddDefaultBehavior("EffectCapability::EffectBehavior")
|
||||
.AddDefaultBehavior("ResizableCapability::ResizableBehavior")
|
||||
.AddDefaultBehavior("OpacityCapability::OpacityBehavior")
|
||||
.SetCategoryFullName(_("General"));
|
||||
|
||||
// Deprecated
|
||||
obj.AddCondition("Opacity",
|
||||
_("Opacity"),
|
||||
_("Compare the opacity of a Tiled Sprite, between 0 (fully "
|
||||
@@ -49,8 +53,10 @@ void DeclareTiledSpriteObjectExtension(gd::PlatformExtension& extension) {
|
||||
.UseStandardRelationalOperatorParameters(
|
||||
"number",
|
||||
gd::ParameterOptions::MakeNewOptions().SetDescription(
|
||||
_("Opacity to compare to (0-255)")));
|
||||
_("Opacity to compare to (0-255)")))
|
||||
.SetHidden();
|
||||
|
||||
// Deprecated
|
||||
obj.AddAction(
|
||||
"SetOpacity",
|
||||
_("Change Tiled Sprite opacity"),
|
||||
@@ -65,14 +71,17 @@ void DeclareTiledSpriteObjectExtension(gd::PlatformExtension& extension) {
|
||||
.UseStandardOperatorParameters(
|
||||
"number",
|
||||
gd::ParameterOptions::MakeNewOptions().SetDescription(
|
||||
_("Opacity (0-255)")));
|
||||
_("Opacity (0-255)")))
|
||||
.SetHidden();
|
||||
|
||||
// Deprecated
|
||||
obj.AddExpression("Opacity",
|
||||
_("Opacity"),
|
||||
_("Opacity"),
|
||||
_("Visibility"),
|
||||
"res/actions/opacity.png")
|
||||
.AddParameter("object", _("Object"), "TiledSprite");
|
||||
.AddParameter("object", _("Object"), "TiledSprite")
|
||||
.SetHidden();
|
||||
|
||||
obj.AddAction(
|
||||
"SetColor",
|
||||
@@ -86,6 +95,7 @@ void DeclareTiledSpriteObjectExtension(gd::PlatformExtension& extension) {
|
||||
.AddParameter("object", _("Object"), "TiledSprite")
|
||||
.AddParameter("color", _("Tint"));
|
||||
|
||||
// Deprecated
|
||||
obj.AddAction("Width",
|
||||
_("Width"),
|
||||
_("Modify the width of a Tiled Sprite."),
|
||||
@@ -97,9 +107,11 @@ void DeclareTiledSpriteObjectExtension(gd::PlatformExtension& extension) {
|
||||
.AddParameter("object", _("Object"), "TiledSprite")
|
||||
.UseStandardOperatorParameters("number",
|
||||
gd::ParameterOptions::MakeNewOptions())
|
||||
.SetHidden()
|
||||
.SetFunctionName("SetWidth")
|
||||
.SetGetter("GetWidth");
|
||||
|
||||
// Deprecated
|
||||
obj.AddCondition("Width",
|
||||
_("Width"),
|
||||
_("Test the width of a Tiled Sprite."),
|
||||
@@ -111,8 +123,10 @@ void DeclareTiledSpriteObjectExtension(gd::PlatformExtension& extension) {
|
||||
.UseStandardRelationalOperatorParameters(
|
||||
"number", gd::ParameterOptions::MakeNewOptions())
|
||||
.MarkAsAdvanced()
|
||||
.SetHidden()
|
||||
.SetFunctionName("GetWidth");
|
||||
|
||||
// Deprecated
|
||||
obj.AddAction("Height",
|
||||
_("Height"),
|
||||
_("Modify the height of a Tiled Sprite."),
|
||||
@@ -124,9 +138,11 @@ void DeclareTiledSpriteObjectExtension(gd::PlatformExtension& extension) {
|
||||
.AddParameter("object", _("Object"), "TiledSprite")
|
||||
.UseStandardOperatorParameters("number",
|
||||
gd::ParameterOptions::MakeNewOptions())
|
||||
.SetHidden()
|
||||
.SetFunctionName("SetHeight")
|
||||
.SetGetter("GetHeight");
|
||||
|
||||
// Deprecated
|
||||
obj.AddCondition("Height",
|
||||
_("Height"),
|
||||
_("Test the height of a Tiled Sprite."),
|
||||
@@ -138,8 +154,10 @@ void DeclareTiledSpriteObjectExtension(gd::PlatformExtension& extension) {
|
||||
.UseStandardRelationalOperatorParameters(
|
||||
"number", gd::ParameterOptions::MakeNewOptions())
|
||||
.MarkAsAdvanced()
|
||||
.SetHidden()
|
||||
.SetFunctionName("GetHeight");
|
||||
|
||||
// Deprecated
|
||||
obj.AddAction("SetSize",
|
||||
_("Size"),
|
||||
_("Modify the size of a Tiled Sprite."),
|
||||
@@ -151,6 +169,7 @@ void DeclareTiledSpriteObjectExtension(gd::PlatformExtension& extension) {
|
||||
.AddParameter("object", _("Object"), "TiledSprite")
|
||||
.AddParameter("expression", _("Width"))
|
||||
.AddParameter("expression", _("Height"))
|
||||
.SetHidden()
|
||||
.SetFunctionName("SetSize");
|
||||
|
||||
// Deprecated: now available for all objects.
|
||||
|
@@ -17,7 +17,9 @@ namespace gdjs {
|
||||
/**
|
||||
* The TiledSpriteRuntimeObject displays a tiled texture.
|
||||
*/
|
||||
export class TiledSpriteRuntimeObject extends gdjs.RuntimeObject {
|
||||
export class TiledSpriteRuntimeObject
|
||||
extends gdjs.RuntimeObject
|
||||
implements gdjs.Resizable, gdjs.OpacityHandler {
|
||||
_xOffset: float = 0;
|
||||
_yOffset: float = 0;
|
||||
opacity: float = 255;
|
||||
@@ -209,10 +211,6 @@ namespace gdjs {
|
||||
return this._yOffset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the transparency of the object.
|
||||
* @param opacity The new opacity, between 0 (transparent) and 255 (opaque).
|
||||
*/
|
||||
setOpacity(opacity: float): void {
|
||||
if (opacity < 0) {
|
||||
opacity = 0;
|
||||
@@ -224,10 +222,6 @@ namespace gdjs {
|
||||
this._renderer.updateOpacity();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the transparency of the object.
|
||||
* @return The opacity, between 0 (transparent) and 255 (opaque).
|
||||
*/
|
||||
getOpacity(): number {
|
||||
return this.opacity;
|
||||
}
|
||||
@@ -253,10 +247,14 @@ namespace gdjs {
|
||||
// Implement support for get/set scale:
|
||||
|
||||
/**
|
||||
* Get scale of the tiled sprite object.
|
||||
* Get the scale of the object (or the geometric mean of the X and Y scale in case they are different).
|
||||
*
|
||||
* @return the scale of the object (or the geometric mean of the X and Y scale in case they are different).
|
||||
*/
|
||||
getScale(): float {
|
||||
return (this.getScaleX() + this.getScaleY()) / 2.0;
|
||||
const scaleX = Math.abs(this.getScaleX());
|
||||
const scaleY = Math.abs(this.getScaleY());
|
||||
return scaleX === scaleY ? scaleX : Math.sqrt(scaleX * scaleY);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -21,6 +21,7 @@ void DeclareTopDownMovementBehaviorExtension(gd::PlatformExtension& extension) {
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)")
|
||||
.SetCategory("Movement")
|
||||
.SetTags("top-down")
|
||||
.SetExtensionHelpPath("/behaviors/topdown");
|
||||
extension.AddInstructionOrExpressionGroupMetadata(_("Top-down movement"))
|
||||
.SetIcon("CppPlatform/Extensions/topdownmovementicon16.png");
|
||||
|
@@ -74,6 +74,7 @@ module.exports = {
|
||||
'Open source (MIT License)'
|
||||
)
|
||||
.setCategory('Visual effect')
|
||||
.setTags("tween, interpolation, smooth")
|
||||
.setExtensionHelpPath('/behaviors/tween');
|
||||
extension
|
||||
.addInstructionOrExpressionGroupMetadata(_('Tweening'))
|
||||
@@ -708,7 +709,7 @@ module.exports = {
|
||||
_(
|
||||
'Tween the scale of _PARAM0_ to X-scale: _PARAM3_, Y-scale: _PARAM4_ (from center: _PARAM8_) with easing _PARAM5_ over _PARAM6_ms as _PARAM2_'
|
||||
),
|
||||
_('Scale'),
|
||||
_('Size'),
|
||||
'JsPlatform/Extensions/tween_behavior24.png',
|
||||
'JsPlatform/Extensions/tween_behavior32.png'
|
||||
)
|
||||
@@ -742,7 +743,7 @@ module.exports = {
|
||||
_(
|
||||
'Tween the X-scale of _PARAM0_ to _PARAM3_ (from center: _PARAM7_) with easing _PARAM4_ over _PARAM5_ms as _PARAM2_'
|
||||
),
|
||||
_('Scale'),
|
||||
_('Size'),
|
||||
'JsPlatform/Extensions/tween_behavior24.png',
|
||||
'JsPlatform/Extensions/tween_behavior32.png'
|
||||
)
|
||||
@@ -775,7 +776,7 @@ module.exports = {
|
||||
_(
|
||||
'Tween the Y-scale of _PARAM0_ to _PARAM3_ (from center: _PARAM7_) with easing _PARAM4_ over _PARAM5_ms as _PARAM2_'
|
||||
),
|
||||
_('Scale'),
|
||||
_('Size'),
|
||||
'JsPlatform/Extensions/tween_behavior24.png',
|
||||
'JsPlatform/Extensions/tween_behavior32.png'
|
||||
)
|
||||
@@ -839,7 +840,7 @@ module.exports = {
|
||||
_(
|
||||
'Tween the opacity of _PARAM0_ to _PARAM3_ with easing _PARAM4_ over _PARAM5_ms as _PARAM2_'
|
||||
),
|
||||
_('Opacity'),
|
||||
_('Visibility'),
|
||||
'JsPlatform/Extensions/tween_behavior24.png',
|
||||
'JsPlatform/Extensions/tween_behavior32.png'
|
||||
)
|
||||
|
@@ -8,6 +8,8 @@
|
||||
#include "GDCore/Events/Tools/EventsCodeNameMangler.h"
|
||||
#include "GDCore/Extensions/Metadata/MultipleInstructionMetadata.h"
|
||||
#include "GDCore/Extensions/PlatformExtension.h"
|
||||
#include "GDCore/Project/CustomBehavior.h"
|
||||
#include "GDCore/Project/CustomBehaviorsSharedData.h"
|
||||
#include "GDCore/Project/EventsBasedObject.h"
|
||||
#include "GDCore/Project/EventsFunctionsExtension.h"
|
||||
#include "GDCore/Project/Project.h"
|
||||
@@ -34,6 +36,10 @@ void MetadataDeclarationHelper::DeclareExtension(
|
||||
.SetExtensionHelpPath(eventsFunctionsExtension.GetHelpPath())
|
||||
.SetIconUrl(eventsFunctionsExtension.GetIconUrl());
|
||||
|
||||
for(auto tag : eventsFunctionsExtension.GetTags()) {
|
||||
extension.AddTag(tag);
|
||||
}
|
||||
|
||||
if (!fullName.empty()) {
|
||||
extension.AddInstructionOrExpressionGroupMetadata(fullName).SetIcon(
|
||||
eventsFunctionsExtension.GetIconUrl());
|
||||
@@ -71,15 +77,26 @@ const gd::String &MetadataDeclarationHelper::GetExtensionIconUrl(
|
||||
* events based behavior.
|
||||
*/
|
||||
gd::BehaviorMetadata &MetadataDeclarationHelper::DeclareBehaviorMetadata(
|
||||
const gd::Project &project,
|
||||
gd::PlatformExtension &extension,
|
||||
const gd::EventsBasedBehavior &eventsBasedBehavior) {
|
||||
auto &behaviorMetadata =
|
||||
extension
|
||||
.AddEventsBasedBehavior(eventsBasedBehavior.GetName(),
|
||||
eventsBasedBehavior.GetFullName() ||
|
||||
eventsBasedBehavior.GetName(),
|
||||
eventsBasedBehavior.GetDescription(), "",
|
||||
GetExtensionIconUrl(extension))
|
||||
.AddBehavior(
|
||||
eventsBasedBehavior.GetName(),
|
||||
eventsBasedBehavior.GetFullName() ||
|
||||
eventsBasedBehavior.GetName(),
|
||||
eventsBasedBehavior.GetName(),
|
||||
eventsBasedBehavior.GetDescription(), "",
|
||||
GetExtensionIconUrl(extension), "",
|
||||
std::make_shared<gd::CustomBehavior>(
|
||||
eventsBasedBehavior.GetName(), project,
|
||||
PlatformExtension::GetBehaviorFullType(
|
||||
extension.GetName(), eventsBasedBehavior.GetName())),
|
||||
std::make_shared<gd::CustomBehaviorsSharedData>(
|
||||
eventsBasedBehavior.GetName(), project,
|
||||
PlatformExtension::GetBehaviorFullType(
|
||||
extension.GetName(), eventsBasedBehavior.GetName())))
|
||||
.SetObjectType(eventsBasedBehavior.GetObjectType());
|
||||
|
||||
if (eventsBasedBehavior.IsPrivate())
|
||||
@@ -107,12 +124,19 @@ gd::ObjectMetadata &MetadataDeclarationHelper::DeclareObjectMetadata(
|
||||
// several categories, we can assume it"s not scoped correctly.
|
||||
// Note: EventsFunctionsExtension should be used instead of
|
||||
// PlatformExtension but this line will be removed soon.
|
||||
.SetCategoryFullName(extension.GetCategory());
|
||||
.SetCategoryFullName(extension.GetCategory())
|
||||
// Update Project::CreateObject when default behavior are added.
|
||||
.AddDefaultBehavior("EffectCapability::EffectBehavior")
|
||||
.AddDefaultBehavior("ResizableCapability::ResizableBehavior")
|
||||
.AddDefaultBehavior("ScalableCapability::ScalableBehavior")
|
||||
.AddDefaultBehavior("FlippableCapability::FlippableBehavior")
|
||||
.AddDefaultBehavior("OpacityCapability::OpacityBehavior");
|
||||
|
||||
// TODO EBO Use full type to identify object to avoid collision.
|
||||
// Objects are identified by their name alone.
|
||||
const gd::String &objectType = eventsBasedObject.GetName();
|
||||
|
||||
// Deprecated
|
||||
objectMetadata
|
||||
.AddScopedAction("Width", _("Width"), _("Change the width of an object."),
|
||||
_("the width"), _("Size"),
|
||||
@@ -122,6 +146,7 @@ gd::ObjectMetadata &MetadataDeclarationHelper::DeclareObjectMetadata(
|
||||
.UseStandardOperatorParameters("number",
|
||||
gd::ParameterOptions::MakeNewOptions())
|
||||
.MarkAsAdvanced()
|
||||
.SetHidden()
|
||||
.SetFunctionName("setWidth")
|
||||
.SetGetter("getWidth");
|
||||
|
||||
@@ -131,14 +156,15 @@ gd::ObjectMetadata &MetadataDeclarationHelper::DeclareObjectMetadata(
|
||||
_("the width"), _("Size"),
|
||||
"res/actions/scaleWidth24_black.png",
|
||||
"res/actions/scale_black.png")
|
||||
.SetHidden()
|
||||
.AddParameter("object", _("Object"), objectType)
|
||||
.UseStandardOperatorParameters("number",
|
||||
gd::ParameterOptions::MakeNewOptions())
|
||||
.MarkAsAdvanced()
|
||||
.SetHidden()
|
||||
.SetFunctionName("setWidth")
|
||||
.SetGetter("getWidth");
|
||||
|
||||
// Deprecated
|
||||
objectMetadata
|
||||
.AddScopedAction("Height", _("Height"),
|
||||
_("Change the height of an object."), _("the height"),
|
||||
@@ -148,6 +174,7 @@ gd::ObjectMetadata &MetadataDeclarationHelper::DeclareObjectMetadata(
|
||||
.UseStandardOperatorParameters("number",
|
||||
gd::ParameterOptions::MakeNewOptions())
|
||||
.MarkAsAdvanced()
|
||||
.SetHidden()
|
||||
.SetFunctionName("setHeight")
|
||||
.SetGetter("getHeight");
|
||||
|
||||
@@ -157,14 +184,15 @@ gd::ObjectMetadata &MetadataDeclarationHelper::DeclareObjectMetadata(
|
||||
_("the height"), _("Size"),
|
||||
"res/actions/scaleHeight24_black.png",
|
||||
"res/actions/scale_black.png")
|
||||
.SetHidden()
|
||||
.AddParameter("object", _("Object"), objectType)
|
||||
.UseStandardOperatorParameters("number",
|
||||
gd::ParameterOptions::MakeNewOptions())
|
||||
.MarkAsAdvanced()
|
||||
.SetHidden()
|
||||
.SetFunctionName("setHeight")
|
||||
.SetGetter("getHeight");
|
||||
|
||||
// Deprecated
|
||||
objectMetadata
|
||||
.AddScopedAction(
|
||||
"Scale", _("Scale"), _("Modify the scale of the specified object."),
|
||||
@@ -174,8 +202,9 @@ gd::ObjectMetadata &MetadataDeclarationHelper::DeclareObjectMetadata(
|
||||
.UseStandardOperatorParameters("number",
|
||||
gd::ParameterOptions::MakeNewOptions())
|
||||
.MarkAsAdvanced()
|
||||
.SetHidden()
|
||||
.SetFunctionName("setScale")
|
||||
.SetGetter("getScale");
|
||||
.SetGetter("getScaleMean");
|
||||
|
||||
// Deprecated
|
||||
objectMetadata
|
||||
@@ -183,14 +212,15 @@ gd::ObjectMetadata &MetadataDeclarationHelper::DeclareObjectMetadata(
|
||||
_("Modify the scale of the specified object."), _("the scale"),
|
||||
_("Size"), "res/actions/scale24_black.png",
|
||||
"res/actions/scale_black.png")
|
||||
.SetHidden()
|
||||
.AddParameter("object", _("Object"), objectType)
|
||||
.UseStandardOperatorParameters("number",
|
||||
gd::ParameterOptions::MakeNewOptions())
|
||||
.MarkAsAdvanced()
|
||||
.SetHidden()
|
||||
.SetFunctionName("setScale")
|
||||
.SetGetter("getScale");
|
||||
.SetGetter("getScaleMean");
|
||||
|
||||
// Deprecated
|
||||
objectMetadata
|
||||
.AddExpressionAndConditionAndAction(
|
||||
"number", "ScaleX", _("Scale on X axis"),
|
||||
@@ -199,9 +229,11 @@ gd::ObjectMetadata &MetadataDeclarationHelper::DeclareObjectMetadata(
|
||||
.AddParameter("object", _("Object"), objectType)
|
||||
.UseStandardParameters("number", gd::ParameterOptions::MakeNewOptions())
|
||||
.MarkAsAdvanced()
|
||||
.SetHidden()
|
||||
.SetFunctionName("setScaleX")
|
||||
.SetGetter("getScaleX");
|
||||
|
||||
// Deprecated
|
||||
objectMetadata
|
||||
.AddExpressionAndConditionAndAction(
|
||||
"number", "ScaleY", _("Scale on Y axis"),
|
||||
@@ -210,9 +242,11 @@ gd::ObjectMetadata &MetadataDeclarationHelper::DeclareObjectMetadata(
|
||||
.AddParameter("object", _("Object"), objectType)
|
||||
.UseStandardParameters("number", gd::ParameterOptions::MakeNewOptions())
|
||||
.MarkAsAdvanced()
|
||||
.SetHidden()
|
||||
.SetFunctionName("setScaleY")
|
||||
.SetGetter("getScaleY");
|
||||
|
||||
// Deprecated
|
||||
objectMetadata
|
||||
.AddScopedAction("FlipX", _("Flip the object horizontally"),
|
||||
_("Flip the object horizontally"),
|
||||
@@ -221,6 +255,7 @@ gd::ObjectMetadata &MetadataDeclarationHelper::DeclareObjectMetadata(
|
||||
.AddParameter("object", _("Object"), objectType)
|
||||
.AddParameter("yesorno", _("Activate flipping"))
|
||||
.MarkAsSimple()
|
||||
.SetHidden()
|
||||
.SetFunctionName("flipX");
|
||||
|
||||
// Deprecated
|
||||
@@ -229,12 +264,13 @@ gd::ObjectMetadata &MetadataDeclarationHelper::DeclareObjectMetadata(
|
||||
_("Flip the object horizontally"),
|
||||
_("Flip horizontally _PARAM0_: _PARAM1_"), _("Effects"),
|
||||
"res/actions/flipX24.png", "res/actions/flipX.png")
|
||||
.SetHidden()
|
||||
.AddParameter("object", _("Object"), objectType)
|
||||
.AddParameter("yesorno", _("Activate flipping"))
|
||||
.MarkAsSimple()
|
||||
.SetHidden()
|
||||
.SetFunctionName("flipX");
|
||||
|
||||
// Deprecated
|
||||
objectMetadata
|
||||
.AddScopedAction("FlipY", _("Flip the object vertically"),
|
||||
_("Flip the object vertically"),
|
||||
@@ -243,8 +279,10 @@ gd::ObjectMetadata &MetadataDeclarationHelper::DeclareObjectMetadata(
|
||||
.AddParameter("object", _("Object"), objectType)
|
||||
.AddParameter("yesorno", _("Activate flipping"))
|
||||
.MarkAsSimple()
|
||||
.SetHidden()
|
||||
.SetFunctionName("flipY");
|
||||
|
||||
// Deprecated
|
||||
objectMetadata
|
||||
.AddAction("FlipY", _("Flip the object vertically"),
|
||||
_("Flip the object vertically"),
|
||||
@@ -254,14 +292,17 @@ gd::ObjectMetadata &MetadataDeclarationHelper::DeclareObjectMetadata(
|
||||
.AddParameter("object", _("Object"), objectType)
|
||||
.AddParameter("yesorno", _("Activate flipping"))
|
||||
.MarkAsSimple()
|
||||
.SetHidden()
|
||||
.SetFunctionName("flipY");
|
||||
|
||||
// Deprecated
|
||||
objectMetadata
|
||||
.AddScopedCondition("FlippedX", _("Horizontally flipped"),
|
||||
_("Check if the object is horizontally flipped"),
|
||||
_("_PARAM0_ is horizontally flipped"), _("Effects"),
|
||||
"res/actions/flipX24.png", "res/actions/flipX.png")
|
||||
.AddParameter("object", _("Object"), objectType)
|
||||
.SetHidden()
|
||||
.SetFunctionName("isFlippedX");
|
||||
|
||||
// Deprecated
|
||||
@@ -270,16 +311,18 @@ gd::ObjectMetadata &MetadataDeclarationHelper::DeclareObjectMetadata(
|
||||
_("Check if the object is horizontally flipped"),
|
||||
_("_PARAM0_ is horizontally flipped"), _("Effects"),
|
||||
"res/actions/flipX24.png", "res/actions/flipX.png")
|
||||
.SetHidden()
|
||||
.AddParameter("object", _("Object"), objectType)
|
||||
.SetHidden()
|
||||
.SetFunctionName("isFlippedX");
|
||||
|
||||
// Deprecated
|
||||
objectMetadata
|
||||
.AddScopedCondition("FlippedY", _("Vertically flipped"),
|
||||
_("Check if the object is vertically flipped"),
|
||||
_("_PARAM0_ is vertically flipped"), _("Effects"),
|
||||
"res/actions/flipY24.png", "res/actions/flipY.png")
|
||||
.AddParameter("object", _("Object"), objectType)
|
||||
.SetHidden()
|
||||
.SetFunctionName("isFlippedY");
|
||||
|
||||
// Deprecated
|
||||
@@ -288,8 +331,8 @@ gd::ObjectMetadata &MetadataDeclarationHelper::DeclareObjectMetadata(
|
||||
_("Check if the object is vertically flipped"),
|
||||
_("_PARAM0_ is vertically flipped"), _("Effects"),
|
||||
"res/actions/flipY24.png", "res/actions/flipY.png")
|
||||
.SetHidden()
|
||||
.AddParameter("object", _("Object"), objectType)
|
||||
.SetHidden()
|
||||
.SetFunctionName("isFlippedY");
|
||||
|
||||
objectMetadata
|
||||
@@ -301,7 +344,8 @@ gd::ObjectMetadata &MetadataDeclarationHelper::DeclareObjectMetadata(
|
||||
.AddParameter("object", _("Object"), objectType)
|
||||
.UseStandardParameters("number", gd::ParameterOptions::MakeNewOptions())
|
||||
.SetFunctionName("setOpacity")
|
||||
.SetGetter("getOpacity");
|
||||
.SetGetter("getOpacity")
|
||||
.SetHidden();
|
||||
|
||||
return objectMetadata;
|
||||
}
|
||||
@@ -1348,7 +1392,7 @@ void MetadataDeclarationHelper::DeclareEventsFunctionParameters(
|
||||
}
|
||||
|
||||
gd::String MetadataDeclarationHelper::GetExtensionCodeNamespacePrefix(
|
||||
const gd::EventsFunctionsExtension eventsFunctionsExtension) {
|
||||
const gd::EventsFunctionsExtension &eventsFunctionsExtension) {
|
||||
return "gdjs.evtsExt__" + EventsCodeNameMangler::GetMangledName(
|
||||
eventsFunctionsExtension.GetName());
|
||||
}
|
||||
@@ -1411,7 +1455,7 @@ gd::BehaviorMetadata &MetadataDeclarationHelper::GenerateBehaviorMetadata(
|
||||
const gd::EventsBasedBehavior &eventsBasedBehavior,
|
||||
std::map<gd::String, gd::String> &behaviorMethodMangledNames) {
|
||||
auto &behaviorMetadata =
|
||||
DeclareBehaviorMetadata(extension, eventsBasedBehavior);
|
||||
DeclareBehaviorMetadata(project, extension, eventsBasedBehavior);
|
||||
|
||||
auto &eventsFunctionsContainer = eventsBasedBehavior.GetEventsFunctions();
|
||||
|
||||
|
@@ -66,10 +66,30 @@ public:
|
||||
const gd::EventsBasedObject &eventsBasedObject,
|
||||
std::map<gd::String, gd::String> &objectMethodMangledNames);
|
||||
|
||||
/** Generate the namespace prefix for an extension. */
|
||||
static gd::String GetExtensionCodeNamespacePrefix(
|
||||
const gd::EventsFunctionsExtension &eventsFunctionsExtension);
|
||||
|
||||
/** Generate the fully qualified name for a free function. */
|
||||
static gd::String GetFreeFunctionCodeName(
|
||||
const gd::EventsFunctionsExtension &eventsFunctionsExtension,
|
||||
const gd::EventsFunction &eventsFunction);
|
||||
|
||||
/** Generate the namespace for a free function. */
|
||||
static gd::String
|
||||
GetFreeFunctionCodeNamespace(const gd::EventsFunction &eventsFunction,
|
||||
const gd::String &codeNamespacePrefix);
|
||||
|
||||
/** Generate the namespace for a behavior function. */
|
||||
static gd::String GetBehaviorFunctionCodeNamespace(
|
||||
const gd::EventsBasedBehavior &eventsBasedBehavior,
|
||||
const gd::String &codeNamespacePrefix);
|
||||
|
||||
/** Generate the namespace for an object function. */
|
||||
static gd::String
|
||||
GetObjectFunctionCodeNamespace(const gd::EventsBasedObject &eventsBasedObject,
|
||||
const gd::String &codeNamespacePrefix);
|
||||
|
||||
/**
|
||||
* Declare an extension from an events based extension.
|
||||
*/
|
||||
@@ -164,7 +184,8 @@ private:
|
||||
* events based behavior.
|
||||
*/
|
||||
static gd::BehaviorMetadata &
|
||||
DeclareBehaviorMetadata(gd::PlatformExtension &extension,
|
||||
DeclareBehaviorMetadata(const gd::Project &project,
|
||||
gd::PlatformExtension &extension,
|
||||
const gd::EventsBasedBehavior &eventsBasedBehavior);
|
||||
|
||||
/**
|
||||
@@ -292,24 +313,6 @@ private:
|
||||
gd::MultipleInstructionMetadata &multipleInstructionMetadata,
|
||||
const int userDefinedFirstParameterIndex);
|
||||
|
||||
static gd::String GetExtensionCodeNamespacePrefix(
|
||||
const gd::EventsFunctionsExtension eventsFunctionsExtension);
|
||||
|
||||
/** Generate the namespace for a free function. */
|
||||
static gd::String
|
||||
GetFreeFunctionCodeNamespace(const gd::EventsFunction &eventsFunction,
|
||||
const gd::String &codeNamespacePrefix);
|
||||
|
||||
/** Generate the namespace for a behavior function. */
|
||||
static gd::String GetBehaviorFunctionCodeNamespace(
|
||||
const gd::EventsBasedBehavior &eventsBasedBehavior,
|
||||
const gd::String &codeNamespacePrefix);
|
||||
|
||||
/** Generate the namespace for an object function. */
|
||||
static gd::String
|
||||
GetObjectFunctionCodeNamespace(const gd::EventsBasedObject &eventsBasedObject,
|
||||
const gd::String &codeNamespacePrefix);
|
||||
|
||||
static gd::String RemoveTrailingDot(const gd::String &description);
|
||||
|
||||
static gd::String
|
||||
|
@@ -27,14 +27,8 @@ BaseObjectExtension::BaseObjectExtension() {
|
||||
std::map<gd::String, gd::ExpressionMetadata> &objectStrExpressions =
|
||||
GetAllStrExpressionsForObject("");
|
||||
|
||||
objectActions["MettreX"]
|
||||
.SetFunctionName("setX")
|
||||
.SetGetter("getX")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectActions["MettreY"]
|
||||
.SetFunctionName("setY")
|
||||
.SetGetter("getY")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectActions["MettreX"].SetFunctionName("setX").SetGetter("getX");
|
||||
objectActions["MettreY"].SetFunctionName("setY").SetGetter("getY");
|
||||
objectConditions["PosX"].SetFunctionName("getX").SetIncludeFile(
|
||||
"runtimeobject.js");
|
||||
objectConditions["PosY"].SetFunctionName("getY").SetIncludeFile(
|
||||
@@ -47,13 +41,8 @@ BaseObjectExtension::BaseObjectExtension() {
|
||||
objectActions["SetCenterY"]
|
||||
.SetFunctionName("setCenterYInScene")
|
||||
.SetGetter("getCenterYInScene");
|
||||
objectActions["SetAngle"]
|
||||
.SetFunctionName("setAngle")
|
||||
.SetGetter("getAngle")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectConditions["Angle"]
|
||||
.SetFunctionName("getAngle")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectActions["SetAngle"].SetFunctionName("setAngle").SetGetter("getAngle");
|
||||
objectConditions["Angle"].SetFunctionName("getAngle");
|
||||
objectConditions["BoundingBoxLeft"].SetFunctionName("getAABBLeft");
|
||||
objectConditions["BoundingBoxTop"].SetFunctionName("getAABBTop");
|
||||
objectConditions["BoundingBoxRight"].SetFunctionName("getAABBRight");
|
||||
@@ -62,142 +51,71 @@ BaseObjectExtension::BaseObjectExtension() {
|
||||
objectConditions["BoundingBoxCenterY"].SetFunctionName("getAABBCenterY");
|
||||
objectActions["Rotate"].SetFunctionName("rotate").SetIncludeFile(
|
||||
"runtimeobject.js");
|
||||
objectActions["RotateTowardAngle"]
|
||||
.SetFunctionName("rotateTowardAngle")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectActions["RotateTowardPosition"]
|
||||
.SetFunctionName("rotateTowardPosition")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectActions["ChangeLayer"]
|
||||
.SetFunctionName("setLayer")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectConditions["Layer"]
|
||||
.SetFunctionName("isOnLayer")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectActions["RotateTowardAngle"].SetFunctionName("rotateTowardAngle");
|
||||
objectActions["RotateTowardPosition"].SetFunctionName("rotateTowardPosition");
|
||||
objectActions["ChangeLayer"].SetFunctionName("setLayer");
|
||||
objectConditions["Layer"].SetFunctionName("isOnLayer");
|
||||
objectActions["ChangePlan"]
|
||||
.SetFunctionName("setZOrder")
|
||||
.SetGetter("getZOrder")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectConditions["Plan"]
|
||||
.SetFunctionName("getZOrder")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
.SetGetter("getZOrder");
|
||||
objectConditions["Plan"].SetFunctionName("getZOrder");
|
||||
objectActions["Cache"].SetFunctionName("hide").SetIncludeFile(
|
||||
"runtimeobject.js");
|
||||
objectActions["Montre"].SetFunctionName("hide").SetIncludeFile(
|
||||
"runtimeobject.js");
|
||||
objectConditions["Visible"]
|
||||
.SetFunctionName("isVisible")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectConditions["Invisible"]
|
||||
.SetFunctionName("isHidden")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectConditions["IsEffectEnabled"]
|
||||
.SetFunctionName("isEffectEnabled")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectConditions["Visible"].SetFunctionName("isVisible");
|
||||
objectConditions["Invisible"].SetFunctionName("isHidden");
|
||||
objectConditions["IsEffectEnabled"].SetFunctionName("isEffectEnabled");
|
||||
objectActions["Delete"].SetFunctionName("deleteFromScene");
|
||||
objectActions["MettreAutourPos"].SetFunctionName("putAround");
|
||||
objectActions["MettreAutour"]
|
||||
.SetFunctionName("putAroundObject")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectConditions["VarObjet"]
|
||||
.SetFunctionName("getVariableNumber")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectConditions["VarObjetTxt"]
|
||||
.SetFunctionName("getVariableString")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectConditions["ObjectVariableAsBoolean"]
|
||||
.SetFunctionName("getVariableBoolean")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectConditions["VarObjetDef"]
|
||||
.SetFunctionName("hasVariable")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectActions["AddForceXY"]
|
||||
.SetFunctionName("addForce")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectActions["AddForceAL"]
|
||||
.SetFunctionName("addPolarForce")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectActions["AddForceVersPos"]
|
||||
.SetFunctionName("addForceTowardPosition")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectActions["AddForceVers"]
|
||||
.SetFunctionName("addForceTowardObject")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectActions["Arreter"]
|
||||
.SetFunctionName("clearForces")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectConditions["Arret"]
|
||||
.SetFunctionName("hasNoForces")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectConditions["Vitesse"]
|
||||
.SetFunctionName("getAverageForce().getLength")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectConditions["AngleOfDisplacement"]
|
||||
.SetFunctionName("averageForceAngleIs")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectActions["SeparateFromObjects"]
|
||||
.SetFunctionName("separateFromObjectsList")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectActions["Ecarter"] // Deprecated
|
||||
.SetFunctionName("separateObjectsWithoutForces")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectActions["Rebondir"] // Deprecated
|
||||
.SetFunctionName("separateObjectsWithForces")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectConditions["BehaviorActivated"]
|
||||
.SetFunctionName("behaviorActivated")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectActions["ActivateBehavior"]
|
||||
.SetFunctionName("activateBehavior")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectConditions["ObjectVariableChildExists"]
|
||||
.SetFunctionName("variableChildExists")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectActions["ObjectVariableRemoveChild"]
|
||||
.SetFunctionName("variableRemoveChild")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectActions["ObjectVariableClearChildren"]
|
||||
.SetFunctionName("variableClearChildren")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectConditions["CollisionPoint"]
|
||||
.SetFunctionName("isCollidingWithPoint")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectConditions["ObjectTimer"] // deprecated
|
||||
.SetFunctionName("timerElapsedTime")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectConditions["CompareObjectTimer"]
|
||||
.SetFunctionName("getTimerElapsedTimeInSecondsOrNaN")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectConditions["ObjectTimerPaused"]
|
||||
.SetFunctionName("timerPaused")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectActions["ResetObjectTimer"]
|
||||
.SetFunctionName("resetTimer")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectActions["PauseObjectTimer"]
|
||||
.SetFunctionName("pauseTimer")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectActions["UnPauseObjectTimer"]
|
||||
.SetFunctionName("unpauseTimer")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectActions["RemoveObjectTimer"]
|
||||
.SetFunctionName("removeTimer")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectActions["EnableEffect"]
|
||||
.SetFunctionName("enableEffect")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectActions["SetEffectDoubleParameter"]
|
||||
.SetFunctionName("setEffectDoubleParameter")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectActions["SetEffectStringParameter"]
|
||||
.SetFunctionName("setEffectStringParameter")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectActions["SetEffectBooleanParameter"]
|
||||
.SetFunctionName("setEffectBooleanParameter")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectActions["SetIncludedInParentCollisionMask"]
|
||||
.SetFunctionName("setIncludedInParentCollisionMask")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectActions["MettreAutour"].SetFunctionName("putAroundObject");
|
||||
objectConditions["VarObjet"].SetFunctionName("getVariableNumber");
|
||||
objectConditions["VarObjetTxt"].SetFunctionName("getVariableString");
|
||||
objectConditions["ObjectVariableAsBoolean"].SetFunctionName(
|
||||
"getVariableBoolean");
|
||||
objectConditions["VarObjetDef"].SetFunctionName("hasVariable");
|
||||
objectActions["AddForceXY"].SetFunctionName("addForce");
|
||||
objectActions["AddForceAL"].SetFunctionName("addPolarForce");
|
||||
objectActions["AddForceVersPos"].SetFunctionName("addForceTowardPosition");
|
||||
objectActions["AddForceVers"].SetFunctionName("addForceTowardObject");
|
||||
objectActions["Arreter"].SetFunctionName("clearForces");
|
||||
objectConditions["Arret"].SetFunctionName("hasNoForces");
|
||||
objectConditions["Vitesse"].SetFunctionName("getAverageForce().getLength");
|
||||
objectConditions["AngleOfDisplacement"].SetFunctionName(
|
||||
"averageForceAngleIs");
|
||||
objectActions["SeparateFromObjects"].SetFunctionName(
|
||||
"separateFromObjectsList");
|
||||
// Deprecated
|
||||
objectActions["Ecarter"].SetFunctionName("separateObjectsWithoutForces");
|
||||
// Deprecated
|
||||
objectActions["Rebondir"].SetFunctionName("separateObjectsWithForces");
|
||||
objectConditions["BehaviorActivated"].SetFunctionName("behaviorActivated");
|
||||
objectActions["ActivateBehavior"].SetFunctionName("activateBehavior");
|
||||
objectConditions["ObjectVariableChildExists"].SetFunctionName(
|
||||
"variableChildExists");
|
||||
objectActions["ObjectVariableRemoveChild"].SetFunctionName(
|
||||
"variableRemoveChild");
|
||||
objectActions["ObjectVariableClearChildren"].SetFunctionName(
|
||||
"variableClearChildren");
|
||||
objectConditions["CollisionPoint"].SetFunctionName("isCollidingWithPoint");
|
||||
// deprecated
|
||||
objectConditions["ObjectTimer"].SetFunctionName("timerElapsedTime");
|
||||
objectConditions["CompareObjectTimer"].SetFunctionName(
|
||||
"getTimerElapsedTimeInSecondsOrNaN");
|
||||
objectConditions["ObjectTimerPaused"].SetFunctionName("timerPaused");
|
||||
objectActions["ResetObjectTimer"].SetFunctionName("resetTimer");
|
||||
objectActions["PauseObjectTimer"].SetFunctionName("pauseTimer");
|
||||
objectActions["UnPauseObjectTimer"].SetFunctionName("unpauseTimer");
|
||||
objectActions["RemoveObjectTimer"].SetFunctionName("removeTimer");
|
||||
objectActions["EnableEffect"].SetFunctionName("enableEffect");
|
||||
objectActions["SetEffectDoubleParameter"].SetFunctionName(
|
||||
"setEffectDoubleParameter");
|
||||
objectActions["SetEffectStringParameter"].SetFunctionName(
|
||||
"setEffectStringParameter");
|
||||
objectActions["SetEffectBooleanParameter"].SetFunctionName(
|
||||
"setEffectBooleanParameter");
|
||||
objectActions["SetIncludedInParentCollisionMask"].SetFunctionName(
|
||||
"setIncludedInParentCollisionMask");
|
||||
|
||||
objectExpressions["X"].SetFunctionName("getX");
|
||||
objectExpressions["Y"].SetFunctionName("getY");
|
||||
@@ -210,11 +128,14 @@ BaseObjectExtension::BaseObjectExtension() {
|
||||
objectExpressions["BoundingBoxCenterX"].SetFunctionName("getAABBCenterX");
|
||||
objectExpressions["BoundingBoxCenterY"].SetFunctionName("getAABBCenterY");
|
||||
objectExpressions["ZOrder"].SetFunctionName("getZOrder");
|
||||
objectExpressions["Plan"].SetFunctionName("getZOrder"); // Deprecated
|
||||
// Deprecated
|
||||
objectExpressions["Plan"].SetFunctionName("getZOrder");
|
||||
objectExpressions["Width"].SetFunctionName("getWidth");
|
||||
objectExpressions["Height"].SetFunctionName("getHeight");
|
||||
objectExpressions["Largeur"].SetFunctionName("getWidth"); // Deprecated
|
||||
objectExpressions["Hauteur"].SetFunctionName("getHeight"); // Deprecated
|
||||
// Deprecated
|
||||
objectExpressions["Largeur"].SetFunctionName("getWidth");
|
||||
// Deprecated
|
||||
objectExpressions["Hauteur"].SetFunctionName("getHeight");
|
||||
objectExpressions["Variable"]
|
||||
.SetFunctionName("gdjs.RuntimeObject.getVariableNumber")
|
||||
.SetStatic();
|
||||
@@ -242,8 +163,8 @@ BaseObjectExtension::BaseObjectExtension() {
|
||||
objectExpressions["Angle"].SetFunctionName("getAngle");
|
||||
objectExpressions["ForceLength"].SetFunctionName(
|
||||
"getAverageForce().getLength");
|
||||
objectExpressions["Longueur"].SetFunctionName(
|
||||
"getAverageForce().getLength"); // Deprecated
|
||||
// Deprecated
|
||||
objectExpressions["Longueur"].SetFunctionName("getAverageForce().getLength");
|
||||
objectExpressions["Distance"].SetFunctionName("getDistanceToObject");
|
||||
objectExpressions["SqDistance"].SetFunctionName("getSqDistanceToObject");
|
||||
objectExpressions["DistanceToPosition"].SetFunctionName(
|
||||
@@ -265,11 +186,12 @@ BaseObjectExtension::BaseObjectExtension() {
|
||||
"gdjs.evtTools.object.createObjectOnScene");
|
||||
GetAllActions()["CreateByName"].SetFunctionName(
|
||||
"gdjs.evtTools.object.createObjectFromGroupOnScene");
|
||||
|
||||
// Deprecated
|
||||
GetAllExpressions()["Count"].SetFunctionName(
|
||||
"gdjs.evtTools.object.pickedObjectsCount"); // Deprecated
|
||||
"gdjs.evtTools.object.pickedObjectsCount");
|
||||
// Deprecated
|
||||
GetAllConditions()["NbObjet"].SetFunctionName(
|
||||
"gdjs.evtTools.object.pickedObjectsCount"); // Deprecated
|
||||
"gdjs.evtTools.object.pickedObjectsCount");
|
||||
|
||||
GetAllExpressions()["SceneInstancesCount"].SetFunctionName(
|
||||
"gdjs.evtTools.object.getSceneInstancesCount");
|
||||
@@ -315,42 +237,27 @@ BaseObjectExtension::BaseObjectExtension() {
|
||||
{"-", "sub"},
|
||||
{"*", "mul"},
|
||||
{"/", "div"},
|
||||
})
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
});
|
||||
objectActions["ModVarObjetTxt"]
|
||||
.SetFunctionName("returnVariable")
|
||||
.SetManipulatedType("string")
|
||||
.SetMutators({
|
||||
{"=", "setString"},
|
||||
{"+", "concatenate"},
|
||||
})
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
});
|
||||
|
||||
objectActions["SetObjectVariableAsBoolean"]
|
||||
.SetFunctionName("setVariableBoolean")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectActions["ToggleObjectVariableAsBoolean"]
|
||||
.SetFunctionName("toggleVariableBoolean")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectActions["SetObjectVariableAsBoolean"].SetFunctionName(
|
||||
"setVariableBoolean");
|
||||
objectActions["ToggleObjectVariableAsBoolean"].SetFunctionName(
|
||||
"toggleVariableBoolean");
|
||||
|
||||
objectActions["ObjectVariablePush"]
|
||||
.SetFunctionName("variablePushCopy")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectActions["ObjectVariablePushString"]
|
||||
.SetFunctionName("valuePush")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectActions["ObjectVariablePushNumber"]
|
||||
.SetFunctionName("valuePush")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectActions["ObjectVariablePushBool"]
|
||||
.SetFunctionName("valuePush")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectActions["ObjectVariableRemoveAt"]
|
||||
.SetFunctionName("variableRemoveAt")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectConditions["ObjectVariableChildCount"]
|
||||
.SetFunctionName("getVariableChildCount")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectActions["ObjectVariablePush"].SetFunctionName("variablePushCopy");
|
||||
objectActions["ObjectVariablePushString"].SetFunctionName("valuePush");
|
||||
objectActions["ObjectVariablePushNumber"].SetFunctionName("valuePush");
|
||||
objectActions["ObjectVariablePushBool"].SetFunctionName("valuePush");
|
||||
objectActions["ObjectVariableRemoveAt"].SetFunctionName("variableRemoveAt");
|
||||
objectConditions["ObjectVariableChildCount"].SetFunctionName(
|
||||
"getVariableChildCount");
|
||||
|
||||
GetAllActions()["MoveObjects"].SetCustomCodeGenerator(
|
||||
[](gd::Instruction &,
|
||||
@@ -481,4 +388,4 @@ BaseObjectExtension::BaseObjectExtension() {
|
||||
StripUnimplementedInstructionsAndExpressions();
|
||||
}
|
||||
|
||||
} // namespace gdjs
|
||||
} // namespace gdjs
|
||||
|
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* GDevelop JS Platform
|
||||
* Copyright 2008-2023 Florian Rival (Florian.Rival@gmail.com). All rights
|
||||
* reserved. This project is released under the MIT License.
|
||||
*/
|
||||
#include "GDJS/Extensions/Builtin/Capacities/AnimatableExtension.h"
|
||||
#include "GDCore/Extensions/Builtin/AllBuiltinExtensions.h"
|
||||
#include "GDCore/Extensions/Metadata/InstructionMetadata.h"
|
||||
#include "GDCore/Tools/Localization.h"
|
||||
|
||||
namespace gdjs {
|
||||
|
||||
AnimatableExtension::AnimatableExtension() {
|
||||
gd::BuiltinExtensionsImplementer::ImplementsAnimatableExtension(*this);
|
||||
|
||||
GetBehaviorMetadata("AnimatableCapability::AnimatableBehavior")
|
||||
.SetIncludeFile("object-capabilities/AnimatableBehavior.js");
|
||||
|
||||
auto& actions = GetAllActionsForBehavior("AnimatableCapability::AnimatableBehavior");
|
||||
auto& conditions = GetAllConditionsForBehavior("AnimatableCapability::AnimatableBehavior");
|
||||
auto& expressions = GetAllExpressionsForBehavior("AnimatableCapability::AnimatableBehavior");
|
||||
auto& strExpressions = GetAllStrExpressionsForBehavior("AnimatableCapability::AnimatableBehavior");
|
||||
|
||||
actions["AnimatableCapability::AnimatableBehavior::SetIndex"]
|
||||
.SetFunctionName("setAnimationIndex")
|
||||
.SetGetter("getAnimationIndex")
|
||||
.SetIncludeFile("object-capabilities/AnimatableBehavior.js");
|
||||
conditions["AnimatableCapability::AnimatableBehavior::Index"]
|
||||
.SetFunctionName("getAnimationIndex")
|
||||
.SetIncludeFile("object-capabilities/AnimatableBehavior.js");
|
||||
expressions["Index"]
|
||||
.SetFunctionName("getAnimationIndex")
|
||||
.SetIncludeFile("object-capabilities/AnimatableBehavior.js");
|
||||
|
||||
actions["AnimatableCapability::AnimatableBehavior::SetName"]
|
||||
.SetFunctionName("setAnimationName")
|
||||
.SetGetter("getAnimationName")
|
||||
.SetIncludeFile("object-capabilities/AnimatableBehavior.js");
|
||||
conditions["AnimatableCapability::AnimatableBehavior::Name"]
|
||||
.SetFunctionName("getAnimationName")
|
||||
.SetIncludeFile("object-capabilities/AnimatableBehavior.js");
|
||||
strExpressions["Name"]
|
||||
.SetFunctionName("getAnimationName")
|
||||
.SetIncludeFile("object-capabilities/AnimatableBehavior.js");
|
||||
|
||||
actions["AnimatableCapability::AnimatableBehavior::SetSpeedScale"]
|
||||
.SetFunctionName("setAnimationSpeedScale")
|
||||
.SetGetter("getAnimationSpeedScale")
|
||||
.SetIncludeFile("object-capabilities/AnimatableBehavior.js");
|
||||
conditions["AnimatableCapability::AnimatableBehavior::SpeedScale"]
|
||||
.SetFunctionName("getAnimationSpeedScale")
|
||||
.SetIncludeFile("object-capabilities/AnimatableBehavior.js");
|
||||
expressions["SpeedScale"]
|
||||
.SetFunctionName("getAnimationSpeedScale")
|
||||
.SetIncludeFile("object-capabilities/AnimatableBehavior.js");
|
||||
|
||||
actions["AnimatableCapability::AnimatableBehavior::PauseAnimation"]
|
||||
.SetFunctionName("pauseAnimation")
|
||||
.SetIncludeFile("object-capabilities/AnimatableBehavior.js");
|
||||
actions["AnimatableCapability::AnimatableBehavior::PlayAnimation"]
|
||||
.SetFunctionName("resumeAnimation")
|
||||
.SetIncludeFile("object-capabilities/AnimatableBehavior.js");
|
||||
|
||||
conditions["AnimatableCapability::AnimatableBehavior::IsAnimationPaused"]
|
||||
.SetFunctionName("isAnimationPaused")
|
||||
.SetIncludeFile("object-capabilities/AnimatableBehavior.js");
|
||||
conditions["AnimatableCapability::AnimatableBehavior::HasAnimationEnded"]
|
||||
.SetFunctionName("hasAnimationEnded")
|
||||
.SetIncludeFile("object-capabilities/AnimatableBehavior.js");
|
||||
}
|
||||
|
||||
} // namespace gdjs
|
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* GDevelop JS Platform
|
||||
* Copyright 2008-2023 Florian Rival (Florian.Rival@gmail.com). All rights
|
||||
* reserved. This project is released under the MIT License.
|
||||
*/
|
||||
#pragma once
|
||||
#include "GDCore/Extensions/PlatformExtension.h"
|
||||
|
||||
namespace gdjs {
|
||||
|
||||
/**
|
||||
* \brief Built-in extension providing Animatable object capacity.
|
||||
*
|
||||
* \ingroup BuiltinExtensions
|
||||
*/
|
||||
class AnimatableExtension : public gd::PlatformExtension {
|
||||
public:
|
||||
AnimatableExtension();
|
||||
virtual ~AnimatableExtension(){};
|
||||
};
|
||||
|
||||
} // namespace gdjs
|
40
GDJS/GDJS/Extensions/Builtin/Capacities/EffectExtension.cpp
Normal file
40
GDJS/GDJS/Extensions/Builtin/Capacities/EffectExtension.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* GDevelop JS Platform
|
||||
* Copyright 2008-2023 Florian Rival (Florian.Rival@gmail.com). All rights
|
||||
* reserved. This project is released under the MIT License.
|
||||
*/
|
||||
#include "GDJS/Extensions/Builtin/Capacities/EffectExtension.h"
|
||||
#include "GDCore/Extensions/Builtin/AllBuiltinExtensions.h"
|
||||
#include "GDCore/Extensions/Metadata/InstructionMetadata.h"
|
||||
#include "GDCore/Tools/Localization.h"
|
||||
|
||||
namespace gdjs {
|
||||
|
||||
EffectExtension::EffectExtension() {
|
||||
gd::BuiltinExtensionsImplementer::ImplementsEffectExtension(*this);
|
||||
|
||||
GetBehaviorMetadata("EffectCapability::EffectBehavior")
|
||||
.SetIncludeFile("object-capabilities/EffectBehavior.js");
|
||||
|
||||
auto& actions = GetAllActionsForBehavior("EffectCapability::EffectBehavior");
|
||||
auto& conditions = GetAllConditionsForBehavior("EffectCapability::EffectBehavior");
|
||||
|
||||
actions["EffectCapability::EffectBehavior::SetEffectDoubleParameter"]
|
||||
.SetFunctionName("setEffectDoubleParameter")
|
||||
.SetIncludeFile("object-capabilities/EffectBehavior.js");
|
||||
actions["EffectCapability::EffectBehavior::SetEffectStringParameter"]
|
||||
.SetFunctionName("setEffectStringParameter")
|
||||
.SetIncludeFile("object-capabilities/EffectBehavior.js");
|
||||
actions["EffectCapability::EffectBehavior::SetEffectBooleanParameter"]
|
||||
.SetFunctionName("setEffectBooleanParameter")
|
||||
.SetIncludeFile("object-capabilities/EffectBehavior.js");
|
||||
|
||||
actions["EffectCapability::EffectBehavior::EnableEffect"]
|
||||
.SetFunctionName("enableEffect")
|
||||
.SetIncludeFile("object-capabilities/EffectBehavior.js");
|
||||
conditions["EffectCapability::EffectBehavior::IsEffectEnabled"]
|
||||
.SetFunctionName("isEffectEnabled")
|
||||
.SetIncludeFile("object-capabilities/EffectBehavior.js");
|
||||
}
|
||||
|
||||
} // namespace gdjs
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user