Compare commits

..

26 Commits

Author SHA1 Message Date
Florian Rival
64cad25b81 Bump newIDE version (#4752) 2022-12-26 16:24:35 +01:00
Florian Rival
8472e30342 Show a warning about Piskel/Jfxr/Yarn not being available yet for cloud projects on desktop (#4751) 2022-12-26 16:23:29 +01:00
Clément Pasteau
1b7d258727 Remove mentions of "experimental" for features and tools widely used and supported (#4749) 2022-12-26 15:02:56 +01:00
github-actions[bot]
946b77093d Update translations [skip ci] (#4742)
Co-authored-by: 4ian <4ian@users.noreply.github.com>
2022-12-26 14:10:34 +01:00
Florian Rival
74c882f219 Fix wrong scrollbars in the Sprite editor 2022-12-26 12:50:40 +01:00
Florian Rival
abd417c494 Fix games crash because of some extensions not included in the generated games
Revert "Fix missing export files by including the free functions of every extension that is actually used (#4672)" (#4746) (commit 93121d1a1c)
2022-12-26 12:36:39 +01:00
Florian Rival
2005f9c37b Bump newIDE version 2022-12-24 11:30:25 +01:00
github-actions[bot]
b749ac1106 Update translations [skip ci] (#4736)
Co-authored-by: 4ian <4ian@users.noreply.github.com>
2022-12-24 11:21:40 +01:00
Baptiste Augrain
f34f901fa7 Add support for opacity of layers for Tiled tilemaps (#4739) 2022-12-24 11:21:03 +01:00
Florian Rival
c74110c058 Fix the storage provider default choice not being always the optimal one when running the tutorial 2022-12-23 23:29:44 +01:00
Baptiste Augrain
2a38be827c Add support for Tileset resources with .tsj extension (#4737) 2022-12-23 23:09:16 +01:00
D8H
7cd97e8cc4 Disable "missing shared data" error logs for custom objects. (#4735)
* Don't in changelog
2022-12-23 18:31:19 +01:00
github-actions[bot]
4c9445f6f5 Update translations [skip ci] (#4734)
Co-authored-by: 4ian <4ian@users.noreply.github.com>
2022-12-23 18:08:28 +01:00
Baptiste Augrain
b7772520b5 Add support for selecting directly .ldtk and .tmj files from the interface (#4733)
* Files saved from LDtk or from Tiled (using the .tmj format) can be now selected directly when choosing a Tilemap to be displayed by a Tilemap object.
2022-12-23 17:46:17 +01:00
D8H
93121d1a1c Fix missing export files by including the free functions of every extension that is actually used (#4672) 2022-12-23 17:33:52 +01:00
D8H
9f7c1a1748 Better display custom objects in the editor (#4643) 2022-12-23 17:21:47 +01:00
Florian Rival
f6fc2406a5 Fix missing menu items on web-app
Don't show in changelog
2022-12-23 15:32:37 +01:00
github-actions[bot]
daede19d0d Update translations [skip ci] (#4718)
Co-authored-by: 4ian <4ian@users.noreply.github.com>
2022-12-23 12:42:26 +01:00
Florian Rival
36e835c461 Don't enable player authentication if a tutorial is running when creating a new project
Don't show in changelog
2022-12-23 10:49:16 +01:00
Florian Rival
8d0b3ef53e Fix MarkdownText using a div instead of a span when not a standalone text
* Also add a missing translation
* Also enable player authentication by default when creating a new game
2022-12-23 10:13:58 +01:00
Florian Rival
7ccd2cd146 Update README with link to GDevelop-tutorials repository [skip ci]
* This is where the step-by-step onboarding is stored and future tutorials can be built by the community: https://github.com/GDevelopApp/GDevelop-tutorials

Only show in developer changelog
2022-12-22 22:59:40 +01:00
D8H
49974131d0 Improve installation of assets containing custom objects, like menu buttons, so that if an extension needs an update, a confirmation dialog is shown (#4724) 2022-12-22 19:27:54 +01:00
Baptiste Augrain
77320ce12e Add support for LDtk Tilemaps (#4575)
* Tilemaps made with [LDtk](https://ldtk.io/), a modern 2D level editor, can be now used directly. Make sure to save your map made in LDtk as a JSON file, create a new Tilemap object in GDevelop and in the Tilemap field, choose the LDtk file.
* Tilesets used by the LDtk Tilemap are automatically imported in your game - you don't need to import them separately.
* For more information, read about the [Tilemap object on the wiki](https://wiki.gdevelop.io/gdevelop5/objects/tilemap).

Co-authored-by: Davy Hélard <davy.helard@gmail.com>
Co-authored-by: Florian Rival <Florian.Rival@gmail.com>
2022-12-22 18:44:27 +01:00
Clément Pasteau
35833e6e23 Allow adding default player authentication when creating a project (#4714)
* New checkbox in the Project Creation dialog, which will apply best practices for player authentication on the empty project
2022-12-22 16:20:13 +01:00
AlexandreS
7436032787 Fix asset store preview (#4729)
Do not show in changelog
2022-12-22 15:48:15 +01:00
AlexandreS
aa4fd1bda9 Prefer scroll in homepage header rather than uncontrolled wrap (#4728)
Do not show in changelog
2022-12-22 11:46:04 +01:00
226 changed files with 5892 additions and 2078 deletions

View File

@@ -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" ||

View File

@@ -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"),

View File

@@ -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);
}
});

View File

@@ -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;

View File

@@ -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;

View File

@@ -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);
};

View File

@@ -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);
}

View File

@@ -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.
*/

View File

@@ -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"

View File

@@ -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

View File

@@ -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);
}

View File

@@ -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.
*

View File

@@ -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\"}}");
}
}

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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; };

View File

@@ -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

View File

@@ -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';

View File

@@ -622,10 +622,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) {

View File

@@ -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
@@ -645,8 +647,7 @@ module.exports = {
update() {
const instance = this._instance;
const properties = this._associatedObjectConfiguration
.getProperties();
const properties = this._associatedObjectConfiguration.getProperties();
const placeholder =
instance.getRawStringProperty('placeholder') ||

View File

@@ -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

View File

@@ -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.
*/

View File

@@ -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;
};

View File

@@ -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);
}
});
}

View File

@@ -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)!
)!;
}

View File

@@ -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

View File

@@ -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

View File

@@ -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"}

View 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

View File

@@ -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"}

View 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: &lt;`null`&gt;, `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: &lt;`null`&gt;, `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: &lt;`null`&gt;, `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: &lt;`null`&gt;, `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

View 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

View File

@@ -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,CA6IxB;CACF"}

View File

@@ -0,0 +1,5 @@
export declare function getLDtkTileId(
tileSetId: number,
tileId: number
): number;
//# sourceMappingURL=LDtkTileMapLoaderHelper.d.ts.map

View File

@@ -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"}

View File

@@ -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

View 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

View File

@@ -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"}

View File

@@ -0,0 +1 @@
{"version":3,"file":"TiledTileMapLoader.spec.d.ts","sourceRoot":"","sources":["../../../src/load/tiled/TiledTileMapLoader.spec.ts"],"names":[],"mappings":""}

View File

@@ -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

View File

@@ -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"}

View File

@@ -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

View File

@@ -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"}

View 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

View 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"}

View File

@@ -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

View File

@@ -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;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,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"}

View File

@@ -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;
}

View File

@@ -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"}

View File

@@ -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,

View File

@@ -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"}

View File

@@ -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

View File

@@ -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"}

View 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

View File

@@ -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"}

View 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

View File

@@ -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"}

View File

@@ -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

View File

@@ -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"}

View File

@@ -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

View File

@@ -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"}

View File

@@ -1 +0,0 @@
{"version":3,"file":"TiledTileMapLoader.spec.d.ts","sourceRoot":"","sources":["../../src/tiled/TiledTileMapLoader.spec.ts"],"names":[],"mappings":""}

View 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

View 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"}

View File

@@ -154,6 +154,7 @@ namespace gdjs {
this._tileMapManager.getOrLoadTileMap(
this._tilemapJsonFile,
this._tilesetJsonFile,
0, // levelIndex
(tileMap: TileMapHelper.EditableTileMap | null) => {
if (!tileMap) {
// getOrLoadTileMap already log errors.

View File

@@ -13,6 +13,7 @@ namespace gdjs {
_tilemapAtlasImage: string;
_displayMode: string;
_layerIndex: integer;
_levelIndex: integer;
_animationSpeedScale: number;
_animationFps: number;
_tileMapManager: gdjs.TileMap.TileMapRuntimeManager;
@@ -26,6 +27,7 @@ namespace gdjs {
this._tilemapAtlasImage = objectData.content.tilemapAtlasImage;
this._displayMode = objectData.content.displayMode;
this._layerIndex = objectData.content.layerIndex;
this._levelIndex = objectData.content.levelIndex;
this._animationSpeedScale = objectData.content.animationSpeedScale;
this._animationFps = objectData.content.animationFps;
this._tileMapManager = gdjs.TileMap.TileMapRuntimeManager.getManager(
@@ -83,6 +85,11 @@ namespace gdjs {
) {
this.setLayerIndex(newObjectData.content.layerIndex);
}
if (
oldObjectData.content.levelIndex !== newObjectData.content.levelIndex
) {
this.setLevelIndex(newObjectData.content.levelIndex);
}
if (
oldObjectData.content.animationSpeedScale !==
newObjectData.content.animationSpeedScale
@@ -116,22 +123,29 @@ namespace gdjs {
this._tileMapManager.getOrLoadTileMap(
this._tilemapJsonFile,
this._tilesetJsonFile,
this._levelIndex,
(tileMap: TileMapHelper.EditableTileMap | null) => {
if (!tileMap) {
// getOrLoadTileMap already warn.
return;
}
this._tileMapManager.getOrLoadTextureCache(
(textureName) =>
(this.getInstanceContainer()
.getGame()
(textureName) => {
const game = this.getInstanceContainer().getGame();
const mappedName = game.resolveEmbeddedResource(
this._tilemapJsonFile,
textureName
);
return (game
.getImageManager()
.getPIXITexture(textureName) as unknown) as PIXI.BaseTexture<
.getPIXITexture(mappedName) as unknown) as PIXI.BaseTexture<
PIXI.Resource
>,
>;
},
this._tilemapAtlasImage,
this._tilemapJsonFile,
this._tilesetJsonFile,
this._levelIndex,
(textureCache: TileMapHelper.TileTextureCache | null) => {
if (!textureCache) {
// getOrLoadTextureCache already log warns and errors.
@@ -145,7 +159,7 @@ namespace gdjs {
}
/**
* Set the Tilemap json file to display.
* Set the Tilemap file to display.
*/
setTilemapJsonFile(tilemapJsonFile: string): void {
this._tilemapJsonFile = tilemapJsonFile;
@@ -203,6 +217,15 @@ namespace gdjs {
return this._layerIndex;
}
setLevelIndex(levelIndex): void {
this._levelIndex = levelIndex;
this._updateTileMap();
}
getLevelIndex() {
return this._levelIndex;
}
setAnimationSpeedScale(animationSpeedScale): void {
this._animationSpeedScale = animationSpeedScale;
}

View File

@@ -37,7 +37,8 @@ void TiledSpriteObject::DoSerializeTo(gd::SerializerElement& element) const {
element.SetAttribute("height", height);
}
void TiledSpriteObject::ExposeResources(gd::ArbitraryResourceWorker& worker) {
void TiledSpriteObject::ExposeResources(
gd::ArbitraryResourceWorker& worker) {
worker.ExposeImage(textureName);
}
#endif

View File

@@ -26,9 +26,7 @@ class GD_EXTENSION_API TiledSpriteObject : public gd::ObjectConfiguration {
return gd::make_unique<TiledSpriteObject>(*this);
}
#if defined(GD_IDE_ONLY)
virtual void ExposeResources(gd::ArbitraryResourceWorker &worker);
#endif
virtual double GetWidth() const { return width; };
virtual double GetHeight() const { return height; };

View File

@@ -272,12 +272,7 @@ namespace gdjs {
* @returns The shared data for the behavior, if any.
*/
getInitialSharedDataForBehavior(name: string): BehaviorSharedData | null {
const behaviorSharedData = this._initialBehaviorSharedData.get(name);
if (behaviorSharedData) {
return behaviorSharedData;
}
logger.error("Can't find shared data for behavior with name: " + name);
return null;
return this._initialBehaviorSharedData.get(name);
}
/**

View File

@@ -76,7 +76,12 @@ namespace gdjs {
): void {
const resources = this._resources;
const jsonResources = resources.filter(function (resource) {
return resource.kind === 'json' && !resource.disablePreload;
return (
(resource.kind === 'json' ||
resource.kind === 'tilemap' ||
resource.kind === 'tileset') &&
!resource.disablePreload
);
});
if (jsonResources.length === 0) {
return onComplete(jsonResources.length);
@@ -109,7 +114,12 @@ namespace gdjs {
*/
loadJson(resourceName: string, callback: JsonManagerRequestCallback): void {
const resource = this._resources.find(function (resource) {
return resource.kind === 'json' && resource.name === resourceName;
return (
(resource.kind === 'json' ||
resource.kind === 'tilemap' ||
resource.kind === 'tileset') &&
resource.name === resourceName
);
});
if (!resource) {
callback(

View File

@@ -90,6 +90,9 @@ namespace gdjs {
_injectExternalLayout: any;
_options: RuntimeGameOptions;
//The mappings for embedded resources
_embeddedResourcesMappings: Map<string, Record<string, string>>;
/**
* Optional client to connect to a debugger server.
*/
@@ -143,6 +146,25 @@ namespace gdjs {
this._sessionId = null;
this._playerId = null;
this._embeddedResourcesMappings = new Map();
for (const resource of this._data.resources.resources) {
if (resource.metadata) {
try {
const metadata = JSON.parse(resource.metadata);
if (metadata?.embeddedResourcesMapping) {
this._embeddedResourcesMappings.set(
resource.name,
metadata.embeddedResourcesMapping
);
}
} catch {
logger.error(
'Some metadata of resources can not be succesfully parsed.'
);
}
}
}
this._eventsBasedObjectDatas = new Map<String, EventsBasedObjectData>();
if (this._data.eventsFunctionsExtensions) {
for (const extension of this._data.eventsFunctionsExtensions) {
@@ -953,5 +975,21 @@ namespace gdjs {
}
return null;
}
/**
* Resolves the name of an embedded resource.
* @param mainResourceName The name of the resource containing the embedded resource.
* @param embeddedResourceName The name of the embedded resource.
* @return The resource name.
*/
resolveEmbeddedResource(
mainResourceName: string,
embeddedResourceName: string
): string {
const mapping = this._embeddedResourcesMappings.get(mainResourceName);
return mapping && mapping[embeddedResourceName]
? mapping[embeddedResourceName]
: embeddedResourceName;
}
}
}

View File

@@ -183,6 +183,16 @@ namespace gdjs {
this._timeManager.reset();
}
getInitialSharedDataForBehavior(name: string): BehaviorSharedData | null {
// TODO Move this error in RuntimeInstanceContainer after deciding
// what to do with shared data in custom object.
const behaviorSharedData = super.getInitialSharedDataForBehavior(name);
if (!behaviorSharedData) {
logger.error("Can't find shared data for behavior with name: " + name);
}
return behaviorSharedData;
}
addLayer(layerData: LayerData) {
this._layers.put(
layerData.name,

View File

@@ -240,4 +240,6 @@ declare type ResourceKind =
| 'font'
| 'video'
| 'json'
| 'tilemap'
| 'tileset'
| 'bitmapFont';

View File

@@ -976,6 +976,16 @@ interface JsonResource {
};
JsonResource implements Resource;
interface TilemapResource {
void TilemapResource();
};
TilemapResource implements Resource;
interface TilesetResource {
void TilesetResource();
};
TilesetResource implements Resource;
interface InitialInstance {
void InitialInstance();

View File

@@ -163,8 +163,7 @@ void ObjectJsImplementation::__destroy__() { // Useless?
(int)this);
}
void ObjectJsImplementation::ExposeResources(
gd::ArbitraryResourceWorker& worker) {
void ObjectJsImplementation::ExposeResources(gd::ArbitraryResourceWorker& worker) {
std::map<gd::String, gd::PropertyDescriptor> properties = GetProperties();
for (auto& property : properties) {
@@ -186,6 +185,12 @@ void ObjectJsImplementation::ExposeResources(
worker.ExposeVideo(newPropertyValue);
} else if (resourceType == "json") {
worker.ExposeJson(newPropertyValue);
worker.ExposeEmbeddeds(newPropertyValue);
} else if (resourceType == "tilemap") {
worker.ExposeTilemap(newPropertyValue);
worker.ExposeEmbeddeds(newPropertyValue);
} else if (resourceType == "tileset") {
worker.ExposeTileset(newPropertyValue);
} else if (resourceType == "bitmapFont") {
worker.ExposeBitmapFont(newPropertyValue);
}

View File

@@ -327,13 +327,13 @@ type ParticleEmitterObject_RendererType = 0 | 1 | 2`
shell.sed(
'-i',
/setKind\(kind: string\): void/,
"setKind(kind: 'image' | 'audio' | 'font' | 'video' | 'json'): void",
"setKind(kind: 'image' | 'audio' | 'font' | 'video' | 'json' | 'tilemap' | 'tileset'): void",
'types/gdresource.js'
);
shell.sed(
'-i',
/getKind\(\): string/,
"getKind(): 'image' | 'audio' | 'font' | 'video' | 'json'",
"getKind(): 'image' | 'audio' | 'font' | 'video' | 'json' | 'tilemap' | 'tileset'",
'types/gdresource.js'
);

View File

@@ -4,8 +4,8 @@ declare class gdResource {
clone(): gdResource;
setName(name: string): void;
getName(): string;
setKind(kind: 'image' | 'audio' | 'font' | 'video' | 'json'): void;
getKind(): 'image' | 'audio' | 'font' | 'video' | 'json';
setKind(kind: 'image' | 'audio' | 'font' | 'video' | 'json' | 'tilemap' | 'tileset'): void;
getKind(): 'image' | 'audio' | 'font' | 'video' | 'json' | 'tilemap' | 'tileset';
isUserAdded(): boolean;
setUserAdded(yes: boolean): void;
useFile(): boolean;

View File

@@ -0,0 +1,6 @@
// Automatically generated by GDevelop.js/scripts/generate-types.js
declare class gdTilemapResource extends gdResource {
constructor(): void;
delete(): void;
ptr: number;
};

View File

@@ -0,0 +1,6 @@
// Automatically generated by GDevelop.js/scripts/generate-types.js
declare class gdTilesetResource extends gdResource {
constructor(): void;
delete(): void;
ptr: number;
};

View File

@@ -98,6 +98,8 @@ declare class libGDevelop {
BitmapFontResource: Class<gdBitmapFontResource>;
VideoResource: Class<gdVideoResource>;
JsonResource: Class<gdJsonResource>;
TilemapResource: Class<gdTilemapResource>;
TilesetResource: Class<gdTilesetResource>;
InitialInstance: Class<gdInitialInstance>;
InitialInstancesContainer: Class<gdInitialInstancesContainer>;
HighestZOrderFinder: Class<gdHighestZOrderFinder>;

View File

@@ -1,29 +1,29 @@
![GDevelop logo](https://raw.githubusercontent.com/4ian/GDevelop/master/newIDE/GDevelop%20banner.png "GDevelop logo")
![GDevelop logo](https://raw.githubusercontent.com/4ian/GDevelop/master/newIDE/GDevelop%20banner.png 'GDevelop logo')
GDevelop is a full-featured, no-code, open-source game development software. You can build games for mobile, desktop and the web. GDevelop is fast and easy to use: the game logic is built up using an intuitive and powerful event-based system.
![The GDevelop editor when editing a game level](https://raw.githubusercontent.com/4ian/GDevelop/master/newIDE/GDevelop%20screenshot.png "The GDevelop editor when editing a game level")
![The GDevelop editor when editing a game level](https://raw.githubusercontent.com/4ian/GDevelop/master/newIDE/GDevelop%20screenshot.png 'The GDevelop editor when editing a game level')
## Getting started
| ❔ I want to... | 🚀 What to do |
| ------------------------------- | ------------------------------------------------------------------------------ |
| Download GDevelop to make games | Go to [GDevelop website](https://gdevelop.io) to download the app! |
| Contribute to the editor | Download [Node.js] and follow this [README](newIDE/README.md). |
| Create/improve an extension | Download [Node.js] and follow this [README](newIDE/README-extensions.md). |
| Help to translate GDevelop | Go on the [GDevelop project on Crowdin](https://crowdin.com/project/gdevelop). |
| ❔ I want to... | 🚀 What to do |
| ------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Download GDevelop to make games | Go to [GDevelop website](https://gdevelop.io) to download the app! |
| Contribute to the editor | Download [Node.js] and follow this [README](newIDE/README.md). |
| Create/improve an extension | Download [Node.js] and follow this [README](newIDE/README-extensions.md). |
| Help to translate GDevelop | Go on the [GDevelop project on Crowdin](https://crowdin.com/project/gdevelop) or translate [in-app tutorials](https://github.com/GDevelopApp/GDevelop-tutorials). |
> Are you interested in contributing to GDevelop for the first time? Take a look at the list of **[good first issues](https://github.com/4ian/GDevelop/issues?q=is%3Aissue+is%3Aopen+label%3A%22%F0%9F%91%8Cgood+first+issue%22)**, **[good first contributions](https://github.com/4ian/GDevelop/discussions/categories/good-first-contribution)** or the **["🏐 not too hard" cards](https://trello.com/b/qf0lM7k8/gdevelop-roadmap?menu=filter&filter=label:Not%20too%20hard%20%E2%9A%BD%EF%B8%8F)** on the Roadmap.
## Overview of the architecture
| Directory | Description |
| ------------- | ----------------------------------------------------------------------------------------------------- |
| `Core` | GDevelop core library, containing common tools to implement the IDE and work with GDevelop games. |
| `GDJS` | The game engine, written in TypeScript, using PixiJS (WebGL), powering all GDevelop games. |
| `GDevelop.js` | Bindings of `Core`, `GDJS` and `Extensions` to JavaScript (with WebAssembly), used by the IDE. |
| `newIDE` | The game editor, written in JavaScript with React, Electron and PixiJS. |
| `Extensions` | Extensions for the game engine, providing objects, behaviors, events and new features. |
| Directory | Description |
| ------------- | ------------------------------------------------------------------------------------------------- |
| `Core` | GDevelop core library, containing common tools to implement the IDE and work with GDevelop games. |
| `GDJS` | The game engine, written in TypeScript, using PixiJS (WebGL), powering all GDevelop games. |
| `GDevelop.js` | Bindings of `Core`, `GDJS` and `Extensions` to JavaScript (with WebAssembly), used by the IDE. |
| `newIDE` | The game editor, written in JavaScript with React, Electron and PixiJS. |
| `Extensions` | Extensions for the game engine, providing objects, behaviors, events and new features. |
To learn more about GDevelop Architecture, read the [architecture overview here](Core/GDevelop-Architecture-Overview.md).
@@ -35,29 +35,29 @@ Status of the tests and builds: [![macOS and Linux build status](https://circlec
### Community
- [GDevelop forums](https://forum.gdevelop.io) and [Discord chat](https://discord.gg/gdevelop).
- [GDevelop homepage](https://gdevelop.io)
- [GDevelop wiki (documentation)](https://wiki.gdevelop.io/gdevelop5/start)
- Help translate GDevelop in your language: [GDevelop project on Crowdin](https://crowdin.com/project/gdevelop).
- [GDevelop forums](https://forum.gdevelop.io) and [Discord chat](https://discord.gg/gdevelop).
- [GDevelop homepage](https://gdevelop.io)
- [GDevelop wiki (documentation)](https://wiki.gdevelop.io/gdevelop5/start)
- Help translate GDevelop in your language: [GDevelop project on Crowdin](https://crowdin.com/project/gdevelop).
### Development Roadmap
- [GDevelop Roadmap on Trello.com](https://trello.com/b/qf0lM7k8/gdevelop-roadmap), for a global view of the features that could be added. Please vote and comment here for new features/requests.
- [GitHub issue page](https://github.com/4ian/GDevelop/issues), for technical issues and bugs.
- [Github discussions](https://github.com/4ian/GDevelop/discussions) to talk about new features and ideas.
- [GDevelop Roadmap on Trello.com](https://trello.com/b/qf0lM7k8/gdevelop-roadmap), for a global view of the features that could be added. Please vote and comment here for new features/requests.
- [GitHub issue page](https://github.com/4ian/GDevelop/issues), for technical issues and bugs.
- [Github discussions](https://github.com/4ian/GDevelop/discussions) to talk about new features and ideas.
### Games made with GDevelop
- See the [showcase of games](https://gdevelop.io/games) created with GDevelop.
- Find more GDevelop games on [Liluo.io](https://liluo.io).
- Suggest your game to be [added to the showcase here](https://docs.google.com/forms/d/e/1FAIpQLSfjiOnkbODuPifSGuzxYY61vB5kyMWdTZSSqkJsv3H6ePRTQA/viewform).
- See the [showcase of games](https://gdevelop.io/games) created with GDevelop.
- Find more GDevelop games on [Liluo.io](https://liluo.io).
- Suggest your game to be [added to the showcase here](https://docs.google.com/forms/d/e/1FAIpQLSfjiOnkbODuPifSGuzxYY61vB5kyMWdTZSSqkJsv3H6ePRTQA/viewform).
![Some games made with GDevelop](https://raw.githubusercontent.com/4ian/GDevelop/master/newIDE/GDevelop%20games.png "Some games made with GDevelop")
![Some games made with GDevelop](https://raw.githubusercontent.com/4ian/GDevelop/master/newIDE/GDevelop%20games.png 'Some games made with GDevelop')
## License
- The Core library, the native and HTML5 game engines, the IDE, and all extensions (respectively `Core`, `GDJS`, `newIDE` and `Extensions` folders) are under the **MIT license**.
- The name, GDevelop, and its logo are the exclusive property of Florian Rival.
- The Core library, the native and HTML5 game engines, the IDE, and all extensions (respectively `Core`, `GDJS`, `newIDE` and `Extensions` folders) are under the **MIT license**.
- The name, GDevelop, and its logo are the exclusive property of Florian Rival.
Games exported with GDevelop are based on the GDevelop game engine (see `Core` and `GDJS` folders): this engine is distributed under the MIT license so that you can **distribute, sell or do anything** with the games you created with GDevelop. In particular, you are not forced to make your game open-source.

View File

@@ -9,34 +9,35 @@ module.exports = function (config) {
},
},
files: [
{ pattern: "node_modules/expect.js/index.js" },
{ pattern: "./src/tiled/**/*.ts" },
{ pattern: "./src/model/**/*.ts" }
{ pattern: "node_modules/expect.js/index.js" },
{ pattern: "./src/load/**/*.ts" },
{ pattern: "./src/model/*.ts" },
{ pattern: "./src/types/*.ts" },
],
preprocessors: {
"**/*.ts": 'karma-typescript'
},
preprocessors: {
"**/*.ts": 'karma-typescript',
},
reporters: ['dots', 'karma-typescript'],
singleRun: true,
karmaTypescriptConfig: {
compilerOptions: {
module: "commonjs",
noImplicitAny: true,
outDir: "tmp",
target: "ES5",
sourceMap: true,
types : [
"mocha",
"expect.js",
"offscreencanvas"
],
lib: ["DOM", "ES5", "ES6"],
"esModuleInterop": false,
"downlevelIteration": true,
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
},
exclude: ["node_modules"]
}
karmaTypescriptConfig: {
compilerOptions: {
module: "commonjs",
noImplicitAny: true,
outDir: "tmp",
target: "ES5",
sourceMap: true,
types : [
"mocha",
"expect.js",
"offscreencanvas"
],
lib: ["DOM", "ES5", "ES6"],
"esModuleInterop": false,
"downlevelIteration": true,
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
},
exclude: ["node_modules"],
},
});
};

View File

@@ -28,7 +28,7 @@
},
"devDependencies": {
"@rollup/plugin-node-resolve": "^13.1.3",
"@rollup/plugin-typescript": "^8.3.3",
"@rollup/plugin-typescript": "8.3.3",
"@types/expect.js": "^0.3.29",
"@types/mocha": "^5.2.7",
"expect.js": "^0.3.1",
@@ -56,4 +56,4 @@
"url": ""
},
"homepage": ""
}
}

View File

@@ -12,11 +12,13 @@ export default [
format: 'umd',
file: '../../Extensions/TileMap/helper/TileMapHelper.js',
sourcemap: true,
plugins: [terser({
format: {
comments: false
},
})]
plugins: [
terser({
format: {
comments: false
},
})
]
},
],
external: ['pixi.js'],

View File

@@ -3,26 +3,16 @@
* @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";

View File

@@ -0,0 +1,33 @@
import type { EditableTileMap } from "../model/TileMapModel";
import { TileMap } from "../types";
import { LDtkTileMapLoader } from "./ldtk/LDtkTileMapLoader";
import { TiledTileMapLoader } from "./tiled/TiledTileMapLoader";
export 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}
*/
export function load(
tileMap: TileMap,
levelIndex: number,
pako: any
): EditableTileMap | null {
if (tileMap.kind === "ldtk") {
return LDtkTileMapLoader.load(tileMap.data, levelIndex);
}
if (tileMap.kind === "tiled") {
return TiledTileMapLoader.load(tileMap.data, pako);
}
console.warn(
"The loaded Tile Map data does not contain a 'tiledversion' or '__header__' key. Are you sure this file has been exported from Tiled (mapeditor.org) or LDtk (ldtk.io)?"
);
return null;
}
}

View File

@@ -0,0 +1,611 @@
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: &lt;`null`&gt;, `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: &lt;`null`&gt;, `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: &lt;`null`&gt;, `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: &lt;`null`&gt;, `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 = {};

View File

@@ -0,0 +1,160 @@
import { integer } from "../../model/CommonTypes";
import { EditableTileMap, TileDefinition } from "../../model/TileMapModel";
import { getLDtkTileId } from "./LDtkTileMapLoaderHelper";
import { LDtkTileMap } from "./LDtkFormat";
import { getTileGID } from "../../model/GID";
export namespace LDtkTileMapLoader {
/**
* 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}
*/
export function load(
ldtkTileMap: LDtkTileMap,
levelIndex: number
): EditableTileMap | null {
const ldtkLevel = ldtkTileMap.levels[levelIndex > -1 ? levelIndex : 0];
if (!ldtkLevel || !ldtkLevel.layerInstances) {
return null;
}
const tileSet = new Map<integer, TileDefinition>();
let gridSize = 0;
let dimX = 0;
let dimY = 0;
for (
let iLayer = ldtkLevel.layerInstances.length - 1;
iLayer >= 0;
--iLayer
) {
const layer = ldtkLevel.layerInstances[iLayer];
const tilesetId = layer.__tilesetDefUid;
const tileCache: Record<number, boolean> = {};
for (const tile of [...layer.autoLayerTiles, ...layer.gridTiles]) {
if (tileCache[tile.t]) {
continue;
}
const tileId = getLDtkTileId(tilesetId, tile.t);
if (tileSet.has(tileId)) {
tileCache[tile.t] = true;
continue;
}
const tileDef = new TileDefinition(0);
tileCache[tile.t] = true;
tileSet.set(tileId, tileDef);
}
if (gridSize === 0 && layer.__type === "IntGrid") {
gridSize = layer.__gridSize;
dimX = layer.__cWid;
dimY = layer.__cHei;
}
}
const editableTileMap = new EditableTileMap(
gridSize,
gridSize,
dimX,
dimY,
tileSet
);
const composedTileMap = new Map<string, TileDefinition>();
let nextComposedTileId = 0xfffffff;
for (
let iLayer = ldtkLevel.layerInstances.length - 1;
iLayer >= 0;
--iLayer
) {
const layer = ldtkLevel.layerInstances[iLayer];
const gridSize = layer.__gridSize;
const tilesetId = layer.__tilesetDefUid;
const editableTileLayer = editableTileMap.addTileLayer(iLayer);
editableTileLayer.setAlpha(layer.__opacity);
editableTileLayer.setVisible(layer.visible);
for (const tile of [...layer.autoLayerTiles, ...layer.gridTiles]) {
const x = Math.floor(tile.px[0] / gridSize);
const y = Math.floor(tile.px[1] / gridSize);
const tileId = getLDtkTileId(tilesetId, tile.t);
const oldTileId = editableTileLayer.getTileId(x, y);
if (oldTileId === undefined) {
editableTileLayer.setTile(x, y, tileId);
editableTileLayer.setFlippedHorizontally(
x,
y,
tile.f === 1 || tile.f === 3
);
editableTileLayer.setFlippedVertically(
x,
y,
tile.f === 2 || tile.f === 3
);
} else {
const tileGID = getTileGID(
tileId,
tile.f === 1 || tile.f === 3,
tile.f === 2 || tile.f === 3,
false
);
const oldTileDef = tileSet.get(oldTileId);
if (oldTileDef?.hasStackedTiles()) {
const hash = `${oldTileDef
.getStackedTiles()
.map((tileId) => `${tileId}`)
.join(";")};${tileGID}`;
const tileDef = composedTileMap.get(hash);
if (tileDef) {
editableTileLayer.setTile(x, y, tileDef.getStackTileId());
} else {
const tileDef = new TileDefinition(0);
tileDef.setStackedTiles(
nextComposedTileId,
...oldTileDef.getStackedTiles(),
tileGID
);
tileSet.set(nextComposedTileId, tileDef);
nextComposedTileId -= 1;
composedTileMap.set(hash, tileDef);
editableTileLayer.setTile(x, y, tileDef.getStackTileId());
}
} else {
const oldTileGID = editableTileLayer.getTileGID(x, y)!;
const hash = `${oldTileGID};${tileGID}`;
const tileDef = new TileDefinition(0);
tileDef.setStackedTiles(nextComposedTileId, oldTileGID, tileGID);
tileSet.set(nextComposedTileId, tileDef);
nextComposedTileId -= 1;
composedTileMap.set(hash, tileDef);
editableTileLayer.setTile(x, y, tileDef.getStackTileId());
}
}
}
}
if (ldtkLevel.bgRelPath) {
void editableTileMap.setBackgroundResourceName(ldtkLevel.bgRelPath);
}
return editableTileMap;
}
}

View File

@@ -0,0 +1,9 @@
export function getLDtkTileId(tileSetId: number, tileId: number): number {
// Crude bit shifting (for speed)
let uniqueId = tileSetId << 16;
uniqueId += tileId;
return uniqueId;
// Cantor Pairing
// return (0.5 * (tileSetId + tileId) * (tileSetId + tileId + 1)) + tileId;
}

View File

@@ -1,9 +1,9 @@
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 type TiledMap = {
export type TiledTileMap = {
/** Hex-formatted color (#RRGGBB or #AARRGGBB) (optional) */
backgroundcolor?: string;

View File

@@ -1,11 +1,14 @@
import { EditableTileMap, EditableTileMapLayer } from "../model/TileMapModel";
import { TiledMap } from "./TiledFormat";
import {
EditableTileMap,
EditableTileMapLayer,
} from "../../model/TileMapModel";
import { TiledTileMap } from "./TiledFormat";
import { TiledTileMapLoader } from "./TiledTileMapLoader";
describe("TiledTileMapLoader", function () {
describe("without a collision mask", function () {
// Built from an actual json file exported by Tiled.
const tiledMap: TiledMap = {
const tiledMap: TiledTileMap = {
compressionlevel: -1,
height: 2,
infinite: false,
@@ -53,7 +56,7 @@ describe("TiledTileMapLoader", function () {
width: 4,
};
const tileMap: EditableTileMap = TiledTileMapLoader.load(null, tiledMap);
const tileMap: EditableTileMap = TiledTileMapLoader.load(tiledMap, null);
it("can load map dimensions", function () {
expect(tileMap.getDimensionX()).to.be(4);
@@ -80,21 +83,21 @@ describe("TiledTileMapLoader", function () {
expect(layer.id).to.be(1);
expect(layer.isVisible()).to.be(true);
expect(layer.get(0, 0)).to.be(0);
expect(layer.get(1, 0)).to.be(undefined);
expect(layer.get(2, 0)).to.be(1);
expect(layer.get(3, 0)).to.be(undefined);
expect(layer.getTileId(0, 0)).to.be(0);
expect(layer.getTileId(1, 0)).to.be(undefined);
expect(layer.getTileId(2, 0)).to.be(1);
expect(layer.getTileId(3, 0)).to.be(undefined);
expect(layer.get(0, 1)).to.be(undefined);
expect(layer.get(1, 1)).to.be(0);
expect(layer.get(2, 1)).to.be(undefined);
expect(layer.get(3, 1)).to.be(1);
expect(layer.getTileId(0, 1)).to.be(undefined);
expect(layer.getTileId(1, 1)).to.be(0);
expect(layer.getTileId(2, 1)).to.be(undefined);
expect(layer.getTileId(3, 1)).to.be(1);
});
});
describe("with a collision mask", function () {
// Built from an actual json file exported by Tiled.
const tiledMap: TiledMap = {
const tiledMap: TiledTileMap = {
compressionlevel: -1,
height: 2,
infinite: false,
@@ -377,7 +380,7 @@ describe("TiledTileMapLoader", function () {
width: 4,
};
const tileMap: EditableTileMap = TiledTileMapLoader.load(null, tiledMap);
const tileMap: EditableTileMap = TiledTileMapLoader.load(tiledMap, null);
it("can load map dimensions", function () {
expect(tileMap.getDimensionX()).to.be(4);
@@ -391,8 +394,8 @@ describe("TiledTileMapLoader", function () {
it("can load a tile set with a rectangle collision mask", function () {
const tileDefinition = tileMap.getTileDefinition(0);
expect(tileDefinition).to.be.ok();
expect(tileDefinition.hasTag("obstacle")).to.be(true);
expect(tileDefinition.hasTag("lava")).to.be(false);
expect(tileDefinition.hasTaggedHitBox("obstacle")).to.be(true);
expect(tileDefinition.hasTaggedHitBox("lava")).to.be(false);
expect(tileDefinition.getHitBoxes("obstacle")).to.be.eql([
[
[0, 0],
@@ -406,16 +409,16 @@ describe("TiledTileMapLoader", function () {
it("can load a tile set with an empty collision mask", function () {
const tileDefinition = tileMap.getTileDefinition(1);
expect(tileDefinition).to.be.ok();
expect(tileDefinition.hasTag("obstacle")).to.be(false);
expect(tileDefinition.hasTag("lava")).to.be(false);
expect(tileDefinition.hasTaggedHitBox("obstacle")).to.be(false);
expect(tileDefinition.hasTaggedHitBox("lava")).to.be(false);
});
it("can load a tile set with a polygon collision mask", function () {
{
const tileDefinition = tileMap.getTileDefinition(2);
expect(tileDefinition).to.be.ok();
expect(tileDefinition.hasTag("obstacle")).to.be(true);
expect(tileDefinition.hasTag("lava")).to.be(false);
expect(tileDefinition.hasTaggedHitBox("obstacle")).to.be(true);
expect(tileDefinition.hasTaggedHitBox("lava")).to.be(false);
expect(tileDefinition.getHitBoxes("obstacle")).to.be.eql([
[
[0, 8],
@@ -429,8 +432,8 @@ describe("TiledTileMapLoader", function () {
it("can load a tile set with a 2 polygons collision mask", function () {
const tileDefinition = tileMap.getTileDefinition(3);
expect(tileDefinition).to.be.ok();
expect(tileDefinition.hasTag("obstacle")).to.be(true);
expect(tileDefinition.hasTag("lava")).to.be(false);
expect(tileDefinition.hasTaggedHitBox("obstacle")).to.be(true);
expect(tileDefinition.hasTaggedHitBox("lava")).to.be(false);
expect(tileDefinition.getHitBoxes("obstacle")).to.be.eql([
[
[0, 0],
@@ -448,8 +451,8 @@ describe("TiledTileMapLoader", function () {
it("can load a tile set with several collision mask filter tags", function () {
const tileDefinition = tileMap.getTileDefinition(4);
expect(tileDefinition).to.be.ok();
expect(tileDefinition.hasTag("obstacle")).to.be(true);
expect(tileDefinition.hasTag("lava")).to.be(true);
expect(tileDefinition.hasTaggedHitBox("obstacle")).to.be(true);
expect(tileDefinition.hasTaggedHitBox("lava")).to.be(true);
expect(tileDefinition.getHitBoxes("obstacle")).to.be.eql([
[
[0, 0],
@@ -469,8 +472,8 @@ describe("TiledTileMapLoader", function () {
it("can load a tile set with only the other filter tag", function () {
const tileDefinition = tileMap.getTileDefinition(5);
expect(tileDefinition).to.be.ok();
expect(tileDefinition.hasTag("obstacle")).to.be(false);
expect(tileDefinition.hasTag("lava")).to.be(true);
expect(tileDefinition.hasTaggedHitBox("obstacle")).to.be(false);
expect(tileDefinition.hasTaggedHitBox("lava")).to.be(true);
expect(tileDefinition.getHitBoxes("lava")).to.be.eql([
[
[0, 0],
@@ -492,15 +495,15 @@ describe("TiledTileMapLoader", function () {
expect(layer.id).to.be(1);
expect(layer.isVisible()).to.be(true);
expect(layer.get(0, 0)).to.be(0);
expect(layer.get(1, 0)).to.be(2);
expect(layer.get(2, 0)).to.be(3);
expect(layer.get(3, 0)).to.be(4);
expect(layer.getTileId(0, 0)).to.be(0);
expect(layer.getTileId(1, 0)).to.be(2);
expect(layer.getTileId(2, 0)).to.be(3);
expect(layer.getTileId(3, 0)).to.be(4);
expect(layer.get(0, 1)).to.be(2);
expect(layer.get(1, 1)).to.be(1);
expect(layer.get(2, 1)).to.be(undefined);
expect(layer.get(3, 1)).to.be(4);
expect(layer.getTileId(0, 1)).to.be(2);
expect(layer.getTileId(1, 1)).to.be(1);
expect(layer.getTileId(2, 1)).to.be(undefined);
expect(layer.getTileId(3, 1)).to.be(4);
expect(layer.isFlippedVertically(3, 1)).to.be(true);
expect(layer.isFlippedHorizontally(3, 1)).to.be(false);
expect(layer.isFlippedDiagonally(3, 1)).to.be(false);
@@ -516,7 +519,7 @@ describe("TiledTileMapLoader", function () {
describe("with a collision mask", function () {
// Built from an actual json file exported by Tiled.
const tiledMap: TiledMap = {
const tiledMap: TiledTileMap = {
compressionlevel: -1,
height: 2,
infinite: false,
@@ -619,7 +622,7 @@ describe("TiledTileMapLoader", function () {
width: 4,
};
const tileMap: EditableTileMap = TiledTileMapLoader.load(null, tiledMap);
const tileMap: EditableTileMap = TiledTileMapLoader.load(tiledMap, null);
it("can load flipped tiles", function () {
const layers = new Array(...tileMap.getLayers());
@@ -628,42 +631,42 @@ describe("TiledTileMapLoader", function () {
expect(layer.id).to.be(1);
expect(layer.isVisible()).to.be(true);
expect(layer.get(0, 0)).to.be(2);
expect(layer.getTileId(0, 0)).to.be(2);
expect(layer.isFlippedVertically(0, 0)).to.be(false);
expect(layer.isFlippedHorizontally(0, 0)).to.be(false);
expect(layer.isFlippedDiagonally(0, 0)).to.be(false);
expect(layer.get(1, 0)).to.be(2);
expect(layer.getTileId(1, 0)).to.be(2);
expect(layer.isFlippedVertically(1, 0)).to.be(false);
expect(layer.isFlippedHorizontally(1, 0)).to.be(true);
expect(layer.isFlippedDiagonally(1, 0)).to.be(true);
expect(layer.get(1, 1)).to.be(2);
expect(layer.getTileId(1, 1)).to.be(2);
expect(layer.isFlippedVertically(1, 1)).to.be(true);
expect(layer.isFlippedHorizontally(1, 1)).to.be(true);
expect(layer.isFlippedDiagonally(1, 1)).to.be(false);
expect(layer.get(0, 1)).to.be(2);
expect(layer.getTileId(0, 1)).to.be(2);
expect(layer.isFlippedVertically(0, 1)).to.be(true);
expect(layer.isFlippedHorizontally(0, 1)).to.be(false);
expect(layer.isFlippedDiagonally(0, 1)).to.be(true);
expect(layer.get(2, 0)).to.be(2);
expect(layer.getTileId(2, 0)).to.be(2);
expect(layer.isFlippedVertically(2, 0)).to.be(false);
expect(layer.isFlippedHorizontally(2, 0)).to.be(false);
expect(layer.isFlippedDiagonally(2, 0)).to.be(true);
expect(layer.get(3, 0)).to.be(2);
expect(layer.getTileId(3, 0)).to.be(2);
expect(layer.isFlippedVertically(3, 0)).to.be(false);
expect(layer.isFlippedHorizontally(3, 0)).to.be(true);
expect(layer.isFlippedDiagonally(3, 0)).to.be(false);
expect(layer.get(3, 1)).to.be(2);
expect(layer.getTileId(3, 1)).to.be(2);
expect(layer.isFlippedVertically(3, 1)).to.be(true);
expect(layer.isFlippedHorizontally(3, 1)).to.be(true);
expect(layer.isFlippedDiagonally(3, 1)).to.be(true);
expect(layer.get(2, 1)).to.be(2);
expect(layer.getTileId(2, 1)).to.be(2);
expect(layer.isFlippedVertically(2, 1)).to.be(true);
expect(layer.isFlippedHorizontally(2, 1)).to.be(false);
expect(layer.isFlippedDiagonally(2, 1)).to.be(false);

Some files were not shown because too many files have changed in this diff Show More