mirror of
https://github.com/4ian/GDevelop.git
synced 2025-10-15 10:19:04 +00:00
Compare commits
101 Commits
dynamical-
...
rename-obj
Author | SHA1 | Date | |
---|---|---|---|
![]() |
4c5f624b34 | ||
![]() |
0928247ee1 | ||
![]() |
2ae7b1a862 | ||
![]() |
00e664ef52 | ||
![]() |
ed8e272740 | ||
![]() |
84e9373f7e | ||
![]() |
d31e816790 | ||
![]() |
9b26c82597 | ||
![]() |
0054324df8 | ||
![]() |
0e9ed86b4d | ||
![]() |
3961c2af4a | ||
![]() |
cc4d78b08a | ||
![]() |
8d13285c97 | ||
![]() |
7b7e13817c | ||
![]() |
129ebeb4e4 | ||
![]() |
808f2bc802 | ||
![]() |
c5935232f7 | ||
![]() |
35a8341964 | ||
![]() |
95783fd58f | ||
![]() |
a78aa4af6e | ||
![]() |
4f4b2b7901 | ||
![]() |
957f672b90 | ||
![]() |
b9e932d0de | ||
![]() |
fdd2362dae | ||
![]() |
47583e3092 | ||
![]() |
8d7967d71a | ||
![]() |
72142a62c4 | ||
![]() |
619890a25f | ||
![]() |
debcd3045f | ||
![]() |
86635e4f66 | ||
![]() |
eedc68b0f2 | ||
![]() |
b1a6425ab8 | ||
![]() |
3d1ee5efcc | ||
![]() |
4d1fde608b | ||
![]() |
e40666bd73 | ||
![]() |
4a6c075e41 | ||
![]() |
82426fa564 | ||
![]() |
a21eef6930 | ||
![]() |
c6112a1549 | ||
![]() |
d8350396df | ||
![]() |
a8282aaf83 | ||
![]() |
7de7fc7193 | ||
![]() |
81c5829267 | ||
![]() |
07cf1a90a4 | ||
![]() |
3213985a81 | ||
![]() |
d4441fda99 | ||
![]() |
91c55fcf94 | ||
![]() |
6d7b5ac7d3 | ||
![]() |
903b353b7b | ||
![]() |
4dd189512b | ||
![]() |
535fa39a7b | ||
![]() |
78c0cb944f | ||
![]() |
55e037484f | ||
![]() |
84392c08b2 | ||
![]() |
0061b1cb8b | ||
![]() |
9e19aa8886 | ||
![]() |
f4b812ab29 | ||
![]() |
106d9de47c | ||
![]() |
ecbafe60d1 | ||
![]() |
c0ba26f1d5 | ||
![]() |
089be66e82 | ||
![]() |
ffb8a399cd | ||
![]() |
63482a0cda | ||
![]() |
4fe8dcaf0c | ||
![]() |
9729461aa1 | ||
![]() |
26fcc9770b | ||
![]() |
c62f9c5c65 | ||
![]() |
9b199d5aa0 | ||
![]() |
46e1a5c6e8 | ||
![]() |
052a6240c5 | ||
![]() |
d081711838 | ||
![]() |
f0151b2e1f | ||
![]() |
e2f42ca290 | ||
![]() |
b7a3d85287 | ||
![]() |
4b542e071a | ||
![]() |
64cad25b81 | ||
![]() |
8472e30342 | ||
![]() |
1b7d258727 | ||
![]() |
946b77093d | ||
![]() |
74c882f219 | ||
![]() |
abd417c494 | ||
![]() |
2005f9c37b | ||
![]() |
b749ac1106 | ||
![]() |
f34f901fa7 | ||
![]() |
c74110c058 | ||
![]() |
2a38be827c | ||
![]() |
7cd97e8cc4 | ||
![]() |
4c9445f6f5 | ||
![]() |
b7772520b5 | ||
![]() |
93121d1a1c | ||
![]() |
9f7c1a1748 | ||
![]() |
f6fc2406a5 | ||
![]() |
daede19d0d | ||
![]() |
36e835c461 | ||
![]() |
8d0b3ef53e | ||
![]() |
7ccd2cd146 | ||
![]() |
49974131d0 | ||
![]() |
77320ce12e | ||
![]() |
35833e6e23 | ||
![]() |
7436032787 | ||
![]() |
aa4fd1bda9 |
@@ -726,6 +726,8 @@ gd::String EventsCodeGenerator::GenerateParameterCodes(
|
||||
metadata.GetType() == "fontResource" ||
|
||||
metadata.GetType() == "imageResource" ||
|
||||
metadata.GetType() == "jsonResource" ||
|
||||
metadata.GetType() == "tilemapResource" ||
|
||||
metadata.GetType() == "tilesetResource" ||
|
||||
metadata.GetType() == "videoResource" ||
|
||||
// Deprecated, old parameter names:
|
||||
metadata.GetType() == "password" || metadata.GetType() == "musicfile" ||
|
||||
|
@@ -23,6 +23,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAudioExtension(
|
||||
.SetCategory("Audio");
|
||||
extension.AddInstructionOrExpressionGroupMetadata(_("Sounds and music"))
|
||||
.SetIcon("res/actions/music24.png");
|
||||
extension.AddInstructionOrExpressionGroupMetadata(_("Sounds on channels"))
|
||||
.SetIcon("res/actions/son24.png");
|
||||
|
||||
extension
|
||||
.AddAction("PlaySoundCanal",
|
||||
|
@@ -26,6 +26,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
|
||||
.SetExtensionHelpPath("/interface/scene-editor/layers-and-cameras");
|
||||
extension.AddInstructionOrExpressionGroupMetadata(_("Layers and cameras"))
|
||||
.SetIcon("res/conditions/camera24.png");
|
||||
extension.AddInstructionOrExpressionGroupMetadata(_("Effects"))
|
||||
.SetIcon("res/actions/effect24.png");
|
||||
|
||||
extension
|
||||
.AddExpressionAndConditionAndAction(
|
||||
@@ -453,8 +455,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
|
||||
"names) in the effects window."),
|
||||
_("Set _PARAM3_ to _PARAM4_ for effect _PARAM2_ of layer _PARAM1_"),
|
||||
_("Effects"),
|
||||
"res/conditions/camera24.png",
|
||||
"res/conditions/camera.png")
|
||||
"res/actions/effect24.png",
|
||||
"res/actions/effect.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.AddParameter("layer", _("Layer (base layer if empty)"), "", true)
|
||||
.SetDefaultValue("\"\"")
|
||||
@@ -472,8 +474,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
|
||||
"names) in the effects window."),
|
||||
_("Set _PARAM3_ to _PARAM4_ for effect _PARAM2_ of layer _PARAM1_"),
|
||||
_("Effects"),
|
||||
"res/conditions/camera24.png",
|
||||
"res/conditions/camera.png")
|
||||
"res/actions/effect24.png",
|
||||
"res/actions/effect.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.AddParameter("layer", _("Layer (base layer if empty)"), "", true)
|
||||
.SetDefaultValue("\"\"")
|
||||
@@ -491,8 +493,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
|
||||
"names) in the effects window."),
|
||||
_("Enable _PARAM3_ for effect _PARAM2_ of layer _PARAM1_: _PARAM4_"),
|
||||
_("Effects"),
|
||||
"res/conditions/camera24.png",
|
||||
"res/conditions/camera.png")
|
||||
"res/actions/effect24.png",
|
||||
"res/actions/effect.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.AddParameter("layer", _("Layer (base layer if empty)"), "", true)
|
||||
.SetDefaultValue("\"\"")
|
||||
@@ -506,9 +508,9 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
|
||||
_("Layer effect is enabled"),
|
||||
_("The effect on a layer is enabled"),
|
||||
_("Effect _PARAM2_ on layer _PARAM1_ is enabled"),
|
||||
_("Effects"),
|
||||
"res/conditions/camera24.png",
|
||||
"res/conditions/camera.png")
|
||||
_(""),
|
||||
"res/actions/effect24.png",
|
||||
"res/actions/effect.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.AddParameter("layer", _("Layer (base layer if empty)"), "", true)
|
||||
.SetDefaultValue("\"\"")
|
||||
@@ -521,8 +523,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
|
||||
_("Enable an effect on a layer"),
|
||||
_("Enable effect _PARAM2_ on layer _PARAM1_: _PARAM3_"),
|
||||
_("Effects"),
|
||||
"res/conditions/camera24.png",
|
||||
"res/conditions/camera.png")
|
||||
"res/actions/effect24.png",
|
||||
"res/actions/effect.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.AddParameter("layer", _("Layer (base layer if empty)"), "", true)
|
||||
.SetDefaultValue("\"\"")
|
||||
@@ -601,7 +603,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
|
||||
_("Set the ambient light color of the lighting layer in format "
|
||||
"\"R;G;B\" string."),
|
||||
_("Set the ambient color of the lighting layer _PARAM1_ to _PARAM2_"),
|
||||
_("Lighting"),
|
||||
_(""),
|
||||
"res/actions/color24.png",
|
||||
"res/actions/color.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
|
@@ -27,6 +27,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsMouseExtension(
|
||||
.SetCategory("Input");
|
||||
extension.AddInstructionOrExpressionGroupMetadata(_("Mouse and touch"))
|
||||
.SetIcon("res/actions/mouse24.png");
|
||||
extension.AddInstructionOrExpressionGroupMetadata(_("Multitouch"))
|
||||
.SetIcon("res/conditions/touch24.png");
|
||||
|
||||
extension
|
||||
.AddCondition(
|
||||
@@ -153,7 +155,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsMouseExtension(
|
||||
extension
|
||||
.AddExpressionAndCondition(
|
||||
"number",
|
||||
"MouseX",
|
||||
"CursorX",
|
||||
_("Cursor X position"),
|
||||
_("the X position of the cursor or of a touch"),
|
||||
_("the cursor (or touch) X position"),
|
||||
@@ -167,13 +169,15 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsMouseExtension(
|
||||
.SetDefaultValue("0");
|
||||
|
||||
// Support for deprecated names:
|
||||
extension.AddDuplicatedCondition("SourisX", "MouseX").SetHidden();
|
||||
extension.AddDuplicatedExpression("SourisX", "MouseX").SetHidden();
|
||||
extension.AddDuplicatedCondition("MouseX", "CursorX").SetHidden();
|
||||
extension.AddDuplicatedExpression("MouseX", "CursorX").SetHidden();
|
||||
extension.AddDuplicatedCondition("SourisX", "CursorX").SetHidden();
|
||||
extension.AddDuplicatedExpression("SourisX", "CursorX").SetHidden();
|
||||
|
||||
extension
|
||||
.AddExpressionAndCondition(
|
||||
"number",
|
||||
"MouseY",
|
||||
"CursorY",
|
||||
_("Cursor Y position"),
|
||||
_("the Y position of the cursor or of a touch"),
|
||||
_("the cursor (or touch) Y position"),
|
||||
@@ -187,8 +191,46 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsMouseExtension(
|
||||
.SetDefaultValue("0");
|
||||
|
||||
// Support for deprecated names:
|
||||
extension.AddDuplicatedCondition("SourisY", "MouseY").SetHidden();
|
||||
extension.AddDuplicatedExpression("SourisY", "MouseY").SetHidden();
|
||||
extension.AddDuplicatedCondition("MouseY", "CursorY").SetHidden();
|
||||
extension.AddDuplicatedExpression("MouseY", "CursorY").SetHidden();
|
||||
extension.AddDuplicatedCondition("SourisY", "CursorY").SetHidden();
|
||||
extension.AddDuplicatedExpression("SourisY", "CursorY").SetHidden();
|
||||
|
||||
extension
|
||||
.AddExpressionAndCondition(
|
||||
"number",
|
||||
"MouseOnlyCursorX",
|
||||
_("Mouse cursor X position"),
|
||||
_("the X position of the mouse cursor"),
|
||||
_("the mouse cursor X position"),
|
||||
"",
|
||||
"res/conditions/mouse24.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.UseStandardParameters("number", ParameterOptions::MakeNewOptions())
|
||||
.AddParameter("layer", _("Layer (base layer if empty)"), "", true)
|
||||
.SetDefaultValue("\"\"")
|
||||
.AddParameter("expression", _("Camera number (default : 0)"), "", true)
|
||||
.SetDefaultValue("0")
|
||||
// It's only useful for extensions as they can't use TouchSimulateMouse.
|
||||
.SetHidden();
|
||||
|
||||
extension
|
||||
.AddExpressionAndCondition(
|
||||
"number",
|
||||
"MouseOnlyCursorY",
|
||||
_("Mouse cursor Y position"),
|
||||
_("the Y position of the mouse cursor"),
|
||||
_("the mouse cursor Y position"),
|
||||
"",
|
||||
"res/conditions/mouse24.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.UseStandardParameters("number", ParameterOptions::MakeNewOptions())
|
||||
.AddParameter("layer", _("Layer (base layer if empty)"), "", true)
|
||||
.SetDefaultValue("\"\"")
|
||||
.AddParameter("expression", _("Camera number (default : 0)"), "", true)
|
||||
.SetDefaultValue("0")
|
||||
// It's only useful for extensions as they can't use TouchSimulateMouse.
|
||||
.SetHidden();
|
||||
|
||||
extension
|
||||
.AddCondition("IsMouseInsideCanvas",
|
||||
@@ -340,7 +382,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsMouseExtension(
|
||||
_("Multitouch"),
|
||||
"res/conditions/touch24.png",
|
||||
"res/conditions/touch.png")
|
||||
.AddCodeOnlyParameter("currentScene", "");
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.SetHidden();
|
||||
|
||||
extension
|
||||
.AddExpression(
|
||||
@@ -350,7 +393,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsMouseExtension(
|
||||
"accessed using StartedTouchId()."),
|
||||
_("Multitouch"),
|
||||
"res/conditions/touch.png")
|
||||
.AddCodeOnlyParameter("currentScene", "");
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.SetHidden();
|
||||
|
||||
extension
|
||||
.AddExpression(
|
||||
@@ -361,13 +405,50 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsMouseExtension(
|
||||
_("Multitouch"),
|
||||
"res/conditions/touch.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.AddParameter("expression", _("Touch index"))
|
||||
.SetHidden();
|
||||
|
||||
extension
|
||||
.AddCondition(
|
||||
"HasAnyTouchOrMouseStarted",
|
||||
_("A new touch has started"),
|
||||
_("Check if a touch has just started or the mouse left button has "
|
||||
"been pressed on this frame. The touch identifiers can be "
|
||||
"accessed using StartedTouchOrMouseId() and StartedTouchOrMouseCount()."),
|
||||
_("A new touch has started"),
|
||||
_("Multitouch"),
|
||||
"res/conditions/touch24.png",
|
||||
"res/conditions/touch.png")
|
||||
.AddCodeOnlyParameter("currentScene", "");
|
||||
|
||||
extension
|
||||
.AddExpression(
|
||||
"StartedTouchOrMouseCount",
|
||||
_("Started touch count"),
|
||||
_("The number of touches (including the mouse) that have just "
|
||||
"started on this frame. The touch identifiers can be "
|
||||
"accessed using StartedTouchOrMouseCount()."),
|
||||
_("Multitouch"),
|
||||
"res/conditions/touch.png")
|
||||
.AddCodeOnlyParameter("currentScene", "");
|
||||
|
||||
extension
|
||||
.AddExpression(
|
||||
"StartedTouchOrMouseId",
|
||||
_("Started touch identifier"),
|
||||
_("The identifier of the touch or mouse that has just started on "
|
||||
"this frame. The touch number of touches can be "
|
||||
"accessed using StartedTouchOrMouseCount()."),
|
||||
_("Multitouch"),
|
||||
"res/conditions/touch.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.AddParameter("expression", _("Touch index"));
|
||||
|
||||
extension
|
||||
.AddCondition(
|
||||
"HasTouchEnded",
|
||||
_("A touch has ended"),
|
||||
_("Check if a touch has ended."),
|
||||
_("Check if a touch has ended or a mouse left button has been released."),
|
||||
_("The touch with identifier _PARAM1_ has ended"),
|
||||
_("Multitouch"),
|
||||
"res/conditions/touch24.png",
|
||||
|
@@ -136,6 +136,20 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSceneExtension(
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.AddParameter("yesorno", _("Deactivate input when focus is lost"))
|
||||
.MarkAsAdvanced();
|
||||
|
||||
extension
|
||||
.AddCondition(
|
||||
"HasGameJustResumed",
|
||||
_("Game has just resumed"),
|
||||
_("Check if the game has just resumed from being hidden. It "
|
||||
"happens when the game tab is selected, a minimized window is "
|
||||
"restored or the application is put back on front."),
|
||||
_("Game has just resumed"),
|
||||
"",
|
||||
"res/actions/window24.png",
|
||||
"res/actions/window.png")
|
||||
.SetHelpPath("/interface/scene-editor/events")
|
||||
.AddCodeOnlyParameter("currentScene", "");
|
||||
}
|
||||
|
||||
} // namespace gd
|
||||
|
@@ -183,6 +183,26 @@ BuiltinExtensionsImplementer::ImplementsStringInstructionsExtension(
|
||||
_("Position of the last character in the string to be "
|
||||
"considered in the search"));
|
||||
|
||||
extension
|
||||
.AddStrExpression("StrReplaceOne",
|
||||
_("Replace the first occurrence of a text by another."),
|
||||
_("Replace the first occurrence of a text by another."),
|
||||
"",
|
||||
"res/conditions/toujours24_black.png")
|
||||
.AddParameter("string", _("Text in which the replacement must be done"))
|
||||
.AddParameter("string", _("Text to find inside the first text"))
|
||||
.AddParameter("string", _("Replacement to put instead of the text to find"));
|
||||
|
||||
extension
|
||||
.AddStrExpression("StrReplaceAll",
|
||||
_("Replace all occurrences of a text by another."),
|
||||
_("Replace all occurrences of a text by another."),
|
||||
"",
|
||||
"res/conditions/toujours24_black.png")
|
||||
.AddParameter("string", _("Text in which the replacement(s) must be done"))
|
||||
.AddParameter("string", _("Text to find inside the first text"))
|
||||
.AddParameter("string", _("Replacement to put instead of the text to find"));
|
||||
|
||||
}
|
||||
|
||||
} // namespace gd
|
||||
|
@@ -151,7 +151,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsTimeExtension(
|
||||
|
||||
extension
|
||||
.AddAction("Wait",
|
||||
_("Wait X seconds (experimental)"),
|
||||
_("Wait X seconds"),
|
||||
_("Waits a number of seconds before running "
|
||||
"the next actions (and sub-events)."),
|
||||
_("Wait _PARAM0_ seconds"),
|
||||
|
@@ -46,7 +46,7 @@ class GD_CORE_API ObjectMetadata {
|
||||
std::shared_ptr<gd::ObjectConfiguration> blueprintObject_);
|
||||
/**
|
||||
* \brief Construct an object metadata, without "blueprint" object
|
||||
*
|
||||
*
|
||||
* \note This is used by events based objects.
|
||||
*/
|
||||
ObjectMetadata(const gd::String& extensionNamespace_,
|
||||
@@ -295,6 +295,22 @@ class GD_CORE_API ObjectMetadata {
|
||||
*/
|
||||
std::map<gd::String, gd::ExpressionMetadata>& GetAllStrExpressions() { return strExpressionsInfos; };
|
||||
|
||||
/**
|
||||
* \brief Set the object to be hidden in the IDE.
|
||||
*
|
||||
* Used mainly when an object is deprecated.
|
||||
*/
|
||||
ObjectMetadata &SetHidden() {
|
||||
hidden = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Return true if the instruction must be hidden in the IDE.
|
||||
*/
|
||||
bool IsHidden() const { return hidden; }
|
||||
|
||||
std::map<gd::String, gd::InstructionMetadata> conditionsInfos;
|
||||
std::map<gd::String, gd::InstructionMetadata> actionsInfos;
|
||||
std::map<gd::String, gd::ExpressionMetadata> expressionsInfos;
|
||||
@@ -314,6 +330,7 @@ class GD_CORE_API ObjectMetadata {
|
||||
gd::String iconFilename;
|
||||
gd::String categoryFullName;
|
||||
std::set<gd::String> unsupportedBaseObjectCapabilities;
|
||||
bool hidden = false;
|
||||
|
||||
std::shared_ptr<gd::ObjectConfiguration>
|
||||
blueprintObject; ///< The "blueprint" object to be copied when a new
|
||||
|
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "GDCore/Events/Instruction.h"
|
||||
#include "GDCore/Extensions/Metadata/MetadataProvider.h"
|
||||
#include "GDCore/Extensions/Metadata/ParameterMetadataTools.h"
|
||||
#include "GDCore/Extensions/PlatformExtension.h"
|
||||
#include "GDCore/IDE/WholeProjectRefactorer.h"
|
||||
#include "GDCore/IDE/Events/ExpressionTypeFinder.h"
|
||||
@@ -11,30 +12,36 @@
|
||||
|
||||
namespace gd {
|
||||
|
||||
std::set<gd::String> UsedExtensionsFinder::ScanProject(gd::Project& project) {
|
||||
const UsedExtensionsResult UsedExtensionsFinder::ScanProject(gd::Project& project) {
|
||||
UsedExtensionsFinder worker(project);
|
||||
gd::WholeProjectRefactorer::ExposeProjectObjects(project, worker);
|
||||
gd::WholeProjectRefactorer::ExposeProjectEvents(project, worker);
|
||||
return worker.usedExtensions;
|
||||
return worker.result;
|
||||
};
|
||||
|
||||
// Objects scanner
|
||||
|
||||
void UsedExtensionsFinder::DoVisitObject(gd::Object& object) {
|
||||
usedExtensions.insert(gd::MetadataProvider::GetExtensionAndObjectMetadata(
|
||||
project.GetCurrentPlatform(), object.GetType())
|
||||
.GetExtension()
|
||||
.GetName());
|
||||
void UsedExtensionsFinder::DoVisitObject(gd::Object &object) {
|
||||
auto metadata = gd::MetadataProvider::GetExtensionAndObjectMetadata(
|
||||
project.GetCurrentPlatform(), object.GetType());
|
||||
result.GetUsedExtensions().insert(metadata.GetExtension().GetName());
|
||||
for (auto &&includeFile : metadata.GetMetadata().includeFiles) {
|
||||
result.GetUsedIncludeFiles().insert(includeFile);
|
||||
}
|
||||
};
|
||||
|
||||
// Behaviors scanner
|
||||
|
||||
void UsedExtensionsFinder::DoVisitBehavior(gd::Behavior& behavior) {
|
||||
usedExtensions.insert(
|
||||
gd::MetadataProvider::GetExtensionAndBehaviorMetadata(
|
||||
project.GetCurrentPlatform(), behavior.GetTypeName())
|
||||
.GetExtension()
|
||||
.GetName());
|
||||
void UsedExtensionsFinder::DoVisitBehavior(gd::Behavior &behavior) {
|
||||
auto metadata = gd::MetadataProvider::GetExtensionAndBehaviorMetadata(
|
||||
project.GetCurrentPlatform(), behavior.GetTypeName());
|
||||
result.GetUsedExtensions().insert(metadata.GetExtension().GetName());
|
||||
for (auto &&includeFile : metadata.GetMetadata().includeFiles) {
|
||||
result.GetUsedIncludeFiles().insert(includeFile);
|
||||
}
|
||||
for (auto &&includeFile : metadata.GetMetadata().requiredFiles) {
|
||||
result.GetUsedRequiredFiles().insert(includeFile);
|
||||
}
|
||||
};
|
||||
|
||||
// Instructions scanner
|
||||
@@ -46,23 +53,29 @@ bool UsedExtensionsFinder::DoVisitInstruction(gd::Instruction& instruction,
|
||||
project.GetCurrentPlatform(), instruction.GetType())
|
||||
: gd::MetadataProvider::GetExtensionAndActionMetadata(
|
||||
project.GetCurrentPlatform(), instruction.GetType());
|
||||
usedExtensions.insert(metadata.GetExtension().GetName());
|
||||
result.GetUsedExtensions().insert(metadata.GetExtension().GetName());
|
||||
for (auto&& includeFile : metadata.GetMetadata().GetIncludeFiles()) {
|
||||
result.GetUsedIncludeFiles().insert(includeFile);
|
||||
}
|
||||
|
||||
size_t i = 0;
|
||||
for (auto expression : instruction.GetParameters()) {
|
||||
const gd::String& parameterType =
|
||||
metadata.GetMetadata().GetParameter(i).GetType();
|
||||
i++;
|
||||
gd::ParameterMetadataTools::IterateOverParameters(
|
||||
instruction.GetParameters(),
|
||||
metadata.GetMetadata().GetParameters(),
|
||||
[this](const gd::ParameterMetadata& parameterMetadata,
|
||||
const gd::Expression& parameterValue,
|
||||
const gd::String& lastObjectName) {
|
||||
const gd::String& parameterType = parameterMetadata.GetType();
|
||||
|
||||
if (gd::ParameterMetadata::IsExpression("string", parameterType)) {
|
||||
rootType = "string";
|
||||
expression.GetRootNode()->Visit(*this);
|
||||
parameterValue.GetRootNode()->Visit(*this);
|
||||
} else if (gd::ParameterMetadata::IsExpression("number", parameterType)) {
|
||||
rootType = "number";
|
||||
expression.GetRootNode()->Visit(*this);
|
||||
parameterValue.GetRootNode()->Visit(*this);
|
||||
} else if (gd::ParameterMetadata::IsExpression("variable", parameterType))
|
||||
usedExtensions.insert("BuiltinVariables");
|
||||
}
|
||||
result.GetUsedExtensions().insert("BuiltinVariables");
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -93,31 +106,35 @@ void UsedExtensionsFinder::OnVisitUnaryOperatorNode(UnaryOperatorNode& node) {
|
||||
|
||||
// Add variable extension and visit sub-expressions on variable nodes
|
||||
void UsedExtensionsFinder::OnVisitVariableNode(VariableNode& node) {
|
||||
usedExtensions.insert("BuiltinVariables");
|
||||
result.GetUsedExtensions().insert("BuiltinVariables");
|
||||
if (node.child) node.child->Visit(*this);
|
||||
};
|
||||
|
||||
void UsedExtensionsFinder::OnVisitVariableAccessorNode(
|
||||
VariableAccessorNode& node) {
|
||||
usedExtensions.insert("BuiltinVariables");
|
||||
result.GetUsedExtensions().insert("BuiltinVariables");
|
||||
if (node.child) node.child->Visit(*this);
|
||||
};
|
||||
|
||||
void UsedExtensionsFinder::OnVisitVariableBracketAccessorNode(
|
||||
VariableBracketAccessorNode& node) {
|
||||
usedExtensions.insert("BuiltinVariables");
|
||||
result.GetUsedExtensions().insert("BuiltinVariables");
|
||||
node.expression->Visit(*this);
|
||||
if (node.child) node.child->Visit(*this);
|
||||
};
|
||||
|
||||
// Add extensions bound to Objects/Behaviors/Functions
|
||||
void UsedExtensionsFinder::OnVisitIdentifierNode(IdentifierNode& node) {
|
||||
auto type = gd::ExpressionTypeFinder::GetType(project.GetCurrentPlatform(), GetGlobalObjectsContainer(), GetObjectsContainer(), rootType, node);
|
||||
void UsedExtensionsFinder::OnVisitIdentifierNode(IdentifierNode &node) {
|
||||
auto type = gd::ExpressionTypeFinder::GetType(
|
||||
project.GetCurrentPlatform(), GetGlobalObjectsContainer(),
|
||||
GetObjectsContainer(), rootType, node);
|
||||
if (gd::ParameterMetadata::IsObject(type)) {
|
||||
usedExtensions.insert(gd::MetadataProvider::GetExtensionAndObjectMetadata(
|
||||
project.GetCurrentPlatform(), node.identifierName)
|
||||
.GetExtension()
|
||||
.GetName());
|
||||
auto metadata = gd::MetadataProvider::GetExtensionAndObjectMetadata(
|
||||
project.GetCurrentPlatform(), node.identifierName);
|
||||
result.GetUsedExtensions().insert(metadata.GetExtension().GetName());
|
||||
for (auto &&includeFile : metadata.GetMetadata().includeFiles) {
|
||||
result.GetUsedIncludeFiles().insert(includeFile);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -138,7 +155,10 @@ void UsedExtensionsFinder::OnVisitFunctionCallNode(FunctionCallNode& node) {
|
||||
return;
|
||||
}
|
||||
|
||||
usedExtensions.insert(metadata.GetExtension().GetName());
|
||||
result.GetUsedExtensions().insert(metadata.GetExtension().GetName());
|
||||
for (auto&& includeFile : metadata.GetMetadata().GetIncludeFiles()) {
|
||||
result.GetUsedIncludeFiles().insert(includeFile);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace gd
|
||||
|
@@ -21,18 +21,62 @@ class Behavior;
|
||||
|
||||
namespace gd {
|
||||
|
||||
class GD_CORE_API UsedExtensionsResult {
|
||||
public:
|
||||
/**
|
||||
* The extensions used by the project (or part of it).
|
||||
*/
|
||||
const std::set<gd::String> &GetUsedExtensions() const {
|
||||
return usedExtensions;
|
||||
}
|
||||
|
||||
/**
|
||||
* The include files used at runtime by the project (or part of it).
|
||||
*/
|
||||
const std::set<gd::String> &GetUsedIncludeFiles() const {
|
||||
return usedIncludeFiles;
|
||||
}
|
||||
|
||||
/**
|
||||
* The additional files required at runtime by the project (or part of it).
|
||||
*/
|
||||
const std::set<gd::String> &GetUsedRequiredFiles() const {
|
||||
return usedRequiredFiles;
|
||||
}
|
||||
|
||||
/**
|
||||
* The extensions used by the project (or part of it).
|
||||
*/
|
||||
std::set<gd::String> &GetUsedExtensions() { return usedExtensions; }
|
||||
|
||||
/**
|
||||
* The include files used at runtime by the project (or part of it).
|
||||
*/
|
||||
std::set<gd::String> &GetUsedIncludeFiles() { return usedIncludeFiles; }
|
||||
|
||||
/**
|
||||
* The additional files required at runtime by the project (or part of it).
|
||||
*/
|
||||
std::set<gd::String> &GetUsedRequiredFiles() { return usedRequiredFiles; }
|
||||
|
||||
private:
|
||||
std::set<gd::String> usedExtensions;
|
||||
std::set<gd::String> usedIncludeFiles;
|
||||
std::set<gd::String> usedRequiredFiles;
|
||||
};
|
||||
|
||||
class GD_CORE_API UsedExtensionsFinder
|
||||
: public ArbitraryObjectsWorker,
|
||||
public ArbitraryEventsWorkerWithContext,
|
||||
public ExpressionParser2NodeWorker {
|
||||
public:
|
||||
static std::set<gd::String> ScanProject(gd::Project& project);
|
||||
static const UsedExtensionsResult ScanProject(gd::Project& project);
|
||||
|
||||
private:
|
||||
UsedExtensionsFinder(gd::Project& project_) : project(project_){};
|
||||
gd::Project& project;
|
||||
gd::String rootType;
|
||||
std::set<gd::String> usedExtensions;
|
||||
UsedExtensionsResult result;
|
||||
|
||||
// Object Visitor
|
||||
void DoVisitObject(gd::Object& object) override;
|
||||
|
@@ -35,6 +35,16 @@ void ArbitraryResourceWorker::ExposeJson(gd::String& jsonName){
|
||||
// do.
|
||||
};
|
||||
|
||||
void ArbitraryResourceWorker::ExposeTilemap(gd::String& tilemapName){
|
||||
// Nothing to do by default - each child class can define here the action to
|
||||
// do.
|
||||
};
|
||||
|
||||
void ArbitraryResourceWorker::ExposeTileset(gd::String& tilesetName){
|
||||
// Nothing to do by default - each child class can define here the action to
|
||||
// do.
|
||||
};
|
||||
|
||||
void ArbitraryResourceWorker::ExposeVideo(gd::String& videoName){
|
||||
// Nothing to do by default - each child class can define here the action to
|
||||
// do.
|
||||
@@ -92,6 +102,67 @@ void ArbitraryResourceWorker::ExposeResources(
|
||||
}
|
||||
}
|
||||
|
||||
void ArbitraryResourceWorker::ExposeEmbeddeds(gd::String& resourceName) {
|
||||
if (resourcesManagers.empty()) return;
|
||||
gd::ResourcesManager* resourcesManager = resourcesManagers[0];
|
||||
|
||||
gd::Resource& resource = resourcesManager->GetResource(resourceName);
|
||||
|
||||
if (!resource.GetMetadata().empty()) {
|
||||
gd::SerializerElement serializerElement =
|
||||
gd::Serializer::FromJSON(resource.GetMetadata());
|
||||
|
||||
if (serializerElement.HasChild("embeddedResourcesMapping")) {
|
||||
bool anyEmbeddedResourceNameWasRenamed = false;
|
||||
gd::SerializerElement& embeddedResourcesMappingElement =
|
||||
serializerElement.GetChild("embeddedResourcesMapping");
|
||||
|
||||
for (const auto& child :
|
||||
embeddedResourcesMappingElement.GetAllChildren()) {
|
||||
const gd::String& targetResourceName =
|
||||
child.second->GetValue().GetString();
|
||||
|
||||
if (resourcesManager->HasResource(targetResourceName)) {
|
||||
std::cout << targetResourceName << std::endl;
|
||||
gd::Resource& targetResource =
|
||||
resourcesManager->GetResource(targetResourceName);
|
||||
const gd::String& targetResourceKind = targetResource.GetKind();
|
||||
|
||||
gd::String potentiallyUpdatedTargetResourceName = targetResourceName;
|
||||
|
||||
if (targetResourceKind == "audio") {
|
||||
ExposeAudio(potentiallyUpdatedTargetResourceName);
|
||||
} else if (targetResourceKind == "bitmapFont") {
|
||||
ExposeBitmapFont(potentiallyUpdatedTargetResourceName);
|
||||
} else if (targetResourceKind == "font") {
|
||||
ExposeFont(potentiallyUpdatedTargetResourceName);
|
||||
} else if (targetResourceKind == "image") {
|
||||
ExposeImage(potentiallyUpdatedTargetResourceName);
|
||||
} else if (targetResourceKind == "json") {
|
||||
ExposeJson(potentiallyUpdatedTargetResourceName);
|
||||
} else if (targetResourceKind == "tilemap") {
|
||||
ExposeTilemap(potentiallyUpdatedTargetResourceName);
|
||||
} else if (targetResourceKind == "tileset") {
|
||||
ExposeTileset(potentiallyUpdatedTargetResourceName);
|
||||
} else if (targetResourceKind == "video") {
|
||||
ExposeVideo(potentiallyUpdatedTargetResourceName);
|
||||
}
|
||||
|
||||
if (potentiallyUpdatedTargetResourceName != targetResourceName) {
|
||||
// The resource name was renamed. Also update the mapping.
|
||||
child.second->SetStringValue(potentiallyUpdatedTargetResourceName);
|
||||
anyEmbeddedResourceNameWasRenamed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (anyEmbeddedResourceNameWasRenamed) {
|
||||
resource.SetMetadata(gd::Serializer::ToJSON(serializerElement));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ArbitraryResourceWorker::ExposeResource(gd::Resource& resource) {
|
||||
if (!resource.UseFile()) return;
|
||||
|
||||
@@ -154,6 +225,14 @@ class ResourceWorkerInEventsWorker : public ArbitraryEventsWorker {
|
||||
gd::String updatedParameterValue = parameterValue;
|
||||
worker.ExposeJson(updatedParameterValue);
|
||||
instruction.SetParameter(parameterIndex, updatedParameterValue);
|
||||
} else if (parameterMetadata.GetType() == "tilemapResource") {
|
||||
gd::String updatedParameterValue = parameterValue;
|
||||
worker.ExposeTilemap(updatedParameterValue);
|
||||
instruction.SetParameter(parameterIndex, updatedParameterValue);
|
||||
} else if (parameterMetadata.GetType() == "tilesetResource") {
|
||||
gd::String updatedParameterValue = parameterValue;
|
||||
worker.ExposeTileset(updatedParameterValue);
|
||||
instruction.SetParameter(parameterIndex, updatedParameterValue);
|
||||
}
|
||||
});
|
||||
|
||||
|
@@ -75,6 +75,16 @@ class GD_CORE_API ArbitraryResourceWorker {
|
||||
*/
|
||||
virtual void ExposeJson(gd::String &jsonName);
|
||||
|
||||
/**
|
||||
* \brief Expose a Tilemap, which is always a reference to a "tilemap" resource.
|
||||
*/
|
||||
virtual void ExposeTilemap(gd::String &tilemapName);
|
||||
|
||||
/**
|
||||
* \brief Expose a Tileset, which is always a reference to a "tileset" resource.
|
||||
*/
|
||||
virtual void ExposeTileset(gd::String &tilesetName);
|
||||
|
||||
/**
|
||||
* \brief Expose a video, which is always a reference to a "video" resource.
|
||||
*/
|
||||
@@ -96,6 +106,11 @@ class GD_CORE_API ArbitraryResourceWorker {
|
||||
*/
|
||||
virtual void ExposeFile(gd::String &resourceFileName) = 0;
|
||||
|
||||
/**
|
||||
* \brief Expose the embedded resources of the specified resource.
|
||||
*/
|
||||
virtual void ExposeEmbeddeds(gd::String &resourceName);
|
||||
|
||||
protected:
|
||||
const std::vector<gd::ResourcesManager *> &GetResources() {
|
||||
return resourcesManagers;
|
||||
|
@@ -40,6 +40,8 @@ class ResourcesInUseHelper : public gd::ArbitraryResourceWorker {
|
||||
std::set<gd::String>& GetAllAudios() { return GetAll("audio"); };
|
||||
std::set<gd::String>& GetAllFonts() { return GetAll("font"); };
|
||||
std::set<gd::String>& GetAllJsons() { return GetAll("json"); };
|
||||
std::set<gd::String>& GetAllTilemaps() { return GetAll("tilemap"); };
|
||||
std::set<gd::String>& GetAllTilesets() { return GetAll("tileset"); };
|
||||
std::set<gd::String>& GetAllVideos() { return GetAll("video"); };
|
||||
std::set<gd::String>& GetAllBitmapFonts() { return GetAll("bitmapFont"); };
|
||||
std::set<gd::String>& GetAll(const gd::String& resourceType) {
|
||||
@@ -47,6 +49,8 @@ class ResourcesInUseHelper : public gd::ArbitraryResourceWorker {
|
||||
if (resourceType == "audio") return allAudios;
|
||||
if (resourceType == "font") return allFonts;
|
||||
if (resourceType == "json") return allJsons;
|
||||
if (resourceType == "tilemap") return allTilemaps;
|
||||
if (resourceType == "tileset") return allTilesets;
|
||||
if (resourceType == "video") return allVideos;
|
||||
if (resourceType == "bitmapFont") return allBitmapFonts;
|
||||
|
||||
@@ -68,6 +72,12 @@ class ResourcesInUseHelper : public gd::ArbitraryResourceWorker {
|
||||
virtual void ExposeJson(gd::String& jsonResourceName) override {
|
||||
allJsons.insert(jsonResourceName);
|
||||
};
|
||||
virtual void ExposeTilemap(gd::String& tilemapResourceName) override {
|
||||
allTilemaps.insert(tilemapResourceName);
|
||||
};
|
||||
virtual void ExposeTileset(gd::String& tilesetResourceName) override {
|
||||
allTilesets.insert(tilesetResourceName);
|
||||
};
|
||||
virtual void ExposeVideo(gd::String& videoResourceName) override {
|
||||
allVideos.insert(videoResourceName);
|
||||
};
|
||||
@@ -80,6 +90,8 @@ class ResourcesInUseHelper : public gd::ArbitraryResourceWorker {
|
||||
std::set<gd::String> allAudios;
|
||||
std::set<gd::String> allFonts;
|
||||
std::set<gd::String> allJsons;
|
||||
std::set<gd::String> allTilemaps;
|
||||
std::set<gd::String> allTilesets;
|
||||
std::set<gd::String> allVideos;
|
||||
std::set<gd::String> allBitmapFonts;
|
||||
std::set<gd::String> emptyResources;
|
||||
|
@@ -49,6 +49,12 @@ class ResourcesRenamer : public gd::ArbitraryResourceWorker {
|
||||
virtual void ExposeJson(gd::String& jsonResourceName) override {
|
||||
RenameIfNeeded(jsonResourceName);
|
||||
};
|
||||
virtual void ExposeTilemap(gd::String& tilemapResourceName) override {
|
||||
RenameIfNeeded(tilemapResourceName);
|
||||
};
|
||||
virtual void ExposeTileset(gd::String& tilesetResourceName) override {
|
||||
RenameIfNeeded(tilesetResourceName);
|
||||
};
|
||||
virtual void ExposeVideo(gd::String& videoResourceName) override {
|
||||
RenameIfNeeded(videoResourceName);
|
||||
};
|
||||
|
@@ -12,6 +12,7 @@
|
||||
#include "GDCore/Project/EventsBasedBehavior.h"
|
||||
#include "GDCore/Project/EventsBasedObject.h"
|
||||
#include "GDCore/Project/EventsFunctionsExtension.h"
|
||||
#include "GDCore/Project/EventsFunction.h"
|
||||
#include "GDCore/Project/Project.h"
|
||||
#include "GDCore/Project/PropertyDescriptor.h"
|
||||
#include "GDCore/String.h"
|
||||
@@ -298,4 +299,16 @@ PropertyFunctionGenerator::UnCapitalizeFirstLetter(const gd::String &string) {
|
||||
return string.substr(0, 1).LowerCase() + string.substr(1);
|
||||
}
|
||||
|
||||
void PropertyFunctionGenerator::GenerateConditionSkeleton(
|
||||
gd::Project &project, gd::EventsFunction &eventFunction) {
|
||||
auto &event = dynamic_cast<gd::StandardEvent &>(
|
||||
eventFunction.GetEvents().InsertNewEvent(
|
||||
project, "BuiltinCommonInstructions::Standard", 0));
|
||||
|
||||
gd::Instruction action;
|
||||
action.SetType("SetReturnBoolean");
|
||||
action.AddParameter("True");
|
||||
event.GetActions().Insert(action, 0);
|
||||
}
|
||||
|
||||
} // namespace gd
|
||||
|
@@ -10,6 +10,7 @@ namespace gd {
|
||||
class String;
|
||||
class Project;
|
||||
class EventsFunctionsExtension;
|
||||
class EventsFunction;
|
||||
class EventsBasedBehavior;
|
||||
class EventsBasedObject;
|
||||
class AbstractEventsBasedEntity;
|
||||
@@ -43,6 +44,12 @@ public:
|
||||
const gd::AbstractEventsBasedEntity &eventsBasedEntity,
|
||||
const gd::NamedPropertyDescriptor &property);
|
||||
|
||||
/**
|
||||
* \brief Generate an event with a "return" action.
|
||||
*/
|
||||
static void GenerateConditionSkeleton(gd::Project &project,
|
||||
gd::EventsFunction &eventFunction);
|
||||
|
||||
~PropertyFunctionGenerator();
|
||||
|
||||
private:
|
||||
|
@@ -125,6 +125,11 @@ class GD_CORE_API AbstractEventsBasedEntity {
|
||||
*/
|
||||
static gd::String GetPropertyExpressionName(const gd::String& propertyName) { return "Property" + propertyName; };
|
||||
|
||||
/**
|
||||
* \brief Get the name of the action to toggle a boolean property.
|
||||
*/
|
||||
static gd::String GetPropertyToggleActionName(const gd::String& propertyName) { return "ToggleProperty" + propertyName; };
|
||||
|
||||
/** \name Serialization
|
||||
*/
|
||||
///@{
|
||||
|
@@ -38,7 +38,7 @@ gd::ObjectConfiguration &CustomObjectConfiguration::GetChildObjectConfiguration(
|
||||
return badObjectConfiguration;
|
||||
}
|
||||
const auto &eventsBasedObject = project->GetEventsBasedObject(GetType());
|
||||
|
||||
|
||||
if (!eventsBasedObject.HasObjectNamed(objectName)) {
|
||||
gd::LogError("Tried to get the configuration of a child-object:" + objectName
|
||||
+ " that doesn't exist in the event-based object: " + GetType());
|
||||
@@ -78,7 +78,7 @@ bool CustomObjectConfiguration::UpdateProperty(const gd::String& propertyName,
|
||||
}
|
||||
const auto &eventsBasedObject = project->GetEventsBasedObject(GetType());
|
||||
const auto &properties = eventsBasedObject.GetPropertyDescriptors();
|
||||
|
||||
|
||||
return gd::CustomConfigurationHelper::UpdateProperty(
|
||||
properties,
|
||||
objectContent,
|
||||
@@ -125,8 +125,7 @@ void CustomObjectConfiguration::DoUnserializeFrom(Project& project,
|
||||
}
|
||||
}
|
||||
|
||||
void CustomObjectConfiguration::ExposeResources(
|
||||
gd::ArbitraryResourceWorker& worker) {
|
||||
void CustomObjectConfiguration::ExposeResources(gd::ArbitraryResourceWorker& worker) {
|
||||
std::map<gd::String, gd::PropertyDescriptor> properties = GetProperties();
|
||||
|
||||
for (auto& property : properties) {
|
||||
@@ -148,6 +147,10 @@ void CustomObjectConfiguration::ExposeResources(
|
||||
worker.ExposeVideo(newPropertyValue);
|
||||
} else if (resourceType == "json") {
|
||||
worker.ExposeJson(newPropertyValue);
|
||||
} else if (resourceType == "tilemap") {
|
||||
worker.ExposeTilemap(newPropertyValue);
|
||||
} else if (resourceType == "tileset") {
|
||||
worker.ExposeTileset(newPropertyValue);
|
||||
} else if (resourceType == "bitmapFont") {
|
||||
worker.ExposeBitmapFont(newPropertyValue);
|
||||
}
|
||||
|
@@ -87,9 +87,9 @@ class CustomObjectConfiguration : public gd::ObjectConfiguration {
|
||||
/**
|
||||
* Initialize configuration using another configuration. Used by copy-ctor
|
||||
* and assign-op.
|
||||
*
|
||||
*
|
||||
* Don't forget to update me if members were changed!
|
||||
*
|
||||
*
|
||||
* It's needed because there is no default copy for childObjectConfigurations
|
||||
* and it must be a deep copy.
|
||||
*/
|
||||
|
@@ -125,6 +125,13 @@ class GD_CORE_API EventsBasedBehavior: public AbstractEventsBasedEntity {
|
||||
return "SharedProperty" + propertyName;
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Get the name of the action to toggle a boolean shared property.
|
||||
*/
|
||||
static gd::String GetSharedPropertyToggleActionName(const gd::String &propertyName) {
|
||||
return "ToggleSharedProperty" + propertyName;
|
||||
};
|
||||
|
||||
void SerializeTo(SerializerElement& element) const override;
|
||||
|
||||
void UnserializeFrom(gd::Project& project,
|
||||
|
@@ -12,6 +12,7 @@
|
||||
|
||||
#include "GDCore/Project/Behavior.h"
|
||||
#include "GDCore/Project/EffectsContainer.h"
|
||||
#include "GDCore/Project/ResourcesManager.h"
|
||||
#include "GDCore/Project/VariablesContainer.h"
|
||||
#include "GDCore/String.h"
|
||||
#include "GDCore/Tools/MakeUnique.h"
|
||||
|
@@ -982,8 +982,10 @@ void Project::ExposeResources(gd::ArbitraryResourceWorker& worker) {
|
||||
// (this time for effects). Ideally, this method could be moved outside of
|
||||
// gd::Project.
|
||||
|
||||
gd::ResourcesManager* resourcesManager = &GetResourcesManager();
|
||||
|
||||
// Add project resources
|
||||
worker.ExposeResources(&GetResourcesManager());
|
||||
worker.ExposeResources(resourcesManager);
|
||||
platformSpecificAssets.ExposeResources(worker);
|
||||
|
||||
// Add layouts resources
|
||||
|
@@ -85,6 +85,10 @@ std::shared_ptr<Resource> ResourcesManager::CreateResource(
|
||||
return std::make_shared<VideoResource>();
|
||||
else if (kind == "json")
|
||||
return std::make_shared<JsonResource>();
|
||||
else if (kind == "tilemap")
|
||||
return std::make_shared<TilemapResource>();
|
||||
else if (kind == "tileset")
|
||||
return std::make_shared<TilesetResource>();
|
||||
else if (kind == "bitmapFont")
|
||||
return std::make_shared<BitmapFontResource>();
|
||||
|
||||
@@ -650,6 +654,74 @@ bool JsonResource::UpdateProperty(const gd::String& name,
|
||||
return true;
|
||||
}
|
||||
|
||||
void TilemapResource::SetFile(const gd::String& newFile) {
|
||||
file = NormalizePathSeparator(newFile);
|
||||
}
|
||||
|
||||
void TilemapResource::UnserializeFrom(const SerializerElement& element) {
|
||||
SetUserAdded(element.GetBoolAttribute("userAdded"));
|
||||
SetFile(element.GetStringAttribute("file"));
|
||||
DisablePreload(element.GetBoolAttribute("disablePreload", false));
|
||||
}
|
||||
|
||||
void TilemapResource::SerializeTo(SerializerElement& element) const {
|
||||
element.SetAttribute("userAdded", IsUserAdded());
|
||||
element.SetAttribute("file", GetFile());
|
||||
element.SetAttribute("disablePreload", IsPreloadDisabled());
|
||||
}
|
||||
|
||||
std::map<gd::String, gd::PropertyDescriptor> TilemapResource::GetProperties()
|
||||
const {
|
||||
std::map<gd::String, gd::PropertyDescriptor> properties;
|
||||
properties["disablePreload"]
|
||||
.SetValue(disablePreload ? "true" : "false")
|
||||
.SetType("Boolean")
|
||||
.SetLabel(_("Disable preloading at game startup"));
|
||||
|
||||
return properties;
|
||||
}
|
||||
|
||||
bool TilemapResource::UpdateProperty(const gd::String& name,
|
||||
const gd::String& value) {
|
||||
if (name == "disablePreload") disablePreload = value == "1";
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void TilesetResource::SetFile(const gd::String& newFile) {
|
||||
file = NormalizePathSeparator(newFile);
|
||||
}
|
||||
|
||||
void TilesetResource::UnserializeFrom(const SerializerElement& element) {
|
||||
SetUserAdded(element.GetBoolAttribute("userAdded"));
|
||||
SetFile(element.GetStringAttribute("file"));
|
||||
DisablePreload(element.GetBoolAttribute("disablePreload", false));
|
||||
}
|
||||
|
||||
void TilesetResource::SerializeTo(SerializerElement& element) const {
|
||||
element.SetAttribute("userAdded", IsUserAdded());
|
||||
element.SetAttribute("file", GetFile());
|
||||
element.SetAttribute("disablePreload", IsPreloadDisabled());
|
||||
}
|
||||
|
||||
std::map<gd::String, gd::PropertyDescriptor> TilesetResource::GetProperties()
|
||||
const {
|
||||
std::map<gd::String, gd::PropertyDescriptor> properties;
|
||||
properties["disablePreload"]
|
||||
.SetValue(disablePreload ? "true" : "false")
|
||||
.SetType("Boolean")
|
||||
.SetLabel(_("Disable preloading at game startup"));
|
||||
|
||||
return properties;
|
||||
}
|
||||
|
||||
bool TilesetResource::UpdateProperty(const gd::String& name,
|
||||
const gd::String& value) {
|
||||
if (name == "disablePreload") disablePreload = value == "1";
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void BitmapFontResource::SetFile(const gd::String& newFile) {
|
||||
file = NormalizePathSeparator(newFile);
|
||||
}
|
||||
|
@@ -373,6 +373,88 @@ class GD_CORE_API JsonResource : public Resource {
|
||||
gd::String file;
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Describe a tilemap file used by a project.
|
||||
*
|
||||
* \see Resource
|
||||
* \ingroup ResourcesManagement
|
||||
*/
|
||||
class GD_CORE_API TilemapResource : public Resource {
|
||||
public:
|
||||
TilemapResource() : Resource(), disablePreload(false) { SetKind("tilemap"); };
|
||||
virtual ~TilemapResource(){};
|
||||
virtual TilemapResource* Clone() const override {
|
||||
return new TilemapResource(*this);
|
||||
}
|
||||
|
||||
virtual const gd::String& GetFile() const override { return file; };
|
||||
virtual void SetFile(const gd::String& newFile) override;
|
||||
|
||||
virtual bool UseFile() const override { return true; }
|
||||
|
||||
std::map<gd::String, gd::PropertyDescriptor> GetProperties() const override;
|
||||
bool UpdateProperty(const gd::String& name, const gd::String& value) override;
|
||||
|
||||
void SerializeTo(SerializerElement& element) const override;
|
||||
|
||||
void UnserializeFrom(const SerializerElement& element) override;
|
||||
|
||||
/**
|
||||
* \brief Return true if the loading at game startup must be disabled
|
||||
*/
|
||||
bool IsPreloadDisabled() const { return disablePreload; }
|
||||
|
||||
/**
|
||||
* \brief Set if the tilemap preload at game startup must be disabled
|
||||
*/
|
||||
void DisablePreload(bool disable = true) { disablePreload = disable; }
|
||||
|
||||
private:
|
||||
bool disablePreload; ///< If "true", don't load the tilemap at game startup
|
||||
gd::String file;
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Describe a tileset file used by a project.
|
||||
*
|
||||
* \see Resource
|
||||
* \ingroup ResourcesManagement
|
||||
*/
|
||||
class GD_CORE_API TilesetResource : public Resource {
|
||||
public:
|
||||
TilesetResource() : Resource(), disablePreload(false) { SetKind("tileset"); };
|
||||
virtual ~TilesetResource(){};
|
||||
virtual TilesetResource* Clone() const override {
|
||||
return new TilesetResource(*this);
|
||||
}
|
||||
|
||||
virtual const gd::String& GetFile() const override { return file; };
|
||||
virtual void SetFile(const gd::String& newFile) override;
|
||||
|
||||
virtual bool UseFile() const override { return true; }
|
||||
|
||||
std::map<gd::String, gd::PropertyDescriptor> GetProperties() const override;
|
||||
bool UpdateProperty(const gd::String& name, const gd::String& value) override;
|
||||
|
||||
void SerializeTo(SerializerElement& element) const override;
|
||||
|
||||
void UnserializeFrom(const SerializerElement& element) override;
|
||||
|
||||
/**
|
||||
* \brief Return true if the loading at game startup must be disabled
|
||||
*/
|
||||
bool IsPreloadDisabled() const { return disablePreload; }
|
||||
|
||||
/**
|
||||
* \brief Set if the tilemap preload at game startup must be disabled
|
||||
*/
|
||||
void DisablePreload(bool disable = true) { disablePreload = disable; }
|
||||
|
||||
private:
|
||||
bool disablePreload; ///< If "true", don't load the tilemap at game startup
|
||||
gd::String file;
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Describe a bitmap font file used by a project.
|
||||
*
|
||||
|
@@ -187,7 +187,7 @@ void SetupProjectWithDummyPlatform(gd::Project& project,
|
||||
.SetDefaultValue("\"\"")
|
||||
.AddParameter("camera", _("Camera"), "", true)
|
||||
.SetDefaultValue("0")
|
||||
.SetFunctionName("getMouseX");
|
||||
.SetFunctionName("getCursorX");
|
||||
extension
|
||||
->AddExpression("GetGlobalVariableAsNumber",
|
||||
"Get me a global variable value",
|
||||
|
@@ -217,7 +217,7 @@ TEST_CASE("ExpressionCodeGenerator", "[common][events]") {
|
||||
REQUIRE(node);
|
||||
node->Visit(expressionCodeGenerator);
|
||||
REQUIRE(expressionCodeGenerator.GetOutput() ==
|
||||
"getMouseX(\"\", \"layer1\", 2 + 2)");
|
||||
"getCursorX(\"\", \"layer1\", 2 + 2)");
|
||||
// (first argument is the currentScene)
|
||||
}
|
||||
SECTION("with last optional parameter omit") {
|
||||
@@ -231,7 +231,7 @@ TEST_CASE("ExpressionCodeGenerator", "[common][events]") {
|
||||
REQUIRE(node);
|
||||
node->Visit(expressionCodeGenerator);
|
||||
REQUIRE(expressionCodeGenerator.GetOutput() ==
|
||||
"getMouseX(\"\", \"layer1\", 0)");
|
||||
"getCursorX(\"\", \"layer1\", 0)");
|
||||
// (first argument is the currentScene)
|
||||
}
|
||||
SECTION("with last optional parameter omit (deprecated way)") {
|
||||
@@ -245,7 +245,7 @@ TEST_CASE("ExpressionCodeGenerator", "[common][events]") {
|
||||
REQUIRE(node);
|
||||
node->Visit(expressionCodeGenerator);
|
||||
REQUIRE(expressionCodeGenerator.GetOutput() ==
|
||||
"getMouseX(\"\", \"layer1\", 0)");
|
||||
"getCursorX(\"\", \"layer1\", 0)");
|
||||
// (first argument is the currentScene)
|
||||
}
|
||||
SECTION("with explicit comma (deprecated way)") {
|
||||
@@ -258,7 +258,7 @@ TEST_CASE("ExpressionCodeGenerator", "[common][events]") {
|
||||
REQUIRE(node);
|
||||
node->Visit(expressionCodeGenerator);
|
||||
REQUIRE(expressionCodeGenerator.GetOutput() ==
|
||||
"getMouseX(\"\", \"\", 0)");
|
||||
"getCursorX(\"\", \"\", 0)");
|
||||
// (first argument is the currentScene)
|
||||
}
|
||||
}
|
||||
@@ -624,7 +624,7 @@ TEST_CASE("ExpressionCodeGenerator", "[common][events]") {
|
||||
REQUIRE(node);
|
||||
node->Visit(expressionCodeGenerator);
|
||||
REQUIRE(expressionCodeGenerator.GetOutput() ==
|
||||
"-(+(-(getMouseX(\"\", \"\", 0))))");
|
||||
"-(+(-(getCursorX(\"\", \"\", 0))))");
|
||||
// (first argument is the currentScene)
|
||||
}
|
||||
}
|
||||
|
@@ -19,15 +19,77 @@ TEST_CASE("ResourcesRenamer", "[common]") {
|
||||
gd::ResourcesRenamer resourcesRenamer(renamings);
|
||||
|
||||
gd::Project project;
|
||||
|
||||
// Add "classic", plain resources.
|
||||
gd::ImageResource resource1;
|
||||
resource1.SetName("Resource1");
|
||||
project.GetResourcesManager().AddResource(resource1);
|
||||
gd::ImageResource resource2;
|
||||
resource2.SetName("Resource2");
|
||||
project.GetResourcesManager().AddResource(resource2);
|
||||
|
||||
// Add usage of some resources.
|
||||
project.GetPlatformSpecificAssets().Set(
|
||||
"android", "some-icon", "Resource1");
|
||||
project.GetPlatformSpecificAssets().Set(
|
||||
"android", "some-other-icon", "Resource2");
|
||||
|
||||
project.ExposeResources(resourcesRenamer);
|
||||
|
||||
// Check that resources were renamed were used.
|
||||
REQUIRE(project.GetPlatformSpecificAssets().Get("android", "some-icon") ==
|
||||
"RenamedResource1");
|
||||
REQUIRE(project.GetPlatformSpecificAssets().Get(
|
||||
"android", "some-other-icon") == "Resource2");
|
||||
}
|
||||
|
||||
SECTION("It renames embedded resources") {
|
||||
std::map<gd::String, gd::String> renamings = {
|
||||
{"Resource1", "RenamedResource1"}};
|
||||
gd::ResourcesRenamer resourcesRenamer(renamings);
|
||||
|
||||
gd::Project project;
|
||||
|
||||
// Add "classic", plain resources.
|
||||
gd::ImageResource resource1;
|
||||
resource1.SetName("Resource1");
|
||||
project.GetResourcesManager().AddResource(resource1);
|
||||
gd::ImageResource resource2;
|
||||
resource2.SetName("Resource2");
|
||||
project.GetResourcesManager().AddResource(resource2);
|
||||
|
||||
// Add a resource containing a mapping to other resources.
|
||||
gd::JsonResource jsonResourceWithEmbeddeds;
|
||||
jsonResourceWithEmbeddeds.SetName("Resource3");
|
||||
jsonResourceWithEmbeddeds.SetMetadata(
|
||||
"{ \"embeddedResourcesMapping\": {\"some-resource-name\": "
|
||||
"\"Resource1\", \"some-other-resource-name\": \"Resource2\"} }");
|
||||
project.GetResourcesManager().AddResource(jsonResourceWithEmbeddeds);
|
||||
|
||||
// Add usage of some resources.
|
||||
project.GetPlatformSpecificAssets().Set(
|
||||
"android", "some-icon", "Resource1");
|
||||
project.GetPlatformSpecificAssets().Set(
|
||||
"android", "some-other-icon", "Resource2");
|
||||
|
||||
project.ExposeResources(resourcesRenamer);
|
||||
|
||||
// TODO: This should not be necessary, but for now not all resources support embeddeds,
|
||||
// so we must call it manually:
|
||||
gd::String resource3Name = "Resource3";
|
||||
resourcesRenamer.ExposeEmbeddeds(resource3Name);
|
||||
|
||||
// Check that resources were renamed were used.
|
||||
REQUIRE(project.GetPlatformSpecificAssets().Get("android", "some-icon") ==
|
||||
"RenamedResource1");
|
||||
REQUIRE(project.GetPlatformSpecificAssets().Get(
|
||||
"android", "some-other-icon") == "Resource2");
|
||||
|
||||
// Check that the names were also updated in the embedded resources mapping.
|
||||
REQUIRE(project.GetResourcesManager().HasResource("Resource3") == true);
|
||||
REQUIRE(
|
||||
project.GetResourcesManager().GetResource("Resource3").GetMetadata() ==
|
||||
"{\"embeddedResourcesMapping\":{\"some-resource-name\":"
|
||||
"\"RenamedResource1\",\"some-other-resource-name\":\"Resource2\"}}");
|
||||
}
|
||||
}
|
||||
|
@@ -28,7 +28,7 @@ module.exports = {
|
||||
extension
|
||||
.setExtensionInformation(
|
||||
'DialogueTree',
|
||||
_('Dialogue Tree (experimental)'),
|
||||
_('Dialogue Tree'),
|
||||
'Handle dialogue trees, made using Yarn Spinner. Useful to make complex dialogues with multiple choices. The Yarn Spinner editor is embedded in GDevelop so you can edit your dialogues without leaving GDevelop.',
|
||||
'Todor Imreorov',
|
||||
'Open source (MIT License)'
|
||||
@@ -36,7 +36,7 @@ module.exports = {
|
||||
.setExtensionHelpPath('/all-features/dialogue-tree')
|
||||
.setCategory('Game mechanic');
|
||||
extension
|
||||
.addInstructionOrExpressionGroupMetadata(_('Dialogue Tree (experimental)'))
|
||||
.addInstructionOrExpressionGroupMetadata(_('Dialogue Tree'))
|
||||
.setIcon('JsPlatform/Extensions/yarn32.png');
|
||||
|
||||
extension
|
||||
|
@@ -57,35 +57,18 @@ namespace gdjs {
|
||||
}
|
||||
const inputManager = instanceContainer.getGame().getInputManager();
|
||||
|
||||
//Try mouse
|
||||
const mouseDraggableManager = DraggableManager.getMouseManager(
|
||||
instanceContainer
|
||||
);
|
||||
if (
|
||||
inputManager.isMouseButtonPressed(0) &&
|
||||
!mouseDraggableManager.isDragging(this)
|
||||
) {
|
||||
if (mouseDraggableManager.tryAndTakeDragging(instanceContainer, this)) {
|
||||
this._draggedByDraggableManager = mouseDraggableManager;
|
||||
return true;
|
||||
const touchIds = inputManager.getStartedTouchIdentifiers();
|
||||
for (let i = 0; i < touchIds.length; ++i) {
|
||||
const touchDraggableManager = DraggableManager.getTouchManager(
|
||||
instanceContainer,
|
||||
touchIds[i]
|
||||
);
|
||||
if (touchDraggableManager.isDragging(this)) {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
//Try touches
|
||||
const touchIds = inputManager.getStartedTouchIdentifiers();
|
||||
for (let i = 0; i < touchIds.length; ++i) {
|
||||
const touchDraggableManager = DraggableManager.getTouchManager(
|
||||
instanceContainer,
|
||||
touchIds[i]
|
||||
);
|
||||
if (touchDraggableManager.isDragging(this)) {
|
||||
continue;
|
||||
}
|
||||
if (
|
||||
touchDraggableManager.tryAndTakeDragging(instanceContainer, this)
|
||||
) {
|
||||
this._draggedByDraggableManager = touchDraggableManager;
|
||||
return true;
|
||||
}
|
||||
if (touchDraggableManager.tryAndTakeDragging(instanceContainer, this)) {
|
||||
this._draggedByDraggableManager = touchDraggableManager;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@@ -121,14 +104,6 @@ namespace gdjs {
|
||||
}
|
||||
|
||||
doStepPostEvents(instanceContainer: gdjs.RuntimeInstanceContainer) {
|
||||
const mouseDraggableManager = DraggableManager.getMouseManager(
|
||||
instanceContainer
|
||||
);
|
||||
mouseDraggableManager.leftPressedLastFrame = instanceContainer
|
||||
.getGame()
|
||||
.getInputManager()
|
||||
.isMouseButtonPressed(0);
|
||||
|
||||
this._justDropped = false;
|
||||
}
|
||||
|
||||
@@ -144,7 +119,8 @@ namespace gdjs {
|
||||
/**
|
||||
* Handle the dragging
|
||||
*/
|
||||
abstract class DraggableManager {
|
||||
class DraggableManager {
|
||||
private _touchId: integer;
|
||||
/**
|
||||
* The object has left its original position.
|
||||
* When true, the search for the best object to drag has ended.
|
||||
@@ -157,24 +133,11 @@ namespace gdjs {
|
||||
protected _xOffset: number = 0;
|
||||
protected _yOffset: number = 0;
|
||||
|
||||
constructor(instanceContainer: gdjs.RuntimeInstanceContainer) {}
|
||||
|
||||
/**
|
||||
* Get the platforms manager of an instance container.
|
||||
*/
|
||||
static getMouseManager(
|
||||
instanceContainer: gdjs.RuntimeInstanceContainer
|
||||
): MouseDraggableManager {
|
||||
// @ts-ignore
|
||||
if (!instanceContainer.mouseDraggableManager) {
|
||||
//Create the shared manager if necessary.
|
||||
// @ts-ignore
|
||||
instanceContainer.mouseDraggableManager = new MouseDraggableManager(
|
||||
instanceContainer
|
||||
);
|
||||
}
|
||||
// @ts-ignore
|
||||
return instanceContainer.mouseDraggableManager;
|
||||
constructor(
|
||||
instanceContainer: gdjs.RuntimeInstanceContainer,
|
||||
touchId: integer
|
||||
) {
|
||||
this._touchId = touchId;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -196,7 +159,7 @@ namespace gdjs {
|
||||
// @ts-ignore
|
||||
instanceContainer.touchDraggableManagers[
|
||||
touchId
|
||||
] = new TouchDraggableManager(instanceContainer, touchId);
|
||||
] = new DraggableManager(instanceContainer, touchId);
|
||||
}
|
||||
// @ts-ignore
|
||||
return instanceContainer.touchDraggableManagers[touchId];
|
||||
@@ -263,75 +226,6 @@ namespace gdjs {
|
||||
this._draggableBehavior = null;
|
||||
}
|
||||
|
||||
abstract isDragging(
|
||||
draggableRuntimeBehavior: DraggableRuntimeBehavior
|
||||
): boolean;
|
||||
abstract shouldEndDrag(
|
||||
instanceContainer: gdjs.RuntimeInstanceContainer,
|
||||
draggableRuntimeBehavior: DraggableRuntimeBehavior
|
||||
): boolean;
|
||||
abstract getPosition(
|
||||
instanceContainer: gdjs.RuntimeInstanceContainer,
|
||||
draggableRuntimeBehavior: DraggableRuntimeBehavior
|
||||
): FloatPoint;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the dragging by mouse
|
||||
*/
|
||||
class MouseDraggableManager extends DraggableManager {
|
||||
/** Used to only start dragging when clicking. */
|
||||
leftPressedLastFrame = false;
|
||||
|
||||
constructor(instanceContainer: gdjs.RuntimeInstanceContainer) {
|
||||
super(instanceContainer);
|
||||
}
|
||||
|
||||
isDragging(draggableRuntimeBehavior: DraggableRuntimeBehavior): boolean {
|
||||
return this.leftPressedLastFrame || this._draggingSomething;
|
||||
}
|
||||
|
||||
getPosition(
|
||||
instanceContainer: gdjs.RuntimeInstanceContainer,
|
||||
draggableRuntimeBehavior: DraggableRuntimeBehavior
|
||||
): FloatPoint {
|
||||
const workingPoint: FloatPoint = gdjs.staticArray(
|
||||
MouseDraggableManager.prototype.getPosition
|
||||
) as FloatPoint;
|
||||
const inputManager = instanceContainer.getGame().getInputManager();
|
||||
return instanceContainer
|
||||
.getLayer(draggableRuntimeBehavior.owner.getLayer())
|
||||
.convertCoords(
|
||||
inputManager.getMouseX(),
|
||||
inputManager.getMouseY(),
|
||||
0,
|
||||
workingPoint
|
||||
);
|
||||
}
|
||||
|
||||
shouldEndDrag(
|
||||
instanceContainer: gdjs.RuntimeInstanceContainer,
|
||||
draggableRuntimeBehavior: DraggableRuntimeBehavior
|
||||
): boolean {
|
||||
const inputManager = instanceContainer.getGame().getInputManager();
|
||||
return !inputManager.isMouseButtonPressed(0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the dragging by touch
|
||||
*/
|
||||
class TouchDraggableManager extends DraggableManager {
|
||||
private _touchId: integer;
|
||||
|
||||
constructor(
|
||||
instanceContainer: gdjs.RuntimeInstanceContainer,
|
||||
touchId: integer
|
||||
) {
|
||||
super(instanceContainer);
|
||||
this._touchId = touchId;
|
||||
}
|
||||
|
||||
isDragging(draggableRuntimeBehavior: DraggableRuntimeBehavior): boolean {
|
||||
return this._draggingSomething;
|
||||
}
|
||||
@@ -341,7 +235,7 @@ namespace gdjs {
|
||||
draggableRuntimeBehavior: DraggableRuntimeBehavior
|
||||
): FloatPoint {
|
||||
const workingPoint: FloatPoint = gdjs.staticArray(
|
||||
TouchDraggableManager.prototype.getPosition
|
||||
DraggableManager.prototype.getPosition
|
||||
) as FloatPoint;
|
||||
const inputManager = instanceContainer.getGame().getInputManager();
|
||||
return instanceContainer
|
||||
@@ -359,9 +253,7 @@ namespace gdjs {
|
||||
draggableRuntimeBehavior: DraggableRuntimeBehavior
|
||||
): boolean {
|
||||
const inputManager = instanceContainer.getGame().getInputManager();
|
||||
return (
|
||||
inputManager.getAllTouchIdentifiers().indexOf(this._touchId) === -1
|
||||
);
|
||||
return inputManager.hasTouchEnded(this._touchId);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -66,17 +66,21 @@ describe('gdjs.DraggableRuntimeBehavior', function () {
|
||||
|
||||
// Drag'n'drop
|
||||
runtimeScene.renderAndStep(1000 / 60);
|
||||
runtimeGame.getInputManager().onFrameEnded();
|
||||
runtimeGame.getInputManager().onMouseMove(450, 500);
|
||||
runtimeGame
|
||||
.getInputManager()
|
||||
.onMouseButtonPressed(gdjs.InputManager.MOUSE_LEFT_BUTTON);
|
||||
runtimeScene.renderAndStep(1000 / 60);
|
||||
runtimeGame.getInputManager().onFrameEnded();
|
||||
runtimeGame.getInputManager().onMouseMove(750, 600);
|
||||
runtimeScene.renderAndStep(1000 / 60);
|
||||
runtimeGame.getInputManager().onFrameEnded();
|
||||
runtimeGame
|
||||
.getInputManager()
|
||||
.onMouseButtonReleased(gdjs.InputManager.MOUSE_LEFT_BUTTON);
|
||||
runtimeScene.renderAndStep(1000 / 60);
|
||||
runtimeGame.getInputManager().onFrameEnded();
|
||||
|
||||
expect(object.getX()).to.be(750);
|
||||
expect(object.getY()).to.be(600);
|
||||
@@ -84,6 +88,7 @@ describe('gdjs.DraggableRuntimeBehavior', function () {
|
||||
// Mouse move without dragging
|
||||
runtimeGame.getInputManager().onMouseMove(600, 600);
|
||||
runtimeScene.renderAndStep(1000 / 60);
|
||||
runtimeGame.getInputManager().onFrameEnded();
|
||||
|
||||
expect(object.getX()).to.be(750);
|
||||
expect(object.getY()).to.be(600);
|
||||
@@ -94,12 +99,15 @@ describe('gdjs.DraggableRuntimeBehavior', function () {
|
||||
.getInputManager()
|
||||
.onMouseButtonPressed(gdjs.InputManager.MOUSE_LEFT_BUTTON);
|
||||
runtimeScene.renderAndStep(1000 / 60);
|
||||
runtimeGame.getInputManager().onFrameEnded();
|
||||
runtimeGame.getInputManager().onMouseMove(850, 700);
|
||||
runtimeScene.renderAndStep(1000 / 60);
|
||||
runtimeGame.getInputManager().onFrameEnded();
|
||||
runtimeGame
|
||||
.getInputManager()
|
||||
.onMouseButtonReleased(gdjs.InputManager.MOUSE_LEFT_BUTTON);
|
||||
runtimeScene.renderAndStep(1000 / 60);
|
||||
runtimeGame.getInputManager().onFrameEnded();
|
||||
|
||||
expect(object.getX()).to.be(850);
|
||||
expect(object.getY()).to.be(700);
|
||||
@@ -111,17 +119,21 @@ describe('gdjs.DraggableRuntimeBehavior', function () {
|
||||
|
||||
// Dragged point is in the bounding box but not in hitbox
|
||||
runtimeScene.renderAndStep(1000 / 60);
|
||||
runtimeGame.getInputManager().onFrameEnded();
|
||||
runtimeGame.getInputManager().onMouseMove(450, 500);
|
||||
runtimeGame
|
||||
.getInputManager()
|
||||
.onMouseButtonPressed(gdjs.InputManager.MOUSE_LEFT_BUTTON);
|
||||
runtimeScene.renderAndStep(1000 / 60);
|
||||
runtimeGame.getInputManager().onFrameEnded();
|
||||
runtimeGame.getInputManager().onMouseMove(750, 600);
|
||||
runtimeScene.renderAndStep(1000 / 60);
|
||||
runtimeGame.getInputManager().onFrameEnded();
|
||||
runtimeGame
|
||||
.getInputManager()
|
||||
.onMouseButtonReleased(gdjs.InputManager.MOUSE_LEFT_BUTTON);
|
||||
runtimeScene.renderAndStep(1000 / 60);
|
||||
runtimeGame.getInputManager().onFrameEnded();
|
||||
|
||||
expect(object.getX()).to.be(750);
|
||||
expect(object.getY()).to.be(600);
|
||||
@@ -135,34 +147,42 @@ describe('gdjs.DraggableRuntimeBehavior', function () {
|
||||
|
||||
// Dragged point is in the bounding box but not in hitbox
|
||||
runtimeScene.renderAndStep(1000 / 60);
|
||||
runtimeGame.getInputManager().onFrameEnded();
|
||||
runtimeGame.getInputManager().onMouseMove(450, 500);
|
||||
runtimeGame
|
||||
.getInputManager()
|
||||
.onMouseButtonPressed(gdjs.InputManager.MOUSE_LEFT_BUTTON);
|
||||
runtimeScene.renderAndStep(1000 / 60);
|
||||
runtimeGame.getInputManager().onFrameEnded();
|
||||
runtimeGame.getInputManager().onMouseMove(750, 600);
|
||||
runtimeScene.renderAndStep(1000 / 60);
|
||||
runtimeGame.getInputManager().onFrameEnded();
|
||||
runtimeGame
|
||||
.getInputManager()
|
||||
.onMouseButtonReleased(gdjs.InputManager.MOUSE_LEFT_BUTTON);
|
||||
runtimeScene.renderAndStep(1000 / 60);
|
||||
runtimeGame.getInputManager().onFrameEnded();
|
||||
|
||||
expect(object2.getX()).to.be(450);
|
||||
expect(object2.getY()).to.be(500);
|
||||
|
||||
// Dragged point is in the bounding box and in hitbox
|
||||
runtimeScene.renderAndStep(1000 / 60);
|
||||
runtimeGame.getInputManager().onFrameEnded();
|
||||
runtimeGame.getInputManager().onMouseMove(455, 505);
|
||||
runtimeGame
|
||||
.getInputManager()
|
||||
.onMouseButtonPressed(gdjs.InputManager.MOUSE_LEFT_BUTTON);
|
||||
runtimeScene.renderAndStep(1000 / 60);
|
||||
runtimeGame.getInputManager().onFrameEnded();
|
||||
runtimeGame.getInputManager().onMouseMove(855, 705);
|
||||
runtimeScene.renderAndStep(1000 / 60);
|
||||
runtimeGame.getInputManager().onFrameEnded();
|
||||
runtimeGame
|
||||
.getInputManager()
|
||||
.onMouseButtonReleased(gdjs.InputManager.MOUSE_LEFT_BUTTON);
|
||||
runtimeScene.renderAndStep(1000 / 60);
|
||||
runtimeGame.getInputManager().onFrameEnded();
|
||||
|
||||
expect(object2.getX()).to.be(850);
|
||||
expect(object2.getY()).to.be(700);
|
||||
@@ -185,17 +205,21 @@ describe('gdjs.DraggableRuntimeBehavior', function () {
|
||||
|
||||
// Drag'n'drop
|
||||
runtimeScene.renderAndStep(1000 / 60);
|
||||
runtimeGame.getInputManager().onFrameEnded();
|
||||
runtimeGame.getInputManager().onMouseMove(450, 500);
|
||||
runtimeGame
|
||||
.getInputManager()
|
||||
.onMouseButtonPressed(gdjs.InputManager.MOUSE_LEFT_BUTTON);
|
||||
runtimeScene.renderAndStep(1000 / 60);
|
||||
runtimeGame.getInputManager().onFrameEnded();
|
||||
runtimeGame.getInputManager().onMouseMove(750, 600);
|
||||
runtimeScene.renderAndStep(1000 / 60);
|
||||
runtimeGame.getInputManager().onFrameEnded();
|
||||
runtimeGame
|
||||
.getInputManager()
|
||||
.onMouseButtonReleased(gdjs.InputManager.MOUSE_LEFT_BUTTON);
|
||||
runtimeScene.renderAndStep(1000 / 60);
|
||||
runtimeGame.getInputManager().onFrameEnded();
|
||||
|
||||
if (firstInFront) {
|
||||
// The 1st object moved
|
||||
@@ -220,6 +244,7 @@ describe('gdjs.DraggableRuntimeBehavior', function () {
|
||||
|
||||
// Drag'n'drop
|
||||
runtimeScene.renderAndStep(1000 / 60);
|
||||
runtimeGame.getInputManager().onFrameEnded();
|
||||
runtimeGame.getInputManager().onTouchStart(1, 10, 20);
|
||||
runtimeGame.getInputManager().onTouchStart(0, 450, 500);
|
||||
runtimeScene.renderAndStep(1000 / 60);
|
||||
@@ -237,22 +262,25 @@ describe('gdjs.DraggableRuntimeBehavior', function () {
|
||||
// Move another unrelated touch
|
||||
runtimeGame.getInputManager().onTouchMove(1, 750, 600);
|
||||
runtimeScene.renderAndStep(1000 / 60);
|
||||
runtimeGame.getInputManager().onFrameEnded();
|
||||
runtimeGame.getInputManager().onTouchMove(1, 850, 700);
|
||||
runtimeScene.renderAndStep(1000 / 60);
|
||||
runtimeGame.getInputManager().onFrameEnded();
|
||||
|
||||
expect(object.getX()).to.be(750);
|
||||
expect(object.getY()).to.be(600);
|
||||
|
||||
// Start drag'n'drop with another touch
|
||||
runtimeGame.getInputManager().onTouchEnd(1);
|
||||
runtimeGame.getInputManager().onFrameEnded();
|
||||
runtimeScene.renderAndStep(1000 / 60);
|
||||
runtimeGame.getInputManager().onFrameEnded();
|
||||
runtimeGame.getInputManager().onTouchStart(1, 750, 600);
|
||||
runtimeScene.renderAndStep(1000 / 60);
|
||||
runtimeGame.getInputManager().onFrameEnded();
|
||||
runtimeGame.getInputManager().onTouchMove(1, 850, 700);
|
||||
runtimeScene.renderAndStep(1000 / 60);
|
||||
runtimeGame.getInputManager().onTouchEnd(1);
|
||||
runtimeGame.getInputManager().onFrameEnded();
|
||||
runtimeGame.getInputManager().onTouchEnd(1);
|
||||
|
||||
expect(object.getX()).to.be(850);
|
||||
expect(object.getY()).to.be(700);
|
||||
@@ -264,12 +292,12 @@ describe('gdjs.DraggableRuntimeBehavior', function () {
|
||||
|
||||
// Dragged point is in the bounding box but not in hitbox
|
||||
runtimeScene.renderAndStep(1000 / 60);
|
||||
runtimeGame.getInputManager().onFrameEnded();
|
||||
runtimeGame.getInputManager().onTouchStart(0, 450, 500);
|
||||
runtimeScene.renderAndStep(1000 / 60);
|
||||
runtimeGame.getInputManager().onFrameEnded();
|
||||
runtimeGame.getInputManager().onTouchMove(0, 750, 600);
|
||||
runtimeScene.renderAndStep(1000 / 60);
|
||||
runtimeGame.getInputManager().onFrameEnded();
|
||||
runtimeGame.getInputManager().onTouchEnd(0);
|
||||
runtimeScene.renderAndStep(1000 / 60);
|
||||
runtimeGame.getInputManager().onFrameEnded();
|
||||
@@ -286,6 +314,7 @@ describe('gdjs.DraggableRuntimeBehavior', function () {
|
||||
|
||||
// Dragged point is in the bounding box but not in hitbox
|
||||
runtimeScene.renderAndStep(1000 / 60);
|
||||
runtimeGame.getInputManager().onFrameEnded();
|
||||
runtimeGame.getInputManager().onTouchStart(0, 450, 500);
|
||||
runtimeScene.renderAndStep(1000 / 60);
|
||||
runtimeGame.getInputManager().onFrameEnded();
|
||||
@@ -301,6 +330,7 @@ describe('gdjs.DraggableRuntimeBehavior', function () {
|
||||
|
||||
// Dragged point is in the bounding box but not in hitbox
|
||||
runtimeScene.renderAndStep(1000 / 60);
|
||||
runtimeGame.getInputManager().onFrameEnded();
|
||||
runtimeGame.getInputManager().onTouchStart(0, 455, 505);
|
||||
runtimeScene.renderAndStep(1000 / 60);
|
||||
runtimeGame.getInputManager().onFrameEnded();
|
||||
@@ -323,6 +353,7 @@ describe('gdjs.DraggableRuntimeBehavior', function () {
|
||||
|
||||
// Drag'n'drop
|
||||
runtimeScene.renderAndStep(1000 / 60);
|
||||
runtimeGame.getInputManager().onFrameEnded();
|
||||
runtimeGame.getInputManager().onTouchStart(2, 450, 500);
|
||||
runtimeGame.getInputManager().onTouchStart(1, 650, 600);
|
||||
runtimeScene.renderAndStep(1000 / 60);
|
||||
@@ -361,6 +392,7 @@ describe('gdjs.DraggableRuntimeBehavior', function () {
|
||||
// Drag'n'drop
|
||||
runtimeGame.getInputManager().touchSimulateMouse(false);
|
||||
runtimeScene.renderAndStep(1000 / 60);
|
||||
runtimeGame.getInputManager().onFrameEnded();
|
||||
runtimeGame.getInputManager().onTouchStart(1, 10, 20);
|
||||
runtimeGame.getInputManager().onTouchStart(0, 450, 500);
|
||||
runtimeScene.renderAndStep(1000 / 60);
|
||||
|
@@ -2037,7 +2037,7 @@ module.exports = {
|
||||
_('Update a document in Database'),
|
||||
_('Updates a variable on the database.'),
|
||||
_(
|
||||
'Update varable _PARAM0_ with _PARAM1_ (store result state in _PARAM2_)'
|
||||
'Update variable _PARAM0_ with _PARAM1_ (store result state in _PARAM2_)'
|
||||
),
|
||||
_('Realtime Database'),
|
||||
'JsPlatform/Extensions/firebase.png',
|
||||
|
@@ -28,14 +28,14 @@ module.exports = {
|
||||
extension
|
||||
.setExtensionInformation(
|
||||
'Leaderboards',
|
||||
_('Leaderboards (experimental)'),
|
||||
_('Leaderboards'),
|
||||
_('Allow your game to send scores to your leaderboards.'),
|
||||
'Florian Rival',
|
||||
'Open source (MIT License)'
|
||||
)
|
||||
.setExtensionHelpPath('/all-features/leaderboards')
|
||||
.setCategory('Players')
|
||||
.addInstructionOrExpressionGroupMetadata(_('Leaderboards (experimental)'))
|
||||
.addInstructionOrExpressionGroupMetadata(_('Leaderboards'))
|
||||
.setIcon('JsPlatform/Extensions/leaderboard.svg');
|
||||
|
||||
extension
|
||||
|
@@ -28,7 +28,7 @@ module.exports = {
|
||||
extension
|
||||
.setExtensionInformation(
|
||||
'P2P',
|
||||
_('P2P (experimental)'),
|
||||
_('P2P'),
|
||||
'Allow game instances to communicate remotely using messages sent via WebRTC (P2P).',
|
||||
'Arthur Pacaud (arthuro555)',
|
||||
'MIT'
|
||||
@@ -36,7 +36,7 @@ module.exports = {
|
||||
.setExtensionHelpPath('/all-features/p2p')
|
||||
.setCategory('Network');
|
||||
extension
|
||||
.addInstructionOrExpressionGroupMetadata(_('P2P (experimental)'))
|
||||
.addInstructionOrExpressionGroupMetadata(_('P2P'))
|
||||
.setIcon('JsPlatform/Extensions/p2picon.svg');
|
||||
|
||||
extension
|
||||
|
@@ -54,7 +54,8 @@ void PanelSpriteObject::DoSerializeTo(gd::SerializerElement& element) const {
|
||||
element.SetAttribute("tiled", tiled);
|
||||
}
|
||||
|
||||
void PanelSpriteObject::ExposeResources(gd::ArbitraryResourceWorker& worker) {
|
||||
void PanelSpriteObject::ExposeResources(
|
||||
gd::ArbitraryResourceWorker& worker) {
|
||||
worker.ExposeImage(textureName);
|
||||
}
|
||||
#endif
|
||||
|
@@ -28,9 +28,7 @@ class GD_EXTENSION_API PanelSpriteObject : public gd::ObjectConfiguration {
|
||||
new PanelSpriteObject(*this));
|
||||
}
|
||||
|
||||
#if defined(GD_IDE_ONLY)
|
||||
virtual void ExposeResources(gd::ArbitraryResourceWorker &worker);
|
||||
#endif
|
||||
|
||||
double GetWidth() const { return width; };
|
||||
double GetHeight() const { return height; };
|
||||
|
@@ -179,9 +179,8 @@ namespace gdjs {
|
||||
|
||||
movementAngleIsAround(degreeAngle: float, tolerance: float) {
|
||||
return (
|
||||
gdjs.evtTools.common.angleDifference(
|
||||
this._movementAngle,
|
||||
degreeAngle
|
||||
Math.abs(
|
||||
gdjs.evtTools.common.angleDifference(this._movementAngle, degreeAngle)
|
||||
) <= tolerance
|
||||
);
|
||||
}
|
||||
|
@@ -426,7 +426,9 @@ module.exports = {
|
||||
)
|
||||
.setIncludeFile('Extensions/Physics2Behavior/physics2runtimebehavior.js')
|
||||
.addIncludeFile('Extensions/Physics2Behavior/Box2D_v2.3.1_min.wasm.js')
|
||||
.addRequiredFile('Extensions/Physics2Behavior/Box2D_v2.3.1_min.wasm.wasm')
|
||||
.addRequiredFile(
|
||||
'Extensions/Physics2Behavior/Box2D_v2.3.1_min.wasm.wasm'
|
||||
);
|
||||
|
||||
// Global
|
||||
aut
|
||||
@@ -1361,6 +1363,40 @@ module.exports = {
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('getLinearVelocityLength');
|
||||
|
||||
aut
|
||||
.addCondition(
|
||||
'LinearVelocityAngle',
|
||||
_('Linear velocity angle'),
|
||||
_('Test an object linear velocity angle.'),
|
||||
_('the linear velocity angle'),
|
||||
_('Velocity'),
|
||||
'res/physics32.png',
|
||||
'res/physics32.png'
|
||||
)
|
||||
.addParameter('object', _('Object'), '', false)
|
||||
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
|
||||
.useStandardRelationalOperatorParameters(
|
||||
'number',
|
||||
gd.ParameterOptions.makeNewOptions().setDescription(
|
||||
_('Angle to compare to (in degrees)')
|
||||
)
|
||||
)
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('getLinearVelocityAngle');
|
||||
|
||||
aut
|
||||
.addExpression(
|
||||
'LinearVelocityAngle',
|
||||
_('Linear velocity angle'),
|
||||
_('Get the linear velocity angle of an object.'),
|
||||
_('Velocity'),
|
||||
'res/physics32.png'
|
||||
)
|
||||
.addParameter('object', _('Object'), '', false)
|
||||
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('getLinearVelocityAngle');
|
||||
|
||||
aut
|
||||
.addCondition(
|
||||
'AngularVelocity',
|
||||
@@ -1498,8 +1534,14 @@ module.exports = {
|
||||
)
|
||||
.addParameter('object', _('Object'), '', false)
|
||||
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
|
||||
.addParameter('expression', _('X component (in Newton * seconds or kilogram * meter per second)'))
|
||||
.addParameter('expression', _('Y component (in Newton * seconds or kilogram * meter per second)'))
|
||||
.addParameter(
|
||||
'expression',
|
||||
_('X component (in Newton * seconds or kilogram * meter per second)')
|
||||
)
|
||||
.addParameter(
|
||||
'expression',
|
||||
_('Y component (in Newton * seconds or kilogram * meter per second)')
|
||||
)
|
||||
.addParameter('expression', _('Applying X position'))
|
||||
.addParameter('expression', _('Applying Y position'))
|
||||
.getCodeExtraInformation()
|
||||
@@ -1522,7 +1564,10 @@ module.exports = {
|
||||
.addParameter('object', _('Object'), '', false)
|
||||
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
|
||||
.addParameter('expression', _('Angle'))
|
||||
.addParameter('expression', _('Length (in Newton * seconds or kilogram * meter per second)'))
|
||||
.addParameter(
|
||||
'expression',
|
||||
_('Length (in Newton * seconds or kilogram * meter per second)')
|
||||
)
|
||||
.addParameter('expression', _('Applying X position'))
|
||||
.addParameter('expression', _('Applying Y position'))
|
||||
.getCodeExtraInformation()
|
||||
@@ -1544,7 +1589,10 @@ module.exports = {
|
||||
)
|
||||
.addParameter('object', _('Object'), '', false)
|
||||
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
|
||||
.addParameter('expression', _('Length (in Newton * seconds or kilogram * meter per second)'))
|
||||
.addParameter(
|
||||
'expression',
|
||||
_('Length (in Newton * seconds or kilogram * meter per second)')
|
||||
)
|
||||
.addParameter('expression', _('X position'))
|
||||
.addParameter('expression', _('Y position'))
|
||||
.addParameter('expression', _('Applying X position'))
|
||||
@@ -1601,31 +1649,33 @@ module.exports = {
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('getMass');
|
||||
|
||||
aut
|
||||
.addExpression(
|
||||
'Inertia',
|
||||
_('Inertia'),
|
||||
_('Return the rotational inertia of the object (in kilograms * meters * meters)'),
|
||||
'',
|
||||
'res/physics32.png'
|
||||
)
|
||||
.addParameter('object', _('Object'), '', false)
|
||||
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('getInertia');
|
||||
aut
|
||||
.addExpression(
|
||||
'Inertia',
|
||||
_('Inertia'),
|
||||
_(
|
||||
'Return the rotational inertia of the object (in kilograms * meters * meters)'
|
||||
),
|
||||
'',
|
||||
'res/physics32.png'
|
||||
)
|
||||
.addParameter('object', _('Object'), '', false)
|
||||
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('getInertia');
|
||||
|
||||
aut
|
||||
.addExpression(
|
||||
'MassCenterX',
|
||||
_('Mass center X'),
|
||||
_('Mass center X'),
|
||||
'',
|
||||
'res/physics32.png'
|
||||
)
|
||||
.addParameter('object', _('Object'), '', false)
|
||||
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('getMassCenterX');
|
||||
aut
|
||||
.addExpression(
|
||||
'MassCenterX',
|
||||
_('Mass center X'),
|
||||
_('Mass center X'),
|
||||
'',
|
||||
'res/physics32.png'
|
||||
)
|
||||
.addParameter('object', _('Object'), '', false)
|
||||
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('getMassCenterX');
|
||||
|
||||
aut
|
||||
.addExpression(
|
||||
|
@@ -1408,6 +1408,22 @@ namespace gdjs {
|
||||
).Length();
|
||||
}
|
||||
|
||||
getLinearVelocityAngle(): float {
|
||||
// If there is no body, set a new one
|
||||
if (this._body === null) {
|
||||
if (!this.createBody()) return 0;
|
||||
}
|
||||
const body = this._body!;
|
||||
|
||||
// Get the linear velocity angle
|
||||
return gdjs.toDegrees(
|
||||
Math.atan2(
|
||||
body.GetLinearVelocity().get_y() * this._sharedData.scaleY,
|
||||
body.GetLinearVelocity().get_x() * this._sharedData.scaleX
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
getAngularVelocity(): float {
|
||||
// If there is no body, set a new one
|
||||
if (this._body === null) {
|
||||
|
@@ -28,7 +28,7 @@ module.exports = {
|
||||
extension
|
||||
.setExtensionInformation(
|
||||
'PlayerAuthentication',
|
||||
_('Player Authentication (experimental)'),
|
||||
_('Player Authentication'),
|
||||
_('Allow your game to authenticate players.'),
|
||||
'Florian Rival',
|
||||
'Open source (MIT License)'
|
||||
@@ -36,9 +36,7 @@ module.exports = {
|
||||
.setExtensionHelpPath('/all-features/player-authentication')
|
||||
.setCategory('Players');
|
||||
extension
|
||||
.addInstructionOrExpressionGroupMetadata(
|
||||
_('Player Authentication (experimental)')
|
||||
)
|
||||
.addInstructionOrExpressionGroupMetadata(_('Player Authentication'))
|
||||
.setIcon('JsPlatform/Extensions/authentication.svg');
|
||||
|
||||
extension
|
||||
|
@@ -19,10 +19,11 @@ namespace gdjs {
|
||||
'If the window did not open, please check your pop-up blocker and click the button below to try again.',
|
||||
}
|
||||
: {
|
||||
title: 'Your game is not registered!',
|
||||
title: 'Publish your game!',
|
||||
text1:
|
||||
'In order to use player authentication, this game must be registered with GDevelop Services first.',
|
||||
text2: 'Head to your Game Dashboard, then try again.',
|
||||
"GDevelop's player accounts are only available for published games.",
|
||||
text2:
|
||||
'Click the button below to learn how to publish your game then try again.',
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -119,7 +120,8 @@ namespace gdjs {
|
||||
export const addAuthenticationTextsToLoadingContainer = (
|
||||
loaderContainer: HTMLDivElement,
|
||||
platform,
|
||||
isGameRegistered
|
||||
isGameRegistered,
|
||||
wikiOpenAction
|
||||
) => {
|
||||
const textContainer: HTMLDivElement = document.createElement('div');
|
||||
textContainer.id = 'authentication-container-texts';
|
||||
@@ -151,8 +153,20 @@ namespace gdjs {
|
||||
textContainer.appendChild(text2);
|
||||
|
||||
if (!isGameRegistered) {
|
||||
// Remove the loader.
|
||||
// Remove the loader and add the wiki link.
|
||||
loaderContainer.innerHTML = '';
|
||||
|
||||
if (wikiOpenAction) {
|
||||
const link = document.createElement('a');
|
||||
addTouchAndClickEventListeners(link, wikiOpenAction);
|
||||
link.innerText = 'How to publish my game';
|
||||
link.style.color = '#0078d4';
|
||||
link.style.textDecoration = 'none';
|
||||
link.style.textDecoration = 'underline';
|
||||
link.style.cursor = 'pointer';
|
||||
|
||||
textContainer.appendChild(link);
|
||||
}
|
||||
}
|
||||
|
||||
loaderContainer.prepend(textContainer);
|
||||
@@ -170,7 +184,7 @@ namespace gdjs {
|
||||
) => {
|
||||
const link = document.createElement('a');
|
||||
addTouchAndClickEventListeners(link, onClick);
|
||||
link.innerText = 'Click here to authenticate';
|
||||
link.innerText = 'Try again';
|
||||
link.style.color = '#0078d4';
|
||||
link.style.textDecoration = 'none';
|
||||
link.style.textDecoration = 'underline';
|
||||
|
@@ -20,6 +20,7 @@ namespace gdjs {
|
||||
let _authenticationLoaderContainer: HTMLDivElement | null = null;
|
||||
let _authenticationTextContainer: HTMLDivElement | null = null;
|
||||
let _authenticationBanner: HTMLDivElement | null = null;
|
||||
let _initialAuthenticationTimeoutId: NodeJS.Timeout | null = null;
|
||||
let _authenticationTimeoutId: NodeJS.Timeout | null = null;
|
||||
|
||||
// Communication methods.
|
||||
@@ -36,6 +37,43 @@ namespace gdjs {
|
||||
_justLoggedIn = false;
|
||||
});
|
||||
|
||||
// If the extension is used, register an eventlistener to know if the user is
|
||||
// logged in while playing the game on Liluo.io.
|
||||
// Then send a message to the parent iframe to say that the player auth is ready.
|
||||
gdjs.registerFirstRuntimeSceneLoadedCallback(
|
||||
(runtimeScene: RuntimeScene) => {
|
||||
if (getPlatform(runtimeScene) !== 'web') {
|
||||
// Automatic authentication is only valid when the game is hosted in Liluo.io.
|
||||
return;
|
||||
}
|
||||
removeAuthenticationCallbacks(); // Remove any callback that could have been registered before.
|
||||
_authenticationMessageCallback = (event: MessageEvent) => {
|
||||
receiveAuthenticationMessage(runtimeScene, event, {
|
||||
checkOrigin: true,
|
||||
});
|
||||
};
|
||||
window.addEventListener(
|
||||
'message',
|
||||
_authenticationMessageCallback,
|
||||
true
|
||||
);
|
||||
logger.info(
|
||||
'Notifying parent window that player authentication is ready.'
|
||||
);
|
||||
window.parent.postMessage(
|
||||
{
|
||||
id: 'playerAuthReady',
|
||||
},
|
||||
'*' // We could restrict to liluo.io but it's not necessary as the message is not sensitive, and it allows easy debugging.
|
||||
);
|
||||
// If no answer after 3 seconds, assume that the game is not embedded in Liluo.io, and remove the listener.
|
||||
_initialAuthenticationTimeoutId = setTimeout(() => {
|
||||
logger.info('Removing initial authentication listener.');
|
||||
removeAuthenticationCallbacks();
|
||||
}, 3000);
|
||||
}
|
||||
);
|
||||
|
||||
const getLocalStorageKey = (gameId: string) =>
|
||||
`${gameId}_authenticatedUser`;
|
||||
|
||||
@@ -190,19 +228,26 @@ namespace gdjs {
|
||||
logger.error('Missing game id in project properties.');
|
||||
return;
|
||||
}
|
||||
const authenticatedUserStorageItem = window.localStorage.getItem(
|
||||
getLocalStorageKey(gameId)
|
||||
);
|
||||
if (!authenticatedUserStorageItem) {
|
||||
_checkedLocalStorage = true;
|
||||
return;
|
||||
}
|
||||
const authenticatedUser = JSON.parse(authenticatedUserStorageItem);
|
||||
try {
|
||||
const authenticatedUserStorageItem = window.localStorage.getItem(
|
||||
getLocalStorageKey(gameId)
|
||||
);
|
||||
if (!authenticatedUserStorageItem) {
|
||||
_checkedLocalStorage = true;
|
||||
return;
|
||||
}
|
||||
const authenticatedUser = JSON.parse(authenticatedUserStorageItem);
|
||||
|
||||
_username = authenticatedUser.username;
|
||||
_userId = authenticatedUser.userId;
|
||||
_userToken = authenticatedUser.userToken;
|
||||
_checkedLocalStorage = true;
|
||||
_username = authenticatedUser.username;
|
||||
_userId = authenticatedUser.userId;
|
||||
_userToken = authenticatedUser.userToken;
|
||||
_checkedLocalStorage = true;
|
||||
} catch (err) {
|
||||
logger.warn(
|
||||
'Unable to read authentication details from localStorage. Player authentication will not be available.',
|
||||
err
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -228,16 +273,15 @@ namespace gdjs {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* When the websocket receives the authentication result, close all the
|
||||
* authentication windows, display the notification and focus on the game.
|
||||
*/
|
||||
const handleLoggedInEvent = function (
|
||||
runtimeScene: gdjs.RuntimeScene,
|
||||
userId: string,
|
||||
username: string | null,
|
||||
userToken: string
|
||||
) {
|
||||
const saveAuthKeyToStorage = ({
|
||||
username,
|
||||
userId,
|
||||
userToken,
|
||||
}: {
|
||||
username: string | null;
|
||||
userId: string;
|
||||
userToken: string;
|
||||
}) => {
|
||||
if (!username) {
|
||||
logger.warn('The authenticated player does not have a username');
|
||||
}
|
||||
@@ -251,14 +295,34 @@ namespace gdjs {
|
||||
logger.error('Missing game id in project properties.');
|
||||
return;
|
||||
}
|
||||
window.localStorage.setItem(
|
||||
getLocalStorageKey(gameId),
|
||||
JSON.stringify({
|
||||
username: _username,
|
||||
userId: _userId,
|
||||
userToken: _userToken,
|
||||
})
|
||||
);
|
||||
try {
|
||||
window.localStorage.setItem(
|
||||
getLocalStorageKey(gameId),
|
||||
JSON.stringify({
|
||||
username: _username,
|
||||
userId: _userId,
|
||||
userToken: _userToken,
|
||||
})
|
||||
);
|
||||
} catch (err) {
|
||||
logger.warn(
|
||||
'Unable to save the authentication details to localStorage. Player authentication will not be available.',
|
||||
err
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* When the game receives the authentication result, close all the
|
||||
* authentication windows, display the notification and focus on the game.
|
||||
*/
|
||||
const handleLoggedInEvent = function (
|
||||
runtimeScene: gdjs.RuntimeScene,
|
||||
userId: string,
|
||||
username: string | null,
|
||||
userToken: string
|
||||
) {
|
||||
saveAuthKeyToStorage({ userId, username, userToken });
|
||||
cleanUpAuthWindowAndCallbacks(runtimeScene);
|
||||
removeAuthenticationBanner(runtimeScene);
|
||||
|
||||
@@ -284,15 +348,15 @@ namespace gdjs {
|
||||
* Reads the event sent by the authentication window and
|
||||
* display the appropriate banner.
|
||||
*/
|
||||
const receiveMessageFromAuthenticationWindow = function (
|
||||
const receiveAuthenticationMessage = function (
|
||||
runtimeScene: gdjs.RuntimeScene,
|
||||
event: MessageEvent,
|
||||
{ checkOrigin }: { checkOrigin: boolean }
|
||||
) {
|
||||
const allowedOrigin = 'https://liluo.io';
|
||||
const allowedOrigins = ['https://liluo.io', 'https://gd.games'];
|
||||
|
||||
// Check origin of message.
|
||||
if (checkOrigin && event.origin !== allowedOrigin) {
|
||||
if (checkOrigin && !allowedOrigins.includes(event.origin)) {
|
||||
throw new Error(`Unexpected origin: ${event.origin}`);
|
||||
}
|
||||
// Check that message is not malformed.
|
||||
@@ -315,6 +379,20 @@ namespace gdjs {
|
||||
);
|
||||
break;
|
||||
}
|
||||
case 'alreadyAuthenticated': {
|
||||
if (!(event.data.body && event.data.body.token)) {
|
||||
throw new Error('Malformed message.');
|
||||
}
|
||||
|
||||
saveAuthKeyToStorage({
|
||||
userId: event.data.body.userId,
|
||||
username: event.data.body.username,
|
||||
userToken: event.data.body.token,
|
||||
});
|
||||
removeAuthenticationCallbacks();
|
||||
refreshAuthenticationBannerIfAny(runtimeScene);
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -362,15 +440,42 @@ namespace gdjs {
|
||||
};
|
||||
|
||||
/**
|
||||
* Clear the authentication window timeout.
|
||||
* Clear all existing authentication timeouts.
|
||||
* Useful when:
|
||||
* - a new authentication starts
|
||||
* - the authentication succeeded
|
||||
* - the authentication window is closed
|
||||
*/
|
||||
const clearAuthenticationWindowTimeout = () => {
|
||||
if (_initialAuthenticationTimeoutId)
|
||||
clearTimeout(_initialAuthenticationTimeoutId);
|
||||
if (_authenticationTimeoutId) clearTimeout(_authenticationTimeoutId);
|
||||
};
|
||||
|
||||
/**
|
||||
* Helper to create the authentication banner based on the authentication status.
|
||||
*/
|
||||
const createAuthenticationBanner = function (
|
||||
runtimeScene: gdjs.RuntimeScene
|
||||
): HTMLDivElement {
|
||||
const onDismissBanner = () => {
|
||||
removeAuthenticationBanner(runtimeScene);
|
||||
};
|
||||
const onOpenAuthenticationWindow = () => {
|
||||
openAuthenticationWindow(runtimeScene);
|
||||
};
|
||||
return _userToken
|
||||
? authComponents.computeAuthenticatedBanner(
|
||||
onOpenAuthenticationWindow,
|
||||
onDismissBanner,
|
||||
_username
|
||||
)
|
||||
: authComponents.computeNotAuthenticatedBanner(
|
||||
onOpenAuthenticationWindow,
|
||||
onDismissBanner
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Action to display the banner to the user, depending on their authentication status.
|
||||
*/
|
||||
@@ -397,26 +502,39 @@ namespace gdjs {
|
||||
);
|
||||
return;
|
||||
}
|
||||
const onDismissBanner = () => {
|
||||
removeAuthenticationBanner(runtimeScene);
|
||||
};
|
||||
const onOpenAuthenticationWindow = () => {
|
||||
openAuthenticationWindow(runtimeScene);
|
||||
};
|
||||
// We display the corresponding banner depending on the authentication status.
|
||||
_authenticationBanner = _userToken
|
||||
? authComponents.computeAuthenticatedBanner(
|
||||
onOpenAuthenticationWindow,
|
||||
onDismissBanner,
|
||||
_username
|
||||
)
|
||||
: authComponents.computeNotAuthenticatedBanner(
|
||||
onOpenAuthenticationWindow,
|
||||
onDismissBanner
|
||||
);
|
||||
|
||||
_authenticationBanner = createAuthenticationBanner(runtimeScene);
|
||||
domElementContainer.appendChild(_authenticationBanner);
|
||||
};
|
||||
|
||||
/**
|
||||
* Helper to recompute the authentication banner.
|
||||
* This is useful if the user is already logged in on Liluo.io
|
||||
* and we want to display the banner with the username.
|
||||
*/
|
||||
const refreshAuthenticationBannerIfAny = function (
|
||||
runtimeScene: gdjs.RuntimeScene
|
||||
) {
|
||||
if (!_authenticationBanner) return;
|
||||
const domElementContainer = runtimeScene
|
||||
.getGame()
|
||||
.getRenderer()
|
||||
.getDomElementContainer();
|
||||
if (!domElementContainer) {
|
||||
handleAuthenticationError(
|
||||
runtimeScene,
|
||||
"The div element covering the game couldn't be found, the authentication banner cannot be displayed."
|
||||
);
|
||||
return;
|
||||
}
|
||||
const oldAuthenticationBanner = _authenticationBanner;
|
||||
_authenticationBanner = createAuthenticationBanner(runtimeScene);
|
||||
domElementContainer.replaceChild(
|
||||
_authenticationBanner,
|
||||
oldAuthenticationBanner
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Helper to handle authentication window on Electron.
|
||||
* We open a new window, and create a websocket to know when the user is logged in.
|
||||
@@ -516,7 +634,7 @@ namespace gdjs {
|
||||
// know when the user is authenticated.
|
||||
if (_authenticationInAppWindow) {
|
||||
_cordovaAuthenticationMessageCallback = (event: MessageEvent) => {
|
||||
receiveMessageFromAuthenticationWindow(runtimeScene, event, {
|
||||
receiveAuthenticationMessage(runtimeScene, event, {
|
||||
checkOrigin: false, // For Cordova we don't check the origin, as the message is read from the InAppBrowser directly.
|
||||
});
|
||||
};
|
||||
@@ -545,7 +663,7 @@ namespace gdjs {
|
||||
// Listen to messages posted by the authentication window, so that we can
|
||||
// know when the user is authenticated.
|
||||
_authenticationMessageCallback = (event: MessageEvent) => {
|
||||
receiveMessageFromAuthenticationWindow(runtimeScene, event, {
|
||||
receiveAuthenticationMessage(runtimeScene, event, {
|
||||
checkOrigin: true,
|
||||
});
|
||||
};
|
||||
@@ -622,10 +740,19 @@ namespace gdjs {
|
||||
checkIfGameIsRegistered(runtimeScene.getGame(), _gameId)
|
||||
.then((isGameRegistered) => {
|
||||
if (_authenticationLoaderContainer) {
|
||||
const electron = runtimeScene.getGame().getRenderer().getElectron();
|
||||
const wikiOpenAction = electron
|
||||
? () =>
|
||||
electron.shell.openExternal(
|
||||
'https://wiki.gdevelop.io/gdevelop5/publishing/web'
|
||||
)
|
||||
: null; // Only show a link if we're on electron.
|
||||
|
||||
_authenticationTextContainer = authComponents.addAuthenticationTextsToLoadingContainer(
|
||||
_authenticationLoaderContainer,
|
||||
platform,
|
||||
isGameRegistered
|
||||
isGameRegistered,
|
||||
wikiOpenAction
|
||||
);
|
||||
}
|
||||
if (isGameRegistered) {
|
||||
@@ -652,7 +779,7 @@ namespace gdjs {
|
||||
runtimeScene,
|
||||
'Error while checking if the game is registered.'
|
||||
);
|
||||
console.error(error);
|
||||
logger.error(error);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -669,6 +796,7 @@ namespace gdjs {
|
||||
export const removeAuthenticationContainer = function (
|
||||
runtimeScene: gdjs.RuntimeScene
|
||||
) {
|
||||
removeAuthenticationCallbacks();
|
||||
const domElementContainer = runtimeScene
|
||||
.getGame()
|
||||
.getRenderer()
|
||||
@@ -685,6 +813,15 @@ namespace gdjs {
|
||||
domElementContainer.removeChild(_authenticationRootContainer);
|
||||
}
|
||||
|
||||
_authenticationRootContainer = null;
|
||||
_authenticationLoaderContainer = null;
|
||||
_authenticationTextContainer = null;
|
||||
};
|
||||
|
||||
/*
|
||||
* Remove the authentication callbacks from web or cordova.
|
||||
*/
|
||||
const removeAuthenticationCallbacks = function () {
|
||||
// Remove the authentication callbacks.
|
||||
if (_authenticationMessageCallback) {
|
||||
window.removeEventListener(
|
||||
@@ -696,10 +833,6 @@ namespace gdjs {
|
||||
// No need to detach the callback from the InAppBrowser, as it's destroyed when the window is closed.
|
||||
_cordovaAuthenticationMessageCallback = null;
|
||||
}
|
||||
|
||||
_authenticationRootContainer = null;
|
||||
_authenticationLoaderContainer = null;
|
||||
_authenticationTextContainer = null;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@@ -28,9 +28,9 @@ void DeclarePrimitiveDrawingExtension(gd::PlatformExtension& extension) {
|
||||
.AddObject<ShapePainterObject>(
|
||||
"Drawer", //"Drawer" is kept for compatibility with GD<=3.6.76
|
||||
_("Shape painter"),
|
||||
_("Allows you to draw simple shapes on the screen"),
|
||||
_("Allows you to draw simple shapes on the screen using the events."),
|
||||
"CppPlatform/Extensions/primitivedrawingicon.png")
|
||||
.SetCategoryFullName(_("General"));
|
||||
.SetCategoryFullName(_("Advanced"));
|
||||
|
||||
#if defined(GD_IDE_ONLY)
|
||||
obj.AddAction(
|
||||
|
@@ -9,27 +9,47 @@ This project is released under the MIT License.
|
||||
#include "GDCore/Tools/Localization.h"
|
||||
|
||||
void DeclareSystemInfoExtension(gd::PlatformExtension& extension) {
|
||||
extension.SetExtensionInformation(
|
||||
"SystemInfo",
|
||||
_("System information"),
|
||||
_("Get information about the system and device running the game."),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)")
|
||||
extension
|
||||
.SetExtensionInformation(
|
||||
"SystemInfo",
|
||||
_("System information"),
|
||||
_("Get information about the system and device running the game."),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)")
|
||||
.SetCategory("Advanced");
|
||||
extension.AddInstructionOrExpressionGroupMetadata(_("System information"))
|
||||
.SetIcon("CppPlatform/Extensions/systeminfoicon.png");
|
||||
|
||||
extension
|
||||
.AddCondition(
|
||||
"IsMobile",
|
||||
_("Is a mobile device"),
|
||||
_("Check if the device running the game is a mobile device"),
|
||||
_("The device is a mobile device"),
|
||||
"",
|
||||
"CppPlatform/Extensions/systeminfoicon.png",
|
||||
"CppPlatform/Extensions/systeminfoicon.png")
|
||||
extension.AddCondition(
|
||||
"IsMobile",
|
||||
_("Is a mobile device"),
|
||||
_("Check if the device running the game is a mobile device (phone or "
|
||||
"tablet on iOS, Android or other mobile devices). The game itself "
|
||||
"might be a web game or distributed as a native mobile app (to check "
|
||||
"this precisely, use other conditions)."),
|
||||
_("The device is a mobile device"),
|
||||
"",
|
||||
"CppPlatform/Extensions/systeminfoicon.png",
|
||||
"CppPlatform/Extensions/systeminfoicon.png");
|
||||
|
||||
.SetFunctionName("SystemInfo::IsMobile");
|
||||
extension.AddCondition("IsNativeMobileApp",
|
||||
_("Is a native mobile app"),
|
||||
_("Check if the game is running as a native mobile "
|
||||
"app (iOS or Android app)."),
|
||||
_("The game is running as a native mobile app"),
|
||||
"",
|
||||
"CppPlatform/Extensions/systeminfoicon.png",
|
||||
"CppPlatform/Extensions/systeminfoicon.png");
|
||||
|
||||
extension
|
||||
.AddCondition("IsNativeDesktopApp",
|
||||
_("Is a native desktop app"),
|
||||
_("Check if the game is running as a native desktop app."),
|
||||
_("The game is running as a native desktop app"),
|
||||
"",
|
||||
"CppPlatform/Extensions/systeminfoicon.png",
|
||||
"CppPlatform/Extensions/systeminfoicon.png")
|
||||
.AddCodeOnlyParameter("currentScene", "");
|
||||
|
||||
extension
|
||||
.AddCondition("IsWebGLSupported",
|
||||
|
@@ -28,6 +28,14 @@ class SystemInfoJsExtension : public gd::PlatformExtension {
|
||||
.codeExtraInformation
|
||||
.SetIncludeFile("Extensions/SystemInfo/systeminfotools.js")
|
||||
.SetFunctionName("gdjs.evtTools.systemInfo.isMobile");
|
||||
GetAllConditions()["SystemInfo::IsNativeMobileApp"]
|
||||
.codeExtraInformation
|
||||
.SetIncludeFile("Extensions/SystemInfo/systeminfotools.js")
|
||||
.SetFunctionName("gdjs.evtTools.systemInfo.isNativeMobileApp");
|
||||
GetAllConditions()["SystemInfo::IsNativeDesktopApp"]
|
||||
.codeExtraInformation
|
||||
.SetIncludeFile("Extensions/SystemInfo/systeminfotools.js")
|
||||
.SetFunctionName("gdjs.evtTools.systemInfo.isNativeDesktopApp");
|
||||
GetAllConditions()["SystemInfo::IsWebGLSupported"]
|
||||
.codeExtraInformation
|
||||
.SetIncludeFile("Extensions/SystemInfo/systeminfotools.js")
|
||||
|
@@ -59,6 +59,32 @@ namespace gdjs {
|
||||
}
|
||||
return (cachedIsMobile = checkIsMobile());
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if the game is running as a native mobile app - which in the case
|
||||
* of an exported GDevelop game means: running packaged inside Cordova/Capacitor.js.
|
||||
*
|
||||
* Note: this could be improved to also detect running inside an embedded webview.
|
||||
*
|
||||
* @returns true if running inside Cordova (or Capacitor.js).
|
||||
*/
|
||||
export const isNativeMobileApp = (): boolean => {
|
||||
return typeof window !== 'undefined' && (window as any).cordova;
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if the game is running as a native desktop app - which in the case
|
||||
* of an exported GDevelop game means: running packaged inside Electron.
|
||||
*
|
||||
* @param instanceContainer The current scene.
|
||||
* @returns true if running inside Electron.
|
||||
*/
|
||||
export const isNativeDesktopApp = (
|
||||
instanceContainer: gdjs.RuntimeInstanceContainer
|
||||
): boolean => {
|
||||
return !!instanceContainer.getGame().getRenderer().getElectron();
|
||||
};
|
||||
|
||||
const checkHasTouchScreen = (): boolean => {
|
||||
// First check if the device is mobile, as all mobile devices have a touchscreen
|
||||
// and some older browsers don't have support for `navigator.maxTouchPoints`
|
||||
|
@@ -9,13 +9,14 @@ This project is released under the MIT License.
|
||||
#include "GDCore/Tools/Localization.h"
|
||||
#include "TextEntryObject.h"
|
||||
|
||||
// Deprecated extension - so no translation markers and the object is hidden in the editor.
|
||||
void DeclareTextEntryObjectExtension(gd::PlatformExtension& extension) {
|
||||
extension
|
||||
.SetExtensionInformation(
|
||||
"TextEntryObject",
|
||||
_("Text entry object"),
|
||||
_("An object that can be used to capture the text "
|
||||
"entered with a keyboard by a player."),
|
||||
"Text entry object",
|
||||
"Deprecated object that can be used to capture the text "
|
||||
"entered with a keyboard by a player.",
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)")
|
||||
.SetCategory("User interface")
|
||||
@@ -24,71 +25,72 @@ void DeclareTextEntryObjectExtension(gd::PlatformExtension& extension) {
|
||||
gd::ObjectMetadata& obj =
|
||||
extension
|
||||
.AddObject<TextEntryObject>("TextEntry",
|
||||
_("Text entry"),
|
||||
_("Invisible object used to get the text "
|
||||
"entered with the keyboard."),
|
||||
"Text entry",
|
||||
"Invisible object used to get the text "
|
||||
"entered with the keyboard.",
|
||||
"CppPlatform/Extensions/textentry.png")
|
||||
.SetCategoryFullName(_("User interface"));
|
||||
.SetCategoryFullName("User interface")
|
||||
.SetHidden(); // Deprecated
|
||||
|
||||
obj.AddAction("String",
|
||||
_("Text in memory"),
|
||||
_("Modify text in memory of the object"),
|
||||
_("the text in memory"),
|
||||
"Text in memory",
|
||||
"Modify text in memory of the object",
|
||||
"the text in memory",
|
||||
"",
|
||||
"CppPlatform/Extensions/textentry24.png",
|
||||
"CppPlatform/Extensions/textentryicon.png")
|
||||
|
||||
.AddParameter("object", _("Object"), "TextEntry")
|
||||
.AddParameter("object", "Object", "TextEntry")
|
||||
.UseStandardOperatorParameters(
|
||||
"string",
|
||||
gd::ParameterOptions::MakeNewOptions().SetDescription(_("Text")))
|
||||
gd::ParameterOptions::MakeNewOptions().SetDescription("Text"))
|
||||
.SetFunctionName("SetString")
|
||||
.SetGetter("GetString");
|
||||
|
||||
obj.AddCondition("String",
|
||||
_("Text in memory"),
|
||||
_("Test the text of a Text Entry object."),
|
||||
_("the text"),
|
||||
"Text in memory",
|
||||
"Test the text of a Text Entry object.",
|
||||
"the text",
|
||||
"",
|
||||
"CppPlatform/Extensions/textentry24.png",
|
||||
"CppPlatform/Extensions/textentryicon.png")
|
||||
|
||||
.AddParameter("object", _("Object"), "TextEntry")
|
||||
.AddParameter("object", "Object", "TextEntry")
|
||||
.UseStandardRelationalOperatorParameters(
|
||||
"string",
|
||||
gd::ParameterOptions::MakeNewOptions().SetDescription(_("Text to compare to")))
|
||||
gd::ParameterOptions::MakeNewOptions().SetDescription("Text to compare to"))
|
||||
.SetFunctionName("GetString");
|
||||
|
||||
obj.AddAction(
|
||||
"Activate",
|
||||
_("De/activate capturing text input"),
|
||||
_("Activate or deactivate the capture of text entered with keyboard."),
|
||||
_("Activate capture by _PARAM0_ of the text entered with keyboard: "
|
||||
"_PARAM1_"),
|
||||
_("Setup"),
|
||||
"De/activate capturing text input",
|
||||
"Activate or deactivate the capture of text entered with keyboard.",
|
||||
"Activate capture by _PARAM0_ of the text entered with keyboard: "
|
||||
"_PARAM1_",
|
||||
"Setup",
|
||||
"CppPlatform/Extensions/textentry24.png",
|
||||
"CppPlatform/Extensions/textentryicon.png")
|
||||
|
||||
.AddParameter("object", _("Object"), "TextEntry")
|
||||
.AddParameter("yesorno", _("Activate"))
|
||||
.AddParameter("object", "Object", "TextEntry")
|
||||
.AddParameter("yesorno", "Activate")
|
||||
.SetFunctionName("Activate");
|
||||
|
||||
obj.AddCondition("Activated",
|
||||
_("Text input"),
|
||||
_("Test if the object captured text entered with keyboard."),
|
||||
_("_PARAM0_ capture the text entered with keyboard"),
|
||||
_("Setup"),
|
||||
"Text input",
|
||||
"Test if the object captured text entered with keyboard.",
|
||||
"_PARAM0_ capture the text entered with keyboard",
|
||||
"Setup",
|
||||
"CppPlatform/Extensions/textentry24.png",
|
||||
"CppPlatform/Extensions/textentryicon.png")
|
||||
|
||||
.AddParameter("object", _("Object"), "TextEntry")
|
||||
.AddParameter("object", "Object", "TextEntry")
|
||||
.SetFunctionName("IsActivated");
|
||||
|
||||
obj.AddStrExpression("String",
|
||||
_("Text entered with keyboard"),
|
||||
_("Text entered with keyboard"),
|
||||
_("Text entered with keyboard"),
|
||||
"Text entered with keyboard",
|
||||
"Text entered with keyboard",
|
||||
"Text entered with keyboard",
|
||||
"res/texteicon.png")
|
||||
.AddParameter("object", _("Object"), "TextEntry")
|
||||
.AddParameter("object", "Object", "TextEntry")
|
||||
.SetFunctionName("GetString");
|
||||
}
|
||||
|
@@ -25,16 +25,18 @@ module.exports = {
|
||||
gd /*: libGDevelop */
|
||||
) {
|
||||
const extension = new gd.PlatformExtension();
|
||||
extension.setExtensionInformation(
|
||||
'TextInput',
|
||||
_('Text Input'),
|
||||
_('A text field the player can type text into.'),
|
||||
'Florian Rival',
|
||||
'MIT'
|
||||
)
|
||||
.setCategory('User interface');
|
||||
extension.addInstructionOrExpressionGroupMetadata(_("Text Input"))
|
||||
.setIcon("JsPlatform/Extensions/text_input.svg");
|
||||
extension
|
||||
.setExtensionInformation(
|
||||
'TextInput',
|
||||
_('Text Input'),
|
||||
_('A text field the player can type text into.'),
|
||||
'Florian Rival',
|
||||
'MIT'
|
||||
)
|
||||
.setCategory('User interface');
|
||||
extension
|
||||
.addInstructionOrExpressionGroupMetadata(_('Text Input'))
|
||||
.setIcon('JsPlatform/Extensions/text_input.svg');
|
||||
|
||||
const textInputObject = new gd.ObjectJsImplementation();
|
||||
// $FlowExpectedError - ignore Flow warning as we're creating an object
|
||||
@@ -275,7 +277,7 @@ module.exports = {
|
||||
const object = extension
|
||||
.addObject(
|
||||
'TextInputObject',
|
||||
_('Text input (experimental)'),
|
||||
_('Text input'),
|
||||
_('A text field the player can type text into.'),
|
||||
'JsPlatform/Extensions/text_input.svg',
|
||||
textInputObject
|
||||
@@ -500,7 +502,10 @@ module.exports = {
|
||||
'res/conditions/text24_black.png'
|
||||
)
|
||||
.addParameter('object', _('Text input'), 'TextInputObject', false)
|
||||
.useStandardParameters('boolean', gd.ParameterOptions.makeNewOptions())
|
||||
.useStandardParameters(
|
||||
'boolean',
|
||||
gd.ParameterOptions.makeNewOptions().setDescription(_('Read-only?'))
|
||||
)
|
||||
.setFunctionName('setReadOnly')
|
||||
.setGetter('isReadOnly');
|
||||
|
||||
@@ -645,8 +650,7 @@ module.exports = {
|
||||
|
||||
update() {
|
||||
const instance = this._instance;
|
||||
const properties = this._associatedObjectConfiguration
|
||||
.getProperties();
|
||||
const properties = this._associatedObjectConfiguration.getProperties();
|
||||
|
||||
const placeholder =
|
||||
instance.getRawStringProperty('placeholder') ||
|
||||
|
@@ -87,7 +87,7 @@ void DeclareTextObjectExtension(gd::PlatformExtension& extension) {
|
||||
"res/conditions/scaleWidth_black.png")
|
||||
|
||||
.AddParameter("object", _("Object"), "Text")
|
||||
.UseStandardOperatorParameters(
|
||||
.UseStandardRelationalOperatorParameters(
|
||||
"number",
|
||||
gd::ParameterOptions::MakeNewOptions().SetDescription(
|
||||
_("Scale to compare to (1 by default)")))
|
||||
@@ -103,7 +103,7 @@ void DeclareTextObjectExtension(gd::PlatformExtension& extension) {
|
||||
"res/actions/scaleWidth_black.png")
|
||||
|
||||
.AddParameter("object", _("Object"), "Text")
|
||||
.UseStandardRelationalOperatorParameters(
|
||||
.UseStandardOperatorParameters(
|
||||
"number",
|
||||
gd::ParameterOptions::MakeNewOptions().SetDescription(
|
||||
_("Scale (1 by default)")))
|
||||
|
@@ -71,7 +71,8 @@ void TextObject::DoSerializeTo(gd::SerializerElement& element) const {
|
||||
element.SetAttribute("underlined", underlined);
|
||||
}
|
||||
|
||||
void TextObject::ExposeResources(gd::ArbitraryResourceWorker& worker) {
|
||||
void TextObject::ExposeResources(
|
||||
gd::ArbitraryResourceWorker& worker) {
|
||||
worker.ExposeFont(fontName);
|
||||
}
|
||||
#endif
|
||||
|
@@ -25,9 +25,7 @@ class GD_EXTENSION_API TextObject : public gd::ObjectConfiguration {
|
||||
return gd::make_unique<TextObject>(*this);
|
||||
}
|
||||
|
||||
#if defined(GD_IDE_ONLY)
|
||||
virtual void ExposeResources(gd::ArbitraryResourceWorker& worker);
|
||||
#endif
|
||||
|
||||
/** \brief Change the text.
|
||||
*/
|
||||
|
@@ -25,8 +25,8 @@ import { type ObjectsRenderingService, type ObjectsEditorService } from '../JsEx
|
||||
const defineTileMap = function (
|
||||
extension,
|
||||
_ /*: (string) => string */,
|
||||
gd /*: libGDevelop */) {
|
||||
|
||||
gd /*: libGDevelop */
|
||||
) {
|
||||
var objectTileMap = new gd.ObjectJsImplementation();
|
||||
// $FlowExpectedError - ignore Flow warning as we're creating an object
|
||||
objectTileMap.updateProperty = function (
|
||||
@@ -54,6 +54,10 @@ const defineTileMap = function (
|
||||
objectContent.layerIndex = parseFloat(newValue);
|
||||
return true;
|
||||
}
|
||||
if (propertyName === 'levelIndex') {
|
||||
objectContent.levelIndex = parseFloat(newValue);
|
||||
return true;
|
||||
}
|
||||
if (propertyName === 'animationSpeedScale') {
|
||||
objectContent.animationSpeedScale = parseFloat(newValue);
|
||||
return true;
|
||||
@@ -73,25 +77,27 @@ const defineTileMap = function (
|
||||
'tilemapJsonFile',
|
||||
new gd.PropertyDescriptor(objectContent.tilemapJsonFile)
|
||||
.setType('resource')
|
||||
.addExtraInfo('tilemap')
|
||||
.addExtraInfo('json')
|
||||
.setLabel(_('Tilemap JSON file'))
|
||||
.setLabel(_('Tilemap file (Tiled or LDtk)'))
|
||||
.setDescription(
|
||||
_('This is the JSON file that was saved or exported from Tiled.')
|
||||
_('This is the file that was saved or exported from Tiled/LDtk.')
|
||||
)
|
||||
.setGroup(_('Tilemap and tileset'))
|
||||
.setGroup(_('LDtk and Tiled: Tilemap'))
|
||||
);
|
||||
objectProperties.set(
|
||||
'tilesetJsonFile',
|
||||
new gd.PropertyDescriptor(objectContent.tilesetJsonFile || '')
|
||||
.setType('resource')
|
||||
.addExtraInfo('tileset')
|
||||
.addExtraInfo('json')
|
||||
.setLabel(_('Tileset JSON file (optional)'))
|
||||
.setDescription(
|
||||
_(
|
||||
"Optional, don't specify it if you've not saved the tileset in a different file."
|
||||
"Tiled only - not useful for LDtk files. Optional: specify this if you've saved the tileset in a different file as the Tiled tilemap."
|
||||
)
|
||||
)
|
||||
.setGroup(_('Tilemap and tileset'))
|
||||
.setGroup(_('Tiled only: Tileset and Atlas image'))
|
||||
);
|
||||
objectProperties.set(
|
||||
'tilemapAtlasImage',
|
||||
@@ -99,7 +105,12 @@ const defineTileMap = function (
|
||||
.setType('resource')
|
||||
.addExtraInfo('image')
|
||||
.setLabel(_('Atlas image'))
|
||||
.setGroup(_('Tilemap and tileset'))
|
||||
.setDescription(
|
||||
_(
|
||||
'Tiled only - not useful for LDtk files. The Atlas image containing the tileset.'
|
||||
)
|
||||
)
|
||||
.setGroup(_('Tiled only: Tileset and Atlas image'))
|
||||
);
|
||||
objectProperties.set(
|
||||
'displayMode',
|
||||
@@ -123,6 +134,14 @@ const defineTileMap = function (
|
||||
)
|
||||
.setGroup(_('Appearance'))
|
||||
);
|
||||
objectProperties.set(
|
||||
'levelIndex',
|
||||
new gd.PropertyDescriptor((objectContent.levelIndex || 0).toString())
|
||||
.setType('number')
|
||||
.setLabel(_('Level index to display'))
|
||||
.setDescription(_('Select which level to render via its index (LDtk)'))
|
||||
.setGroup(_('Appearance'))
|
||||
);
|
||||
objectProperties.set(
|
||||
'animationSpeedScale',
|
||||
new gd.PropertyDescriptor(objectContent.animationSpeedScale.toString())
|
||||
@@ -147,6 +166,7 @@ const defineTileMap = function (
|
||||
tilemapAtlasImage: '',
|
||||
displayMode: 'visible',
|
||||
layerIndex: 0,
|
||||
levelIndex: 0,
|
||||
animationSpeedScale: 1,
|
||||
animationFps: 4,
|
||||
})
|
||||
@@ -179,7 +199,7 @@ const defineTileMap = function (
|
||||
'TileMap',
|
||||
_('Tilemap'),
|
||||
_(
|
||||
'Displays a tiled-based map, made with the Tiled editor (download it separately on https://www.mapeditor.org/).'
|
||||
'Displays a tiled-based map, made with the Tiled editor (https://www.mapeditor.org/) or the LDtk editor (https://ldtk.io/).'
|
||||
),
|
||||
'JsPlatform/Extensions/tile_map.svg',
|
||||
objectTileMap
|
||||
@@ -187,44 +207,50 @@ const defineTileMap = function (
|
||||
.setCategoryFullName(_('Advanced'))
|
||||
.setIncludeFile('Extensions/TileMap/tilemapruntimeobject.js')
|
||||
.addIncludeFile('Extensions/TileMap/TileMapRuntimeManager.js')
|
||||
.addIncludeFile(
|
||||
'Extensions/TileMap/tilemapruntimeobject-pixi-renderer.js'
|
||||
)
|
||||
.addIncludeFile(
|
||||
'Extensions/TileMap/pixi-tilemap/dist/pixi-tilemap.umd.js'
|
||||
)
|
||||
.addIncludeFile('Extensions/TileMap/tilemapruntimeobject-pixi-renderer.js')
|
||||
.addIncludeFile('Extensions/TileMap/pixi-tilemap/dist/pixi-tilemap.umd.js')
|
||||
.addIncludeFile('Extensions/TileMap/pako/dist/pako.min.js')
|
||||
.addIncludeFile('Extensions/TileMap/helper/TileMapHelper.js');
|
||||
|
||||
object
|
||||
.addCondition(
|
||||
'TilemapJsonFile',
|
||||
_('Tilemap JSON file'),
|
||||
_('Check the Tilemap JSON file being used.'),
|
||||
_('The Tilemap JSON file of _PARAM0_ is _PARAM1_'),
|
||||
_('Tilemap file (Tiled or LDtk)'),
|
||||
_('Check the tilemap file (Tiled or LDtk) being used.'),
|
||||
_('The tilemap file of _PARAM0_ is _PARAM1_'),
|
||||
'',
|
||||
'JsPlatform/Extensions/tile_map.svg',
|
||||
'JsPlatform/Extensions/tile_map.svg'
|
||||
)
|
||||
.addParameter('object', _('Tile map'), 'TileMap', false)
|
||||
.addParameter('jsonResource', _('Tilemap JSON file'), '', false)
|
||||
.addParameter(
|
||||
'tilemapResource',
|
||||
_('Tilemap file (Tiled or LDtk)'),
|
||||
'',
|
||||
false
|
||||
)
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('isTilemapJsonFile');
|
||||
|
||||
object
|
||||
.addAction(
|
||||
'SetTilemapJsonFile',
|
||||
_('Tilemap JSON file'),
|
||||
_('Tilemap file (Tiled or LDtk)'),
|
||||
_(
|
||||
'Set the JSON file containing the Tilemap data to display. This is usually the JSON file exported from Tiled.'
|
||||
'Set the Tiled or LDtk file containing the Tilemap data to display. This is usually the main file exported from Tiled/LDtk.'
|
||||
),
|
||||
_('Set the Tilemap JSON file of _PARAM0_ to _PARAM1_'),
|
||||
_('Set the tilemape file of _PARAM0_ to _PARAM1_'),
|
||||
'',
|
||||
'JsPlatform/Extensions/tile_map.svg',
|
||||
'JsPlatform/Extensions/tile_map.svg'
|
||||
)
|
||||
.addParameter('object', _('Tile map'), 'TileMap', false)
|
||||
.addParameter('jsonResource', _('Tilemap JSON file'), '', false)
|
||||
.addParameter(
|
||||
'tilemapResource',
|
||||
_('Tilemap file (Tiled or LDtk)'),
|
||||
'',
|
||||
false
|
||||
)
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('setTilemapJsonFile');
|
||||
|
||||
@@ -239,7 +265,7 @@ const defineTileMap = function (
|
||||
'JsPlatform/Extensions/tile_map.svg'
|
||||
)
|
||||
.addParameter('object', _('Tile map'), 'TileMap', false)
|
||||
.addParameter('jsonResource', _('Tileset JSON file'), '', false)
|
||||
.addParameter('tilesetResource', _('Tileset JSON file'), '', false)
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('isTilesetJsonFile');
|
||||
|
||||
@@ -256,7 +282,7 @@ const defineTileMap = function (
|
||||
'JsPlatform/Extensions/tile_map.svg'
|
||||
)
|
||||
.addParameter('object', _('Tile map'), 'TileMap', false)
|
||||
.addParameter('jsonResource', _('Tileset JSON file'), '', false)
|
||||
.addParameter('tilesetResource', _('Tileset JSON file'), '', false)
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('setTilesetJsonFile');
|
||||
|
||||
@@ -349,6 +375,20 @@ const defineTileMap = function (
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('getLayerIndex');
|
||||
|
||||
object
|
||||
.addExpressionAndCondition(
|
||||
'number',
|
||||
'LevelIndex',
|
||||
_('Level index'),
|
||||
_('the level index being displayed.'),
|
||||
_('the level index'),
|
||||
'',
|
||||
'JsPlatform/Extensions/tile_map.svg'
|
||||
)
|
||||
.addParameter('object', _('Tile map'), 'TileMap', false)
|
||||
.useStandardParameters('number', gd.ParameterOptions.makeNewOptions())
|
||||
.setFunctionName('getLevelndex');
|
||||
|
||||
object
|
||||
.addCondition(
|
||||
'AnimationSpeedScale',
|
||||
@@ -508,22 +548,25 @@ const defineTileMap = function (
|
||||
'res/actions/scaleHeight24_black.png'
|
||||
)
|
||||
.addParameter('object', _('Tile map'), 'TileMap', false)
|
||||
.useStandardParameters('number', gd.ParameterOptions.makeNewOptions().setDescription(
|
||||
_('Scale (1 by default)')
|
||||
))
|
||||
.useStandardParameters(
|
||||
'number',
|
||||
gd.ParameterOptions.makeNewOptions().setDescription(
|
||||
_('Scale (1 by default)')
|
||||
)
|
||||
)
|
||||
.markAsAdvanced()
|
||||
.setFunctionName('setScaleY')
|
||||
.setGetter('getScaleY');
|
||||
|
||||
object
|
||||
.addAction(
|
||||
"Width",
|
||||
_("Width"),
|
||||
_("Change the width of an object."),
|
||||
_("the width"),
|
||||
_("Size"),
|
||||
"res/actions/scaleWidth24_black.png",
|
||||
"res/actions/scaleWidth_black.png"
|
||||
'Width',
|
||||
_('Width'),
|
||||
_('Change the width of an object.'),
|
||||
_('the width'),
|
||||
_('Size'),
|
||||
'res/actions/scaleWidth24_black.png',
|
||||
'res/actions/scaleWidth_black.png'
|
||||
)
|
||||
.addParameter('object', _('Tile map'), 'TileMap', false)
|
||||
.useStandardOperatorParameters(
|
||||
@@ -536,13 +579,13 @@ const defineTileMap = function (
|
||||
|
||||
object
|
||||
.addAction(
|
||||
"Height",
|
||||
_("Height"),
|
||||
_("Change the height of an object."),
|
||||
_("the height"),
|
||||
_("Size"),
|
||||
"res/actions/scaleHeight24_black.png",
|
||||
"res/actions/scaleHeight_black.png"
|
||||
'Height',
|
||||
_('Height'),
|
||||
_('Change the height of an object.'),
|
||||
_('the height'),
|
||||
_('Size'),
|
||||
'res/actions/scaleHeight24_black.png',
|
||||
'res/actions/scaleHeight_black.png'
|
||||
)
|
||||
.addParameter('object', _('Tile map'), 'TileMap', false)
|
||||
.useStandardOperatorParameters(
|
||||
@@ -557,8 +600,8 @@ const defineTileMap = function (
|
||||
const defineCollisionMask = function (
|
||||
extension,
|
||||
_ /*: (string) => string */,
|
||||
gd /*: libGDevelop */) {
|
||||
|
||||
gd /*: libGDevelop */
|
||||
) {
|
||||
var collisionMaskObject = new gd.ObjectJsImplementation();
|
||||
// $FlowExpectedError - ignore Flow warning as we're creating an object
|
||||
collisionMaskObject.updateProperty = function (
|
||||
@@ -616,7 +659,9 @@ const defineCollisionMask = function (
|
||||
.addExtraInfo('json')
|
||||
.setLabel(_('Tilemap JSON file'))
|
||||
.setDescription(
|
||||
_('This is the JSON file that was saved or exported from Tiled.')
|
||||
_(
|
||||
'This is the JSON file that was saved or exported from Tiled. LDtk is not supported yet for collisions.'
|
||||
)
|
||||
)
|
||||
);
|
||||
objectProperties.set(
|
||||
@@ -659,13 +704,21 @@ const defineCollisionMask = function (
|
||||
);
|
||||
objectProperties.set(
|
||||
'outlineOpacity',
|
||||
new gd.PropertyDescriptor(objectContent.outlineOpacity === undefined ? '64' : objectContent.outlineOpacity.toString())
|
||||
new gd.PropertyDescriptor(
|
||||
objectContent.outlineOpacity === undefined
|
||||
? '64'
|
||||
: objectContent.outlineOpacity.toString()
|
||||
)
|
||||
.setType('number')
|
||||
.setLabel(_('Outline opacity (0-255)'))
|
||||
);
|
||||
objectProperties.set(
|
||||
'outlineSize',
|
||||
new gd.PropertyDescriptor(objectContent.outlineSize === undefined ? '1' : objectContent.outlineSize.toString())
|
||||
new gd.PropertyDescriptor(
|
||||
objectContent.outlineSize === undefined
|
||||
? '1'
|
||||
: objectContent.outlineSize.toString()
|
||||
)
|
||||
.setType('number')
|
||||
.setLabel(_('Outline size (in pixels)'))
|
||||
);
|
||||
@@ -677,7 +730,11 @@ const defineCollisionMask = function (
|
||||
);
|
||||
objectProperties.set(
|
||||
'fillOpacity',
|
||||
new gd.PropertyDescriptor(objectContent.fillOpacity === undefined ? '32' : objectContent.fillOpacity.toString())
|
||||
new gd.PropertyDescriptor(
|
||||
objectContent.fillOpacity === undefined
|
||||
? '32'
|
||||
: objectContent.fillOpacity.toString()
|
||||
)
|
||||
.setType('number')
|
||||
.setLabel(_('Fill opacity (0-255)'))
|
||||
);
|
||||
@@ -723,7 +780,7 @@ const defineCollisionMask = function (
|
||||
const object = extension
|
||||
.addObject(
|
||||
'CollisionMask',
|
||||
_('Tilemap collision mask (experimental)'),
|
||||
_('Tilemap collision mask'),
|
||||
_('Invisible object handling collisions with parts of a tilemap.'),
|
||||
'JsPlatform/Extensions/tile_map_collision_mask32.svg',
|
||||
collisionMaskObject
|
||||
@@ -748,7 +805,12 @@ const defineCollisionMask = function (
|
||||
'JsPlatform/Extensions/tile_map_collision_mask24.svg',
|
||||
'JsPlatform/Extensions/tile_map_collision_mask32.svg'
|
||||
)
|
||||
.addParameter('object', _('Tile map collision mask'), 'CollisionMask', false)
|
||||
.addParameter(
|
||||
'object',
|
||||
_('Tile map collision mask'),
|
||||
'CollisionMask',
|
||||
false
|
||||
)
|
||||
.addParameter('jsonResource', _('Tilemap JSON file'), '', false)
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('isTilemapJsonFile');
|
||||
@@ -765,7 +827,12 @@ const defineCollisionMask = function (
|
||||
'JsPlatform/Extensions/tile_map_collision_mask24.svg',
|
||||
'JsPlatform/Extensions/tile_map_collision_mask32.svg'
|
||||
)
|
||||
.addParameter('object', _('Tile map collision mask'), 'CollisionMask', false)
|
||||
.addParameter(
|
||||
'object',
|
||||
_('Tile map collision mask'),
|
||||
'CollisionMask',
|
||||
false
|
||||
)
|
||||
.addParameter('jsonResource', _('Tilemap JSON file'), '', false)
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('setTilemapJsonFile');
|
||||
@@ -780,7 +847,12 @@ const defineCollisionMask = function (
|
||||
'JsPlatform/Extensions/tile_map_collision_mask24.svg',
|
||||
'JsPlatform/Extensions/tile_map_collision_mask32.svg'
|
||||
)
|
||||
.addParameter('object', _('Tile map collision mask'), 'CollisionMask', false)
|
||||
.addParameter(
|
||||
'object',
|
||||
_('Tile map collision mask'),
|
||||
'CollisionMask',
|
||||
false
|
||||
)
|
||||
.addParameter('jsonResource', _('Tileset JSON file'), '', false)
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('isTilesetJsonFile');
|
||||
@@ -797,7 +869,12 @@ const defineCollisionMask = function (
|
||||
'JsPlatform/Extensions/tile_map_collision_mask24.svg',
|
||||
'JsPlatform/Extensions/tile_map_collision_mask32.svg'
|
||||
)
|
||||
.addParameter('object', _('Tile map collision mask'), 'CollisionMask', false)
|
||||
.addParameter(
|
||||
'object',
|
||||
_('Tile map collision mask'),
|
||||
'CollisionMask',
|
||||
false
|
||||
)
|
||||
.addParameter('jsonResource', _('Tileset JSON file'), '', false)
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('setTilesetJsonFile');
|
||||
@@ -935,6 +1012,7 @@ module.exports = {
|
||||
gd /*: libGDevelop */
|
||||
) {
|
||||
const extension = new gd.PlatformExtension();
|
||||
|
||||
extension
|
||||
.setExtensionInformation(
|
||||
'TileMap',
|
||||
@@ -945,11 +1023,13 @@ module.exports = {
|
||||
)
|
||||
.setCategory('Advanced')
|
||||
.setExtensionHelpPath('/objects/tilemap');
|
||||
extension.addInstructionOrExpressionGroupMetadata(_("Tilemap"))
|
||||
.setIcon("JsPlatform/Extensions/tile_map.svg");
|
||||
|
||||
defineTileMap(extension, _, gd);
|
||||
defineCollisionMask(extension, _, gd);
|
||||
extension
|
||||
.addInstructionOrExpressionGroupMetadata(_('Tilemap'))
|
||||
.setIcon('JsPlatform/Extensions/tile_map.svg');
|
||||
|
||||
defineTileMap(extension, _, gd);
|
||||
defineCollisionMask(extension, _, gd);
|
||||
|
||||
return extension;
|
||||
},
|
||||
@@ -1075,8 +1155,9 @@ module.exports = {
|
||||
);
|
||||
|
||||
RenderedTileMapInstance.prototype.onLoadingError = function () {
|
||||
this.errorPixiObject = this.errorPixiObject ||
|
||||
new PIXI.Sprite(this._pixiResourcesLoader.getInvalidPIXITexture());
|
||||
this.errorPixiObject =
|
||||
this.errorPixiObject ||
|
||||
new PIXI.Sprite(this._pixiResourcesLoader.getInvalidPIXITexture());
|
||||
this._pixiContainer.addChild(this.errorPixiObject);
|
||||
this._pixiObject = this.errorPixiObject;
|
||||
};
|
||||
@@ -1124,33 +1205,59 @@ module.exports = {
|
||||
.getValue(),
|
||||
10
|
||||
);
|
||||
const levelIndex = parseInt(
|
||||
this._associatedObjectConfiguration
|
||||
.getProperties(this.project)
|
||||
.get('levelIndex')
|
||||
.getValue(),
|
||||
10
|
||||
);
|
||||
const displayMode = this._associatedObjectConfiguration
|
||||
.getProperties(this.project)
|
||||
.get('displayMode')
|
||||
.getValue();
|
||||
|
||||
const tilemapResource = this._project
|
||||
.getResourcesManager()
|
||||
.getResource(tilemapJsonFile);
|
||||
|
||||
let metadata = {};
|
||||
try {
|
||||
const tilemapMetadataAsString = tilemapResource.getMetadata();
|
||||
if (tilemapMetadataAsString)
|
||||
metadata = JSON.parse(tilemapMetadataAsString);
|
||||
} catch (error) {
|
||||
console.warn('Malformed metadata in a tilemap object:', error);
|
||||
}
|
||||
const mapping = metadata.embeddedResourcesMapping || {};
|
||||
|
||||
/** @type {TileMapHelper.TileMapManager} */
|
||||
const manager = TilemapHelper.TileMapManager.getManager(this._project);
|
||||
manager.getOrLoadTileMap(
|
||||
this._loadTiledMapWithCallback.bind(this),
|
||||
this._loadTileMapWithCallback.bind(this),
|
||||
tilemapJsonFile,
|
||||
tilesetJsonFile,
|
||||
levelIndex,
|
||||
pako,
|
||||
(tileMap) => {
|
||||
if (!tileMap) {
|
||||
this.onLoadingError();
|
||||
// _loadTiledMapWithCallback already log errors
|
||||
// _loadTileMapWithCallback already log errors
|
||||
return;
|
||||
}
|
||||
|
||||
/** @type {TileMapHelper.TileTextureCache} */
|
||||
const textureCache = manager.getOrLoadTextureCache(
|
||||
this._loadTiledMapWithCallback.bind(this),
|
||||
this._loadTileMapWithCallback.bind(this),
|
||||
(textureName) =>
|
||||
this._pixiResourcesLoader.getPIXITexture(this._project, textureName),
|
||||
this._pixiResourcesLoader.getPIXITexture(
|
||||
this._project,
|
||||
mapping[textureName] || textureName
|
||||
),
|
||||
tilemapAtlasImage,
|
||||
tilemapJsonFile,
|
||||
tilesetJsonFile,
|
||||
levelIndex,
|
||||
(textureCache) => {
|
||||
if (!textureCache) {
|
||||
this.onLoadingError();
|
||||
@@ -1175,18 +1282,18 @@ module.exports = {
|
||||
};
|
||||
|
||||
// GDJS doesn't use Promise to avoid allocation.
|
||||
RenderedTileMapInstance.prototype._loadTiledMapWithCallback = function (
|
||||
RenderedTileMapInstance.prototype._loadTileMapWithCallback = function (
|
||||
tilemapJsonFile,
|
||||
tilesetJsonFile,
|
||||
callback
|
||||
) {
|
||||
this._loadTiledMap(tilemapJsonFile, tilesetJsonFile).then(callback);
|
||||
this._loadTileMap(tilemapJsonFile, tilesetJsonFile).then(callback);
|
||||
};
|
||||
|
||||
RenderedTileMapInstance.prototype._loadTiledMap = async function (
|
||||
RenderedTileMapInstance.prototype._loadTileMap = async function (
|
||||
tilemapJsonFile,
|
||||
tilesetJsonFile) {
|
||||
|
||||
tilesetJsonFile
|
||||
) {
|
||||
let tileMapJsonData = null;
|
||||
try {
|
||||
tileMapJsonData = await this._pixiResourcesLoader.getResourceJsonData(
|
||||
@@ -1194,20 +1301,25 @@ module.exports = {
|
||||
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];
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Unable to load a Tilemap JSON data: ', err);
|
||||
}
|
||||
return tileMapJsonData;
|
||||
|
||||
return tileMap;
|
||||
} catch (err) {
|
||||
console.error('Unable to load a Tilemap JSON data: ', err);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -1216,7 +1328,8 @@ module.exports = {
|
||||
RenderedTileMapInstance.prototype.update = function () {
|
||||
if (this._instance.hasCustomSize()) {
|
||||
this._pixiObject.scale.x = this._instance.getCustomWidth() / this.width;
|
||||
this._pixiObject.scale.y = this._instance.getCustomHeight() / this.height;
|
||||
this._pixiObject.scale.y =
|
||||
this._instance.getCustomHeight() / this.height;
|
||||
} else {
|
||||
this._pixiObject.scale.x = 1;
|
||||
this._pixiObject.scale.y = 1;
|
||||
@@ -1233,8 +1346,12 @@ module.exports = {
|
||||
// Modifying the pivot position also has an impact on the transform. The instance (X,Y) position
|
||||
// of this object refers to the top-left point, but now in Pixi, as we changed the pivot, the Pixi
|
||||
// object (X,Y) position refers to the center. So we add an offset to convert from top-left to center.
|
||||
this._pixiObject.x = this._instance.getX() + this._pixiObject.pivot.x * this._pixiObject.scale.x;
|
||||
this._pixiObject.y = this._instance.getY() + this._pixiObject.pivot.y * this._pixiObject.scale.y;
|
||||
this._pixiObject.x =
|
||||
this._instance.getX() +
|
||||
this._pixiObject.pivot.x * this._pixiObject.scale.x;
|
||||
this._pixiObject.y =
|
||||
this._instance.getY() +
|
||||
this._pixiObject.pivot.y * this._pixiObject.scale.y;
|
||||
|
||||
// Rotation works as intended because we put the pivot in the center
|
||||
this._pixiObject.rotation = RenderedInstance.toRad(
|
||||
@@ -1268,7 +1385,7 @@ module.exports = {
|
||||
* @class RenderedTileMapInstance
|
||||
* @constructor
|
||||
*/
|
||||
function RenderedCollisionMaskInstance(
|
||||
function RenderedCollisionMaskInstance(
|
||||
project,
|
||||
layout,
|
||||
instance,
|
||||
@@ -1317,8 +1434,9 @@ module.exports = {
|
||||
);
|
||||
|
||||
RenderedCollisionMaskInstance.prototype.onLoadingError = function () {
|
||||
this.errorPixiObject = this.errorPixiObject ||
|
||||
new PIXI.Sprite(this._pixiResourcesLoader.getInvalidPIXITexture());
|
||||
this.errorPixiObject =
|
||||
this.errorPixiObject ||
|
||||
new PIXI.Sprite(this._pixiResourcesLoader.getInvalidPIXITexture());
|
||||
this._pixiContainer.addChild(this.errorPixiObject);
|
||||
this._pixiObject = this.errorPixiObject;
|
||||
};
|
||||
@@ -1334,7 +1452,7 @@ module.exports = {
|
||||
/**
|
||||
* Return the path to the thumbnail of the specified object.
|
||||
*/
|
||||
RenderedCollisionMaskInstance.getThumbnail = function (
|
||||
RenderedCollisionMaskInstance.getThumbnail = function (
|
||||
project,
|
||||
resourcesLoader,
|
||||
objectConfiguration
|
||||
@@ -1345,45 +1463,47 @@ module.exports = {
|
||||
/**
|
||||
* This is used to reload the Tilemap
|
||||
*/
|
||||
RenderedCollisionMaskInstance.prototype.updateTileMap = function () {
|
||||
RenderedCollisionMaskInstance.prototype.updateTileMap = function () {
|
||||
// Get the tileset resource to use
|
||||
const tilemapAtlasImage = this._associatedObjectConfiguration
|
||||
.getProperties(this.project)
|
||||
.get('tilemapAtlasImage')
|
||||
.getValue();
|
||||
const tilemapJsonFile = this._associatedObjectConfiguration
|
||||
.getProperties(this.project)
|
||||
.get('tilemapJsonFile')
|
||||
.getValue();
|
||||
const tilesetJsonFile = this._associatedObjectConfiguration
|
||||
.getProperties(this.project)
|
||||
.get('tilesetJsonFile')
|
||||
.getValue();
|
||||
const collisionMaskTag = this._associatedObjectConfiguration
|
||||
.getProperties(this.project)
|
||||
.get('collisionMaskTag')
|
||||
.getValue();
|
||||
const outlineColor = objectsRenderingService.rgbOrHexToHexNumber(
|
||||
this._associatedObjectConfiguration
|
||||
.getProperties(this.project)
|
||||
.get('outlineColor')
|
||||
.getValue()
|
||||
);
|
||||
const fillColor = objectsRenderingService.rgbOrHexToHexNumber(
|
||||
this._associatedObjectConfiguration
|
||||
.get('tilemapAtlasImage')
|
||||
.getValue();
|
||||
const tilemapJsonFile = this._associatedObjectConfiguration
|
||||
.getProperties(this.project)
|
||||
.get('fillColor')
|
||||
.getValue()
|
||||
);
|
||||
const outlineOpacity = this._associatedObjectConfiguration
|
||||
.getProperties(this.project)
|
||||
.get('outlineOpacity')
|
||||
.getValue() / 255;
|
||||
const fillOpacity = this._associatedObjectConfiguration
|
||||
.getProperties(this.project)
|
||||
.get('fillOpacity')
|
||||
.getValue() / 255;
|
||||
const outlineSize = 1;
|
||||
.get('tilemapJsonFile')
|
||||
.getValue();
|
||||
const tilesetJsonFile = this._associatedObjectConfiguration
|
||||
.getProperties(this.project)
|
||||
.get('tilesetJsonFile')
|
||||
.getValue();
|
||||
const collisionMaskTag = this._associatedObjectConfiguration
|
||||
.getProperties(this.project)
|
||||
.get('collisionMaskTag')
|
||||
.getValue();
|
||||
const outlineColor = objectsRenderingService.rgbOrHexToHexNumber(
|
||||
this._associatedObjectConfiguration
|
||||
.getProperties(this.project)
|
||||
.get('outlineColor')
|
||||
.getValue()
|
||||
);
|
||||
const fillColor = objectsRenderingService.rgbOrHexToHexNumber(
|
||||
this._associatedObjectConfiguration
|
||||
.getProperties(this.project)
|
||||
.get('fillColor')
|
||||
.getValue()
|
||||
);
|
||||
const outlineOpacity =
|
||||
this._associatedObjectConfiguration
|
||||
.getProperties(this.project)
|
||||
.get('outlineOpacity')
|
||||
.getValue() / 255;
|
||||
const fillOpacity =
|
||||
this._associatedObjectConfiguration
|
||||
.getProperties(this.project)
|
||||
.get('fillOpacity')
|
||||
.getValue() / 255;
|
||||
const outlineSize = 1;
|
||||
|
||||
/** @type {TileMapHelper.TileMapManager} */
|
||||
const manager = TilemapHelper.TileMapManager.getManager(this._project);
|
||||
@@ -1391,6 +1511,7 @@ module.exports = {
|
||||
this._loadTiledMapWithCallback.bind(this),
|
||||
tilemapJsonFile,
|
||||
tilesetJsonFile,
|
||||
0, // leveIndex
|
||||
pako,
|
||||
(tileMap) => {
|
||||
if (!tileMap) {
|
||||
@@ -1412,48 +1533,20 @@ module.exports = {
|
||||
fillColor,
|
||||
fillOpacity
|
||||
);
|
||||
|
||||
// const textureCache = manager.getOrLoadTextureCache(
|
||||
// this._loadTiledMapWithCallback.bind(this),
|
||||
// (textureName) =>
|
||||
// this._pixiResourcesLoader.getPIXITexture(this._project, textureName),
|
||||
// tilemapAtlasImage,
|
||||
// tilemapJsonFile,
|
||||
// tilesetJsonFile,
|
||||
// (textureCache) => {
|
||||
// if (!textureCache) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// let tileId = -1;
|
||||
// for (const definition of tileMap.getTileDefinitions()) {
|
||||
// if (definition.getTag() === collisionMaskTag) {
|
||||
// tileId = definition.getTag();
|
||||
// }
|
||||
// }
|
||||
// if (tileId >= 0) {
|
||||
// const texture = textureCache.findTileTexture(tileId, false, false, false);
|
||||
// // TODO set the thumbnail from this texture
|
||||
// }
|
||||
// }
|
||||
// );
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
// GDJS doesn't use Promise to avoid allocation.
|
||||
RenderedCollisionMaskInstance.prototype._loadTiledMapWithCallback = function (
|
||||
tilemapJsonFile,
|
||||
tilesetJsonFile,
|
||||
callback
|
||||
) {
|
||||
this._loadTiledMap(tilemapJsonFile, tilesetJsonFile).then(callback);
|
||||
};
|
||||
RenderedCollisionMaskInstance.prototype._loadTiledMapWithCallback =
|
||||
function (tilemapJsonFile, tilesetJsonFile, callback) {
|
||||
this._loadTiledMap(tilemapJsonFile, tilesetJsonFile).then(callback);
|
||||
};
|
||||
|
||||
RenderedCollisionMaskInstance.prototype._loadTiledMap = async function (
|
||||
tilemapJsonFile,
|
||||
tilesetJsonFile) {
|
||||
|
||||
tilesetJsonFile
|
||||
) {
|
||||
let tileMapJsonData = null;
|
||||
try {
|
||||
tileMapJsonData = await this._pixiResourcesLoader.getResourceJsonData(
|
||||
@@ -1471,19 +1564,20 @@ module.exports = {
|
||||
if (tilesetJsonData) {
|
||||
tileMapJsonData.tilesets = [tilesetJsonData];
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Unable to load a Tilemap JSON data: ', err);
|
||||
}
|
||||
return tileMapJsonData;
|
||||
} catch (err) {
|
||||
console.error('Unable to load a Tilemap JSON data: ', err);
|
||||
}
|
||||
return tileMapJsonData;
|
||||
};
|
||||
|
||||
/**
|
||||
* This is called to update the PIXI object on the scene editor
|
||||
*/
|
||||
RenderedCollisionMaskInstance.prototype.update = function () {
|
||||
RenderedCollisionMaskInstance.prototype.update = function () {
|
||||
if (this._instance.hasCustomSize()) {
|
||||
this._pixiObject.scale.x = this._instance.getCustomWidth() / this.width;
|
||||
this._pixiObject.scale.y = this._instance.getCustomHeight() / this.height;
|
||||
this._pixiObject.scale.y =
|
||||
this._instance.getCustomHeight() / this.height;
|
||||
} else {
|
||||
this._pixiObject.scale.x = 1;
|
||||
this._pixiObject.scale.y = 1;
|
||||
@@ -1500,8 +1594,12 @@ module.exports = {
|
||||
// Modifying the pivot position also has an impact on the transform. The instance (X,Y) position
|
||||
// of this object refers to the top-left point, but now in Pixi, as we changed the pivot, the Pixi
|
||||
// object (X,Y) position refers to the center. So we add an offset to convert from top-left to center.
|
||||
this._pixiObject.x = this._instance.getX() + this._pixiObject.pivot.x * this._pixiObject.scale.x;
|
||||
this._pixiObject.y = this._instance.getY() + this._pixiObject.pivot.y * this._pixiObject.scale.y;
|
||||
this._pixiObject.x =
|
||||
this._instance.getX() +
|
||||
this._pixiObject.pivot.x * this._pixiObject.scale.x;
|
||||
this._pixiObject.y =
|
||||
this._instance.getY() +
|
||||
this._pixiObject.pivot.y * this._pixiObject.scale.y;
|
||||
|
||||
// Rotation works as intended because we put the pivot in the center
|
||||
this._pixiObject.rotation = RenderedInstance.toRad(
|
||||
@@ -1512,14 +1610,14 @@ module.exports = {
|
||||
/**
|
||||
* Return the width of the instance, when it's not resized.
|
||||
*/
|
||||
RenderedCollisionMaskInstance.prototype.getDefaultWidth = function () {
|
||||
RenderedCollisionMaskInstance.prototype.getDefaultWidth = function () {
|
||||
return this.width;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return the height of the instance, when it's not resized.
|
||||
*/
|
||||
RenderedCollisionMaskInstance.prototype.getDefaultHeight = function () {
|
||||
RenderedCollisionMaskInstance.prototype.getDefaultHeight = function () {
|
||||
return this.height;
|
||||
};
|
||||
|
||||
|
@@ -60,17 +60,20 @@ namespace gdjs {
|
||||
/**
|
||||
* @param tileMapJsonResourceName The resource name of the tile map.
|
||||
* @param tileSetJsonResourceName The resource name of the tile set.
|
||||
* @param levelIndex The level of the tile map.
|
||||
* @param callback A function called when the tile map is parsed.
|
||||
*/
|
||||
getOrLoadTileMap(
|
||||
tileMapJsonResourceName: string,
|
||||
tileSetJsonResourceName: string,
|
||||
levelIndex: number,
|
||||
callback: (tileMap: TileMapHelper.EditableTileMap | null) => void
|
||||
): void {
|
||||
this._manager.getOrLoadTileMap(
|
||||
this._loadTiledMap.bind(this),
|
||||
this._loadTileMap.bind(this),
|
||||
tileMapJsonResourceName,
|
||||
tileSetJsonResourceName,
|
||||
levelIndex,
|
||||
pako,
|
||||
callback
|
||||
);
|
||||
@@ -81,6 +84,7 @@ namespace gdjs {
|
||||
* @param atlasImageResourceName The resource name of the atlas image.
|
||||
* @param tileMapJsonResourceName The resource name of the tile map.
|
||||
* @param tileSetJsonResourceName The resource name of the tile set.
|
||||
* @param levelIndex The level of the tile map.
|
||||
* @param callback A function called when the tiles textures are split.
|
||||
*/
|
||||
getOrLoadTextureCache(
|
||||
@@ -88,14 +92,16 @@ namespace gdjs {
|
||||
atlasImageResourceName: string,
|
||||
tileMapJsonResourceName: string,
|
||||
tileSetJsonResourceName: string,
|
||||
levelIndex: number,
|
||||
callback: (textureCache: TileMapHelper.TileTextureCache | null) => void
|
||||
): void {
|
||||
this._manager.getOrLoadTextureCache(
|
||||
this._loadTiledMap.bind(this),
|
||||
this._loadTileMap.bind(this),
|
||||
getTexture,
|
||||
atlasImageResourceName,
|
||||
tileMapJsonResourceName,
|
||||
tileSetJsonResourceName,
|
||||
levelIndex,
|
||||
callback
|
||||
);
|
||||
}
|
||||
@@ -104,10 +110,10 @@ namespace gdjs {
|
||||
* Parse both JSON and set the content of the tile set in the right
|
||||
* attribute in the tile map to merge both parsed data.
|
||||
*/
|
||||
private _loadTiledMap(
|
||||
private _loadTileMap(
|
||||
tileMapJsonResourceName: string,
|
||||
tileSetJsonResourceName: string,
|
||||
callback: (tiledMap: TileMapHelper.TiledMap | null) => void
|
||||
callback: (tileMap: TileMapHelper.TileMap | null) => void
|
||||
): void {
|
||||
this._instanceContainer
|
||||
.getGame()
|
||||
@@ -121,8 +127,14 @@ namespace gdjs {
|
||||
callback(null);
|
||||
return;
|
||||
}
|
||||
const tiledMap = tileMapJsonData as TileMapHelper.TiledMap;
|
||||
if (tileSetJsonResourceName) {
|
||||
const tileMap = TileMapHelper.TileMapManager.identify(
|
||||
tileMapJsonData
|
||||
);
|
||||
if (!tileMap) {
|
||||
callback(null);
|
||||
return;
|
||||
}
|
||||
if (tileMap.kind === 'tiled' && tileSetJsonResourceName) {
|
||||
this._instanceContainer
|
||||
.getGame()
|
||||
.getJsonManager()
|
||||
@@ -135,13 +147,14 @@ namespace gdjs {
|
||||
callback(null);
|
||||
return;
|
||||
}
|
||||
const tiledMap = tileMap.data;
|
||||
const tileSet = tileSetJsonData as TileMapHelper.TiledTileset;
|
||||
tileSet.firstgid = tiledMap.tilesets[0].firstgid;
|
||||
tiledMap.tilesets = [tileSet];
|
||||
callback(tiledMap);
|
||||
callback(tileMap);
|
||||
});
|
||||
} else {
|
||||
callback(tiledMap);
|
||||
callback(tileMap);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@@ -580,7 +580,7 @@ namespace gdjs {
|
||||
if (!definition) {
|
||||
continue;
|
||||
}
|
||||
if (definition.hasTag(this.tag)) {
|
||||
if (definition.hasTaggedHitBox(this.tag)) {
|
||||
polygonItr = tile.getHitboxes()[Symbol.iterator]();
|
||||
listNext = polygonItr.next();
|
||||
}
|
||||
@@ -661,7 +661,7 @@ namespace gdjs {
|
||||
*/
|
||||
getDefinition(): TileMapHelper.TileDefinition {
|
||||
return this.layer.tileMap.getTileDefinition(
|
||||
this.layer._source.get(this.x, this.y)!
|
||||
this.layer._source.getTileId(this.x, this.y)!
|
||||
)!;
|
||||
}
|
||||
|
||||
|
24
Extensions/TileMap/helper/TileMapHelper.d.ts
vendored
24
Extensions/TileMap/helper/TileMapHelper.d.ts
vendored
@@ -1,23 +1,25 @@
|
||||
import {
|
||||
EditableTileMap,
|
||||
EditableTileMapLayer,
|
||||
PixiTileMapHelper,
|
||||
TileDefinition,
|
||||
TiledMap,
|
||||
TiledTileset,
|
||||
TileMap,
|
||||
TileMapManager,
|
||||
TileTextureCache,
|
||||
PixiTileMapHelper,
|
||||
TiledTileset,
|
||||
} from './dts/index';
|
||||
|
||||
declare global {
|
||||
namespace TileMapHelper {
|
||||
export { EditableTileMap };
|
||||
export { EditableTileMapLayer };
|
||||
export { TileDefinition };
|
||||
export { TiledMap };
|
||||
export { TiledTileset };
|
||||
export { TileMapManager };
|
||||
export { TileTextureCache };
|
||||
export { PixiTileMapHelper };
|
||||
export {
|
||||
EditableTileMap,
|
||||
EditableTileMapLayer,
|
||||
PixiTileMapHelper,
|
||||
TileDefinition,
|
||||
TileMap,
|
||||
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
19
Extensions/TileMap/helper/dts/index.d.ts
vendored
19
Extensions/TileMap/helper/dts/index.d.ts
vendored
@@ -2,22 +2,15 @@
|
||||
* @packageDocumentation
|
||||
* @module TileMapHelper
|
||||
*/
|
||||
import { TiledMap, TiledTileset } from './tiled/TiledFormat';
|
||||
import {
|
||||
export {
|
||||
EditableTileMap,
|
||||
EditableTileMapLayer,
|
||||
TileDefinition,
|
||||
} from './model/TileMapModel';
|
||||
import { TileMapManager } from './render/TileMapManager';
|
||||
import { TileTextureCache } from './render/TileTextureCache';
|
||||
import { PixiTileMapHelper } from './render/TileMapPixiHelper';
|
||||
export { TileMapManager } from './render/TileMapManager';
|
||||
export { TileTextureCache } from './render/TileTextureCache';
|
||||
export { PixiTileMapHelper } from './render/TileMapPixiHelper';
|
||||
export * from './types/index';
|
||||
export * from './model/CommonTypes';
|
||||
export { EditableTileMap };
|
||||
export { EditableTileMapLayer };
|
||||
export { TileDefinition };
|
||||
export { TiledMap };
|
||||
export { TiledTileset };
|
||||
export { TileMapManager };
|
||||
export { TileTextureCache };
|
||||
export { PixiTileMapHelper };
|
||||
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,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,cAAc,EACf,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,qBAAqB,CAAC;AAEpC,OAAO,EAAE,eAAe,EAAE,CAAC;AAC3B,OAAO,EAAE,oBAAoB,EAAE,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,CAAC;AAE1B,OAAO,EAAE,QAAQ,EAAE,CAAC;AACpB,OAAO,EAAE,YAAY,EAAE,CAAC;AAExB,OAAO,EAAE,cAAc,EAAE,CAAC;AAC1B,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAC5B,OAAO,EAAE,iBAAiB,EAAE,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,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC"}
|
18
Extensions/TileMap/helper/dts/load/TileMapLoader.d.ts
vendored
Normal file
18
Extensions/TileMap/helper/dts/load/TileMapLoader.d.ts
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
import type { EditableTileMap } from '../model/TileMapModel';
|
||||
import { TileMap } from '../types';
|
||||
export declare namespace TileMapLoader {
|
||||
/**
|
||||
* Create a {@link EditableTileMap} from the raw data.
|
||||
*
|
||||
* @param tiledMap 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,
|
||||
levelIndex: number,
|
||||
pako: any
|
||||
): EditableTileMap | null;
|
||||
}
|
||||
//# sourceMappingURL=TileMapLoader.d.ts.map
|
@@ -0,0 +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"}
|
589
Extensions/TileMap/helper/dts/load/ldtk/LDtkFormat.d.ts
vendored
Normal file
589
Extensions/TileMap/helper/dts/load/ldtk/LDtkFormat.d.ts
vendored
Normal file
@@ -0,0 +1,589 @@
|
||||
import { integer } from '../../model/CommonTypes';
|
||||
/**
|
||||
* version 1.1.3 - https://github.com/deepnight/ldtk/blob/66fff7199932357f3ab9b044c2fc2a856f527831/docs/JSON_SCHEMA.json
|
||||
*/
|
||||
export 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 */
|
||||
backupLimit: integer;
|
||||
/** If TRUE, an extra copy of the project will be created in a sub folder, when saving. */
|
||||
backupOnSave: boolean;
|
||||
/** Project background color */
|
||||
bgColor: string;
|
||||
/** Default grid size for new layers */
|
||||
defaultGridSize: integer;
|
||||
/** Default background color of levels */
|
||||
defaultLevelBgColor: string;
|
||||
/** **WARNING**: this field will move to the `worlds` array after the \"multi-worlds\" update. It will then be `null`. You can enable the Multi-worlds advanced project option to enable the change immediately.<br/><br/> Default new level height */
|
||||
defaultLevelHeight: integer | null;
|
||||
/** **WARNING**: this field will move to the `worlds` array after the \"multi-worlds\" update. It will then be `null`. You can enable the Multi-worlds advanced project option to enable the change immediately.<br/><br/> Default new level width */
|
||||
defaultLevelWidth: integer | null;
|
||||
/** Default X pivot (0 to 1) for new entities */
|
||||
defaultPivotX: number;
|
||||
/** Default Y pivot (0 to 1) for new entities */
|
||||
defaultPivotY: number;
|
||||
/** A structure containing all the definitions of this project */
|
||||
defs: LDtkDefinition;
|
||||
/** **WARNING**: this deprecated value is no longer exported since version 0.9.3 Replaced by: `imageExportMode` */
|
||||
exportPng: boolean | null;
|
||||
/** If TRUE, a Tiled compatible file will also be generated along with the LDtk JSON file (default is FALSE) */
|
||||
exportTiled: boolean;
|
||||
/** If TRUE, one file will be saved for the project (incl. all its definitions) and one file in a sub-folder for each level. */
|
||||
externalLevels: boolean;
|
||||
/** An array containing various advanced flags (ie. options or other states). Possible values: `DiscardPreCsvIntGrid`, `ExportPreCsvIntGridFormat`, `IgnoreBackupSuggest`, `PrependIndexToLevelFileNames`, `MultiWorlds`, `UseMultilinesType` */
|
||||
flags: LDtkFlag[];
|
||||
/** Naming convention for Identifiers (first-letter uppercase, full uppercase etc.) Possible values: `Capitalize`, `Uppercase`, `Lowercase`, `Free` */
|
||||
identifierStyle: 'Capitalize' | 'Uppercase' | 'Lowercase' | 'Free';
|
||||
/** \"Image export\" option when saving project. Possible values: `None`, `OneImagePerLayer`, `OneImagePerLevel`, `LayersAndLevels` */
|
||||
imageExportMode:
|
||||
| 'None'
|
||||
| 'OneImagePerLayer'
|
||||
| 'OneImagePerLevel'
|
||||
| 'LayersAndLevels';
|
||||
/** File format version */
|
||||
jsonVersion: string;
|
||||
/** The default naming convention for level identifiers. */
|
||||
levelNamePattern: string;
|
||||
/** All levels. The order of this array is only relevant in `LinearHorizontal` and `linearVertical` world layouts (see `worldLayout` value).<br/> Otherwise, you should refer to the `worldX`,`worldY` coordinates of each Level. */
|
||||
levels: LDtkLevel[];
|
||||
/** If TRUE, the Json is partially minified (no indentation, nor line breaks, default is FALSE) */
|
||||
minifyJson: boolean;
|
||||
/** Next Unique integer ID available */
|
||||
nextUid: integer;
|
||||
/** File naming pattern for exported PNGs */
|
||||
pngFilePattern: string | null;
|
||||
/** If TRUE, a very simplified will be generated on saving, for quicker & easier engine integration. */
|
||||
simplifiedExport: boolean;
|
||||
/** This optional description is used by LDtk Samples to show up some informations and instructions. */
|
||||
tutorialDesc: string | null;
|
||||
/** This array is not used yet in current LDtk version (so, for now, it's always empty).<br/><br/>In a later update, it will be possible to have multiple Worlds in a single project, each containing multiple Levels.<br/><br/>What will change when \"Multiple worlds\" support will be added to LDtk:<br/><br/> - in current version, a LDtk project file can only contain a single world with multiple levels in it. In this case, levels and world layout related settings are stored in the root of the JSON.<br/> - after the \"Multiple worlds\" update, there will be a `worlds` array in root, each world containing levels and layout settings. Basically, it's pretty much only about moving the `levels` array to the `worlds` array, along with world layout related values (eg. `worldGridWidth` etc).<br/><br/>If you want to start supporting this future update easily, please refer to this documentation: https://github.com/deepnight/ldtk/issues/231 */
|
||||
worlds: LDtkWorld[];
|
||||
/** **WARNING**: this field will move to the `worlds` array after the \"multi-worlds\" update. It will then be `null`. You can enable the Multi-worlds advanced project option to enable the change immediately.<br/><br/> Height of the world grid in pixels. */
|
||||
worldGridHeight: integer | null;
|
||||
/** **WARNING**: this field will move to the `worlds` array after the \"multi-worlds\" update. It will then be `null`. You can enable the Multi-worlds advanced project option to enable the change immediately.<br/><br/> Width of the world grid in pixels. */
|
||||
worldGridWidth: integer | null;
|
||||
/** **WARNING**: this field will move to the `worlds` array after the \"multi-worlds\" update. It will then be `null`. You can enable the Multi-worlds advanced project option to enable the change immediately.<br/><br/> An enum that describes how levels are organized in this project (ie. linearly or in a 2D space). Possible values: <`null`>, `Free`, `GridVania`, `LinearHorizontal`, `LinearVertical` */
|
||||
worldLayout:
|
||||
| 'Free'
|
||||
| 'GridVania'
|
||||
| 'LinearHorizontal'
|
||||
| 'LinearVertical'
|
||||
| null;
|
||||
};
|
||||
/** Auto-layer rule group */
|
||||
type LDtkAutoLayerRuleGroup = {
|
||||
/** */
|
||||
active: boolean;
|
||||
/** *This field was removed in 1.0.0 and should no longer be used.* */
|
||||
collapsed: boolean | null;
|
||||
/** */
|
||||
isOptional: boolean;
|
||||
/** */
|
||||
name: string;
|
||||
/** */
|
||||
rules: LDtkAutoRuleDef[];
|
||||
/** */
|
||||
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 = {};
|
||||
/** 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 = {
|
||||
/** All entities definitions, including their custom fields */
|
||||
entities: LDtkEntityDef[];
|
||||
/** All internal enums */
|
||||
enums: LDtkEnumDef[];
|
||||
/** Note: external enums are exactly the same as `enums`, except they have a `relPath` to point to an external source file. */
|
||||
externalEnums: LDtkEnumDef[];
|
||||
/** All layer definitions */
|
||||
layers: LDtkLayerDef[];
|
||||
/** All custom fields available to all levels. */
|
||||
levelFields: LDtkFieldDef[];
|
||||
/** All tilesets */
|
||||
tilesets: LDtkTilesetDef[];
|
||||
};
|
||||
/** Entity definition */
|
||||
type LDtkEntityDef = {
|
||||
/** Base entity color */
|
||||
color: string;
|
||||
/** Array of field definitions */
|
||||
fieldDefs: LDtkFieldDef[];
|
||||
/** */
|
||||
fillOpacity: number;
|
||||
/** Pixel height */
|
||||
height: integer;
|
||||
/** */
|
||||
hollow: boolean;
|
||||
/** User defined unique identifier */
|
||||
identifier: string;
|
||||
/** Only applies to entities resizable on both X/Y. If TRUE, the entity instance width/height will keep the same aspect ratio as the definition. */
|
||||
keepAspectRatio: boolean;
|
||||
/** Possible values: `DiscardOldOnes`, `PreventAdding`, `MoveLastOne` */
|
||||
limitBehavior: 'DiscardOldOnes' | 'MoveLastOne' | 'PreventAdding';
|
||||
/** If TRUE, the maxCount is a \"per world\" limit, if FALSE, it's a \"per level\". Possible values: `PerLayer`, `PerLevel`, `PerWorld` */
|
||||
limitScope: 'PerLayer' | 'PerLevel' | 'PerWorld';
|
||||
/** */
|
||||
lineOpacity: number;
|
||||
/** Max instances count */
|
||||
maxCount: integer;
|
||||
/** An array of 4 dimensions for the up/right/down/left borders (in this order) when using 9-slice mode for `tileRenderMode`.<br/> If the tileRenderMode is not NineSlice, then this array is empty.<br/> See: https://en.wikipedia.org/wiki/9-slice_scaling */
|
||||
nineSliceBorders: integer[];
|
||||
/** Pivot X coordinate (from 0 to 1.0) */
|
||||
pivotX: number;
|
||||
/** Pivot Y coordinate (from 0 to 1.0) */
|
||||
pivotY: number;
|
||||
/** Possible values: `Rectangle`, `Ellipse`, `Tile`, `Cross` */
|
||||
renderMode: 'Cross' | 'Ellipse' | 'Rectangle' | 'Ellipse';
|
||||
/** If TRUE, the entity instances will be resizable horizontally */
|
||||
resizableX: boolean;
|
||||
/** If TRUE, the entity instances will be resizable vertically */
|
||||
resizableY: boolean;
|
||||
/** Display entity name in editor */
|
||||
showName: boolean;
|
||||
/** An array of strings that classifies this entity */
|
||||
tags: string[];
|
||||
/** **WARNING**: this deprecated value will be *removed* completely on version 1.2.0+ Replaced by: `tileRect` */
|
||||
tileId: integer | null;
|
||||
/** */
|
||||
tileOpacity: number;
|
||||
/** An object representing a rectangle from an existing Tileset */
|
||||
tileRect: LDtkTilesetRect | null;
|
||||
/** An enum describing how the the Entity tile is rendered inside the Entity bounds. Possible values: `Cover`, `FitInside`, `Repeat`, `Stretch`, `FullSizeCropped`, `FullSizeUncropped`, `NineSlice` */
|
||||
tileRenderMode:
|
||||
| 'Cover'
|
||||
| 'FitInside'
|
||||
| 'FullSizeCropped'
|
||||
| 'FullSizeUncropped'
|
||||
| 'NineSlice'
|
||||
| 'Repeat'
|
||||
| 'Stretch';
|
||||
/** Tileset ID used for optional tile display */
|
||||
tilesetId: integer | null;
|
||||
/** Unique Int identifier */
|
||||
uid: integer;
|
||||
/** Pixel width */
|
||||
width: integer;
|
||||
};
|
||||
/** Entity instance */
|
||||
type LDtkEntityInstance = {
|
||||
/** Grid-based coordinates (`[x,y]` format) */
|
||||
__grid: integer[];
|
||||
/** Entity definition identifier */
|
||||
__identifier: string;
|
||||
/** Pivot coordinates (`[x,y]` format, values are from 0 to 1) of the Entity */
|
||||
__pivot: number[];
|
||||
/** The entity \"smart\" color, guessed from either Entity definition, or one its field instances. */
|
||||
__smartColor: string;
|
||||
/** Array of tags defined in this Entity definition */
|
||||
__tags: string[];
|
||||
/** Optional TilesetRect used to display this entity (it could either be the default Entity tile, or some tile provided by a field value, like an Enum). */
|
||||
__tile: LDtkTilesetRect | null;
|
||||
/** Reference of the **Entity definition** UID */
|
||||
defUid: integer;
|
||||
/** An array of all custom fields and their values. */
|
||||
fieldInstances: LDtkFieldInstance[];
|
||||
/** Entity height in pixels. For non-resizable entities, it will be the same as Entity definition. */
|
||||
height: integer;
|
||||
/** Unique instance identifier */
|
||||
iid: string;
|
||||
/** Pixel coordinates (`[x,y]` format) in current level coordinate space. Don't forget optional layer offsets, if they exist! */
|
||||
px: integer[];
|
||||
/** Entity width in pixels. For non-resizable entities, it will be the same as Entity definition. */
|
||||
width: integer;
|
||||
};
|
||||
/** Enum definition */
|
||||
type LDtkEnumDef = {
|
||||
/** */
|
||||
externalFileChecksum: string | null;
|
||||
/** Relative path to the external file providing this Enum */
|
||||
externalRelPath: string | null;
|
||||
/** Tileset UID if provided */
|
||||
iconTilesetUid: integer | null;
|
||||
/** User defined unique identifier */
|
||||
identifier: string;
|
||||
/** An array of user-defined tags to organize the Enums */
|
||||
tags: string[];
|
||||
/** Unique Int identifier */
|
||||
uid: integer;
|
||||
/** All possible enum values, with their optional Tile infos. */
|
||||
values: LDtkEnumDefValues[];
|
||||
};
|
||||
/** Enum value definition */
|
||||
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 */
|
||||
color: integer;
|
||||
/** Enum value */
|
||||
id: string;
|
||||
/** The optional ID of the tile */
|
||||
tileId: integer | null;
|
||||
};
|
||||
/** In a tileset definition, enum based tag infos */
|
||||
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 = {
|
||||
/** 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` */
|
||||
acceptFileTypes: string[] | null;
|
||||
/** Possible values: `Any`, `OnlySame`, `OnlyTags` */
|
||||
allowedRefs: 'Any' | 'OnlySame' | 'OnlyTags';
|
||||
/** */
|
||||
allowedRefTags: string[];
|
||||
/** */
|
||||
allowOutOfLevelRef: boolean;
|
||||
/** Array max length */
|
||||
arrayMaxLength: integer | null;
|
||||
/** Array min length */
|
||||
arrayMinLength: integer | null;
|
||||
/** */
|
||||
autoChainRef: boolean;
|
||||
/** TRUE if the value can be null. For arrays, TRUE means it can contain null values (exception: array of Points can't have null values). */
|
||||
canBeNull: boolean;
|
||||
/** Default value if selected value is null or invalid. */
|
||||
defaultOverride: any | null;
|
||||
/** */
|
||||
editorAlwaysShow: boolean;
|
||||
/** */
|
||||
editorCutLongValues: boolean;
|
||||
/** Possible values: `Hidden`, `ValueOnly`, `NameAndValue`, `EntityTile`, `Points`, `PointStar`, `PointPath`, `PointPathLoop`, `RadiusPx`, `RadiusGrid`, `ArrayCountWithLabel`, `ArrayCountNoLabel`, `RefLinkBetweenPivots`, `RefLinkBetweenCenters` */
|
||||
editorDisplayMode:
|
||||
| 'ArrayCountNoLabel'
|
||||
| 'ArrayCountWithLabel'
|
||||
| 'EntityTile'
|
||||
| 'Hidden'
|
||||
| 'NameAndValue'
|
||||
| 'PointPath'
|
||||
| 'PointPathLoop'
|
||||
| 'PointStar'
|
||||
| 'Points'
|
||||
| 'RadiusGrid'
|
||||
| 'RadiusPx'
|
||||
| 'RefLinkBetweenCenters'
|
||||
| 'RefLinkBetweenPivots'
|
||||
| 'ValueOnly';
|
||||
/** Possible values: `Above`, `Center`, `Beneath` */
|
||||
editorDisplayPos: 'Above' | 'Beneath' | 'Center';
|
||||
/** */
|
||||
editorTextPrefix: string | null;
|
||||
/** */
|
||||
editorTextSuffix: string | null;
|
||||
/** User defined unique identifier */
|
||||
identifier: string;
|
||||
/** TRUE if the value is an array of multiple values */
|
||||
isArray: boolean;
|
||||
/** Max limit for value, if applicable */
|
||||
max: number | null;
|
||||
/** Min limit for value, if applicable */
|
||||
min: number | null;
|
||||
/** Optional regular expression that needs to be matched to accept values. Expected format: `/some_reg_ex/g`, with optional \"i\" flag. */
|
||||
regex: string | null;
|
||||
/** */
|
||||
symmetricalRef: boolean;
|
||||
/** Possible values: <`null`>, `LangPython`, `LangRuby`, `LangJS`, `LangLua`, `LangC`, `LangHaxe`, `LangMarkdown`, `LangJson`, `LangXml`, `LangLog` */
|
||||
textLanguageMode:
|
||||
| 'LangC'
|
||||
| 'LangHaxe'
|
||||
| 'LangJS'
|
||||
| 'LangJson'
|
||||
| 'LangLog'
|
||||
| 'LangLua'
|
||||
| 'LangMarkdown'
|
||||
| 'LangPython'
|
||||
| 'LangRuby'
|
||||
| 'LangXml'
|
||||
| null;
|
||||
/** UID of the tileset used for a Tile */
|
||||
tilesetUid: integer | null;
|
||||
/** Internal enum representing the possible field types. Possible values: F_Int, F_Float, F_String, F_Text, F_Bool, F_Color, F_Enum(...), F_Point, F_Path, F_EntityRef, F_Tile */
|
||||
type: string;
|
||||
/** Unique Int identifier */
|
||||
uid: integer;
|
||||
/** If TRUE, the color associated with this field will override the Entity or Level default color in the editor UI. For Enum fields, this would be the color associated to their values. */
|
||||
useForSmartColor: boolean;
|
||||
};
|
||||
/** Field instance */
|
||||
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). */
|
||||
__tile: LDtkTilesetRect | null;
|
||||
/** Type of the field, such as `Int`, `Float`, `String`, `Enum(my_enum_name)`, `Bool`, etc.<br/> NOTE: if you enable the advanced option **Use Multilines type**, you will have \"*Multilines*\" instead of \"*String*\" when relevant. */
|
||||
__type: string;
|
||||
/** Actual value of the field instance. The value type varies, depending on `__type`:<br/> - For **classic types** (ie. Integer, Float, Boolean, String, Text and FilePath), you just get the actual value with the expected type.<br/> - For **Color**, the value is an hexadecimal string using \"#rrggbb\" format.<br/> - For **Enum**, the value is a String representing the selected enum value.<br/> - For **Point**, the value is a [GridPoint](#ldtk-GridPoint) object.<br/> - For **Tile**, the value is a [TilesetRect](#ldtk-TilesetRect) object.<br/> - For **EntityRef**, the value is an [EntityReferenceInfos](#ldtk-EntityReferenceInfos) object.<br/><br/> If the field is an array, then this `__value` will also be a JSON array. */
|
||||
__value: any;
|
||||
/** Reference of the **Field definition** UID */
|
||||
defUid: integer;
|
||||
/** Editor internal raw values */
|
||||
realEditorValues: any[];
|
||||
};
|
||||
type LDtkFlag =
|
||||
| 'DiscardPreCsvIntGrid'
|
||||
| 'ExportPreCsvIntGridFormat'
|
||||
| 'IgnoreBackupSuggest'
|
||||
| 'PrependIndexToLevelFileNames'
|
||||
| 'MultiWorlds'
|
||||
| 'UseMultilinesType';
|
||||
/** IntGrid value definition */
|
||||
type LDtkIntGridValueDef = {
|
||||
/** */
|
||||
color: string;
|
||||
/** User defined unique identifier */
|
||||
identifier: string | null;
|
||||
/** The IntGrid value itself */
|
||||
value: integer;
|
||||
};
|
||||
/** IntGrid value instance */
|
||||
type LDtkIntGridValueInstance = {
|
||||
/** Coordinate ID in the layer grid */
|
||||
coordId: integer;
|
||||
/** IntGrid value */
|
||||
v: integer;
|
||||
};
|
||||
/** Layer definition */
|
||||
type LDtkLayerDef = {
|
||||
/** Type of the layer (*IntGrid, Entities, Tiles or AutoLayer*) */
|
||||
__type: string;
|
||||
/** Contains all the auto-layer rule definitions. */
|
||||
autoRuleGroups: LDtkAutoLayerRuleGroup[];
|
||||
/** */
|
||||
autoSourceLayerDefUid: integer | null;
|
||||
/** **WARNING**: this deprecated value will be *removed* completely on version 1.2.0+ Replaced by: `tilesetDefUid` */
|
||||
autoTilesetDefUid: integer | null;
|
||||
/** Opacity of the layer (0 to 1.0) */
|
||||
displayOpacity: number;
|
||||
/** An array of tags to forbid some Entities in this layer */
|
||||
excludedTags: string[];
|
||||
/** Width and height of the grid in pixels*/
|
||||
gridSize: integer;
|
||||
/** Height of the optional \"guide\" grid in pixels */
|
||||
guideGridHei: integer;
|
||||
/** Width of the optional \"guide\" grid in pixels */
|
||||
guideGridWid: integer;
|
||||
/** */
|
||||
hideFieldsWhenInactive: boolean;
|
||||
/** Hide the layer from the list on the side of the editor view. */
|
||||
hideInList: boolean;
|
||||
/** User defined unique identifier */
|
||||
identifier: string;
|
||||
/** Alpha of this layer when it is not the active one. */
|
||||
inactiveOpacity: number;
|
||||
/** An array that defines extra optional info for each IntGrid value.<br/> WARNING: the array order is not related to actual IntGrid values! As user can re-order IntGrid values freely, you may value \"2\" before value \"1\" in this array. */
|
||||
intGridValues: LDtkIntGridValueDef[];
|
||||
/** Parallax horizontal factor (from -1 to 1, defaults to 0) which affects the scrolling speed of this layer, creating a fake 3D (parallax) effect. */
|
||||
parallaxFactorX: number;
|
||||
/** Parallax vertical factor (from -1 to 1, defaults to 0) which affects the scrolling speed of this layer, creating a fake 3D (parallax) effect. */
|
||||
parallaxFactorY: number;
|
||||
/** If true (default), a layer with a parallax factor will also be scaled up/down accordingly. */
|
||||
parallaxScaling: boolean;
|
||||
/** X offset of the layer, in pixels (IMPORTANT: this should be added to the `LayerInstance` optional offset) */
|
||||
pxOffsetX: integer;
|
||||
/** Y offset of the layer, in pixels (IMPORTANT: this should be added to the `LayerInstance` optional offset) */
|
||||
pxOffsetY: integer;
|
||||
/** An array of tags to filter Entities that can be added to this layer */
|
||||
requiredTags: string[];
|
||||
/** If the tiles are smaller or larger than the layer grid, the pivot value will be used to position the tile relatively its grid cell. */
|
||||
tilePivotX: number;
|
||||
/** If the tiles are smaller or larger than the layer grid, the pivot value will be used to position the tile relatively its grid cell.*/
|
||||
tilePivotY: number;
|
||||
/** Reference to the default Tileset UID being used by this layer definition.<br/> **WARNING**: some layer *instances* might use a different tileset. So most of the time, you should probably use the `__tilesetDefUid` value found in layer instances.<br/> Note: since version 1.0.0, the old `autoTilesetDefUid` was removed and merged into this value. */
|
||||
tilesetDefUid: integer | null;
|
||||
/** Type of the layer as Haxe Enum Possible values: `IntGrid`, `Entities`, `Tiles`, `AutoLayer` */
|
||||
type: 'AutoLayer' | 'Entities' | 'IntGrid' | 'Tiles';
|
||||
/** Unique Int identifier */
|
||||
uid: integer;
|
||||
};
|
||||
/** Layer instance */
|
||||
type LDtkLayerInstance = {
|
||||
/** Grid-based height */
|
||||
__cHei: integer;
|
||||
/** Grid-based width */
|
||||
__cWid: integer;
|
||||
/** Grid size */
|
||||
__gridSize: integer;
|
||||
/** Layer definition identifier */
|
||||
__identifier: string;
|
||||
/** Layer opacity as Float [0-1] */
|
||||
__opacity: number;
|
||||
/** Total layer X pixel offset, including both instance and definition offsets. */
|
||||
__pxTotalOffsetX: integer;
|
||||
/** Total layer Y pixel offset, including both instance and definition offsets. */
|
||||
__pxTotalOffsetY: integer;
|
||||
/** The definition UID of corresponding Tileset, if any. */
|
||||
__tilesetDefUid: integer | null;
|
||||
/** The relative path to corresponding Tileset, if any. */
|
||||
__tilesetRelPath: string | null;
|
||||
/** Layer type (possible values: IntGrid, Entities, Tiles or AutoLayer) */
|
||||
__type: string;
|
||||
/** An array containing all tiles generated by Auto-layer rules. The array is already sorted in display order (ie. 1st tile is beneath 2nd, which is beneath 3rd etc.).<br/><br/> Note: if multiple tiles are stacked in the same cell as the result of different rules, all tiles behind opaque ones will be discarded. */
|
||||
autoLayerTiles: LDtkTile[];
|
||||
/** */
|
||||
entityInstances: LDtkEntityInstance[];
|
||||
/** */
|
||||
gridTiles: LDtkTile[];
|
||||
/** Unique layer instance identifier */
|
||||
iid: string;
|
||||
/** **WARNING**: this deprecated value is no longer exported since version 1.0.0 Replaced by: `intGridCsv` */
|
||||
intGrid: LDtkIntGridValueInstance[] | null;
|
||||
/** A list of all values in the IntGrid layer, stored in CSV format (Comma Separated Values).<br/> Order is from left to right, and top to bottom (ie. first row from left to right, followed by second row, etc).<br/> `0` means \"empty cell\" and IntGrid values start at 1.<br/> The array size is `__cWid` x `__cHei` cells. */
|
||||
intGridCsv: integer[];
|
||||
/** Reference the Layer definition UID */
|
||||
layerDefUid: integer;
|
||||
/** Reference to the UID of the level containing this layer instance */
|
||||
levelId: integer;
|
||||
/** An Array containing the UIDs of optional rules that were enabled in this specific layer instance. */
|
||||
optionalRules: integer[];
|
||||
/** This layer can use another tileset by overriding the tileset UID here. */
|
||||
overrideTilesetUid: integer | null;
|
||||
/** X offset in pixels to render this layer, usually 0 (IMPORTANT: this should be added to the `LayerDef` optional offset, see `__pxTotalOffsetX`) */
|
||||
pxOffsetX: integer;
|
||||
/** Y offset in pixels to render this layer, usually 0 (IMPORTANT: this should be added to the `LayerDef` optional offset, see `__pxTotalOffsetY`) */
|
||||
pxOffsetY: integer;
|
||||
/** Random seed used for Auto-Layers rendering */
|
||||
seed: integer;
|
||||
/** Layer instance visibility */
|
||||
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 = {
|
||||
/** 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. */
|
||||
__bgPos: LDtkLevelBgPosInfos | null;
|
||||
/** An array listing all other levels touching this one on the world map.<br/> Only relevant for world layouts where level spatial positioning is manual (ie. GridVania, Free). For Horizontal and Vertical layouts, this array is always empty. */
|
||||
__neighbours: LDtkNeighbourLevel[];
|
||||
/** The \"guessed\" color for this level in the editor, decided using either the background color or an existing custom field. */
|
||||
__smartColor: string;
|
||||
/** Background color of the level. If `null`, the project `defaultLevelBgColor` should be used. */
|
||||
bgColor: string | null;
|
||||
/** Background image Y pivot (0-1) */
|
||||
bgPivotY: number;
|
||||
/** Background image X pivot (0-1) */
|
||||
bgPivotX: number;
|
||||
/** An enum defining the way the background image (if any) is positioned on the level. See `__bgPos` for resulting position info. Possible values: <`null`>, `Unscaled`, `Contain`, `Cover`, `CoverDirty` */
|
||||
bgPos: 'Unscaled' | 'Contain' | 'Cover' | 'CoverDirty' | null;
|
||||
/** The *optional* relative path to the level background image. */
|
||||
bgRelPath: string | null;
|
||||
/** This value is not null if the project option \"*Save levels separately*\" is enabled. In this case, this **relative** path points to the level Json file. */
|
||||
externalRelPath: string | null;
|
||||
/** An array containing this level custom field values. */
|
||||
fieldInstances: LDtkFieldInstance[];
|
||||
/** User defined unique identifier */
|
||||
identifier: string;
|
||||
/** Unique instance identifier */
|
||||
iid: string;
|
||||
/** An array containing all Layer instances. **IMPORTANT**: if the project option \"*Save levels separately*\" is enabled, this field will be `null`.<br/> This array is **sorted in display order**: the 1st layer is the top-most and the last is behind. */
|
||||
layerInstances: LDtkLayerInstance[] | null;
|
||||
/** Height of the level in pixels */
|
||||
pxHei: integer;
|
||||
/** Width of the level in pixels */
|
||||
pxWid: integer;
|
||||
/** Unique Int identifier */
|
||||
uid: integer;
|
||||
/** If TRUE, the level identifier will always automatically use the naming pattern as defined in `Project.levelNamePattern`. Becomes FALSE if the identifier is manually modified by user. */
|
||||
useAutoIdentifier: boolean;
|
||||
/** Index that represents the \"depth\" of the level in the world. Default is 0, greater means \"above\", lower means \"below\".<br/> This value is mostly used for display only and is intended to make stacking of levels easier to manage. */
|
||||
worldDepth: integer;
|
||||
/** World X coordinate in pixels.<br/> Only relevant for world layouts where level spatial positioning is manual (ie. GridVania, Free). For Horizontal and Vertical layouts, the value is always -1 here. */
|
||||
worldX: integer;
|
||||
/** World Y coordinate in pixels.<br/> Only relevant for world layouts where level spatial positioning is manual (ie. GridVania, Free). For Horizontal and Vertical layouts, the value is always -1 here. */
|
||||
worldY: integer;
|
||||
};
|
||||
/** Level background image position info */
|
||||
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. */
|
||||
scale: number[];
|
||||
/** An array containing the `[x,y]` pixel coordinates of the top-left corner of the **cropped** background image, depending on `bgPos` option. */
|
||||
topLeftPx: integer[];
|
||||
};
|
||||
/** Nearby level info */
|
||||
type LDtkNeighbourLevel = {
|
||||
/** A single lowercase character tipping on the level location (`n`orth, `s`outh, `w`est, `e`ast). */
|
||||
dir: string;
|
||||
/** Neighbour Instance Identifier */
|
||||
levelIid: string;
|
||||
/** **WARNING**: this deprecated value will be *removed* completely on version 1.2.0+ Replaced by: `levelIid` */
|
||||
levelUid: integer;
|
||||
};
|
||||
/** This structure represents a single tile from a given Tileset. */
|
||||
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) */
|
||||
f: integer;
|
||||
/** Pixel coordinates of the tile in the **layer** (`[x,y]` format). Don't forget optional layer offsets, if they exist! */
|
||||
px: integer[];
|
||||
/** Pixel coordinates of the tile in the **tileset** (`[x,y]` format) */
|
||||
src: integer[];
|
||||
/** The *Tile ID* in the corresponding tileset. */
|
||||
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 = {
|
||||
/** Grid-based height */
|
||||
__cHei: integer;
|
||||
/** Grid-based width */
|
||||
__cWid: integer;
|
||||
/** The following data is used internally for various optimizations. It's always synced with source image changes. */
|
||||
cachedPixelData: object | null;
|
||||
/** An array of custom tile metadata */
|
||||
customData: LDtkTileCustomMetadata[];
|
||||
/** If this value is set, then it means that this atlas uses an internal LDtk atlas image instead of a loaded one. Possible values: <`null`>, `LdtkIcons` */
|
||||
embedAtlas: 'LdtkIcons' | null;
|
||||
/** Tileset tags using Enum values specified by `tagsSourceEnumId`. This array contains 1 element per Enum value, which contains an array of all Tile IDs that are tagged with it. */
|
||||
enumTags: LDtkEnumTagValue[];
|
||||
/** User defined unique identifier */
|
||||
identifier: string;
|
||||
/** Distance in pixels from image borders */
|
||||
padding: integer;
|
||||
/** Image height in pixels */
|
||||
pxHei: integer;
|
||||
/** Image width in pixels */
|
||||
pxWid: integer;
|
||||
/** Path to the source file, relative to the current project JSON file<br/> It can be null if no image was provided, or when using an embed atlas. */
|
||||
relPath: string | null;
|
||||
/** Array of group of tiles selections, only meant to be used in the editor */
|
||||
savedSelections: object[];
|
||||
/** Space in pixels between all tiles */
|
||||
spacing: integer;
|
||||
/** An array of user-defined tags to organize the Tilesets */
|
||||
tags: string[];
|
||||
/** Optional Enum definition UID used for this tileset meta-data */
|
||||
tagsSourceEnumUid: integer | null;
|
||||
/** */
|
||||
tileGridSize: integer;
|
||||
/** Unique Intidentifier */
|
||||
uid: integer;
|
||||
};
|
||||
/** In a tileset definition, user defined meta-data of a tile. */
|
||||
type LDtkTileCustomMetadata = {
|
||||
/** */
|
||||
data: string;
|
||||
/** */
|
||||
tileId: integer;
|
||||
};
|
||||
/** This object represents a custom sub rectangle in a Tileset image. */
|
||||
type LDtkTilesetRect = {
|
||||
/** Height in pixels */
|
||||
h: integer;
|
||||
/** UID of the tileset */
|
||||
tilesetUid: integer;
|
||||
/** Width in pixels */
|
||||
w: integer;
|
||||
/** X pixels coordinate of the top-left corner in the Tileset image */
|
||||
x: integer;
|
||||
/** Y pixels coordinate of the top-left corner in the Tileset image */
|
||||
y: integer;
|
||||
};
|
||||
type LDtkWorld = {};
|
||||
export {};
|
||||
//# sourceMappingURL=LDtkFormat.d.ts.map
|
File diff suppressed because one or more lines are too long
16
Extensions/TileMap/helper/dts/load/ldtk/LDtkTileMapLoader.d.ts
vendored
Normal file
16
Extensions/TileMap/helper/dts/load/ldtk/LDtkTileMapLoader.d.ts
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
import { EditableTileMap } from '../../model/TileMapModel';
|
||||
import { LDtkTileMap } from './LDtkFormat';
|
||||
export declare namespace LDtkTileMapLoader {
|
||||
/**
|
||||
* Create a {@link EditableTileMap} from the LDtk JSON.
|
||||
*
|
||||
* @param ldtkTileMap A tile map exported from LDtk.
|
||||
* @param levelIndex The level of the tile map to load from.
|
||||
* @returns A {@link EditableTileMap}
|
||||
*/
|
||||
function load(
|
||||
ldtkTileMap: LDtkTileMap,
|
||||
levelIndex: number
|
||||
): EditableTileMap | null;
|
||||
}
|
||||
//# sourceMappingURL=LDtkTileMapLoader.d.ts.map
|
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"LDtkTileMapLoader.d.ts","sourceRoot":"","sources":["../../../src/load/ldtk/LDtkTileMapLoader.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAkB,MAAM,0BAA0B,CAAC;AAE3E,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAG3C,yBAAiB,iBAAiB,CAAC;IACjC;;;;;;OAMG;IACH,SAAgB,IAAI,CAClB,WAAW,EAAE,WAAW,EACxB,UAAU,EAAE,MAAM,GACjB,eAAe,GAAG,IAAI,CAwJxB;CACF"}
|
5
Extensions/TileMap/helper/dts/load/ldtk/LDtkTileMapLoaderHelper.d.ts
vendored
Normal file
5
Extensions/TileMap/helper/dts/load/ldtk/LDtkTileMapLoaderHelper.d.ts
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
export declare function getLDtkTileId(
|
||||
tileSetId: number,
|
||||
tileId: number
|
||||
): number;
|
||||
//# sourceMappingURL=LDtkTileMapLoaderHelper.d.ts.map
|
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"LDtkTileMapLoaderHelper.d.ts","sourceRoot":"","sources":["../../../src/load/ldtk/LDtkTileMapLoaderHelper.ts"],"names":[],"mappings":"AAAA,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAQvE"}
|
@@ -1,8 +1,8 @@
|
||||
import { float, integer } from '../model/CommonTypes';
|
||||
import { float, integer } from '../../model/CommonTypes';
|
||||
/**
|
||||
* Tiled JSON format (https://www.mapeditor.org/).
|
||||
* Tiled JSON format (https://github.com/mapeditor/tiled/blob/master/docs/reference/json-map-format.rst).
|
||||
*/
|
||||
export declare type TiledMap = {
|
||||
export 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 declare type TiledMap = {
|
||||
/** Number of tile columns */
|
||||
width: integer;
|
||||
};
|
||||
export declare type TiledLayer = {
|
||||
export 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 declare type TiledLayer = {
|
||||
/** Vertical layer offset in tiles. Always 0. */
|
||||
y: integer;
|
||||
};
|
||||
export declare type TiledChunk = {
|
||||
export type TiledChunk = {
|
||||
/** Array of `unsigned` `integer` (GIDs) or base64-encoded data */
|
||||
data: Array<integer> | string;
|
||||
/** Height in tiles */
|
||||
@@ -110,7 +110,7 @@ export declare type TiledChunk = {
|
||||
/** Y coordinate in tiles */
|
||||
y: integer;
|
||||
};
|
||||
export declare type TiledObject = {
|
||||
export 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 declare type TiledObject = {
|
||||
/** Y coordinate in pixels */
|
||||
y: float;
|
||||
};
|
||||
export declare type TiledText = {
|
||||
export 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 declare type TiledText = {
|
||||
/** Whether the text is wrapped within the object bounds (default: `false`) */
|
||||
wrap: boolean;
|
||||
};
|
||||
export declare type TiledTileset = {
|
||||
export type TiledTileset = {
|
||||
/** Hex-formatted color (#RRGGBB or #AARRGGBB) (optional) */
|
||||
backgroundcolor?: string;
|
||||
/** The number of tile columns in the tileset */
|
||||
@@ -224,7 +224,7 @@ export declare type TiledTileset = {
|
||||
/** Array of {@link TiledWangSet} (since 1.1.5) */
|
||||
wangsets?: Array<TiledWangSet>;
|
||||
};
|
||||
export declare type TiledGrid = {
|
||||
export type TiledGrid = {
|
||||
/** Cell height of tile grid */
|
||||
height: integer;
|
||||
/** `orthogonal` (default) or `isometric` */
|
||||
@@ -232,13 +232,13 @@ export declare type TiledGrid = {
|
||||
/** Cell width of tile grid */
|
||||
width: integer;
|
||||
};
|
||||
export declare type TileOffset = {
|
||||
export type TileOffset = {
|
||||
/** Horizontal offset in pixels */
|
||||
x: integer;
|
||||
/** Vertical offset in pixels (positive is down) */
|
||||
y: integer;
|
||||
};
|
||||
export declare type TiledTransformations = {
|
||||
export type TiledTransformations = {
|
||||
/** Tiles can be flipped horizontally */
|
||||
hflip: boolean;
|
||||
/** Tiles can be flipped vertically */
|
||||
@@ -248,7 +248,7 @@ export declare type TiledTransformations = {
|
||||
/** Whether untransformed tiles remain preferred, otherwise transformed tiles are used to produce more variations */
|
||||
preferuntransformed: boolean;
|
||||
};
|
||||
export declare type TiledTileDefinition = {
|
||||
export 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 declare type TiledTileDefinition = {
|
||||
/** Index of terrain for each corner of tile (optional) */
|
||||
terrain?: Array<integer>;
|
||||
};
|
||||
export declare type TiledFrame = {
|
||||
export type TiledFrame = {
|
||||
/** Frame duration in milliseconds */
|
||||
duration: integer;
|
||||
/** Local tile ID representing this frame */
|
||||
tileid: integer;
|
||||
};
|
||||
export declare type TiledTerrain = {
|
||||
export type TiledTerrain = {
|
||||
/** Name of terrain */
|
||||
name: string;
|
||||
/** Array of {@link TiledProperty} */
|
||||
@@ -284,7 +284,7 @@ export declare type TiledTerrain = {
|
||||
/** Local ID of tile representing terrain */
|
||||
tile: integer;
|
||||
};
|
||||
export declare type TiledWangSet = {
|
||||
export type TiledWangSet = {
|
||||
/** Array of {@link TiledWangColor} */
|
||||
colors: Array<TiledWangColor>;
|
||||
/** Name of the Wang set */
|
||||
@@ -296,7 +296,7 @@ export declare type TiledWangSet = {
|
||||
/** Array of {@link TiledWangTile} */
|
||||
wangtiles: Array<TiledWangTile>;
|
||||
};
|
||||
export declare type TiledWangColor = {
|
||||
export type TiledWangColor = {
|
||||
/** Hex-formatted color (#RRGGBB or #AARRGGBB) */
|
||||
color: string;
|
||||
/** Name of the Wang color */
|
||||
@@ -308,13 +308,13 @@ export declare type TiledWangColor = {
|
||||
/** Local ID of tile representing the Wang color */
|
||||
tile: integer;
|
||||
};
|
||||
export declare type TiledWangTile = {
|
||||
export type TiledWangTile = {
|
||||
/** Local ID of tile */
|
||||
tileid: integer;
|
||||
/** Array of Wang color indexes (`uchar[8]`) */
|
||||
wangid: Array<integer>;
|
||||
};
|
||||
export declare type TiledObjectTemplate = {
|
||||
export type TiledObjectTemplate = {
|
||||
/** `template` */
|
||||
type: string;
|
||||
/** External tileset used by the template (optional) */
|
||||
@@ -322,7 +322,7 @@ export declare type TiledObjectTemplate = {
|
||||
/** The object instantiated by this template */
|
||||
object: Object;
|
||||
};
|
||||
export declare type TiledProperty = {
|
||||
export 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 declare type TiledProperty = {
|
||||
/** Value of the property */
|
||||
value: string | number;
|
||||
};
|
||||
export declare type TiledPoint = {
|
||||
export type TiledPoint = {
|
||||
/** X coordinate in pixels */
|
||||
x: float;
|
||||
/** Y coordinate in pixels */
|
File diff suppressed because one or more lines are too long
16
Extensions/TileMap/helper/dts/load/tiled/TiledTileMapLoader.d.ts
vendored
Normal file
16
Extensions/TileMap/helper/dts/load/tiled/TiledTileMapLoader.d.ts
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
import { EditableTileMap } from '../../model/TileMapModel';
|
||||
import { TiledTileMap } from './TiledFormat';
|
||||
/**
|
||||
* It creates a {@link EditableTileMap} from a Tiled JSON.
|
||||
*/
|
||||
export declare namespace TiledTileMapLoader {
|
||||
/**
|
||||
* Create a {@link EditableTileMap} from the Tiled JSON.
|
||||
*
|
||||
* @param tiledTileMap A tile map exported from Tiled.
|
||||
* @param pako The zlib library.
|
||||
* @returns A {@link EditableTileMap}
|
||||
*/
|
||||
function load(tiledTileMap: TiledTileMap, pako: any): EditableTileMap | null;
|
||||
}
|
||||
//# sourceMappingURL=TiledTileMapLoader.d.ts.map
|
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"TiledTileMapLoader.d.ts","sourceRoot":"","sources":["../../../src/load/tiled/TiledTileMapLoader.ts"],"names":[],"mappings":"AACA,OAAO,EACL,eAAe,EAGhB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAO7C;;GAEG;AACH,yBAAiB,kBAAkB,CAAC;IAClC;;;;;;OAMG;IACH,SAAgB,IAAI,CAClB,YAAY,EAAE,YAAY,EAC1B,IAAI,EAAE,GAAG,GACR,eAAe,GAAG,IAAI,CA0KxB;CACF"}
|
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"TiledTileMapLoader.spec.d.ts","sourceRoot":"","sources":["../../../src/load/tiled/TiledTileMapLoader.spec.ts"],"names":[],"mappings":""}
|
@@ -1,18 +1,18 @@
|
||||
import { integer } from '../model/CommonTypes';
|
||||
import { integer } from '../../model/CommonTypes';
|
||||
import { TiledLayer } from './TiledFormat';
|
||||
/**
|
||||
* Decodes a layer data, which can sometimes be store as a compressed base64 string
|
||||
* by Tiled.
|
||||
* See https://doc.mapeditor.org/en/stable/reference/tmx-map-format/#data.
|
||||
* @param pako The zlib library.
|
||||
* @param layer The layer data from a Tiled JSON.
|
||||
* @param tiledLayer The layer data from a Tiled JSON.
|
||||
* @returns The decoded layer data.
|
||||
*/
|
||||
export declare const decodeBase64LayerData: (
|
||||
pako: any,
|
||||
layer: TiledLayer
|
||||
tiledLayer: TiledLayer
|
||||
) => number[];
|
||||
export declare type TiledGID = {
|
||||
export type TiledGID = {
|
||||
id: integer;
|
||||
flippedHorizontally: boolean;
|
||||
flippedVertically: boolean;
|
||||
@@ -29,9 +29,9 @@ export declare const extractTileUidFlippedStates: (
|
||||
/**
|
||||
* Tiled use 0 as null, we do too but it's black boxed.
|
||||
* This is why the id needs to be decremented.
|
||||
* @return the tile identifier used in {@link TilMapModel}.
|
||||
* @return the tile identifier.
|
||||
*/
|
||||
export declare const getTileIdFromTiledGUI: (
|
||||
export declare function getTileIdFromTiledGUI(
|
||||
tiledGUI: number | undefined
|
||||
) => number | undefined;
|
||||
//# sourceMappingURL=TiledLoaderHelper.d.ts.map
|
||||
): number | undefined;
|
||||
//# sourceMappingURL=TiledTileMapLoaderHelper.d.ts.map
|
@@ -0,0 +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"}
|
@@ -1,5 +1,5 @@
|
||||
export declare type integer = number;
|
||||
export declare type float = number;
|
||||
export declare type FloatPoint = [float, float];
|
||||
export declare type PolygonVertices = FloatPoint[];
|
||||
export type FloatPoint = [float, float];
|
||||
export 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,oBAAY,UAAU,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AAExC,oBAAY,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,MAAM,MAAM,UAAU,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AAExC,MAAM,MAAM,eAAe,GAAG,UAAU,EAAE,CAAC"}
|
45
Extensions/TileMap/helper/dts/model/GID.d.ts
vendored
Normal file
45
Extensions/TileMap/helper/dts/model/GID.d.ts
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
import { integer } from './CommonTypes';
|
||||
export declare const FLIPPED_HORIZONTALLY_FLAG = 2147483648;
|
||||
export declare const FLIPPED_VERTICALLY_FLAG = 1073741824;
|
||||
export declare const FLIPPED_DIAGONALLY_FLAG = 536870912;
|
||||
/**
|
||||
* Tile identifiers making to access flipping flags.
|
||||
*/
|
||||
export declare namespace FlippingHelper {
|
||||
const tileIdMask: number;
|
||||
function getTileId(tileId: integer): integer;
|
||||
function setFlippedHorizontally(
|
||||
tileId: integer,
|
||||
flippedHorizontally: boolean
|
||||
): integer;
|
||||
function setFlippedVertically(
|
||||
tileId: integer,
|
||||
flippedVertically: boolean
|
||||
): integer;
|
||||
function setFlippedDiagonally(
|
||||
tileId: integer,
|
||||
flippedDiagonally: boolean
|
||||
): integer;
|
||||
function isFlippedHorizontally(tileId: integer): boolean;
|
||||
function isFlippedVertically(tileId: integer): boolean;
|
||||
function isFlippedDiagonally(tileId: integer): boolean;
|
||||
}
|
||||
/**
|
||||
* Return the texture to use for the tile with the specified uid, which can contains
|
||||
* information about rotation in bits 32, 31 and 30
|
||||
* (see https://doc.mapeditor.org/en/stable/reference/tmx-map-format/).
|
||||
*
|
||||
* @param flippedHorizontally true if the tile is flipped horizontally.
|
||||
* @param flippedVertically true if the tile is flipped vertically.
|
||||
* @param flippedDiagonally true if the tile is flipped diagonally.
|
||||
* @returns the rotation "D8" number used by Pixi.
|
||||
* @see https://pixijs.io/examples/#/textures/texture-rotate.js
|
||||
*/
|
||||
export declare function getPixiRotate(tileGID: integer): number;
|
||||
export declare function getTileGID(
|
||||
tileId: integer,
|
||||
flippedHorizontally: boolean,
|
||||
flippedVertically: boolean,
|
||||
flippedDiagonally: boolean
|
||||
): integer;
|
||||
//# sourceMappingURL=GID.d.ts.map
|
1
Extensions/TileMap/helper/dts/model/GID.d.ts.map
Normal file
1
Extensions/TileMap/helper/dts/model/GID.d.ts.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"GID.d.ts","sourceRoot":"","sources":["../../src/model/GID.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,eAAO,MAAM,yBAAyB,aAAa,CAAC;AACpD,eAAO,MAAM,uBAAuB,aAAa,CAAC;AAClD,eAAO,MAAM,uBAAuB,YAAa,CAAC;AAElD;;GAEG;AACH,yBAAiB,cAAc,CAAC;IACvB,MAAM,UAAU,QAItB,CAAC;IAEF,SAAgB,SAAS,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAElD;IAED,SAAgB,sBAAsB,CACpC,MAAM,EAAE,OAAO,EACf,mBAAmB,EAAE,OAAO,GAC3B,OAAO,CAMT;IAED,SAAgB,oBAAoB,CAClC,MAAM,EAAE,OAAO,EACf,iBAAiB,EAAE,OAAO,GACzB,OAAO,CAMT;IAED,SAAgB,oBAAoB,CAClC,MAAM,EAAE,OAAO,EACf,iBAAiB,EAAE,OAAO,GACzB,OAAO,CAMT;IAED,SAAgB,qBAAqB,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAE9D;IAED,SAAgB,mBAAmB,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAE5D;IAED,SAAgB,mBAAmB,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAE5D;CACF;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,UA0B7C;AAED,wBAAgB,UAAU,CACxB,MAAM,EAAE,OAAO,EACf,mBAAmB,EAAE,OAAO,EAC5B,iBAAiB,EAAE,OAAO,EAC1B,iBAAiB,EAAE,OAAO,GACzB,OAAO,CAYT"}
|
@@ -2,12 +2,13 @@ import { PolygonVertices, integer, float } from './CommonTypes';
|
||||
/**
|
||||
* A tile map model.
|
||||
*
|
||||
* Tile map files are parsed into this model by {@link TiledTileMapLoader}.
|
||||
* Tile map files are parsed into this model by {@link TiledTileMapLoader} or {@link LDtkTileMapLoader}.
|
||||
* This model is used for rending ({@link TileMapRuntimeObjectPixiRenderer})
|
||||
* and hitboxes handling ({@link TransformedCollisionTileMap}).
|
||||
* This allows to support new file format with only a new parser.
|
||||
*/
|
||||
export declare class EditableTileMap {
|
||||
private _backgroundResourceName?;
|
||||
private _tileSet;
|
||||
private _layers;
|
||||
/**
|
||||
@@ -83,6 +84,10 @@ export declare class EditableTileMap {
|
||||
* @returns The new layer.
|
||||
*/
|
||||
addObjectLayer(id: integer): EditableObjectLayer;
|
||||
/**
|
||||
* @returns The resource name of the background
|
||||
*/
|
||||
getBackgroundResourceName(): string;
|
||||
/**
|
||||
* @returns All the layers of the tile map.
|
||||
*/
|
||||
@@ -99,6 +104,10 @@ export declare class EditableTileMap {
|
||||
* @returns true when the point is inside a tile with a given tag.
|
||||
*/
|
||||
pointIsInsideTile(x: float, y: float, tag: string): boolean;
|
||||
/**
|
||||
* @param resourceName The name of the resource
|
||||
*/
|
||||
setBackgroundResourceName(resourceName: string): void;
|
||||
}
|
||||
/**
|
||||
* A tile map layer.
|
||||
@@ -183,15 +192,24 @@ export declare class TileObject {
|
||||
*/
|
||||
export declare class EditableTileMapLayer extends AbstractEditableLayer {
|
||||
private readonly _tiles;
|
||||
private _alpha;
|
||||
/**
|
||||
* @param tileMap The layer tile map.
|
||||
* @param id The layer identifier.
|
||||
*/
|
||||
constructor(tileMap: EditableTileMap, id: integer);
|
||||
/**
|
||||
* The opacity (between 0-1) of the layer
|
||||
*/
|
||||
getAlpha(): float;
|
||||
/**
|
||||
* @param alpha The opacity between 0-1
|
||||
*/
|
||||
setAlpha(alpha: float): void;
|
||||
/**
|
||||
* @param x The layer column.
|
||||
* @param y The layer row.
|
||||
* @param tileId The tile identifier in the tile set.
|
||||
* @param tileId The tile.
|
||||
*/
|
||||
setTile(x: integer, y: integer, tileId: integer): void;
|
||||
/**
|
||||
@@ -250,9 +268,15 @@ export declare class EditableTileMapLayer extends AbstractEditableLayer {
|
||||
/**
|
||||
* @param x The layer column.
|
||||
* @param y The layer row.
|
||||
* @returns The tile identifier from the tile set.
|
||||
* @returns The tile's GID (id + flipping bits).
|
||||
*/
|
||||
get(x: integer, y: integer): integer | undefined;
|
||||
getTileGID(x: integer, y: integer): integer | undefined;
|
||||
/**
|
||||
* @param x The layer column.
|
||||
* @param y The layer row.
|
||||
* @returns The tile's id.
|
||||
*/
|
||||
getTileId(x: integer, y: integer): integer | undefined;
|
||||
/**
|
||||
* The number of tile columns in the layer.
|
||||
*/
|
||||
@@ -280,23 +304,28 @@ export declare class TileDefinition {
|
||||
*/
|
||||
private readonly taggedHitBoxes;
|
||||
private readonly animationLength;
|
||||
/**
|
||||
* A tile can be a composition of several tiles.
|
||||
*/
|
||||
private stackedTiles;
|
||||
private stackTileId?;
|
||||
/**
|
||||
* @param animationLength The number of frame in the tile animation.
|
||||
*/
|
||||
constructor(animationLength: integer);
|
||||
constructor(animationLength?: integer);
|
||||
/**
|
||||
* Add a polygon for the collision layer
|
||||
* @param tag The tag to allow collision layer filtering.
|
||||
* @param polygon The polygon to use for collisions.
|
||||
*/
|
||||
add(tag: string, polygon: PolygonVertices): void;
|
||||
addHitBox(tag: string, polygon: PolygonVertices): void;
|
||||
/**
|
||||
* This property is used by {@link TransformedCollisionTileMap}
|
||||
* to make collision classes.
|
||||
* @param tag The tag to allow collision layer filtering.
|
||||
* @returns true if this tile contains any polygon with the given tag.
|
||||
*/
|
||||
hasTag(tag: string): boolean;
|
||||
hasTaggedHitBox(tag: string): boolean;
|
||||
/**
|
||||
* The hitboxes positioning is done by {@link TransformedCollisionTileMap}.
|
||||
* @param tag The tag to allow collision layer filtering.
|
||||
@@ -310,6 +339,23 @@ export declare class TileDefinition {
|
||||
* @returns The number of frame in the tile animation.
|
||||
*/
|
||||
getAnimationLength(): integer;
|
||||
/**
|
||||
* @returns The tile representing the stack of tiles.
|
||||
*/
|
||||
getStackTileId(): integer;
|
||||
/**
|
||||
* @returns All the tiles composed in the stack.
|
||||
*/
|
||||
getStackedTiles(): integer[];
|
||||
/**
|
||||
* @returns `true` if the defintion is a stack of tiles.
|
||||
*/
|
||||
hasStackedTiles(): boolean;
|
||||
/**
|
||||
* @param stackTileId The `tileId` representing the stack.
|
||||
* @param tiles All the tiles of stack.
|
||||
*/
|
||||
setStackedTiles(stackTileId: integer, ...tiles: integer[]): void;
|
||||
}
|
||||
export {};
|
||||
//# sourceMappingURL=TileMapModel.d.ts.map
|
||||
|
@@ -1 +1 @@
|
||||
{"version":3,"file":"TileMapModel.d.ts","sourceRoot":"","sources":["../../src/model/TileMapModel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEhE;;;;;;;GAOG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAA+B;IAC/C,OAAO,CAAC,OAAO,CAA+B;IAC9C;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAU;IACpC;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAU;IACrC;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAU;IAC/B;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAU;IAE/B;;;;;;OAMG;gBAED,SAAS,EAAE,OAAO,EAClB,UAAU,EAAE,OAAO,EACnB,IAAI,EAAE,OAAO,EACb,IAAI,EAAE,OAAO,EAGb,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,cAAc,CAAC;IAUvC;;OAEG;IACH,QAAQ,IAAI,OAAO;IAInB;;OAEG;IACH,SAAS,IAAI,OAAO;IAIpB;;OAEG;IACH,aAAa,IAAI,OAAO;IAIxB;;OAEG;IACH,YAAY,IAAI,OAAO;IAIvB;;OAEG;IACH,aAAa,IAAI,OAAO;IAIxB;;OAEG;IACH,aAAa,IAAI,OAAO;IAIxB;;;OAGG;IACH,iBAAiB,CAAC,MAAM,EAAE,OAAO,GAAG,cAAc,GAAG,SAAS;IAI9D;;OAEG;IACH,kBAAkB,IAAI,QAAQ,CAAC,cAAc,CAAC;IAI9C;;;OAGG;IACH,YAAY,CAAC,EAAE,EAAE,OAAO,GAAG,oBAAoB;IAM/C;;;OAGG;IACH,cAAc,CAAC,EAAE,EAAE,OAAO,GAAG,mBAAmB;IAMhD;;OAEG;IACH,SAAS,IAAI,QAAQ,CAAC,qBAAqB,CAAC;IAI5C;;;;;;;;;;OAUG;IACH,iBAAiB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO;CAmB5D;AAED;;GAEG;AACH,uBAAe,qBAAqB;IAClC;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;IAClC;;OAEG;IACH,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC;IACrB,OAAO,CAAC,OAAO,CAAiB;IAEhC;;;OAGG;gBACS,OAAO,EAAE,eAAe,EAAE,EAAE,EAAE,OAAO;IAKjD,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAIlC;;OAEG;IACH,SAAS,IAAI,OAAO;CAGrB;AAED;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,qBAAqB;IAC5D,QAAQ,CAAC,OAAO,EAAE,UAAU,EAAE,CAAC;IAE/B;;;OAGG;gBACS,OAAO,EAAE,eAAe,EAAE,EAAE,EAAE,OAAO;IAKjD,GAAG,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;CAG9B;AAED;;GAEG;AACH,qBAAa,UAAU;IACrB;;OAEG;IACH,OAAO,CAAC,MAAM,CAAU;IACxB;;OAEG;IACH,QAAQ,CAAC,CAAC,EAAE,KAAK,CAAC;IAClB;;OAEG;IACH,QAAQ,CAAC,CAAC,EAAE,KAAK,CAAC;IAElB;;;;OAIG;gBACS,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO;IAM/C;;OAEG;IACH,SAAS,IAAI,OAAO;IAIpB,sBAAsB,CAAC,mBAAmB,EAAE,OAAO,GAAG,IAAI;IAO1D,oBAAoB,CAAC,iBAAiB,EAAE,OAAO,GAAG,IAAI;IAOtD,oBAAoB,CAAC,iBAAiB,EAAE,OAAO,GAAG,IAAI;IAOtD;;OAEG;IACH,qBAAqB,IAAI,OAAO;IAIhC;;OAEG;IACH,mBAAmB,IAAI,OAAO;IAI9B;;OAEG;IACH,mBAAmB,IAAI,OAAO;CAG/B;AAiED;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,qBAAqB;IAC7D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAoB;IAE3C;;;OAGG;gBACS,OAAO,EAAE,eAAe,EAAE,EAAE,EAAE,OAAO;IASjD;;;;OAIG;IACH,OAAO,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI;IAUtD;;;OAGG;IACH,UAAU,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,IAAI;IAKxC;;;;OAIG;IACH,sBAAsB,CACpB,CAAC,EAAE,OAAO,EACV,CAAC,EAAE,OAAO,EACV,mBAAmB,EAAE,OAAO,GAC3B,IAAI;IAWP;;;;OAIG;IACH,oBAAoB,CAClB,CAAC,EAAE,OAAO,EACV,CAAC,EAAE,OAAO,EACV,iBAAiB,EAAE,OAAO,GACzB,IAAI;IAWP;;;;OAIG;IACH,oBAAoB,CAClB,CAAC,EAAE,OAAO,EACV,CAAC,EAAE,OAAO,EACV,iBAAiB,EAAE,OAAO,GACzB,IAAI;IAWP;;;;OAIG;IACH,qBAAqB,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO;IAItD;;;;OAIG;IACH,mBAAmB,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO;IAIpD;;;;OAIG;IACH,mBAAmB,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO;IAIpD;;;;OAIG;IACH,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO,GAAG,SAAS;IAUhD;;OAEG;IACH,aAAa,IAAI,OAAO;IAIxB;;OAEG;IACH,aAAa,IAAI,OAAO;IAIxB;;OAEG;IACH,QAAQ,IAAI,OAAO;IAInB;;OAEG;IACH,SAAS,IAAI,OAAO;CAGrB;AAED;;GAEG;AACH,qBAAa,cAAc;IACzB;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAC,cAAc,CAG3B;IACJ,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAU;IAE1C;;OAEG;gBACS,eAAe,EAAE,OAAO;IAKpC;;;;OAIG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,GAAG,IAAI;IAShD;;;;;OAKG;IACH,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAI5B;;;;OAIG;IACH,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe,EAAE,GAAG,SAAS;IAOvD;;;;;OAKG;IACH,kBAAkB,IAAI,OAAO;CAG9B"}
|
||||
{"version":3,"file":"TileMapModel.d.ts","sourceRoot":"","sources":["../../src/model/TileMapModel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAGhE;;;;;;;GAOG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,uBAAuB,CAAC,CAAS;IACzC,OAAO,CAAC,QAAQ,CAA+B;IAC/C,OAAO,CAAC,OAAO,CAA+B;IAC9C;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAU;IACpC;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAU;IACrC;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAU;IAC/B;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAU;IAE/B;;;;;;OAMG;gBAED,SAAS,EAAE,OAAO,EAClB,UAAU,EAAE,OAAO,EACnB,IAAI,EAAE,OAAO,EACb,IAAI,EAAE,OAAO,EAGb,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,cAAc,CAAC;IAUvC;;OAEG;IACH,QAAQ,IAAI,OAAO;IAInB;;OAEG;IACH,SAAS,IAAI,OAAO;IAIpB;;OAEG;IACH,aAAa,IAAI,OAAO;IAIxB;;OAEG;IACH,YAAY,IAAI,OAAO;IAIvB;;OAEG;IACH,aAAa,IAAI,OAAO;IAIxB;;OAEG;IACH,aAAa,IAAI,OAAO;IAIxB;;;OAGG;IACH,iBAAiB,CAAC,MAAM,EAAE,OAAO,GAAG,cAAc,GAAG,SAAS;IAI9D;;OAEG;IACH,kBAAkB,IAAI,QAAQ,CAAC,cAAc,CAAC;IAI9C;;;OAGG;IACH,YAAY,CAAC,EAAE,EAAE,OAAO,GAAG,oBAAoB;IAM/C;;;OAGG;IACH,cAAc,CAAC,EAAE,EAAE,OAAO,GAAG,mBAAmB;IAMhD;;OAEG;IACH,yBAAyB,IAAI,MAAM;IAInC;;OAEG;IACH,SAAS,IAAI,QAAQ,CAAC,qBAAqB,CAAC;IAI5C;;;;;;;;;;OAUG;IACH,iBAAiB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO;IAoB3D;;OAEG;IACH,yBAAyB,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI;CAGtD;AAED;;GAEG;AACH,uBAAe,qBAAqB;IAClC;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;IAClC;;OAEG;IACH,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC;IACrB,OAAO,CAAC,OAAO,CAAiB;IAEhC;;;OAGG;gBACS,OAAO,EAAE,eAAe,EAAE,EAAE,EAAE,OAAO;IAKjD,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAIlC;;OAEG;IACH,SAAS,IAAI,OAAO;CAGrB;AAED;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,qBAAqB;IAC5D,QAAQ,CAAC,OAAO,EAAE,UAAU,EAAE,CAAC;IAE/B;;;OAGG;gBACS,OAAO,EAAE,eAAe,EAAE,EAAE,EAAE,OAAO;IAKjD,GAAG,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;CAG9B;AAED;;GAEG;AACH,qBAAa,UAAU;IACrB;;OAEG;IACH,OAAO,CAAC,MAAM,CAAU;IACxB;;OAEG;IACH,QAAQ,CAAC,CAAC,EAAE,KAAK,CAAC;IAClB;;OAEG;IACH,QAAQ,CAAC,CAAC,EAAE,KAAK,CAAC;IAElB;;;;OAIG;gBACS,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO;IAM/C;;OAEG;IACH,SAAS,IAAI,OAAO;IAIpB,sBAAsB,CAAC,mBAAmB,EAAE,OAAO,GAAG,IAAI;IAO1D,oBAAoB,CAAC,iBAAiB,EAAE,OAAO,GAAG,IAAI;IAOtD,oBAAoB,CAAC,iBAAiB,EAAE,OAAO,GAAG,IAAI;IAOtD;;OAEG;IACH,qBAAqB,IAAI,OAAO;IAIhC;;OAEG;IACH,mBAAmB,IAAI,OAAO;IAI9B;;OAEG;IACH,mBAAmB,IAAI,OAAO;CAG/B;AAED;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,qBAAqB;IAC7D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAe;IACtC,OAAO,CAAC,MAAM,CAAQ;IAEtB;;;OAGG;gBACS,OAAO,EAAE,eAAe,EAAE,EAAE,EAAE,OAAO;IAUjD;;OAEG;IACH,QAAQ,IAAI,KAAK;IAIjB;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,KAAK;IAIrB;;;;OAIG;IACH,OAAO,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI;IAgBtD;;;OAGG;IACH,UAAU,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,IAAI;IAWxC;;;;OAIG;IACH,sBAAsB,CACpB,CAAC,EAAE,OAAO,EACV,CAAC,EAAE,OAAO,EACV,mBAAmB,EAAE,OAAO,GAC3B,IAAI;IAiBP;;;;OAIG;IACH,oBAAoB,CAClB,CAAC,EAAE,OAAO,EACV,CAAC,EAAE,OAAO,EACV,iBAAiB,EAAE,OAAO,GACzB,IAAI;IAiBP;;;;OAIG;IACH,oBAAoB,CAClB,CAAC,EAAE,OAAO,EACV,CAAC,EAAE,OAAO,EACV,iBAAiB,EAAE,OAAO,GACzB,IAAI;IAiBP;;;;OAIG;IACH,qBAAqB,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO;IAUtD;;;;OAIG;IACH,mBAAmB,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO;IAUpD;;;;OAIG;IACH,mBAAmB,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO;IAUpD;;;;OAIG;IACH,UAAU,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO,GAAG,SAAS;IASvD;;;;OAIG;IACH,SAAS,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO,GAAG,SAAS;IAUtD;;OAEG;IACH,aAAa,IAAI,OAAO;IAIxB;;OAEG;IACH,aAAa,IAAI,OAAO;IAIxB;;OAEG;IACH,QAAQ,IAAI,OAAO;IAInB;;OAEG;IACH,SAAS,IAAI,OAAO;CAGrB;AAED;;GAEG;AACH,qBAAa,cAAc;IACzB;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAC,cAAc,CAG3B;IACJ,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAU;IAE1C;;OAEG;IACH,OAAO,CAAC,YAAY,CAAY;IAChC,OAAO,CAAC,WAAW,CAAC,CAAU;IAE9B;;OAEG;gBACS,eAAe,CAAC,EAAE,OAAO;IAMrC;;;;OAIG;IACH,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,GAAG,IAAI;IAStD;;;;;OAKG;IACH,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAIrC;;;;OAIG;IACH,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe,EAAE,GAAG,SAAS;IAOvD;;;;;OAKG;IACH,kBAAkB,IAAI,OAAO;IAI7B;;OAEG;IACH,cAAc,IAAI,OAAO;IAIzB;;OAEG;IACH,eAAe,IAAI,OAAO,EAAE;IAI5B;;OAEG;IACH,eAAe,IAAI,OAAO;IAI1B;;;OAGG;IACH,eAAe,CAAC,WAAW,EAAE,OAAO,EAAE,GAAG,KAAK,EAAE,OAAO,EAAE,GAAG,IAAI;CAIjE"}
|
@@ -1,7 +1,7 @@
|
||||
import { TiledMap } from '../tiled/TiledFormat';
|
||||
import { EditableTileMap } from '../model/TileMapModel';
|
||||
import { TileTextureCache } from './TileTextureCache';
|
||||
import PIXI = GlobalPIXIModule.PIXI;
|
||||
import { TileMap } from '../types';
|
||||
/**
|
||||
* A holder to share tile maps across the 2 extension objects.
|
||||
*
|
||||
@@ -20,41 +20,50 @@ export declare class TileMapManager {
|
||||
*/
|
||||
static getManager(instanceHolder: Object): TileMapManager;
|
||||
/**
|
||||
* @param loadTiledMap The method that loads the Tiled JSON file in memory.
|
||||
* @param data JSON data.
|
||||
* @returns The data enclosed with its detected kind.
|
||||
*/
|
||||
static identify(data: any): TileMap | null;
|
||||
/**
|
||||
* @param loadTileMap The method that loads the Tiled JSON file in memory.
|
||||
* @param tileMapJsonResourceName The resource name of the tile map.
|
||||
* @param tileSetJsonResourceName The resource name of the tile set.
|
||||
* @param levelIndex The level of the tile map to load from.
|
||||
* @param pako The zlib library.
|
||||
* @param callback A function called when the tile map is parsed.
|
||||
*/
|
||||
getOrLoadTileMap(
|
||||
loadTiledMap: (
|
||||
loadTileMap: (
|
||||
tileMapJsonResourceName: string,
|
||||
tileSetJsonResourceName: string,
|
||||
callback: (tiledMap: TiledMap | null) => void
|
||||
callback: (tileMap: TileMap | null) => void
|
||||
) => void,
|
||||
tileMapJsonResourceName: string,
|
||||
tileSetJsonResourceName: string,
|
||||
levelIndex: number,
|
||||
pako: any,
|
||||
callback: (tileMap: EditableTileMap | null) => void
|
||||
): void;
|
||||
/**
|
||||
* @param loadTiledMap The method that loads the Tiled JSON file in memory.
|
||||
* @param loadTileMap The method that loads the Tiled JSON file in memory.
|
||||
* @param getTexture The method that loads the atlas image file in memory.
|
||||
* @param atlasImageResourceName The resource name of the atlas image.
|
||||
* @param tileMapJsonResourceName The resource name of the tile map.
|
||||
* @param tileSetJsonResourceName The resource name of the tile set.
|
||||
* @param levelIndex The level of the tile map to load from.
|
||||
* @param callback A function called when the tiles textures are split.
|
||||
*/
|
||||
getOrLoadTextureCache(
|
||||
loadTiledMap: (
|
||||
loadTileMap: (
|
||||
tileMapJsonResourceName: string,
|
||||
tileSetJsonResourceName: string,
|
||||
callback: (tiledMap: TiledMap | null) => void
|
||||
callback: (tileMap: TileMap | null) => void
|
||||
) => void,
|
||||
getTexture: (textureName: string) => PIXI.BaseTexture<PIXI.Resource>,
|
||||
atlasImageResourceName: string,
|
||||
tileMapJsonResourceName: string,
|
||||
tileSetJsonResourceName: string,
|
||||
levelIndex: number,
|
||||
callback: (textureCache: TileTextureCache | null) => void
|
||||
): void;
|
||||
}
|
||||
|
@@ -1 +1 @@
|
||||
{"version":3,"file":"TileMapManager.d.ts","sourceRoot":"","sources":["../../src/render/TileMapManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEhD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAGtD,OAAO,IAAI,GAAG,gBAAgB,CAAC,IAAI,CAAC;AAEpC;;;;;;;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;;;;;;OAMG;IACH,gBAAgB,CACd,YAAY,EAAE,CACZ,uBAAuB,EAAE,MAAM,EAC/B,uBAAuB,EAAE,MAAM,EAC/B,QAAQ,EAAE,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,KAAK,IAAI,KAC1C,IAAI,EACT,uBAAuB,EAAE,MAAM,EAC/B,uBAAuB,EAAE,MAAM,EAC/B,IAAI,EAAE,GAAG,EACT,QAAQ,EAAE,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI,KAAK,IAAI,GAClD,IAAI;IAwBP;;;;;;;OAOG;IACH,qBAAqB,CACnB,YAAY,EAAE,CACZ,uBAAuB,EAAE,MAAM,EAC/B,uBAAuB,EAAE,MAAM,EAC/B,QAAQ,EAAE,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,KAAK,IAAI,KAC1C,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,QAAQ,EAAE,CAAC,YAAY,EAAE,gBAAgB,GAAG,IAAI,KAAK,IAAI,GACxD,IAAI;CAoCR"}
|
||||
{"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"}
|
@@ -1,26 +1,28 @@
|
||||
import { integer, float } from '../model/CommonTypes';
|
||||
import { TiledMap } from '../tiled/TiledFormat';
|
||||
import { EditableTileMap } from '../model/TileMapModel';
|
||||
import { TileMap } from '../types';
|
||||
import { TileTextureCache } from './TileTextureCache';
|
||||
import PIXI = GlobalPIXIModule.PIXI;
|
||||
export declare class PixiTileMapHelper {
|
||||
export declare namespace PixiTileMapHelper {
|
||||
/**
|
||||
* Split an atlas image into Pixi textures.
|
||||
*
|
||||
* @param tiledMap A tile map exported from Tiled.
|
||||
* @param levelIndex The level of the tile map to load from.
|
||||
* @param atlasTexture The texture containing the whole tile set.
|
||||
* @param getTexture A getter to load a texture. Used if atlasTexture is not specified.
|
||||
* @returns A textures cache.
|
||||
*/
|
||||
static parseAtlas(
|
||||
tiledMap: TiledMap,
|
||||
function parseAtlas(
|
||||
tileMap: TileMap,
|
||||
levelIndex: number,
|
||||
atlasTexture: PIXI.BaseTexture<PIXI.Resource> | null,
|
||||
getTexture: (textureName: string) => PIXI.BaseTexture<PIXI.Resource>
|
||||
): TileTextureCache | null;
|
||||
/**
|
||||
* Re-renders the tile map whenever its rendering settings have been changed
|
||||
*
|
||||
* @param pixiTileMap the tile map renderer
|
||||
* @param untypedPixiTileMap the tile map renderer
|
||||
* @param tileMap the tile map model
|
||||
* @param textureCache the tile set textures
|
||||
* @param displayMode What to display:
|
||||
@@ -30,7 +32,7 @@ export declare class PixiTileMapHelper {
|
||||
* @param layerIndex If `displayMode` is set to `index`, the layer index to be
|
||||
* displayed.
|
||||
*/
|
||||
static updatePixiTileMap(
|
||||
function updatePixiTileMap(
|
||||
untypedPixiTileMap: any,
|
||||
tileMap: EditableTileMap,
|
||||
textureCache: TileTextureCache,
|
||||
@@ -40,7 +42,7 @@ export declare class PixiTileMapHelper {
|
||||
/**
|
||||
* Re-renders the collision mask
|
||||
*/
|
||||
static updatePixiCollisionMask(
|
||||
function updatePixiCollisionMask(
|
||||
pixiGraphics: PIXI.Graphics,
|
||||
tileMap: EditableTileMap,
|
||||
typeFilter: string,
|
||||
|
@@ -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,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAEL,eAAe,EAEhB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,IAAI,GAAG,gBAAgB,CAAC,IAAI,CAAC;AAGpC,qBAAa,iBAAiB;IAC5B;;;;;;;OAOG;IACH,MAAM,CAAC,UAAU,CACf,QAAQ,EAAE,QAAQ,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;IA6F1B;;;;;;;;;;;;OAYG;IACH,MAAM,CAAC,iBAAiB,CACtB,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;IAgFP;;OAEG;IACH,MAAM,CAAC,uBAAuB,CAC5B,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;CAiER"}
|
||||
{"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"}
|
@@ -7,44 +7,18 @@ import PIXI = GlobalPIXIModule.PIXI;
|
||||
* and used by {@link PixiTileMapHelper.updatePixiTileMap}.
|
||||
*/
|
||||
export declare class TileTextureCache {
|
||||
private static readonly flippedHorizontallyFlag;
|
||||
private static readonly flippedVerticallyFlag;
|
||||
private static readonly flippedDiagonallyFlag;
|
||||
private readonly _levelBackgroundTextures;
|
||||
private readonly _textures;
|
||||
constructor();
|
||||
setTexture(
|
||||
tileId: integer,
|
||||
flippedHorizontally: boolean,
|
||||
flippedVertically: boolean,
|
||||
flippedDiagonally: boolean,
|
||||
texture: PIXI.Texture
|
||||
): void;
|
||||
setTexture(tileId: integer, texture: PIXI.Texture): void;
|
||||
/**
|
||||
* Return the texture to use for the tile with the specified id.
|
||||
*
|
||||
* @param tileId The tile identifier
|
||||
* @returns The texture for the given tile identifier.
|
||||
*/
|
||||
findTileTexture(tileId: integer): PIXI.Texture | undefined;
|
||||
/**
|
||||
* Return the texture to use for the tile with the specified uid, which can contains
|
||||
* information about rotation in bits 32, 31 and 30
|
||||
* (see https://doc.mapeditor.org/en/stable/reference/tmx-map-format/).
|
||||
*
|
||||
* @param flippedHorizontally true if the tile is flipped horizontally.
|
||||
* @param flippedVertically true if the tile is flipped vertically.
|
||||
* @param flippedDiagonally true if the tile is flipped diagonally.
|
||||
* @returns the rotation "D8" number used by Pixi.
|
||||
* @see https://pixijs.io/examples/#/textures/texture-rotate.js
|
||||
*/
|
||||
getPixiRotate(
|
||||
flippedHorizontally: boolean,
|
||||
flippedVertically: boolean,
|
||||
flippedDiagonally: boolean
|
||||
): number;
|
||||
/**
|
||||
* @return the Tiled tile global uniq identifier.
|
||||
*/
|
||||
private _getGlobalId;
|
||||
getTexture(tileId: integer): PIXI.Texture | undefined;
|
||||
getLevelBackgroundTexture(name: string): PIXI.Texture | undefined;
|
||||
setLevelBackgroundTexture(name: string, texture: PIXI.Texture): void;
|
||||
}
|
||||
//# sourceMappingURL=TileTextureCache.d.ts.map
|
||||
|
@@ -1 +1 @@
|
||||
{"version":3,"file":"TileTextureCache.d.ts","sourceRoot":"","sources":["../../src/render/TileTextureCache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE/C,OAAO,IAAI,GAAG,gBAAgB,CAAC,IAAI,CAAC;AAEpC;;;;;GAKG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,uBAAuB,CAAc;IAC7D,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,qBAAqB,CAAc;IAC3D,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,qBAAqB,CAAc;IAE3D,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA6B;;IAMvD,UAAU,CACR,MAAM,EAAE,OAAO,EACf,mBAAmB,EAAE,OAAO,EAC5B,iBAAiB,EAAE,OAAO,EAC1B,iBAAiB,EAAE,OAAO,EAC1B,OAAO,EAAE,IAAI,CAAC,OAAO,GACpB,IAAI;IAUP;;;;;OAKG;IACH,eAAe,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC,OAAO,GAAG,SAAS;IAI1D;;;;;;;;;;OAUG;IACH,aAAa,CACX,mBAAmB,EAAE,OAAO,EAC5B,iBAAiB,EAAE,OAAO,EAC1B,iBAAiB,EAAE,OAAO,GACzB,MAAM;IAwBT;;OAEG;IACH,OAAO,CAAC,YAAY;CAkBrB"}
|
||||
{"version":3,"file":"TileTextureCache.d.ts","sourceRoot":"","sources":["../../src/render/TileTextureCache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE/C,OAAO,IAAI,GAAG,gBAAgB,CAAC,IAAI,CAAC;AAEpC;;;;;GAKG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,wBAAwB,CAA4B;IACrE,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA6B;;IAOvD,UAAU,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,GAAG,IAAI;IAIxD;;;;;OAKG;IACH,UAAU,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC,OAAO,GAAG,SAAS;IAIrD,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC,OAAO,GAAG,SAAS;IAIjE,yBAAyB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,GAAG,IAAI;CAGrE"}
|
24
Extensions/TileMap/helper/dts/render/ldtk/LDtkPixiHelper.d.ts
vendored
Normal file
24
Extensions/TileMap/helper/dts/render/ldtk/LDtkPixiHelper.d.ts
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
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>;
|
||||
export declare namespace LDtkPixiHelper {
|
||||
/**
|
||||
* Split an atlas image into Pixi textures.
|
||||
*
|
||||
* @param tileMap A tile map exported from LDtk.
|
||||
* @param levelIndex The level of the tile map to load from.
|
||||
* @param atlasTexture The texture containing the whole tile set.
|
||||
* @param getTexture A getter to load a texture.
|
||||
* @returns A textures cache.
|
||||
*/
|
||||
function parseAtlas(
|
||||
tileMap: LDtkTileMap,
|
||||
levelIndex: number,
|
||||
atlasTexture: Texture | null,
|
||||
getTexture: TextureLoader
|
||||
): TileTextureCache | null;
|
||||
}
|
||||
export {};
|
||||
//# sourceMappingURL=LDtkPixiHelper.d.ts.map
|
@@ -0,0 +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"}
|
21
Extensions/TileMap/helper/dts/render/tiled/TiledPixiHelper.d.ts
vendored
Normal file
21
Extensions/TileMap/helper/dts/render/tiled/TiledPixiHelper.d.ts
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
import { TileTextureCache } from '../TileTextureCache';
|
||||
import { TiledTileMap } from '../../load/tiled/TiledFormat';
|
||||
import PIXI = GlobalPIXIModule.PIXI;
|
||||
export declare namespace TiledPixiHelper {
|
||||
/**
|
||||
* Split an atlas image into Pixi textures.
|
||||
*
|
||||
* @param tileMap A tile map exported from Tiled.
|
||||
* @param levelIndex The level of the tile map to load from.
|
||||
* @param atlasTexture The texture containing the whole tile set.
|
||||
* @param getTexture A getter to load a texture. Used if atlasTexture is not specified.
|
||||
* @returns A textures cache.
|
||||
*/
|
||||
function parseAtlas(
|
||||
tileMap: TiledTileMap,
|
||||
levelIndex: number,
|
||||
atlasTexture: PIXI.BaseTexture<PIXI.Resource> | null,
|
||||
getTexture: (textureName: string) => PIXI.BaseTexture<PIXI.Resource>
|
||||
): TileTextureCache | null;
|
||||
}
|
||||
//# sourceMappingURL=TiledPixiHelper.d.ts.map
|
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"TiledPixiHelper.d.ts","sourceRoot":"","sources":["../../../src/render/tiled/TiledPixiHelper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAE5D,OAAO,IAAI,GAAG,gBAAgB,CAAC,IAAI,CAAC;AAEpC,yBAAiB,eAAe,CAAC;IAC/B;;;;;;;;OAQG;IACH,SAAgB,UAAU,CACxB,OAAO,EAAE,YAAY,EACrB,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,CA2FzB;CACF"}
|
339
Extensions/TileMap/helper/dts/tiled/Tiled.d.ts
vendored
339
Extensions/TileMap/helper/dts/tiled/Tiled.d.ts
vendored
@@ -1,339 +0,0 @@
|
||||
import { float, integer } from '../model/CommonTypes';
|
||||
/**
|
||||
* Tiled JSON format.
|
||||
*/
|
||||
export declare type TiledMap = {
|
||||
/** 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) */
|
||||
compressionlevel: integer;
|
||||
/** Number of tile rows */
|
||||
height: integer;
|
||||
/** Length of the side of a hex tile in pixels (hexagonal maps only) */
|
||||
hexsidelength?: integer;
|
||||
/** Whether the map has infinite dimensions */
|
||||
infinite: boolean;
|
||||
/** Array of {@link TiledLayer} */
|
||||
layers: Array<TiledLayer>;
|
||||
/** Auto-increments for each layer */
|
||||
nextlayerid: integer;
|
||||
/** Auto-increments for each placed object */
|
||||
nextobjectid: integer;
|
||||
/** `orthogonal`, `isometric`, `staggered` or `hexagonal` */
|
||||
orientation: string;
|
||||
/** Array of {@link TiledProperty} */
|
||||
properties?: Array<TiledProperty>;
|
||||
/** `right-down` (the default), `right-up`, `left-down` or `left-up` (currently only supported for orthogonal maps) */
|
||||
renderorder: string;
|
||||
/** `x` or `y` (staggered / hexagonal maps only) */
|
||||
staggeraxis?: string;
|
||||
/** `odd` or `even` (staggered / hexagonal maps only) */
|
||||
staggerindex?: string;
|
||||
/** The Tiled version used to save the file */
|
||||
tiledversion: string;
|
||||
/** Map grid height */
|
||||
tileheight: integer;
|
||||
/** Array of {@link TiledTileset} */
|
||||
tilesets: Array<TiledTileset>;
|
||||
/** Map grid width */
|
||||
tilewidth: integer;
|
||||
/** `map` (since 1.0) */
|
||||
type: string;
|
||||
/** The JSON format version (previously a number, saved as string since 1.6) */
|
||||
version: string;
|
||||
/** Number of tile columns */
|
||||
width: integer;
|
||||
};
|
||||
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. */
|
||||
compression?: string;
|
||||
/** Array of `unsigned`, `integer` (GIDs) or base64-encoded data. `tilelayer` only.*/
|
||||
data?: Array<integer> | string;
|
||||
/** `topdown` (default) or `index`. `objectgroup` only. */
|
||||
draworder?: string;
|
||||
/** `csv` (default) or `base64`. `tilelayer` only. */
|
||||
encoding?: string;
|
||||
/** Row count. Same as map height for fixed-size maps. */
|
||||
height?: integer;
|
||||
/** Incremental ID - unique across all layers */
|
||||
id?: integer;
|
||||
/** Image used by this layer. `imagelayer` only. */
|
||||
image?: string;
|
||||
/** Array of {@link TiledLayer}. `group` only. */
|
||||
layers?: Array<TiledLayer>;
|
||||
/** Name assigned to this layer */
|
||||
name: string;
|
||||
/** Array of {@link TiledObject}. `objectgroup` only. */
|
||||
objects?: Array<TiledObject>;
|
||||
/** Horizontal layer offset in pixels (default: 0) */
|
||||
offsetx?: float;
|
||||
/** Vertical layer offset in pixels (default: 0) */
|
||||
offsety?: float;
|
||||
/** Value between 0 and 1 */
|
||||
opacity: float;
|
||||
/** Horizontal {@link parallax factor} for this layer (default: 1). (since Tiled 1.5) */
|
||||
parallaxx?: float;
|
||||
/** Vertical {@link parallax factor} for this layer (default: 1). (since Tiled 1.5) */
|
||||
parallaxy?: float;
|
||||
/** Array of {@link TiledProperty} */
|
||||
properties?: Array<TiledProperty>;
|
||||
/** X coordinate where layer content starts (for infinite maps) */
|
||||
startx?: integer;
|
||||
/** Y coordinate where layer content starts (for infinite maps) */
|
||||
starty?: integer;
|
||||
/** Hex-formatted {@link tint color} (#RRGGBB or #AARRGGBB) that is multiplied with any graphics drawn by this layer or any child layers (optional). */
|
||||
tintcolor?: string;
|
||||
/** Hex-formatted color (#RRGGBB) (optional). `imagelayer` only. */
|
||||
transparentcolor?: string;
|
||||
/** `tilelayer`, `objectgroup`, `imagelayer` or `group` */
|
||||
type: string;
|
||||
/** Whether layer is shown or hidden in editor */
|
||||
visible: boolean;
|
||||
/** Column count. Same as map width for fixed-size maps. */
|
||||
width?: integer;
|
||||
/** Horizontal layer offset in tiles. Always 0. */
|
||||
x: integer;
|
||||
/** Vertical layer offset in tiles. Always 0. */
|
||||
y: integer;
|
||||
};
|
||||
export declare type TiledChunk = {
|
||||
/** Array of `unsigned` `integer` (GIDs) or base64-encoded data */
|
||||
data: Array<integer> | string;
|
||||
/** Height in tiles */
|
||||
height: integer;
|
||||
/** Width in tiles */
|
||||
width: integer;
|
||||
/** X coordinate in tiles */
|
||||
x: integer;
|
||||
/** Y coordinate in tiles */
|
||||
y: integer;
|
||||
};
|
||||
export declare type TiledObject = {
|
||||
/** Used to mark an object as an ellipse */
|
||||
ellipse?: boolean;
|
||||
/** Global tile ID, only if object represents a tile */
|
||||
gid?: integer;
|
||||
/** Height in pixels. */
|
||||
height: float;
|
||||
/** Incremental ID, unique across all objects */
|
||||
id: integer;
|
||||
/** String assigned to name field in editor */
|
||||
name: string;
|
||||
/** Used to mark an object as a point */
|
||||
point?: boolean;
|
||||
/** Array of {@link TiledPoint}, in case the object is a polygon */
|
||||
polygon?: Array<TiledPoint>;
|
||||
/** Array of {@link TiledPoint}, in case the object is a polyline */
|
||||
polyline?: Array<TiledPoint>;
|
||||
/** Array of {@link TiledProperty} */
|
||||
properties?: Array<TiledProperty>;
|
||||
/** Angle in degrees clockwise */
|
||||
rotation: float;
|
||||
/** Reference to a template file, in case object is a {@link template instance} */
|
||||
template?: string;
|
||||
/** Only used for text objects */
|
||||
text?: Text;
|
||||
/** String assigned to type Tiledfield in editor */
|
||||
type: string;
|
||||
/** Whether object is shown in editor. */
|
||||
visible: boolean;
|
||||
/** Width in pixels. */
|
||||
width: float;
|
||||
/** X coordinate in pixels */
|
||||
x: float;
|
||||
/** Y coordinate in pixels */
|
||||
y: float;
|
||||
};
|
||||
export declare type TiledText = {
|
||||
/** Whether to use a bold font (default: `false`) */
|
||||
bold: boolean;
|
||||
/** Hex-formatted color (#RRGGBB or #AARRGGBB) (default: `#000000`) */
|
||||
color: string;
|
||||
/** Font family (default: `sans-serif`) */
|
||||
fontfamily: string;
|
||||
/** Horizontal alignment (`center`, `right`, `justify` or `left` (default)) */
|
||||
halign: string;
|
||||
/** Whether to use an italic font (default: `false`) */
|
||||
italic: boolean;
|
||||
/** Whether to use kerning when placing characters (default: `true`) */
|
||||
kerning: boolean;
|
||||
/** Pixel size of font (default: 16) */
|
||||
pixelsize: integer;
|
||||
/** Whether to strike out the text (default: `false`) */
|
||||
strikeout: boolean;
|
||||
/** Text */
|
||||
text: string;
|
||||
/** Whether to underline the text (default: `false`) */
|
||||
underline: boolean;
|
||||
/** Vertical alignment (`center`, `bottom` or `top` (default)) */
|
||||
valign: string;
|
||||
/** Whether the text is wrapped within the object bounds (default: `false`) */
|
||||
wrap: boolean;
|
||||
};
|
||||
export declare type TiledTileset = {
|
||||
/** Hex-formatted color (#RRGGBB or #AARRGGBB) (optional) */
|
||||
backgroundcolor?: string;
|
||||
/** The number of tile columns in the tileset */
|
||||
columns: integer;
|
||||
/** GID corresponding to the first tile in the set */
|
||||
firstgid: integer;
|
||||
/** (optional) */
|
||||
grid?: TiledGrid;
|
||||
/** Image used for tiles in this set */
|
||||
image: string;
|
||||
/** Height of source image in pixels */
|
||||
imageheight: integer;
|
||||
/** Width of source image in pixels */
|
||||
imagewidth: integer;
|
||||
/** Buffer between image edge and first tile (pixels) */
|
||||
margin: integer;
|
||||
/** Name given to this tileset */
|
||||
name: string;
|
||||
/** Alignment to use for tile objects (`unspecified` (default), `topleft`, `top`, `topright`, `left`, `center`, `right`, `bottomleft`, `bottom` or `bottomright`) (since 1.4) */
|
||||
objectalignment?: string;
|
||||
/** Array of {@link TiledProperty} */
|
||||
properties?: Array<TiledProperty>;
|
||||
/** The external file that contains this tilesets data */
|
||||
source?: string;
|
||||
/** Spacing between adjacent tiles in image (pixels) */
|
||||
spacing: integer;
|
||||
/** Array of {@link TiledTerrain} (optional) */
|
||||
terrains?: Array<TiledTerrain>;
|
||||
/** The number of tiles in this tileset */
|
||||
tilecount: integer;
|
||||
/** The Tiled version used to save the file */
|
||||
tiledversion: string;
|
||||
/** Maximum height of tiles in this set */
|
||||
tileheight: integer;
|
||||
/** (optional) */
|
||||
tileoffset?: TileOffset;
|
||||
/** Array of {@link TiledTileDefinition} (optional) */
|
||||
tiles?: Array<TiledTileDefinition>;
|
||||
/** Maximum width of tiles in this set */
|
||||
tilewidth: integer;
|
||||
/** Allowed transformations (optional) */
|
||||
transformations?: TiledTransformations;
|
||||
/** Hex-formatted color (#RRGGBB) (optional) */
|
||||
transparentcolor?: string;
|
||||
/** `tileset` (for tileset files, since 1.0) */
|
||||
type: string;
|
||||
/** The JSON format version (previously a number, saved as string since 1.6) */
|
||||
version: string;
|
||||
/** Array of {@link TiledWangSet} (since 1.1.5) */
|
||||
wangsets?: Array<TiledWangSet>;
|
||||
};
|
||||
export declare type TiledGrid = {
|
||||
/** Cell height of tile grid */
|
||||
height: integer;
|
||||
/** `orthogonal` (default) or `isometric` */
|
||||
orientation: string;
|
||||
/** Cell width of tile grid */
|
||||
width: integer;
|
||||
};
|
||||
export declare type TileOffset = {
|
||||
/** Horizontal offset in pixels */
|
||||
x: integer;
|
||||
/** Vertical offset in pixels (positive is down) */
|
||||
y: integer;
|
||||
};
|
||||
export declare type TiledTransformations = {
|
||||
/** Tiles can be flipped horizontally */
|
||||
hflip: boolean;
|
||||
/** Tiles can be flipped vertically */
|
||||
vflip: boolean;
|
||||
/** Tiles can be rotated in 90-degree increments */
|
||||
rotate: boolean;
|
||||
/** Whether untransformed tiles remain preferred, otherwise transformed tiles are used to produce more variations */
|
||||
preferuntransformed: boolean;
|
||||
};
|
||||
export declare type TiledTileDefinition = {
|
||||
/** Array of {@link TiledTiles} */
|
||||
animation?: Array<TiledTileDefinition>;
|
||||
/** Local ID of the tile */
|
||||
id: integer;
|
||||
/** Image representing this tile (optional) */
|
||||
image?: string;
|
||||
/** Height of the tile image in pixels */
|
||||
imageheight?: integer;
|
||||
/** Width of the tile image in pixels */
|
||||
imagewidth?: integer;
|
||||
/** Layer with type Tiled`objectgroup`, when collision shapes are specified (optional) */
|
||||
objectgroup?: TiledLayer;
|
||||
/** Percentage chance this tile is chosen when competing with others in the editor (optional) */
|
||||
probability?: float;
|
||||
/** Array of {@link TiledProperty} */
|
||||
properties?: Array<TiledProperty>;
|
||||
/** Index of terrain for each corner of tile (optional) */
|
||||
terrain?: Array<integer>;
|
||||
/** The type of the tile (optional) */
|
||||
type?: string;
|
||||
};
|
||||
export declare type TiledFrame = {
|
||||
/** Frame duration in milliseconds */
|
||||
duration: integer;
|
||||
/** Local tile ID representing this frame */
|
||||
tileid: integer;
|
||||
};
|
||||
export declare type TiledTerrain = {
|
||||
/** Name of terrain */
|
||||
name: string;
|
||||
/** Array of {@link TiledProperty} */
|
||||
properties: Array<TiledProperty>;
|
||||
/** Local ID of tile representing terrain */
|
||||
tile: integer;
|
||||
};
|
||||
export declare type TiledWangSet = {
|
||||
/** Array of {@link TiledWangColor} */
|
||||
colors: Array<TiledWangColor>;
|
||||
/** Name of the Wang set */
|
||||
name: string;
|
||||
/** Array of {@link TiledProperty} */
|
||||
properties: Array<TiledProperty>;
|
||||
/** Local ID of tile representing the Wang set */
|
||||
tile: integer;
|
||||
/** Array of {@link TiledWangTile} */
|
||||
wangtiles: Array<TiledWangTile>;
|
||||
};
|
||||
export declare type TiledWangColor = {
|
||||
/** Hex-formatted color (#RRGGBB or #AARRGGBB) */
|
||||
color: string;
|
||||
/** Name of the Wang color */
|
||||
name: string;
|
||||
/** Probability used when randomizing */
|
||||
probability: float;
|
||||
/** Array of {@link TiledProperty} */
|
||||
properties: Array<TiledProperty>;
|
||||
/** Local ID of tile representing the Wang color */
|
||||
tile: integer;
|
||||
};
|
||||
export declare type TiledWangTile = {
|
||||
/** Local ID of tile */
|
||||
tileid: integer;
|
||||
/** Array of Wang color indexes (`uchar[8]`) */
|
||||
wangid: Array<integer>;
|
||||
};
|
||||
export declare type TiledObjectTemplate = {
|
||||
/** `template` */
|
||||
type: string;
|
||||
/** External tileset used by the template (optional) */
|
||||
tileset?: TiledTileset;
|
||||
/** The object instantiated by this template */
|
||||
object: Object;
|
||||
};
|
||||
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)) */
|
||||
type: string;
|
||||
/** Value of the property */
|
||||
value: string | number;
|
||||
};
|
||||
export declare type TiledPoint = {
|
||||
/** X coordinate in pixels */
|
||||
x: float;
|
||||
/** Y coordinate in pixels */
|
||||
y: float;
|
||||
};
|
||||
//# sourceMappingURL=Tiled.d.ts.map
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"TiledLoaderHelper.d.ts","sourceRoot":"","sources":["../../src/tiled/TiledLoaderHelper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,SAAU,GAAG,SAAS,UAAU,aAgDjE,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,QAuBF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,aACtB,MAAM,GAAG,SAAS,KAC3B,MAAM,GAAG,SAAwD,CAAC"}
|
@@ -1,9 +0,0 @@
|
||||
import { EditableTileMap } from '../model/TileMapModel';
|
||||
import { TiledMap } from './TiledFormat';
|
||||
/**
|
||||
* It creates a {@link EditableTileMap} from a Tiled JSON.
|
||||
*/
|
||||
export declare class TiledTileMapLoader {
|
||||
static load(pako: any, tiledMap: TiledMap): EditableTileMap | null;
|
||||
}
|
||||
//# sourceMappingURL=TiledTileMapLoader.d.ts.map
|
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"TiledTileMapLoader.d.ts","sourceRoot":"","sources":["../../src/tiled/TiledTileMapLoader.ts"],"names":[],"mappings":"AACA,OAAO,EACL,eAAe,EAGhB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAOzC;;GAEG;AACH,qBAAa,kBAAkB;IAC7B,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ,GAAG,eAAe,GAAG,IAAI;CAyKnE"}
|
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"TiledTileMapLoader.spec.d.ts","sourceRoot":"","sources":["../../src/tiled/TiledTileMapLoader.spec.ts"],"names":[],"mappings":""}
|
12
Extensions/TileMap/helper/dts/types/index.d.ts
vendored
Normal file
12
Extensions/TileMap/helper/dts/types/index.d.ts
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
import { LDtkTileMap } from '../load/ldtk/LDtkFormat';
|
||||
import { TiledTileMap } from '../load/tiled/TiledFormat';
|
||||
export type TileMap =
|
||||
| {
|
||||
kind: 'tiled';
|
||||
data: TiledTileMap;
|
||||
}
|
||||
| {
|
||||
kind: 'ldtk';
|
||||
data: LDtkTileMap;
|
||||
};
|
||||
//# sourceMappingURL=index.d.ts.map
|
1
Extensions/TileMap/helper/dts/types/index.d.ts.map
Normal file
1
Extensions/TileMap/helper/dts/types/index.d.ts.map
Normal file
@@ -0,0 +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"}
|
@@ -121,7 +121,7 @@ describe('gdjs.TileMapCollisionMaskRuntimeObject', function () {
|
||||
// TODO find a clean way to wait for the json to be read.
|
||||
for (
|
||||
let index = 0;
|
||||
index < 200 && tileMap._collisionTileMap.getDimensionX() === 0;
|
||||
index < 30 && tileMap._collisionTileMap.getDimensionX() === 0;
|
||||
index++
|
||||
) {
|
||||
await delay(100);
|
||||
@@ -268,10 +268,10 @@ describe('gdjs.TileMapCollisionMaskRuntimeObject', function () {
|
||||
// TODO find a clean way to wait for the json to be read.
|
||||
for (
|
||||
let index = 0;
|
||||
index < 200 && tileMap._collisionTileMap.getDimensionX() === 0;
|
||||
index < 100 && tileMap._collisionTileMap.getDimensionX() === 0;
|
||||
index++
|
||||
) {
|
||||
await delay(5);
|
||||
await delay(50);
|
||||
}
|
||||
if (tileMap._collisionTileMap.getDimensionX() === 0) {
|
||||
throw new Error('Timeout reading the tile map JSON file.');
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user