mirror of
https://github.com/4ian/GDevelop.git
synced 2025-10-15 10:19:04 +00:00
Compare commits
76 Commits
v5.1.157
...
refactor/a
Author | SHA1 | Date | |
---|---|---|---|
![]() |
ddb091298c | ||
![]() |
e0e7037dd8 | ||
![]() |
412dc0b4ea | ||
![]() |
111c6eb014 | ||
![]() |
1f0f62099b | ||
![]() |
ea10467062 | ||
![]() |
a6dac96db1 | ||
![]() |
b8de8d4f15 | ||
![]() |
d25cad5aaf | ||
![]() |
f0583df184 | ||
![]() |
8d25904462 | ||
![]() |
9e9db1fc4c | ||
![]() |
9047b5a4ec | ||
![]() |
4dbe90b9a2 | ||
![]() |
73b88b7d5e | ||
![]() |
e8bc3b7ee8 | ||
![]() |
baa3cad99a | ||
![]() |
f477af7c6b | ||
![]() |
f8cedfd357 | ||
![]() |
1021447b02 | ||
![]() |
7567584ecd | ||
![]() |
90f75fba42 | ||
![]() |
fcc35f4e3c | ||
![]() |
01a7c48864 | ||
![]() |
be6a7753cf | ||
![]() |
3b1e0a5750 | ||
![]() |
4d2fd4752f | ||
![]() |
8e00e9615e | ||
![]() |
68253017ee | ||
![]() |
35c91f6f99 | ||
![]() |
803559fad8 | ||
![]() |
e85229d38e | ||
![]() |
e7381a7229 | ||
![]() |
257ba78486 | ||
![]() |
fb3d821368 | ||
![]() |
a5068d8fcf | ||
![]() |
d20b3228cf | ||
![]() |
aae54ef331 | ||
![]() |
caa5105651 | ||
![]() |
5eccdde332 | ||
![]() |
c34d758ccf | ||
![]() |
4e57d6aee9 | ||
![]() |
74d208f736 | ||
![]() |
d88b76becf | ||
![]() |
4a0e2481e6 | ||
![]() |
612b041da4 | ||
![]() |
3df7cd8e80 | ||
![]() |
7ba96ed0ab | ||
![]() |
689cd14947 | ||
![]() |
de50dc7967 | ||
![]() |
1aa2afaf85 | ||
![]() |
9120a52a08 | ||
![]() |
b0ffaebe91 | ||
![]() |
64a4a0b3a1 | ||
![]() |
cdfd7a7ab1 | ||
![]() |
a944ac43db | ||
![]() |
b7a1a96e7b | ||
![]() |
29d71796cc | ||
![]() |
78a1361897 | ||
![]() |
e340784ad6 | ||
![]() |
511466f0b8 | ||
![]() |
3f4e372acb | ||
![]() |
a73a92d748 | ||
![]() |
6e131d8a17 | ||
![]() |
9ac4c021e0 | ||
![]() |
a1fbf91ac7 | ||
![]() |
3f8d01e25e | ||
![]() |
03b4170d74 | ||
![]() |
0146ad9c38 | ||
![]() |
fbb23f86cd | ||
![]() |
1fdaeea4f8 | ||
![]() |
32b97f2c40 | ||
![]() |
d61f8336a8 | ||
![]() |
3448cd57fe | ||
![]() |
b7333612aa | ||
![]() |
de82182b37 |
8
.github/workflows/build-storybook.yml
vendored
8
.github/workflows/build-storybook.yml
vendored
@@ -17,6 +17,10 @@ jobs:
|
||||
build-storybook:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 16
|
||||
|
||||
- name: Configure AWS Credentials
|
||||
uses: aws-actions/configure-aws-credentials@v1
|
||||
with:
|
||||
@@ -57,8 +61,8 @@ jobs:
|
||||
|
||||
- name: Log urls to the Storybook
|
||||
run: |
|
||||
echo "Find the latest Storybook for this branch on http://gdevelop-storybook.s3-website-us-east-1.amazonaws.com/$(git rev-parse --abbrev-ref HEAD)/latest/index.html"
|
||||
echo "Find the Storybook for this commit on http://gdevelop-storybook.s3-website-us-east-1.amazonaws.com/$(git rev-parse --abbrev-ref HEAD)/commit/$(git rev-parse HEAD)/index.html"
|
||||
echo "Find the latest Storybook for this branch on https://gdevelop-storybook.s3.amazonaws.com/$(git rev-parse --abbrev-ref HEAD)/latest/index.html"
|
||||
echo "Find the Storybook for this commit on https://gdevelop-storybook.s3.amazonaws.com/$(git rev-parse --abbrev-ref HEAD)/commit/$(git rev-parse HEAD)/index.html"
|
||||
|
||||
# Publish on Chromatic, only when manually launched (too costly to run on every commit).
|
||||
- name: Publish Storybook to Chromatic
|
||||
|
5
.github/workflows/extract-translations.yml
vendored
5
.github/workflows/extract-translations.yml
vendored
@@ -11,6 +11,9 @@ jobs:
|
||||
extract-translations:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 16
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
# Cache npm dependencies to speed up the workflow
|
||||
@@ -38,7 +41,7 @@ jobs:
|
||||
- name: Install Crowdin CLI
|
||||
if: github.ref == 'refs/heads/master'
|
||||
run: npm i -g @crowdin/cli
|
||||
|
||||
|
||||
- name: Upload translations to Crowdin
|
||||
run: crowdin upload sources
|
||||
if: github.ref == 'refs/heads/master'
|
||||
|
9
.github/workflows/update-translations.yml
vendored
9
.github/workflows/update-translations.yml
vendored
@@ -14,6 +14,9 @@ jobs:
|
||||
update-translations:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 16
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
# Cache npm dependencies to speed up the workflow
|
||||
@@ -44,7 +47,7 @@ jobs:
|
||||
# (Build and) download the most recent translations (PO files) from Crowdin.
|
||||
- name: Install Crowdin CLI
|
||||
run: npm i -g @crowdin/cli
|
||||
|
||||
|
||||
- name: Download new translations from Crowdin
|
||||
run: crowdin download
|
||||
env:
|
||||
@@ -66,8 +69,8 @@ jobs:
|
||||
commit-message: Update translations [skip ci]
|
||||
branch: chore/update-translations
|
||||
delete-branch: true
|
||||
title: '[Auto PR] Update translations'
|
||||
title: "[Auto PR] Update translations"
|
||||
body: |
|
||||
This updates the translations by downloading them from Crowdin and compiling them for usage by the app.
|
||||
|
||||
|
||||
Please double check the values in `newIDE/app/src/locales/LocalesMetadata.js` to ensure the changes are sensible.
|
||||
|
@@ -34,6 +34,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAdvancedExtension(
|
||||
"res/function32.png")
|
||||
.SetHelpPath("/events/functions/return")
|
||||
.AddParameter("expression", "The number to be returned")
|
||||
.SetRelevantForFunctionEventsOnly()
|
||||
.MarkAsAdvanced();
|
||||
|
||||
extension
|
||||
@@ -48,6 +49,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAdvancedExtension(
|
||||
"res/function32.png")
|
||||
.SetHelpPath("/events/functions/return")
|
||||
.AddParameter("string", "The text to be returned")
|
||||
.SetRelevantForFunctionEventsOnly()
|
||||
.MarkAsAdvanced();
|
||||
|
||||
extension
|
||||
@@ -61,6 +63,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAdvancedExtension(
|
||||
"res/function32.png")
|
||||
.SetHelpPath("/events/functions/return")
|
||||
.AddParameter("trueorfalse", "Should the condition be true or false?")
|
||||
.SetRelevantForFunctionEventsOnly()
|
||||
.MarkAsAdvanced();
|
||||
|
||||
extension
|
||||
@@ -75,6 +78,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAdvancedExtension(
|
||||
"res/function32.png",
|
||||
"res/function32.png")
|
||||
.AddParameter("functionParameterName", "Parameter name")
|
||||
.SetRelevantForFunctionEventsOnly()
|
||||
.MarkAsAdvanced();
|
||||
|
||||
extension
|
||||
@@ -84,7 +88,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAdvancedExtension(
|
||||
_("Get function parameter (also called \"argument\") value."),
|
||||
"",
|
||||
"res/function16.png")
|
||||
.AddParameter("functionParameterName", "Parameter name");
|
||||
.AddParameter("functionParameterName", "Parameter name")
|
||||
.SetRelevantForFunctionEventsOnly();
|
||||
|
||||
extension
|
||||
.AddStrExpression(
|
||||
@@ -93,7 +98,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAdvancedExtension(
|
||||
_("Get function parameter (also called \"argument\") text."),
|
||||
"",
|
||||
"res/function16.png")
|
||||
.AddParameter("functionParameterName", "Parameter name");
|
||||
.AddParameter("functionParameterName", "Parameter name")
|
||||
.SetRelevantForFunctionEventsOnly();
|
||||
|
||||
extension
|
||||
.AddCondition(
|
||||
@@ -106,7 +112,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAdvancedExtension(
|
||||
"res/function16.png")
|
||||
.AddParameter("functionParameterName", "Parameter name")
|
||||
.UseStandardRelationalOperatorParameters(
|
||||
"number", gd::ParameterOptions::MakeNewOptions());
|
||||
"number", gd::ParameterOptions::MakeNewOptions())
|
||||
.SetRelevantForFunctionEventsOnly();
|
||||
|
||||
extension
|
||||
.AddCondition(
|
||||
@@ -119,7 +126,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAdvancedExtension(
|
||||
"res/function16.png")
|
||||
.AddParameter("functionParameterName", "Parameter name")
|
||||
.UseStandardRelationalOperatorParameters(
|
||||
"string", gd::ParameterOptions::MakeNewOptions());
|
||||
"string", gd::ParameterOptions::MakeNewOptions())
|
||||
.SetRelevantForFunctionEventsOnly();
|
||||
}
|
||||
|
||||
} // namespace gd
|
||||
|
@@ -40,7 +40,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAsyncExtension(
|
||||
"",
|
||||
"res/actions/quit24.png",
|
||||
"res/actions/quit.png")
|
||||
.AddCodeOnlyParameter("eventsFunctionContext", "");
|
||||
.AddCodeOnlyParameter("eventsFunctionContext", "")
|
||||
.SetRelevantForAsynchronousFunctionEventsOnly();
|
||||
}
|
||||
|
||||
} // namespace gd
|
||||
|
@@ -27,6 +27,10 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
||||
.SetIcon("res/actions/create24.png");
|
||||
extension.AddInstructionOrExpressionGroupMetadata(_("Movement using forces"))
|
||||
.SetIcon("res/actions/force24.png");
|
||||
extension.AddInstructionOrExpressionGroupMetadata(_("Variables"))
|
||||
.SetIcon("res/conditions/var24.png");
|
||||
extension.AddInstructionOrExpressionGroupMetadata(_("Position"))
|
||||
.SetIcon("res/actions/position24_black.png");
|
||||
|
||||
gd::ObjectMetadata& obj = extension.AddObject<gd::ObjectConfiguration>(
|
||||
"", _("Base object"), _("Base object"), "res/objeticon24.png");
|
||||
@@ -406,8 +410,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
||||
.MarkAsAdvanced();
|
||||
|
||||
obj.AddAction("ModVarObjet",
|
||||
_("Value of an object variable"),
|
||||
_("Change the value of an object variable."),
|
||||
_("Change number variable"),
|
||||
_("Modify the number value of an object variable."),
|
||||
_("the variable _PARAM1_"),
|
||||
_("Variables"),
|
||||
"res/actions/var24.png",
|
||||
@@ -419,8 +423,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
||||
ParameterOptions::MakeNewOptions());
|
||||
|
||||
obj.AddAction("ModVarObjetTxt",
|
||||
_("Text of an object variable"),
|
||||
_("Change the text of an object variable."),
|
||||
_("Change text variable"),
|
||||
_("Modify the text of an object variable."),
|
||||
_("the text of variable _PARAM1_"),
|
||||
_("Variables"),
|
||||
"res/actions/var24.png",
|
||||
@@ -432,8 +436,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
||||
ParameterOptions::MakeNewOptions());
|
||||
|
||||
obj.AddAction("SetObjectVariableAsBoolean",
|
||||
_("Boolean value of an object variable"),
|
||||
_("Change the boolean value of an object variable."),
|
||||
_("Change boolean variable"),
|
||||
_("Modify the boolean value of an object variable."),
|
||||
_("Set the boolean value of variable _PARAM1_ of "
|
||||
"_PARAM0_ to _PARAM2_"),
|
||||
_("Variables"),
|
||||
@@ -446,7 +450,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
||||
|
||||
obj.AddAction(
|
||||
"ToggleObjectVariableAsBoolean",
|
||||
_("Toggle the boolean value of an object variable"),
|
||||
_("Toggle boolean variable"),
|
||||
_("Toggles the boolean value of an object variable.") + "\n" +
|
||||
_("If it was true, it will become false, and if it was false "
|
||||
"it will become true."),
|
||||
@@ -461,37 +465,39 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
||||
|
||||
obj.AddCondition("ObjectVariableChildExists",
|
||||
_("Child existence"),
|
||||
_("Check if the specified child of the variable exists."),
|
||||
_("Check if the specified child of the object "
|
||||
"structure variable exists."),
|
||||
_("Child _PARAM2_ of variable _PARAM1_ of _PARAM0_ exists"),
|
||||
_("Variables/Collections/Structures"),
|
||||
_("Variables/Arrays and structures"),
|
||||
"res/conditions/var24.png",
|
||||
"res/conditions/var.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddParameter("objectvar", _("Variable"))
|
||||
.AddParameter("objectvar", _("Structure variable"))
|
||||
.AddParameter("string", _("Name of the child"))
|
||||
.MarkAsAdvanced();
|
||||
|
||||
obj.AddAction("ObjectVariableRemoveChild",
|
||||
_("Remove a child"),
|
||||
_("Remove a child from an object variable."),
|
||||
_("Remove a child from an object structure variable."),
|
||||
_("Remove child _PARAM2_ from variable _PARAM1_ of _PARAM0_"),
|
||||
_("Variables/Collections/Structures"),
|
||||
_("Variables/Arrays and structures"),
|
||||
"res/actions/var24.png",
|
||||
"res/actions/var.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddParameter("objectvar", _("Variable"))
|
||||
.AddParameter("objectvar", _("Structure variable"))
|
||||
.AddParameter("string", _("Child's name"))
|
||||
.MarkAsAdvanced();
|
||||
|
||||
obj.AddAction("ObjectVariableClearChildren",
|
||||
_("Clear variable"),
|
||||
_("Remove all the children from the object variable."),
|
||||
_("Clear children"),
|
||||
_("Remove all the children from the object array or structure "
|
||||
"variable."),
|
||||
_("Clear children from variable _PARAM1_ of _PARAM0_"),
|
||||
_("Variables/Collections"),
|
||||
_("Variables/Arrays and structures"),
|
||||
"res/actions/var24.png",
|
||||
"res/actions/var.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddParameter("objectvar", _("Variable"))
|
||||
.AddParameter("objectvar", _("Array or structure variable"))
|
||||
.MarkAsAdvanced();
|
||||
|
||||
obj.AddAction("Cache",
|
||||
@@ -619,8 +625,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
||||
.MarkAsAdvanced();
|
||||
|
||||
obj.AddCondition("VarObjet",
|
||||
_("Value of an object variable"),
|
||||
_("Compare the value of an object variable."),
|
||||
_("Number variable"),
|
||||
_("Compare the number value of an object variable."),
|
||||
_("the variable _PARAM1_"),
|
||||
_("Variables"),
|
||||
"res/conditions/var24.png",
|
||||
@@ -632,7 +638,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
||||
"number", ParameterOptions::MakeNewOptions());
|
||||
|
||||
obj.AddCondition("VarObjetTxt",
|
||||
_("Text of an object variable"),
|
||||
_("Text variable"),
|
||||
_("Compare the text of an object variable."),
|
||||
_("the text of variable _PARAM1_"),
|
||||
_("Variables"),
|
||||
@@ -645,7 +651,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
||||
"string", ParameterOptions::MakeNewOptions());
|
||||
|
||||
obj.AddCondition("ObjectVariableAsBoolean",
|
||||
_("Boolean value of an object variable"),
|
||||
_("Boolean variable"),
|
||||
_("Compare the boolean value of an object variable."),
|
||||
_("The boolean value of variable _PARAM1_ of object "
|
||||
"_PARAM0_ is _PARAM2_"),
|
||||
@@ -659,7 +665,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
||||
|
||||
obj.AddCondition("VarObjetDef",
|
||||
"Variable defined",
|
||||
"Check if the variable is defined.",
|
||||
"Check if the object variable is defined.",
|
||||
"Variable _PARAM1 of _PARAM0_ is defined",
|
||||
_("Variables"),
|
||||
"res/conditions/var24.png",
|
||||
@@ -667,78 +673,131 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
||||
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddParameter("string", _("Variable"))
|
||||
.SetHidden();
|
||||
.SetHidden(); // Deprecated.
|
||||
|
||||
obj.AddAction(
|
||||
"ObjectVariablePush",
|
||||
_("Append variable to an object array"),
|
||||
_("Appends a variable to the end of an object array variable."),
|
||||
_("Append variable _PARAM2_ to array variable _PARAM1_ of _PARAM0_"),
|
||||
_("Variables/Collections/Arrays"),
|
||||
_("Add existing variable"),
|
||||
_("Adds an existing variable to the end of an object array variable."),
|
||||
_("Add variable _PARAM2_ to array variable _PARAM1_ of _PARAM0_"),
|
||||
_("Variables/Arrays and structures"),
|
||||
"res/actions/var24.png",
|
||||
"res/actions/var.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddParameter("objectvar", _("Array variable"))
|
||||
.AddParameter("scenevar", _("Scene variable with the content to append"))
|
||||
.SetParameterLongDescription(
|
||||
_("The content of the variable will *be copied* and appended at the "
|
||||
"end of the array."))
|
||||
.AddParameter("scenevar", _("Scene variable with the content to add"))
|
||||
.SetParameterLongDescription(_("The content of the object variable will "
|
||||
"*be copied* and added at the "
|
||||
"end of the array."))
|
||||
.MarkAsAdvanced();
|
||||
|
||||
obj.AddAction(
|
||||
"ObjectVariablePushString",
|
||||
_("Append a string to an object array"),
|
||||
_("Appends a string to the end of an object array variable."),
|
||||
_("Append string _PARAM2_ to array variable _PARAM1_ of _PARAM0_"),
|
||||
_("Variables/Collections/Arrays"),
|
||||
_("Add text variable"),
|
||||
_("Adds a text (string) to the end of an object array variable."),
|
||||
_("Add text _PARAM2_ to array variable _PARAM1_ of _PARAM0_"),
|
||||
_("Variables/Arrays and structures"),
|
||||
"res/actions/var24.png",
|
||||
"res/actions/var.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddParameter("objectvar", _("Array variable"))
|
||||
.AddParameter("string", _("String to append"))
|
||||
.AddParameter("string", _("Text to add"))
|
||||
.MarkAsAdvanced();
|
||||
|
||||
obj.AddAction(
|
||||
"ObjectVariablePushNumber",
|
||||
_("Append a number to an object array"),
|
||||
_("Appends a number to the end of an object array variable."),
|
||||
_("Append number _PARAM2_ to array variable _PARAM1_ of _PARAM0_"),
|
||||
_("Variables/Collections/Arrays"),
|
||||
"res/actions/var24.png",
|
||||
"res/actions/var.png")
|
||||
obj.AddAction("ObjectVariablePushNumber",
|
||||
_("Add number variable"),
|
||||
_("Adds a number to the end of an object array variable."),
|
||||
_("Add number _PARAM2_ to array variable _PARAM1_ of _PARAM0_"),
|
||||
_("Variables/Arrays and structures"),
|
||||
"res/actions/var24.png",
|
||||
"res/actions/var.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddParameter("objectvar", _("Array variable"))
|
||||
.AddParameter("expression", _("Number to append"))
|
||||
.AddParameter("expression", _("Number to add"))
|
||||
.MarkAsAdvanced();
|
||||
|
||||
obj.AddAction(
|
||||
"ObjectVariablePushBool",
|
||||
_("Append a boolean to an object array"),
|
||||
_("Appends a boolean to the end of an object array variable."),
|
||||
_("Append boolean _PARAM2_ to array variable _PARAM1_ of _PARAM0_"),
|
||||
_("Variables/Collections/Arrays"),
|
||||
_("Add boolean variable"),
|
||||
_("Adds a boolean to the end of an object array variable."),
|
||||
_("Add boolean _PARAM2_ to array variable _PARAM1_ of _PARAM0_"),
|
||||
_("Variables/Arrays and structures"),
|
||||
"res/actions/var24.png",
|
||||
"res/actions/var.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddParameter("objectvar", _("Array variable"))
|
||||
.AddParameter("trueorfalse", _("Boolean to append"))
|
||||
.AddParameter("trueorfalse", _("Boolean to add"))
|
||||
.MarkAsAdvanced();
|
||||
|
||||
obj.AddAction(
|
||||
"ObjectVariableRemoveAt",
|
||||
_("Remove variable from an object array (by index)"),
|
||||
_("Remove variable by index"),
|
||||
_("Removes a variable at the specified index of an object array "
|
||||
"variable."),
|
||||
_("Remove variable at index _PARAM2_ from array variable _PARAM1_ of "
|
||||
"_PARAM0_"),
|
||||
_("Variables/Collections/Arrays"),
|
||||
_("Variables/Arrays and structures"),
|
||||
"res/actions/var24.png",
|
||||
"res/actions/var.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddParameter("objectvar", _("Variable"))
|
||||
.AddParameter("objectvar", _("Array variable"))
|
||||
.AddParameter("expression", _("Index to remove"))
|
||||
.MarkAsAdvanced();
|
||||
|
||||
obj.AddCondition(
|
||||
"ObjectVariableChildCount",
|
||||
_("Number of children"),
|
||||
_("Compare the number of children in an object array variable."),
|
||||
_("The number of children in the array variable _PARAM1_"),
|
||||
_("Variables/Arrays and structures"),
|
||||
"res/conditions/var24.png",
|
||||
"res/conditions/var.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddParameter("objectvar", _("Variable"))
|
||||
.UseStandardRelationalOperatorParameters(
|
||||
"number", ParameterOptions::MakeNewOptions())
|
||||
.MarkAsAdvanced();
|
||||
|
||||
obj.AddStrExpression(
|
||||
"ArrayVariableFirstString",
|
||||
_("First text child"),
|
||||
_("Get the value of the first element of an object array variable, if "
|
||||
"it is a text (string) variable."),
|
||||
_("Variables/Arrays and structures"),
|
||||
"res/actions/var.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddParameter("objectvar", _("Array variable"));
|
||||
|
||||
obj.AddExpression(
|
||||
"ArrayVariableFirstNumber",
|
||||
_("First number child"),
|
||||
_("Get the value of the first element of an object array variable, if "
|
||||
"it is a number variable."),
|
||||
_("Variables/Arrays and structures"),
|
||||
"res/actions/var.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddParameter("objectvar", _("Array variable"));
|
||||
|
||||
obj.AddStrExpression(
|
||||
"ArrayVariableLastString",
|
||||
_("Last text child"),
|
||||
_("Get the value of the last element of an object array variable, if "
|
||||
"it is a text (string) variable."),
|
||||
_("Variables/Arrays and structures"),
|
||||
"res/actions/var.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddParameter("objectvar", _("Array variable"));
|
||||
|
||||
obj.AddExpression(
|
||||
"ArrayVariableLastNumber",
|
||||
_("Last number child"),
|
||||
_("Get the value of the last element of an object array variable, if "
|
||||
"it is a number variable."),
|
||||
_("Variables/Arrays and structures"),
|
||||
"res/actions/var.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddParameter("objectvar", _("Array variable"));
|
||||
|
||||
obj.AddCondition("BehaviorActivated",
|
||||
_("Behavior activated"),
|
||||
_("Check if the behavior is activated for the object."),
|
||||
@@ -1115,23 +1174,24 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
||||
.AddParameter("expression", _("Target Y position"));
|
||||
|
||||
obj.AddExpression("Variable",
|
||||
_("Value of an object variable"),
|
||||
_("Value of an object variable"),
|
||||
_("Number variable"),
|
||||
_("Number value of an object variable"),
|
||||
_("Variables"),
|
||||
"res/actions/var.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddParameter("objectvar", _("Variable"));
|
||||
|
||||
obj.AddExpression("VariableChildCount",
|
||||
_("Number of children of an object variable"),
|
||||
_("Number of children of an object variable"),
|
||||
_("Variables"),
|
||||
"res/actions/var.png")
|
||||
obj.AddExpression(
|
||||
"VariableChildCount",
|
||||
_("Number of children"),
|
||||
_("Number of children in an object array or structure variable"),
|
||||
_("Variables/Arrays and structures"),
|
||||
"res/actions/var.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddParameter("objectvar", _("Variable"));
|
||||
.AddParameter("objectvar", _("Array or structure variable"));
|
||||
|
||||
obj.AddStrExpression("VariableString",
|
||||
_("Text of an object variable"),
|
||||
_("Text variable"),
|
||||
_("Text of an object variable"),
|
||||
_("Variables"),
|
||||
"res/actions/var.png")
|
||||
@@ -1293,7 +1353,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
||||
"res/actions/create24.png",
|
||||
"res/actions/create24.png")
|
||||
.AddCodeOnlyParameter("objectsContext", "")
|
||||
.AddParameter("objectListOrEmptyIfJustDeclared", _("Group of potential objects"))
|
||||
.AddParameter("objectListOrEmptyIfJustDeclared",
|
||||
_("Group of potential objects"))
|
||||
.SetParameterLongDescription(
|
||||
_("Group containing objects that can be created by the action."))
|
||||
.AddParameter("string", _("Name of the object to create"))
|
||||
|
@@ -27,9 +27,9 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
||||
|
||||
extension
|
||||
.AddCondition("VarScene",
|
||||
_("Value of a scene variable"),
|
||||
_("Compare the value of a scene variable."),
|
||||
_("the scene variable _PARAM0_"),
|
||||
_("Number variable"),
|
||||
_("Compare the number value of a scene variable."),
|
||||
_("The number of scene variable _PARAM0_"),
|
||||
_("Scene variables"),
|
||||
"res/conditions/var24.png",
|
||||
"res/conditions/var.png")
|
||||
@@ -39,9 +39,9 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
||||
|
||||
extension
|
||||
.AddCondition("VarSceneTxt",
|
||||
_("Text of a scene variable"),
|
||||
_("Compare the text of a scene variable."),
|
||||
_("the text of scene variable _PARAM0_"),
|
||||
_("Text variable"),
|
||||
_("Compare the text (string) of a scene variable."),
|
||||
_("The text of scene variable _PARAM0_"),
|
||||
_("Scene variables"),
|
||||
"res/conditions/var24.png",
|
||||
"res/conditions/var.png")
|
||||
@@ -52,7 +52,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
||||
extension
|
||||
.AddCondition(
|
||||
"SceneVariableAsBoolean",
|
||||
_("Boolean value of a scene variable"),
|
||||
_("Boolean variable"),
|
||||
_("Compare the boolean value of a scene variable."),
|
||||
_("The boolean value of scene variable _PARAM0_ is _PARAM1_"),
|
||||
_("Scene variables"),
|
||||
@@ -63,14 +63,14 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
||||
.SetDefaultValue("true");
|
||||
|
||||
extension
|
||||
.AddCondition(
|
||||
"VariableChildExists",
|
||||
_("Child existence"),
|
||||
_("Check if the specified child of the scene variable exists."),
|
||||
_("Child _PARAM1_ of scene variable _PARAM0_ exists"),
|
||||
_("Scene variables/Collections/Structures"),
|
||||
"res/conditions/var24.png",
|
||||
"res/conditions/var.png")
|
||||
.AddCondition("VariableChildExists",
|
||||
_("Child existence"),
|
||||
_("Check if the specified child of the scene structure "
|
||||
"variable exists."),
|
||||
_("Child _PARAM1_ of scene variable _PARAM0_ exists"),
|
||||
_("Scene variables/Arrays and structures"),
|
||||
"res/conditions/var24.png",
|
||||
"res/conditions/var.png")
|
||||
.AddParameter("scenevar", _("Variable"))
|
||||
.AddParameter("string", _("Name of the child"))
|
||||
.MarkAsAdvanced();
|
||||
@@ -78,10 +78,10 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
||||
extension
|
||||
.AddCondition("GlobalVariableChildExists",
|
||||
_("Child existence"),
|
||||
_("Check if the specified child of the global "
|
||||
_("Check if the specified child of the global structure "
|
||||
"variable exists."),
|
||||
_("Child _PARAM1_ of global variable _PARAM0_ exists"),
|
||||
_("Global variables/Collections/Structures"),
|
||||
_("Global variables/Arrays and structures"),
|
||||
"res/conditions/var24.png",
|
||||
"res/conditions/var.png")
|
||||
.AddParameter("globalvar", _("Variable"))
|
||||
@@ -90,7 +90,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
||||
|
||||
extension
|
||||
.AddCondition("VarSceneDef",
|
||||
"Test if a scene variable is defined",
|
||||
"Variable defined",
|
||||
"Test if the scene variable exists.",
|
||||
"Scene variable _PARAM0_ is defined",
|
||||
_("Scene variables"),
|
||||
@@ -98,12 +98,12 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
||||
"res/conditions/var.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.AddParameter("string", _("Variable"))
|
||||
.SetHidden();
|
||||
.SetHidden(); // Deprecated.
|
||||
|
||||
extension
|
||||
.AddCondition("VarGlobal",
|
||||
_("Value of a global variable"),
|
||||
_("Compare the value of a global variable."),
|
||||
_("Number variable"),
|
||||
_("Compare the number value of a global variable."),
|
||||
_("the global variable _PARAM0_"),
|
||||
_("Global variables"),
|
||||
"res/conditions/var24.png",
|
||||
@@ -115,8 +115,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
||||
|
||||
extension
|
||||
.AddCondition("VarGlobalTxt",
|
||||
_("Text of a global variable"),
|
||||
_("Compare the text of a global variable."),
|
||||
_("Text variable"),
|
||||
_("Compare the text (string) of a global variable."),
|
||||
_("the text of the global variable _PARAM0_"),
|
||||
_("Global variables"),
|
||||
"res/conditions/var24.png",
|
||||
@@ -129,7 +129,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
||||
extension
|
||||
.AddCondition(
|
||||
"GlobalVariableAsBoolean",
|
||||
_("Boolean value of a global variable"),
|
||||
_("Boolean variable"),
|
||||
_("Compare the boolean value of a global variable."),
|
||||
_("The boolean value of global variable _PARAM0_ is _PARAM1_"),
|
||||
_("Global variables"),
|
||||
@@ -141,8 +141,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
||||
|
||||
extension
|
||||
.AddCondition("VarGlobalDef",
|
||||
"Test if a global variable is defined",
|
||||
"Test if a global variable exists",
|
||||
"Variable defined",
|
||||
"Test if a global variable exists.",
|
||||
"Global variable _PARAM0_ is defined",
|
||||
_("Global variables"),
|
||||
"res/conditions/var24.png",
|
||||
@@ -150,12 +150,12 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.AddParameter("string", _("Variable"))
|
||||
.MarkAsAdvanced()
|
||||
.SetHidden();
|
||||
.SetHidden(); // Deprecated.
|
||||
|
||||
extension
|
||||
.AddAction("ModVarScene",
|
||||
_("Value of a scene variable"),
|
||||
_("Change the value of a scene variable."),
|
||||
_("Change number variable"),
|
||||
_("Modify the number value of a scene variable."),
|
||||
_("the scene variable _PARAM0_"),
|
||||
_("Scene variables"),
|
||||
"res/actions/var24.png",
|
||||
@@ -166,8 +166,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
||||
|
||||
extension
|
||||
.AddAction("ModVarSceneTxt",
|
||||
_("String of a scene variable"),
|
||||
_("Modify the text of a scene variable."),
|
||||
_("Change text variable"),
|
||||
_("Modify the text (string) of a scene variable."),
|
||||
_("the text of scene variable _PARAM0_"),
|
||||
_("Scene variables"),
|
||||
"res/actions/var24.png",
|
||||
@@ -179,7 +179,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
||||
extension
|
||||
.AddAction(
|
||||
"SetSceneVariableAsBoolean",
|
||||
_("Boolean value of a scene variable"),
|
||||
_("Change boolean variable"),
|
||||
_("Modify the boolean value of a scene variable."),
|
||||
_("Set the boolean value of scene variable _PARAM0_ to _PARAM1_"),
|
||||
_("Scene variables"),
|
||||
@@ -190,7 +190,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
||||
|
||||
extension
|
||||
.AddAction("ToggleSceneVariableAsBoolean",
|
||||
_("Toggle boolean value of a scene variable"),
|
||||
_("Toggle boolean variable"),
|
||||
_("Toggle the boolean value of a scene variable.") + "\n" +
|
||||
_("If it was true, it will become false, and if it was "
|
||||
"false it will become true."),
|
||||
@@ -202,8 +202,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
||||
|
||||
extension
|
||||
.AddAction("ModVarGlobal",
|
||||
_("Value of a global variable"),
|
||||
_("Change the value of a global variable"),
|
||||
_("Change number variable"),
|
||||
_("Modify the number value of a global variable."),
|
||||
_("the global variable _PARAM0_"),
|
||||
_("Global variables"),
|
||||
"res/actions/var24.png",
|
||||
@@ -215,8 +215,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
||||
|
||||
extension
|
||||
.AddAction("ModVarGlobalTxt",
|
||||
_("String of a global variable"),
|
||||
_("Modify the text of a global variable."),
|
||||
_("Change text variable"),
|
||||
_("Modify the text (string) of a global variable."),
|
||||
_("the text of global variable _PARAM0_"),
|
||||
_("Global variables"),
|
||||
"res/actions/var24.png",
|
||||
@@ -229,7 +229,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
||||
extension
|
||||
.AddAction(
|
||||
"SetGlobalVariableAsBoolean",
|
||||
_("Boolean value of a global variable"),
|
||||
_("Change boolean variable"),
|
||||
_("Modify the boolean value of a global variable."),
|
||||
_("Set the boolean value of global variable _PARAM0_ to _PARAM1_"),
|
||||
_("Global variables"),
|
||||
@@ -240,7 +240,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
||||
|
||||
extension
|
||||
.AddAction("ToggleGlobalVariableAsBoolean",
|
||||
_("Toggle boolean value of a global variable"),
|
||||
_("Toggle boolean variable"),
|
||||
_("Toggle the boolean value of a global variable.") + "\n" +
|
||||
_("If it was true, it will become false, and if it was "
|
||||
"false it will become true."),
|
||||
@@ -251,202 +251,324 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
||||
.AddParameter("globalvar", _("Variable"));
|
||||
|
||||
extension
|
||||
.AddAction("VariableRemoveChild",
|
||||
_("Remove a child"),
|
||||
_("Remove a child from a scene variable."),
|
||||
_("Remove child _PARAM1_ from scene variable _PARAM0_"),
|
||||
_("Scene variables/Collections/Structures"),
|
||||
"res/actions/var24.png",
|
||||
"res/actions/var.png")
|
||||
.AddParameter("scenevar", _("Variable"))
|
||||
.AddAction(
|
||||
"VariableRemoveChild",
|
||||
_("Remove a child"),
|
||||
_("Remove a child from a scene structure variable."),
|
||||
_("Remove child _PARAM1_ from scene structure variable _PARAM0_"),
|
||||
_("Scene variables/Arrays and structures"),
|
||||
"res/actions/var24.png",
|
||||
"res/actions/var.png")
|
||||
.AddParameter("scenevar", _("Structure variable"))
|
||||
.AddParameter("string", _("Child's name"))
|
||||
.MarkAsAdvanced();
|
||||
|
||||
extension
|
||||
.AddAction("GlobalVariableRemoveChild",
|
||||
_("Remove a child"),
|
||||
_("Remove a child from a global variable."),
|
||||
_("Remove child _PARAM1_ from global variable _PARAM0_"),
|
||||
_("Global variables/Collections/Structures"),
|
||||
"res/actions/var24.png",
|
||||
"res/actions/var.png")
|
||||
.AddParameter("globalvar", _("Variable"))
|
||||
.AddAction(
|
||||
"GlobalVariableRemoveChild",
|
||||
_("Remove a child"),
|
||||
_("Remove a child from a global structure variable."),
|
||||
_("Remove child _PARAM1_ from global structure variable _PARAM0_"),
|
||||
_("Global variables/Arrays and structures"),
|
||||
"res/actions/var24.png",
|
||||
"res/actions/var.png")
|
||||
.AddParameter("globalvar", _("Structure variable"))
|
||||
.AddParameter("string", _("Child's name"))
|
||||
.MarkAsAdvanced();
|
||||
|
||||
extension
|
||||
.AddAction("VariableClearChildren",
|
||||
_("Clear scene variable"),
|
||||
_("Remove all the children from the scene variable."),
|
||||
_("Clear children"),
|
||||
_("Remove all the children from the scene structure or array "
|
||||
"variable."),
|
||||
_("Clear children from scene variable _PARAM0_"),
|
||||
_("Scene variables/Collections"),
|
||||
_("Scene variables/Arrays and structures"),
|
||||
"res/actions/var24.png",
|
||||
"res/actions/var.png")
|
||||
.AddParameter("scenevar", _("Variable"))
|
||||
.AddParameter("scenevar", _("Structure or array variable"))
|
||||
.MarkAsAdvanced();
|
||||
|
||||
extension
|
||||
.AddAction("GlobalVariableClearChildren",
|
||||
_("Clear global variable"),
|
||||
_("Remove all the children from the global variable."),
|
||||
_("Clear children"),
|
||||
_("Remove all the children from the global structure or array "
|
||||
"variable."),
|
||||
_("Clear children from global variable _PARAM0_"),
|
||||
_("Global variables/Collections"),
|
||||
_("Global variables/Arrays and structures"),
|
||||
"res/actions/var24.png",
|
||||
"res/actions/var.png")
|
||||
.AddParameter("globalvar", _("Variable"))
|
||||
.AddParameter("globalvar", _("Structure or array variable"))
|
||||
.MarkAsAdvanced();
|
||||
|
||||
extension
|
||||
.AddAction("SceneVariablePush",
|
||||
_("Append variable to a scene array"),
|
||||
_("Appends a variable at the end of a scene array variable."),
|
||||
_("Append variable _PARAM1_ to array variable _PARAM0_"),
|
||||
_("Scene variables/Collections/Arrays"),
|
||||
_("Add existing variable"),
|
||||
_("Adds an existing variable at the end of a scene array "
|
||||
"variable."),
|
||||
_("Add variable _PARAM1_ to array variable _PARAM0_"),
|
||||
_("Scene variables/Arrays and structures"),
|
||||
"res/actions/var24.png",
|
||||
"res/actions/var.png")
|
||||
.AddParameter("scenevar", _("Array variable"))
|
||||
.AddParameter("scenevar", _("Scene variable with the content to append"))
|
||||
.SetParameterLongDescription(_("The content of the variable will *be copied* and appended at the end of the array."))
|
||||
.AddParameter("scenevar", _("Scene variable with the content to add"))
|
||||
.SetParameterLongDescription(
|
||||
_("The content of the variable will *be copied* and added at the "
|
||||
"end of the array."))
|
||||
.MarkAsAdvanced();
|
||||
|
||||
extension
|
||||
.AddAction("SceneVariablePushString",
|
||||
_("Append a string to a scene array"),
|
||||
_("Appends a string at the end of a scene array variable."),
|
||||
_("Append string _PARAM1_ to array variable _PARAM0_"),
|
||||
_("Scene variables/Collections/Arrays"),
|
||||
"res/actions/var24.png",
|
||||
"res/actions/var.png")
|
||||
.AddAction(
|
||||
"SceneVariablePushString",
|
||||
_("Add text variable"),
|
||||
_("Adds a text (string) at the end of a scene array variable."),
|
||||
_("Add text _PARAM1_ to array variable _PARAM0_"),
|
||||
_("Scene variables/Arrays and structures"),
|
||||
"res/actions/var24.png",
|
||||
"res/actions/var.png")
|
||||
.AddParameter("scenevar", _("Array variable"))
|
||||
.AddParameter("string", _("String to append"))
|
||||
.AddParameter("string", _("Text to add"))
|
||||
.MarkAsAdvanced();
|
||||
|
||||
extension
|
||||
.AddAction("SceneVariablePushNumber",
|
||||
_("Append a number to a scene array"),
|
||||
_("Appends a number at the end of a scene array variable."),
|
||||
_("Append number _PARAM1_ to array variable _PARAM0_"),
|
||||
_("Scene variables/Collections/Arrays"),
|
||||
_("Add number variable"),
|
||||
_("Adds a number at the end of a scene array variable."),
|
||||
_("Add number _PARAM1_ to array variable _PARAM0_"),
|
||||
_("Scene variables/Arrays and structures"),
|
||||
"res/actions/var24.png",
|
||||
"res/actions/var.png")
|
||||
.AddParameter("scenevar", _("Array variable"))
|
||||
.AddParameter("expression", _("Number to append"))
|
||||
.AddParameter("expression", _("Number to add"))
|
||||
.MarkAsAdvanced();
|
||||
|
||||
extension
|
||||
.AddAction("SceneVariablePushBool",
|
||||
_("Append a boolean to a scene array"),
|
||||
_("Appends a boolean at the end of a scene array variable."),
|
||||
_("Append boolean _PARAM1_ to array variable _PARAM0_"),
|
||||
_("Scene variables/Collections/Arrays"),
|
||||
_("Add boolean variable"),
|
||||
_("Adds a boolean at the end of a scene array variable."),
|
||||
_("Add boolean _PARAM1_ to array variable _PARAM0_"),
|
||||
_("Scene variables/Arrays and structures"),
|
||||
"res/actions/var24.png",
|
||||
"res/actions/var.png")
|
||||
.AddParameter("scenevar", _("Array variable"))
|
||||
.AddParameter("trueorfalse", _("Boolean to append"))
|
||||
.AddParameter("trueorfalse", _("Boolean to add"))
|
||||
.MarkAsAdvanced();
|
||||
|
||||
extension
|
||||
.AddAction(
|
||||
"SceneVariableRemoveAt",
|
||||
_("Remove variable from a scene array (by index)"),
|
||||
_("Removes a variable at the specified index of a scene array variable."),
|
||||
_("Remove variable at index _PARAM1_ from scene array variable _PARAM0_"),
|
||||
_("Scene variables/Collections/Arrays"),
|
||||
"res/actions/var24.png",
|
||||
"res/actions/var.png")
|
||||
.AddParameter("scenevar", _("Variable"))
|
||||
.AddAction("SceneVariableRemoveAt",
|
||||
_("Remove variable by index"),
|
||||
_("Removes a variable at the specified index of a scene array "
|
||||
"variable."),
|
||||
_("Remove variable at index _PARAM1_ from scene array "
|
||||
"variable _PARAM0_"),
|
||||
_("Scene variables/Arrays and structures"),
|
||||
"res/actions/var24.png",
|
||||
"res/actions/var.png")
|
||||
.AddParameter("scenevar", _("Array variable"))
|
||||
.AddParameter("expression", _("Index to remove"))
|
||||
.MarkAsAdvanced();
|
||||
|
||||
extension
|
||||
.AddAction("GlobalVariablePush",
|
||||
_("Append variable to a global array"),
|
||||
_("Appends a variable at the end of a global array variable."),
|
||||
_("Append variable _PARAM1_ to array variable _PARAM0_"),
|
||||
_("Global variables/Collections/Arrays"),
|
||||
"res/actions/var24.png",
|
||||
"res/actions/var.png")
|
||||
.AddParameter("globalvar", _("Array variable"))
|
||||
.AddParameter("scenevar", _("Scene variable with the content to append"))
|
||||
.SetParameterLongDescription(_("The content of the variable will *be copied* and appended at the end of the array."))
|
||||
.AddCondition(
|
||||
"SceneVariableChildCount",
|
||||
_("Number of children"),
|
||||
_("Compare the number of children in a scene array variable."),
|
||||
_("The number of children in the array variable _PARAM0_"),
|
||||
_("Scene variables/Arrays and structures"),
|
||||
"res/conditions/var24.png",
|
||||
"res/conditions/var.png")
|
||||
.AddParameter("scenevar", _("Array variable"))
|
||||
.UseStandardRelationalOperatorParameters(
|
||||
"number", ParameterOptions::MakeNewOptions())
|
||||
.MarkAsAdvanced();
|
||||
|
||||
extension
|
||||
.AddStrExpression(
|
||||
"SceneVariableFirstString",
|
||||
_("First text child"),
|
||||
_("Get the value of the first element of a scene array variable, if "
|
||||
"it is a text (string)."),
|
||||
_("Scene variables/Arrays and structures"),
|
||||
"res/actions/var.png")
|
||||
.AddParameter("scenevar", _("Array variable"));
|
||||
|
||||
extension
|
||||
.AddExpression(
|
||||
"SceneVariableFirstNumber",
|
||||
_("First number child"),
|
||||
_("Get the value of the first element of a scene array variable, if "
|
||||
"it is a number."),
|
||||
_("Scene variables/Arrays and structures"),
|
||||
"res/actions/var.png")
|
||||
.AddParameter("scenevar", _("Array variable"));
|
||||
|
||||
extension
|
||||
.AddStrExpression(
|
||||
"SceneVariableLastString",
|
||||
_("Last text child"),
|
||||
_("Get the value of the last element of a scene array variable, if "
|
||||
"it is a text (string)."),
|
||||
_("Scene variables/Arrays and structures"),
|
||||
"res/actions/var.png")
|
||||
.AddParameter("scenevar", _("Array variable"));
|
||||
|
||||
extension
|
||||
.AddExpression(
|
||||
"SceneVariableLastNumber",
|
||||
_("Last number child"),
|
||||
_("Get the value of the last element of a scene array variable, if "
|
||||
"it is a number."),
|
||||
_("Scene variables/Arrays and structures"),
|
||||
"res/actions/var.png")
|
||||
.AddParameter("scenevar", _("Array variable"));
|
||||
|
||||
extension
|
||||
.AddAction(
|
||||
"GlobalVariableRemoveAt",
|
||||
_("Remove variable from a global array (by index)"),
|
||||
_("Removes a variable at the specified index of a global array variable."),
|
||||
_("Remove variable at index _PARAM1_ from global array variable _PARAM0_"),
|
||||
_("Global variables/Collections/Arrays"),
|
||||
"GlobalVariablePush",
|
||||
_("Add existing variable"),
|
||||
_("Adds an existing variable at the end of a global array variable."),
|
||||
_("Add variable _PARAM1_ to array variable _PARAM0_"),
|
||||
_("Global variables/Arrays and structures"),
|
||||
"res/actions/var24.png",
|
||||
"res/actions/var.png")
|
||||
.AddParameter("globalvar", _("Variable"))
|
||||
.AddParameter("globalvar", _("Array variable"))
|
||||
.AddParameter("scenevar", _("Scene variable with the content to add"))
|
||||
.SetParameterLongDescription(
|
||||
_("The content of the variable will *be copied* and added at the "
|
||||
"end of the array."))
|
||||
.MarkAsAdvanced();
|
||||
|
||||
extension
|
||||
.AddAction("GlobalVariableRemoveAt",
|
||||
_("Remove variable by index"),
|
||||
_("Removes a variable at the specified index of a global "
|
||||
"array variable."),
|
||||
_("Remove variable at index _PARAM1_ from global array "
|
||||
"variable _PARAM0_"),
|
||||
_("Global variables/Arrays and structures"),
|
||||
"res/actions/var24.png",
|
||||
"res/actions/var.png")
|
||||
.AddParameter("globalvar", _("Array variable"))
|
||||
.AddParameter("expression", _("Index to remove"))
|
||||
.MarkAsAdvanced();
|
||||
|
||||
extension
|
||||
.AddAction("GlobalVariablePushString",
|
||||
_("Append a string to a global array"),
|
||||
_("Appends a string at the end of a global array variable."),
|
||||
_("Append string _PARAM1_ to array variable _PARAM0_"),
|
||||
_("Global variables/Collections/Arrays"),
|
||||
"res/actions/var24.png",
|
||||
"res/actions/var.png")
|
||||
.AddAction(
|
||||
"GlobalVariablePushString",
|
||||
_("Add text variable"),
|
||||
_("Adds a text (string) at the end of a global array variable."),
|
||||
_("Add text _PARAM1_ to array variable _PARAM0_"),
|
||||
_("Global variables/Arrays and structures"),
|
||||
"res/actions/var24.png",
|
||||
"res/actions/var.png")
|
||||
.AddParameter("globalvar", _("Array variable"))
|
||||
.AddParameter("string", _("String to append"))
|
||||
.AddParameter("string", _("Text to add"))
|
||||
.MarkAsAdvanced();
|
||||
|
||||
extension
|
||||
.AddAction("GlobalVariablePushNumber",
|
||||
_("Append a number to a global array"),
|
||||
_("Appends a number at the end of a global array variable."),
|
||||
_("Append number _PARAM1_ to array variable _PARAM0_"),
|
||||
_("Global variables/Collections/Arrays"),
|
||||
_("Add number variable"),
|
||||
_("Adds a number at the end of a global array variable."),
|
||||
_("Add number _PARAM1_ to array variable _PARAM0_"),
|
||||
_("Global variables/Arrays and structures"),
|
||||
"res/actions/var24.png",
|
||||
"res/actions/var.png")
|
||||
.AddParameter("globalvar", _("Array variable"))
|
||||
.AddParameter("expression", _("Number to append"))
|
||||
.AddParameter("expression", _("Number to add"))
|
||||
.MarkAsAdvanced();
|
||||
|
||||
extension
|
||||
.AddAction("GlobalVariablePushBool",
|
||||
_("Append a boolean to a global array"),
|
||||
_("Appends a boolean at the end of a global array variable."),
|
||||
_("Append boolean _PARAM1_ to array variable _PARAM0_"),
|
||||
_("Global variables/Collections/Arrays"),
|
||||
_("Add boolean variable"),
|
||||
_("Adds a boolean at the end of a global array variable."),
|
||||
_("Add boolean _PARAM1_ to array variable _PARAM0_"),
|
||||
_("Global variables/Arrays and structures"),
|
||||
"res/actions/var24.png",
|
||||
"res/actions/var.png")
|
||||
.AddParameter("globalvar", _("Array variable"))
|
||||
.AddParameter("trueorfalse", _("Boolean to append"))
|
||||
.AddParameter("trueorfalse", _("Boolean to add"))
|
||||
.MarkAsAdvanced();
|
||||
|
||||
extension
|
||||
.AddExpression("GlobalVariableChildCount",
|
||||
_("Number of children of a global variable"),
|
||||
_("Number of children of a global variable"),
|
||||
_("Global variables"),
|
||||
.AddCondition(
|
||||
"GlobalVariableChildCount",
|
||||
_("Number of children"),
|
||||
_("Compare the number of children in a global array variable."),
|
||||
_("The number of children of the array variable _PARAM0_"),
|
||||
_("Global variables/Arrays and structures"),
|
||||
"res/conditions/var24.png",
|
||||
"res/conditions/var.png")
|
||||
.AddParameter("globalvar", _("Array variable"))
|
||||
.UseStandardRelationalOperatorParameters(
|
||||
"number", ParameterOptions::MakeNewOptions())
|
||||
.MarkAsAdvanced();
|
||||
|
||||
extension
|
||||
.AddStrExpression("GlobalVariableFirstString",
|
||||
_("First text child"),
|
||||
_("Value of the first element of a global array "
|
||||
"variable, if it is a text (string) variable."),
|
||||
_("Global variables/Arrays and structures"),
|
||||
"res/actions/var.png")
|
||||
.AddParameter("globalvar", _("Array variable"));
|
||||
|
||||
extension
|
||||
.AddExpression("GlobalVariableFirstNumber",
|
||||
_("First number child"),
|
||||
_("Value of the first element of a global array "
|
||||
"variable, if it is a number variable"),
|
||||
_("Global variables/Arrays and structures"),
|
||||
"res/actions/var.png")
|
||||
.AddParameter("globalvar", _("Variable"));
|
||||
.AddParameter("globalvar", _("Array variable"));
|
||||
|
||||
extension
|
||||
.AddStrExpression(
|
||||
"GlobalVariableLastString",
|
||||
_("Last text child"),
|
||||
_("Value of the last element of a global array variable, if "
|
||||
"it is a text (string) variable."),
|
||||
_("Global variables/Arrays and structures"),
|
||||
"res/actions/var.png")
|
||||
.AddParameter("globalvar", _("Array variable"));
|
||||
|
||||
extension
|
||||
.AddExpression(
|
||||
"GlobalVariableLastNumber",
|
||||
_("Last number child"),
|
||||
_("Value of the last element of a global array variable, if "
|
||||
"it is a number variable"),
|
||||
_("Global variables/Arrays and structures"),
|
||||
"res/actions/var.png")
|
||||
.AddParameter("globalvar", _("Array variable"));
|
||||
|
||||
extension
|
||||
.AddExpression("GlobalVariableChildCount",
|
||||
_("Number of children"),
|
||||
_("Number of children in a global array or "
|
||||
"structure variable"),
|
||||
_("Global variables/Arrays and structures"),
|
||||
"res/actions/var.png")
|
||||
.AddParameter("globalvar", _("Array or structure variable"));
|
||||
|
||||
extension
|
||||
.AddExpression("VariableChildCount",
|
||||
_("Number of children of a scene variable"),
|
||||
_("Number of children of a scene variable"),
|
||||
_("Scene variables"),
|
||||
_("Number of children"),
|
||||
_("Number of children in a scene array or "
|
||||
"structure variable"),
|
||||
_("Scene variables/Arrays and structures"),
|
||||
"res/actions/var.png")
|
||||
.AddParameter("scenevar", _("Variable"));
|
||||
.AddParameter("scenevar", _("Array or structure variable"));
|
||||
|
||||
extension
|
||||
.AddExpression("Variable",
|
||||
_("Value of a scene variable"),
|
||||
_("Value of a scene variable"),
|
||||
_("Number variable"),
|
||||
_("Number value of a scene variable"),
|
||||
_("Scene variables"),
|
||||
"res/actions/var.png")
|
||||
.AddParameter("scenevar", _("Variable"));
|
||||
|
||||
extension
|
||||
.AddStrExpression("VariableString",
|
||||
_("Text of a scene variable"),
|
||||
_("Text variable"),
|
||||
_("Text of a scene variable"),
|
||||
_("Scene variables"),
|
||||
"res/actions/var.png")
|
||||
@@ -454,15 +576,15 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
||||
|
||||
extension
|
||||
.AddExpression("GlobalVariable",
|
||||
_("Value of a global variable"),
|
||||
_("Value of a global variable"),
|
||||
_("Number variable"),
|
||||
_("Number value of a global variable"),
|
||||
_("Global variables"),
|
||||
"res/actions/var.png")
|
||||
.AddParameter("globalvar", _("Name of the global variable"));
|
||||
|
||||
extension
|
||||
.AddStrExpression("GlobalVariableString",
|
||||
_("Text of a global variable"),
|
||||
_("Text variable"),
|
||||
_("Text of a global variable"),
|
||||
_("Global variables"),
|
||||
"res/actions/var.png")
|
||||
|
@@ -23,7 +23,8 @@ ExpressionMetadata::ExpressionMetadata(const gd::String& returnType_,
|
||||
shown(true),
|
||||
smallIconFilename(smallicon_),
|
||||
extensionNamespace(extensionNamespace_),
|
||||
isPrivate(false) {
|
||||
isPrivate(false),
|
||||
relevantContext("Any") {
|
||||
}
|
||||
|
||||
ExpressionMetadata& ExpressionMetadata::SetHidden() {
|
||||
|
@@ -137,7 +137,7 @@ class GD_CORE_API ExpressionMetadata {
|
||||
* to fulfill std::map requirements.
|
||||
*/
|
||||
ExpressionMetadata()
|
||||
: returnType("unknown"), shown(false), isPrivate(false){};
|
||||
: returnType("unknown"), shown(false), isPrivate(false), relevantContext("Any"){};
|
||||
|
||||
virtual ~ExpressionMetadata(){};
|
||||
|
||||
@@ -184,6 +184,67 @@ class GD_CORE_API ExpressionMetadata {
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the instruction can be used in layouts or external events.
|
||||
*/
|
||||
bool IsRelevantForLayoutEvents() const {
|
||||
return relevantContext == "Any" || relevantContext == "Layout";
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the instruction can be used in function events.
|
||||
*/
|
||||
bool IsRelevantForFunctionEvents() const {
|
||||
return relevantContext == "Any" || relevantContext == "Function";
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the instruction can be used in asynchronous function events.
|
||||
*/
|
||||
bool IsRelevantForAsynchronousFunctionEvents() const {
|
||||
return relevantContext == "Any" || relevantContext == "Function" ||
|
||||
relevantContext == "AsynchronousFunction";
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the instruction can be used in custom object events.
|
||||
*/
|
||||
bool IsRelevantForCustomObjectEvents() const {
|
||||
return relevantContext == "Any" || relevantContext == "Object";
|
||||
}
|
||||
|
||||
/**
|
||||
* Set that the instruction can be used in layouts or external events.
|
||||
*/
|
||||
ExpressionMetadata &SetRelevantForLayoutEventsOnly() {
|
||||
relevantContext = "Layout";
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set that the instruction can be used in function events.
|
||||
*/
|
||||
ExpressionMetadata &SetRelevantForFunctionEventsOnly() {
|
||||
relevantContext = "Function";
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set that the instruction can be used in asynchronous function events.
|
||||
*/
|
||||
ExpressionMetadata &SetRelevantForAsynchronousFunctionEventsOnly() {
|
||||
relevantContext = "AsynchronousFunction";
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set that the instruction can be used in custom object events.
|
||||
*/
|
||||
ExpressionMetadata &SetRelevantForCustomObjectEventsOnly() {
|
||||
relevantContext = "Object";
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* \see gd::InstructionMetadata::AddParameter
|
||||
*/
|
||||
@@ -326,6 +387,7 @@ class GD_CORE_API ExpressionMetadata {
|
||||
gd::String extensionNamespace;
|
||||
bool isPrivate;
|
||||
gd::String requiredBaseObjectCapability;
|
||||
gd::String relevantContext;
|
||||
};
|
||||
|
||||
} // namespace gd
|
||||
|
@@ -47,7 +47,8 @@ InstructionMetadata::InstructionMetadata(const gd::String& extensionNamespace_,
|
||||
usageComplexity(5),
|
||||
isPrivate(false),
|
||||
isObjectInstruction(false),
|
||||
isBehaviorInstruction(false) {}
|
||||
isBehaviorInstruction(false),
|
||||
relevantContext("Any") {}
|
||||
|
||||
InstructionMetadata& InstructionMetadata::AddParameter(
|
||||
const gd::String& type,
|
||||
|
@@ -101,6 +101,67 @@ class GD_CORE_API InstructionMetadata {
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the instruction can be used in layouts or external events.
|
||||
*/
|
||||
bool IsRelevantForLayoutEvents() const {
|
||||
return relevantContext == "Any" || relevantContext == "Layout";
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the instruction can be used in function events.
|
||||
*/
|
||||
bool IsRelevantForFunctionEvents() const {
|
||||
return relevantContext == "Any" || relevantContext == "Function";
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the instruction can be used in asynchronous function events.
|
||||
*/
|
||||
bool IsRelevantForAsynchronousFunctionEvents() const {
|
||||
return relevantContext == "Any" || relevantContext == "Function" ||
|
||||
relevantContext == "AsynchronousFunction";
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the instruction can be used in custom object events.
|
||||
*/
|
||||
bool IsRelevantForCustomObjectEvents() const {
|
||||
return relevantContext == "Any" || relevantContext == "Object";
|
||||
}
|
||||
|
||||
/**
|
||||
* Set that the instruction can be used in layouts or external events.
|
||||
*/
|
||||
InstructionMetadata &SetRelevantForLayoutEventsOnly() {
|
||||
relevantContext = "Layout";
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set that the instruction can be used in function events.
|
||||
*/
|
||||
InstructionMetadata &SetRelevantForFunctionEventsOnly() {
|
||||
relevantContext = "Function";
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set that the instruction can be used in asynchronous function events.
|
||||
*/
|
||||
InstructionMetadata &SetRelevantForAsynchronousFunctionEventsOnly() {
|
||||
relevantContext = "AsynchronousFunction";
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set that the instruction can be used in custom object events.
|
||||
*/
|
||||
InstructionMetadata &SetRelevantForCustomObjectEventsOnly() {
|
||||
relevantContext = "Object";
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the instruction is asynchronous - it will be running in the
|
||||
* background, executing the instructions following it before the frame after
|
||||
@@ -539,6 +600,7 @@ class GD_CORE_API InstructionMetadata {
|
||||
bool isObjectInstruction;
|
||||
bool isBehaviorInstruction;
|
||||
gd::String requiredBaseObjectCapability;
|
||||
gd::String relevantContext;
|
||||
};
|
||||
|
||||
} // namespace gd
|
||||
|
@@ -202,7 +202,7 @@ std::set<gd::String> EventsIdentifiersFinder::FindAllIdentifierExpressions(
|
||||
std::set<gd::String> results;
|
||||
|
||||
const bool isObjectIdentifier = identifierType.find("object") == 0;
|
||||
// The object from the context is only relevent for object identifiers.
|
||||
// The object from the context is only relevant for object identifiers.
|
||||
auto& actualObjectName = isObjectIdentifier ? contextObjectName : "";
|
||||
|
||||
FindArgumentsInEventsAndDependencies(
|
||||
|
24
Core/GDCore/IDE/Events/InstructionsCountEvaluator.cpp
Normal file
24
Core/GDCore/IDE/Events/InstructionsCountEvaluator.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
#include "InstructionsCountEvaluator.h"
|
||||
|
||||
#include "GDCore/Events/Instruction.h"
|
||||
#include "GDCore/Extensions/PlatformExtension.h"
|
||||
#include "GDCore/IDE/WholeProjectRefactorer.h"
|
||||
|
||||
namespace gd {
|
||||
|
||||
const int InstructionsCountEvaluator::ScanProject(gd::Project &project) {
|
||||
InstructionsCountEvaluator worker(project);
|
||||
gd::WholeProjectRefactorer::ExposeProjectEventsWithoutExtensions(project,
|
||||
worker);
|
||||
return worker.instructionCount;
|
||||
};
|
||||
|
||||
// Instructions scanner
|
||||
|
||||
bool InstructionsCountEvaluator::DoVisitInstruction(
|
||||
gd::Instruction &instruction, bool isCondition) {
|
||||
instructionCount++;
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace gd
|
50
Core/GDCore/IDE/Events/InstructionsCountEvaluator.h
Normal file
50
Core/GDCore/IDE/Events/InstructionsCountEvaluator.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* GDevelop Core
|
||||
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
|
||||
* reserved. This project is released under the MIT License.
|
||||
*/
|
||||
|
||||
#ifndef GDCORE_INSTRUCTIONS_COUNT_EVALUATOR_H
|
||||
#define GDCORE_INSTRUCTIONS_COUNT_EVALUATOR_H
|
||||
#include <set>
|
||||
|
||||
#include "GDCore/Events/Parsers/ExpressionParser2NodeWorker.h"
|
||||
#include "GDCore/IDE/Events/ArbitraryEventsWorker.h"
|
||||
#include "GDCore/IDE/Project/ArbitraryObjectsWorker.h"
|
||||
#include "GDCore/String.h"
|
||||
|
||||
namespace gd {
|
||||
class Project;
|
||||
class Object;
|
||||
class Behavior;
|
||||
} // namespace gd
|
||||
|
||||
namespace gd {
|
||||
|
||||
/**
|
||||
* @brief Count the number of instructions in a project excluding extensions.
|
||||
*
|
||||
* This is used by the examples repository to evaluate examples size.
|
||||
*
|
||||
*/
|
||||
class GD_CORE_API InstructionsCountEvaluator : public ArbitraryEventsWorker {
|
||||
public:
|
||||
/**
|
||||
* Return the number of instructions in the project excluding extensions.
|
||||
*/
|
||||
static const int ScanProject(gd::Project &project);
|
||||
|
||||
private:
|
||||
InstructionsCountEvaluator(gd::Project &project_)
|
||||
: project(project_), instructionCount(0){};
|
||||
gd::Project &project;
|
||||
int instructionCount;
|
||||
|
||||
// Instructions Visitor
|
||||
bool DoVisitInstruction(gd::Instruction &instruction,
|
||||
bool isCondition) override;
|
||||
};
|
||||
|
||||
}; // namespace gd
|
||||
|
||||
#endif
|
@@ -49,14 +49,8 @@ void WholeProjectRefactorer::ExposeProjectEvents(
|
||||
// See also gd::Project::ExposeResources for a method that traverse the whole
|
||||
// project (this time for resources).
|
||||
|
||||
// Add layouts events
|
||||
for (std::size_t s = 0; s < project.GetLayoutsCount(); s++) {
|
||||
worker.Launch(project.GetLayout(s).GetEvents());
|
||||
}
|
||||
// Add external events events
|
||||
for (std::size_t s = 0; s < project.GetExternalEventsCount(); s++) {
|
||||
worker.Launch(project.GetExternalEvents(s).GetEvents());
|
||||
}
|
||||
ExposeProjectEventsWithoutExtensions(project, worker);
|
||||
|
||||
// Add events based extensions
|
||||
for (std::size_t e = 0; e < project.GetEventsFunctionsExtensionsCount();
|
||||
e++) {
|
||||
@@ -90,6 +84,18 @@ void WholeProjectRefactorer::ExposeProjectEvents(
|
||||
}
|
||||
}
|
||||
|
||||
void WholeProjectRefactorer::ExposeProjectEventsWithoutExtensions(
|
||||
gd::Project& project, gd::ArbitraryEventsWorker& worker) {
|
||||
// Add layouts events
|
||||
for (std::size_t s = 0; s < project.GetLayoutsCount(); s++) {
|
||||
worker.Launch(project.GetLayout(s).GetEvents());
|
||||
}
|
||||
// Add external events events
|
||||
for (std::size_t s = 0; s < project.GetExternalEventsCount(); s++) {
|
||||
worker.Launch(project.GetExternalEvents(s).GetEvents());
|
||||
}
|
||||
}
|
||||
|
||||
void WholeProjectRefactorer::ExposeProjectEvents(
|
||||
gd::Project& project, gd::ArbitraryEventsWorkerWithContext& worker) {
|
||||
// See also gd::Project::ExposeResources for a method that traverse the whole
|
||||
|
@@ -47,6 +47,14 @@ class GD_CORE_API WholeProjectRefactorer {
|
||||
*/
|
||||
static void ExposeProjectEvents(gd::Project& project,
|
||||
gd::ArbitraryEventsWorker& worker);
|
||||
/**
|
||||
* \brief Call the specified worker on all events of the project (layout and
|
||||
* external events) but not events from extensions.
|
||||
*
|
||||
* Only use this for stats.
|
||||
*/
|
||||
static void ExposeProjectEventsWithoutExtensions(gd::Project& project,
|
||||
gd::ArbitraryEventsWorker& worker);
|
||||
|
||||
/**
|
||||
* \brief Call the specified worker on all events of the project (layout,
|
||||
|
@@ -11,7 +11,7 @@
|
||||
namespace gd {
|
||||
|
||||
LoadingScreen::LoadingScreen()
|
||||
: showGDevelopLogoDuringLoadingScreen(false),
|
||||
: showGDevelopLogoDuringLoadingScreen(true),
|
||||
gdevelopLogoStyle("light"),
|
||||
backgroundImageResourceName(""),
|
||||
backgroundColor(0),
|
||||
@@ -27,16 +27,18 @@ LoadingScreen::LoadingScreen()
|
||||
progressBarColor(0xFFFFFF){};
|
||||
|
||||
void LoadingScreen::SerializeTo(SerializerElement& element) const {
|
||||
element.SetAttribute("showGDevelopSplash", showGDevelopLogoDuringLoadingScreen);
|
||||
element.SetAttribute("gdevelopLogoStyle",
|
||||
gdevelopLogoStyle);
|
||||
element.SetAttribute("showGDevelopSplash",
|
||||
showGDevelopLogoDuringLoadingScreen);
|
||||
element.SetAttribute("gdevelopLogoStyle", gdevelopLogoStyle);
|
||||
element.SetAttribute("backgroundImageResourceName",
|
||||
backgroundImageResourceName);
|
||||
element.SetAttribute("backgroundColor", backgroundColor);
|
||||
element.SetAttribute("backgroundFadeInDuration", backgroundFadeInDuration);
|
||||
element.SetAttribute("minDuration", minDuration);
|
||||
element.SetAttribute("logoAndProgressFadeInDuration", logoAndProgressFadeInDuration);
|
||||
element.SetAttribute("logoAndProgressLogoFadeInDelay", logoAndProgressLogoFadeInDelay);
|
||||
element.SetAttribute("logoAndProgressFadeInDuration",
|
||||
logoAndProgressFadeInDuration);
|
||||
element.SetAttribute("logoAndProgressLogoFadeInDelay",
|
||||
logoAndProgressLogoFadeInDelay);
|
||||
element.SetAttribute("showProgressBar", showProgressBar);
|
||||
element.SetAttribute("progressBarMinWidth", progressBarMinWidth);
|
||||
element.SetAttribute("progressBarMaxWidth", progressBarMaxWidth);
|
||||
@@ -46,21 +48,24 @@ void LoadingScreen::SerializeTo(SerializerElement& element) const {
|
||||
}
|
||||
|
||||
void LoadingScreen::UnserializeFrom(const SerializerElement& element) {
|
||||
showGDevelopLogoDuringLoadingScreen = element.GetBoolAttribute("showGDevelopSplash", true);
|
||||
gdevelopLogoStyle =
|
||||
element.GetStringAttribute("gdevelopLogoStyle", "light");
|
||||
showGDevelopLogoDuringLoadingScreen =
|
||||
element.GetBoolAttribute("showGDevelopSplash", true);
|
||||
gdevelopLogoStyle = element.GetStringAttribute("gdevelopLogoStyle", "light");
|
||||
backgroundImageResourceName =
|
||||
element.GetStringAttribute("backgroundImageResourceName");
|
||||
backgroundColor = element.GetIntAttribute("backgroundColor", 0);
|
||||
backgroundFadeInDuration =
|
||||
element.GetDoubleAttribute("backgroundFadeInDuration", 0.2);
|
||||
minDuration = element.GetDoubleAttribute("minDuration", 1.5);
|
||||
logoAndProgressFadeInDuration = element.GetDoubleAttribute("logoAndProgressFadeInDuration", 0.2);
|
||||
logoAndProgressLogoFadeInDelay = element.GetDoubleAttribute("logoAndProgressLogoFadeInDelay", 0.2);
|
||||
logoAndProgressFadeInDuration =
|
||||
element.GetDoubleAttribute("logoAndProgressFadeInDuration", 0.2);
|
||||
logoAndProgressLogoFadeInDelay =
|
||||
element.GetDoubleAttribute("logoAndProgressLogoFadeInDelay", 0.2);
|
||||
showProgressBar = element.GetBoolAttribute("showProgressBar", true);
|
||||
progressBarMinWidth = element.GetDoubleAttribute("progressBarMinWidth", 40);
|
||||
progressBarMaxWidth = element.GetDoubleAttribute("progressBarMaxWidth", 200);
|
||||
progressBarWidthPercent = element.GetDoubleAttribute("progressBarWidthPercent", 30);
|
||||
progressBarWidthPercent =
|
||||
element.GetDoubleAttribute("progressBarWidthPercent", 30);
|
||||
progressBarHeight = element.GetDoubleAttribute("progressBarHeight", 20);
|
||||
progressBarColor = element.GetIntAttribute("progressBarColor", 0xFFFFFF);
|
||||
}
|
||||
|
40
Core/tests/InstructionCountEvaluator.cpp
Normal file
40
Core/tests/InstructionCountEvaluator.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* GDevelop Core
|
||||
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
|
||||
* reserved. This project is released under the MIT License.
|
||||
*/
|
||||
#include "GDCore/IDE/Events/InstructionsCountEvaluator.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "DummyPlatform.h"
|
||||
#include "GDCore/Events/Builtin/StandardEvent.h"
|
||||
#include "GDCore/Events/Event.h"
|
||||
#include "GDCore/Extensions/Platform.h"
|
||||
#include "GDCore/Project/Layout.h"
|
||||
#include "GDCore/Project/Project.h"
|
||||
#include "catch.hpp"
|
||||
|
||||
namespace {
|
||||
|
||||
TEST_CASE("InstructionsCountEvaluator", "[events]") {
|
||||
|
||||
SECTION("Can count 1 action in a layout") {
|
||||
gd::Project project;
|
||||
gd::Platform platform;
|
||||
SetupProjectWithDummyPlatform(project, platform);
|
||||
auto &layout1 = project.InsertNewLayout("Layout1", 0);
|
||||
|
||||
// Add an event with an action.
|
||||
gd::StandardEvent event;
|
||||
gd::Instruction instruction;
|
||||
instruction.SetType("MyExtension::DoSomething");
|
||||
instruction.SetParametersCount(1);
|
||||
event.GetActions().Insert(instruction);
|
||||
layout1.GetEvents().InsertEvent(event);
|
||||
|
||||
REQUIRE(gd::InstructionsCountEvaluator::ScanProject(project) == 1);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
@@ -75,7 +75,8 @@ module.exports = {
|
||||
)
|
||||
.getCodeExtraInformation()
|
||||
.setIncludeFile('Extensions/FileSystem/filesystemtools.js')
|
||||
.setFunctionName('gdjs.fileSystem.makeDirectory');
|
||||
.setFunctionName('gdjs.fileSystem.makeDirectory')
|
||||
.setAsyncFunctionName('gdjs.fileSystem.makeDirectoryAsync');
|
||||
|
||||
extension
|
||||
.addAction(
|
||||
@@ -127,7 +128,8 @@ module.exports = {
|
||||
)
|
||||
.getCodeExtraInformation()
|
||||
.setIncludeFile('Extensions/FileSystem/filesystemtools.js')
|
||||
.setFunctionName('gdjs.fileSystem.saveStringToFileAsync');
|
||||
.setFunctionName('gdjs.fileSystem.saveStringToFileAsync')
|
||||
.setAsyncFunctionName('gdjs.fileSystem.saveStringToFileAsyncTask');
|
||||
|
||||
extension
|
||||
.addAction(
|
||||
@@ -179,7 +181,8 @@ module.exports = {
|
||||
)
|
||||
.getCodeExtraInformation()
|
||||
.setIncludeFile('Extensions/FileSystem/filesystemtools.js')
|
||||
.setFunctionName('gdjs.fileSystem.saveVariableToJSONFileAsync');
|
||||
.setFunctionName('gdjs.fileSystem.saveVariableToJSONFileAsync')
|
||||
.setAsyncFunctionName('gdjs.fileSystem.saveVariableToJSONFileAsyncTask');
|
||||
|
||||
extension
|
||||
.addAction(
|
||||
@@ -217,7 +220,8 @@ module.exports = {
|
||||
.setDefaultValue('yes')
|
||||
.getCodeExtraInformation()
|
||||
.setIncludeFile('Extensions/FileSystem/filesystemtools.js')
|
||||
.setFunctionName('gdjs.fileSystem.loadStringFromFileAsync');
|
||||
.setFunctionName('gdjs.fileSystem.loadStringFromFileAsync')
|
||||
.setAsyncFunctionName('gdjs.fileSystem.loadStringFromFileAsyncTask');
|
||||
|
||||
extension
|
||||
.addAction(
|
||||
@@ -331,7 +335,10 @@ module.exports = {
|
||||
.setDefaultValue('yes')
|
||||
.getCodeExtraInformation()
|
||||
.setIncludeFile('Extensions/FileSystem/filesystemtools.js')
|
||||
.setFunctionName('gdjs.fileSystem.loadVariableFromJSONFileAsync');
|
||||
.setFunctionName('gdjs.fileSystem.loadVariableFromJSONFileAsync')
|
||||
.setAsyncFunctionName(
|
||||
'gdjs.fileSystem.loadVariableFromJSONFileAsyncTask'
|
||||
);
|
||||
|
||||
extension
|
||||
.addAction(
|
||||
@@ -379,7 +386,8 @@ module.exports = {
|
||||
)
|
||||
.getCodeExtraInformation()
|
||||
.setIncludeFile('Extensions/FileSystem/filesystemtools.js')
|
||||
.setFunctionName('gdjs.fileSystem.deleteFileAsync');
|
||||
.setFunctionName('gdjs.fileSystem.deleteFileAsync')
|
||||
.setAsyncFunctionName('gdjs.fileSystem.deleteFileAsyncTask');
|
||||
|
||||
extension
|
||||
.addStrExpression(
|
||||
|
@@ -2,28 +2,20 @@ namespace gdjs {
|
||||
const logger = new gdjs.Logger('Filesystem');
|
||||
export namespace fileSystem {
|
||||
// The Node.js path module, or null if it can't be loaded.
|
||||
export let _path: any = null;
|
||||
const path: typeof import('path') | null =
|
||||
typeof require !== 'undefined' ? require('path') : null;
|
||||
// The Node.js fs module, or null if it can't be loaded.
|
||||
export let _fs: any = null;
|
||||
const fs: typeof import('fs') | null =
|
||||
typeof require !== 'undefined' ? require('fs') : null;
|
||||
const asyncFs: typeof import('fs/promises') | null =
|
||||
typeof require !== 'undefined' ? require('fs/promises') : null;
|
||||
|
||||
/** Get the Node.js path module, or null if it can't be loaded */
|
||||
export const _getPath = function () {
|
||||
if (!_path) {
|
||||
_path = typeof require !== 'undefined' ? require('path') : null;
|
||||
}
|
||||
return _path;
|
||||
};
|
||||
|
||||
/** Get the Node.js fs module, or null if it can't be loaded */
|
||||
export const _getFs = function () {
|
||||
if (!_fs) {
|
||||
_fs = typeof require !== 'undefined' ? require('fs') : null;
|
||||
}
|
||||
return _fs;
|
||||
};
|
||||
if (!fs)
|
||||
logger.warn(
|
||||
'Filesystem is not supported on this platform! Only PC builds support filesystem access.'
|
||||
);
|
||||
|
||||
export const getDirectoryName = function (fileOrFolderPath: string) {
|
||||
const path = gdjs.fileSystem._getPath();
|
||||
if (!path) {
|
||||
return '';
|
||||
}
|
||||
@@ -31,7 +23,6 @@ namespace gdjs {
|
||||
};
|
||||
|
||||
export const getFileName = function (filePath: string) {
|
||||
const path = gdjs.fileSystem._getPath();
|
||||
if (!path) {
|
||||
return '';
|
||||
}
|
||||
@@ -39,7 +30,6 @@ namespace gdjs {
|
||||
};
|
||||
|
||||
export const getExtensionName = function (filePath: string) {
|
||||
const path = gdjs.fileSystem._getPath();
|
||||
if (!path) {
|
||||
return '';
|
||||
}
|
||||
@@ -134,10 +124,7 @@ namespace gdjs {
|
||||
export const getExecutableFolderPath = function (
|
||||
instanceContainer: gdjs.RuntimeInstanceContainer
|
||||
): string {
|
||||
const path = gdjs.fileSystem._getPath();
|
||||
const executablePath = gdjs.fileSystem.getExecutablePath(
|
||||
instanceContainer
|
||||
);
|
||||
const executablePath = getExecutablePath(instanceContainer);
|
||||
if (!path) {
|
||||
return '';
|
||||
}
|
||||
@@ -208,7 +195,6 @@ namespace gdjs {
|
||||
* @return The path delimiter
|
||||
*/
|
||||
export const getPathDelimiter = function (): string {
|
||||
const path = gdjs.fileSystem._getPath();
|
||||
if (path) {
|
||||
return path.sep || '/';
|
||||
} else {
|
||||
@@ -225,11 +211,10 @@ namespace gdjs {
|
||||
directory: string,
|
||||
resultVar: gdjs.Variable
|
||||
) {
|
||||
const fileSystem = gdjs.fileSystem._getFs();
|
||||
let result = 'error';
|
||||
if (fileSystem) {
|
||||
if (fs) {
|
||||
try {
|
||||
fileSystem.mkdirSync(directory);
|
||||
fs.mkdirSync(directory);
|
||||
result = 'ok';
|
||||
} catch (err) {
|
||||
logger.error(
|
||||
@@ -241,6 +226,27 @@ namespace gdjs {
|
||||
resultVar.setString(result);
|
||||
};
|
||||
|
||||
export const makeDirectoryAsync = (
|
||||
directory: string,
|
||||
resultVar: gdjs.Variable
|
||||
) =>
|
||||
asyncFs
|
||||
? new gdjs.PromiseTask(
|
||||
asyncFs
|
||||
.mkdir(directory, { recursive: true })
|
||||
.then(() => {
|
||||
resultVar.setString('ok');
|
||||
})
|
||||
.catch((err) => {
|
||||
resultVar.setString('error');
|
||||
logger.error(
|
||||
"Unable to create directory at: '" + directory + "': ",
|
||||
err
|
||||
);
|
||||
})
|
||||
)
|
||||
: (resultVar.setString('error'), new gdjs.ResolveTask());
|
||||
|
||||
/**
|
||||
* Save a string into a file, asynchronously.
|
||||
* @param text The string to be saved
|
||||
@@ -252,9 +258,8 @@ namespace gdjs {
|
||||
savePath: string,
|
||||
resultVar: gdjs.Variable
|
||||
) {
|
||||
const fileSystem = gdjs.fileSystem._getFs();
|
||||
if (fileSystem) {
|
||||
fileSystem.writeFile(savePath, text, 'utf8', (err) => {
|
||||
if (fs) {
|
||||
fs.writeFile(savePath, text, 'utf8', (err) => {
|
||||
resultVar.setString('ok');
|
||||
if (err) {
|
||||
logger.error(
|
||||
@@ -267,6 +272,28 @@ namespace gdjs {
|
||||
}
|
||||
};
|
||||
|
||||
export const saveStringToFileAsyncTask = (
|
||||
text: string,
|
||||
savePath: string,
|
||||
resultVar: gdjs.Variable
|
||||
) =>
|
||||
asyncFs
|
||||
? new gdjs.PromiseTask(
|
||||
asyncFs
|
||||
.writeFile(savePath, text, { encoding: 'utf8' })
|
||||
.then(() => {
|
||||
resultVar.setString('ok');
|
||||
})
|
||||
.catch((err) => {
|
||||
resultVar.setString('error');
|
||||
logger.error(
|
||||
"Unable to save the text to path: '" + savePath + "': ",
|
||||
err
|
||||
);
|
||||
})
|
||||
)
|
||||
: (resultVar.setString('error'), new gdjs.ResolveTask());
|
||||
|
||||
/**
|
||||
* Save a string into a file.
|
||||
* @param text The string to be saved
|
||||
@@ -278,11 +305,10 @@ namespace gdjs {
|
||||
savePath: string,
|
||||
resultVar: gdjs.Variable
|
||||
) {
|
||||
const fileSystem = gdjs.fileSystem._getFs();
|
||||
let result = 'error';
|
||||
if (fileSystem) {
|
||||
if (fs) {
|
||||
try {
|
||||
fileSystem.writeFileSync(savePath, text, 'utf8');
|
||||
fs.writeFileSync(savePath, text, 'utf8');
|
||||
result = 'ok';
|
||||
} catch (err) {
|
||||
logger.error(
|
||||
@@ -305,11 +331,10 @@ namespace gdjs {
|
||||
savePath: string,
|
||||
resultVar: gdjs.Variable
|
||||
) {
|
||||
const fileSystem = gdjs.fileSystem._getFs();
|
||||
let result = 'error';
|
||||
if (fileSystem) {
|
||||
if (fs) {
|
||||
try {
|
||||
fileSystem.writeFileSync(
|
||||
fs.writeFileSync(
|
||||
savePath,
|
||||
JSON.stringify(variable.toJSObject()),
|
||||
'utf8'
|
||||
@@ -336,9 +361,8 @@ namespace gdjs {
|
||||
savePath: string,
|
||||
resultVar: gdjs.Variable
|
||||
) {
|
||||
const fileSystem = gdjs.fileSystem._getFs();
|
||||
if (fileSystem) {
|
||||
fileSystem.writeFile(
|
||||
if (fs) {
|
||||
fs.writeFile(
|
||||
savePath,
|
||||
JSON.stringify(variable.toJSObject()),
|
||||
'utf8',
|
||||
@@ -356,6 +380,30 @@ namespace gdjs {
|
||||
}
|
||||
};
|
||||
|
||||
export const saveVariableToJSONFileAsyncTask = (
|
||||
variable: gdjs.Variable,
|
||||
savePath: string,
|
||||
resultVar: gdjs.Variable
|
||||
) =>
|
||||
asyncFs
|
||||
? new gdjs.PromiseTask(
|
||||
asyncFs
|
||||
.writeFile(savePath, JSON.stringify(variable.toJSObject()), {
|
||||
encoding: 'utf8',
|
||||
})
|
||||
.then(() => {
|
||||
resultVar.setString('ok');
|
||||
})
|
||||
.catch((err) => {
|
||||
resultVar.setString('error');
|
||||
logger.error(
|
||||
"Unable to save the text to path: '" + savePath + "': ",
|
||||
err
|
||||
);
|
||||
})
|
||||
)
|
||||
: (resultVar.setString('error'), new gdjs.ResolveTask());
|
||||
|
||||
/**
|
||||
* Load a string from a file into a scene variable.
|
||||
* @param stringVar Variable where to store the content
|
||||
@@ -369,11 +417,10 @@ namespace gdjs {
|
||||
resultVar: gdjs.Variable,
|
||||
removeCRCharacters: boolean
|
||||
) {
|
||||
const fileSystem = gdjs.fileSystem._getFs();
|
||||
let result = 'error';
|
||||
if (fileSystem) {
|
||||
if (fs) {
|
||||
try {
|
||||
const data = fileSystem.readFileSync(loadPath, 'utf8');
|
||||
const data = fs.readFileSync(loadPath, 'utf8');
|
||||
if (data) {
|
||||
stringVar.setString(
|
||||
removeCRCharacters ? data.replace(/\r/g, '') : data
|
||||
@@ -403,11 +450,10 @@ namespace gdjs {
|
||||
resultVar: gdjs.Variable,
|
||||
removeCRCharacters: boolean
|
||||
) {
|
||||
const fileSystem = gdjs.fileSystem._getFs();
|
||||
let result = 'error';
|
||||
if (fileSystem) {
|
||||
if (fs) {
|
||||
try {
|
||||
const data = fileSystem.readFileSync(loadPath, 'utf8');
|
||||
const data = fs.readFileSync(loadPath, 'utf8');
|
||||
if (data) {
|
||||
variable.fromJSON(
|
||||
removeCRCharacters ? data.replace(/\r/g, '') : data
|
||||
@@ -439,9 +485,8 @@ namespace gdjs {
|
||||
resultVar: gdjs.Variable,
|
||||
removeCRCharacters: boolean
|
||||
) {
|
||||
const fileSystem = gdjs.fileSystem._getFs();
|
||||
if (fileSystem) {
|
||||
fileSystem.readFile(loadPath, 'utf8', (err, data) => {
|
||||
if (fs) {
|
||||
fs.readFile(loadPath, 'utf8', (err, data) => {
|
||||
if (data) {
|
||||
variable.fromJSON(
|
||||
removeCRCharacters ? data.replace(/\r/g, '') : data
|
||||
@@ -461,6 +506,35 @@ namespace gdjs {
|
||||
}
|
||||
};
|
||||
|
||||
export const loadVariableFromJSONFileAsyncTask = (
|
||||
variable: gdjs.Variable,
|
||||
loadPath: string,
|
||||
resultVar: gdjs.Variable,
|
||||
removeCRCharacters: boolean
|
||||
) =>
|
||||
asyncFs
|
||||
? new gdjs.PromiseTask(
|
||||
asyncFs
|
||||
.readFile(loadPath, { encoding: 'utf8' })
|
||||
.then((data) => {
|
||||
if (data)
|
||||
variable.fromJSON(
|
||||
removeCRCharacters ? data.replace(/\r/g, '') : data
|
||||
);
|
||||
resultVar.setString('ok');
|
||||
})
|
||||
.catch((err) => {
|
||||
resultVar.setString('error');
|
||||
logger.error(
|
||||
"Unable to load the JSON file from path: '" +
|
||||
loadPath +
|
||||
"': ",
|
||||
err
|
||||
);
|
||||
})
|
||||
)
|
||||
: (resultVar.setString('error'), new gdjs.ResolveTask());
|
||||
|
||||
/**
|
||||
* Load a string from a file into a scene variable, asynchronously.
|
||||
* @param stringVar Variable where to store the content
|
||||
@@ -474,9 +548,8 @@ namespace gdjs {
|
||||
resultVar: gdjs.Variable,
|
||||
removeCRCharacters: boolean
|
||||
) {
|
||||
const fileSystem = gdjs.fileSystem._getFs();
|
||||
if (fileSystem) {
|
||||
fileSystem.readFile(loadPath, 'utf8', (err, data) => {
|
||||
if (fs) {
|
||||
fs.readFile(loadPath, 'utf8', (err, data) => {
|
||||
if (data) {
|
||||
stringVar.setString(
|
||||
removeCRCharacters ? data.replace(/\r/g, '') : data
|
||||
@@ -494,6 +567,35 @@ namespace gdjs {
|
||||
}
|
||||
};
|
||||
|
||||
export const loadStringFromFileAsyncTask = (
|
||||
variable: gdjs.Variable,
|
||||
loadPath: string,
|
||||
resultVar: gdjs.Variable,
|
||||
removeCRCharacters: boolean
|
||||
) =>
|
||||
asyncFs
|
||||
? new gdjs.PromiseTask(
|
||||
asyncFs
|
||||
.readFile(loadPath, { encoding: 'utf8' })
|
||||
.then((data) => {
|
||||
if (data)
|
||||
variable.setString(
|
||||
removeCRCharacters ? data.replace(/\r/g, '') : data
|
||||
);
|
||||
resultVar.setString('ok');
|
||||
})
|
||||
.catch((err) => {
|
||||
resultVar.setString('error');
|
||||
logger.error(
|
||||
"Unable to load the text file from path: '" +
|
||||
loadPath +
|
||||
"': ",
|
||||
err
|
||||
);
|
||||
})
|
||||
)
|
||||
: (resultVar.setString('error'), new gdjs.ResolveTask());
|
||||
|
||||
/**
|
||||
* Delete a file from the filesystem.
|
||||
* @param filePath Path to the file
|
||||
@@ -503,11 +605,10 @@ namespace gdjs {
|
||||
filePath: string,
|
||||
resultVar: gdjs.Variable
|
||||
) {
|
||||
const fileSystem = gdjs.fileSystem._getFs();
|
||||
let result = 'error';
|
||||
if (fileSystem) {
|
||||
if (fs) {
|
||||
try {
|
||||
fileSystem.unlinkSync(filePath);
|
||||
fs.unlinkSync(filePath);
|
||||
result = 'ok';
|
||||
} catch (err) {
|
||||
logger.error("Unable to delete the file: '" + filePath + "': ", err);
|
||||
@@ -526,9 +627,8 @@ namespace gdjs {
|
||||
filePath: string,
|
||||
resultVar: gdjs.Variable
|
||||
) {
|
||||
const fileSystem = gdjs.fileSystem._getFs();
|
||||
if (fileSystem) {
|
||||
fileSystem.unlink(filePath, (err) => {
|
||||
if (fs) {
|
||||
fs.unlink(filePath, (err) => {
|
||||
resultVar.setString('ok');
|
||||
if (err) {
|
||||
logger.error(
|
||||
@@ -541,15 +641,35 @@ namespace gdjs {
|
||||
}
|
||||
};
|
||||
|
||||
export const deleteFileAsyncTask = (
|
||||
filePath: string,
|
||||
resultVar: gdjs.Variable
|
||||
) =>
|
||||
asyncFs
|
||||
? new gdjs.PromiseTask(
|
||||
asyncFs
|
||||
.rm(filePath, { recursive: true })
|
||||
.then(() => {
|
||||
resultVar.setString('ok');
|
||||
})
|
||||
.catch((err) => {
|
||||
resultVar.setString('error');
|
||||
logger.error(
|
||||
"Unable to delete the file: '" + filePath + "': ",
|
||||
err
|
||||
);
|
||||
})
|
||||
)
|
||||
: (resultVar.setString('error'), new gdjs.ResolveTask());
|
||||
|
||||
/**
|
||||
* Check if the file or directory exists.
|
||||
* @param filePath The path to the file or directory
|
||||
* @return true if fhe file or directory exists
|
||||
*/
|
||||
export const pathExists = function (filePath: string): boolean {
|
||||
const fileSystem = gdjs.fileSystem._getFs();
|
||||
if (fileSystem) {
|
||||
return fileSystem.existsSync(filePath);
|
||||
if (fs) {
|
||||
return fs.existsSync(filePath);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
@@ -24,23 +24,23 @@ const variable = new gdjs.Variable().fromJSObject({
|
||||
it: ['is', true],
|
||||
});
|
||||
|
||||
/**
|
||||
* A firebase configuration of a project made only for those tests.
|
||||
*/
|
||||
const firebaseConfig = {
|
||||
apiKey: 'AIzaSyBwPnGpfEBXDjwQrWfU0wqgp4m9qEt7YM8',
|
||||
authDomain: 'gdtest-e11a5.firebaseapp.com',
|
||||
databaseURL: 'https://gdtest-e11a5.firebaseio.com',
|
||||
projectId: 'gdtest-e11a5',
|
||||
storageBucket: 'gdtest-e11a5.appspot.com',
|
||||
messagingSenderId: '254035412678',
|
||||
appId: '1:254035412678:web:2ddd6b83019b7f259b79c7',
|
||||
measurementId: 'G-4REML26L59',
|
||||
};
|
||||
|
||||
// The tests require an internet connection, as a real Firebase instance is used.
|
||||
const describeIfOnline = navigator.onLine ? describe : describe.skip;
|
||||
describeIfOnline('Firebase extension end-to-end tests', function () {
|
||||
/**
|
||||
* A firebase configuration of a project made only for those tests.
|
||||
*/
|
||||
const firebaseConfig = {
|
||||
apiKey: 'AIzaSyBwPnGpfEBXDjwQrWfU0wqgp4m9qEt7YM8',
|
||||
authDomain: 'gdtest-e11a5.firebaseapp.com',
|
||||
databaseURL: 'https://gdtest-e11a5.firebaseio.com',
|
||||
projectId: 'gdtest-e11a5',
|
||||
storageBucket: 'gdtest-e11a5.appspot.com',
|
||||
messagingSenderId: '254035412678',
|
||||
appId: '1:254035412678:web:2ddd6b83019b7f259b79c7',
|
||||
measurementId: 'G-4REML26L59',
|
||||
};
|
||||
|
||||
// Increase the timeout to work on low connections as well.
|
||||
this.timeout('5s');
|
||||
|
||||
@@ -48,8 +48,8 @@ describeIfOnline('Firebase extension end-to-end tests', function () {
|
||||
.toString()
|
||||
.replace('.', '-')}-${Date.now()}`;
|
||||
|
||||
before(function setupFirebase() {
|
||||
gdjs.evtTools.firebaseTools._setupFirebase({
|
||||
before(async function setupFirebase() {
|
||||
await gdjs.evtTools.firebaseTools._setupFirebase({
|
||||
getGame: () => ({
|
||||
getExtensionProperty: () => JSON.stringify(firebaseConfig),
|
||||
}),
|
||||
|
@@ -686,7 +686,7 @@ namespace gdjs {
|
||||
const isDev = runtimeScene
|
||||
.getGame()
|
||||
.isUsingGDevelopDevelopmentEnvironment();
|
||||
const targetUrl = `https://liluo.io/games/${gameId}/leaderboard/${leaderboardId}?inGameEmbedded=true${
|
||||
const targetUrl = `https://gd.games/games/${gameId}/leaderboard/${leaderboardId}?inGameEmbedded=true${
|
||||
isDev ? '&dev=true' : ''
|
||||
}`;
|
||||
checkLeaderboardAvailability(targetUrl).then(
|
||||
|
@@ -372,4 +372,15 @@ void ExtensionSubDeclaration3(gd::ObjectMetadata& obj) {
|
||||
_("Setup"),
|
||||
"CppPlatform/Extensions/particleSystemicon16.png")
|
||||
.AddParameter("object", _("Object"), "ParticleEmitter", false);
|
||||
|
||||
obj.AddAction("JumpEmitterForwardInTime",
|
||||
_("Jump emitter forward in time"),
|
||||
_("Simulate the passage of time for an emitter, "
|
||||
"including creating and moving particles"),
|
||||
_("Jump _PARAM0_ forward in time by _PARAM1_ seconds"),
|
||||
_("Advanced"),
|
||||
"CppPlatform/Extensions/particleSystemicon24.png",
|
||||
"CppPlatform/Extensions/particleSystemicon16.png")
|
||||
.AddParameter("object", _("Object"), "ParticleEmitter")
|
||||
.AddParameter("number", _("Seconds of time"));
|
||||
}
|
||||
|
@@ -178,6 +178,8 @@ class ParticleSystemJsExtension : public gd::PlatformExtension {
|
||||
.SetFunctionName("setTexture")
|
||||
.SetGetter("getTexture");
|
||||
conditions["ParticleSystem::Texture"].SetFunctionName("getTexture");
|
||||
actions["ParticleSystem::JumpEmitterForwardInTime"].SetFunctionName(
|
||||
"jumpEmitterForwardInTime");
|
||||
|
||||
strExpressions["Texture"].SetFunctionName("getTexture");
|
||||
expressions["CurrentParticleCount"].SetFunctionName("getParticleCount");
|
||||
|
@@ -849,6 +849,10 @@ namespace gdjs {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
jumpEmitterForwardInTime(timeSkipped: number): void {
|
||||
this._renderer.update(timeSkipped);
|
||||
}
|
||||
}
|
||||
gdjs.registerObject(
|
||||
'ParticleSystem::ParticleEmitter',
|
||||
|
@@ -34,6 +34,7 @@ namespace gdjs {
|
||||
): {
|
||||
rootContainer: HTMLDivElement;
|
||||
loaderContainer: HTMLDivElement;
|
||||
iframeContainer: HTMLDivElement;
|
||||
} {
|
||||
const rootContainer = document.createElement('div');
|
||||
rootContainer.id = 'authentication-root-container';
|
||||
@@ -45,17 +46,17 @@ namespace gdjs {
|
||||
rootContainer.style.zIndex = '2';
|
||||
rootContainer.style.pointerEvents = 'all';
|
||||
|
||||
const subContainer = document.createElement('div');
|
||||
subContainer.id = 'authentication-sub-container';
|
||||
subContainer.style.backgroundColor = '#FFFFFF';
|
||||
subContainer.style.position = 'absolute';
|
||||
subContainer.style.top = '16px';
|
||||
subContainer.style.bottom = '16px';
|
||||
subContainer.style.left = '16px';
|
||||
subContainer.style.right = '16px';
|
||||
subContainer.style.borderRadius = '8px';
|
||||
subContainer.style.boxShadow = '0px 4px 4px rgba(0, 0, 0, 0.25)';
|
||||
subContainer.style.padding = '16px';
|
||||
const frameContainer = document.createElement('div');
|
||||
frameContainer.id = 'authentication-frame-container';
|
||||
frameContainer.style.backgroundColor = '#FFFFFF';
|
||||
frameContainer.style.position = 'absolute';
|
||||
frameContainer.style.top = '16px';
|
||||
frameContainer.style.bottom = '16px';
|
||||
frameContainer.style.left = '16px';
|
||||
frameContainer.style.right = '16px';
|
||||
frameContainer.style.borderRadius = '8px';
|
||||
frameContainer.style.boxShadow = '0px 4px 4px rgba(0, 0, 0, 0.25)';
|
||||
frameContainer.style.padding = '16px';
|
||||
|
||||
const _closeContainer: HTMLDivElement = document.createElement('div');
|
||||
_closeContainer.style.cursor = 'pointer';
|
||||
@@ -106,11 +107,57 @@ namespace gdjs {
|
||||
|
||||
loaderContainer.appendChild(_loader);
|
||||
|
||||
subContainer.appendChild(_closeContainer);
|
||||
subContainer.appendChild(loaderContainer);
|
||||
rootContainer.appendChild(subContainer);
|
||||
const iframeContainer: HTMLDivElement = document.createElement('div');
|
||||
iframeContainer.style.display = 'flex';
|
||||
iframeContainer.style.flexDirection = 'column';
|
||||
iframeContainer.style.height = '100%';
|
||||
iframeContainer.style.width = '100%';
|
||||
iframeContainer.style.justifyContent = 'stretch';
|
||||
iframeContainer.style.alignItems = 'stretch';
|
||||
iframeContainer.style.display = 'none';
|
||||
|
||||
return { rootContainer, loaderContainer };
|
||||
frameContainer.appendChild(_closeContainer);
|
||||
frameContainer.appendChild(loaderContainer);
|
||||
frameContainer.appendChild(iframeContainer);
|
||||
rootContainer.appendChild(frameContainer);
|
||||
|
||||
return { rootContainer, loaderContainer, iframeContainer };
|
||||
};
|
||||
|
||||
export const displayIframeInsideAuthenticationContainer = (
|
||||
iframeContainer: HTMLDivElement,
|
||||
loaderContainer: HTMLDivElement,
|
||||
textContainer: HTMLDivElement,
|
||||
url: string
|
||||
) => {
|
||||
const iframe = document.createElement('iframe');
|
||||
iframe.setAttribute(
|
||||
'sandbox',
|
||||
'allow-forms allow-modals allow-orientation-lock allow-popups allow-same-origin allow-scripts'
|
||||
);
|
||||
iframe.addEventListener('load', () => {
|
||||
iframeContainer.style.display = 'flex';
|
||||
loaderContainer.style.display = 'none';
|
||||
});
|
||||
iframe.addEventListener('loaderror', () => {
|
||||
addAuthenticationUrlToTextsContainer(() => {
|
||||
// Try again.
|
||||
iframeContainer.removeChild(iframe);
|
||||
iframeContainer.style.display = 'none';
|
||||
loaderContainer.style.display = 'flex';
|
||||
displayIframeInsideAuthenticationContainer(
|
||||
iframeContainer,
|
||||
loaderContainer,
|
||||
textContainer,
|
||||
url
|
||||
);
|
||||
}, textContainer);
|
||||
});
|
||||
iframe.src = url;
|
||||
iframe.style.flex = '1';
|
||||
iframe.style.border = '0';
|
||||
|
||||
iframeContainer.appendChild(iframe);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@@ -18,6 +18,7 @@ namespace gdjs {
|
||||
let _authenticationInAppWindow: Window | null = null; // For Cordova.
|
||||
let _authenticationRootContainer: HTMLDivElement | null = null;
|
||||
let _authenticationLoaderContainer: HTMLDivElement | null = null;
|
||||
let _authenticationIframeContainer: HTMLDivElement | null = null;
|
||||
let _authenticationTextContainer: HTMLDivElement | null = null;
|
||||
let _authenticationBanner: HTMLDivElement | null = null;
|
||||
let _initialAuthenticationTimeoutId: NodeJS.Timeout | null = null;
|
||||
@@ -38,12 +39,12 @@ namespace gdjs {
|
||||
});
|
||||
|
||||
// If the extension is used, register an eventlistener to know if the user is
|
||||
// logged in while playing the game on Liluo.io.
|
||||
// logged in while playing the game on GDevelop games platform.
|
||||
// Then send a message to the parent iframe to say that the player auth is ready.
|
||||
gdjs.registerFirstRuntimeSceneLoadedCallback(
|
||||
(runtimeScene: RuntimeScene) => {
|
||||
if (getPlatform(runtimeScene) !== 'web') {
|
||||
// Automatic authentication is only valid when the game is hosted in Liluo.io.
|
||||
// Automatic authentication is only valid when the game is hosted on GDevelop games platform.
|
||||
return;
|
||||
}
|
||||
removeAuthenticationCallbacks(); // Remove any callback that could have been registered before.
|
||||
@@ -64,9 +65,9 @@ namespace gdjs {
|
||||
{
|
||||
id: 'playerAuthReady',
|
||||
},
|
||||
'*' // We could restrict to liluo.io but it's not necessary as the message is not sensitive, and it allows easy debugging.
|
||||
'*' // We could restrict to GDevelop games platform but it's not necessary as the message is not sensitive, and it allows easy debugging.
|
||||
);
|
||||
// If no answer after 3 seconds, assume that the game is not embedded in Liluo.io, and remove the listener.
|
||||
// If no answer after 3 seconds, assume that the game is not embedded in GDevelop games platform, and remove the listener.
|
||||
_initialAuthenticationTimeoutId = setTimeout(() => {
|
||||
logger.info('Removing initial authentication listener.');
|
||||
removeAuthenticationCallbacks();
|
||||
@@ -85,12 +86,16 @@ namespace gdjs {
|
||||
runtimeGame: gdjs.RuntimeGame;
|
||||
gameId: string;
|
||||
connectionId?: string;
|
||||
}) =>
|
||||
`https://liluo.io/auth?gameId=${gameId}${
|
||||
}) => {
|
||||
// Uncomment to test the case of a failing loading:
|
||||
// return 'https://gd.games.wronglink';
|
||||
|
||||
return `https://gd.games/auth?gameId=${gameId}${
|
||||
connectionId ? `&connectionId=${connectionId}` : ''
|
||||
}${
|
||||
runtimeGame.isUsingGDevelopDevelopmentEnvironment() ? '&dev=true' : ''
|
||||
}`;
|
||||
};
|
||||
|
||||
/**
|
||||
* Helper returning the platform.
|
||||
@@ -98,14 +103,31 @@ namespace gdjs {
|
||||
const getPlatform = (
|
||||
runtimeScene: RuntimeScene
|
||||
): 'electron' | 'cordova' | 'web' => {
|
||||
const electron = runtimeScene.getGame().getRenderer().getElectron();
|
||||
const runtimeGame = runtimeScene.getGame();
|
||||
const electron = runtimeGame.getRenderer().getElectron();
|
||||
if (electron) {
|
||||
return 'electron';
|
||||
}
|
||||
if (typeof cordova !== 'undefined') return 'cordova';
|
||||
|
||||
return 'web';
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if, in some exceptional cases, we allow authentication
|
||||
* to be done through a iframe.
|
||||
* This is usually discouraged as the user can't verify that the authentication
|
||||
* window is a genuine one. It's only to be used in trusted contexts.
|
||||
*/
|
||||
const shouldAuthenticationUseIframe = (runtimeScene: RuntimeScene) => {
|
||||
const runtimeGameOptions = runtimeScene.getGame().getAdditionalOptions();
|
||||
return (
|
||||
runtimeGameOptions &&
|
||||
runtimeGameOptions.isPreview &&
|
||||
runtimeGameOptions.allowAuthenticationUsingIframeForPreview
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns true if a user token is present in the local storage.
|
||||
*/
|
||||
@@ -509,7 +531,7 @@ namespace gdjs {
|
||||
|
||||
/**
|
||||
* Helper to recompute the authentication banner.
|
||||
* This is useful if the user is already logged in on Liluo.io
|
||||
* This is useful if the user is already logged on GDevelop games platform
|
||||
* and we want to display the banner with the username.
|
||||
*/
|
||||
const refreshAuthenticationBannerIfAny = function (
|
||||
@@ -685,6 +707,47 @@ namespace gdjs {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Helper to handle authentication iframe on web.
|
||||
* We open an iframe, and listen to messages posted back to the game window.
|
||||
*/
|
||||
const openAuthenticationIframeForWeb = (
|
||||
runtimeScene: gdjs.RuntimeScene,
|
||||
gameId: string
|
||||
) => {
|
||||
if (
|
||||
!_authenticationIframeContainer ||
|
||||
!_authenticationLoaderContainer ||
|
||||
!_authenticationTextContainer
|
||||
) {
|
||||
console.error(
|
||||
"Can't open an authentication iframe - no iframe container, loader container or text container was opened for it."
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
const targetUrl = getAuthWindowUrl({
|
||||
runtimeGame: runtimeScene.getGame(),
|
||||
gameId,
|
||||
});
|
||||
|
||||
// Listen to messages posted by the authentication window, so that we can
|
||||
// know when the user is authenticated.
|
||||
_authenticationMessageCallback = (event: MessageEvent) => {
|
||||
receiveAuthenticationMessage(runtimeScene, event, {
|
||||
checkOrigin: true,
|
||||
});
|
||||
};
|
||||
window.addEventListener('message', _authenticationMessageCallback, true);
|
||||
|
||||
authComponents.displayIframeInsideAuthenticationContainer(
|
||||
_authenticationIframeContainer,
|
||||
_authenticationLoaderContainer,
|
||||
_authenticationTextContainer,
|
||||
targetUrl
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Action to display the authentication window to the user.
|
||||
*/
|
||||
@@ -725,11 +788,13 @@ namespace gdjs {
|
||||
const {
|
||||
rootContainer,
|
||||
loaderContainer,
|
||||
iframeContainer,
|
||||
} = authComponents.computeAuthenticationContainer(
|
||||
onAuthenticationContainerDismissed
|
||||
);
|
||||
_authenticationRootContainer = rootContainer;
|
||||
_authenticationLoaderContainer = loaderContainer;
|
||||
_authenticationIframeContainer = iframeContainer;
|
||||
|
||||
// Display the authentication window right away, to show a loader
|
||||
// while the call for game registration is happening.
|
||||
@@ -769,7 +834,11 @@ namespace gdjs {
|
||||
break;
|
||||
case 'web':
|
||||
default:
|
||||
openAuthenticationWindowForWeb(runtimeScene, _gameId);
|
||||
if (shouldAuthenticationUseIframe(runtimeScene)) {
|
||||
openAuthenticationIframeForWeb(runtimeScene, _gameId);
|
||||
} else {
|
||||
openAuthenticationWindowForWeb(runtimeScene, _gameId);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -815,6 +884,7 @@ namespace gdjs {
|
||||
|
||||
_authenticationRootContainer = null;
|
||||
_authenticationLoaderContainer = null;
|
||||
_authenticationIframeContainer = null;
|
||||
_authenticationTextContainer = null;
|
||||
};
|
||||
|
||||
|
@@ -722,7 +722,7 @@ void DeclarePrimitiveDrawingExtension(gd::PlatformExtension& extension) {
|
||||
_("Center of rotation"),
|
||||
_("Change the center of rotation of an object relatively to the "
|
||||
"object origin."),
|
||||
_("Change the center of rotation of _PARAM0_: _PARAM1_; _PARAM2_"),
|
||||
_("Change the center of rotation of _PARAM0_ to _PARAM1_, _PARAM2_"),
|
||||
_("Angle"),
|
||||
"res/actions/position24_black.png",
|
||||
"res/actions/position_black.png")
|
||||
|
@@ -474,7 +474,7 @@ namespace gdjs {
|
||||
/**
|
||||
* The center of rotation is defined relatively
|
||||
* to the drawing origin (the object position).
|
||||
* This avoid the center to move on the drawing
|
||||
* This avoids the center to move on the drawing
|
||||
* when new shapes push the bounds.
|
||||
*
|
||||
* When no custom center is defined, it will move
|
||||
|
@@ -1294,9 +1294,8 @@ module.exports = {
|
||||
tilemapJsonFile,
|
||||
tilesetJsonFile
|
||||
) {
|
||||
let tileMapJsonData = null;
|
||||
try {
|
||||
tileMapJsonData = await this._pixiResourcesLoader.getResourceJsonData(
|
||||
const tileMapJsonData = await this._pixiResourcesLoader.getResourceJsonData(
|
||||
this._project,
|
||||
tilemapJsonFile
|
||||
);
|
||||
@@ -1320,6 +1319,7 @@ module.exports = {
|
||||
} catch (err) {
|
||||
console.error('Unable to load a Tilemap JSON data: ', err);
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -1540,34 +1540,38 @@ module.exports = {
|
||||
// GDJS doesn't use Promise to avoid allocation.
|
||||
RenderedCollisionMaskInstance.prototype._loadTiledMapWithCallback =
|
||||
function (tilemapJsonFile, tilesetJsonFile, callback) {
|
||||
this._loadTiledMap(tilemapJsonFile, tilesetJsonFile).then(callback);
|
||||
this._loadTileMap(tilemapJsonFile, tilesetJsonFile).then(callback);
|
||||
};
|
||||
|
||||
RenderedCollisionMaskInstance.prototype._loadTiledMap = async function (
|
||||
RenderedCollisionMaskInstance.prototype._loadTileMap = async function (
|
||||
tilemapJsonFile,
|
||||
tilesetJsonFile
|
||||
) {
|
||||
let tileMapJsonData = null;
|
||||
try {
|
||||
tileMapJsonData = await this._pixiResourcesLoader.getResourceJsonData(
|
||||
const tileMapJsonData = await this._pixiResourcesLoader.getResourceJsonData(
|
||||
this._project,
|
||||
tilemapJsonFile
|
||||
);
|
||||
|
||||
const tilesetJsonData = tilesetJsonFile
|
||||
? await this._pixiResourcesLoader.getResourceJsonData(
|
||||
this._project,
|
||||
tilesetJsonFile
|
||||
)
|
||||
: null;
|
||||
const tileMap = TilemapHelper.TileMapManager.identify(tileMapJsonData);
|
||||
|
||||
if (tilesetJsonData) {
|
||||
tileMapJsonData.tilesets = [tilesetJsonData];
|
||||
if (tileMap.kind === 'tiled') {
|
||||
const tilesetJsonData = tilesetJsonFile
|
||||
? await this._pixiResourcesLoader.getResourceJsonData(
|
||||
this._project,
|
||||
tilesetJsonFile
|
||||
)
|
||||
: null;
|
||||
|
||||
if (tilesetJsonData) {
|
||||
tileMapJsonData.tilesets = [tilesetJsonData];
|
||||
}
|
||||
}
|
||||
return tileMap;
|
||||
} catch (err) {
|
||||
console.error('Unable to load a Tilemap JSON data: ', err);
|
||||
}
|
||||
return tileMapJsonData;
|
||||
return null;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@@ -67,7 +67,9 @@ namespace gdjs {
|
||||
tileMapJsonResourceName: string,
|
||||
tileSetJsonResourceName: string,
|
||||
levelIndex: number,
|
||||
callback: (tileMap: TileMapHelper.EditableTileMap | null) => void
|
||||
callback: (
|
||||
tileMapFileContent: TileMapHelper.EditableTileMap | null
|
||||
) => void
|
||||
): void {
|
||||
this._manager.getOrLoadTileMap(
|
||||
this._loadTileMap.bind(this),
|
||||
@@ -113,7 +115,9 @@ namespace gdjs {
|
||||
private _loadTileMap(
|
||||
tileMapJsonResourceName: string,
|
||||
tileSetJsonResourceName: string,
|
||||
callback: (tileMap: TileMapHelper.TileMap | null) => void
|
||||
callback: (
|
||||
tileMapFileContent: TileMapHelper.TileMapFileContent | null
|
||||
) => void
|
||||
): void {
|
||||
this._instanceContainer
|
||||
.getGame()
|
||||
@@ -127,14 +131,17 @@ namespace gdjs {
|
||||
callback(null);
|
||||
return;
|
||||
}
|
||||
const tileMap = TileMapHelper.TileMapManager.identify(
|
||||
const tileMapFileContent = TileMapHelper.TileMapManager.identify(
|
||||
tileMapJsonData
|
||||
);
|
||||
if (!tileMap) {
|
||||
if (!tileMapFileContent) {
|
||||
callback(null);
|
||||
return;
|
||||
}
|
||||
if (tileMap.kind === 'tiled' && tileSetJsonResourceName) {
|
||||
if (
|
||||
tileMapFileContent.kind === 'tiled' &&
|
||||
tileSetJsonResourceName
|
||||
) {
|
||||
this._instanceContainer
|
||||
.getGame()
|
||||
.getJsonManager()
|
||||
@@ -147,14 +154,14 @@ namespace gdjs {
|
||||
callback(null);
|
||||
return;
|
||||
}
|
||||
const tiledMap = tileMap.data;
|
||||
const tiledMap = tileMapFileContent.data;
|
||||
const tileSet = tileSetJsonData as TileMapHelper.TiledTileset;
|
||||
tileSet.firstgid = tiledMap.tilesets[0].firstgid;
|
||||
tiledMap.tilesets = [tileSet];
|
||||
callback(tileMap);
|
||||
callback(tileMapFileContent);
|
||||
});
|
||||
} else {
|
||||
callback(tileMap);
|
||||
callback(tileMapFileContent);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
4
Extensions/TileMap/helper/TileMapHelper.d.ts
vendored
4
Extensions/TileMap/helper/TileMapHelper.d.ts
vendored
@@ -3,7 +3,7 @@ import {
|
||||
EditableTileMapLayer,
|
||||
PixiTileMapHelper,
|
||||
TileDefinition,
|
||||
TileMap,
|
||||
TileMapFileContent,
|
||||
TileMapManager,
|
||||
TileTextureCache,
|
||||
TiledTileset,
|
||||
@@ -16,7 +16,7 @@ declare global {
|
||||
EditableTileMapLayer,
|
||||
PixiTileMapHelper,
|
||||
TileDefinition,
|
||||
TileMap,
|
||||
TileMapFileContent,
|
||||
TileMapManager,
|
||||
TileTextureCache,
|
||||
TiledTileset,
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
2
Extensions/TileMap/helper/dts/index.d.ts
vendored
2
Extensions/TileMap/helper/dts/index.d.ts
vendored
@@ -10,7 +10,7 @@ export {
|
||||
export { TileMapManager } from './render/TileMapManager';
|
||||
export { TileTextureCache } from './render/TileTextureCache';
|
||||
export { PixiTileMapHelper } from './render/TileMapPixiHelper';
|
||||
export * from './types/index';
|
||||
export * from './load/TileMapFileContent';
|
||||
export * from './model/CommonTypes';
|
||||
export { TiledTileset } from './load/tiled/TiledFormat';
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
|
@@ -1 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,cAAc,GACf,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAE/D,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC"}
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,cAAc,GACf,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAE/D,cAAc,2BAA2B,CAAC;AAC1C,cAAc,qBAAqB,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC"}
|
12
Extensions/TileMap/helper/dts/load/TileMapFileContent.d.ts
vendored
Normal file
12
Extensions/TileMap/helper/dts/load/TileMapFileContent.d.ts
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
import { LDtkTileMap } from '../load/ldtk/LDtkFormat';
|
||||
import { TiledTileMap } from '../load/tiled/TiledFormat';
|
||||
export declare type TileMapFileContent =
|
||||
| {
|
||||
kind: 'tiled';
|
||||
data: TiledTileMap;
|
||||
}
|
||||
| {
|
||||
kind: 'ldtk';
|
||||
data: LDtkTileMap;
|
||||
};
|
||||
//# sourceMappingURL=TileMapFileContent.d.ts.map
|
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"TileMapFileContent.d.ts","sourceRoot":"","sources":["../../src/load/TileMapFileContent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD,oBAAY,kBAAkB,GAC1B;IACE,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE,YAAY,CAAC;CACpB,GACD;IACE,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,WAAW,CAAC;CACnB,CAAC"}
|
@@ -1,16 +1,16 @@
|
||||
import type { EditableTileMap } from '../model/TileMapModel';
|
||||
import { TileMap } from '../types';
|
||||
import { TileMapFileContent } from './TileMapFileContent';
|
||||
export declare namespace TileMapLoader {
|
||||
/**
|
||||
* Create a {@link EditableTileMap} from the raw data.
|
||||
*
|
||||
* @param tiledMap The data exported from Tiled/LDtk.
|
||||
* @param tileMapFileContent The data exported from Tiled/LDtk.
|
||||
* @param levelIndex The level of the tile map to load from.
|
||||
* @param pako The zlib library.
|
||||
* @returns A {@link EditableTileMap}
|
||||
*/
|
||||
function load(
|
||||
tileMap: TileMap,
|
||||
tileMapFileContent: TileMapFileContent,
|
||||
levelIndex: number,
|
||||
pako: any
|
||||
): EditableTileMap | null;
|
||||
|
@@ -1 +1 @@
|
||||
{"version":3,"file":"TileMapLoader.d.ts","sourceRoot":"","sources":["../../src/load/TileMapLoader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAInC,yBAAiB,aAAa,CAAC;IAC7B;;;;;;;OAOG;IACH,SAAgB,IAAI,CAClB,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,GAAG,GACR,eAAe,GAAG,IAAI,CAaxB;CACF"}
|
||||
{"version":3,"file":"TileMapLoader.d.ts","sourceRoot":"","sources":["../../src/load/TileMapLoader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAI1D,yBAAiB,aAAa,CAAC;IAC7B;;;;;;;OAOG;IACH,SAAgB,IAAI,CAClB,kBAAkB,EAAE,kBAAkB,EACtC,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,GAAG,GACR,eAAe,GAAG,IAAI,CAaxB;CACF"}
|
@@ -2,7 +2,7 @@ import { integer } from '../../model/CommonTypes';
|
||||
/**
|
||||
* version 1.1.3 - https://github.com/deepnight/ldtk/blob/66fff7199932357f3ab9b044c2fc2a856f527831/docs/JSON_SCHEMA.json
|
||||
*/
|
||||
export type LDtkTileMap = {
|
||||
export declare type LDtkTileMap = {
|
||||
/** LDtk application build identifier.<br/> This is only used to identify the LDtk version that generated this particular project file, which can be useful for specific bug fixing. Note that the build identifier is just the date of the release, so it's not unique to each user (one single global ID per LDtk public release), and as a result, completely anonymous. */
|
||||
appBuildId: number;
|
||||
/** Number of backup files to keep, if the `backupOnSave` is TRUE */
|
||||
@@ -72,7 +72,7 @@ export type LDtkTileMap = {
|
||||
| null;
|
||||
};
|
||||
/** Auto-layer rule group */
|
||||
type LDtkAutoLayerRuleGroup = {
|
||||
declare type LDtkAutoLayerRuleGroup = {
|
||||
/** */
|
||||
active: boolean;
|
||||
/** *This field was removed in 1.0.0 and should no longer be used.* */
|
||||
@@ -87,9 +87,9 @@ type LDtkAutoLayerRuleGroup = {
|
||||
uid: integer;
|
||||
};
|
||||
/** This complex section isn't meant to be used by game devs at all, as these rules are completely resolved internally by the editor before any saving. You should just ignore this part. */
|
||||
type LDtkAutoRuleDef = {};
|
||||
declare type LDtkAutoRuleDef = {};
|
||||
/** If you're writing your own LDtk importer, you should probably just ignore *most* stuff in the `defs` section, as it contains data that are mostly important to the editor. To keep you away from the `defs` section and avoid some unnecessary JSON parsing, important data from definitions is often duplicated in fields prefixed with a double underscore (eg. `__identifier` or `__type`). The 2 only definition types you might need here are **Tilesets** and **Enums**. */
|
||||
type LDtkDefinition = {
|
||||
declare type LDtkDefinition = {
|
||||
/** All entities definitions, including their custom fields */
|
||||
entities: LDtkEntityDef[];
|
||||
/** All internal enums */
|
||||
@@ -104,7 +104,7 @@ type LDtkDefinition = {
|
||||
tilesets: LDtkTilesetDef[];
|
||||
};
|
||||
/** Entity definition */
|
||||
type LDtkEntityDef = {
|
||||
declare type LDtkEntityDef = {
|
||||
/** Base entity color */
|
||||
color: string;
|
||||
/** Array of field definitions */
|
||||
@@ -166,7 +166,7 @@ type LDtkEntityDef = {
|
||||
width: integer;
|
||||
};
|
||||
/** Entity instance */
|
||||
type LDtkEntityInstance = {
|
||||
declare type LDtkEntityInstance = {
|
||||
/** Grid-based coordinates (`[x,y]` format) */
|
||||
__grid: integer[];
|
||||
/** Entity definition identifier */
|
||||
@@ -193,7 +193,7 @@ type LDtkEntityInstance = {
|
||||
width: integer;
|
||||
};
|
||||
/** Enum definition */
|
||||
type LDtkEnumDef = {
|
||||
declare type LDtkEnumDef = {
|
||||
/** */
|
||||
externalFileChecksum: string | null;
|
||||
/** Relative path to the external file providing this Enum */
|
||||
@@ -210,7 +210,7 @@ type LDtkEnumDef = {
|
||||
values: LDtkEnumDefValues[];
|
||||
};
|
||||
/** Enum value definition */
|
||||
type LDtkEnumDefValues = {
|
||||
declare type LDtkEnumDefValues = {
|
||||
/** An array of 4 Int values that refers to the tile in the tileset image: `[ x, y, width, height ]` */
|
||||
__tileSrcRect: integer[] | null;
|
||||
/** Optional color */
|
||||
@@ -221,14 +221,14 @@ type LDtkEnumDefValues = {
|
||||
tileId: integer | null;
|
||||
};
|
||||
/** In a tileset definition, enum based tag infos */
|
||||
type LDtkEnumTagValue = {
|
||||
declare type LDtkEnumTagValue = {
|
||||
/** */
|
||||
enumValueId: string;
|
||||
/** */
|
||||
tileIds: integer[];
|
||||
};
|
||||
/** This section is mostly only intended for the LDtk editor app itself. You can safely ignore it. */
|
||||
type LDtkFieldDef = {
|
||||
declare type LDtkFieldDef = {
|
||||
/** Human readable value type. Possible values: `Int, Float, String, Bool, Color, ExternEnum.XXX, LocalEnum.XXX, Point, FilePath`.<br/> If the field is an array, this field will look like `Array<...>` (eg. `Array<Int>`, `Array<Point>` etc.)<br/> NOTE: if you enable the advanced option **Use Multilines type**, you will have \"*Multilines*\" instead of \"*String*\" when relevant. */
|
||||
__type: string;
|
||||
/** Optional list of accepted file extensions for FilePath value type. Includes the dot: `.ext` */
|
||||
@@ -310,7 +310,7 @@ type LDtkFieldDef = {
|
||||
useForSmartColor: boolean;
|
||||
};
|
||||
/** Field instance */
|
||||
type LDtkFieldInstance = {
|
||||
declare type LDtkFieldInstance = {
|
||||
/** Field definition identifier */
|
||||
__identifier: string;
|
||||
/** Optional TilesetRect used to display this field (this can be the field own Tile, or some other Tile guessed from the value, like an Enum). */
|
||||
@@ -324,7 +324,7 @@ type LDtkFieldInstance = {
|
||||
/** Editor internal raw values */
|
||||
realEditorValues: any[];
|
||||
};
|
||||
type LDtkFlag =
|
||||
declare type LDtkFlag =
|
||||
| 'DiscardPreCsvIntGrid'
|
||||
| 'ExportPreCsvIntGridFormat'
|
||||
| 'IgnoreBackupSuggest'
|
||||
@@ -332,7 +332,7 @@ type LDtkFlag =
|
||||
| 'MultiWorlds'
|
||||
| 'UseMultilinesType';
|
||||
/** IntGrid value definition */
|
||||
type LDtkIntGridValueDef = {
|
||||
declare type LDtkIntGridValueDef = {
|
||||
/** */
|
||||
color: string;
|
||||
/** User defined unique identifier */
|
||||
@@ -341,14 +341,14 @@ type LDtkIntGridValueDef = {
|
||||
value: integer;
|
||||
};
|
||||
/** IntGrid value instance */
|
||||
type LDtkIntGridValueInstance = {
|
||||
declare type LDtkIntGridValueInstance = {
|
||||
/** Coordinate ID in the layer grid */
|
||||
coordId: integer;
|
||||
/** IntGrid value */
|
||||
v: integer;
|
||||
};
|
||||
/** Layer definition */
|
||||
type LDtkLayerDef = {
|
||||
declare type LDtkLayerDef = {
|
||||
/** Type of the layer (*IntGrid, Entities, Tiles or AutoLayer*) */
|
||||
__type: string;
|
||||
/** Contains all the auto-layer rule definitions. */
|
||||
@@ -401,7 +401,7 @@ type LDtkLayerDef = {
|
||||
uid: integer;
|
||||
};
|
||||
/** Layer instance */
|
||||
type LDtkLayerInstance = {
|
||||
declare type LDtkLayerInstance = {
|
||||
/** Grid-based height */
|
||||
__cHei: integer;
|
||||
/** Grid-based width */
|
||||
@@ -452,7 +452,7 @@ type LDtkLayerInstance = {
|
||||
visible: boolean;
|
||||
};
|
||||
/** This section contains all the level data. It can be found in 2 distinct forms, depending on Project current settings: - If \"*Separate level files*\" is **disabled** (default): full level data is *embedded* inside the main Project JSON file, - If \"*Separate level files*\" is **enabled**: level data is stored in *separate* standalone `.ldtkl` files (one per level). In this case, the main Project JSON file will still contain most level data, except heavy sections, like the `layerInstances` array (which will be null). The `externalRelPath` string points to the `ldtkl` file. A `ldtkl` file is just a JSON file containing exactly what is described below. */
|
||||
type LDtkLevel = {
|
||||
declare type LDtkLevel = {
|
||||
/** Background color of the level (same as `bgColor`, except the default value is automatically used here if its value is `null`) */
|
||||
__bgColor: string;
|
||||
/** Position informations of the background image, if there is one. */
|
||||
@@ -497,7 +497,7 @@ type LDtkLevel = {
|
||||
worldY: integer;
|
||||
};
|
||||
/** Level background image position info */
|
||||
type LDtkLevelBgPosInfos = {
|
||||
declare type LDtkLevelBgPosInfos = {
|
||||
/** An array of 4 float values describing the cropped sub-rectangle of the displayed background image. This cropping happens when original is larger than the level bounds. Array format: `[ cropX, cropY, cropWidth, cropHeight ]` */
|
||||
cropRect: number[];
|
||||
/** An array containing the `[scaleX,scaleY]` values of the **cropped** background image, depending on `bgPos` option. */
|
||||
@@ -506,7 +506,7 @@ type LDtkLevelBgPosInfos = {
|
||||
topLeftPx: integer[];
|
||||
};
|
||||
/** Nearby level info */
|
||||
type LDtkNeighbourLevel = {
|
||||
declare type LDtkNeighbourLevel = {
|
||||
/** A single lowercase character tipping on the level location (`n`orth, `s`outh, `w`est, `e`ast). */
|
||||
dir: string;
|
||||
/** Neighbour Instance Identifier */
|
||||
@@ -515,7 +515,7 @@ type LDtkNeighbourLevel = {
|
||||
levelUid: integer;
|
||||
};
|
||||
/** This structure represents a single tile from a given Tileset. */
|
||||
type LDtkTile = {
|
||||
declare type LDtkTile = {
|
||||
/** Internal data used by the editor.<br/> For auto-layer tiles: `[ruleId, coordId]`.<br/> For tile-layer tiles: `[coordId]`. */
|
||||
d: integer[];
|
||||
/** \"Flip bits\", a 2-bits integer to represent the mirror transformations of the tile.<br/> - Bit 0 = X flip<br/> - Bit 1 = Y flip<br/> Examples: f=0 (no flip), f=1 (X flip only), f=2 (Y flip only), f=3 (both flips) */
|
||||
@@ -528,7 +528,7 @@ type LDtkTile = {
|
||||
t: integer;
|
||||
};
|
||||
/** The `Tileset` definition is the most important part among project definitions. It contains some extra informations about each integrated tileset. If you only had to parse one definition section, that would be the one. */
|
||||
export type LDtkTilesetDef = {
|
||||
export declare type LDtkTilesetDef = {
|
||||
/** Grid-based height */
|
||||
__cHei: integer;
|
||||
/** Grid-based width */
|
||||
@@ -565,14 +565,14 @@ export type LDtkTilesetDef = {
|
||||
uid: integer;
|
||||
};
|
||||
/** In a tileset definition, user defined meta-data of a tile. */
|
||||
type LDtkTileCustomMetadata = {
|
||||
declare type LDtkTileCustomMetadata = {
|
||||
/** */
|
||||
data: string;
|
||||
/** */
|
||||
tileId: integer;
|
||||
};
|
||||
/** This object represents a custom sub rectangle in a Tileset image. */
|
||||
type LDtkTilesetRect = {
|
||||
declare type LDtkTilesetRect = {
|
||||
/** Height in pixels */
|
||||
h: integer;
|
||||
/** UID of the tileset */
|
||||
@@ -584,6 +584,6 @@ type LDtkTilesetRect = {
|
||||
/** Y pixels coordinate of the top-left corner in the Tileset image */
|
||||
y: integer;
|
||||
};
|
||||
type LDtkWorld = {};
|
||||
declare type LDtkWorld = {};
|
||||
export {};
|
||||
//# sourceMappingURL=LDtkFormat.d.ts.map
|
||||
|
File diff suppressed because one or more lines are too long
@@ -2,7 +2,7 @@ import { float, integer } from '../../model/CommonTypes';
|
||||
/**
|
||||
* Tiled JSON format (https://github.com/mapeditor/tiled/blob/master/docs/reference/json-map-format.rst).
|
||||
*/
|
||||
export type TiledTileMap = {
|
||||
export declare type TiledTileMap = {
|
||||
/** Hex-formatted color (#RRGGBB or #AARRGGBB) (optional) */
|
||||
backgroundcolor?: string;
|
||||
/** The compression level to use for tile layer data (defaults to -1, which means to use the algorithm default) */
|
||||
@@ -44,7 +44,7 @@ export type TiledTileMap = {
|
||||
/** Number of tile columns */
|
||||
width: integer;
|
||||
};
|
||||
export type TiledLayer = {
|
||||
export declare type TiledLayer = {
|
||||
/** Array of {@link TiledChunk} (optional). `tilelayer` only. */
|
||||
chunks?: Array<TiledChunk>;
|
||||
/** `zlib`, `gzip`, `zstd` (since Tiled 1.3) or empty (default). `tilelayer` only. */
|
||||
@@ -98,7 +98,7 @@ export type TiledLayer = {
|
||||
/** Vertical layer offset in tiles. Always 0. */
|
||||
y: integer;
|
||||
};
|
||||
export type TiledChunk = {
|
||||
export declare type TiledChunk = {
|
||||
/** Array of `unsigned` `integer` (GIDs) or base64-encoded data */
|
||||
data: Array<integer> | string;
|
||||
/** Height in tiles */
|
||||
@@ -110,7 +110,7 @@ export type TiledChunk = {
|
||||
/** Y coordinate in tiles */
|
||||
y: integer;
|
||||
};
|
||||
export type TiledObject = {
|
||||
export declare type TiledObject = {
|
||||
/** The class of the object (renamed from type since 1.9, optional) */
|
||||
class?: string;
|
||||
/** Used to mark an object as an ellipse */
|
||||
@@ -146,7 +146,7 @@ export type TiledObject = {
|
||||
/** Y coordinate in pixels */
|
||||
y: float;
|
||||
};
|
||||
export type TiledText = {
|
||||
export declare type TiledText = {
|
||||
/** Whether to use a bold font (default: `false`) */
|
||||
bold: boolean;
|
||||
/** Hex-formatted color (#RRGGBB or #AARRGGBB) (default: `#000000`) */
|
||||
@@ -172,7 +172,7 @@ export type TiledText = {
|
||||
/** Whether the text is wrapped within the object bounds (default: `false`) */
|
||||
wrap: boolean;
|
||||
};
|
||||
export type TiledTileset = {
|
||||
export declare type TiledTileset = {
|
||||
/** Hex-formatted color (#RRGGBB or #AARRGGBB) (optional) */
|
||||
backgroundcolor?: string;
|
||||
/** The number of tile columns in the tileset */
|
||||
@@ -224,7 +224,7 @@ export type TiledTileset = {
|
||||
/** Array of {@link TiledWangSet} (since 1.1.5) */
|
||||
wangsets?: Array<TiledWangSet>;
|
||||
};
|
||||
export type TiledGrid = {
|
||||
export declare type TiledGrid = {
|
||||
/** Cell height of tile grid */
|
||||
height: integer;
|
||||
/** `orthogonal` (default) or `isometric` */
|
||||
@@ -232,13 +232,13 @@ export type TiledGrid = {
|
||||
/** Cell width of tile grid */
|
||||
width: integer;
|
||||
};
|
||||
export type TileOffset = {
|
||||
export declare type TileOffset = {
|
||||
/** Horizontal offset in pixels */
|
||||
x: integer;
|
||||
/** Vertical offset in pixels (positive is down) */
|
||||
y: integer;
|
||||
};
|
||||
export type TiledTransformations = {
|
||||
export declare type TiledTransformations = {
|
||||
/** Tiles can be flipped horizontally */
|
||||
hflip: boolean;
|
||||
/** Tiles can be flipped vertically */
|
||||
@@ -248,7 +248,7 @@ export type TiledTransformations = {
|
||||
/** Whether untransformed tiles remain preferred, otherwise transformed tiles are used to produce more variations */
|
||||
preferuntransformed: boolean;
|
||||
};
|
||||
export type TiledTileDefinition = {
|
||||
export declare type TiledTileDefinition = {
|
||||
/** Array of {@link TiledTiles} */
|
||||
animation?: Array<TiledTileDefinition>;
|
||||
/** The class of the tile (renamed from type since 1.9, optional) */
|
||||
@@ -270,13 +270,13 @@ export type TiledTileDefinition = {
|
||||
/** Index of terrain for each corner of tile (optional) */
|
||||
terrain?: Array<integer>;
|
||||
};
|
||||
export type TiledFrame = {
|
||||
export declare type TiledFrame = {
|
||||
/** Frame duration in milliseconds */
|
||||
duration: integer;
|
||||
/** Local tile ID representing this frame */
|
||||
tileid: integer;
|
||||
};
|
||||
export type TiledTerrain = {
|
||||
export declare type TiledTerrain = {
|
||||
/** Name of terrain */
|
||||
name: string;
|
||||
/** Array of {@link TiledProperty} */
|
||||
@@ -284,7 +284,7 @@ export type TiledTerrain = {
|
||||
/** Local ID of tile representing terrain */
|
||||
tile: integer;
|
||||
};
|
||||
export type TiledWangSet = {
|
||||
export declare type TiledWangSet = {
|
||||
/** Array of {@link TiledWangColor} */
|
||||
colors: Array<TiledWangColor>;
|
||||
/** Name of the Wang set */
|
||||
@@ -296,7 +296,7 @@ export type TiledWangSet = {
|
||||
/** Array of {@link TiledWangTile} */
|
||||
wangtiles: Array<TiledWangTile>;
|
||||
};
|
||||
export type TiledWangColor = {
|
||||
export declare type TiledWangColor = {
|
||||
/** Hex-formatted color (#RRGGBB or #AARRGGBB) */
|
||||
color: string;
|
||||
/** Name of the Wang color */
|
||||
@@ -308,13 +308,13 @@ export type TiledWangColor = {
|
||||
/** Local ID of tile representing the Wang color */
|
||||
tile: integer;
|
||||
};
|
||||
export type TiledWangTile = {
|
||||
export declare type TiledWangTile = {
|
||||
/** Local ID of tile */
|
||||
tileid: integer;
|
||||
/** Array of Wang color indexes (`uchar[8]`) */
|
||||
wangid: Array<integer>;
|
||||
};
|
||||
export type TiledObjectTemplate = {
|
||||
export declare type TiledObjectTemplate = {
|
||||
/** `template` */
|
||||
type: string;
|
||||
/** External tileset used by the template (optional) */
|
||||
@@ -322,7 +322,7 @@ export type TiledObjectTemplate = {
|
||||
/** The object instantiated by this template */
|
||||
object: Object;
|
||||
};
|
||||
export type TiledProperty = {
|
||||
export declare type TiledProperty = {
|
||||
/** Name of the property */
|
||||
name: string;
|
||||
/** type of the property (`string` (default), `integer`, `float`, `boolean`, `color` or `file` (since 0.16, with `color` and `file` added in 0.17)) */
|
||||
@@ -330,7 +330,7 @@ export type TiledProperty = {
|
||||
/** Value of the property */
|
||||
value: string | number;
|
||||
};
|
||||
export type TiledPoint = {
|
||||
export declare type TiledPoint = {
|
||||
/** X coordinate in pixels */
|
||||
x: float;
|
||||
/** Y coordinate in pixels */
|
||||
|
File diff suppressed because one or more lines are too long
@@ -12,7 +12,7 @@ export declare const decodeBase64LayerData: (
|
||||
pako: any,
|
||||
tiledLayer: TiledLayer
|
||||
) => number[];
|
||||
export type TiledGID = {
|
||||
export declare type TiledGID = {
|
||||
id: integer;
|
||||
flippedHorizontally: boolean;
|
||||
flippedVertically: boolean;
|
||||
|
@@ -1 +1 @@
|
||||
{"version":3,"file":"TiledTileMapLoaderHelper.d.ts","sourceRoot":"","sources":["../../../src/load/tiled/TiledTileMapLoaderHelper.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,SAAU,GAAG,cAAc,UAAU,aAgDtE,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG;IACrB,EAAE,EAAE,OAAO,CAAC;IACZ,mBAAmB,EAAE,OAAO,CAAC;IAC7B,iBAAiB,EAAE,OAAO,CAAC;IAC3B,iBAAiB,EAAE,OAAO,CAAC;CAC5B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,2BAA2B,kBACvB,OAAO,KACrB,QAmBF,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,MAAM,GAAG,SAAS,GAC3B,MAAM,GAAG,SAAS,CAEpB"}
|
||||
{"version":3,"file":"TiledTileMapLoaderHelper.d.ts","sourceRoot":"","sources":["../../../src/load/tiled/TiledTileMapLoaderHelper.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,SAAU,GAAG,cAAc,UAAU,aAgDtE,CAAC;AAEF,oBAAY,QAAQ,GAAG;IACrB,EAAE,EAAE,OAAO,CAAC;IACZ,mBAAmB,EAAE,OAAO,CAAC;IAC7B,iBAAiB,EAAE,OAAO,CAAC;IAC3B,iBAAiB,EAAE,OAAO,CAAC;CAC5B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,2BAA2B,kBACvB,OAAO,KACrB,QAmBF,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,MAAM,GAAG,SAAS,GAC3B,MAAM,GAAG,SAAS,CAEpB"}
|
@@ -1,5 +1,5 @@
|
||||
export declare type integer = number;
|
||||
export declare type float = number;
|
||||
export type FloatPoint = [float, float];
|
||||
export type PolygonVertices = FloatPoint[];
|
||||
export declare type FloatPoint = [float, float];
|
||||
export declare type PolygonVertices = FloatPoint[];
|
||||
//# sourceMappingURL=CommonTypes.d.ts.map
|
||||
|
@@ -1 +1 @@
|
||||
{"version":3,"file":"CommonTypes.d.ts","sourceRoot":"","sources":["../../src/model/CommonTypes.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,MAAM,OAAO,GAAG,MAAM,CAAC;AACrC,MAAM,CAAC,OAAO,MAAM,KAAK,GAAG,MAAM,CAAC;AACnC,MAAM,MAAM,UAAU,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AAExC,MAAM,MAAM,eAAe,GAAG,UAAU,EAAE,CAAC"}
|
||||
{"version":3,"file":"CommonTypes.d.ts","sourceRoot":"","sources":["../../src/model/CommonTypes.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,MAAM,OAAO,GAAG,MAAM,CAAC;AACrC,MAAM,CAAC,OAAO,MAAM,KAAK,GAAG,MAAM,CAAC;AACnC,oBAAY,UAAU,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AAExC,oBAAY,eAAe,GAAG,UAAU,EAAE,CAAC"}
|
@@ -1,7 +1,7 @@
|
||||
import { EditableTileMap } from '../model/TileMapModel';
|
||||
import { TileTextureCache } from './TileTextureCache';
|
||||
import PIXI = GlobalPIXIModule.PIXI;
|
||||
import { TileMap } from '../types';
|
||||
import { TileMapFileContent } from '../load/TileMapFileContent';
|
||||
/**
|
||||
* A holder to share tile maps across the 2 extension objects.
|
||||
*
|
||||
@@ -23,7 +23,7 @@ export declare class TileMapManager {
|
||||
* @param data JSON data.
|
||||
* @returns The data enclosed with its detected kind.
|
||||
*/
|
||||
static identify(data: any): TileMap | null;
|
||||
static identify(data: any): TileMapFileContent | null;
|
||||
/**
|
||||
* @param loadTileMap The method that loads the Tiled JSON file in memory.
|
||||
* @param tileMapJsonResourceName The resource name of the tile map.
|
||||
@@ -36,7 +36,7 @@ export declare class TileMapManager {
|
||||
loadTileMap: (
|
||||
tileMapJsonResourceName: string,
|
||||
tileSetJsonResourceName: string,
|
||||
callback: (tileMap: TileMap | null) => void
|
||||
callback: (tileMapFileContent: TileMapFileContent | null) => void
|
||||
) => void,
|
||||
tileMapJsonResourceName: string,
|
||||
tileSetJsonResourceName: string,
|
||||
@@ -57,7 +57,7 @@ export declare class TileMapManager {
|
||||
loadTileMap: (
|
||||
tileMapJsonResourceName: string,
|
||||
tileSetJsonResourceName: string,
|
||||
callback: (tileMap: TileMap | null) => void
|
||||
callback: (tileMapFileContent: TileMapFileContent | null) => void
|
||||
) => void,
|
||||
getTexture: (textureName: string) => PIXI.BaseTexture<PIXI.Resource>,
|
||||
atlasImageResourceName: string,
|
||||
|
@@ -1 +1 @@
|
||||
{"version":3,"file":"TileMapManager.d.ts","sourceRoot":"","sources":["../../src/render/TileMapManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAGtD,OAAO,IAAI,GAAG,gBAAgB,CAAC,IAAI,CAAC;AAEpC,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAEnC;;;;;;;GAOG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,aAAa,CAAiC;IACtD,OAAO,CAAC,mBAAmB,CAAkC;;IAO7D;;;OAGG;IACH,MAAM,CAAC,UAAU,CAAC,cAAc,EAAE,MAAM,GAAG,cAAc;IAWzD;;;OAGG;IACH,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,GAAG,GAAG,OAAO,GAAG,IAAI;IAyB1C;;;;;;;OAOG;IACH,gBAAgB,CACd,WAAW,EAAE,CACX,uBAAuB,EAAE,MAAM,EAC/B,uBAAuB,EAAE,MAAM,EAC/B,QAAQ,EAAE,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,KAAK,IAAI,KACxC,IAAI,EACT,uBAAuB,EAAE,MAAM,EAC/B,uBAAuB,EAAE,MAAM,EAC/B,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,GAAG,EACT,QAAQ,EAAE,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI,KAAK,IAAI,GAClD,IAAI;IAiCP;;;;;;;;OAQG;IACH,qBAAqB,CACnB,WAAW,EAAE,CACX,uBAAuB,EAAE,MAAM,EAC/B,uBAAuB,EAAE,MAAM,EAC/B,QAAQ,EAAE,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,KAAK,IAAI,KACxC,IAAI,EACT,UAAU,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,EACpE,sBAAsB,EAAE,MAAM,EAC9B,uBAAuB,EAAE,MAAM,EAC/B,uBAAuB,EAAE,MAAM,EAC/B,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,CAAC,YAAY,EAAE,gBAAgB,GAAG,IAAI,KAAK,IAAI,GACxD,IAAI;CAuCR"}
|
||||
{"version":3,"file":"TileMapManager.d.ts","sourceRoot":"","sources":["../../src/render/TileMapManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAGtD,OAAO,IAAI,GAAG,gBAAgB,CAAC,IAAI,CAAC;AAEpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAEhE;;;;;;;GAOG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,aAAa,CAAiC;IACtD,OAAO,CAAC,mBAAmB,CAAkC;;IAO7D;;;OAGG;IACH,MAAM,CAAC,UAAU,CAAC,cAAc,EAAE,MAAM,GAAG,cAAc;IAWzD;;;OAGG;IACH,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,GAAG,GAAG,kBAAkB,GAAG,IAAI;IAwBrD;;;;;;;OAOG;IACH,gBAAgB,CACd,WAAW,EAAE,CACX,uBAAuB,EAAE,MAAM,EAC/B,uBAAuB,EAAE,MAAM,EAC/B,QAAQ,EAAE,CAAC,kBAAkB,EAAE,kBAAkB,GAAG,IAAI,KAAK,IAAI,KAC9D,IAAI,EACT,uBAAuB,EAAE,MAAM,EAC/B,uBAAuB,EAAE,MAAM,EAC/B,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,GAAG,EACT,QAAQ,EAAE,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI,KAAK,IAAI,GAClD,IAAI;IAiCP;;;;;;;;OAQG;IACH,qBAAqB,CACnB,WAAW,EAAE,CACX,uBAAuB,EAAE,MAAM,EAC/B,uBAAuB,EAAE,MAAM,EAC/B,QAAQ,EAAE,CAAC,kBAAkB,EAAE,kBAAkB,GAAG,IAAI,KAAK,IAAI,KAC9D,IAAI,EACT,UAAU,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,EACpE,sBAAsB,EAAE,MAAM,EAC9B,uBAAuB,EAAE,MAAM,EAC/B,uBAAuB,EAAE,MAAM,EAC/B,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,CAAC,YAAY,EAAE,gBAAgB,GAAG,IAAI,KAAK,IAAI,GACxD,IAAI;CAuCR"}
|
@@ -1,6 +1,6 @@
|
||||
import { integer, float } from '../model/CommonTypes';
|
||||
import { EditableTileMap } from '../model/TileMapModel';
|
||||
import { TileMap } from '../types';
|
||||
import { TileMapFileContent } from '../load/TileMapFileContent';
|
||||
import { TileTextureCache } from './TileTextureCache';
|
||||
import PIXI = GlobalPIXIModule.PIXI;
|
||||
export declare namespace PixiTileMapHelper {
|
||||
@@ -14,7 +14,7 @@ export declare namespace PixiTileMapHelper {
|
||||
* @returns A textures cache.
|
||||
*/
|
||||
function parseAtlas(
|
||||
tileMap: TileMap,
|
||||
tileMap: TileMapFileContent,
|
||||
levelIndex: number,
|
||||
atlasTexture: PIXI.BaseTexture<PIXI.Resource> | null,
|
||||
getTexture: (textureName: string) => PIXI.BaseTexture<PIXI.Resource>
|
||||
|
@@ -1 +1 @@
|
||||
{"version":3,"file":"TileMapPixiHelper.d.ts","sourceRoot":"","sources":["../../src/render/TileMapPixiHelper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAEL,eAAe,EAEhB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAGtD,OAAO,IAAI,GAAG,gBAAgB,CAAC,IAAI,CAAC;AAEpC,yBAAiB,iBAAiB,CAAC;IACjC;;;;;;;;OAQG;IACH,SAAgB,UAAU,CACxB,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,IAAI,EACpD,UAAU,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,GACnE,gBAAgB,GAAG,IAAI,CAuBzB;IAED;;;;;;;;;;;;OAYG;IACH,SAAgB,iBAAiB,CAC/B,kBAAkB,EAAE,GAAG,EACvB,OAAO,EAAE,eAAe,EACxB,YAAY,EAAE,gBAAgB,EAC9B,WAAW,EAAE,OAAO,GAAG,SAAS,GAAG,KAAK,EACxC,UAAU,EAAE,MAAM,GACjB,IAAI,CA0GN;IAED;;OAEG;IACH,SAAgB,uBAAuB,CACrC,YAAY,EAAE,IAAI,CAAC,QAAQ,EAC3B,OAAO,EAAE,eAAe,EACxB,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,OAAO,EACpB,YAAY,EAAE,OAAO,EACrB,cAAc,EAAE,KAAK,EACrB,SAAS,EAAE,OAAO,EAClB,WAAW,EAAE,KAAK,GACjB,IAAI,CAgEN;CACF"}
|
||||
{"version":3,"file":"TileMapPixiHelper.d.ts","sourceRoot":"","sources":["../../src/render/TileMapPixiHelper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAEL,eAAe,EAEhB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAGtD,OAAO,IAAI,GAAG,gBAAgB,CAAC,IAAI,CAAC;AAEpC,yBAAiB,iBAAiB,CAAC;IACjC;;;;;;;;OAQG;IACH,SAAgB,UAAU,CACxB,OAAO,EAAE,kBAAkB,EAC3B,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,IAAI,EACpD,UAAU,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,GACnE,gBAAgB,GAAG,IAAI,CAuBzB;IAED;;;;;;;;;;;;OAYG;IACH,SAAgB,iBAAiB,CAC/B,kBAAkB,EAAE,GAAG,EACvB,OAAO,EAAE,eAAe,EACxB,YAAY,EAAE,gBAAgB,EAC9B,WAAW,EAAE,OAAO,GAAG,SAAS,GAAG,KAAK,EACxC,UAAU,EAAE,MAAM,GACjB,IAAI,CA0GN;IAED;;OAEG;IACH,SAAgB,uBAAuB,CACrC,YAAY,EAAE,IAAI,CAAC,QAAQ,EAC3B,OAAO,EAAE,eAAe,EACxB,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,OAAO,EACpB,YAAY,EAAE,OAAO,EACrB,cAAc,EAAE,KAAK,EACrB,SAAS,EAAE,OAAO,EAClB,WAAW,EAAE,KAAK,GACjB,IAAI,CAgEN;CACF"}
|
@@ -1,8 +1,10 @@
|
||||
import { TileTextureCache } from '../TileTextureCache';
|
||||
import { LDtkTileMap } from '../../load/ldtk/LDtkFormat';
|
||||
import PIXI = GlobalPIXIModule.PIXI;
|
||||
type Texture = PIXI.BaseTexture<PIXI.Resource>;
|
||||
type TextureLoader = (textureName: string) => PIXI.BaseTexture<PIXI.Resource>;
|
||||
declare type Texture = PIXI.BaseTexture<PIXI.Resource>;
|
||||
declare type TextureLoader = (
|
||||
textureName: string
|
||||
) => PIXI.BaseTexture<PIXI.Resource>;
|
||||
export declare namespace LDtkPixiHelper {
|
||||
/**
|
||||
* Split an atlas image into Pixi textures.
|
||||
|
@@ -1 +1 @@
|
||||
{"version":3,"file":"LDtkPixiHelper.d.ts","sourceRoot":"","sources":["../../../src/render/ldtk/LDtkPixiHelper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAkB,MAAM,4BAA4B,CAAC;AAEzE,OAAO,IAAI,GAAG,gBAAgB,CAAC,IAAI,CAAC;AAEpC,KAAK,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AAC/C,KAAK,aAAa,GAAG,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AAmC9E,yBAAiB,cAAc,CAAC;IAC9B;;;;;;;;OAQG;IACH,SAAgB,UAAU,CACxB,OAAO,EAAE,WAAW,EACpB,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,OAAO,GAAG,IAAI,EAC5B,UAAU,EAAE,aAAa,GACxB,gBAAgB,GAAG,IAAI,CAoFzB;CACF"}
|
||||
{"version":3,"file":"LDtkPixiHelper.d.ts","sourceRoot":"","sources":["../../../src/render/ldtk/LDtkPixiHelper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAkB,MAAM,4BAA4B,CAAC;AAEzE,OAAO,IAAI,GAAG,gBAAgB,CAAC,IAAI,CAAC;AAEpC,aAAK,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AAC/C,aAAK,aAAa,GAAG,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AAmC9E,yBAAiB,cAAc,CAAC;IAC9B;;;;;;;;OAQG;IACH,SAAgB,UAAU,CACxB,OAAO,EAAE,WAAW,EACpB,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,OAAO,GAAG,IAAI,EAC5B,UAAU,EAAE,aAAa,GACxB,gBAAgB,GAAG,IAAI,CAoFzB;CACF"}
|
@@ -1,6 +1,6 @@
|
||||
import { LDtkTileMap } from '../load/ldtk/LDtkFormat';
|
||||
import { TiledTileMap } from '../load/tiled/TiledFormat';
|
||||
export type TileMap =
|
||||
export declare type TileMap =
|
||||
| {
|
||||
kind: 'tiled';
|
||||
data: TiledTileMap;
|
||||
|
@@ -1 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD,MAAM,MAAM,OAAO,GACf;IACE,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE,YAAY,CAAC;CACpB,GACD;IACE,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,WAAW,CAAC;CACnB,CAAC"}
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD,oBAAY,OAAO,GACf;IACE,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE,YAAY,CAAC;CACpB,GACD;IACE,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,WAAW,CAAC;CACnB,CAAC"}
|
@@ -45,6 +45,10 @@ namespace gdjs {
|
||||
private _basisTransformation: gdjs.TopDownMovementRuntimeBehavior.BasisTransformation | null;
|
||||
private _temporaryPointForTransformations: FloatPoint = [0, 0];
|
||||
|
||||
private _topDownMovementHooks: Array<
|
||||
gdjs.TopDownMovementRuntimeBehavior.TopDownMovementHook
|
||||
> = [];
|
||||
|
||||
constructor(
|
||||
instanceContainer: gdjs.RuntimeInstanceContainer,
|
||||
behaviorData,
|
||||
@@ -335,6 +339,13 @@ namespace gdjs {
|
||||
}
|
||||
}
|
||||
|
||||
for (const topDownMovementHook of this._topDownMovementHooks) {
|
||||
direction = topDownMovementHook.overrideDirection(direction);
|
||||
}
|
||||
for (const topDownMovementHook of this._topDownMovementHooks) {
|
||||
topDownMovementHook.beforeSpeedUpdate();
|
||||
}
|
||||
|
||||
const object = this.owner;
|
||||
const timeDelta = this.owner.getElapsedTime() / 1000;
|
||||
const previousVelocityX = this._xVelocity;
|
||||
@@ -419,6 +430,10 @@ namespace gdjs {
|
||||
// No acceleration for angular speed for now.
|
||||
this._angularSpeed = this._angularMaxSpeed;
|
||||
|
||||
for (const topDownMovementHook of this._topDownMovementHooks) {
|
||||
topDownMovementHook.beforePositionUpdate();
|
||||
}
|
||||
|
||||
// Position object.
|
||||
// This is a Verlet integration considering the acceleration as constant.
|
||||
// If you expand deltaX or deltaY, it gives, thanks to the usage of both
|
||||
@@ -523,8 +538,44 @@ namespace gdjs {
|
||||
getLastStickInputAngle() {
|
||||
return this._stickAngle;
|
||||
}
|
||||
|
||||
/**
|
||||
* A hook must typically be registered by a behavior that requires this one
|
||||
* in its onCreate function.
|
||||
* The hook must stay forever to avoid side effects like a hooks order
|
||||
* change. To handle deactivated behavior, the hook can check that its
|
||||
* behavior is activated before doing anything.
|
||||
*/
|
||||
registerHook(
|
||||
hook: gdjs.TopDownMovementRuntimeBehavior.TopDownMovementHook
|
||||
) {
|
||||
this._topDownMovementHooks.push(hook);
|
||||
}
|
||||
}
|
||||
|
||||
export namespace TopDownMovementRuntimeBehavior {
|
||||
/**
|
||||
* Allow extensions relying on the top-down movement to customize its
|
||||
* behavior a bit.
|
||||
*/
|
||||
export interface TopDownMovementHook {
|
||||
/**
|
||||
* Return the direction to use instead of the direction given in
|
||||
* parameter.
|
||||
*/
|
||||
overrideDirection(direction: integer): integer;
|
||||
/**
|
||||
* Called before the acceleration and new direction is applied to the
|
||||
* velocity.
|
||||
*/
|
||||
beforeSpeedUpdate(): void;
|
||||
/**
|
||||
* Called before the velocity is applied to the object position and
|
||||
* angle.
|
||||
*/
|
||||
beforePositionUpdate(): void;
|
||||
}
|
||||
|
||||
export interface BasisTransformation {
|
||||
toScreen(worldPoint: FloatPoint, screenPoint: FloatPoint): void;
|
||||
}
|
||||
|
@@ -855,9 +855,9 @@ module.exports = {
|
||||
.addParameter('expression', _('To Hue'), '', false)
|
||||
.addParameter('yesorno', _('Animate Hue'), '', false)
|
||||
.setDefaultValue('yes')
|
||||
.addParameter('expression', _('To Saturation (-1 to ignore)'), '', false)
|
||||
.addParameter('expression', _('To Saturation (0 to 100, -1 to ignore)'), '', false)
|
||||
.setDefaultValue('-1')
|
||||
.addParameter('expression', _('To Lightness (-1 to ignore)'), '', false)
|
||||
.addParameter('expression', _('To Lightness (0 to 100, -1 to ignore)'), '', false)
|
||||
.setDefaultValue('-1')
|
||||
.addParameter('stringWithSelector', _('Easing'), easingChoices, false)
|
||||
.setDefaultValue('linear')
|
||||
|
@@ -164,7 +164,7 @@ BaseObjectExtension::BaseObjectExtension() {
|
||||
objectConditions["CollisionPoint"]
|
||||
.SetFunctionName("isCollidingWithPoint")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectConditions["ObjectTimer"] // deprecated
|
||||
objectConditions["ObjectTimer"] // deprecated
|
||||
.SetFunctionName("timerElapsedTime")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectConditions["CompareObjectTimer"]
|
||||
@@ -223,6 +223,18 @@ BaseObjectExtension::BaseObjectExtension() {
|
||||
objectExpressions["VariableChildCount"]
|
||||
.SetFunctionName("gdjs.RuntimeObject.getVariableChildCount")
|
||||
.SetStatic();
|
||||
objectExpressions["ArrayVariableFirstNumber"]
|
||||
.SetFunctionName("gdjs.RuntimeObject.getFirstVariableNumber")
|
||||
.SetStatic();
|
||||
objectStrExpressions["ArrayVariableFirstString"]
|
||||
.SetFunctionName("gdjs.RuntimeObject.getFirstVariableString")
|
||||
.SetStatic();
|
||||
objectExpressions["ArrayVariableLastNumber"]
|
||||
.SetFunctionName("gdjs.RuntimeObject.getLastVariableNumber")
|
||||
.SetStatic();
|
||||
objectStrExpressions["ArrayVariableLastString"]
|
||||
.SetFunctionName("gdjs.RuntimeObject.getLastVariableString")
|
||||
.SetStatic();
|
||||
objectExpressions["ForceX"].SetFunctionName("getAverageForce().getX");
|
||||
objectExpressions["ForceY"].SetFunctionName("getAverageForce().getY");
|
||||
objectExpressions["ForceAngle"].SetFunctionName("getAverageForce().getAngle");
|
||||
@@ -254,9 +266,9 @@ BaseObjectExtension::BaseObjectExtension() {
|
||||
"gdjs.evtTools.object.createObjectFromGroupOnScene");
|
||||
|
||||
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"); // Deprecated
|
||||
|
||||
GetAllExpressions()["SceneInstancesCount"].SetFunctionName(
|
||||
"gdjs.evtTools.object.getSceneInstancesCount");
|
||||
@@ -335,6 +347,9 @@ BaseObjectExtension::BaseObjectExtension() {
|
||||
objectActions["ObjectVariableRemoveAt"]
|
||||
.SetFunctionName("variableRemoveAt")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectConditions["ObjectVariableChildCount"]
|
||||
.SetFunctionName("getVariableChildCount")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
|
||||
GetAllActions()["MoveObjects"].codeExtraInformation.SetCustomCodeGenerator(
|
||||
[](gd::Instruction &,
|
||||
|
@@ -34,23 +34,46 @@ VariablesExtension::VariablesExtension() {
|
||||
"gdjs.evtTools.variable.getVariableString");
|
||||
GetAllConditions()["GlobalVariableAsBoolean"].SetFunctionName(
|
||||
"gdjs.evtTools.variable.getVariableBoolean");
|
||||
GetAllExpressions()["Variable"].SetFunctionName(
|
||||
"gdjs.evtTools.variable.getVariableNumber");
|
||||
GetAllStrExpressions()["VariableString"].SetFunctionName(
|
||||
"gdjs.evtTools.variable.getVariableString");
|
||||
|
||||
GetAllExpressions()["VariableChildCount"].SetFunctionName(
|
||||
"gdjs.evtTools.variable.getVariableChildCount");
|
||||
GetAllExpressions()["GlobalVariableChildCount"].SetFunctionName(
|
||||
"gdjs.evtTools.variable.getVariableChildCount");
|
||||
|
||||
GetAllExpressions()["Variable"].SetFunctionName(
|
||||
"gdjs.evtTools.variable.getVariableNumber");
|
||||
GetAllStrExpressions()["VariableString"].SetFunctionName(
|
||||
"gdjs.evtTools.variable.getVariableString");
|
||||
GetAllExpressions()["GlobalVariable"].SetFunctionName(
|
||||
"gdjs.evtTools.variable.getVariableNumber");
|
||||
GetAllStrExpressions()["GlobalVariableString"].SetFunctionName(
|
||||
"gdjs.evtTools.variable.getVariableString");
|
||||
|
||||
GetAllStrExpressions()["GlobalVariableFirstString"].SetFunctionName(
|
||||
"gdjs.evtTools.variable.getFirstVariableString");
|
||||
GetAllExpressions()["GlobalVariableFirstNumber"].SetFunctionName(
|
||||
"gdjs.evtTools.variable.getFirstVariableNumber");
|
||||
GetAllStrExpressions()["GlobalVariableLastString"].SetFunctionName(
|
||||
"gdjs.evtTools.variable.getLastVariableString");
|
||||
GetAllExpressions()["GlobalVariableLastNumber"].SetFunctionName(
|
||||
"gdjs.evtTools.variable.getLastVariableNumber");
|
||||
GetAllStrExpressions()["SceneVariableFirstString"].SetFunctionName(
|
||||
"gdjs.evtTools.variable.getFirstVariableString");
|
||||
GetAllExpressions()["SceneVariableFirstNumber"].SetFunctionName(
|
||||
"gdjs.evtTools.variable.getFirstVariableNumber");
|
||||
GetAllStrExpressions()["SceneVariableLastString"].SetFunctionName(
|
||||
"gdjs.evtTools.variable.getLastVariableString");
|
||||
GetAllExpressions()["SceneVariableLastNumber"].SetFunctionName(
|
||||
"gdjs.evtTools.variable.getLastVariableNumber");
|
||||
|
||||
GetAllConditions()["VarSceneDef"].SetFunctionName(
|
||||
"gdjs.evtTools.variable.sceneVariableExists");
|
||||
GetAllConditions()["VarGlobalDef"].SetFunctionName(
|
||||
"gdjs.evtTools.variable.globalVariableExists");
|
||||
GetAllConditions()["SceneVariableChildCount"].SetFunctionName(
|
||||
"gdjs.evtTools.variable.getVariableChildCount");
|
||||
GetAllConditions()["GlobalVariableChildCount"].SetFunctionName(
|
||||
"gdjs.evtTools.variable.getVariableChildCount");
|
||||
|
||||
GetAllActions()["SetSceneVariableAsBoolean"].SetFunctionName(
|
||||
"gdjs.evtTools.variable.setVariableBoolean");
|
||||
|
@@ -190,6 +190,8 @@ bool ExporterHelper::ExportProjectForPixiPreview(
|
||||
runtimeGameOptions.AddChild("gdevelopResourceToken")
|
||||
.SetStringValue(options.gdevelopResourceToken);
|
||||
}
|
||||
runtimeGameOptions.AddChild("allowAuthenticationUsingIframeForPreview")
|
||||
.SetBoolValue(options.allowAuthenticationUsingIframeForPreview);
|
||||
|
||||
// Pass in the options the list of scripts files - useful for hot-reloading.
|
||||
auto &scriptFilesElement = runtimeGameOptions.AddChild("scriptFiles");
|
||||
@@ -589,8 +591,9 @@ void ExporterHelper::AddLibsInclude(bool pixiRenderers,
|
||||
InsertUnique(includesFiles, "runtimescene.js");
|
||||
InsertUnique(includesFiles, "scenestack.js");
|
||||
InsertUnique(includesFiles, "force.js");
|
||||
InsertUnique(includesFiles, "RuntimeLayer.js");
|
||||
InsertUnique(includesFiles, "layer.js");
|
||||
InsertUnique(includesFiles, "RuntimeSceneLayer.js");
|
||||
InsertUnique(includesFiles, "RuntimeCustomObjectLayer.js");
|
||||
InsertUnique(includesFiles, "timer.js");
|
||||
InsertUnique(includesFiles, "runtimewatermark.js");
|
||||
InsertUnique(includesFiles, "runtimegame.js");
|
||||
|
@@ -40,7 +40,8 @@ struct PreviewExportOptions {
|
||||
isDevelopmentEnvironment(false),
|
||||
nonRuntimeScriptsCacheBurst(0),
|
||||
fallbackAuthorId(""),
|
||||
fallbackAuthorUsername(""){};
|
||||
fallbackAuthorUsername(""),
|
||||
allowAuthenticationUsingIframeForPreview(false){};
|
||||
|
||||
/**
|
||||
* \brief Set the address of the debugger server that the game should reach
|
||||
@@ -160,6 +161,20 @@ struct PreviewExportOptions {
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set if, in some exceptional cases, we allow authentication
|
||||
* to be done through a iframe.
|
||||
* This is usually discouraged as the user can't verify that the
|
||||
* authentication window is a genuine one. It's only to be used in trusted
|
||||
* contexts.
|
||||
*/
|
||||
PreviewExportOptions &SetAllowAuthenticationUsingIframeForPreview(
|
||||
bool allowAuthenticationUsingIframeForPreview_) {
|
||||
allowAuthenticationUsingIframeForPreview =
|
||||
allowAuthenticationUsingIframeForPreview_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
gd::Project &project;
|
||||
gd::String exportPath;
|
||||
gd::String websocketDebuggerServerAddress;
|
||||
@@ -176,6 +191,7 @@ struct PreviewExportOptions {
|
||||
unsigned int nonRuntimeScriptsCacheBurst;
|
||||
gd::String electronRemoteRequirePath;
|
||||
gd::String gdevelopResourceToken;
|
||||
bool allowAuthenticationUsingIframeForPreview;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@@ -27,11 +27,15 @@ namespace gdjs {
|
||||
_untransformedHitBoxes: gdjs.Polygon[] = [];
|
||||
/** The dimension of this object is calculated from its children AABBs. */
|
||||
_unrotatedAABB: AABB = { min: [0, 0], max: [0, 0] };
|
||||
_scaleX: number = 1;
|
||||
_scaleY: number = 1;
|
||||
_scaleX: float = 1;
|
||||
_scaleY: float = 1;
|
||||
_flippedX: boolean = false;
|
||||
_flippedY: boolean = false;
|
||||
opacity: float = 255;
|
||||
_customCenter: FloatPoint | null = null;
|
||||
_localTransformation: gdjs.AffineTransformation = new gdjs.AffineTransformation();
|
||||
_localInverseTransformation: gdjs.AffineTransformation = new gdjs.AffineTransformation();
|
||||
_isLocalTransformationDirty: boolean = true;
|
||||
|
||||
/**
|
||||
* @param parent The container the object belongs to
|
||||
@@ -149,8 +153,9 @@ namespace gdjs {
|
||||
this._updateUntransformedHitBoxes();
|
||||
}
|
||||
|
||||
//Update the current hitboxes with the frame custom hit boxes
|
||||
//and apply transformations.
|
||||
// Update the current hitboxes with the frame custom hit boxes
|
||||
// and apply transformations.
|
||||
const localTransformation = this.getLocalTransformation();
|
||||
for (let i = 0; i < this._untransformedHitBoxes.length; ++i) {
|
||||
if (i >= this.hitBoxes.length) {
|
||||
this.hitBoxes.push(new gdjs.Polygon());
|
||||
@@ -163,9 +168,8 @@ namespace gdjs {
|
||||
if (j >= this.hitBoxes[i].vertices.length) {
|
||||
this.hitBoxes[i].vertices.push([0, 0]);
|
||||
}
|
||||
this.applyObjectTransformation(
|
||||
this._untransformedHitBoxes[i].vertices[j][0],
|
||||
this._untransformedHitBoxes[i].vertices[j][1],
|
||||
localTransformation.transform(
|
||||
this._untransformedHitBoxes[i].vertices[j],
|
||||
this.hitBoxes[i].vertices[j]
|
||||
);
|
||||
}
|
||||
@@ -181,11 +185,6 @@ namespace gdjs {
|
||||
_updateUntransformedHitBoxes() {
|
||||
this._isUntransformedHitBoxesDirty = false;
|
||||
|
||||
const oldUnrotatedMinX = this._unrotatedAABB.min[0];
|
||||
const oldUnrotatedMinY = this._unrotatedAABB.min[1];
|
||||
const oldUnrotatedMaxX = this._unrotatedAABB.max[0];
|
||||
const oldUnrotatedMaxY = this._unrotatedAABB.max[1];
|
||||
|
||||
this._untransformedHitBoxes.length = 0;
|
||||
if (this._instanceContainer.getAdhocListOfAllInstances().length === 0) {
|
||||
this._unrotatedAABB.min[0] = 0;
|
||||
@@ -218,20 +217,6 @@ namespace gdjs {
|
||||
}
|
||||
this.hitBoxes.length = this._untransformedHitBoxes.length;
|
||||
}
|
||||
|
||||
// The default camera center depends on the object dimensions so checking
|
||||
// the AABB center is not enough.
|
||||
if (
|
||||
this._unrotatedAABB.min[0] !== oldUnrotatedMinX ||
|
||||
this._unrotatedAABB.min[1] !== oldUnrotatedMinY ||
|
||||
this._unrotatedAABB.max[0] !== oldUnrotatedMaxX ||
|
||||
this._unrotatedAABB.max[1] !== oldUnrotatedMaxY
|
||||
) {
|
||||
this._instanceContainer.onObjectUnscaledCenterChanged(
|
||||
(oldUnrotatedMinX + oldUnrotatedMaxX) / 2,
|
||||
(oldUnrotatedMinY + oldUnrotatedMaxY) / 2
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Position:
|
||||
@@ -246,37 +231,52 @@ namespace gdjs {
|
||||
* @param result Array that will be updated with the result
|
||||
* (x and y position of the point in parent coordinates).
|
||||
*/
|
||||
applyObjectTransformation(x: float, y: float, result: number[]) {
|
||||
let cx = this.getCenterX();
|
||||
let cy = this.getCenterY();
|
||||
applyObjectTransformation(x: float, y: float, destination: FloatPoint) {
|
||||
const source = destination;
|
||||
source[0] = x;
|
||||
source[1] = y;
|
||||
this.getLocalTransformation().transform(source, destination);
|
||||
}
|
||||
|
||||
// Flipping
|
||||
if (this._flippedX) {
|
||||
x = x + (cx - x) * 2;
|
||||
}
|
||||
if (this._flippedY) {
|
||||
y = y + (cy - y) * 2;
|
||||
/**
|
||||
* Return the affine transformation that represents
|
||||
* flipping, scale, rotation and translation of the object.
|
||||
* @returns the affine transformation.
|
||||
*/
|
||||
getLocalTransformation(): gdjs.AffineTransformation {
|
||||
if (this._isLocalTransformationDirty) {
|
||||
this._updateLocalTransformation();
|
||||
}
|
||||
return this._localTransformation;
|
||||
}
|
||||
|
||||
// Scale
|
||||
getLocalInverseTransformation(): gdjs.AffineTransformation {
|
||||
if (this._isLocalTransformationDirty) {
|
||||
this._updateLocalTransformation();
|
||||
}
|
||||
return this._localInverseTransformation;
|
||||
}
|
||||
|
||||
_updateLocalTransformation() {
|
||||
const absScaleX = Math.abs(this._scaleX);
|
||||
const absScaleY = Math.abs(this._scaleY);
|
||||
x *= absScaleX;
|
||||
y *= absScaleY;
|
||||
cx *= absScaleX;
|
||||
cy *= absScaleY;
|
||||
const centerX = this.getUnscaledCenterX() * absScaleX;
|
||||
const centerY = this.getUnscaledCenterY() * absScaleY;
|
||||
const angleInRadians = (this.angle * Math.PI) / 180;
|
||||
|
||||
// Rotation
|
||||
const angleInRadians = (this.angle / 180) * Math.PI;
|
||||
const cosValue = Math.cos(angleInRadians);
|
||||
const sinValue = Math.sin(angleInRadians);
|
||||
const xToCenterXDelta = x - cx;
|
||||
const yToCenterYDelta = y - cy;
|
||||
x = cx + cosValue * xToCenterXDelta - sinValue * yToCenterYDelta;
|
||||
y = cy + sinValue * xToCenterXDelta + cosValue * yToCenterYDelta;
|
||||
result.length = 2;
|
||||
result[0] = x + this.x;
|
||||
result[1] = y + this.y;
|
||||
this._localTransformation.setToTranslation(this.x, this.y);
|
||||
this._localTransformation.rotateAround(angleInRadians, centerX, centerY);
|
||||
if (this._flippedX) {
|
||||
this._localTransformation.flipX(centerX);
|
||||
}
|
||||
if (this._flippedY) {
|
||||
this._localTransformation.flipY(centerY);
|
||||
}
|
||||
this._localTransformation.scale(absScaleX, absScaleY);
|
||||
|
||||
this._localInverseTransformation.copyFrom(this._localTransformation);
|
||||
this._localInverseTransformation.invert();
|
||||
this._isLocalTransformationDirty = false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -290,53 +290,51 @@ namespace gdjs {
|
||||
* @param result Array that will be updated with the result
|
||||
* (x and y position of the point in object coordinates).
|
||||
*/
|
||||
applyObjectInverseTransformation(x: float, y: float, result: number[]) {
|
||||
x -= this.getCenterXInScene();
|
||||
y -= this.getCenterYInScene();
|
||||
|
||||
const absScaleX = Math.abs(this._scaleX);
|
||||
const absScaleY = Math.abs(this._scaleY);
|
||||
|
||||
// Rotation
|
||||
const angleInRadians = (this.angle / 180) * Math.PI;
|
||||
const cosValue = Math.cos(-angleInRadians);
|
||||
const sinValue = Math.sin(-angleInRadians);
|
||||
const oldX = x;
|
||||
x = cosValue * x - sinValue * y;
|
||||
y = sinValue * oldX + cosValue * y;
|
||||
|
||||
// Scale
|
||||
x /= absScaleX;
|
||||
y /= absScaleY;
|
||||
|
||||
// Flipping
|
||||
if (this._flippedX) {
|
||||
x = -x;
|
||||
}
|
||||
if (this._flippedY) {
|
||||
y = -y;
|
||||
}
|
||||
|
||||
const positionToCenterX =
|
||||
this.getUnscaledWidth() / 2 + this._unrotatedAABB.min[0];
|
||||
const positionToCenterY =
|
||||
this.getUnscaledHeight() / 2 + this._unrotatedAABB.min[1];
|
||||
result[0] = x + positionToCenterX;
|
||||
result[1] = y + positionToCenterY;
|
||||
applyObjectInverseTransformation(
|
||||
x: float,
|
||||
y: float,
|
||||
destination: FloatPoint
|
||||
) {
|
||||
const source = destination;
|
||||
source[0] = x;
|
||||
source[1] = y;
|
||||
this.getLocalInverseTransformation().transform(source, destination);
|
||||
}
|
||||
|
||||
getDrawableX(): float {
|
||||
if (this._isUntransformedHitBoxesDirty) {
|
||||
this._updateUntransformedHitBoxes();
|
||||
}
|
||||
return this.x + this._unrotatedAABB.min[0] * this._scaleX;
|
||||
const absScaleX = this.getScaleX();
|
||||
if (!this._flippedX) {
|
||||
return this.x + this._unrotatedAABB.min[0] * absScaleX;
|
||||
} else {
|
||||
return (
|
||||
this.x +
|
||||
(-this._unrotatedAABB.min[0] -
|
||||
this.getUnscaledWidth() +
|
||||
2 * this.getUnscaledCenterX()) *
|
||||
absScaleX
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
getDrawableY(): float {
|
||||
if (this._isUntransformedHitBoxesDirty) {
|
||||
this._updateUntransformedHitBoxes();
|
||||
}
|
||||
return this.y + this._unrotatedAABB.min[1] * this._scaleY;
|
||||
const absScaleY = this.getScaleY();
|
||||
if (!this._flippedY) {
|
||||
return this.y + this._unrotatedAABB.min[1] * absScaleY;
|
||||
} else {
|
||||
return (
|
||||
this.y +
|
||||
(-this._unrotatedAABB.min[1] -
|
||||
this.getUnscaledHeight() +
|
||||
2 * this.getUnscaledCenterY()) *
|
||||
absScaleY
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -363,6 +361,9 @@ namespace gdjs {
|
||||
* @returns the center X from the local origin (0;0).
|
||||
*/
|
||||
getUnscaledCenterX(): float {
|
||||
if (this._customCenter) {
|
||||
return this._customCenter[0];
|
||||
}
|
||||
if (this._isUntransformedHitBoxesDirty) {
|
||||
this._updateUntransformedHitBoxes();
|
||||
}
|
||||
@@ -373,12 +374,57 @@ namespace gdjs {
|
||||
* @returns the center Y from the local origin (0;0).
|
||||
*/
|
||||
getUnscaledCenterY(): float {
|
||||
if (this._customCenter) {
|
||||
return this._customCenter[1];
|
||||
}
|
||||
if (this._isUntransformedHitBoxesDirty) {
|
||||
this._updateUntransformedHitBoxes();
|
||||
}
|
||||
return (this._unrotatedAABB.min[1] + this._unrotatedAABB.max[1]) / 2;
|
||||
}
|
||||
|
||||
/**
|
||||
* The center of rotation is defined relatively to the origin (the object
|
||||
* position).
|
||||
* This avoids the center to move when children push the bounds.
|
||||
*
|
||||
* When no custom center is defined, it will move
|
||||
* to stay at the center of the children bounds.
|
||||
*
|
||||
* @param x coordinate of the custom center
|
||||
* @param y coordinate of the custom center
|
||||
*/
|
||||
setRotationCenter(x: float, y: float) {
|
||||
if (!this._customCenter) {
|
||||
this._customCenter = [0, 0];
|
||||
}
|
||||
this._customCenter[0] = x;
|
||||
this._customCenter[1] = y;
|
||||
|
||||
this._isLocalTransformationDirty = true;
|
||||
this.invalidateHitboxes();
|
||||
}
|
||||
|
||||
getCenterX(): float {
|
||||
if (this._isUntransformedHitBoxesDirty) {
|
||||
this._updateUntransformedHitBoxes();
|
||||
}
|
||||
return (
|
||||
(this.getUnscaledCenterX() - this._unrotatedAABB.min[0]) *
|
||||
this.getScaleX()
|
||||
);
|
||||
}
|
||||
|
||||
getCenterY(): float {
|
||||
if (this._isUntransformedHitBoxesDirty) {
|
||||
this._updateUntransformedHitBoxes();
|
||||
}
|
||||
return (
|
||||
(this.getUnscaledCenterY() - this._unrotatedAABB.min[1]) *
|
||||
this.getScaleY()
|
||||
);
|
||||
}
|
||||
|
||||
getWidth(): float {
|
||||
return this.getUnscaledWidth() * this.getScaleX();
|
||||
}
|
||||
@@ -417,6 +463,7 @@ namespace gdjs {
|
||||
return;
|
||||
}
|
||||
this.x = x;
|
||||
this._isLocalTransformationDirty = true;
|
||||
this.invalidateHitboxes();
|
||||
this.getRenderer().updateX();
|
||||
}
|
||||
@@ -426,6 +473,7 @@ namespace gdjs {
|
||||
return;
|
||||
}
|
||||
this.y = y;
|
||||
this._isLocalTransformationDirty = true;
|
||||
this.invalidateHitboxes();
|
||||
this.getRenderer().updateY();
|
||||
}
|
||||
@@ -435,6 +483,7 @@ namespace gdjs {
|
||||
return;
|
||||
}
|
||||
this.angle = angle;
|
||||
this._isLocalTransformationDirty = true;
|
||||
this.invalidateHitboxes();
|
||||
this.getRenderer().updateAngle();
|
||||
}
|
||||
@@ -456,6 +505,7 @@ namespace gdjs {
|
||||
}
|
||||
this._scaleX = newScale * (this._flippedX ? -1 : 1);
|
||||
this._scaleY = newScale * (this._flippedY ? -1 : 1);
|
||||
this._isLocalTransformationDirty = true;
|
||||
this.invalidateHitboxes();
|
||||
this.getRenderer().update();
|
||||
}
|
||||
@@ -473,6 +523,7 @@ namespace gdjs {
|
||||
return;
|
||||
}
|
||||
this._scaleX = newScale * (this._flippedX ? -1 : 1);
|
||||
this._isLocalTransformationDirty = true;
|
||||
this.invalidateHitboxes();
|
||||
this.getRenderer().update();
|
||||
}
|
||||
|
@@ -43,6 +43,13 @@ namespace gdjs {
|
||||
this._debuggerRenderer = new gdjs.DebuggerRenderer(this);
|
||||
}
|
||||
|
||||
addLayer(layerData: LayerData) {
|
||||
this._layers.put(
|
||||
layerData.name,
|
||||
new gdjs.RuntimeCustomObjectLayer(layerData, this)
|
||||
);
|
||||
}
|
||||
|
||||
createObject(objectName: string): gdjs.RuntimeObject | null {
|
||||
const result = super.createObject(objectName);
|
||||
this._customObject.onChildrenLocationChanged();
|
||||
@@ -293,21 +300,6 @@ namespace gdjs {
|
||||
this._customObject.onChildrenLocationChanged();
|
||||
}
|
||||
|
||||
/**
|
||||
* Triggered when the object dimensions are changed.
|
||||
*
|
||||
* It adapts the layers camera positions.
|
||||
*/
|
||||
onObjectUnscaledCenterChanged(oldOriginX: float, oldOriginY: float): void {
|
||||
for (const name in this._layers.items) {
|
||||
if (this._layers.items.hasOwnProperty(name)) {
|
||||
/** @type gdjs.Layer */
|
||||
const theLayer: gdjs.Layer = this._layers.items[name];
|
||||
theLayer.onGameResolutionResized(oldOriginX, oldOriginY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
convertCoords(x: float, y: float, result: FloatPoint): FloatPoint {
|
||||
// The result parameter used to be optional.
|
||||
let position = result || [0, 0];
|
||||
|
104
GDJS/Runtime/RuntimeCustomObjectLayer.ts
Normal file
104
GDJS/Runtime/RuntimeCustomObjectLayer.ts
Normal file
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* GDevelop JS Platform
|
||||
* Copyright 2013-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
|
||||
* This project is released under the MIT License.
|
||||
*/
|
||||
namespace gdjs {
|
||||
/**
|
||||
* Represents a layer of a custom object. It doesn't allow to move any camera
|
||||
* because it doesn't make sense inside an object.
|
||||
*/
|
||||
export class RuntimeCustomObjectLayer extends gdjs.RuntimeLayer {
|
||||
/**
|
||||
* @param layerData The data used to initialize the layer
|
||||
* @param instanceContainer The container in which the layer is used
|
||||
*/
|
||||
constructor(
|
||||
layerData: LayerData,
|
||||
instanceContainer: gdjs.RuntimeInstanceContainer
|
||||
) {
|
||||
super(layerData, instanceContainer);
|
||||
}
|
||||
|
||||
onGameResolutionResized(
|
||||
oldGameResolutionOriginX: float,
|
||||
oldGameResolutionOriginY: float
|
||||
): void {}
|
||||
|
||||
getCameraX(cameraId?: integer): float {
|
||||
return 0;
|
||||
}
|
||||
|
||||
getCameraY(cameraId?: integer): float {
|
||||
return 0;
|
||||
}
|
||||
|
||||
setCameraX(x: float, cameraId?: integer): void {}
|
||||
|
||||
setCameraY(y: float, cameraId?: integer): void {}
|
||||
|
||||
getCameraWidth(cameraId?: integer): float {
|
||||
return 0;
|
||||
}
|
||||
|
||||
getCameraHeight(cameraId?: integer): float {
|
||||
return 0;
|
||||
}
|
||||
|
||||
setCameraZoom(newZoom: float, cameraId?: integer): void {}
|
||||
|
||||
getCameraZoom(cameraId?: integer): float {
|
||||
return 0;
|
||||
}
|
||||
|
||||
getCameraRotation(cameraId?: integer): float {
|
||||
return 0;
|
||||
}
|
||||
|
||||
setCameraRotation(rotation: float, cameraId?: integer): void {}
|
||||
|
||||
convertCoords(
|
||||
x: float,
|
||||
y: float,
|
||||
cameraId: integer,
|
||||
result: FloatPoint
|
||||
): FloatPoint {
|
||||
// TODO EBO use an AffineTransformation to avoid chained calls.
|
||||
// The result parameter used to be optional.
|
||||
return this._runtimeScene.convertCoords(x, y, result || [0, 0]);
|
||||
}
|
||||
|
||||
convertInverseCoords(
|
||||
x: float,
|
||||
y: float,
|
||||
cameraId: integer,
|
||||
result: FloatPoint
|
||||
): FloatPoint {
|
||||
// TODO EBO use an AffineTransformation to avoid chained calls.
|
||||
// The result parameter used to be optional.
|
||||
return this._runtimeScene.convertInverseCoords(x, y, result || [0, 0]);
|
||||
}
|
||||
|
||||
applyLayerInverseTransformation(
|
||||
x: float,
|
||||
y: float,
|
||||
cameraId: integer,
|
||||
result: FloatPoint
|
||||
): FloatPoint {
|
||||
result[0] = x;
|
||||
result[1] = y;
|
||||
return result;
|
||||
}
|
||||
|
||||
applyLayerTransformation(
|
||||
x: float,
|
||||
y: float,
|
||||
cameraId: integer,
|
||||
result: FloatPoint
|
||||
): FloatPoint {
|
||||
result[0] = x;
|
||||
result[1] = y;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
@@ -32,7 +32,7 @@ namespace gdjs {
|
||||
_objects: Hashtable<ObjectData>;
|
||||
_objectsCtor: Hashtable<typeof RuntimeObject>;
|
||||
|
||||
_layers: Hashtable<Layer>;
|
||||
_layers: Hashtable<RuntimeLayer>;
|
||||
_layersCameraCoordinates: Record<string, [float, float, float, float]> = {};
|
||||
|
||||
// Options for the debug draw:
|
||||
@@ -601,7 +601,7 @@ namespace gdjs {
|
||||
* @param name The name of the layer
|
||||
* @returns The layer, or the base layer if not found
|
||||
*/
|
||||
getLayer(name: string): gdjs.Layer {
|
||||
getLayer(name: string): gdjs.RuntimeLayer {
|
||||
if (this._layers.containsKey(name)) {
|
||||
return this._layers.get(name);
|
||||
}
|
||||
@@ -620,9 +620,7 @@ namespace gdjs {
|
||||
* Add a layer.
|
||||
* @param layerData The data to construct the layer
|
||||
*/
|
||||
addLayer(layerData: LayerData) {
|
||||
this._layers.put(layerData.name, new gdjs.Layer(layerData, this));
|
||||
}
|
||||
abstract addLayer(layerData: LayerData);
|
||||
|
||||
/**
|
||||
* Remove a layer. All {@link gdjs.RuntimeObject} on this layer will
|
||||
@@ -647,7 +645,7 @@ namespace gdjs {
|
||||
* @param index The new position in the list of layers
|
||||
*/
|
||||
setLayerIndex(layerName: string, index: integer): void {
|
||||
const layer: gdjs.Layer = this._layers.get(layerName);
|
||||
const layer: gdjs.RuntimeLayer = this._layers.get(layerName);
|
||||
if (!layer) {
|
||||
return;
|
||||
}
|
||||
|
490
GDJS/Runtime/RuntimeLayer.ts
Normal file
490
GDJS/Runtime/RuntimeLayer.ts
Normal file
@@ -0,0 +1,490 @@
|
||||
/*
|
||||
* GDevelop JS Platform
|
||||
* Copyright 2013-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
|
||||
* This project is released under the MIT License.
|
||||
*/
|
||||
namespace gdjs {
|
||||
/**
|
||||
* Represents a layer of a container, used to display objects.
|
||||
*
|
||||
* Viewports and multiple cameras are not supported.
|
||||
*/
|
||||
export abstract class RuntimeLayer implements EffectsTarget {
|
||||
_name: string;
|
||||
_timeScale: float = 1;
|
||||
_defaultZOrder: integer = 0;
|
||||
_hidden: boolean;
|
||||
_initialEffectsData: Array<EffectData>;
|
||||
|
||||
_runtimeScene: gdjs.RuntimeInstanceContainer;
|
||||
_effectsManager: gdjs.EffectsManager;
|
||||
|
||||
// Lighting layer properties.
|
||||
_isLightingLayer: boolean;
|
||||
_followBaseLayerCamera: boolean;
|
||||
_clearColor: Array<integer>;
|
||||
|
||||
_rendererEffects: Record<string, PixiFiltersTools.Filter> = {};
|
||||
_renderer: gdjs.LayerRenderer;
|
||||
|
||||
/**
|
||||
* @param layerData The data used to initialize the layer
|
||||
* @param instanceContainer The container in which the layer is used
|
||||
*/
|
||||
constructor(
|
||||
layerData: LayerData,
|
||||
instanceContainer: gdjs.RuntimeInstanceContainer
|
||||
) {
|
||||
this._name = layerData.name;
|
||||
this._hidden = !layerData.visibility;
|
||||
this._initialEffectsData = layerData.effects || [];
|
||||
this._runtimeScene = instanceContainer;
|
||||
this._effectsManager = instanceContainer.getGame().getEffectsManager();
|
||||
this._isLightingLayer = layerData.isLightingLayer;
|
||||
this._followBaseLayerCamera = layerData.followBaseLayerCamera;
|
||||
this._clearColor = [
|
||||
layerData.ambientLightColorR / 255,
|
||||
layerData.ambientLightColorG / 255,
|
||||
layerData.ambientLightColorB / 255,
|
||||
1.0,
|
||||
];
|
||||
this._renderer = new gdjs.LayerRenderer(
|
||||
this,
|
||||
instanceContainer.getRenderer(),
|
||||
instanceContainer.getGame().getRenderer().getPIXIRenderer()
|
||||
);
|
||||
this.show(!this._hidden);
|
||||
for (let i = 0; i < layerData.effects.length; ++i) {
|
||||
this.addEffect(layerData.effects[i]);
|
||||
}
|
||||
}
|
||||
|
||||
getRenderer(): gdjs.LayerRenderer {
|
||||
return this._renderer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default Z order to be attributed to objects created on this layer
|
||||
* (usually from events generated code).
|
||||
*/
|
||||
getDefaultZOrder(): float {
|
||||
return this._defaultZOrder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the default Z order to be attributed to objects created on this layer.
|
||||
* @param defaultZOrder The Z order to use when creating a new object from events.
|
||||
*/
|
||||
setDefaultZOrder(defaultZOrder: integer): void {
|
||||
this._defaultZOrder = defaultZOrder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by the RuntimeScene whenever the game resolution size is changed.
|
||||
* Updates the layer width/height and position.
|
||||
*/
|
||||
abstract onGameResolutionResized(
|
||||
oldGameResolutionOriginX: float,
|
||||
oldGameResolutionOriginY: float
|
||||
): void;
|
||||
|
||||
/**
|
||||
* Returns the scene the layer belongs to directly or indirectly
|
||||
* @returns the scene the layer belongs to directly or indirectly
|
||||
*/
|
||||
getRuntimeScene(): gdjs.RuntimeScene {
|
||||
return this._runtimeScene.getScene();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called at each frame, after events are run and before rendering.
|
||||
*/
|
||||
updatePreRender(instanceContainer?: gdjs.RuntimeInstanceContainer): void {
|
||||
if (this._followBaseLayerCamera) {
|
||||
this.followBaseLayer();
|
||||
}
|
||||
this._renderer.updatePreRender();
|
||||
this._effectsManager.updatePreRender(this._rendererEffects, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the layer
|
||||
* @return The name of the layer
|
||||
*/
|
||||
getName(): string {
|
||||
return this._name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the camera center X position.
|
||||
*
|
||||
* @param cameraId The camera number. Currently ignored.
|
||||
* @return The x position of the camera
|
||||
*/
|
||||
abstract getCameraX(cameraId?: integer): float;
|
||||
|
||||
/**
|
||||
* Change the camera center Y position.
|
||||
*
|
||||
* @param cameraId The camera number. Currently ignored.
|
||||
* @return The y position of the camera
|
||||
*/
|
||||
abstract getCameraY(cameraId?: integer): float;
|
||||
|
||||
/**
|
||||
* Set the camera center X position.
|
||||
*
|
||||
* @param x The new x position
|
||||
* @param cameraId The camera number. Currently ignored.
|
||||
*/
|
||||
abstract setCameraX(x: float, cameraId?: integer): void;
|
||||
|
||||
/**
|
||||
* Set the camera center Y position.
|
||||
*
|
||||
* @param y The new y position
|
||||
* @param cameraId The camera number. Currently ignored.
|
||||
*/
|
||||
abstract setCameraY(y: float, cameraId?: integer): void;
|
||||
|
||||
/**
|
||||
* Get the camera width (which can be different than the game resolution width
|
||||
* if the camera is zoomed).
|
||||
*
|
||||
* @param cameraId The camera number. Currently ignored.
|
||||
* @return The width of the camera
|
||||
*/
|
||||
abstract getCameraWidth(cameraId?: integer): float;
|
||||
|
||||
/**
|
||||
* Get the camera height (which can be different than the game resolution height
|
||||
* if the camera is zoomed).
|
||||
*
|
||||
* @param cameraId The camera number. Currently ignored.
|
||||
* @return The height of the camera
|
||||
*/
|
||||
abstract getCameraHeight(cameraId?: integer): float;
|
||||
|
||||
/**
|
||||
* Show (or hide) the layer.
|
||||
* @param enable true to show the layer, false to hide it.
|
||||
*/
|
||||
show(enable: boolean): void {
|
||||
this._hidden = !enable;
|
||||
this._renderer.updateVisibility(enable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the layer is visible.
|
||||
*
|
||||
* @return true if the layer is visible.
|
||||
*/
|
||||
isVisible(): boolean {
|
||||
return !this._hidden;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the zoom of a camera.
|
||||
*
|
||||
* @param newZoom The new zoom. Must be superior to 0. 1 is the default zoom.
|
||||
* @param cameraId The camera number. Currently ignored.
|
||||
*/
|
||||
abstract setCameraZoom(newZoom: float, cameraId?: integer): void;
|
||||
|
||||
/**
|
||||
* Get the zoom of a camera.
|
||||
*
|
||||
* @param cameraId The camera number. Currently ignored.
|
||||
* @return The zoom.
|
||||
*/
|
||||
abstract getCameraZoom(cameraId?: integer): float;
|
||||
|
||||
/**
|
||||
* Get the rotation of the camera, expressed in degrees.
|
||||
*
|
||||
* @param cameraId The camera number. Currently ignored.
|
||||
* @return The rotation, in degrees.
|
||||
*/
|
||||
abstract getCameraRotation(cameraId?: integer): float;
|
||||
|
||||
/**
|
||||
* Set the rotation of the camera, expressed in degrees.
|
||||
* The rotation is made around the camera center.
|
||||
*
|
||||
* @param rotation The new rotation, in degrees.
|
||||
* @param cameraId The camera number. Currently ignored.
|
||||
*/
|
||||
abstract setCameraRotation(rotation: float, cameraId?: integer): void;
|
||||
|
||||
/**
|
||||
* Convert a point from the canvas coordinates (for example,
|
||||
* the mouse position) to the container coordinates.
|
||||
*
|
||||
* @param x The x position, in canvas coordinates.
|
||||
* @param y The y position, in canvas coordinates.
|
||||
* @param cameraId The camera number. Currently ignored.
|
||||
* @param result The point instance that is used to return the result.
|
||||
*/
|
||||
abstract convertCoords(
|
||||
x: float,
|
||||
y: float,
|
||||
cameraId: integer,
|
||||
result: FloatPoint
|
||||
): FloatPoint;
|
||||
|
||||
/**
|
||||
* Return an array containing the coordinates of the point passed as parameter
|
||||
* in parent coordinate coordinates (as opposed to the layer local coordinates).
|
||||
*
|
||||
* All transformations (scale, rotation) are supported.
|
||||
*
|
||||
* @param x The X position of the point, in layer coordinates.
|
||||
* @param y The Y position of the point, in layer coordinates.
|
||||
* @param result Array that will be updated with the result
|
||||
* (x and y position of the point in parent coordinates).
|
||||
*/
|
||||
abstract applyLayerTransformation(
|
||||
x: float,
|
||||
y: float,
|
||||
cameraId: integer,
|
||||
result: FloatPoint
|
||||
): FloatPoint;
|
||||
|
||||
/**
|
||||
* Convert a point from the container coordinates (for example,
|
||||
* an object position) to the canvas coordinates.
|
||||
*
|
||||
* @param x The x position, in container coordinates.
|
||||
* @param y The y position, in container coordinates.
|
||||
* @param cameraId The camera number. Currently ignored.
|
||||
* @param result The point instance that is used to return the result.
|
||||
*/
|
||||
abstract convertInverseCoords(
|
||||
x: float,
|
||||
y: float,
|
||||
cameraId: integer,
|
||||
result: FloatPoint
|
||||
): FloatPoint;
|
||||
|
||||
/**
|
||||
* Return an array containing the coordinates of the point passed as parameter
|
||||
* in layer local coordinates (as opposed to the parent coordinates).
|
||||
*
|
||||
* All transformations (scale, rotation) are supported.
|
||||
*
|
||||
* @param x The X position of the point, in parent coordinates.
|
||||
* @param y The Y position of the point, in parent coordinates.
|
||||
* @param result Array that will be updated with the result
|
||||
* @param result The point instance that is used to return the result.
|
||||
* (x and y position of the point in layer coordinates).
|
||||
*/
|
||||
abstract applyLayerInverseTransformation(
|
||||
x: float,
|
||||
y: float,
|
||||
cameraId: integer,
|
||||
result: FloatPoint
|
||||
): FloatPoint;
|
||||
|
||||
getWidth(): float {
|
||||
return this._runtimeScene.getViewportWidth();
|
||||
}
|
||||
|
||||
getHeight(): float {
|
||||
return this._runtimeScene.getViewportHeight();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the initial effects data for the layer. Only to
|
||||
* be used by renderers.
|
||||
* @deprecated
|
||||
*/
|
||||
getInitialEffectsData(): EffectData[] {
|
||||
return this._initialEffectsData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new effect, or replace the one with the same name.
|
||||
* @param effectData The data of the effect to add.
|
||||
*/
|
||||
addEffect(effectData: EffectData): void {
|
||||
this._effectsManager.addEffect(
|
||||
effectData,
|
||||
this._rendererEffects,
|
||||
this._renderer.getRendererObject(),
|
||||
this
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the effect with the specified name
|
||||
* @param effectName The name of the effect.
|
||||
*/
|
||||
removeEffect(effectName: string): void {
|
||||
this._effectsManager.removeEffect(
|
||||
this._rendererEffects,
|
||||
this._renderer.getRendererObject(),
|
||||
effectName
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change an effect parameter value (for parameters that are numbers).
|
||||
* @param name The name of the effect to update.
|
||||
* @param parameterName The name of the parameter to update.
|
||||
* @param value The new value (number).
|
||||
*/
|
||||
setEffectDoubleParameter(
|
||||
name: string,
|
||||
parameterName: string,
|
||||
value: float
|
||||
): void {
|
||||
this._effectsManager.setEffectDoubleParameter(
|
||||
this._rendererEffects,
|
||||
name,
|
||||
parameterName,
|
||||
value
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change an effect parameter value (for parameters that are strings).
|
||||
* @param name The name of the effect to update.
|
||||
* @param parameterName The name of the parameter to update.
|
||||
* @param value The new value (string).
|
||||
*/
|
||||
setEffectStringParameter(
|
||||
name: string,
|
||||
parameterName: string,
|
||||
value: string
|
||||
): void {
|
||||
this._effectsManager.setEffectStringParameter(
|
||||
this._rendererEffects,
|
||||
name,
|
||||
parameterName,
|
||||
value
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change an effect parameter value (for parameters that are booleans).
|
||||
* @param name The name of the effect to update.
|
||||
* @param parameterName The name of the parameter to update.
|
||||
* @param value The new value (boolean).
|
||||
*/
|
||||
setEffectBooleanParameter(
|
||||
name: string,
|
||||
parameterName: string,
|
||||
value: boolean
|
||||
): void {
|
||||
this._effectsManager.setEffectBooleanParameter(
|
||||
this._rendererEffects,
|
||||
name,
|
||||
parameterName,
|
||||
value
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable or disable an effect.
|
||||
* @param name The name of the effect to enable or disable.
|
||||
* @param enable true to enable, false to disable
|
||||
*/
|
||||
enableEffect(name: string, enable: boolean): void {
|
||||
this._effectsManager.enableEffect(this._rendererEffects, name, enable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if an effect is enabled
|
||||
* @param name The name of the effect
|
||||
* @return true if the effect is enabled, false otherwise.
|
||||
*/
|
||||
isEffectEnabled(name: string): boolean {
|
||||
return this._effectsManager.isEffectEnabled(this._rendererEffects, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if an effect exists on this layer
|
||||
* @param name The name of the effect
|
||||
* @return true if the effect exists, false otherwise.
|
||||
*/
|
||||
hasEffect(name: string): boolean {
|
||||
return this._effectsManager.hasEffect(this._rendererEffects, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the time scale for the objects on the layer:
|
||||
* time will be slower if time scale is < 1, faster if > 1.
|
||||
* @param timeScale The new time scale (must be positive).
|
||||
*/
|
||||
setTimeScale(timeScale: float): void {
|
||||
if (timeScale >= 0) {
|
||||
this._timeScale = timeScale;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the time scale for the objects on the layer.
|
||||
*/
|
||||
getTimeScale(): float {
|
||||
return this._timeScale;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the time elapsed since the last frame,
|
||||
* in milliseconds, for objects on the layer.
|
||||
*
|
||||
* @param instanceContainer The instance container the layer belongs to (deprecated - can be omitted).
|
||||
*/
|
||||
getElapsedTime(instanceContainer?: gdjs.RuntimeInstanceContainer): float {
|
||||
const container = instanceContainer || this._runtimeScene;
|
||||
return container.getElapsedTime() * this._timeScale;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the position, rotation and scale (zoom) of the layer camera to be the same as the base layer camera.
|
||||
*/
|
||||
followBaseLayer(): void {
|
||||
const baseLayer = this._runtimeScene.getLayer('');
|
||||
this.setCameraX(baseLayer.getCameraX());
|
||||
this.setCameraY(baseLayer.getCameraY());
|
||||
this.setCameraRotation(baseLayer.getCameraRotation());
|
||||
this.setCameraZoom(baseLayer.getCameraZoom());
|
||||
}
|
||||
|
||||
/**
|
||||
* The clear color is defined in the format [r, g, b], with components in the range of 0 to 1.
|
||||
* @return the clear color of layer in the range of [0, 1].
|
||||
*/
|
||||
getClearColor(): Array<integer> {
|
||||
return this._clearColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the clear color in format [r, g, b], with components in the range of 0 to 1.;
|
||||
* @param r Red color component in the range 0-255.
|
||||
* @param g Green color component in the range 0-255.
|
||||
* @param b Blue color component in the range 0-255.
|
||||
*/
|
||||
setClearColor(r: integer, g: integer, b: integer): void {
|
||||
this._clearColor[0] = r / 255;
|
||||
this._clearColor[1] = g / 255;
|
||||
this._clearColor[2] = b / 255;
|
||||
this._renderer.updateClearColor();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether layer's camera follows base layer's camera or not.
|
||||
*/
|
||||
setFollowBaseLayerCamera(follow: boolean): void {
|
||||
this._followBaseLayerCamera = follow;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the layer is a lighting layer, false otherwise.
|
||||
* @return true if it is a lighting layer, false otherwise.
|
||||
*/
|
||||
isLightingLayer(): boolean {
|
||||
return this._isLightingLayer;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,74 +0,0 @@
|
||||
/*
|
||||
* GDevelop JS Platform
|
||||
* Copyright 2013-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
|
||||
* This project is released under the MIT License.
|
||||
*/
|
||||
namespace gdjs {
|
||||
/**
|
||||
* Represents a layer of a scene, used to display objects.
|
||||
*
|
||||
* Viewports and multiple cameras are not supported.
|
||||
*
|
||||
* It does some optimizations but works exactly the same as
|
||||
* {@link gdjs.Layer}.
|
||||
*/
|
||||
export class RuntimeSceneLayer extends gdjs.Layer {
|
||||
/**
|
||||
* @param layerData The data used to initialize the layer
|
||||
* @param scene The scene in which the layer is used
|
||||
*/
|
||||
constructor(layerData: LayerData, scene: gdjs.RuntimeScene) {
|
||||
super(layerData, scene);
|
||||
}
|
||||
|
||||
convertCoords(
|
||||
x: float,
|
||||
y: float,
|
||||
cameraId: integer = 0,
|
||||
result: FloatPoint
|
||||
): FloatPoint {
|
||||
// The result parameter used to be optional.
|
||||
let position = result || [0, 0];
|
||||
x -= this.getRuntimeScene()._cachedGameResolutionWidth / 2;
|
||||
y -= this.getRuntimeScene()._cachedGameResolutionHeight / 2;
|
||||
x /= Math.abs(this._zoomFactor);
|
||||
y /= Math.abs(this._zoomFactor);
|
||||
|
||||
// Only compute angle and cos/sin once (allow heavy optimization from JS engines).
|
||||
const angleInRadians = (this._cameraRotation / 180) * Math.PI;
|
||||
const tmp = x;
|
||||
const cosValue = Math.cos(angleInRadians);
|
||||
const sinValue = Math.sin(angleInRadians);
|
||||
x = cosValue * x - sinValue * y;
|
||||
y = sinValue * tmp + cosValue * y;
|
||||
position[0] = x + this.getCameraX(cameraId);
|
||||
position[1] = y + this.getCameraY(cameraId);
|
||||
return position;
|
||||
}
|
||||
|
||||
convertInverseCoords(
|
||||
x: float,
|
||||
y: float,
|
||||
cameraId: integer = 0,
|
||||
result: FloatPoint
|
||||
): FloatPoint {
|
||||
// The result parameter used to be optional.
|
||||
let position = result || [0, 0];
|
||||
x -= this.getCameraX(cameraId);
|
||||
y -= this.getCameraY(cameraId);
|
||||
|
||||
// Only compute angle and cos/sin once (allow heavy optimization from JS engines).
|
||||
const angleInRadians = (this._cameraRotation / 180) * Math.PI;
|
||||
const tmp = x;
|
||||
const cosValue = Math.cos(-angleInRadians);
|
||||
const sinValue = Math.sin(-angleInRadians);
|
||||
x = cosValue * x - sinValue * y;
|
||||
y = sinValue * tmp + cosValue * y;
|
||||
x *= Math.abs(this._zoomFactor);
|
||||
y *= Math.abs(this._zoomFactor);
|
||||
position[0] = x + this.getRuntimeScene()._cachedGameResolutionWidth / 2;
|
||||
position[1] = y + this.getRuntimeScene()._cachedGameResolutionHeight / 2;
|
||||
return position;
|
||||
}
|
||||
}
|
||||
}
|
@@ -339,6 +339,7 @@ namespace gdjs {
|
||||
// Avoid circular reference from behavior to parent runtimeObject
|
||||
// Exclude rendering related objects:
|
||||
'_renderer',
|
||||
'_gameRenderer',
|
||||
'_imageManager',
|
||||
// Exclude PIXI textures:
|
||||
'baseTexture',
|
||||
|
@@ -1037,7 +1037,7 @@ namespace gdjs {
|
||||
_hotReloadRuntimeLayer(
|
||||
oldLayer: LayerData,
|
||||
newLayer: LayerData,
|
||||
runtimeLayer: gdjs.Layer
|
||||
runtimeLayer: gdjs.RuntimeLayer
|
||||
): void {
|
||||
// Properties
|
||||
if (oldLayer.visibility !== newLayer.visibility) {
|
||||
@@ -1073,7 +1073,7 @@ namespace gdjs {
|
||||
_hotReloadRuntimeLayerEffects(
|
||||
oldEffectsData: EffectData[],
|
||||
newEffectsData: EffectData[],
|
||||
runtimeLayer: gdjs.Layer
|
||||
runtimeLayer: gdjs.RuntimeLayer
|
||||
): void {
|
||||
oldEffectsData.forEach((oldEffectData) => {
|
||||
const name = oldEffectData.name;
|
||||
@@ -1115,7 +1115,7 @@ namespace gdjs {
|
||||
_hotReloadRuntimeLayerEffect(
|
||||
oldEffectData: EffectData,
|
||||
newEffectData: EffectData,
|
||||
runtimeLayer: gdjs.Layer,
|
||||
runtimeLayer: gdjs.RuntimeLayer,
|
||||
effectName: string
|
||||
): void {
|
||||
// We consider oldEffectData.effectType and newEffectData.effectType
|
||||
|
@@ -170,6 +170,54 @@ namespace gdjs {
|
||||
): number {
|
||||
return variable.getChildrenCount();
|
||||
};
|
||||
|
||||
/**
|
||||
* Shortcut to get the first value of an array variable as a number.
|
||||
*/
|
||||
export const getFirstVariableNumber = function (
|
||||
array: gdjs.Variable
|
||||
): number {
|
||||
if (array.getChildrenCount() === 0) {
|
||||
return 0;
|
||||
}
|
||||
return array.getAllChildrenArray()[0].getAsNumber();
|
||||
};
|
||||
|
||||
/**
|
||||
* Shortcut to get the last value of an array variable as a string.
|
||||
*/
|
||||
export const getFirstVariableString = function (
|
||||
array: gdjs.Variable
|
||||
): string {
|
||||
if (array.getChildrenCount() === 0) {
|
||||
return '';
|
||||
}
|
||||
return array.getAllChildrenArray()[0].getAsString();
|
||||
};
|
||||
|
||||
/**
|
||||
* Shortcut to get the last value of an array variable as a number.
|
||||
*/
|
||||
export const getLastVariableNumber = function (
|
||||
array: gdjs.Variable
|
||||
): number {
|
||||
const children = array.getAllChildrenArray();
|
||||
return children.length === 0
|
||||
? 0
|
||||
: children[children.length - 1].getAsNumber();
|
||||
};
|
||||
|
||||
/**
|
||||
* Shortcut to get the last value of an array variable as a string.
|
||||
*/
|
||||
export const getLastVariableString = function (
|
||||
array: gdjs.Variable
|
||||
): string {
|
||||
const children = array.getAllChildrenArray();
|
||||
return children.length === 0
|
||||
? ''
|
||||
: children[children.length - 1].getAsString();
|
||||
};
|
||||
}
|
||||
|
||||
export namespace common {
|
||||
|
@@ -5,32 +5,16 @@
|
||||
*/
|
||||
namespace gdjs {
|
||||
/**
|
||||
* Represents a layer of a container, used to display objects.
|
||||
* Represents a layer of a scene, used to display objects.
|
||||
*
|
||||
* Viewports and multiple cameras are not supported.
|
||||
*/
|
||||
export class Layer implements EffectsTarget {
|
||||
_name: string;
|
||||
export class Layer extends gdjs.RuntimeLayer {
|
||||
_cameraRotation: float = 0;
|
||||
_zoomFactor: float = 1;
|
||||
_timeScale: float = 1;
|
||||
_defaultZOrder: integer = 0;
|
||||
_hidden: boolean;
|
||||
_initialEffectsData: Array<EffectData>;
|
||||
_cameraX: float;
|
||||
_cameraY: float;
|
||||
|
||||
_runtimeScene: gdjs.RuntimeInstanceContainer;
|
||||
_effectsManager: gdjs.EffectsManager;
|
||||
|
||||
// Lighting layer properties.
|
||||
_isLightingLayer: boolean;
|
||||
_followBaseLayerCamera: boolean;
|
||||
_clearColor: Array<integer>;
|
||||
|
||||
_rendererEffects: Record<string, PixiFiltersTools.Filter> = {};
|
||||
_renderer: gdjs.LayerRenderer;
|
||||
|
||||
/**
|
||||
* @param layerData The data used to initialize the layer
|
||||
* @param instanceContainer The container in which the layer is used
|
||||
@@ -39,50 +23,10 @@ namespace gdjs {
|
||||
layerData: LayerData,
|
||||
instanceContainer: gdjs.RuntimeInstanceContainer
|
||||
) {
|
||||
this._name = layerData.name;
|
||||
this._hidden = !layerData.visibility;
|
||||
this._initialEffectsData = layerData.effects || [];
|
||||
this._runtimeScene = instanceContainer;
|
||||
super(layerData, instanceContainer);
|
||||
|
||||
this._cameraX = this.getWidth() / 2;
|
||||
this._cameraY = this.getHeight() / 2;
|
||||
this._effectsManager = instanceContainer.getGame().getEffectsManager();
|
||||
this._isLightingLayer = layerData.isLightingLayer;
|
||||
this._followBaseLayerCamera = layerData.followBaseLayerCamera;
|
||||
this._clearColor = [
|
||||
layerData.ambientLightColorR / 255,
|
||||
layerData.ambientLightColorG / 255,
|
||||
layerData.ambientLightColorB / 255,
|
||||
1.0,
|
||||
];
|
||||
this._renderer = new gdjs.LayerRenderer(
|
||||
this,
|
||||
instanceContainer.getRenderer(),
|
||||
instanceContainer.getGame().getRenderer().getPIXIRenderer()
|
||||
);
|
||||
this.show(!this._hidden);
|
||||
for (let i = 0; i < layerData.effects.length; ++i) {
|
||||
this.addEffect(layerData.effects[i]);
|
||||
}
|
||||
}
|
||||
|
||||
getRenderer(): gdjs.LayerRenderer {
|
||||
return this._renderer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default Z order to be attributed to objects created on this layer
|
||||
* (usually from events generated code).
|
||||
*/
|
||||
getDefaultZOrder(): float {
|
||||
return this._defaultZOrder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the default Z order to be attributed to objects created on this layer.
|
||||
* @param defaultZOrder The Z order to use when creating a new object from events.
|
||||
*/
|
||||
setDefaultZOrder(defaultZOrder: integer): void {
|
||||
this._defaultZOrder = defaultZOrder;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -107,33 +51,6 @@ namespace gdjs {
|
||||
this._renderer.updatePosition();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the scene the layer belongs to directly or indirectly
|
||||
* @returns the scene the layer belongs to directly or indirectly
|
||||
*/
|
||||
getRuntimeScene(): gdjs.RuntimeScene {
|
||||
return this._runtimeScene.getScene();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called at each frame, after events are run and before rendering.
|
||||
*/
|
||||
updatePreRender(instanceContainer?: gdjs.RuntimeInstanceContainer): void {
|
||||
if (this._followBaseLayerCamera) {
|
||||
this.followBaseLayer();
|
||||
}
|
||||
this._renderer.updatePreRender();
|
||||
this._effectsManager.updatePreRender(this._rendererEffects, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the layer
|
||||
* @return The name of the layer
|
||||
*/
|
||||
getName(): string {
|
||||
return this._name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the camera center X position.
|
||||
*
|
||||
@@ -202,24 +119,6 @@ namespace gdjs {
|
||||
return this.getHeight() / this._zoomFactor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show (or hide) the layer.
|
||||
* @param enable true to show the layer, false to hide it.
|
||||
*/
|
||||
show(enable: boolean): void {
|
||||
this._hidden = !enable;
|
||||
this._renderer.updateVisibility(enable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the layer is visible.
|
||||
*
|
||||
* @return true if the layer is visible.
|
||||
*/
|
||||
isVisible(): boolean {
|
||||
return !this._hidden;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the zoom of a camera.
|
||||
*
|
||||
@@ -278,16 +177,25 @@ namespace gdjs {
|
||||
cameraId: integer = 0,
|
||||
result: FloatPoint
|
||||
): FloatPoint {
|
||||
// This code duplicates applyLayerInverseTransformation for performance reasons;
|
||||
|
||||
// The result parameter used to be optional.
|
||||
let position = result || [0, 0];
|
||||
// TODO EBO use an AffineTransformation to avoid chained calls.
|
||||
position = this._runtimeScene.convertCoords(x, y, position);
|
||||
return this.applyLayerInverseTransformation(
|
||||
position[0],
|
||||
position[1],
|
||||
cameraId,
|
||||
position
|
||||
);
|
||||
x -= this.getRuntimeScene()._cachedGameResolutionWidth / 2;
|
||||
y -= this.getRuntimeScene()._cachedGameResolutionHeight / 2;
|
||||
x /= Math.abs(this._zoomFactor);
|
||||
y /= Math.abs(this._zoomFactor);
|
||||
|
||||
// Only compute angle and cos/sin once (allow heavy optimization from JS engines).
|
||||
const angleInRadians = (this._cameraRotation / 180) * Math.PI;
|
||||
const tmp = x;
|
||||
const cosValue = Math.cos(angleInRadians);
|
||||
const sinValue = Math.sin(angleInRadians);
|
||||
x = cosValue * x - sinValue * y;
|
||||
y = sinValue * tmp + cosValue * y;
|
||||
position[0] = x + this.getCameraX(cameraId);
|
||||
position[1] = y + this.getCameraY(cameraId);
|
||||
return position;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -341,14 +249,25 @@ namespace gdjs {
|
||||
cameraId: integer = 0,
|
||||
result: FloatPoint
|
||||
): FloatPoint {
|
||||
// This code duplicates applyLayerTransformation for performance reasons;
|
||||
|
||||
// The result parameter used to be optional.
|
||||
let position = result || [0, 0];
|
||||
// TODO EBO use an AffineTransformation to avoid chained calls.
|
||||
this.applyLayerTransformation(x, y, cameraId, position);
|
||||
return this._runtimeScene.convertInverseCoords(
|
||||
position[0],
|
||||
position[1],
|
||||
position
|
||||
);
|
||||
x -= this.getCameraX(cameraId);
|
||||
y -= this.getCameraY(cameraId);
|
||||
|
||||
// Only compute angle and cos/sin once (allow heavy optimization from JS engines).
|
||||
const angleInRadians = (this._cameraRotation / 180) * Math.PI;
|
||||
const tmp = x;
|
||||
const cosValue = Math.cos(-angleInRadians);
|
||||
const sinValue = Math.sin(-angleInRadians);
|
||||
x = cosValue * x - sinValue * y;
|
||||
y = sinValue * tmp + cosValue * y;
|
||||
x *= Math.abs(this._zoomFactor);
|
||||
y *= Math.abs(this._zoomFactor);
|
||||
position[0] = x + this.getRuntimeScene()._cachedGameResolutionWidth / 2;
|
||||
position[1] = y + this.getRuntimeScene()._cachedGameResolutionHeight / 2;
|
||||
return position;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -388,14 +307,6 @@ namespace gdjs {
|
||||
return result;
|
||||
}
|
||||
|
||||
getWidth(): float {
|
||||
return this._runtimeScene.getViewportWidth();
|
||||
}
|
||||
|
||||
getHeight(): float {
|
||||
return this._runtimeScene.getViewportHeight();
|
||||
}
|
||||
|
||||
/**
|
||||
* This ensure that the viewport dimensions are up to date.
|
||||
*
|
||||
@@ -406,199 +317,5 @@ namespace gdjs {
|
||||
// This will update dimensions.
|
||||
this._runtimeScene.getViewportWidth();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the initial effects data for the layer. Only to
|
||||
* be used by renderers.
|
||||
* @deprecated
|
||||
*/
|
||||
getInitialEffectsData(): EffectData[] {
|
||||
return this._initialEffectsData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new effect, or replace the one with the same name.
|
||||
* @param effectData The data of the effect to add.
|
||||
*/
|
||||
addEffect(effectData: EffectData): void {
|
||||
this._effectsManager.addEffect(
|
||||
effectData,
|
||||
this._rendererEffects,
|
||||
this._renderer.getRendererObject(),
|
||||
this
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the effect with the specified name
|
||||
* @param effectName The name of the effect.
|
||||
*/
|
||||
removeEffect(effectName: string): void {
|
||||
this._effectsManager.removeEffect(
|
||||
this._rendererEffects,
|
||||
this._renderer.getRendererObject(),
|
||||
effectName
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change an effect parameter value (for parameters that are numbers).
|
||||
* @param name The name of the effect to update.
|
||||
* @param parameterName The name of the parameter to update.
|
||||
* @param value The new value (number).
|
||||
*/
|
||||
setEffectDoubleParameter(
|
||||
name: string,
|
||||
parameterName: string,
|
||||
value: float
|
||||
): void {
|
||||
this._effectsManager.setEffectDoubleParameter(
|
||||
this._rendererEffects,
|
||||
name,
|
||||
parameterName,
|
||||
value
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change an effect parameter value (for parameters that are strings).
|
||||
* @param name The name of the effect to update.
|
||||
* @param parameterName The name of the parameter to update.
|
||||
* @param value The new value (string).
|
||||
*/
|
||||
setEffectStringParameter(
|
||||
name: string,
|
||||
parameterName: string,
|
||||
value: string
|
||||
): void {
|
||||
this._effectsManager.setEffectStringParameter(
|
||||
this._rendererEffects,
|
||||
name,
|
||||
parameterName,
|
||||
value
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change an effect parameter value (for parameters that are booleans).
|
||||
* @param name The name of the effect to update.
|
||||
* @param parameterName The name of the parameter to update.
|
||||
* @param value The new value (boolean).
|
||||
*/
|
||||
setEffectBooleanParameter(
|
||||
name: string,
|
||||
parameterName: string,
|
||||
value: boolean
|
||||
): void {
|
||||
this._effectsManager.setEffectBooleanParameter(
|
||||
this._rendererEffects,
|
||||
name,
|
||||
parameterName,
|
||||
value
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable or disable an effect.
|
||||
* @param name The name of the effect to enable or disable.
|
||||
* @param enable true to enable, false to disable
|
||||
*/
|
||||
enableEffect(name: string, enable: boolean): void {
|
||||
this._effectsManager.enableEffect(this._rendererEffects, name, enable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if an effect is enabled
|
||||
* @param name The name of the effect
|
||||
* @return true if the effect is enabled, false otherwise.
|
||||
*/
|
||||
isEffectEnabled(name: string): boolean {
|
||||
return this._effectsManager.isEffectEnabled(this._rendererEffects, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if an effect exists on this layer
|
||||
* @param name The name of the effect
|
||||
* @return true if the effect exists, false otherwise.
|
||||
*/
|
||||
hasEffect(name: string): boolean {
|
||||
return this._effectsManager.hasEffect(this._rendererEffects, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the time scale for the objects on the layer:
|
||||
* time will be slower if time scale is < 1, faster if > 1.
|
||||
* @param timeScale The new time scale (must be positive).
|
||||
*/
|
||||
setTimeScale(timeScale: float): void {
|
||||
if (timeScale >= 0) {
|
||||
this._timeScale = timeScale;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the time scale for the objects on the layer.
|
||||
*/
|
||||
getTimeScale(): float {
|
||||
return this._timeScale;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the time elapsed since the last frame,
|
||||
* in milliseconds, for objects on the layer.
|
||||
*
|
||||
* @param instanceContainer The instance container the layer belongs to (deprecated - can be omitted).
|
||||
*/
|
||||
getElapsedTime(instanceContainer?: gdjs.RuntimeInstanceContainer): float {
|
||||
const container = instanceContainer || this._runtimeScene;
|
||||
return container.getElapsedTime() * this._timeScale;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the position, rotation and scale (zoom) of the layer camera to be the same as the base layer camera.
|
||||
*/
|
||||
followBaseLayer(): void {
|
||||
const baseLayer = this._runtimeScene.getLayer('');
|
||||
this.setCameraX(baseLayer.getCameraX());
|
||||
this.setCameraY(baseLayer.getCameraY());
|
||||
this.setCameraRotation(baseLayer.getCameraRotation());
|
||||
this.setCameraZoom(baseLayer.getCameraZoom());
|
||||
}
|
||||
|
||||
/**
|
||||
* The clear color is defined in the format [r, g, b], with components in the range of 0 to 1.
|
||||
* @return the clear color of layer in the range of [0, 1].
|
||||
*/
|
||||
getClearColor(): Array<integer> {
|
||||
return this._clearColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the clear color in format [r, g, b], with components in the range of 0 to 1.;
|
||||
* @param r Red color component in the range 0-255.
|
||||
* @param g Green color component in the range 0-255.
|
||||
* @param b Blue color component in the range 0-255.
|
||||
*/
|
||||
setClearColor(r: integer, g: integer, b: integer): void {
|
||||
this._clearColor[0] = r / 255;
|
||||
this._clearColor[1] = g / 255;
|
||||
this._clearColor[2] = b / 255;
|
||||
this._renderer.updateClearColor();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether layer's camera follows base layer's camera or not.
|
||||
*/
|
||||
setFollowBaseLayerCamera(follow: boolean): void {
|
||||
this._followBaseLayerCamera = follow;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the layer is a lighting layer, false otherwise.
|
||||
* @return true if it is a lighting layer, false otherwise.
|
||||
*/
|
||||
isLightingLayer(): boolean {
|
||||
return this._isLightingLayer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -67,11 +67,12 @@ namespace gdjs {
|
||||
this._pixiContainer.pivot.x = this._object.getUnscaledCenterX();
|
||||
this._pixiContainer.pivot.y = this._object.getUnscaledCenterY();
|
||||
this._pixiContainer.position.x =
|
||||
this._object.getDrawableX() +
|
||||
this._object.getX() +
|
||||
this._pixiContainer.pivot.x * Math.abs(this._object._scaleX);
|
||||
this._pixiContainer.position.y =
|
||||
this._object.getDrawableY() +
|
||||
this._object.getY() +
|
||||
this._pixiContainer.pivot.y * Math.abs(this._object._scaleY);
|
||||
|
||||
this._pixiContainer.rotation = gdjs.toRad(this._object.angle);
|
||||
this._pixiContainer.scale.x = this._object._scaleX;
|
||||
this._pixiContainer.scale.y = this._object._scaleY;
|
||||
@@ -126,7 +127,7 @@ namespace gdjs {
|
||||
return null;
|
||||
}
|
||||
|
||||
setLayerIndex(layer: gdjs.Layer, index: float): void {
|
||||
setLayerIndex(layer: gdjs.RuntimeLayer, index: float): void {
|
||||
const layerPixiRenderer: gdjs.LayerPixiRenderer = layer.getRenderer();
|
||||
let layerPixiObject:
|
||||
| PIXI.Container
|
||||
|
@@ -20,7 +20,7 @@ namespace gdjs {
|
||||
*
|
||||
* @see gdjs.RuntimeInstanceContainer.setLayerIndex
|
||||
*/
|
||||
setLayerIndex(layer: gdjs.Layer, index: integer): void;
|
||||
setLayerIndex(layer: gdjs.RuntimeLayer, index: integer): void;
|
||||
|
||||
getRendererObject(): PIXI.Container;
|
||||
}
|
||||
|
@@ -13,7 +13,7 @@ namespace gdjs {
|
||||
export class LayerPixiRenderer {
|
||||
_pixiContainer: PIXI.Container;
|
||||
|
||||
_layer: gdjs.Layer;
|
||||
_layer: gdjs.RuntimeLayer;
|
||||
_renderTexture: PIXI.RenderTexture | null = null;
|
||||
_lightingSprite: PIXI.Sprite | null = null;
|
||||
_runtimeSceneRenderer: gdjs.RuntimeInstanceContainerRenderer;
|
||||
@@ -35,7 +35,7 @@ namespace gdjs {
|
||||
* @param runtimeInstanceContainerRenderer The scene renderer
|
||||
*/
|
||||
constructor(
|
||||
layer: gdjs.Layer,
|
||||
layer: gdjs.RuntimeLayer,
|
||||
runtimeInstanceContainerRenderer: gdjs.RuntimeInstanceContainerRenderer,
|
||||
pixiRenderer: PIXI.Renderer | null
|
||||
) {
|
||||
|
@@ -104,7 +104,7 @@ namespace gdjs {
|
||||
return this._pixiRenderer;
|
||||
}
|
||||
|
||||
setLayerIndex(layer: gdjs.Layer, index: float): void {
|
||||
setLayerIndex(layer: gdjs.RuntimeLayer, index: float): void {
|
||||
const layerPixiRenderer: gdjs.LayerPixiRenderer = layer.getRenderer();
|
||||
let layerPixiObject:
|
||||
| PIXI.Container
|
||||
|
@@ -48,6 +48,14 @@ namespace gdjs {
|
||||
*/
|
||||
gdevelopResourceToken?: string;
|
||||
|
||||
/**
|
||||
* Check if, in some exceptional cases, we allow authentication
|
||||
* to be done through a iframe.
|
||||
* This is usually discouraged as the user can't verify that the authentication
|
||||
* window is a genuine one. It's only to be used in trusted contexts.
|
||||
*/
|
||||
allowAuthenticationUsingIframeForPreview?: boolean;
|
||||
|
||||
/**
|
||||
* If set, the game should use the specified environment for making calls
|
||||
* to GDevelop APIs ("dev" = development APIs).
|
||||
|
@@ -940,6 +940,46 @@ namespace gdjs {
|
||||
array.removeAtIndex(index);
|
||||
};
|
||||
|
||||
/**
|
||||
* Shortcut to get the first value of an array variable as a string.
|
||||
*/
|
||||
static getFirstVariableString = function (array: gdjs.Variable): string {
|
||||
if (array.getChildrenCount() === 0) {
|
||||
return '';
|
||||
}
|
||||
return array.getAllChildrenArray()[0].getAsString();
|
||||
};
|
||||
|
||||
/**
|
||||
* Shortcut to get the first value of an array variable as a number.
|
||||
*/
|
||||
static getFirstVariableNumber = function (array: gdjs.Variable): number {
|
||||
if (array.getChildrenCount() === 0) {
|
||||
return 0;
|
||||
}
|
||||
return array.getAllChildrenArray()[0].getAsNumber();
|
||||
};
|
||||
|
||||
/**
|
||||
* Shortcut to get the last value of an array variable as a string.
|
||||
*/
|
||||
static getLastVariableString = function (array: gdjs.Variable): string {
|
||||
const children = array.getAllChildrenArray();
|
||||
return children.length === 0
|
||||
? ''
|
||||
: children[children.length - 1].getAsString();
|
||||
};
|
||||
|
||||
/**
|
||||
* Shortcut to get the last value of an array variable as a number.
|
||||
*/
|
||||
static getLastVariableNumber = function (array: gdjs.Variable): number {
|
||||
const children = array.getAllChildrenArray();
|
||||
return children.length === 0
|
||||
? 0
|
||||
: children[children.length - 1].getAsNumber();
|
||||
};
|
||||
|
||||
/**
|
||||
* Shortcut to test if a variable exists for the object.
|
||||
* @param name The variable to be tested
|
||||
@@ -2531,6 +2571,11 @@ namespace gdjs {
|
||||
setVariableString = RuntimeObject.setVariableString;
|
||||
getVariableBoolean = RuntimeObject.getVariableBoolean;
|
||||
setVariableBoolean = RuntimeObject.setVariableBoolean;
|
||||
getVariableChildCount = RuntimeObject.getVariableChildCount;
|
||||
getFirstVariableNumber = RuntimeObject.getFirstVariableNumber;
|
||||
getFirstVariableString = RuntimeObject.getFirstVariableString;
|
||||
getLastVariableNumber = RuntimeObject.getLastVariableNumber;
|
||||
getLastVariableString = RuntimeObject.getLastVariableString;
|
||||
toggleVariableBoolean = RuntimeObject.toggleVariableBoolean;
|
||||
variableChildExists = RuntimeObject.variableChildExists;
|
||||
variableRemoveChild = RuntimeObject.variableRemoveChild;
|
||||
|
@@ -71,6 +71,10 @@ namespace gdjs {
|
||||
this.onGameResolutionResized();
|
||||
}
|
||||
|
||||
addLayer(layerData: LayerData) {
|
||||
this._layers.put(layerData.name, new gdjs.Layer(layerData, this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Should be called when the canvas where the scene is rendered has been resized.
|
||||
* See gdjs.RuntimeGame.startGameLoop in particular.
|
||||
@@ -86,8 +90,7 @@ namespace gdjs {
|
||||
: 0;
|
||||
for (const name in this._layers.items) {
|
||||
if (this._layers.items.hasOwnProperty(name)) {
|
||||
/** @type gdjs.Layer */
|
||||
const theLayer: gdjs.Layer = this._layers.items[name];
|
||||
const theLayer: gdjs.RuntimeLayer = this._layers.items[name];
|
||||
theLayer.onGameResolutionResized(
|
||||
oldGameResolutionOriginX,
|
||||
oldGameResolutionOriginY
|
||||
@@ -193,13 +196,6 @@ namespace gdjs {
|
||||
return behaviorSharedData;
|
||||
}
|
||||
|
||||
addLayer(layerData: LayerData) {
|
||||
this._layers.put(
|
||||
layerData.name,
|
||||
new gdjs.RuntimeSceneLayer(layerData, this)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a scene is "paused", i.e it will be not be rendered again
|
||||
* for some time, until it's resumed or unloaded.
|
||||
|
@@ -277,8 +277,8 @@ namespace gdjs {
|
||||
linkElement.id = 'watermark-link';
|
||||
|
||||
let targetUrl = this._authorUsername
|
||||
? new URL(`https://liluo.io/${this._authorUsername}`)
|
||||
: new URL('https://liluo.io');
|
||||
? new URL(`https://gd.games/${this._authorUsername}`)
|
||||
: new URL('https://gd.games');
|
||||
|
||||
if (this._isDevEnvironment) {
|
||||
targetUrl.searchParams.set('dev', 'true');
|
||||
|
@@ -6,7 +6,7 @@ describe('gdjs.Layer', function() {
|
||||
|
||||
it('benchmark convertCoords and convertInverseCoords', function() {
|
||||
this.timeout(30000);
|
||||
var layer = new gdjs.RuntimeSceneLayer(
|
||||
var layer = new gdjs.Layer(
|
||||
{ name: 'My layer',
|
||||
visibility: true,
|
||||
effects: [],
|
||||
|
@@ -55,8 +55,9 @@ module.exports = function (config) {
|
||||
'./newIDE/app/resources/GDJS/Runtime/scenestack.js',
|
||||
'./newIDE/app/resources/GDJS/Runtime/profiler.js',
|
||||
'./newIDE/app/resources/GDJS/Runtime/force.js',
|
||||
'./newIDE/app/resources/GDJS/Runtime/RuntimeLayer.js',
|
||||
'./newIDE/app/resources/GDJS/Runtime/layer.js',
|
||||
'./newIDE/app/resources/GDJS/Runtime/RuntimeSceneLayer.js',
|
||||
'./newIDE/app/resources/GDJS/Runtime/RuntimeCustomObjectLayer.js',
|
||||
'./newIDE/app/resources/GDJS/Runtime/timer.js',
|
||||
'./newIDE/app/resources/GDJS/Runtime/inputmanager.js',
|
||||
'./newIDE/app/resources/GDJS/Runtime/runtimegame.js',
|
||||
|
@@ -198,8 +198,8 @@ describe('gdjs.CustomRuntimeObject', function () {
|
||||
expect(customObject.getHitBoxes().length).to.be(2);
|
||||
expect(customObject.getHitBoxes()[0].vertices).to.eql([
|
||||
[32, 32],
|
||||
[31.999999999999993, -31.999999999999996],
|
||||
[96, 31.999999999999996],
|
||||
[32, -32],
|
||||
[96, 32],
|
||||
]);
|
||||
expect(customObject.getHitBoxes()[1].vertices).to.eql([
|
||||
[32, 96],
|
||||
@@ -245,6 +245,12 @@ describe('gdjs.CustomRuntimeObject', function () {
|
||||
customObject.setWidth(32);
|
||||
customObject.setHeight(96);
|
||||
|
||||
// To draw the transformed shapes:
|
||||
// - draw 2 squares side-by-side
|
||||
// - scale them and keep the top-left corner in place
|
||||
// - rotate the shape keeping the center of the scaled drawing in place
|
||||
// - translate it according to the object new position.
|
||||
|
||||
expect(customObject.getWidth()).to.be(32);
|
||||
expect(customObject.getHeight()).to.be(96);
|
||||
|
||||
@@ -253,14 +259,14 @@ describe('gdjs.CustomRuntimeObject', function () {
|
||||
|
||||
expect(customObject.getHitBoxes().length).to.be(2);
|
||||
expect(customObject.getHitBoxes()[0].vertices).to.eql([
|
||||
[-12, 100],
|
||||
[-12, 84],
|
||||
[84, 100],
|
||||
[-24, 64],
|
||||
[-24, 48],
|
||||
[72, 64],
|
||||
]);
|
||||
expect(customObject.getHitBoxes()[1].vertices).to.eql([
|
||||
[-12, 116],
|
||||
[-12, 100],
|
||||
[84, 116],
|
||||
[-24, 80],
|
||||
[-24, 64],
|
||||
[72, 80],
|
||||
]);
|
||||
});
|
||||
|
||||
|
@@ -9,7 +9,7 @@ describe('gdjs.Layer', function() {
|
||||
var runtimeScene = new gdjs.RuntimeScene(runtimeGame);
|
||||
|
||||
it('can convert coordinates', function(){
|
||||
var layer = new gdjs.RuntimeSceneLayer({name: 'My layer', visibility: true, effects:[]}, runtimeScene)
|
||||
var layer = new gdjs.Layer({name: 'My layer', visibility: true, effects:[]}, runtimeScene)
|
||||
layer.setCameraX(100, 0);
|
||||
layer.setCameraY(200, 0);
|
||||
layer.setCameraRotation(90, 0);
|
||||
@@ -18,7 +18,7 @@ describe('gdjs.Layer', function() {
|
||||
expect(layer.convertCoords(350, 450, 0)[1]).to.be.within(149.9999, 150.001);
|
||||
});
|
||||
it('can convert inverse coordinates', function(){
|
||||
var layer = new gdjs.RuntimeSceneLayer({name: 'My layer', visibility: true, effects:[]}, runtimeScene)
|
||||
var layer = new gdjs.Layer({name: 'My layer', visibility: true, effects:[]}, runtimeScene)
|
||||
layer.setCameraX(100, 0);
|
||||
layer.setCameraY(200, 0);
|
||||
layer.setCameraRotation(90, 0);
|
||||
|
@@ -55,7 +55,7 @@ describe('gdjs.RuntimeWatermark integration tests', () => {
|
||||
)
|
||||
throw new Error('Watermark DOM elements could not be found.');
|
||||
expect(watermark._linkElement.href).to.be(
|
||||
'https://liluo.io/HelperWesley?utm_source=gdevelop-game&utm_medium=game-watermark&utm_campaign=project-uuid'
|
||||
'https://gd.games/HelperWesley?utm_source=gdevelop-game&utm_medium=game-watermark&utm_campaign=project-uuid'
|
||||
);
|
||||
expect(watermark._containerElement.style.opacity).to.be('0');
|
||||
expect(watermark._backgroundElement.style.opacity).to.be('0');
|
||||
@@ -146,7 +146,7 @@ describe('gdjs.RuntimeWatermark integration tests', () => {
|
||||
throw new Error('Watermark DOM elements could not be found.');
|
||||
|
||||
expect(watermark._linkElement.href).to.be(
|
||||
'https://liluo.io/?utm_source=gdevelop-game&utm_medium=game-watermark&utm_campaign=project-uuid'
|
||||
'https://gd.games/?utm_source=gdevelop-game&utm_medium=game-watermark&utm_campaign=project-uuid'
|
||||
);
|
||||
expect(watermark._containerElement.style.opacity).to.be('0');
|
||||
expect(watermark._backgroundElement.style.opacity).to.be('0');
|
||||
|
@@ -1257,11 +1257,19 @@ interface InstructionMetadata {
|
||||
boolean IsPrivate();
|
||||
boolean IsAsync();
|
||||
boolean IsOptionallyAsync();
|
||||
boolean IsRelevantForLayoutEvents();
|
||||
boolean IsRelevantForFunctionEvents();
|
||||
boolean IsRelevantForAsynchronousFunctionEvents();
|
||||
boolean IsRelevantForCustomObjectEvents();
|
||||
|
||||
[Ref] InstructionMetadata SetCanHaveSubInstructions();
|
||||
[Ref] InstructionMetadata SetHelpPath([Const] DOMString helpPath);
|
||||
[Ref] InstructionMetadata SetHidden();
|
||||
[Ref] InstructionMetadata SetPrivate();
|
||||
[Ref] InstructionMetadata SetRelevantForLayoutEventsOnly();
|
||||
[Ref] InstructionMetadata SetRelevantForFunctionEventsOnly();
|
||||
[Ref] InstructionMetadata SetRelevantForAsynchronousFunctionEventsOnly();
|
||||
[Ref] InstructionMetadata SetRelevantForCustomObjectEventsOnly();
|
||||
[Ref] InstructionMetadata AddParameter([Const] DOMString type,
|
||||
[Const] DOMString description,
|
||||
[Const] DOMString optionalObjectType,
|
||||
@@ -1310,12 +1318,20 @@ interface ExpressionMetadata {
|
||||
[Const, Ref] DOMString GetHelpPath();
|
||||
boolean IsShown();
|
||||
boolean IsPrivate();
|
||||
boolean IsRelevantForLayoutEvents();
|
||||
boolean IsRelevantForFunctionEvents();
|
||||
boolean IsRelevantForAsynchronousFunctionEvents();
|
||||
boolean IsRelevantForCustomObjectEvents();
|
||||
[Ref] ParameterMetadata GetParameter(unsigned long id);
|
||||
unsigned long GetParametersCount();
|
||||
[Const, Ref] VectorParameterMetadata GetParameters();
|
||||
|
||||
[Ref] ExpressionMetadata SetHidden();
|
||||
[Ref] ExpressionMetadata SetPrivate();
|
||||
[Ref] ExpressionMetadata SetRelevantForLayoutEventsOnly();
|
||||
[Ref] ExpressionMetadata SetRelevantForFunctionEventsOnly();
|
||||
[Ref] ExpressionMetadata SetRelevantForAsynchronousFunctionEventsOnly();
|
||||
[Ref] ExpressionMetadata SetRelevantForCustomObjectEventsOnly();
|
||||
[Ref] ExpressionMetadata AddParameter(
|
||||
[Const] DOMString type,
|
||||
[Const] DOMString description,
|
||||
@@ -2251,6 +2267,10 @@ interface UsedExtensionsFinder {
|
||||
[Value] UsedExtensionsResult STATIC_ScanProject([Ref] Project project);
|
||||
};
|
||||
|
||||
interface InstructionsCountEvaluator {
|
||||
long STATIC_ScanProject([Ref] Project project);
|
||||
};
|
||||
|
||||
interface ExtensionAndBehaviorMetadata {
|
||||
[Const, Ref] PlatformExtension GetExtension();
|
||||
[Const, Ref] BehaviorMetadata GetMetadata();
|
||||
@@ -3150,6 +3170,7 @@ interface PreviewExportOptions {
|
||||
[Ref] PreviewExportOptions SetNonRuntimeScriptsCacheBurst(unsigned long value);
|
||||
[Ref] PreviewExportOptions SetElectronRemoteRequirePath([Const] DOMString electronRemoteRequirePath);
|
||||
[Ref] PreviewExportOptions SetGDevelopResourceToken([Const] DOMString gdevelopResourceToken);
|
||||
[Ref] PreviewExportOptions SetAllowAuthenticationUsingIframeForPreview(boolean enable);
|
||||
};
|
||||
|
||||
[Prefix="gdjs::"]
|
||||
|
@@ -40,6 +40,7 @@
|
||||
#include <GDCore/IDE/Events/InstructionsTypeRenamer.h>
|
||||
#include <GDCore/IDE/Events/TextFormatting.h>
|
||||
#include <GDCore/IDE/Events/UsedExtensionsFinder.h>
|
||||
#include <GDCore/IDE/Events/InstructionsCountEvaluator.h>
|
||||
#include <GDCore/IDE/EventsFunctionTools.h>
|
||||
#include <GDCore/IDE/Events/EventsVariablesFinder.h>
|
||||
#include <GDCore/IDE/Events/EventsIdentifiersFinder.h>
|
||||
|
@@ -9,11 +9,19 @@ declare class gdExpressionMetadata {
|
||||
getHelpPath(): string;
|
||||
isShown(): boolean;
|
||||
isPrivate(): boolean;
|
||||
isRelevantForLayoutEvents(): boolean;
|
||||
isRelevantForFunctionEvents(): boolean;
|
||||
isRelevantForAsynchronousFunctionEvents(): boolean;
|
||||
isRelevantForCustomObjectEvents(): boolean;
|
||||
getParameter(id: number): gdParameterMetadata;
|
||||
getParametersCount(): number;
|
||||
getParameters(): gdVectorParameterMetadata;
|
||||
setHidden(): gdExpressionMetadata;
|
||||
setPrivate(): gdExpressionMetadata;
|
||||
setRelevantForLayoutEventsOnly(): gdExpressionMetadata;
|
||||
setRelevantForFunctionEventsOnly(): gdExpressionMetadata;
|
||||
setRelevantForAsynchronousFunctionEventsOnly(): gdExpressionMetadata;
|
||||
setRelevantForCustomObjectEventsOnly(): gdExpressionMetadata;
|
||||
addParameter(type: string, description: string, optionalObjectType?: string, parameterIsOptional?: boolean): gdExpressionMetadata;
|
||||
addCodeOnlyParameter(type: string, supplementaryInformation: string): gdExpressionMetadata;
|
||||
setDefaultValue(defaultValue: string): gdExpressionMetadata;
|
||||
|
@@ -17,10 +17,18 @@ declare class gdInstructionMetadata {
|
||||
isPrivate(): boolean;
|
||||
isAsync(): boolean;
|
||||
isOptionallyAsync(): boolean;
|
||||
isRelevantForLayoutEvents(): boolean;
|
||||
isRelevantForFunctionEvents(): boolean;
|
||||
isRelevantForAsynchronousFunctionEvents(): boolean;
|
||||
isRelevantForCustomObjectEvents(): boolean;
|
||||
setCanHaveSubInstructions(): gdInstructionMetadata;
|
||||
setHelpPath(helpPath: string): gdInstructionMetadata;
|
||||
setHidden(): gdInstructionMetadata;
|
||||
setPrivate(): gdInstructionMetadata;
|
||||
setRelevantForLayoutEventsOnly(): gdInstructionMetadata;
|
||||
setRelevantForFunctionEventsOnly(): gdInstructionMetadata;
|
||||
setRelevantForAsynchronousFunctionEventsOnly(): gdInstructionMetadata;
|
||||
setRelevantForCustomObjectEventsOnly(): gdInstructionMetadata;
|
||||
addParameter(type: string, description: string, optionalObjectType?: string, parameterIsOptional?: boolean): gdInstructionMetadata;
|
||||
addCodeOnlyParameter(type: string, supplementaryInformation: string): gdInstructionMetadata;
|
||||
setDefaultValue(defaultValue: string): gdInstructionMetadata;
|
||||
|
6
GDevelop.js/types/gdinstructionscountevaluator.js
Normal file
6
GDevelop.js/types/gdinstructionscountevaluator.js
Normal file
@@ -0,0 +1,6 @@
|
||||
// Automatically generated by GDevelop.js/scripts/generate-types.js
|
||||
declare class gdInstructionsCountEvaluator {
|
||||
static scanProject(project: gdProject): number;
|
||||
delete(): void;
|
||||
ptr: number;
|
||||
};
|
@@ -13,6 +13,7 @@ declare class gdPreviewExportOptions {
|
||||
setNonRuntimeScriptsCacheBurst(value: number): gdPreviewExportOptions;
|
||||
setElectronRemoteRequirePath(electronRemoteRequirePath: string): gdPreviewExportOptions;
|
||||
setGDevelopResourceToken(gdevelopResourceToken: string): gdPreviewExportOptions;
|
||||
setAllowAuthenticationUsingIframeForPreview(enable: boolean): gdPreviewExportOptions;
|
||||
delete(): void;
|
||||
ptr: number;
|
||||
};
|
@@ -155,6 +155,7 @@ declare class libGDevelop {
|
||||
PropertyFunctionGenerator: Class<gdPropertyFunctionGenerator>;
|
||||
UsedExtensionsResult: Class<gdUsedExtensionsResult>;
|
||||
UsedExtensionsFinder: Class<gdUsedExtensionsFinder>;
|
||||
InstructionsCountEvaluator: Class<gdInstructionsCountEvaluator>;
|
||||
ExtensionAndBehaviorMetadata: Class<gdExtensionAndBehaviorMetadata>;
|
||||
ExtensionAndObjectMetadata: Class<gdExtensionAndObjectMetadata>;
|
||||
ExtensionAndEffectMetadata: Class<gdExtensionAndEffectMetadata>;
|
||||
|
@@ -1,8 +1,8 @@
|
||||

|
||||

|
||||
|
||||
GDevelop is a full-featured, no-code, open-source game development software. You can build games for mobile, desktop and the web. GDevelop is fast and easy to use: the game logic is built up using an intuitive and powerful event-based system.
|
||||
|
||||

|
||||

|
||||
|
||||
## Getting started
|
||||
|
||||
@@ -49,10 +49,10 @@ Status of the tests and builds: [ created with GDevelop.
|
||||
- Find more GDevelop games on [Liluo.io](https://liluo.io).
|
||||
- Find more GDevelop games on [gd.games](https://gd.games).
|
||||
- Suggest your game to be [added to the showcase here](https://docs.google.com/forms/d/e/1FAIpQLSfjiOnkbODuPifSGuzxYY61vB5kyMWdTZSSqkJsv3H6ePRTQA/viewform).
|
||||
|
||||

|
||||

|
||||
|
||||
## License
|
||||
|
||||
|
@@ -13,6 +13,6 @@ export { TileMapManager } from "./render/TileMapManager";
|
||||
export { TileTextureCache } from "./render/TileTextureCache";
|
||||
export { PixiTileMapHelper } from "./render/TileMapPixiHelper";
|
||||
|
||||
export * from "./types/index";
|
||||
export * from "./load/TileMapFileContent";
|
||||
export * from "./model/CommonTypes";
|
||||
export { TiledTileset } from "./load/tiled/TiledFormat";
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import { LDtkTileMap } from "../load/ldtk/LDtkFormat";
|
||||
import { TiledTileMap } from "../load/tiled/TiledFormat";
|
||||
|
||||
export type TileMap =
|
||||
export type TileMapFileContent =
|
||||
| {
|
||||
kind: "tiled";
|
||||
data: TiledTileMap;
|
@@ -1,5 +1,5 @@
|
||||
import type { EditableTileMap } from "../model/TileMapModel";
|
||||
import { TileMap } from "../types";
|
||||
import { TileMapFileContent } from "./TileMapFileContent";
|
||||
import { LDtkTileMapLoader } from "./ldtk/LDtkTileMapLoader";
|
||||
import { TiledTileMapLoader } from "./tiled/TiledTileMapLoader";
|
||||
|
||||
@@ -7,21 +7,21 @@ export namespace TileMapLoader {
|
||||
/**
|
||||
* Create a {@link EditableTileMap} from the raw data.
|
||||
*
|
||||
* @param tiledMap The data exported from Tiled/LDtk.
|
||||
* @param tileMapFileContent The data exported from Tiled/LDtk.
|
||||
* @param levelIndex The level of the tile map to load from.
|
||||
* @param pako The zlib library.
|
||||
* @returns A {@link EditableTileMap}
|
||||
*/
|
||||
export function load(
|
||||
tileMap: TileMap,
|
||||
tileMapFileContent: TileMapFileContent,
|
||||
levelIndex: number,
|
||||
pako: any
|
||||
): EditableTileMap | null {
|
||||
if (tileMap.kind === "ldtk") {
|
||||
return LDtkTileMapLoader.load(tileMap.data, levelIndex);
|
||||
if (tileMapFileContent.kind === "ldtk") {
|
||||
return LDtkTileMapLoader.load(tileMapFileContent.data, levelIndex);
|
||||
}
|
||||
if (tileMap.kind === "tiled") {
|
||||
return TiledTileMapLoader.load(tileMap.data, pako);
|
||||
if (tileMapFileContent.kind === "tiled") {
|
||||
return TiledTileMapLoader.load(tileMapFileContent.data, pako);
|
||||
}
|
||||
|
||||
console.warn(
|
||||
|
@@ -1,8 +1,8 @@
|
||||
import { integer } from '../../model/CommonTypes';
|
||||
import { EditableTileMap, TileDefinition } from '../../model/TileMapModel';
|
||||
import { getLDtkTileId } from './LDtkTileMapLoaderHelper';
|
||||
import { LDtkTileMap } from './LDtkFormat';
|
||||
import { getTileGID } from '../../model/GID';
|
||||
import { integer } from "../../model/CommonTypes";
|
||||
import { EditableTileMap, TileDefinition } from "../../model/TileMapModel";
|
||||
import { getLDtkTileId } from "./LDtkTileMapLoaderHelper";
|
||||
import { LDtkTileMap } from "./LDtkFormat";
|
||||
import { getTileGID } from "../../model/GID";
|
||||
|
||||
export namespace LDtkTileMapLoader {
|
||||
/**
|
||||
@@ -54,9 +54,9 @@ export namespace LDtkTileMapLoader {
|
||||
}
|
||||
|
||||
if (
|
||||
layer.__type === 'IntGrid' ||
|
||||
layer.__type === 'AutoLayer' ||
|
||||
layer.__type === 'Tiles'
|
||||
layer.__type === "IntGrid" ||
|
||||
layer.__type === "AutoLayer" ||
|
||||
layer.__type === "Tiles"
|
||||
) {
|
||||
if (gridSize === 0) {
|
||||
gridSize = layer.__gridSize;
|
||||
@@ -64,7 +64,7 @@ export namespace LDtkTileMapLoader {
|
||||
dimY = layer.__cHei;
|
||||
} else if (layer.__gridSize !== gridSize) {
|
||||
console.warn(
|
||||
'Grid size is different across layers. Only the first layer grid size will be followed.'
|
||||
"Grid size is different across layers. Only the first layer grid size will be followed."
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -124,7 +124,7 @@ export namespace LDtkTileMapLoader {
|
||||
const hash = `${oldTileDef
|
||||
.getStackedTiles()
|
||||
.map((tileId) => `${tileId}`)
|
||||
.join(';')};${tileGID}`;
|
||||
.join(";")};${tileGID}`;
|
||||
const tileDef = composedTileMap.get(hash);
|
||||
if (tileDef) {
|
||||
editableTileLayer.setTile(x, y, tileDef.getStackTileId());
|
||||
|
@@ -5,7 +5,7 @@ import { PixiTileMapHelper } from "./TileMapPixiHelper";
|
||||
|
||||
import PIXI = GlobalPIXIModule.PIXI;
|
||||
import { TileMapLoader } from "../load/TileMapLoader";
|
||||
import { TileMap } from "../types";
|
||||
import { TileMapFileContent } from "../load/TileMapFileContent";
|
||||
|
||||
/**
|
||||
* A holder to share tile maps across the 2 extension objects.
|
||||
@@ -43,7 +43,7 @@ export class TileMapManager {
|
||||
* @param data JSON data.
|
||||
* @returns The data enclosed with its detected kind.
|
||||
*/
|
||||
static identify(data: any): TileMap | null {
|
||||
static identify(data: any): TileMapFileContent | null {
|
||||
if (data.tiledversion) {
|
||||
console.info("Detected the json file was created in Tiled");
|
||||
return {
|
||||
@@ -63,7 +63,6 @@ export class TileMapManager {
|
||||
console.warn(
|
||||
"The loaded Tile Map data does not contain a 'tiledversion' or '__header__' key. Are you sure this file has been exported from Tiled (mapeditor.org) or LDtk (ldtk.io)?"
|
||||
);
|
||||
console.log("The data that failed Tile Map identification is: ", data);
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -80,7 +79,7 @@ export class TileMapManager {
|
||||
loadTileMap: (
|
||||
tileMapJsonResourceName: string,
|
||||
tileSetJsonResourceName: string,
|
||||
callback: (tileMap: TileMap | null) => void
|
||||
callback: (tileMapFileContent: TileMapFileContent | null) => void
|
||||
) => void,
|
||||
tileMapJsonResourceName: string,
|
||||
tileSetJsonResourceName: string,
|
||||
@@ -101,14 +100,14 @@ export class TileMapManager {
|
||||
loadTileMap(
|
||||
tileMapJsonResourceName,
|
||||
tileSetJsonResourceName,
|
||||
(tileMap: TileMap | null) => {
|
||||
if (!tileMap) {
|
||||
(tileMapFileContent: TileMapFileContent | null) => {
|
||||
if (!tileMapFileContent) {
|
||||
callback(null);
|
||||
return;
|
||||
}
|
||||
|
||||
const editableTileMap = TileMapLoader.load(
|
||||
tileMap,
|
||||
tileMapFileContent,
|
||||
levelIndex,
|
||||
pako
|
||||
);
|
||||
@@ -133,7 +132,7 @@ export class TileMapManager {
|
||||
loadTileMap: (
|
||||
tileMapJsonResourceName: string,
|
||||
tileSetJsonResourceName: string,
|
||||
callback: (tileMap: TileMap | null) => void
|
||||
callback: (tileMapFileContent: TileMapFileContent | null) => void
|
||||
) => void,
|
||||
getTexture: (textureName: string) => PIXI.BaseTexture<PIXI.Resource>,
|
||||
atlasImageResourceName: string,
|
||||
@@ -157,8 +156,8 @@ export class TileMapManager {
|
||||
loadTileMap(
|
||||
tileMapJsonResourceName,
|
||||
tileSetJsonResourceName,
|
||||
(tileMap: TileMap | null) => {
|
||||
if (!tileMap) {
|
||||
(tileMapFileContent: TileMapFileContent | null) => {
|
||||
if (!tileMapFileContent) {
|
||||
// loadTileMap already log errors.
|
||||
callback(null);
|
||||
return;
|
||||
@@ -168,7 +167,7 @@ export class TileMapManager {
|
||||
? getTexture(atlasImageResourceName)
|
||||
: null;
|
||||
const textureCache = PixiTileMapHelper.parseAtlas(
|
||||
tileMap,
|
||||
tileMapFileContent,
|
||||
levelIndex,
|
||||
atlasTexture,
|
||||
getTexture
|
||||
|
@@ -6,7 +6,7 @@ import {
|
||||
} from "../model/TileMapModel";
|
||||
import { TiledPixiHelper } from "./tiled/TiledPixiHelper";
|
||||
import { LDtkPixiHelper } from "./ldtk/LDtkPixiHelper";
|
||||
import { TileMap } from "../types";
|
||||
import { TileMapFileContent } from "../load/TileMapFileContent";
|
||||
import { TileTextureCache } from "./TileTextureCache";
|
||||
import { FlippingHelper, getPixiRotate } from "../model/GID";
|
||||
|
||||
@@ -23,7 +23,7 @@ export namespace PixiTileMapHelper {
|
||||
* @returns A textures cache.
|
||||
*/
|
||||
export function parseAtlas(
|
||||
tileMap: TileMap,
|
||||
tileMap: TileMapFileContent,
|
||||
levelIndex: number,
|
||||
atlasTexture: PIXI.BaseTexture<PIXI.Resource> | null,
|
||||
getTexture: (textureName: string) => PIXI.BaseTexture<PIXI.Resource>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
# GDevelop IDE
|
||||
|
||||
This is the GDevelop 5 editor. It is based on [React](https://facebook.github.io/react/), [Material-UI](http://www.material-ui.com), [Pixi.js](https://github.com/pixijs/pixi.js) and [Electron](https://electron.atom.io/).
|
||||
This is the GDevelop 5 editor. It is based on [React](https://facebook.github.io/react/), [Material-UI](http://www.material-ui.com), [Pixi.js](https://github.com/pixijs/pixi.js) and [Electron](https://electron.atom.io/) for the desktop app.
|
||||
It uses GDevelop [core C++ classes compiled to Javascript](https://github.com/4ian/GDevelop.js) to work with GDevelop games.
|
||||
|
||||

|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user