diff --git a/Core/GDCore/Events/CodeGeneration/EventsCodeGenerator.cpp b/Core/GDCore/Events/CodeGeneration/EventsCodeGenerator.cpp index 5ea717dc3f52..3d113fd70921 100644 --- a/Core/GDCore/Events/CodeGeneration/EventsCodeGenerator.cpp +++ b/Core/GDCore/Events/CodeGeneration/EventsCodeGenerator.cpp @@ -726,6 +726,7 @@ gd::String EventsCodeGenerator::GenerateParameterCodes( metadata.GetType() == "fontResource" || metadata.GetType() == "imageResource" || metadata.GetType() == "jsonResource" || + metadata.GetType() == "tilemapResource" || metadata.GetType() == "videoResource" || // Deprecated, old parameter names: metadata.GetType() == "password" || metadata.GetType() == "musicfile" || diff --git a/Core/GDCore/IDE/Project/ArbitraryResourceWorker.cpp b/Core/GDCore/IDE/Project/ArbitraryResourceWorker.cpp index 1d6bd21fd7e5..61b648866c34 100644 --- a/Core/GDCore/IDE/Project/ArbitraryResourceWorker.cpp +++ b/Core/GDCore/IDE/Project/ArbitraryResourceWorker.cpp @@ -35,6 +35,11 @@ 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::ExposeVideo(gd::String& videoName){ // Nothing to do by default - each child class can define here the action to // do. @@ -92,6 +97,65 @@ 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 == "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 +218,10 @@ 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); } }); diff --git a/Core/GDCore/IDE/Project/ArbitraryResourceWorker.h b/Core/GDCore/IDE/Project/ArbitraryResourceWorker.h index c1aaa52042f2..c17aa094937a 100644 --- a/Core/GDCore/IDE/Project/ArbitraryResourceWorker.h +++ b/Core/GDCore/IDE/Project/ArbitraryResourceWorker.h @@ -75,6 +75,11 @@ 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 video, which is always a reference to a "video" resource. */ @@ -96,6 +101,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 &GetResources() { return resourcesManagers; diff --git a/Core/GDCore/IDE/Project/ResourcesInUseHelper.h b/Core/GDCore/IDE/Project/ResourcesInUseHelper.h index e57c07d38edd..be15c2940d0d 100644 --- a/Core/GDCore/IDE/Project/ResourcesInUseHelper.h +++ b/Core/GDCore/IDE/Project/ResourcesInUseHelper.h @@ -40,6 +40,7 @@ class ResourcesInUseHelper : public gd::ArbitraryResourceWorker { std::set& GetAllAudios() { return GetAll("audio"); }; std::set& GetAllFonts() { return GetAll("font"); }; std::set& GetAllJsons() { return GetAll("json"); }; + std::set& GetAllTilemaps() { return GetAll("tilemap"); }; std::set& GetAllVideos() { return GetAll("video"); }; std::set& GetAllBitmapFonts() { return GetAll("bitmapFont"); }; std::set& GetAll(const gd::String& resourceType) { @@ -47,6 +48,7 @@ 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 == "video") return allVideos; if (resourceType == "bitmapFont") return allBitmapFonts; @@ -68,6 +70,9 @@ 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 ExposeVideo(gd::String& videoResourceName) override { allVideos.insert(videoResourceName); }; @@ -80,6 +85,7 @@ class ResourcesInUseHelper : public gd::ArbitraryResourceWorker { std::set allAudios; std::set allFonts; std::set allJsons; + std::set allTilemaps; std::set allVideos; std::set allBitmapFonts; std::set emptyResources; diff --git a/Core/GDCore/IDE/Project/ResourcesRenamer.h b/Core/GDCore/IDE/Project/ResourcesRenamer.h index 346dcbae2e01..c5f3ccd13070 100644 --- a/Core/GDCore/IDE/Project/ResourcesRenamer.h +++ b/Core/GDCore/IDE/Project/ResourcesRenamer.h @@ -49,6 +49,9 @@ 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 ExposeVideo(gd::String& videoResourceName) override { RenameIfNeeded(videoResourceName); }; diff --git a/Core/GDCore/Project/CustomObjectConfiguration.cpp b/Core/GDCore/Project/CustomObjectConfiguration.cpp index b1aa3636a7d5..c87ccee7b6a3 100644 --- a/Core/GDCore/Project/CustomObjectConfiguration.cpp +++ b/Core/GDCore/Project/CustomObjectConfiguration.cpp @@ -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 properties = GetProperties(); for (auto& property : properties) { @@ -148,6 +147,8 @@ void CustomObjectConfiguration::ExposeResources( worker.ExposeVideo(newPropertyValue); } else if (resourceType == "json") { worker.ExposeJson(newPropertyValue); + } else if (resourceType == "tilemap") { + worker.ExposeTilemap(newPropertyValue); } else if (resourceType == "bitmapFont") { worker.ExposeBitmapFont(newPropertyValue); } diff --git a/Core/GDCore/Project/CustomObjectConfiguration.h b/Core/GDCore/Project/CustomObjectConfiguration.h index 9067d53f8d85..35ad90ba791f 100644 --- a/Core/GDCore/Project/CustomObjectConfiguration.h +++ b/Core/GDCore/Project/CustomObjectConfiguration.h @@ -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. */ diff --git a/Core/GDCore/Project/ObjectConfiguration.h b/Core/GDCore/Project/ObjectConfiguration.h index d06c55fde1d8..a08c5db31cc1 100644 --- a/Core/GDCore/Project/ObjectConfiguration.h +++ b/Core/GDCore/Project/ObjectConfiguration.h @@ -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" diff --git a/Core/GDCore/Project/Project.cpp b/Core/GDCore/Project/Project.cpp index c55e3b58b225..925b4f5b4359 100644 --- a/Core/GDCore/Project/Project.cpp +++ b/Core/GDCore/Project/Project.cpp @@ -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 diff --git a/Core/GDCore/Project/ResourcesManager.cpp b/Core/GDCore/Project/ResourcesManager.cpp index 6c80981f785d..42e5d4d0703a 100644 --- a/Core/GDCore/Project/ResourcesManager.cpp +++ b/Core/GDCore/Project/ResourcesManager.cpp @@ -85,6 +85,8 @@ std::shared_ptr ResourcesManager::CreateResource( return std::make_shared(); else if (kind == "json") return std::make_shared(); + else if (kind == "tilemap") + return std::make_shared(); else if (kind == "bitmapFont") return std::make_shared(); @@ -650,6 +652,40 @@ 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 TilemapResource::GetProperties() + const { + std::map 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 BitmapFontResource::SetFile(const gd::String& newFile) { file = NormalizePathSeparator(newFile); } diff --git a/Core/GDCore/Project/ResourcesManager.h b/Core/GDCore/Project/ResourcesManager.h index a2b9a41b6b23..12277f0b19f5 100644 --- a/Core/GDCore/Project/ResourcesManager.h +++ b/Core/GDCore/Project/ResourcesManager.h @@ -373,6 +373,47 @@ 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 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. * diff --git a/Core/tests/ResourcesRenamer.cpp b/Core/tests/ResourcesRenamer.cpp index 1ca075ddfc7e..4e4a617753a5 100644 --- a/Core/tests/ResourcesRenamer.cpp +++ b/Core/tests/ResourcesRenamer.cpp @@ -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 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\"}}"); } } diff --git a/Extensions/PanelSpriteObject/PanelSpriteObject.cpp b/Extensions/PanelSpriteObject/PanelSpriteObject.cpp index 19570ae6b974..76699f90213a 100644 --- a/Extensions/PanelSpriteObject/PanelSpriteObject.cpp +++ b/Extensions/PanelSpriteObject/PanelSpriteObject.cpp @@ -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 diff --git a/Extensions/PanelSpriteObject/PanelSpriteObject.h b/Extensions/PanelSpriteObject/PanelSpriteObject.h index 2d5436e38b1a..bcae0cd70ada 100644 --- a/Extensions/PanelSpriteObject/PanelSpriteObject.h +++ b/Extensions/PanelSpriteObject/PanelSpriteObject.h @@ -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; }; diff --git a/Extensions/TextObject/TextObject.cpp b/Extensions/TextObject/TextObject.cpp index 63830cda40c5..bd2d061e8b6f 100644 --- a/Extensions/TextObject/TextObject.cpp +++ b/Extensions/TextObject/TextObject.cpp @@ -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 diff --git a/Extensions/TextObject/TextObject.h b/Extensions/TextObject/TextObject.h index 79ede3ef007c..9d72b9f0e151 100644 --- a/Extensions/TextObject/TextObject.h +++ b/Extensions/TextObject/TextObject.h @@ -25,9 +25,7 @@ class GD_EXTENSION_API TextObject : public gd::ObjectConfiguration { return gd::make_unique(*this); } -#if defined(GD_IDE_ONLY) virtual void ExposeResources(gd::ArbitraryResourceWorker& worker); -#endif /** \brief Change the text. */ diff --git a/Extensions/TileMap/JsExtension.js b/Extensions/TileMap/JsExtension.js index 67abddbccc98..e430723321b9 100644 --- a/Extensions/TileMap/JsExtension.js +++ b/Extensions/TileMap/JsExtension.js @@ -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; @@ -74,11 +78,11 @@ const defineTileMap = function ( new gd.PropertyDescriptor(objectContent.tilemapJsonFile) .setType('resource') .addExtraInfo('json') - .setLabel(_('Tilemap JSON file')) + .setLabel(_('Tilemap Tiled JSON or LDtk 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.') ) - .setGroup(_('Tilemap and tileset')) + .setGroup(_('LDtk and Tiled: Tilemap')) ); objectProperties.set( 'tilesetJsonFile', @@ -88,10 +92,10 @@ const defineTileMap = function ( .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 +103,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 +132,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 +164,7 @@ const defineTileMap = function ( tilemapAtlasImage: '', displayMode: 'visible', layerIndex: 0, + levelIndex: 0, animationSpeedScale: 1, animationFps: 4, }) @@ -179,7 +197,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,12 +205,8 @@ 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'); @@ -207,7 +221,7 @@ const defineTileMap = function ( 'JsPlatform/Extensions/tile_map.svg' ) .addParameter('object', _('Tile map'), 'TileMap', false) - .addParameter('jsonResource', _('Tilemap JSON file'), '', false) + .addParameter('tilemapResource', _('Tilemap JSON file'), '', false) .getCodeExtraInformation() .setFunctionName('isTilemapJsonFile'); @@ -216,7 +230,7 @@ const defineTileMap = function ( 'SetTilemapJsonFile', _('Tilemap JSON file'), _( - 'Set the JSON file containing the Tilemap data to display. This is usually the JSON file exported from Tiled.' + 'Set the JSON file containing the Tilemap data to display. This is usually the JSON file from Tiled/LDtk.' ), _('Set the Tilemap JSON file of _PARAM0_ to _PARAM1_'), '', @@ -224,7 +238,7 @@ const defineTileMap = function ( 'JsPlatform/Extensions/tile_map.svg' ) .addParameter('object', _('Tile map'), 'TileMap', false) - .addParameter('jsonResource', _('Tilemap JSON file'), '', false) + .addParameter('tilemapResource', _('Tilemap JSON file'), '', false) .getCodeExtraInformation() .setFunctionName('setTilemapJsonFile'); @@ -349,6 +363,23 @@ 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 +539,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 +570,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 +591,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 ( @@ -659,13 +693,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 +719,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)')) ); @@ -748,7 +794,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 +816,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 +836,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 +858,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 +1001,7 @@ module.exports = { gd /*: libGDevelop */ ) { const extension = new gd.PlatformExtension(); + extension .setExtensionInformation( 'TileMap', @@ -945,11 +1012,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 +1144,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 +1194,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 +1271,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 +1290,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]; - } - } catch (err) { - console.error('Unable to load a Tilemap JSON data: ', err); + if (tileMap.kind === 'tiled') { + const tilesetJsonData = tilesetJsonFile + ? await this._pixiResourcesLoader.getResourceJsonData( + this._project, + tilesetJsonFile + ) + : null; + + if (tilesetJsonData) { + tileMapJsonData.tilesets = [tilesetJsonData]; + } } - return tileMapJsonData; + + return tileMap; + } catch (err) { + console.error('Unable to load a Tilemap JSON data: ', err); + } }; /** @@ -1216,7 +1317,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 +1335,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 +1374,7 @@ module.exports = { * @class RenderedTileMapInstance * @constructor */ - function RenderedCollisionMaskInstance( + function RenderedCollisionMaskInstance( project, layout, instance, @@ -1317,8 +1423,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 +1441,7 @@ module.exports = { /** * Return the path to the thumbnail of the specified object. */ - RenderedCollisionMaskInstance.getThumbnail = function ( + RenderedCollisionMaskInstance.getThumbnail = function ( project, resourcesLoader, objectConfiguration @@ -1345,45 +1452,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 +1500,7 @@ module.exports = { this._loadTiledMapWithCallback.bind(this), tilemapJsonFile, tilesetJsonFile, + 0, // leveIndex pako, (tileMap) => { if (!tileMap) { @@ -1412,48 +1522,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 +1553,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 +1583,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 +1599,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; }; diff --git a/Extensions/TileMap/TileMapRuntimeManager.ts b/Extensions/TileMap/TileMapRuntimeManager.ts index af466048a8cd..22ea8e5fceb2 100644 --- a/Extensions/TileMap/TileMapRuntimeManager.ts +++ b/Extensions/TileMap/TileMapRuntimeManager.ts @@ -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); } }); } diff --git a/Extensions/TileMap/collision/TransformedTileMap.ts b/Extensions/TileMap/collision/TransformedTileMap.ts index fcad21ab749b..86b342b69533 100644 --- a/Extensions/TileMap/collision/TransformedTileMap.ts +++ b/Extensions/TileMap/collision/TransformedTileMap.ts @@ -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)! )!; } diff --git a/Extensions/TileMap/helper/TileMapHelper.d.ts b/Extensions/TileMap/helper/TileMapHelper.d.ts index 1a17bb964d58..c0d7bcb7b776 100644 --- a/Extensions/TileMap/helper/TileMapHelper.d.ts +++ b/Extensions/TileMap/helper/TileMapHelper.d.ts @@ -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, + }; } } diff --git a/Extensions/TileMap/helper/TileMapHelper.js b/Extensions/TileMap/helper/TileMapHelper.js index 7b50a3da5af2..50997631e1f2 100644 --- a/Extensions/TileMap/helper/TileMapHelper.js +++ b/Extensions/TileMap/helper/TileMapHelper.js @@ -1,2 +1,2 @@ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).TileMapHelper={})}(this,(function(t){"use strict";var e=function(t,i){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])},e(t,i)};function i(t,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function n(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}function n(t){var e="function"==typeof Symbol&&Symbol.iterator,i=e&&t[e],n=0;if(i)return i.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}var r=function(){function t(t,e,i,n,r){this.tileWidth=t,this.tileHeight=e,this.dimX=i,this.dimY=n,this._tileSet=r,this._layers=[]}return t.prototype.getWidth=function(){return this.tileWidth*this.dimX},t.prototype.getHeight=function(){return this.tileHeight*this.dimY},t.prototype.getTileHeight=function(){return this.tileHeight},t.prototype.getTileWidth=function(){return this.tileWidth},t.prototype.getDimensionX=function(){return this.dimX},t.prototype.getDimensionY=function(){return this.dimY},t.prototype.getTileDefinition=function(t){return this._tileSet.get(t)},t.prototype.getTileDefinitions=function(){return this._tileSet.values()},t.prototype.addTileLayer=function(t){var e=new p(this,t);return this._layers.push(e),e},t.prototype.addObjectLayer=function(t){var e=new o(this,t);return this._layers.push(e),e},t.prototype.getLayers=function(){return this._layers},t.prototype.pointIsInsideTile=function(t,e,i){var r,l,o=Math.floor(t/this.tileWidth),a=Math.floor(e/this.tileHeight);try{for(var s=n(this._layers),p=s.next();!p.done;p=s.next()){var c=p.value;if(c){var d=c.get(o,a);if(void 0===d)return!1;if(this._tileSet.get(d).hasTag(i))return!0}}}catch(t){r={error:t}}finally{try{p&&!p.done&&(l=s.return)&&l.call(s)}finally{if(r)throw r.error}}return!1},t}(),l=function(){function t(t,e){this.visible=!0,this.tileMap=t,this.id=e}return t.prototype.setVisible=function(t){this.visible=t},t.prototype.isVisible=function(){return this.visible},t}(),o=function(t){function e(e,i){var n=t.call(this,e,i)||this;return n.objects=[],n}return i(e,t),e.prototype.add=function(t){this.objects.push(t)},e}(l),a=function(){function t(t,e,i){this.tileId=i,this.x=t,this.y=e}return t.prototype.getTileId=function(){return s.getTileId(this.tileId)},t.prototype.setFlippedHorizontally=function(t){this.tileId=s.setFlippedHorizontally(this.tileId,t)},t.prototype.setFlippedVertically=function(t){this.tileId=s.setFlippedVertically(this.tileId,t)},t.prototype.setFlippedDiagonally=function(t){this.tileId=s.setFlippedDiagonally(this.tileId,t)},t.prototype.isFlippedHorizontally=function(){return s.isFlippedHorizontally(this.tileId)},t.prototype.isFlippedVertically=function(){return s.isFlippedVertically(this.tileId)},t.prototype.isFlippedDiagonally=function(){return s.isFlippedDiagonally(this.tileId)},t}(),s=function(){function t(){}return t.getTileId=function(e){return e&t.tileIdMask},t.setFlippedHorizontally=function(e,i){return e&=~t.flippedHorizontallyFlag,i&&(e|=t.flippedHorizontallyFlag),e},t.setFlippedVertically=function(e,i){return e&=~t.flippedVerticallyFlag,i&&(e|=t.flippedVerticallyFlag),e},t.setFlippedDiagonally=function(e,i){return e&=~t.flippedDiagonallyFlag,i&&(e|=t.flippedDiagonallyFlag),e},t.isFlippedHorizontally=function(e){return 0!=(e&t.flippedHorizontallyFlag)},t.isFlippedVertically=function(e){return 0!=(e&t.flippedVerticallyFlag)},t.isFlippedDiagonally=function(e){return 0!=(e&t.flippedDiagonallyFlag)},t.flippedHorizontallyFlag=2147483648,t.flippedVerticallyFlag=1073741824,t.flippedDiagonallyFlag=536870912,t.tileIdMask=~(t.flippedHorizontallyFlag|t.flippedVerticallyFlag|t.flippedDiagonallyFlag),t}(),p=function(t){function e(e,i){var n=t.call(this,e,i)||this;n._tiles=[],n._tiles.length=n.tileMap.getDimensionY();for(var r=0;r>>0};if("zlib"===n)for(var s=new Uint8Array(o),p=t.inflate(s);r<=p.length;)l.push(a(p,r-4)),r+=4;else{if("zstd"===n)return console.error("Zstandard compression is not supported for layers in a Tilemap. Use instead zlib compression or no compression."),null;for(;r<=o.length;)l.push(a(o,r-4)),r+=4}return l}catch(t){return console.error("Failed to decompress and unzip base64 layer.data string",t),null}},f=function(t){var e=2147483648,i=1073741824,n=536870912,r=t&e,l=t&i,o=t&n;return{id:h(536870911&t),flippedHorizontally:!!r,flippedVertically:!!l,flippedDiagonally:!!o}},h=function(t){return 0===t?void 0:t-1},y=function(){function t(){}return t.load=function(t,e){var i,l,o,s,p,d,y,g,v,x;if(!e.tiledversion)return console.warn("The loaded Tiled map does not contain a 'tiledversion' key. Are you sure this file has been exported from Tiled (mapeditor.org)?"),null;var F=new Map;try{for(var w=n(e.tilesets),T=w.next();!T.done;T=w.next()){var b=T.value,m=void 0===b.firstgid?1:b.firstgid;if(b.tiles)try{for(var _=(o=void 0,n(b.tiles)),M=_.next();!M.done;M=_.next()){var H=M.value,D=new c(H.animation?H.animation.length:0);if(H.objectgroup){var I=function(t){var e=t.class||H.class;if(!e||0===e.length)return"continue";var i=null;if(t.polygon){var n=t.rotation*Math.PI/180,r=Math.cos(n),l=Math.sin(n);-1!==r&&1!==r||(l=0),-1!==l&&1!==l||(r=0),i=t.polygon.map((function(e){return[t.x+e.x*r-e.y*l,t.y+e.x*l+e.y*r]}))}else void 0!==t.x&&void 0!==t.y&&void 0!==t.width&&void 0!==t.height&&(i=[[t.x,t.y],[t.x,t.y+t.height],[t.x+t.width,t.y+t.height],[t.x+t.width,t.y]]);i&&D.add(e,i)};try{for(var V=(p=void 0,n(H.objectgroup.objects)),z=V.next();!z.done;z=V.next()){I(R=z.value)}}catch(t){p={error:t}}finally{try{z&&!z.done&&(d=V.return)&&d.call(V)}finally{if(p)throw p.error}}}else if(H.class&&H.class.length>0){var L=[[0,0],[0,e.tileheight],[e.tilewidth,e.tileheight],[e.tilewidth,0]];D.add(H.class,L)}F.set(h(m+H.id),D)}}catch(t){o={error:t}}finally{try{M&&!M.done&&(s=_.return)&&s.call(_)}finally{if(o)throw o.error}}for(var j=0;j=f+p+r||1!==e.height&&e.height=y+p+l)return console.error("It seems the atlas file was resized, which is not supported. "+"It should be ".concat(f,"x").concat(y," px, ")+"but it's ".concat(e.width,"x").concat(e.height," px.")),null;if(1!==e.width&&e.width!==f||1!==e.height&&e.height!==y)return console.warn("It seems the atlas file has unused pixels. "+"It should be ".concat(f,"x").concat(y," px, ")+"but it's ".concat(e.width,"x").concat(e.height," px.")),null;for(var x=new g,F=0;F0&&k.tileAnimX(m,C.getAnimationLength())}else console.warn("Unknown tile id: ".concat(L," at (").concat(I,", ").concat(D,")"))}}}}catch(t){a={error:t}}finally{try{h&&!h.done&&(s=f.return)&&s.call(f)}finally{if(a)throw a.error}}}},t.updatePixiCollisionMask=function(t,e,i,r,l,o,a,s){var c,d,u,f;if(t){t.clear(),t.lineStyle(r,l,o),t.drawRect(0,0,e.getWidth(),e.getHeight());try{for(var h=n(e.getLayers()),y=h.next();!y.done;y=h.next()){var g=y.value,v=e.getTileWidth(),x=e.getTileHeight();if(g instanceof p)for(var F=g,w=0;w=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function n(e,t){var i="function"==typeof Symbol&&e[Symbol.iterator];if(!i)return e;var r,n,o=i.call(e),l=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)l.push(r.value)}catch(e){n={error:e}}finally{try{r&&!r.done&&(i=o.return)&&i.call(o)}finally{if(n)throw n.error}}return l}function o(e,t,i){if(i||2===arguments.length)for(var r,n=0,o=t.length;n0},e.prototype.setStackedTiles=function(e){for(var t=[],i=1;i>>0};if("zlib"===r)for(var s=new Uint8Array(l),c=e.inflate(s);n<=c.length;)o.push(a(c,n-4)),n+=4;else{if("zstd"===r)return console.error("Zstandard compression is not supported for layers in a Tilemap. Use instead zlib compression or no compression."),null;for(;n<=l.length;)o.push(a(l,n-4)),n+=4}return o}catch(e){return console.error("Failed to decompress and unzip base64 layer.data string",e),null}},w=function(e){var t=e&a,i=e&s,r=e&c;return{id:b(536870911&e),flippedHorizontally:!!t,flippedVertically:!!i,flippedDiagonally:!!r}};function b(e){return 0===e?void 0:e-1}var m,k=GlobalPIXIModule.PIXI;function M(e,t){var i=e<<16;return i+=t}!function(e){e.parseAtlas=function(e,t,i,r){if(!e.tiledversion)return console.warn("The loaded Tiled map does not contain a 'tiledversion' key. Are you sure this file has been exported from Tiled (mapeditor.org)?"),null;if(!e.tilesets.length||"source"in e.tilesets[0])return console.warn("The loaded Tiled map seems not to contain any tileset data (nothing in 'tilesets' key)."),null;var n=e.tilesets[0],o=n.tilewidth,l=n.tileheight,a=n.tilecount,s=n.image,c=n.columns,d=n.spacing,u=n.margin,p=void 0===n.firstgid?1:n.firstgid;i||(i=r(s));var f=a/c,h=o*c+d*(c-1)+2*u,y=l*f+d*(f-1)+2*u;if(1!==i.width&&i.width=h+d+o||1!==i.height&&i.height=y+d+l)return console.error("It seems the atlas file was resized, which is not supported. "+"It should be ".concat(h,"x").concat(y," px, ")+"but it's ".concat(i.width,"x").concat(i.height," px.")),null;if(1!==i.width&&i.width!==h||1!==i.height&&i.height!==y)return console.warn("It seems the atlas file has unused pixels. "+"It should be ".concat(h,"x").concat(y," px, ")+"but it's ".concat(i.width,"x").concat(i.height," px.")),null;for(var g=new x,v=0;v-1?t:0];if(!u||!u.layerInstances)return null;var p={};try{for(var f=r(e.defs.tilesets),h=f.next();!h.done;h=f.next()){p[(b=h.value).uid]=b}}catch(e){a={error:e}}finally{try{h&&!h.done&&(s=f.return)&&s.call(f)}finally{if(a)throw a.error}}for(var y=new x,g={},v={},T=u.layerInstances.length-1;T>=0;--T){var _=u.layerInstances[T];if("Entities"!==_.__type){var w=_.__tilesetDefUid;if("number"==typeof w){var b=p[w],m=A(v,p,l,w);if(m){var k={},I=b.tileGridSize;try{for(var H=(c=void 0,r(o(o([],n(_.autoLayerTiles),!1),n(_.gridTiles),!1))),F=H.next();!F.done;F=H.next()){var D=F.value;if(!k[D.t]){var L=M(w,D.t);if(g[L])k[D.t]=!0;else{try{var V=n(D.src,2),z=V[0],P=V[1],B=new S.Rectangle(z,P,I,I),j=new S.Texture(m,B);y.setTexture(L,j)}catch(e){console.error("An error occurred while creating a PIXI.Texture to be used in a TileMap:",e)}k[D.t]=!0,g[L]=!0}}}}catch(e){c={error:e}}finally{try{F&&!F.done&&(d=H.return)&&d.call(H)}finally{if(c)throw c.error}}}}}}if(u.bgRelPath){var R=l(u.bgRelPath);B=new S.Rectangle(0,0,u.pxWid,u.pxHei),j=new S.Texture(R,B);y.setLevelBackgroundTexture(u.bgRelPath,j)}return y}}(I||(I={})),e.PixiTileMapHelper=void 0,(H=e.PixiTileMapHelper||(e.PixiTileMapHelper={})).parseAtlas=function(e,t,i,r){return"ldtk"===e.kind?I.parseAtlas(e.data,t,i,r):"tiled"===e.kind?m.parseAtlas(e.data,t,i,r):(console.warn("The loaded Tiled 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)?"),null)},H.updatePixiTileMap=function(e,t,i,n,o){var a,s,c,u,p,f,y=e;if(y){y.clear();var v=t.getBackgroundResourceName();if(v){var T=i.getLevelBackgroundTexture(v);y.tile(T,0,0)}try{for(var x=r(t.getLayers()),_=x.next();!_.done;_=x.next()){var w=_.value;if(!("index"===n&&o!==w.id||"visible"===n&&!w.isVisible()))if(w instanceof h){var b=w;try{for(var m=(c=void 0,r(b.objects)),k=m.next();!k.done;k=m.next()){var M=k.value,I=M.getTileId();if(T=i.getTexture(I)){var H=d(I);y.tile(T,M.x,M.y-b.tileMap.getTileHeight(),{rotate:H})}}}catch(e){c={error:e}}finally{try{k&&!k.done&&(u=m.return)&&u.call(m)}finally{if(c)throw c.error}}}else if(w instanceof g)for(var F=w,D=F.tileMap.getTileWidth(),L=F.tileMap.getTileHeight(),S=F.tileMap.getDimensionX(),A=F.tileMap.getDimensionY(),V=F.getAlpha(),z=0;z0&&N.tileAnimX(D,X.getAnimationLength())}}}}}catch(e){a={error:e}}finally{try{_&&!_.done&&(s=x.return)&&s.call(x)}finally{if(a)throw a.error}}}},H.updatePixiCollisionMask=function(e,t,i,n,o,l,a,s){var c,d,u,p;if(e){e.clear(),e.lineStyle(n,o,l),e.drawRect(0,0,t.getWidth(),t.getHeight());try{for(var f=r(t.getLayers()),h=f.next();!h.done;h=f.next()){var y=h.value,v=t.getTileWidth(),T=t.getTileHeight();if(y instanceof g)for(var x=y,_=0;_-1?t:0];if(!c||!c.layerInstances)return null;for(var d=new Map,f=0,h=0,y=0,g=c.layerInstances.length-1;g>=0;--g){var T=(F=c.layerInstances[g]).__tilesetDefUid,x={};try{for(var _=(i=void 0,r(o(o([],n(F.autoLayerTiles),!1),n(F.gridTiles),!1))),w=_.next();!w.done;w=_.next()){if(!x[(V=w.value).t]){var b=M(T,V.t);if(d.has(b))x[V.t]=!0;else{var m=new v(0);x[V.t]=!0,d.set(b,m)}}}}catch(e){i={error:e}}finally{try{w&&!w.done&&(l=_.return)&&l.call(_)}finally{if(i)throw i.error}}0===f&&"IntGrid"===F.__type&&(f=F.__gridSize,h=F.__cWid,y=F.__cHei)}var k=new p(f,f,h,y,d),I=new Map,H=268435455;for(g=c.layerInstances.length-1;g>=0;--g){var F,D=(F=c.layerInstances[g]).__gridSize,L=(T=F.__tilesetDefUid,k.addTileLayer(g));L.setAlpha(F.__opacity),L.setVisible(F.visible);try{for(var S=(a=void 0,r(o(o([],n(F.autoLayerTiles),!1),n(F.gridTiles),!1))),A=S.next();!A.done;A=S.next()){var V=A.value,z=Math.floor(V.px[0]/D),P=Math.floor(V.px[1]/D),B=(b=M(T,V.t),L.getTileId(z,P));if(void 0===B)L.setTile(z,P,b),L.setFlippedHorizontally(z,P,1===V.f||3===V.f),L.setFlippedVertically(z,P,2===V.f||3===V.f);else{var j=u(b,1===V.f||3===V.f,2===V.f||3===V.f,!1),R=d.get(B);if(null==R?void 0:R.hasStackedTiles()){var X="".concat(R.getStackedTiles().map((function(e){return"".concat(e)})).join(";"),";").concat(j);if(m=I.get(X))L.setTile(z,P,m.getStackTileId());else{var C=new v(0);C.setStackedTiles.apply(C,o(o([H],n(R.getStackedTiles()),!1),[j],!1)),d.set(H,C),H-=1,I.set(X,C),L.setTile(z,P,C.getStackTileId())}}else{var O=L.getTileGID(z,P);X="".concat(O,";").concat(j);(m=new v(0)).setStackedTiles(H,O,j),d.set(H,m),H-=1,I.set(X,m),L.setTile(z,P,m.getStackTileId())}}}}catch(e){a={error:e}}finally{try{A&&!A.done&&(s=S.return)&&s.call(S)}finally{if(a)throw a.error}}}return c.bgRelPath&&k.setBackgroundResourceName(c.bgRelPath),k}}(F||(F={})),function(e){e.load=function(e,t){var i,n,o,l,a,s,c,d,u,f;if(!e.tiledversion)return console.warn("The loaded Tiled map does not contain a 'tiledversion' key. Are you sure this file has been exported from Tiled (mapeditor.org)?"),null;var h=new Map;try{for(var g=r(e.tilesets),T=g.next();!T.done;T=g.next()){var x=T.value,m=void 0===x.firstgid?1:x.firstgid;if(x.tiles)try{for(var k=(o=void 0,r(x.tiles)),M=k.next();!M.done;M=k.next()){var I=M.value,H=new v(I.animation?I.animation.length:0);if(I.objectgroup){var F=function(e){var t=e.class||I.class;if(!t||0===t.length)return"continue";var i=null;if(e.polygon){var r=e.rotation*Math.PI/180,n=Math.cos(r),o=Math.sin(r);-1!==n&&1!==n||(o=0),-1!==o&&1!==o||(n=0),i=e.polygon.map((function(t){return[e.x+t.x*n-t.y*o,e.y+t.x*o+t.y*n]}))}else void 0!==e.x&&void 0!==e.y&&void 0!==e.width&&void 0!==e.height&&(i=[[e.x,e.y],[e.x,e.y+e.height],[e.x+e.width,e.y+e.height],[e.x+e.width,e.y]]);i&&H.addHitBox(t,i)};try{for(var D=(a=void 0,r(I.objectgroup.objects)),L=D.next();!L.done;L=D.next()){F(Y=L.value)}}catch(e){a={error:e}}finally{try{L&&!L.done&&(s=D.return)&&s.call(D)}finally{if(a)throw a.error}}}else if(I.class&&I.class.length>0){var S=[[0,0],[0,e.tileheight],[e.tilewidth,e.tileheight],[e.tilewidth,0]];H.addHitBox(I.class,S)}h.set(b(m+I.id),H)}}catch(e){o={error:e}}finally{try{M&&!M.done&&(l=k.return)&&l.call(k)}finally{if(o)throw o.error}}for(var A=0;A= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n",null,null,null,null,null,null,null],"names":["extendStatics","d","b","Object","setPrototypeOf","__proto__","Array","p","prototype","hasOwnProperty","call","__extends","TypeError","String","__","this","constructor","create","__values","o","s","Symbol","iterator","m","i","length","next","value","done","tileWidth","tileHeight","dimX","dimY","tileSet","_tileSet","_layers","EditableTileMap","tileId","get","values","id","layer","EditableTileMapLayer","push","EditableObjectLayer","x","y","tag","indexX","Math","floor","indexY","_b","undefined","hasTag","tileMap","AbstractEditableLayer","visible","_super","_this","objects","object","TileObject","FlippingHelper","getTileId","flippedHorizontally","setFlippedHorizontally","flippedVertically","setFlippedVertically","flippedDiagonally","setFlippedDiagonally","isFlippedHorizontally","isFlippedVertically","isFlippedDiagonally","tileIdMask","flippedHorizontallyFlag","flippedVerticallyFlag","flippedDiagonallyFlag","_tiles","getDimensionY","index","Int32Array","getDimensionX","getTileDefinition","console","error","row","getWidth","getHeight","animationLength","taggedHitBoxes","TileDefinition","polygon","taggedHitBox","find","hitbox","polygons","some","_cachedValues","Map","_callbacks","ResourceCache","key","load","callback","callbacks","set","delete","callbacks_1","callback_1","decodeBase64LayerData","pako","data","compression","decodedData","step1","atob","split","map","charCodeAt","decodeArray","arr","binData","Uint8Array","decompressedData","inflate","extractTileUidFlippedStates","globalTileUid","FLIPPED_HORIZONTALLY_FLAG","FLIPPED_VERTICALLY_FLAG","FLIPPED_DIAGONALLY_FLAG","getTileIdFromTiledGUI","tiledGUI","TiledTileMapLoader","tiledMap","tiledversion","warn","definitions","_f","tilesets","tiledSet","firstGid","firstgid","tiles","_h","tile","tileDefinition","animation","objectgroup","class","angle","rotation","PI","cos_1","cos","sin_1","sin","point","width","height","add","_k","tileheight","tilewidth","tileIndex","tilecount","has","collisionTileMap","_m","layers","tiledLayer","type","objectLayer","addObjectLayer","setVisible","_p","tiledObject","gid","tileGid","tileSlotIndex","layerData","encoding","collisionTileLayer","addTileLayer","tileUid","setTile","_textures","TileTextureCache","texture","_getGlobalId","rotate","PIXI","GlobalPIXIModule","PixiTileMapHelper","atlasTexture","getTexture","image","columns","spacing","margin","rows","expectedAtlasWidth","expectedAtlasHeight","textureCache","tileSetIndex","rect","Rectangle","Texture","setTexture","untypedPixiTileMap","displayMode","layerIndex","pixiTileMap","clear","_c","getLayers","isVisible","_e","findTileTexture","getPixiRotate","getTileHeight","tileLayer","getTileWidth","dimensionX","dimensionY","xPos","yPos","tileTexture","pixiTilemapFrame","getAnimationLength","tileAnimX","pixiGraphics","typeFilter","outlineSize","outlineColor","outlineOpacity","fillColor","fillOpacity","lineStyle","drawRect","hitboxes","getHitBoxes","hitboxes_1","vertices","beginFill","vertexX","vertexY","swap","moveTo","lineTo","closePath","endFill","_tileMapCache","_textureCacheCaches","TileMapManager","instanceHolder","tileMapCollisionMaskManager","loadTiledMap","tileMapJsonResourceName","tileSetJsonResourceName","getOrLoad","atlasImageResourceName","parseAtlas"],"mappings":"qPAgBA,IAAIA,EAAgB,SAASC,EAAGC,GAI5B,OAHAF,EAAgBG,OAAOC,gBAClB,CAAEC,UAAW,cAAgBC,OAAS,SAAUL,EAAGC,GAAKD,EAAEI,UAAYH,IACvE,SAAUD,EAAGC,GAAK,IAAK,IAAIK,KAAKL,EAAOC,OAAOK,UAAUC,eAAeC,KAAKR,EAAGK,KAAIN,EAAEM,GAAKL,EAAEK,KACzFP,EAAcC,EAAGC,IAGrB,SAASS,EAAUV,EAAGC,GACzB,GAAiB,mBAANA,GAA0B,OAANA,EAC3B,MAAM,IAAIU,UAAU,uBAAyBC,OAAOX,GAAK,iCAE7D,SAASY,IAAOC,KAAKC,YAAcf,EADnCD,EAAcC,EAAGC,GAEjBD,EAAEO,UAAkB,OAANN,EAAaC,OAAOc,OAAOf,IAAMY,EAAGN,UAAYN,EAAEM,UAAW,IAAIM,GA2F5E,SAASI,EAASC,GACrB,IAAIC,EAAsB,mBAAXC,QAAyBA,OAAOC,SAAUC,EAAIH,GAAKD,EAAEC,GAAII,EAAI,EAC5E,GAAID,EAAG,OAAOA,EAAEb,KAAKS,GACrB,GAAIA,GAAyB,iBAAbA,EAAEM,OAAqB,MAAO,CAC1CC,KAAM,WAEF,OAD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K,GAAO,GAG9B,GAAIP,EAAqB,CACvB,IAAM8K,EAAOF,EACbA,EAAUC,EACVA,EAAUC,EAERhL,IACF8K,EAAUxN,EAAYwN,GAEpB7K,IACF8K,EAAUxN,EAAawN,GAEX,IAAVtK,EACFuJ,EAAaiB,OAAOvB,EAAOoB,EAASnB,EAAOoB,GAE3Cf,EAAakB,OAAOxB,EAAOoB,EAASnB,EAAOoB,GAG/Cf,EAAamB,YACbnB,EAAaoB,uOC1QzB,aACE5O,KAAK6O,cAAgB,IAAIvJ,EACzBtF,KAAK8O,oBAAsB,IAAIxJ,EAkHnC,OA3GSyJ,aAAP,SAAkBC,GAQhB,OANKA,EAAeC,8BAGlBD,EAAeC,4BAA8B,IAAIF,GAG5CC,EAAeC,6BAUxBF,6BAAA,SACEG,EAKAC,EACAC,EACApJ,EACAP,GAEA,IAAMF,EAAM4J,EAA0B,IAAMC,EAE5CpP,KAAK6O,cAAcQ,UACjB9J,GACA,SAACE,GACCyJ,EACEC,EACAC,GACA,SAAC7H,GACC,GAAKA,EAAL,CAKA,IAAMiC,EAAmBlC,EAAmB9B,KAAKQ,EAAMuB,GACvD9B,EAAS+D,QALP/D,EAAS,WASjBA,IAYJsJ,kCAAA,SACEG,EAKA9D,EACAkE,EACAH,EACAC,EACA3J,GAEA,IAAMF,EACJ4J,EACA,IACAC,EACA,IACAE,EAEFtP,KAAK8O,oBAAoBO,UACvB9J,GACA,SAACE,GACCyJ,EACEC,EACAC,GACA,SAAC7H,GACC,GAAKA,EAAL,CAMA,IAAM4D,EAAemE,EACjBlE,EAAWkE,GACX,KACE1D,EAAeV,EAAkBqE,WACrChI,EACA4D,EACAC,GAEF3F,EAASmG,QAZPnG,EAAS,WAgBjBA"} \ No newline at end of file +{"version":3,"file":"TileMapHelper.js","sources":["../../../SharedLibs/TileMapHelper/node_modules/tslib/tslib.es6.js","../../../SharedLibs/src/model/GID.ts","../../../SharedLibs/src/model/TileMapModel.ts","../../../SharedLibs/src/render/ResourceCache.ts","../../../SharedLibs/src/render/TileTextureCache.ts","../../../SharedLibs/src/load/tiled/TiledTileMapLoaderHelper.ts","../../../SharedLibs/src/render/tiled/TiledPixiHelper.ts","../../../SharedLibs/src/load/ldtk/LDtkTileMapLoaderHelper.ts","../../../SharedLibs/src/render/ldtk/LDtkPixiHelper.ts","../../../SharedLibs/src/render/TileMapPixiHelper.ts","../../../SharedLibs/src/load/ldtk/LDtkTileMapLoader.ts","../../../SharedLibs/src/load/tiled/TiledTileMapLoader.ts","../../../SharedLibs/src/load/TileMapLoader.ts","../../../SharedLibs/src/render/TileMapManager.ts"],"sourcesContent":["/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n",null,null,null,null,null,null,null,null,null,null,null,null,null],"names":["extendStatics","d","b","Object","setPrototypeOf","__proto__","Array","p","prototype","hasOwnProperty","call","__extends","TypeError","String","__","this","constructor","create","__values","o","s","Symbol","iterator","m","i","length","next","value","done","__read","n","r","e","ar","push","error","__spreadArray","to","from","pack","arguments","l","slice","concat","FlippingHelper","FLIPPED_HORIZONTALLY_FLAG","FLIPPED_VERTICALLY_FLAG","FLIPPED_DIAGONALLY_FLAG","getPixiRotate","tileGID","flippedDiagonally","isFlippedDiagonally","flippedHorizontally","isFlippedHorizontally","flippedVertically","isFlippedVertically","rotate","getTileGID","tileId","tileIdMask","tileWidth","tileHeight","dimX","dimY","tileSet","_tileSet","_layers","EditableTileMap","get","values","id","layer","EditableTileMapLayer","EditableObjectLayer","_backgroundResourceName","x","y","tag","indexX","Math","floor","indexY","_b","getTileId","undefined","hasTaggedHitBox","resourceName","tileMap","AbstractEditableLayer","visible","_super","_this","objects","object","TileObject","setFlippedHorizontally","setFlippedVertically","setFlippedDiagonally","_tiles","getDimensionY","index","Int32Array","getDimensionX","_alpha","alpha","getTileDefinition","console","row","getWidth","getHeight","animationLength","taggedHitBoxes","stackedTiles","TileDefinition","polygon","taggedHitBox","find","hitbox","polygons","some","stackTileId","_i","tiles","_cachedValues","Map","_callbacks","ResourceCache","key","load","callback","callbacks","set","delete","callbacks_1","callback_1","_levelBackgroundTextures","_textures","TileTextureCache","texture","name","decodeBase64LayerData","pako","tiledLayer","data","compression","decodedData","step1","atob","split","map","charCodeAt","decodeArray","arr","binData","Uint8Array","decompressedData","inflate","extractTileUidFlippedStates","globalTileUid","getTileIdFromTiledGUI","tiledGUI","TiledPixiHelper","PIXI","GlobalPIXIModule","getLDtkTileId","tileSetId","uniqueId","levelIndex","atlasTexture","getTexture","tiledversion","warn","tilesets","tiledSet","tilewidth","tileheight","tilecount","image","columns","spacing","margin","firstGid","firstgid","rows","expectedAtlasWidth","expectedAtlasHeight","width","height","textureCache","tileSetIndex","rect","Rectangle","Texture","setTexture","LDtkPixiHelper","PixiTileMapHelper","LDtkTileMapLoader","TiledTileMapLoader","TileMapLoader","getAtlasTexture","atlasTextures","tilesetCache","tilesetId","tileset","relPath","baseTexture","cacheId","identifier","level","levels","layerInstances","_c","defs","uid","levelTileCache","iLayer","__type","__tilesetDefUid","atlasTexture_1","layerTileCache","gridSize","tileGridSize","_e","autoLayerTiles","gridTiles","tile","t","_g","src","bgRelPath","atlasTexture_2","pxWid","pxHei","setLevelBackgroundTexture","kind","parseAtlas","untypedPixiTileMap","displayMode","layerIndex","pixiTileMap","clear","bgResourceName","getBackgroundResourceName","getLevelBackgroundTexture","_d","getLayers","isVisible","objectLayer","_f","getTileHeight","tileLayer","getTileWidth","dimensionX","dimensionY","getAlpha","xPos","yPos","tileDefinition","hasStackedTiles","_h","getStackedTiles","tileGID_1","tileId_1","tileTexture","pixiTilemapFrame","getAnimationLength","tileAnimX","pixiGraphics","typeFilter","outlineSize","outlineColor","outlineOpacity","fillColor","fillOpacity","lineStyle","drawRect","hitboxes","getHitBoxes","hitboxes_1","vertices","beginFill","vertexX","vertexY","swap","moveTo","lineTo","closePath","endFill","ldtkTileMap","ldtkLevel","tileCache","has","tileDef","__gridSize","__cWid","__cHei","editableTileMap","composedTileMap","nextComposedTileId","gridSize_1","editableTileLayer","addTileLayer","setAlpha","__opacity","setVisible","px","oldTileId","setTile","f","oldTileDef","hash","join","getStackTileId","tileDef_1","setStackedTiles","oldTileGID","setBackgroundResourceName","tiledTileMap","definitions","tiledTileSet","animation","objectgroup","class","angle","rotation","PI","cos_1","cos","sin_1","sin","point","addHitBox","_k","tileIndex","collisionTileMap","_m","layers","type","addObjectLayer","_p","tiledObject","gid","tileGid","add","tileSlotIndex","layerData","encoding","collisionTileLayer","tileUid","_tileMapCache","_textureCacheCaches","TileMapManager","instanceHolder","tileMapCollisionMaskManager","info","__header__","app","log","loadTileMap","tileMapJsonResourceName","tileSetJsonResourceName","getOrLoad","atlasImageResourceName"],"mappings":"qPAgBA,IAAIA,EAAgB,SAASC,EAAGC,GAI5B,OAHAF,EAAgBG,OAAOC,gBAClB,CAAEC,UAAW,cAAgBC,OAAS,SAAUL,EAAGC,GAAKD,EAAEI,UAAYH,IACvE,SAAUD,EAA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9K,EAAeO,oBAAkBwC,WACrCpJ,EACAgF,EACAC,EACAC,GAEFxC,EAAS2D,QAbP3D,EAAS,WAiBjBA"} \ No newline at end of file diff --git a/Extensions/TileMap/helper/dts/index.d.ts b/Extensions/TileMap/helper/dts/index.d.ts index 67123021b0da..0c6bd0f074e6 100644 --- a/Extensions/TileMap/helper/dts/index.d.ts +++ b/Extensions/TileMap/helper/dts/index.d.ts @@ -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 diff --git a/Extensions/TileMap/helper/dts/index.d.ts.map b/Extensions/TileMap/helper/dts/index.d.ts.map index 74219ac2506f..ae56097a3ba0 100644 --- a/Extensions/TileMap/helper/dts/index.d.ts.map +++ b/Extensions/TileMap/helper/dts/index.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,cAAc,EACf,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAE/D,cAAc,qBAAqB,CAAC;AAEpC,OAAO,EAAE,eAAe,EAAE,CAAC;AAC3B,OAAO,EAAE,oBAAoB,EAAE,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,CAAC;AAE1B,OAAO,EAAE,QAAQ,EAAE,CAAC;AACpB,OAAO,EAAE,YAAY,EAAE,CAAC;AAExB,OAAO,EAAE,cAAc,EAAE,CAAC;AAC1B,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAC5B,OAAO,EAAE,iBAAiB,EAAE,CAAC"} \ No newline at end of file +{"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"} \ No newline at end of file diff --git a/Extensions/TileMap/helper/dts/load/TileMapLoader.d.ts b/Extensions/TileMap/helper/dts/load/TileMapLoader.d.ts new file mode 100644 index 000000000000..a7d652487f04 --- /dev/null +++ b/Extensions/TileMap/helper/dts/load/TileMapLoader.d.ts @@ -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 diff --git a/Extensions/TileMap/helper/dts/load/TileMapLoader.d.ts.map b/Extensions/TileMap/helper/dts/load/TileMapLoader.d.ts.map new file mode 100644 index 000000000000..68d601bfc9aa --- /dev/null +++ b/Extensions/TileMap/helper/dts/load/TileMapLoader.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"TileMapLoader.d.ts","sourceRoot":"","sources":["../../src/load/TileMapLoader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAInC,yBAAiB,aAAa,CAAC;IAC7B;;;;;;;OAOG;IACH,SAAgB,IAAI,CAClB,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,GAAG,GACR,eAAe,GAAG,IAAI,CAaxB;CACF"} \ No newline at end of file diff --git a/Extensions/TileMap/helper/dts/load/ldtk/LDtkFormat.d.ts b/Extensions/TileMap/helper/dts/load/ldtk/LDtkFormat.d.ts new file mode 100644 index 000000000000..ff6d77d8bf7d --- /dev/null +++ b/Extensions/TileMap/helper/dts/load/ldtk/LDtkFormat.d.ts @@ -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 declare type LDtkTileMap = { + /** LDtk application build identifier.
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.

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.

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).
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).

In a later update, it will be possible to have multiple Worlds in a single project, each containing multiple Levels.

What will change when \"Multiple worlds\" support will be added to LDtk:

- 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.
- 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).

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.

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.

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.

An enum that describes how levels are organized in this project (ie. linearly or in a 2D space). Possible values: <`null`>, `Free`, `GridVania`, `LinearHorizontal`, `LinearVertical` */ + worldLayout: + | 'Free' + | 'GridVania' + | 'LinearHorizontal' + | 'LinearVertical' + | null; +}; +/** Auto-layer rule group */ +declare 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. */ +declare type LDtkAutoRuleDef = {}; +/** If you're writing your own LDtk importer, you should probably just ignore *most* stuff in the `defs` section, as it contains data that are mostly important to the editor. To keep you away from the `defs` section and avoid some unnecessary JSON parsing, important data from definitions is often duplicated in fields prefixed with a double underscore (eg. `__identifier` or `__type`). The 2 only definition types you might need here are **Tilesets** and **Enums**. */ +declare 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 */ +declare 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`.
If the tileRenderMode is not NineSlice, then this array is empty.
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 */ +declare 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 */ +declare 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 */ +declare type LDtkEnumDefValues = { + /** An array of 4 Int values that refers to the tile in the tileset image: `[ x, y, width, height ]` */ + __tileSrcRect: integer[] | null; + /** Optional color */ + color: integer; + /** Enum value */ + id: string; + /** The optional ID of the tile */ + tileId: integer | null; +}; +/** In a tileset definition, enum based tag infos */ +declare type LDtkEnumTagValue = { + /** */ + enumValueId: string; + /** */ + tileIds: integer[]; +}; +/** This section is mostly only intended for the LDtk editor app itself. You can safely ignore it. */ +declare type LDtkFieldDef = { + /** Human readable value type. Possible values: `Int, Float, String, Bool, Color, ExternEnum.XXX, LocalEnum.XXX, Point, FilePath`.
If the field is an array, this field will look like `Array<...>` (eg. `Array`, `Array` etc.)
NOTE: if you enable the advanced option **Use Multilines type**, you will have \"*Multilines*\" instead of \"*String*\" when relevant. */ + __type: string; + /** Optional list of accepted file extensions for FilePath value type. Includes the dot: `.ext` */ + acceptFileTypes: string[] | null; + /** Possible values: `Any`, `OnlySame`, `OnlyTags` */ + allowedRefs: 'Any' | 'OnlySame' | 'OnlyTags'; + /** */ + allowedRefTags: string[]; + /** */ + allowOutOfLevelRef: boolean; + /** Array max length */ + arrayMaxLength: integer | null; + /** Array min length */ + arrayMinLength: integer | null; + /** */ + autoChainRef: boolean; + /** TRUE if the value can be null. For arrays, TRUE means it can contain null values (exception: array of Points can't have null values). */ + canBeNull: boolean; + /** Default value if selected value is null or invalid. */ + defaultOverride: any | null; + /** */ + editorAlwaysShow: boolean; + /** */ + editorCutLongValues: boolean; + /** Possible values: `Hidden`, `ValueOnly`, `NameAndValue`, `EntityTile`, `Points`, `PointStar`, `PointPath`, `PointPathLoop`, `RadiusPx`, `RadiusGrid`, `ArrayCountWithLabel`, `ArrayCountNoLabel`, `RefLinkBetweenPivots`, `RefLinkBetweenCenters` */ + editorDisplayMode: + | 'ArrayCountNoLabel' + | 'ArrayCountWithLabel' + | 'EntityTile' + | 'Hidden' + | 'NameAndValue' + | 'PointPath' + | 'PointPathLoop' + | 'PointStar' + | 'Points' + | 'RadiusGrid' + | 'RadiusPx' + | 'RefLinkBetweenCenters' + | 'RefLinkBetweenPivots' + | 'ValueOnly'; + /** Possible values: `Above`, `Center`, `Beneath` */ + editorDisplayPos: 'Above' | 'Beneath' | 'Center'; + /** */ + editorTextPrefix: string | null; + /** */ + editorTextSuffix: string | null; + /** User defined unique identifier */ + identifier: string; + /** TRUE if the value is an array of multiple values */ + isArray: boolean; + /** Max limit for value, if applicable */ + max: number | null; + /** Min limit for value, if applicable */ + min: number | null; + /** Optional regular expression that needs to be matched to accept values. Expected format: `/some_reg_ex/g`, with optional \"i\" flag. */ + regex: string | null; + /** */ + symmetricalRef: boolean; + /** Possible values: <`null`>, `LangPython`, `LangRuby`, `LangJS`, `LangLua`, `LangC`, `LangHaxe`, `LangMarkdown`, `LangJson`, `LangXml`, `LangLog` */ + textLanguageMode: + | 'LangC' + | 'LangHaxe' + | 'LangJS' + | 'LangJson' + | 'LangLog' + | 'LangLua' + | 'LangMarkdown' + | 'LangPython' + | 'LangRuby' + | 'LangXml' + | null; + /** UID of the tileset used for a Tile */ + tilesetUid: integer | null; + /** Internal enum representing the possible field types. Possible values: F_Int, F_Float, F_String, F_Text, F_Bool, F_Color, F_Enum(...), F_Point, F_Path, F_EntityRef, F_Tile */ + type: string; + /** Unique Int identifier */ + uid: integer; + /** If TRUE, the color associated with this field will override the Entity or Level default color in the editor UI. For Enum fields, this would be the color associated to their values. */ + useForSmartColor: boolean; +}; +/** Field instance */ +declare type LDtkFieldInstance = { + /** Field definition identifier */ + __identifier: string; + /** Optional TilesetRect used to display this field (this can be the field own Tile, or some other Tile guessed from the value, like an Enum). */ + __tile: LDtkTilesetRect | null; + /** Type of the field, such as `Int`, `Float`, `String`, `Enum(my_enum_name)`, `Bool`, etc.
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`:
- For **classic types** (ie. Integer, Float, Boolean, String, Text and FilePath), you just get the actual value with the expected type.
- For **Color**, the value is an hexadecimal string using \"#rrggbb\" format.
- For **Enum**, the value is a String representing the selected enum value.
- For **Point**, the value is a [GridPoint](#ldtk-GridPoint) object.
- For **Tile**, the value is a [TilesetRect](#ldtk-TilesetRect) object.
- For **EntityRef**, the value is an [EntityReferenceInfos](#ldtk-EntityReferenceInfos) object.

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[]; +}; +declare type LDtkFlag = + | 'DiscardPreCsvIntGrid' + | 'ExportPreCsvIntGridFormat' + | 'IgnoreBackupSuggest' + | 'PrependIndexToLevelFileNames' + | 'MultiWorlds' + | 'UseMultilinesType'; +/** IntGrid value definition */ +declare type LDtkIntGridValueDef = { + /** */ + color: string; + /** User defined unique identifier */ + identifier: string | null; + /** The IntGrid value itself */ + value: integer; +}; +/** IntGrid value instance */ +declare type LDtkIntGridValueInstance = { + /** Coordinate ID in the layer grid */ + coordId: integer; + /** IntGrid value */ + v: integer; +}; +/** Layer definition */ +declare 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.
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.
**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.
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 */ +declare 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.).

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).
Order is from left to right, and top to bottom (ie. first row from left to right, followed by second row, etc).
`0` means \"empty cell\" and IntGrid values start at 1.
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. */ +declare type LDtkLevel = { + /** Background color of the level (same as `bgColor`, except the default value is automatically used here if its value is `null`) */ + __bgColor: string; + /** Position informations of the background image, if there is one. */ + __bgPos: LDtkLevelBgPosInfos | null; + /** An array listing all other levels touching this one on the world map.
Only relevant for world layouts where level spatial positioning is manual (ie. GridVania, Free). For Horizontal and Vertical layouts, this array is always empty. */ + __neighbours: LDtkNeighbourLevel[]; + /** The \"guessed\" color for this level in the editor, decided using either the background color or an existing custom field. */ + __smartColor: string; + /** Background color of the level. If `null`, the project `defaultLevelBgColor` should be used. */ + bgColor: string | null; + /** Background image Y pivot (0-1) */ + bgPivotY: number; + /** Background image X pivot (0-1) */ + bgPivotX: number; + /** An enum defining the way the background image (if any) is positioned on the level. See `__bgPos` for resulting position info. Possible values: <`null`>, `Unscaled`, `Contain`, `Cover`, `CoverDirty` */ + bgPos: 'Unscaled' | 'Contain' | 'Cover' | 'CoverDirty' | null; + /** The *optional* relative path to the level background image. */ + bgRelPath: string | null; + /** This value is not null if the project option \"*Save levels separately*\" is enabled. In this case, this **relative** path points to the level Json file. */ + externalRelPath: string | null; + /** An array containing this level custom field values. */ + fieldInstances: LDtkFieldInstance[]; + /** User defined unique identifier */ + identifier: string; + /** Unique instance identifier */ + iid: string; + /** An array containing all Layer instances. **IMPORTANT**: if the project option \"*Save levels separately*\" is enabled, this field will be `null`.
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\".
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.
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.
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 */ +declare type LDtkLevelBgPosInfos = { + /** An array of 4 float values describing the cropped sub-rectangle of the displayed background image. This cropping happens when original is larger than the level bounds. Array format: `[ cropX, cropY, cropWidth, cropHeight ]` */ + cropRect: number[]; + /** An array containing the `[scaleX,scaleY]` values of the **cropped** background image, depending on `bgPos` option. */ + 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 */ +declare type LDtkNeighbourLevel = { + /** A single lowercase character tipping on the level location (`n`orth, `s`outh, `w`est, `e`ast). */ + dir: string; + /** Neighbour Instance Identifier */ + 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. */ +declare type LDtkTile = { + /** Internal data used by the editor.
For auto-layer tiles: `[ruleId, coordId]`.
For tile-layer tiles: `[coordId]`. */ + d: integer[]; + /** \"Flip bits\", a 2-bits integer to represent the mirror transformations of the tile.
- Bit 0 = X flip
- Bit 1 = Y flip
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 declare type LDtkTilesetDef = { + /** Grid-based height */ + __cHei: integer; + /** Grid-based width */ + __cWid: integer; + /** The following data is used internally for various optimizations. It's always synced with source image changes. */ + cachedPixelData: object | null; + /** An array of custom tile metadata */ + customData: LDtkTileCustomMetadata[]; + /** If this value is set, then it means that this atlas uses an internal LDtk atlas image instead of a loaded one. Possible values: <`null`>, `LdtkIcons` */ + embedAtlas: 'LdtkIcons' | null; + /** Tileset tags using Enum values specified by `tagsSourceEnumId`. This array contains 1 element per Enum value, which contains an array of all Tile IDs that are tagged with it. */ + enumTags: LDtkEnumTagValue[]; + /** User defined unique identifier */ + identifier: string; + /** Distance in pixels from image borders */ + padding: integer; + /** Image height in pixels */ + pxHei: integer; + /** Image width in pixels */ + pxWid: integer; + /** Path to the source file, relative to the current project JSON file
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. */ +declare type LDtkTileCustomMetadata = { + /** */ + data: string; + /** */ + tileId: integer; +}; +/** This object represents a custom sub rectangle in a Tileset image. */ +declare 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; +}; +declare type LDtkWorld = {}; +export {}; +//# sourceMappingURL=LDtkFormat.d.ts.map diff --git a/Extensions/TileMap/helper/dts/load/ldtk/LDtkFormat.d.ts.map b/Extensions/TileMap/helper/dts/load/ldtk/LDtkFormat.d.ts.map new file mode 100644 index 000000000000..fa42662d113a --- /dev/null +++ b/Extensions/TileMap/helper/dts/load/ldtk/LDtkFormat.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"LDtkFormat.d.ts","sourceRoot":"","sources":["../../../src/load/ldtk/LDtkFormat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAElD;;GAEG;AACH,oBAAY,WAAW,GAAG;IACxB,+WAA+W;IAC/W,UAAU,EAAE,MAAM,CAAC;IACnB,oEAAoE;IACpE,WAAW,EAAE,OAAO,CAAC;IACrB,0FAA0F;IAC1F,YAAY,EAAE,OAAO,CAAC;IACtB,+BAA+B;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,uCAAuC;IACvC,eAAe,EAAE,OAAO,CAAC;IACzB,yCAAyC;IACzC,mBAAmB,EAAE,MAAM,CAAC;IAC5B,uPAAuP;IACvP,kBAAkB,EAAE,OAAO,GAAG,IAAI,CAAC;IACnC,sPAAsP;IACtP,iBAAiB,EAAE,OAAO,GAAG,IAAI,CAAC;IAClC,gDAAgD;IAChD,aAAa,EAAE,MAAM,CAAC;IACtB,gDAAgD;IAChD,aAAa,EAAE,MAAM,CAAC;IACtB,iEAAiE;IACjE,IAAI,EAAE,cAAc,CAAC;IACrB,mHAAmH;IACnH,SAAS,EAAE,OAAO,GAAG,IAAI,CAAC;IAC1B,+GAA+G;IAC/G,WAAW,EAAE,OAAO,CAAC;IACrB,+HAA+H;IAC/H,cAAc,EAAE,OAAO,CAAC;IACxB,gPAAgP;IAChP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AAM,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,wEAAwE;AACxE,aAAK,eAAe,GAAG;IACrB,uBAAuB;IACvB,CAAC,EAAE,OAAO,CAAC;IACX,yBAAyB;IACzB,UAAU,EAAE,OAAO,CAAC;IACpB,sBAAsB;IACtB,CAAC,EAAE,OAAO,CAAC;IACX,sEAAsE;IACtE,CAAC,EAAE,OAAO,CAAC;IACX,sEAAsE;IACtE,CAAC,EAAE,OAAO,CAAC;CACZ,CAAC;AAEF,aAAK,SAAS,GAAG,EAAE,CAAC"} \ No newline at end of file diff --git a/Extensions/TileMap/helper/dts/load/ldtk/LDtkTileMapLoader.d.ts b/Extensions/TileMap/helper/dts/load/ldtk/LDtkTileMapLoader.d.ts new file mode 100644 index 000000000000..1a3839f1c28a --- /dev/null +++ b/Extensions/TileMap/helper/dts/load/ldtk/LDtkTileMapLoader.d.ts @@ -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 diff --git a/Extensions/TileMap/helper/dts/load/ldtk/LDtkTileMapLoader.d.ts.map b/Extensions/TileMap/helper/dts/load/ldtk/LDtkTileMapLoader.d.ts.map new file mode 100644 index 000000000000..2d10c516a27d --- /dev/null +++ b/Extensions/TileMap/helper/dts/load/ldtk/LDtkTileMapLoader.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"LDtkTileMapLoader.d.ts","sourceRoot":"","sources":["../../../src/load/ldtk/LDtkTileMapLoader.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAkB,MAAM,0BAA0B,CAAC;AAE3E,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAG3C,yBAAiB,iBAAiB,CAAC;IACjC;;;;;;OAMG;IACH,SAAgB,IAAI,CAClB,WAAW,EAAE,WAAW,EACxB,UAAU,EAAE,MAAM,GACjB,eAAe,GAAG,IAAI,CA6IxB;CACF"} \ No newline at end of file diff --git a/Extensions/TileMap/helper/dts/load/ldtk/LDtkTileMapLoaderHelper.d.ts b/Extensions/TileMap/helper/dts/load/ldtk/LDtkTileMapLoaderHelper.d.ts new file mode 100644 index 000000000000..98ebe841edaf --- /dev/null +++ b/Extensions/TileMap/helper/dts/load/ldtk/LDtkTileMapLoaderHelper.d.ts @@ -0,0 +1,5 @@ +export declare function getLDtkTileId( + tileSetId: number, + tileId: number +): number; +//# sourceMappingURL=LDtkTileMapLoaderHelper.d.ts.map diff --git a/Extensions/TileMap/helper/dts/load/ldtk/LDtkTileMapLoaderHelper.d.ts.map b/Extensions/TileMap/helper/dts/load/ldtk/LDtkTileMapLoaderHelper.d.ts.map new file mode 100644 index 000000000000..54cde5f7bd4a --- /dev/null +++ b/Extensions/TileMap/helper/dts/load/ldtk/LDtkTileMapLoaderHelper.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"LDtkTileMapLoaderHelper.d.ts","sourceRoot":"","sources":["../../../src/load/ldtk/LDtkTileMapLoaderHelper.ts"],"names":[],"mappings":"AAAA,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAQvE"} \ No newline at end of file diff --git a/Extensions/TileMap/helper/dts/tiled/TiledFormat.d.ts b/Extensions/TileMap/helper/dts/load/tiled/TiledFormat.d.ts similarity index 98% rename from Extensions/TileMap/helper/dts/tiled/TiledFormat.d.ts rename to Extensions/TileMap/helper/dts/load/tiled/TiledFormat.d.ts index 0b9524bd317e..40443cb322cd 100644 --- a/Extensions/TileMap/helper/dts/tiled/TiledFormat.d.ts +++ b/Extensions/TileMap/helper/dts/load/tiled/TiledFormat.d.ts @@ -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 declare type TiledTileMap = { /** Hex-formatted color (#RRGGBB or #AARRGGBB) (optional) */ backgroundcolor?: string; /** The compression level to use for tile layer data (defaults to -1, which means to use the algorithm default) */ diff --git a/Extensions/TileMap/helper/dts/load/tiled/TiledFormat.d.ts.map b/Extensions/TileMap/helper/dts/load/tiled/TiledFormat.d.ts.map new file mode 100644 index 000000000000..b0e57b8f4f36 --- /dev/null +++ b/Extensions/TileMap/helper/dts/load/tiled/TiledFormat.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"TiledFormat.d.ts","sourceRoot":"","sources":["../../../src/load/tiled/TiledFormat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAEzD;;GAEG;AACH,oBAAY,YAAY,GAAG;IACzB,4DAA4D;IAC5D,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB,kHAAkH;IAClH,gBAAgB,EAAE,OAAO,CAAC;IAE1B,0BAA0B;IAC1B,MAAM,EAAE,OAAO,CAAC;IAEhB,uEAAuE;IACvE,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB,8CAA8C;IAC9C,QAAQ,EAAE,OAAO,CAAC;IAElB,kCAAkC;IAClC,MAAM,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;IAE1B,qCAAqC;IACrC,WAAW,EAAE,OAAO,CAAC;IAErB,6CAA6C;IAC7C,YAAY,EAAE,OAAO,CAAC;IAEtB,4DAA4D;IAC5D,WAAW,EAAE,MAAM,CAAC;IAEpB,qCAAqC;IACrC,UAAU,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC;IAElC,sHAAsH;IACtH,WAAW,EAAE,MAAM,CA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AC;CAChB,CAAC;AAEF,oBAAY,aAAa,GAAG;IAC1B,2BAA2B;IAC3B,IAAI,EAAE,MAAM,CAAC;IAEb,sJAAsJ;IACtJ,IAAI,EAAE,MAAM,CAAC;IAEb,4BAA4B;IAC5B,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;CACxB,CAAC;AAEF,oBAAY,UAAU,GAAG;IACvB,6BAA6B;IAC7B,CAAC,EAAE,KAAK,CAAC;IAET,6BAA6B;IAC7B,CAAC,EAAE,KAAK,CAAC;CACV,CAAC"} \ No newline at end of file diff --git a/Extensions/TileMap/helper/dts/load/tiled/TiledTileMapLoader.d.ts b/Extensions/TileMap/helper/dts/load/tiled/TiledTileMapLoader.d.ts new file mode 100644 index 000000000000..07ae3dbf65a9 --- /dev/null +++ b/Extensions/TileMap/helper/dts/load/tiled/TiledTileMapLoader.d.ts @@ -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 diff --git a/Extensions/TileMap/helper/dts/load/tiled/TiledTileMapLoader.d.ts.map b/Extensions/TileMap/helper/dts/load/tiled/TiledTileMapLoader.d.ts.map new file mode 100644 index 000000000000..6fc8cb617fc5 --- /dev/null +++ b/Extensions/TileMap/helper/dts/load/tiled/TiledTileMapLoader.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"TiledTileMapLoader.d.ts","sourceRoot":"","sources":["../../../src/load/tiled/TiledTileMapLoader.ts"],"names":[],"mappings":"AACA,OAAO,EACL,eAAe,EAGhB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAO7C;;GAEG;AACH,yBAAiB,kBAAkB,CAAC;IAClC;;;;;;OAMG;IACH,SAAgB,IAAI,CAClB,YAAY,EAAE,YAAY,EAC1B,IAAI,EAAE,GAAG,GACR,eAAe,GAAG,IAAI,CAyKxB;CACF"} \ No newline at end of file diff --git a/Extensions/TileMap/helper/dts/tiled/TiledTileMapLoader.spec.d.ts b/Extensions/TileMap/helper/dts/load/tiled/TiledTileMapLoader.spec.d.ts similarity index 100% rename from Extensions/TileMap/helper/dts/tiled/TiledTileMapLoader.spec.d.ts rename to Extensions/TileMap/helper/dts/load/tiled/TiledTileMapLoader.spec.d.ts diff --git a/Extensions/TileMap/helper/dts/load/tiled/TiledTileMapLoader.spec.d.ts.map b/Extensions/TileMap/helper/dts/load/tiled/TiledTileMapLoader.spec.d.ts.map new file mode 100644 index 000000000000..28e59292887b --- /dev/null +++ b/Extensions/TileMap/helper/dts/load/tiled/TiledTileMapLoader.spec.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"TiledTileMapLoader.spec.d.ts","sourceRoot":"","sources":["../../../src/load/tiled/TiledTileMapLoader.spec.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/Extensions/TileMap/helper/dts/tiled/TiledLoaderHelper.d.ts b/Extensions/TileMap/helper/dts/load/tiled/TiledTileMapLoaderHelper.d.ts similarity index 75% rename from Extensions/TileMap/helper/dts/tiled/TiledLoaderHelper.d.ts rename to Extensions/TileMap/helper/dts/load/tiled/TiledTileMapLoaderHelper.d.ts index 76706edeb1b1..1820155bc7f0 100644 --- a/Extensions/TileMap/helper/dts/tiled/TiledLoaderHelper.d.ts +++ b/Extensions/TileMap/helper/dts/load/tiled/TiledTileMapLoaderHelper.d.ts @@ -1,16 +1,16 @@ -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 = { id: integer; @@ -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 diff --git a/Extensions/TileMap/helper/dts/load/tiled/TiledTileMapLoaderHelper.d.ts.map b/Extensions/TileMap/helper/dts/load/tiled/TiledTileMapLoaderHelper.d.ts.map new file mode 100644 index 000000000000..a90bb91bcb68 --- /dev/null +++ b/Extensions/TileMap/helper/dts/load/tiled/TiledTileMapLoaderHelper.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"TiledTileMapLoaderHelper.d.ts","sourceRoot":"","sources":["../../../src/load/tiled/TiledTileMapLoaderHelper.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,SAAU,GAAG,cAAc,UAAU,aAgDtE,CAAC;AAEF,oBAAY,QAAQ,GAAG;IACrB,EAAE,EAAE,OAAO,CAAC;IACZ,mBAAmB,EAAE,OAAO,CAAC;IAC7B,iBAAiB,EAAE,OAAO,CAAC;IAC3B,iBAAiB,EAAE,OAAO,CAAC;CAC5B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,2BAA2B,kBACvB,OAAO,KACrB,QAmBF,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,MAAM,GAAG,SAAS,GAC3B,MAAM,GAAG,SAAS,CAEpB"} \ No newline at end of file diff --git a/Extensions/TileMap/helper/dts/model/GID.d.ts b/Extensions/TileMap/helper/dts/model/GID.d.ts new file mode 100644 index 000000000000..d2555f6af885 --- /dev/null +++ b/Extensions/TileMap/helper/dts/model/GID.d.ts @@ -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 diff --git a/Extensions/TileMap/helper/dts/model/GID.d.ts.map b/Extensions/TileMap/helper/dts/model/GID.d.ts.map new file mode 100644 index 000000000000..ef98bf235121 --- /dev/null +++ b/Extensions/TileMap/helper/dts/model/GID.d.ts.map @@ -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"} \ No newline at end of file diff --git a/Extensions/TileMap/helper/dts/model/TileMapModel.d.ts b/Extensions/TileMap/helper/dts/model/TileMapModel.d.ts index ec157bf49b22..e2062a2911e5 100644 --- a/Extensions/TileMap/helper/dts/model/TileMapModel.d.ts +++ b/Extensions/TileMap/helper/dts/model/TileMapModel.d.ts @@ -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 diff --git a/Extensions/TileMap/helper/dts/model/TileMapModel.d.ts.map b/Extensions/TileMap/helper/dts/model/TileMapModel.d.ts.map index 78d0d1eeba92..e844bc9121e4 100644 --- a/Extensions/TileMap/helper/dts/model/TileMapModel.d.ts.map +++ b/Extensions/TileMap/helper/dts/model/TileMapModel.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"TileMapModel.d.ts","sourceRoot":"","sources":["../../src/model/TileMapModel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEhE;;;;;;;GAOG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CA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IACH,eAAe,IAAI,OAAO;IAI1B;;;OAGG;IACH,eAAe,CAAC,WAAW,EAAE,OAAO,EAAE,GAAG,KAAK,EAAE,OAAO,EAAE,GAAG,IAAI;CAIjE"} \ No newline at end of file diff --git a/Extensions/TileMap/helper/dts/render/TileMapManager.d.ts b/Extensions/TileMap/helper/dts/render/TileMapManager.d.ts index 9f3fd97fc78b..f2d4c833d85e 100644 --- a/Extensions/TileMap/helper/dts/render/TileMapManager.d.ts +++ b/Extensions/TileMap/helper/dts/render/TileMapManager.d.ts @@ -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, atlasImageResourceName: string, tileMapJsonResourceName: string, tileSetJsonResourceName: string, + levelIndex: number, callback: (textureCache: TileTextureCache | null) => void ): void; } diff --git a/Extensions/TileMap/helper/dts/render/TileMapManager.d.ts.map b/Extensions/TileMap/helper/dts/render/TileMapManager.d.ts.map index 4d4b67a18f45..10f372990b37 100644 --- a/Extensions/TileMap/helper/dts/render/TileMapManager.d.ts.map +++ b/Extensions/TileMap/helper/dts/render/TileMapManager.d.ts.map @@ -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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I,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"} \ No newline at end of file diff --git a/Extensions/TileMap/helper/dts/render/TileMapPixiHelper.d.ts b/Extensions/TileMap/helper/dts/render/TileMapPixiHelper.d.ts index de9ac20b1d2b..5aec1b168d95 100644 --- a/Extensions/TileMap/helper/dts/render/TileMapPixiHelper.d.ts +++ b/Extensions/TileMap/helper/dts/render/TileMapPixiHelper.d.ts @@ -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 | null, getTexture: (textureName: string) => PIXI.BaseTexture ): 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, diff --git a/Extensions/TileMap/helper/dts/render/TileMapPixiHelper.d.ts.map b/Extensions/TileMap/helper/dts/render/TileMapPixiHelper.d.ts.map index 1bab8d927537..4d0133c71945 100644 --- a/Extensions/TileMap/helper/dts/render/TileMapPixiHelper.d.ts.map +++ b/Extensions/TileMap/helper/dts/render/TileMapPixiHelper.d.ts.map @@ -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"} \ No newline at end of file +{"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"} \ No newline at end of file diff --git a/Extensions/TileMap/helper/dts/render/TileTextureCache.d.ts b/Extensions/TileMap/helper/dts/render/TileTextureCache.d.ts index 91b62ba80025..e8d7dd8029aa 100644 --- a/Extensions/TileMap/helper/dts/render/TileTextureCache.d.ts +++ b/Extensions/TileMap/helper/dts/render/TileTextureCache.d.ts @@ -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 diff --git a/Extensions/TileMap/helper/dts/render/TileTextureCache.d.ts.map b/Extensions/TileMap/helper/dts/render/TileTextureCache.d.ts.map index b50a7ee19c9b..31e9451ae16d 100644 --- a/Extensions/TileMap/helper/dts/render/TileTextureCache.d.ts.map +++ b/Extensions/TileMap/helper/dts/render/TileTextureCache.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"TileTextureCache.d.ts","sourceRoot":"","sources":["../../src/render/TileTextureCache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE/C,OAAO,IAAI,GAAG,gBAAgB,CAAC,IAAI,CAAC;AAEpC;;;;;GAKG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,uBAAuB,CAAc;IAC7D,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,qBAAqB,CAAc;IAC3D,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,qBAAqB,CAAc;IAE3D,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA6B;;IAMvD,UAAU,CACR,MAAM,EAAE,OAAO,EACf,mBAAmB,EAAE,OAAO,EAC5B,iBAAiB,EAAE,OAAO,EAC1B,iBAAiB,EAAE,OAAO,EAC1B,OAAO,EAAE,IAAI,CAAC,OAAO,GACpB,IAAI;IAUP;;;;;OAKG;IACH,eAAe,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC,OAAO,GAAG,SAAS;IAI1D;;;;;;;;;;OAUG;IACH,aAAa,CACX,mBAAmB,EAAE,OAAO,EAC5B,iBAAiB,EAAE,OAAO,EAC1B,iBAAiB,EAAE,OAAO,GACzB,MAAM;IAwBT;;OAEG;IACH,OAAO,CAAC,YAAY;CAkBrB"} \ No newline at end of file +{"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"} \ No newline at end of file diff --git a/Extensions/TileMap/helper/dts/render/ldtk/LDtkPixiHelper.d.ts b/Extensions/TileMap/helper/dts/render/ldtk/LDtkPixiHelper.d.ts new file mode 100644 index 000000000000..dd88f8c8658c --- /dev/null +++ b/Extensions/TileMap/helper/dts/render/ldtk/LDtkPixiHelper.d.ts @@ -0,0 +1,26 @@ +import { TileTextureCache } from '../TileTextureCache'; +import { LDtkTileMap } from '../../load/ldtk/LDtkFormat'; +import PIXI = GlobalPIXIModule.PIXI; +declare type Texture = PIXI.BaseTexture; +declare type TextureLoader = ( + textureName: string +) => PIXI.BaseTexture; +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 diff --git a/Extensions/TileMap/helper/dts/render/ldtk/LDtkPixiHelper.d.ts.map b/Extensions/TileMap/helper/dts/render/ldtk/LDtkPixiHelper.d.ts.map new file mode 100644 index 000000000000..7b9278c572d4 --- /dev/null +++ b/Extensions/TileMap/helper/dts/render/ldtk/LDtkPixiHelper.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"LDtkPixiHelper.d.ts","sourceRoot":"","sources":["../../../src/render/ldtk/LDtkPixiHelper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAkB,MAAM,4BAA4B,CAAC;AAEzE,OAAO,IAAI,GAAG,gBAAgB,CAAC,IAAI,CAAC;AAEpC,aAAK,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AAC/C,aAAK,aAAa,GAAG,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AAmC9E,yBAAiB,cAAc,CAAC;IAC9B;;;;;;;;OAQG;IACH,SAAgB,UAAU,CACxB,OAAO,EAAE,WAAW,EACpB,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,OAAO,GAAG,IAAI,EAC5B,UAAU,EAAE,aAAa,GACxB,gBAAgB,GAAG,IAAI,CAoFzB;CACF"} \ No newline at end of file diff --git a/Extensions/TileMap/helper/dts/render/tiled/TiledPixiHelper.d.ts b/Extensions/TileMap/helper/dts/render/tiled/TiledPixiHelper.d.ts new file mode 100644 index 000000000000..f0d2d4f0462b --- /dev/null +++ b/Extensions/TileMap/helper/dts/render/tiled/TiledPixiHelper.d.ts @@ -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 | null, + getTexture: (textureName: string) => PIXI.BaseTexture + ): TileTextureCache | null; +} +//# sourceMappingURL=TiledPixiHelper.d.ts.map diff --git a/Extensions/TileMap/helper/dts/render/tiled/TiledPixiHelper.d.ts.map b/Extensions/TileMap/helper/dts/render/tiled/TiledPixiHelper.d.ts.map new file mode 100644 index 000000000000..e270cc6801d8 --- /dev/null +++ b/Extensions/TileMap/helper/dts/render/tiled/TiledPixiHelper.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"TiledPixiHelper.d.ts","sourceRoot":"","sources":["../../../src/render/tiled/TiledPixiHelper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAE5D,OAAO,IAAI,GAAG,gBAAgB,CAAC,IAAI,CAAC;AAEpC,yBAAiB,eAAe,CAAC;IAC/B;;;;;;;;OAQG;IACH,SAAgB,UAAU,CACxB,OAAO,EAAE,YAAY,EACrB,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,IAAI,EACpD,UAAU,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,GACnE,gBAAgB,GAAG,IAAI,CA2FzB;CACF"} \ No newline at end of file diff --git a/Extensions/TileMap/helper/dts/tiled/Tiled.d.ts b/Extensions/TileMap/helper/dts/tiled/Tiled.d.ts deleted file mode 100644 index 0840a202bae7..000000000000 --- a/Extensions/TileMap/helper/dts/tiled/Tiled.d.ts +++ /dev/null @@ -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; - /** 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; - /** `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; - /** 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; - /** `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 | 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; - /** Name assigned to this layer */ - name: string; - /** Array of {@link TiledObject}. `objectgroup` only. */ - objects?: Array; - /** 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; - /** 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 | 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; - /** Array of {@link TiledPoint}, in case the object is a polyline */ - polyline?: Array; - /** Array of {@link TiledProperty} */ - properties?: Array; - /** 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; - /** 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; - /** 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; - /** 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; -}; -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; - /** 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; - /** Index of terrain for each corner of tile (optional) */ - terrain?: Array; - /** 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; - /** Local ID of tile representing terrain */ - tile: integer; -}; -export declare type TiledWangSet = { - /** Array of {@link TiledWangColor} */ - colors: Array; - /** Name of the Wang set */ - name: string; - /** Array of {@link TiledProperty} */ - properties: Array; - /** Local ID of tile representing the Wang set */ - tile: integer; - /** Array of {@link TiledWangTile} */ - wangtiles: Array; -}; -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; - /** 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; -}; -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 diff --git a/Extensions/TileMap/helper/dts/tiled/Tiled.d.ts.map b/Extensions/TileMap/helper/dts/tiled/Tiled.d.ts.map deleted file mode 100644 index fd4ee9456197..000000000000 --- a/Extensions/TileMap/helper/dts/tiled/Tiled.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"Tiled.d.ts","sourceRoot":"","sources":["../../src/tiled/Tiled.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAEtD;;GAEG;AACH,oBAAY,QAAQ,GAAG;IACrB,4DAA4D;IAC5D,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB,kHAAkH;IAClH,gBAAgB,EAAE,OAAO,CAAC;IAE1B,0BAA0B;IAC1B,MAAM,EAAE,OAAO,CAAC;IAEhB,uEAAuE;IACvE,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB,8CAA8C;IAC9C,QAAQ,EAAE,OAAO,CAAC;IAElB,kCAAkC;IAClC,MAAM,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;IAE1B,qCAAqC;IACrC,WAAW,EAAE,OAAO,CAAC;IAErB,6CAA6C;IAC7C,YAAY,EAAE,OAAO,CAAC;IAEtB,4DAA4D;IAC5D,WAAW,EAAE,MAAM,CAAC;IAEpB,qCAAqC;IACrC,UAAU,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC;IAElC,sHAAsH;IACtH,WAAW,EAAE,MAAM,CAAC;IAEpB,mDAAmD;IACnD,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,wDAAwD;IACxD,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,8CAA8C;IAC9C,YAAY,EAAE,MAAM,CAAC;IAErB,sBAAsB;IACtB,UAAU,EAAE,OAAO,CAAC;IAEpB,oCAAoC;IACpC,QAAQ,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC;IAE9B,q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6B;IAC7B,CAAC,EAAE,KAAK,CAAC;CACV,CAAC"} \ No newline at end of file diff --git a/Extensions/TileMap/helper/dts/tiled/TiledFormat.d.ts.map b/Extensions/TileMap/helper/dts/tiled/TiledFormat.d.ts.map deleted file mode 100644 index b1dbad5d859e..000000000000 --- a/Extensions/TileMap/helper/dts/tiled/TiledFormat.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"TiledFormat.d.ts","sourceRoot":"","sources":["../../src/tiled/TiledFormat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAEtD;;GAEG;AACH,oBAAY,QAAQ,GAAG;IACrB,4DAA4D;IAC5D,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB,kHAAkH;IAClH,gBAAgB,EAAE,OAAO,CAAC;IAE1B,0BAA0B;IAC1B,MAAM,EAAE,OAAO,CAAC;IAEhB,uEAAuE;IACvE,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB,8CAA8C;IAC9C,QAAQ,EAAE,OAAO,CAAC;IAElB,kCAAkC;IAClC,MAAM,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;IAE1B,qCAAqC;IACrC,WAAW,EAAE,OAAO,CAAC;IAErB,6CAA6C;IAC7C,YAAY,EAAE,OAAO,CAAC;IAEtB,4DAA4D;IAC5D,WAAW,EAAE,MAAM,CAAC;IAEpB,qCAAqC;IACrC,UAAU,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC;IAElC,sHAAsH;IACtH,WAAW,EAAE,MAAM,CAAC;IAEpB,mDAAmD;IACnD,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,wDAAwD;IACxD,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,8CAA8C;IAC9C,YAAY,EAAE,MAAM,CAAC;IAErB,sBAAsB;IACtB,UAAU,EAAE,OAAO,CAAC;IAEpB,oCAAoC;IACpC,QAAQ,EAAE,KAAK,CAAC,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IAC7B,CAAC,EAAE,KAAK,CAAC;IAET,6BAA6B;IAC7B,CAAC,EAAE,KAAK,CAAC;CACV,CAAC"} \ No newline at end of file diff --git a/Extensions/TileMap/helper/dts/tiled/TiledLoaderHelper.d.ts.map b/Extensions/TileMap/helper/dts/tiled/TiledLoaderHelper.d.ts.map deleted file mode 100644 index 5b03aa9a602d..000000000000 --- a/Extensions/TileMap/helper/dts/tiled/TiledLoaderHelper.d.ts.map +++ /dev/null @@ -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"} \ No newline at end of file diff --git a/Extensions/TileMap/helper/dts/tiled/TiledTileMapLoader.d.ts b/Extensions/TileMap/helper/dts/tiled/TiledTileMapLoader.d.ts deleted file mode 100644 index a6ef645548ff..000000000000 --- a/Extensions/TileMap/helper/dts/tiled/TiledTileMapLoader.d.ts +++ /dev/null @@ -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 diff --git a/Extensions/TileMap/helper/dts/tiled/TiledTileMapLoader.d.ts.map b/Extensions/TileMap/helper/dts/tiled/TiledTileMapLoader.d.ts.map deleted file mode 100644 index a92c55a3ffde..000000000000 --- a/Extensions/TileMap/helper/dts/tiled/TiledTileMapLoader.d.ts.map +++ /dev/null @@ -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"} \ No newline at end of file diff --git a/Extensions/TileMap/helper/dts/tiled/TiledTileMapLoader.spec.d.ts.map b/Extensions/TileMap/helper/dts/tiled/TiledTileMapLoader.spec.d.ts.map deleted file mode 100644 index 8af6cb0f1ea0..000000000000 --- a/Extensions/TileMap/helper/dts/tiled/TiledTileMapLoader.spec.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"TiledTileMapLoader.spec.d.ts","sourceRoot":"","sources":["../../src/tiled/TiledTileMapLoader.spec.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/Extensions/TileMap/helper/dts/types/index.d.ts b/Extensions/TileMap/helper/dts/types/index.d.ts new file mode 100644 index 000000000000..a8d0a2410a8b --- /dev/null +++ b/Extensions/TileMap/helper/dts/types/index.d.ts @@ -0,0 +1,12 @@ +import { LDtkTileMap } from '../load/ldtk/LDtkFormat'; +import { TiledTileMap } from '../load/tiled/TiledFormat'; +export declare type TileMap = + | { + kind: 'tiled'; + data: TiledTileMap; + } + | { + kind: 'ldtk'; + data: LDtkTileMap; + }; +//# sourceMappingURL=index.d.ts.map diff --git a/Extensions/TileMap/helper/dts/types/index.d.ts.map b/Extensions/TileMap/helper/dts/types/index.d.ts.map new file mode 100644 index 000000000000..22cb60590b22 --- /dev/null +++ b/Extensions/TileMap/helper/dts/types/index.d.ts.map @@ -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,oBAAY,OAAO,GACf;IACE,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE,YAAY,CAAC;CACpB,GACD;IACE,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,WAAW,CAAC;CACnB,CAAC"} \ No newline at end of file diff --git a/Extensions/TileMap/tilemapcollisionmaskruntimeobject.ts b/Extensions/TileMap/tilemapcollisionmaskruntimeobject.ts index ef4529659f9e..b2c9a899d85a 100644 --- a/Extensions/TileMap/tilemapcollisionmaskruntimeobject.ts +++ b/Extensions/TileMap/tilemapcollisionmaskruntimeobject.ts @@ -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. diff --git a/Extensions/TileMap/tilemapruntimeobject.ts b/Extensions/TileMap/tilemapruntimeobject.ts index 5d621574642a..51e287de6886 100644 --- a/Extensions/TileMap/tilemapruntimeobject.ts +++ b/Extensions/TileMap/tilemapruntimeobject.ts @@ -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; } diff --git a/Extensions/TiledSpriteObject/TiledSpriteObject.cpp b/Extensions/TiledSpriteObject/TiledSpriteObject.cpp index 7916e3781b30..832be4367e73 100644 --- a/Extensions/TiledSpriteObject/TiledSpriteObject.cpp +++ b/Extensions/TiledSpriteObject/TiledSpriteObject.cpp @@ -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 diff --git a/Extensions/TiledSpriteObject/TiledSpriteObject.h b/Extensions/TiledSpriteObject/TiledSpriteObject.h index a66aedba3f32..f7dce245ace8 100644 --- a/Extensions/TiledSpriteObject/TiledSpriteObject.h +++ b/Extensions/TiledSpriteObject/TiledSpriteObject.h @@ -26,9 +26,7 @@ class GD_EXTENSION_API TiledSpriteObject : public gd::ObjectConfiguration { return gd::make_unique(*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; }; diff --git a/GDJS/Runtime/jsonmanager.ts b/GDJS/Runtime/jsonmanager.ts index c7eb1dbf354a..e7e9fd71c6fc 100644 --- a/GDJS/Runtime/jsonmanager.ts +++ b/GDJS/Runtime/jsonmanager.ts @@ -109,7 +109,10 @@ 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.name === resourceName + ); }); if (!resource) { callback( diff --git a/GDJS/Runtime/runtimegame.ts b/GDJS/Runtime/runtimegame.ts index 52f804f46c07..560b366a3c97 100644 --- a/GDJS/Runtime/runtimegame.ts +++ b/GDJS/Runtime/runtimegame.ts @@ -90,6 +90,9 @@ namespace gdjs { _injectExternalLayout: any; _options: RuntimeGameOptions; + //The mappings for embedded resources + _embeddedResourcesMappings: Map>; + /** * 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(); 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; + } } } diff --git a/GDJS/Runtime/types/project-data.d.ts b/GDJS/Runtime/types/project-data.d.ts index 806f35e1998f..e1ee73563f72 100644 --- a/GDJS/Runtime/types/project-data.d.ts +++ b/GDJS/Runtime/types/project-data.d.ts @@ -240,4 +240,5 @@ declare type ResourceKind = | 'font' | 'video' | 'json' + | 'tilemap' | 'bitmapFont'; diff --git a/GDevelop.js/Bindings/Bindings.idl b/GDevelop.js/Bindings/Bindings.idl index b2bebee2cc02..22400251c15b 100644 --- a/GDevelop.js/Bindings/Bindings.idl +++ b/GDevelop.js/Bindings/Bindings.idl @@ -976,6 +976,11 @@ interface JsonResource { }; JsonResource implements Resource; +interface TilemapResource { + void TilemapResource(); +}; +TilemapResource implements Resource; + interface InitialInstance { void InitialInstance(); diff --git a/GDevelop.js/Bindings/ObjectJsImplementation.cpp b/GDevelop.js/Bindings/ObjectJsImplementation.cpp index ac0285348987..09286f689076 100644 --- a/GDevelop.js/Bindings/ObjectJsImplementation.cpp +++ b/GDevelop.js/Bindings/ObjectJsImplementation.cpp @@ -163,8 +163,7 @@ void ObjectJsImplementation::__destroy__() { // Useless? (int)this); } -void ObjectJsImplementation::ExposeResources( - gd::ArbitraryResourceWorker& worker) { +void ObjectJsImplementation::ExposeResources(gd::ArbitraryResourceWorker& worker) { std::map properties = GetProperties(); for (auto& property : properties) { @@ -186,6 +185,10 @@ 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 == "bitmapFont") { worker.ExposeBitmapFont(newPropertyValue); } diff --git a/GDevelop.js/scripts/generate-types.js b/GDevelop.js/scripts/generate-types.js index babaecc813c6..c398cc59d37f 100644 --- a/GDevelop.js/scripts/generate-types.js +++ b/GDevelop.js/scripts/generate-types.js @@ -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'): void", 'types/gdresource.js' ); shell.sed( '-i', /getKind\(\): string/, - "getKind(): 'image' | 'audio' | 'font' | 'video' | 'json'", + "getKind(): 'image' | 'audio' | 'font' | 'video' | 'json' | 'tilemap'", 'types/gdresource.js' ); diff --git a/GDevelop.js/types/gdresource.js b/GDevelop.js/types/gdresource.js index 7f67c871f268..a8f696e66e9a 100644 --- a/GDevelop.js/types/gdresource.js +++ b/GDevelop.js/types/gdresource.js @@ -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'): void; + getKind(): 'image' | 'audio' | 'font' | 'video' | 'json' | 'tilemap'; isUserAdded(): boolean; setUserAdded(yes: boolean): void; useFile(): boolean; diff --git a/GDevelop.js/types/gdtilemapresource.js b/GDevelop.js/types/gdtilemapresource.js new file mode 100644 index 000000000000..401349545289 --- /dev/null +++ b/GDevelop.js/types/gdtilemapresource.js @@ -0,0 +1,6 @@ +// Automatically generated by GDevelop.js/scripts/generate-types.js +declare class gdTilemapResource extends gdResource { + constructor(): void; + delete(): void; + ptr: number; +}; \ No newline at end of file diff --git a/GDevelop.js/types/libgdevelop.js b/GDevelop.js/types/libgdevelop.js index 9b3917ebfca8..d9cb20673366 100644 --- a/GDevelop.js/types/libgdevelop.js +++ b/GDevelop.js/types/libgdevelop.js @@ -98,6 +98,7 @@ declare class libGDevelop { BitmapFontResource: Class; VideoResource: Class; JsonResource: Class; + TilemapResource: Class; InitialInstance: Class; InitialInstancesContainer: Class; HighestZOrderFinder: Class; diff --git a/SharedLibs/TileMapHelper/karma.conf.js b/SharedLibs/TileMapHelper/karma.conf.js index 17e52bac33ff..8657d1264ed1 100644 --- a/SharedLibs/TileMapHelper/karma.conf.js +++ b/SharedLibs/TileMapHelper/karma.conf.js @@ -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"], + }, }); }; diff --git a/SharedLibs/TileMapHelper/package.json b/SharedLibs/TileMapHelper/package.json index eb6d0503c076..bf0773a933c8 100644 --- a/SharedLibs/TileMapHelper/package.json +++ b/SharedLibs/TileMapHelper/package.json @@ -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": "" -} +} \ No newline at end of file diff --git a/SharedLibs/TileMapHelper/rollup.config.js b/SharedLibs/TileMapHelper/rollup.config.js index 1a6ee978e409..1664e259f3cf 100644 --- a/SharedLibs/TileMapHelper/rollup.config.js +++ b/SharedLibs/TileMapHelper/rollup.config.js @@ -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'], diff --git a/SharedLibs/TileMapHelper/src/index.ts b/SharedLibs/TileMapHelper/src/index.ts index c6614a6e4add..901e5df367c6 100644 --- a/SharedLibs/TileMapHelper/src/index.ts +++ b/SharedLibs/TileMapHelper/src/index.ts @@ -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"; diff --git a/SharedLibs/TileMapHelper/src/load/TileMapLoader.ts b/SharedLibs/TileMapHelper/src/load/TileMapLoader.ts new file mode 100644 index 000000000000..370347810adf --- /dev/null +++ b/SharedLibs/TileMapHelper/src/load/TileMapLoader.ts @@ -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; + } +} diff --git a/SharedLibs/TileMapHelper/src/load/ldtk/LDtkFormat.ts b/SharedLibs/TileMapHelper/src/load/ldtk/LDtkFormat.ts new file mode 100644 index 000000000000..0a770b08088e --- /dev/null +++ b/SharedLibs/TileMapHelper/src/load/ldtk/LDtkFormat.ts @@ -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.
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.

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.

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).
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).

In a later update, it will be possible to have multiple Worlds in a single project, each containing multiple Levels.

What will change when \"Multiple worlds\" support will be added to LDtk:

- 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.
- 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).

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.

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.

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.

An enum that describes how levels are organized in this project (ie. linearly or in a 2D space). Possible values: <`null`>, `Free`, `GridVania`, `LinearHorizontal`, `LinearVertical` */ + worldLayout: + | "Free" + | "GridVania" + | "LinearHorizontal" + | "LinearVertical" + | null; +}; + +/** Auto-layer rule group */ +type LDtkAutoLayerRuleGroup = { + /** */ + active: boolean; + /** *This field was removed in 1.0.0 and should no longer be used.* */ + collapsed: boolean | null; + /** */ + isOptional: boolean; + /** */ + name: string; + /** */ + rules: LDtkAutoRuleDef[]; + /** */ + uid: integer; +}; + +/** This complex section isn't meant to be used by game devs at all, as these rules are completely resolved internally by the editor before any saving. You should just ignore this part. */ +type LDtkAutoRuleDef = {}; + +/** If you're writing your own LDtk importer, you should probably just ignore *most* stuff in the `defs` section, as it contains data that are mostly important to the editor. To keep you away from the `defs` section and avoid some unnecessary JSON parsing, important data from definitions is often duplicated in fields prefixed with a double underscore (eg. `__identifier` or `__type`). The 2 only definition types you might need here are **Tilesets** and **Enums**. */ +type LDtkDefinition = { + /** All entities definitions, including their custom fields */ + entities: LDtkEntityDef[]; + /** All internal enums */ + enums: LDtkEnumDef[]; + /** Note: external enums are exactly the same as `enums`, except they have a `relPath` to point to an external source file. */ + externalEnums: LDtkEnumDef[]; + /** All layer definitions */ + layers: LDtkLayerDef[]; + /** All custom fields available to all levels. */ + levelFields: LDtkFieldDef[]; + /** All tilesets */ + tilesets: LDtkTilesetDef[]; +}; + +/** Entity definition */ +type LDtkEntityDef = { + /** Base entity color */ + color: string; + /** Array of field definitions */ + fieldDefs: LDtkFieldDef[]; + /** */ + fillOpacity: number; + /** Pixel height */ + height: integer; + /** */ + hollow: boolean; + /** User defined unique identifier */ + identifier: string; + /** Only applies to entities resizable on both X/Y. If TRUE, the entity instance width/height will keep the same aspect ratio as the definition. */ + keepAspectRatio: boolean; + /** Possible values: `DiscardOldOnes`, `PreventAdding`, `MoveLastOne` */ + limitBehavior: "DiscardOldOnes" | "MoveLastOne" | "PreventAdding"; + /** If TRUE, the maxCount is a \"per world\" limit, if FALSE, it's a \"per level\". Possible values: `PerLayer`, `PerLevel`, `PerWorld` */ + limitScope: "PerLayer" | "PerLevel" | "PerWorld"; + /** */ + lineOpacity: number; + /** Max instances count */ + maxCount: integer; + /** An array of 4 dimensions for the up/right/down/left borders (in this order) when using 9-slice mode for `tileRenderMode`.
If the tileRenderMode is not NineSlice, then this array is empty.
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`.
If the field is an array, this field will look like `Array<...>` (eg. `Array`, `Array` etc.)
NOTE: if you enable the advanced option **Use Multilines type**, you will have \"*Multilines*\" instead of \"*String*\" when relevant. */ + __type: string; + /** Optional list of accepted file extensions for FilePath value type. Includes the dot: `.ext` */ + acceptFileTypes: string[] | null; + /** Possible values: `Any`, `OnlySame`, `OnlyTags` */ + allowedRefs: "Any" | "OnlySame" | "OnlyTags"; + /** */ + allowedRefTags: string[]; + /** */ + allowOutOfLevelRef: boolean; + /** Array max length */ + arrayMaxLength: integer | null; + /** Array min length */ + arrayMinLength: integer | null; + /** */ + autoChainRef: boolean; + /** TRUE if the value can be null. For arrays, TRUE means it can contain null values (exception: array of Points can't have null values). */ + canBeNull: boolean; + /** Default value if selected value is null or invalid. */ + defaultOverride: any | null; + /** */ + editorAlwaysShow: boolean; + /** */ + editorCutLongValues: boolean; + /** Possible values: `Hidden`, `ValueOnly`, `NameAndValue`, `EntityTile`, `Points`, `PointStar`, `PointPath`, `PointPathLoop`, `RadiusPx`, `RadiusGrid`, `ArrayCountWithLabel`, `ArrayCountNoLabel`, `RefLinkBetweenPivots`, `RefLinkBetweenCenters` */ + editorDisplayMode: + | "ArrayCountNoLabel" + | "ArrayCountWithLabel" + | "EntityTile" + | "Hidden" + | "NameAndValue" + | "PointPath" + | "PointPathLoop" + | "PointStar" + | "Points" + | "RadiusGrid" + | "RadiusPx" + | "RefLinkBetweenCenters" + | "RefLinkBetweenPivots" + | "ValueOnly"; + /** Possible values: `Above`, `Center`, `Beneath` */ + editorDisplayPos: "Above" | "Beneath" | "Center"; + /** */ + editorTextPrefix: string | null; + /** */ + editorTextSuffix: string | null; + /** User defined unique identifier */ + identifier: string; + /** TRUE if the value is an array of multiple values */ + isArray: boolean; + /** Max limit for value, if applicable */ + max: number | null; + /** Min limit for value, if applicable */ + min: number | null; + /** Optional regular expression that needs to be matched to accept values. Expected format: `/some_reg_ex/g`, with optional \"i\" flag. */ + regex: string | null; + /** */ + symmetricalRef: boolean; + /** Possible values: <`null`>, `LangPython`, `LangRuby`, `LangJS`, `LangLua`, `LangC`, `LangHaxe`, `LangMarkdown`, `LangJson`, `LangXml`, `LangLog` */ + textLanguageMode: + | "LangC" + | "LangHaxe" + | "LangJS" + | "LangJson" + | "LangLog" + | "LangLua" + | "LangMarkdown" + | "LangPython" + | "LangRuby" + | "LangXml" + | null; + /** UID of the tileset used for a Tile */ + tilesetUid: integer | null; + /** Internal enum representing the possible field types. Possible values: F_Int, F_Float, F_String, F_Text, F_Bool, F_Color, F_Enum(...), F_Point, F_Path, F_EntityRef, F_Tile */ + type: string; + /** Unique Int identifier */ + uid: integer; + /** If TRUE, the color associated with this field will override the Entity or Level default color in the editor UI. For Enum fields, this would be the color associated to their values. */ + useForSmartColor: boolean; +}; + +/** Field instance */ +type LDtkFieldInstance = { + /** Field definition identifier */ + __identifier: string; + /** Optional TilesetRect used to display this field (this can be the field own Tile, or some other Tile guessed from the value, like an Enum). */ + __tile: LDtkTilesetRect | null; + /** Type of the field, such as `Int`, `Float`, `String`, `Enum(my_enum_name)`, `Bool`, etc.
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`:
- For **classic types** (ie. Integer, Float, Boolean, String, Text and FilePath), you just get the actual value with the expected type.
- For **Color**, the value is an hexadecimal string using \"#rrggbb\" format.
- For **Enum**, the value is a String representing the selected enum value.
- For **Point**, the value is a [GridPoint](#ldtk-GridPoint) object.
- For **Tile**, the value is a [TilesetRect](#ldtk-TilesetRect) object.
- For **EntityRef**, the value is an [EntityReferenceInfos](#ldtk-EntityReferenceInfos) object.

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

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).
Order is from left to right, and top to bottom (ie. first row from left to right, followed by second row, etc).
`0` means \"empty cell\" and IntGrid values start at 1.
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.
Only relevant for world layouts where level spatial positioning is manual (ie. GridVania, Free). For Horizontal and Vertical layouts, this array is always empty. */ + __neighbours: LDtkNeighbourLevel[]; + /** The \"guessed\" color for this level in the editor, decided using either the background color or an existing custom field. */ + __smartColor: string; + /** Background color of the level. If `null`, the project `defaultLevelBgColor` should be used. */ + bgColor: string | null; + /** Background image Y pivot (0-1) */ + bgPivotY: number; + /** Background image X pivot (0-1) */ + bgPivotX: number; + /** An enum defining the way the background image (if any) is positioned on the level. See `__bgPos` for resulting position info. Possible values: <`null`>, `Unscaled`, `Contain`, `Cover`, `CoverDirty` */ + bgPos: "Unscaled" | "Contain" | "Cover" | "CoverDirty" | null; + /** The *optional* relative path to the level background image. */ + bgRelPath: string | null; + /** This value is not null if the project option \"*Save levels separately*\" is enabled. In this case, this **relative** path points to the level Json file. */ + externalRelPath: string | null; + /** An array containing this level custom field values. */ + fieldInstances: LDtkFieldInstance[]; + /** User defined unique identifier */ + identifier: string; + /** Unique instance identifier */ + iid: string; + /** An array containing all Layer instances. **IMPORTANT**: if the project option \"*Save levels separately*\" is enabled, this field will be `null`.
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\".
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.
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.
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.
For auto-layer tiles: `[ruleId, coordId]`.
For tile-layer tiles: `[coordId]`. */ + d: integer[]; + /** \"Flip bits\", a 2-bits integer to represent the mirror transformations of the tile.
- Bit 0 = X flip
- Bit 1 = Y flip
Examples: f=0 (no flip), f=1 (X flip only), f=2 (Y flip only), f=3 (both flips) */ + f: integer; + /** Pixel coordinates of the tile in the **layer** (`[x,y]` format). Don't forget optional layer offsets, if they exist! */ + px: integer[]; + /** Pixel coordinates of the tile in the **tileset** (`[x,y]` format) */ + src: integer[]; + /** The *Tile ID* in the corresponding tileset. */ + t: integer; +}; + +/** The `Tileset` definition is the most important part among project definitions. It contains some extra informations about each integrated tileset. If you only had to parse one definition section, that would be the one. */ +export type LDtkTilesetDef = { + /** Grid-based height */ + __cHei: integer; + /** Grid-based width */ + __cWid: integer; + /** The following data is used internally for various optimizations. It's always synced with source image changes. */ + cachedPixelData: object | null; + /** An array of custom tile metadata */ + customData: LDtkTileCustomMetadata[]; + /** If this value is set, then it means that this atlas uses an internal LDtk atlas image instead of a loaded one. Possible values: <`null`>, `LdtkIcons` */ + embedAtlas: "LdtkIcons" | null; + /** Tileset tags using Enum values specified by `tagsSourceEnumId`. This array contains 1 element per Enum value, which contains an array of all Tile IDs that are tagged with it. */ + enumTags: LDtkEnumTagValue[]; + /** User defined unique identifier */ + identifier: string; + /** Distance in pixels from image borders */ + padding: integer; + /** Image height in pixels */ + pxHei: integer; + /** Image width in pixels */ + pxWid: integer; + /** Path to the source file, relative to the current project JSON file
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 = {}; diff --git a/SharedLibs/TileMapHelper/src/load/ldtk/LDtkTileMapLoader.ts b/SharedLibs/TileMapHelper/src/load/ldtk/LDtkTileMapLoader.ts new file mode 100644 index 000000000000..1ba002c0b5c3 --- /dev/null +++ b/SharedLibs/TileMapHelper/src/load/ldtk/LDtkTileMapLoader.ts @@ -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(); + 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 = {}; + + 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(); + 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; + } +} diff --git a/SharedLibs/TileMapHelper/src/load/ldtk/LDtkTileMapLoaderHelper.ts b/SharedLibs/TileMapHelper/src/load/ldtk/LDtkTileMapLoaderHelper.ts new file mode 100644 index 000000000000..78624e017891 --- /dev/null +++ b/SharedLibs/TileMapHelper/src/load/ldtk/LDtkTileMapLoaderHelper.ts @@ -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; +} diff --git a/SharedLibs/TileMapHelper/src/tiled/TiledFormat.ts b/SharedLibs/TileMapHelper/src/load/tiled/TiledFormat.ts similarity index 98% rename from SharedLibs/TileMapHelper/src/tiled/TiledFormat.ts rename to SharedLibs/TileMapHelper/src/load/tiled/TiledFormat.ts index 43afb3808e67..ddfdc962deb4 100644 --- a/SharedLibs/TileMapHelper/src/tiled/TiledFormat.ts +++ b/SharedLibs/TileMapHelper/src/load/tiled/TiledFormat.ts @@ -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; diff --git a/SharedLibs/TileMapHelper/src/tiled/TiledTileMapLoader.spec.ts b/SharedLibs/TileMapHelper/src/load/tiled/TiledTileMapLoader.spec.ts similarity index 87% rename from SharedLibs/TileMapHelper/src/tiled/TiledTileMapLoader.spec.ts rename to SharedLibs/TileMapHelper/src/load/tiled/TiledTileMapLoader.spec.ts index 4fead950e5d4..a2e1633fce16 100644 --- a/SharedLibs/TileMapHelper/src/tiled/TiledTileMapLoader.spec.ts +++ b/SharedLibs/TileMapHelper/src/load/tiled/TiledTileMapLoader.spec.ts @@ -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); diff --git a/SharedLibs/TileMapHelper/src/tiled/TiledTileMapLoader.ts b/SharedLibs/TileMapHelper/src/load/tiled/TiledTileMapLoader.ts similarity index 81% rename from SharedLibs/TileMapHelper/src/tiled/TiledTileMapLoader.ts rename to SharedLibs/TileMapHelper/src/load/tiled/TiledTileMapLoader.ts index 336b86ef889a..e47bcda606c7 100644 --- a/SharedLibs/TileMapHelper/src/tiled/TiledTileMapLoader.ts +++ b/SharedLibs/TileMapHelper/src/load/tiled/TiledTileMapLoader.ts @@ -1,22 +1,32 @@ -import { integer, PolygonVertices } from "../model/CommonTypes"; +import { integer, PolygonVertices } from "../../model/CommonTypes"; import { EditableTileMap, TileDefinition, TileObject, -} from "../model/TileMapModel"; -import { TiledMap } from "./TiledFormat"; +} from "../../model/TileMapModel"; +import { TiledTileMap } from "./TiledFormat"; import { - extractTileUidFlippedStates, decodeBase64LayerData, + extractTileUidFlippedStates, getTileIdFromTiledGUI, -} from "./TiledLoaderHelper"; +} from "./TiledTileMapLoaderHelper"; /** * It creates a {@link EditableTileMap} from a Tiled JSON. */ -export class TiledTileMapLoader { - static load(pako: any, tiledMap: TiledMap): EditableTileMap | null { - if (!tiledMap.tiledversion) { +export 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} + */ + export function load( + tiledTileMap: TiledTileMap, + pako: any + ): EditableTileMap | null { + if (!tiledTileMap.tiledversion) { console.warn( "The loaded Tiled map does not contain a 'tiledversion' key. Are you sure this file has been exported from Tiled (mapeditor.org)?" ); @@ -25,10 +35,11 @@ export class TiledTileMapLoader { } const definitions = new Map(); - for (const tiledSet of tiledMap.tilesets) { - const firstGid = tiledSet.firstgid === undefined ? 1 : tiledSet.firstgid; - if (tiledSet.tiles) { - for (const tile of tiledSet.tiles) { + for (const tiledTileSet of tiledTileMap.tilesets) { + const firstGid = + tiledTileSet.firstgid === undefined ? 1 : tiledTileSet.firstgid; + if (tiledTileSet.tiles) { + for (const tile of tiledTileSet.tiles) { const tileDefinition = new TileDefinition( tile.animation ? tile.animation.length : 0 ); @@ -73,18 +84,18 @@ export class TiledTileMapLoader { ]; } if (polygon) { - tileDefinition.add(tag, polygon); + tileDefinition.addHitBox(tag, polygon); } } } else if (tile.class && tile.class.length > 0) { // When there is no shape, default to the whole tile. const polygon: PolygonVertices = [ [0, 0], - [0, tiledMap.tileheight], - [tiledMap.tilewidth, tiledMap.tileheight], - [tiledMap.tilewidth, 0], + [0, tiledTileMap.tileheight], + [tiledTileMap.tilewidth, tiledTileMap.tileheight], + [tiledTileMap.tilewidth, 0], ]; - tileDefinition.add(tile.class, polygon); + tileDefinition.addHitBox(tile.class, polygon); } definitions.set( getTileIdFromTiledGUI(firstGid + tile.id), @@ -92,7 +103,7 @@ export class TiledTileMapLoader { ); } } - for (let tileIndex = 0; tileIndex < tiledSet.tilecount; tileIndex++) { + for (let tileIndex = 0; tileIndex < tiledTileSet.tilecount; tileIndex++) { const tileId = getTileIdFromTiledGUI(firstGid + tileIndex); if (!definitions.has(tileId)) { definitions.set(tileId, new TileDefinition(0)); @@ -101,14 +112,14 @@ export class TiledTileMapLoader { } const collisionTileMap = new EditableTileMap( - tiledMap.tilewidth, - tiledMap.tileheight, - tiledMap.width, - tiledMap.height, + tiledTileMap.tilewidth, + tiledTileMap.tileheight, + tiledTileMap.width, + tiledTileMap.height, definitions ); - for (const tiledLayer of tiledMap.layers) { + for (const tiledLayer of tiledTileMap.layers) { if (tiledLayer.type === "objectgroup") { const objectLayer = collisionTileMap.addObjectLayer(tiledLayer.id); objectLayer.setVisible(tiledLayer.visible); diff --git a/SharedLibs/TileMapHelper/src/tiled/TiledLoaderHelper.ts b/SharedLibs/TileMapHelper/src/load/tiled/TiledTileMapLoaderHelper.ts similarity index 83% rename from SharedLibs/TileMapHelper/src/tiled/TiledLoaderHelper.ts rename to SharedLibs/TileMapHelper/src/load/tiled/TiledTileMapLoaderHelper.ts index cbff15ebc0b5..0cc035ff7981 100644 --- a/SharedLibs/TileMapHelper/src/tiled/TiledLoaderHelper.ts +++ b/SharedLibs/TileMapHelper/src/load/tiled/TiledTileMapLoaderHelper.ts @@ -1,4 +1,9 @@ -import { integer } from "../model/CommonTypes"; +import { + FLIPPED_DIAGONALLY_FLAG, + FLIPPED_HORIZONTALLY_FLAG, + FLIPPED_VERTICALLY_FLAG, +} from "../../model/GID"; +import { integer } from "../../model/CommonTypes"; import { TiledLayer } from "./TiledFormat"; /** @@ -6,11 +11,11 @@ import { TiledLayer } from "./TiledFormat"; * 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 const decodeBase64LayerData = (pako: any, layer: TiledLayer) => { - const { data, compression } = layer; +export const decodeBase64LayerData = (pako: any, tiledLayer: TiledLayer) => { + const { data, compression } = tiledLayer; const dataBase64 = data as string; if (!dataBase64) { // The layer data is not encoded. @@ -74,10 +79,6 @@ export type TiledGID = { export const extractTileUidFlippedStates = ( globalTileUid: integer ): TiledGID => { - const FLIPPED_HORIZONTALLY_FLAG = 0x80000000; - const FLIPPED_VERTICALLY_FLAG = 0x40000000; - const FLIPPED_DIAGONALLY_FLAG = 0x20000000; - const flippedHorizontally = globalTileUid & FLIPPED_HORIZONTALLY_FLAG; const flippedVertically = globalTileUid & FLIPPED_VERTICALLY_FLAG; const flippedDiagonally = globalTileUid & FLIPPED_DIAGONALLY_FLAG; @@ -101,8 +102,10 @@ export 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 const getTileIdFromTiledGUI = ( +export function getTileIdFromTiledGUI( tiledGUI: number | undefined -): number | undefined => (tiledGUI === 0 ? undefined : tiledGUI - 1); +): number | undefined { + return tiledGUI === 0 ? undefined : tiledGUI - 1; +} diff --git a/SharedLibs/TileMapHelper/src/model/GID.ts b/SharedLibs/TileMapHelper/src/model/GID.ts new file mode 100644 index 000000000000..906b2da10134 --- /dev/null +++ b/SharedLibs/TileMapHelper/src/model/GID.ts @@ -0,0 +1,123 @@ +import { integer } from "./CommonTypes"; + +export const FLIPPED_HORIZONTALLY_FLAG = 0x80000000; +export const FLIPPED_VERTICALLY_FLAG = 0x40000000; +export const FLIPPED_DIAGONALLY_FLAG = 0x20000000; + +/** + * Tile identifiers making to access flipping flags. + */ +export namespace FlippingHelper { + export const tileIdMask = ~( + FLIPPED_HORIZONTALLY_FLAG | + FLIPPED_VERTICALLY_FLAG | + FLIPPED_DIAGONALLY_FLAG + ); + + export function getTileId(tileId: integer): integer { + return tileId & FlippingHelper.tileIdMask; + } + + export function setFlippedHorizontally( + tileId: integer, + flippedHorizontally: boolean + ): integer { + tileId &= ~FLIPPED_HORIZONTALLY_FLAG; + if (flippedHorizontally) { + tileId |= FLIPPED_HORIZONTALLY_FLAG; + } + return tileId; + } + + export function setFlippedVertically( + tileId: integer, + flippedVertically: boolean + ): integer { + tileId &= ~FLIPPED_VERTICALLY_FLAG; + if (flippedVertically) { + tileId |= FLIPPED_VERTICALLY_FLAG; + } + return tileId; + } + + export function setFlippedDiagonally( + tileId: integer, + flippedDiagonally: boolean + ): integer { + tileId &= ~FLIPPED_DIAGONALLY_FLAG; + if (flippedDiagonally) { + tileId |= FLIPPED_DIAGONALLY_FLAG; + } + return tileId; + } + + export function isFlippedHorizontally(tileId: integer): boolean { + return (tileId & FLIPPED_HORIZONTALLY_FLAG) !== 0; + } + + export function isFlippedVertically(tileId: integer): boolean { + return (tileId & FLIPPED_VERTICALLY_FLAG) !== 0; + } + + export function isFlippedDiagonally(tileId: integer): boolean { + return (tileId & FLIPPED_DIAGONALLY_FLAG) !== 0; + } +} + +/** + * 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 function getPixiRotate(tileGID: integer) { + const flippedDiagonally = FlippingHelper.isFlippedDiagonally(tileGID); + const flippedHorizontally = FlippingHelper.isFlippedHorizontally(tileGID); + const flippedVertically = FlippingHelper.isFlippedVertically(tileGID); + + let rotate = 0; + if (flippedDiagonally) { + rotate = 10; + if (!flippedHorizontally && flippedVertically) { + rotate = 2; + } else if (flippedHorizontally && !flippedVertically) { + rotate = 6; + } else if (flippedHorizontally && flippedVertically) { + rotate = 14; + } + } else { + rotate = 0; + if (!flippedHorizontally && flippedVertically) { + rotate = 8; + } else if (flippedHorizontally && !flippedVertically) { + rotate = 12; + } else if (flippedHorizontally && flippedVertically) { + rotate = 4; + } + } + return rotate; +} + +export function getTileGID( + tileId: integer, + flippedHorizontally: boolean, + flippedVertically: boolean, + flippedDiagonally: boolean +): integer { + let tileGID = tileId; + if (flippedHorizontally) { + tileGID |= FLIPPED_HORIZONTALLY_FLAG; + } + if (flippedVertically) { + tileGID |= FLIPPED_VERTICALLY_FLAG; + } + if (flippedDiagonally) { + tileGID |= FLIPPED_DIAGONALLY_FLAG; + } + return tileGID; +} diff --git a/SharedLibs/TileMapHelper/src/model/TileMapModel.ts b/SharedLibs/TileMapHelper/src/model/TileMapModel.ts index 239d82a37ae0..65a6aca7ac1e 100644 --- a/SharedLibs/TileMapHelper/src/model/TileMapModel.ts +++ b/SharedLibs/TileMapHelper/src/model/TileMapModel.ts @@ -1,14 +1,16 @@ import { PolygonVertices, integer, float } from "./CommonTypes"; +import { FlippingHelper } from "./GID"; /** * 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 class EditableTileMap { + private _backgroundResourceName?: string; private _tileSet: Map; private _layers: Array; /** @@ -129,6 +131,13 @@ export class EditableTileMap { return layer; } + /** + * @returns The resource name of the background + */ + getBackgroundResourceName(): string { + return this._backgroundResourceName; + } + /** * @returns All the layers of the tile map. */ @@ -155,17 +164,24 @@ export class EditableTileMap { if (!tileLayer) { continue; } - const tileId = tileLayer.get(indexX, indexY); + const tileId = tileLayer.getTileId(indexX, indexY); if (tileId === undefined) { return false; } - const tileDefinition = this._tileSet.get(tileId); - if (tileDefinition!.hasTag(tag)) { + const tileDefinition = this._tileSet.get(tileId)!; + if (tileDefinition.hasTaggedHitBox(tag)) { return true; } } return false; } + + /** + * @param resourceName The name of the resource + */ + setBackgroundResourceName(resourceName: string): void { + this._backgroundResourceName = resourceName; + } } /** @@ -301,74 +317,12 @@ export class TileObject { } } -/** - * Tile identifiers making to access flipping flags. - */ -class FlippingHelper { - static readonly flippedHorizontallyFlag = 0x80000000; - static readonly flippedVerticallyFlag = 0x40000000; - static readonly flippedDiagonallyFlag = 0x20000000; - static readonly tileIdMask = ~( - FlippingHelper.flippedHorizontallyFlag | - FlippingHelper.flippedVerticallyFlag | - FlippingHelper.flippedDiagonallyFlag - ); - - static getTileId(tileId: integer): integer { - return tileId & FlippingHelper.tileIdMask; - } - - static setFlippedHorizontally( - tileId: integer, - flippedHorizontally: boolean - ): integer { - tileId &= ~FlippingHelper.flippedHorizontallyFlag; - if (flippedHorizontally) { - tileId |= FlippingHelper.flippedHorizontallyFlag; - } - return tileId; - } - - static setFlippedVertically( - tileId: integer, - flippedVertically: boolean - ): integer { - tileId &= ~FlippingHelper.flippedVerticallyFlag; - if (flippedVertically) { - tileId |= FlippingHelper.flippedVerticallyFlag; - } - return tileId; - } - - static setFlippedDiagonally( - tileId: integer, - flippedDiagonally: boolean - ): integer { - tileId &= ~FlippingHelper.flippedDiagonallyFlag; - if (flippedDiagonally) { - tileId |= FlippingHelper.flippedDiagonallyFlag; - } - return tileId; - } - - static isFlippedHorizontally(tileId: integer): boolean { - return (tileId & FlippingHelper.flippedHorizontallyFlag) !== 0; - } - - static isFlippedVertically(tileId: integer): boolean { - return (tileId & FlippingHelper.flippedVerticallyFlag) !== 0; - } - - static isFlippedDiagonally(tileId: integer): boolean { - return (tileId & FlippingHelper.flippedDiagonallyFlag) !== 0; - } -} - /** * A tile map layer with tile organized in grid. */ export class EditableTileMapLayer extends AbstractEditableLayer { - private readonly _tiles: Array; + private readonly _tiles: Int32Array[]; + private _alpha: float; /** * @param tileMap The layer tile map. @@ -381,12 +335,27 @@ export class EditableTileMapLayer extends AbstractEditableLayer { for (let index = 0; index < this._tiles.length; index++) { this._tiles[index] = new Int32Array(this.tileMap.getDimensionX()); } + this._alpha = 1; + } + + /** + * The opacity (between 0-1) of the layer + */ + getAlpha(): float { + return this._alpha; + } + + /** + * @param alpha The opacity between 0-1 + */ + setAlpha(alpha: float) { + this._alpha = alpha; } /** * @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 { const definition = this.tileMap.getTileDefinition(tileId); @@ -497,9 +466,23 @@ export 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). + */ + getTileGID(x: integer, y: integer): integer | undefined { + const row = this._tiles[y]; + if (!row || row[x] === 0) { + return undefined; + } + // -1 because 0 is keep for null. + return row[x] - 1; + } + + /** + * @param x The layer column. + * @param y The layer row. + * @returns The tile's id. */ - get(x: integer, y: integer): integer | undefined { + getTileId(x: integer, y: integer): integer | undefined { const row = this._tiles[y]; if (!row || row[x] === 0) { return undefined; @@ -552,12 +535,19 @@ export class TileDefinition { }[]; private readonly animationLength: integer; + /** + * A tile can be a composition of several tiles. + */ + private stackedTiles: integer[]; + private stackTileId?: integer; + /** * @param animationLength The number of frame in the tile animation. */ - constructor(animationLength: integer) { + constructor(animationLength?: integer) { this.taggedHitBoxes = []; - this.animationLength = animationLength; + this.animationLength = animationLength ?? 0; + this.stackedTiles = []; } /** @@ -565,7 +555,7 @@ export class TileDefinition { * @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 { let taggedHitBox = this.taggedHitBoxes.find((hitbox) => hitbox.tag === tag); if (!taggedHitBox) { taggedHitBox = { tag, polygons: [] }; @@ -580,7 +570,7 @@ export class TileDefinition { * @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 { return this.taggedHitBoxes.some((hitbox) => hitbox.tag === tag); } @@ -605,4 +595,34 @@ export class TileDefinition { getAnimationLength(): integer { return this.animationLength; } + + /** + * @returns The tile representing the stack of tiles. + */ + getStackTileId(): integer { + return this.stackTileId!; + } + + /** + * @returns All the tiles composed in the stack. + */ + getStackedTiles(): integer[] { + return this.stackedTiles; + } + + /** + * @returns `true` if the defintion is a stack of tiles. + */ + hasStackedTiles(): boolean { + return this.stackedTiles.length > 0; + } + + /** + * @param stackTileId The `tileId` representing the stack. + * @param tiles All the tiles of stack. + */ + setStackedTiles(stackTileId: integer, ...tiles: integer[]): void { + this.stackedTiles = tiles; + this.stackTileId = stackTileId; + } } diff --git a/SharedLibs/TileMapHelper/src/render/TileMapManager.ts b/SharedLibs/TileMapHelper/src/render/TileMapManager.ts index 7312102204bc..3a45e2094b27 100644 --- a/SharedLibs/TileMapHelper/src/render/TileMapManager.ts +++ b/SharedLibs/TileMapHelper/src/render/TileMapManager.ts @@ -1,11 +1,11 @@ import { ResourceCache } from "./ResourceCache"; -import { TiledMap } from "../tiled/TiledFormat"; -import { TiledTileMapLoader } from "../tiled/TiledTileMapLoader"; import { EditableTileMap } from "../model/TileMapModel"; import { TileTextureCache } from "./TileTextureCache"; import { PixiTileMapHelper } from "./TileMapPixiHelper"; import PIXI = GlobalPIXIModule.PIXI; +import { TileMapLoader } from "../load/TileMapLoader"; +import { TileMap } from "../types"; /** * A holder to share tile maps across the 2 extension objects. @@ -40,39 +40,79 @@ export class 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 { + if (data.tiledversion) { + console.info("Detected the json file was created in Tiled"); + return { + kind: "tiled", + data, + }; + } + + if (data.__header__ && data.__header__.app === "LDtk") { + console.info("Detected the json/ldtk file was created in LDtk"); + return { + kind: "ldtk", + data, + }; + } + + console.warn( + "The loaded Tile Map data does not contain a 'tiledversion' or '__header__' key. Are you sure this file has been exported from Tiled (mapeditor.org) or LDtk (ldtk.io)?" + ); + console.log("The data that failed Tile Map identification is: ", data); + + return null; + } + + /** + * @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 { - const key = tileMapJsonResourceName + "|" + tileSetJsonResourceName; + const key = + tileMapJsonResourceName + + "|" + + tileSetJsonResourceName + + "|" + + levelIndex; this._tileMapCache.getOrLoad( key, (callback) => { - loadTiledMap( + loadTileMap( tileMapJsonResourceName, tileSetJsonResourceName, - (tiledMap: TiledMap | null) => { - if (!tiledMap) { + (tileMap: TileMap | null) => { + if (!tileMap) { callback(null); return; } - const collisionTileMap = TiledTileMapLoader.load(pako, tiledMap); - callback(collisionTileMap); + const editableTileMap = TileMapLoader.load( + tileMap, + levelIndex, + pako + ); + callback(editableTileMap); } ); }, @@ -81,23 +121,25 @@ export class TileMapManager { } /** - * @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, atlasImageResourceName: string, tileMapJsonResourceName: string, tileSetJsonResourceName: string, + levelIndex: number, callback: (textureCache: TileTextureCache | null) => void ): void { const key = @@ -105,17 +147,19 @@ export class TileMapManager { "|" + tileSetJsonResourceName + "|" + - atlasImageResourceName; + atlasImageResourceName + + "|" + + levelIndex; this._textureCacheCaches.getOrLoad( key, (callback) => { - loadTiledMap( + loadTileMap( tileMapJsonResourceName, tileSetJsonResourceName, - (tiledMap: TiledMap | null) => { - if (!tiledMap) { - // loadTiledMap already log errors. + (tileMap: TileMap | null) => { + if (!tileMap) { + // loadTileMap already log errors. callback(null); return; } @@ -124,7 +168,8 @@ export class TileMapManager { ? getTexture(atlasImageResourceName) : null; const textureCache = PixiTileMapHelper.parseAtlas( - tiledMap, + tileMap, + levelIndex, atlasTexture, getTexture ); diff --git a/SharedLibs/TileMapHelper/src/render/TileMapPixiHelper.ts b/SharedLibs/TileMapHelper/src/render/TileMapPixiHelper.ts index eaf7983bf07d..e5e1ad6c1823 100644 --- a/SharedLibs/TileMapHelper/src/render/TileMapPixiHelper.ts +++ b/SharedLibs/TileMapHelper/src/render/TileMapPixiHelper.ts @@ -1,125 +1,61 @@ import { integer, float } from "../model/CommonTypes"; -import { TiledMap } from "../tiled/TiledFormat"; import { EditableObjectLayer, EditableTileMap, EditableTileMapLayer, } from "../model/TileMapModel"; +import { TiledPixiHelper } from "./tiled/TiledPixiHelper"; +import { LDtkPixiHelper } from "./ldtk/LDtkPixiHelper"; +import { TileMap } from "../types"; import { TileTextureCache } from "./TileTextureCache"; +import { FlippingHelper, getPixiRotate } from "../model/GID"; import PIXI = GlobalPIXIModule.PIXI; -import { getTileIdFromTiledGUI } from "../tiled/TiledLoaderHelper"; -export class PixiTileMapHelper { +export 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, + export function parseAtlas( + tileMap: TileMap, + levelIndex: number, atlasTexture: PIXI.BaseTexture | null, getTexture: (textureName: string) => PIXI.BaseTexture ): TileTextureCache | null { - if (!tiledMap.tiledversion) { - console.warn( - "The loaded Tiled map does not contain a 'tiledversion' key. Are you sure this file has been exported from Tiled (mapeditor.org)?" + if (tileMap.kind === "ldtk") { + return LDtkPixiHelper.parseAtlas( + tileMap.data, + levelIndex, + atlasTexture, + getTexture ); - - return null; - } - - // We only handle tileset embedded in the tilemap. Warn if it's not the case. - if (!tiledMap.tilesets.length || "source" in tiledMap.tilesets[0]) { - console.warn( - "The loaded Tiled map seems not to contain any tileset data (nothing in 'tilesets' key)." - ); - return null; - } - - const tiledSet = tiledMap.tilesets[0]; - const { - tilewidth, - tileheight, - tilecount, - image, - columns, - spacing, - margin, - } = tiledSet; - const firstGid = tiledSet.firstgid === undefined ? 1 : tiledSet.firstgid; - if (!atlasTexture) atlasTexture = getTexture(image); - - // We try to detect what size Tiled is expecting. - const rows = tilecount / columns; - const expectedAtlasWidth = - tilewidth * columns + spacing * (columns - 1) + margin * 2; - const expectedAtlasHeight = - tileheight * rows + spacing * (rows - 1) + margin * 2; - // When users use an atlas images that are not divisible by the tile width, - // Tiled automatically chooses a number of column that fit in the atlas for - // a given tile size. - // So the atlas images can have unused pixels at the right and bottom. - if ( - (atlasTexture.width !== 1 && atlasTexture.width < expectedAtlasWidth) || - atlasTexture.width >= expectedAtlasWidth + spacing + tilewidth || - (atlasTexture.height !== 1 && - atlasTexture.height < expectedAtlasHeight) || - atlasTexture.height >= expectedAtlasHeight + spacing + tileheight - ) { - console.error( - "It seems the atlas file was resized, which is not supported. " + - `It should be ${expectedAtlasWidth}x${expectedAtlasHeight} px, ` + - `but it's ${atlasTexture.width}x${atlasTexture.height} px.` - ); - return null; } - if ( - (atlasTexture.width !== 1 && atlasTexture.width !== expectedAtlasWidth) || - (atlasTexture.height !== 1 && atlasTexture.height !== expectedAtlasHeight) - ) { - console.warn( - "It seems the atlas file has unused pixels. " + - `It should be ${expectedAtlasWidth}x${expectedAtlasHeight} px, ` + - `but it's ${atlasTexture.width}x${atlasTexture.height} px.` + if (tileMap.kind === "tiled") { + return TiledPixiHelper.parseAtlas( + tileMap.data, + levelIndex, + atlasTexture, + getTexture ); - return null; } - // Prepare the textures pointing to the base "Atlas" Texture for each tile. - // Note that this cache can be augmented later with rotated/flipped - // versions of the tile textures. - const textureCache = new TileTextureCache(); - for (let tileSetIndex = 0; tileSetIndex < tilecount; tileSetIndex++) { - const columnMultiplier = Math.floor(tileSetIndex % columns); - const rowMultiplier = Math.floor(tileSetIndex / columns); - const x = margin + columnMultiplier * (tilewidth + spacing); - const y = margin + rowMultiplier * (tileheight + spacing); - const tileId = getTileIdFromTiledGUI(firstGid + tileSetIndex); + console.warn( + "The loaded Tiled 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)?" + ); - try { - const rect = new PIXI.Rectangle(x, y, tilewidth, tileheight); - const texture = new PIXI.Texture(atlasTexture!, rect); - - textureCache.setTexture(tileId, false, false, false, texture); - } catch (error) { - console.error( - "An error occurred while creating a PIXI.Texture to be used in a TileMap:", - error - ); - } - } - - return textureCache; + return 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: @@ -129,7 +65,7 @@ export class PixiTileMapHelper { * @param layerIndex If `displayMode` is set to `index`, the layer index to be * displayed. */ - static updatePixiTileMap( + export function updatePixiTileMap( untypedPixiTileMap: any, tileMap: EditableTileMap, textureCache: TileTextureCache, @@ -141,6 +77,12 @@ export class PixiTileMapHelper { if (!pixiTileMap) return; pixiTileMap.clear(); + const bgResourceName = tileMap.getBackgroundResourceName(); + if (bgResourceName) { + const texture = textureCache.getLevelBackgroundTexture(bgResourceName); + pixiTileMap.tile(texture, 0, 0); + } + for (const layer of tileMap.getLayers()) { if ( (displayMode === "index" && layerIndex !== layer.id) || @@ -151,14 +93,14 @@ export class PixiTileMapHelper { if (layer instanceof EditableObjectLayer) { const objectLayer = layer as EditableObjectLayer; + for (const object of objectLayer.objects) { - const texture = textureCache.findTileTexture(object.getTileId()); + const tileGID = object.getTileId(); + const texture = textureCache.getTexture(tileGID); + if (texture) { - const rotate = textureCache.getPixiRotate( - object.isFlippedHorizontally(), - object.isFlippedVertically(), - object.isFlippedDiagonally() - ); + const rotate = getPixiRotate(tileGID); + pixiTileMap.tile( texture, object.x, @@ -174,40 +116,62 @@ export class PixiTileMapHelper { const tileHeight = tileLayer.tileMap.getTileHeight(); const dimensionX = tileLayer.tileMap.getDimensionX(); const dimensionY = tileLayer.tileMap.getDimensionY(); + const alpha = tileLayer.getAlpha(); for (let y = 0; y < dimensionY; y++) { for (let x = 0; x < dimensionX; x++) { const xPos = tileWidth * x; const yPos = tileHeight * y; - const tileId = tileLayer.get(x, y); - if (tileId === undefined) { + const tileGID = tileLayer.getTileGID(x, y); + if (tileGID === undefined) { continue; } - const tileTexture = textureCache.findTileTexture(tileId); - if (!tileTexture) { - console.warn(`Unknown tile id: ${tileId} at (${x}, ${y})`); - continue; - } - const rotate = textureCache.getPixiRotate( - tileLayer.isFlippedHorizontally(x, y), - tileLayer.isFlippedVertically(x, y), - tileLayer.isFlippedDiagonally(x, y) - ); - const pixiTilemapFrame = pixiTileMap.tile(tileTexture, xPos, yPos, { - rotate, - }); + const tileId = FlippingHelper.getTileId(tileGID); const tileDefinition = tileLayer.tileMap.getTileDefinition(tileId); - // Animated tiles have a limitation: - // they are only able to use frames arranged horizontally one next - // to each other on the atlas. - if (tileDefinition && tileDefinition.getAnimationLength() > 0) { - pixiTilemapFrame.tileAnimX( - tileWidth, - tileDefinition.getAnimationLength() + if (tileDefinition.hasStackedTiles()) { + for (const tileGID of tileDefinition.getStackedTiles()) { + const tileId = FlippingHelper.getTileId(tileGID); + const tileTexture = textureCache.getTexture(tileId); + if (!tileTexture) { + continue; + } + + const rotate = getPixiRotate(tileGID); + + void pixiTileMap.tile(tileTexture, xPos, yPos, { + alpha, + rotate, + }); + } + } else { + const tileTexture = textureCache.getTexture(tileId); + if (!tileTexture) { + console.warn(`Unknown tile id: ${tileId} at (${x}, ${y})`); + continue; + } + const rotate = getPixiRotate(tileGID); + const pixiTilemapFrame = pixiTileMap.tile( + tileTexture, + xPos, + yPos, + { + alpha, + rotate, + } ); + + // Animated tiles have a limitation: + // they are only able to use frames arranged horizontally one next + // to each other on the atlas. + if (tileDefinition.getAnimationLength() > 0) { + pixiTilemapFrame.tileAnimX( + tileWidth, + tileDefinition.getAnimationLength() + ); + } } } } @@ -218,7 +182,7 @@ export class PixiTileMapHelper { /** * Re-renders the collision mask */ - static updatePixiCollisionMask( + export function updatePixiCollisionMask( pixiGraphics: PIXI.Graphics, tileMap: EditableTileMap, typeFilter: string, @@ -246,7 +210,7 @@ export class PixiTileMapHelper { const xPos = tileWidth * x; const yPos = tileHeight * y; - const tileId = tileLayer.get(x, y)!; + const tileId = tileLayer.getTileId(x, y)!; const isFlippedHorizontally = tileLayer.isFlippedHorizontally(x, y); const isFlippedVertically = tileLayer.isFlippedVertically(x, y); const isFlippedDiagonally = tileLayer.isFlippedDiagonally(x, y); diff --git a/SharedLibs/TileMapHelper/src/render/TileTextureCache.ts b/SharedLibs/TileMapHelper/src/render/TileTextureCache.ts index 3a2c06d8ee61..8567d141e829 100644 --- a/SharedLibs/TileMapHelper/src/render/TileTextureCache.ts +++ b/SharedLibs/TileMapHelper/src/render/TileTextureCache.ts @@ -9,30 +9,16 @@ import PIXI = GlobalPIXIModule.PIXI; * and used by {@link PixiTileMapHelper.updatePixiTileMap}. */ export class TileTextureCache { - private static readonly flippedHorizontallyFlag = 0x80000000; - private static readonly flippedVerticallyFlag = 0x40000000; - private static readonly flippedDiagonallyFlag = 0x20000000; - + private readonly _levelBackgroundTextures: Map; private readonly _textures: Map; constructor() { - this._textures = new Map(); + this._levelBackgroundTextures = new Map(); + this._textures = new Map(); } - setTexture( - tileId: integer, - flippedHorizontally: boolean, - flippedVertically: boolean, - flippedDiagonally: boolean, - texture: PIXI.Texture - ): void { - let globalTileUid = this._getGlobalId( - tileId, - flippedHorizontally, - flippedVertically, - flippedDiagonally - ); - this._textures.set(globalTileUid, texture); + setTexture(tileId: integer, texture: PIXI.Texture): void { + this._textures.set(tileId, texture); } /** @@ -41,68 +27,15 @@ export class TileTextureCache { * @param tileId The tile identifier * @returns The texture for the given tile identifier. */ - findTileTexture(tileId: integer): PIXI.Texture | undefined { + getTexture(tileId: integer): PIXI.Texture | undefined { return this._textures.get(tileId); } - /** - * 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 { - let rotate = 0; - if (flippedDiagonally) { - rotate = 10; - if (!flippedHorizontally && flippedVertically) { - rotate = 2; - } else if (flippedHorizontally && !flippedVertically) { - rotate = 6; - } else if (flippedHorizontally && flippedVertically) { - rotate = 14; - } - } else { - rotate = 0; - if (!flippedHorizontally && flippedVertically) { - rotate = 8; - } else if (flippedHorizontally && !flippedVertically) { - rotate = 12; - } else if (flippedHorizontally && flippedVertically) { - rotate = 4; - } - } - return rotate; + getLevelBackgroundTexture(name: string): PIXI.Texture | undefined { + return this._levelBackgroundTextures.get(name); } - /** - * @return the Tiled tile global uniq identifier. - */ - private _getGlobalId( - tileId: integer, - flippedHorizontally: boolean, - flippedVertically: boolean, - flippedDiagonally: boolean - ): integer { - let globalTileUid = tileId; - if (flippedHorizontally) { - globalTileUid |= TileTextureCache.flippedHorizontallyFlag; - } - if (flippedVertically) { - globalTileUid |= TileTextureCache.flippedVerticallyFlag; - } - if (flippedDiagonally) { - globalTileUid |= TileTextureCache.flippedDiagonallyFlag; - } - return globalTileUid; + setLevelBackgroundTexture(name: string, texture: PIXI.Texture): void { + this._levelBackgroundTextures.set(name, texture); } } diff --git a/SharedLibs/TileMapHelper/src/render/ldtk/LDtkPixiHelper.ts b/SharedLibs/TileMapHelper/src/render/ldtk/LDtkPixiHelper.ts new file mode 100644 index 000000000000..1e37ea6e6123 --- /dev/null +++ b/SharedLibs/TileMapHelper/src/render/ldtk/LDtkPixiHelper.ts @@ -0,0 +1,142 @@ +import { TileTextureCache } from "../TileTextureCache"; +import { LDtkTileMap, LDtkTilesetDef } from "../../load/ldtk/LDtkFormat"; +import { getLDtkTileId } from "../../load/ldtk/LDtkTileMapLoaderHelper"; +import PIXI = GlobalPIXIModule.PIXI; + +type Texture = PIXI.BaseTexture; +type TextureLoader = (textureName: string) => PIXI.BaseTexture; + +function getAtlasTexture( + atlasTextures: Record, + tilesetCache: Record, + getTexture: TextureLoader, + tilesetId: number +): Texture | null { + if (atlasTextures[tilesetId]) { + return atlasTextures[tilesetId]; + } + + let texture = null; + + const tileset = tilesetCache[tilesetId]; + if (tileset?.relPath) { + texture = getTexture(tileset.relPath); + + // @ts-ignore + if (texture.baseTexture?.cacheId === "res/error48.png") { + console.error(`The atlas texture "${tileset.relPath}" can't be loaded`); + + texture = null; + } + } else { + console.error( + `The tileset "${tileset.identifier}" doesn't seems to contain an atlas texture` + ); + } + + atlasTextures[tilesetId] = texture; + + return texture; +} + +export 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. + */ + export function parseAtlas( + tileMap: LDtkTileMap, + levelIndex: number, + atlasTexture: Texture | null, + getTexture: TextureLoader + ): TileTextureCache | null { + const level = tileMap.levels[levelIndex > -1 ? levelIndex : 0]; + if (!level || !level.layerInstances) { + return null; + } + + const tilesetCache: Record = {}; + for (const tileset of tileMap.defs.tilesets) { + tilesetCache[tileset.uid] = tileset; + } + + const textureCache = new TileTextureCache(); + // List the tiles that have been loaded to Pixi by all the layers of the level. + // The keys are a composition (getLDtkTileId) between the tileset's id and the tile's id. + const levelTileCache: Record = {}; + const atlasTextures: Record = {}; + + for (let iLayer = level.layerInstances.length - 1; iLayer >= 0; --iLayer) { + const layer = level.layerInstances[iLayer]; + if (layer.__type === "Entities") { + continue; + } + + const tilesetId = layer.__tilesetDefUid; + if (typeof tilesetId !== "number") { + continue; + } + + const tileset = tilesetCache[tilesetId]; + + const atlasTexture = getAtlasTexture( + atlasTextures, + tilesetCache, + getTexture, + tilesetId + ); + if (!atlasTexture) { + continue; + } + + // List the tiles that have been loaded to Pixi by the current layer. + // Since layer can only have tiles from 1 tileset, the keys are only the tile's id. + const layerTileCache: Record = {}; + const gridSize = tileset.tileGridSize; + + for (const tile of [...layer.autoLayerTiles, ...layer.gridTiles]) { + if (layerTileCache[tile.t]) { + continue; + } + + const tileId = getLDtkTileId(tilesetId, tile.t); + if (levelTileCache[tileId]) { + layerTileCache[tile.t] = true; + continue; + } + + try { + const [x, y] = tile.src; + const rect = new PIXI.Rectangle(x, y, gridSize, gridSize); + + const texture = new PIXI.Texture(atlasTexture, rect); + + textureCache.setTexture(tileId, texture); + } catch (error) { + console.error( + "An error occurred while creating a PIXI.Texture to be used in a TileMap:", + error + ); + } + + layerTileCache[tile.t] = true; + levelTileCache[tileId] = true; + } + } + + if (level.bgRelPath) { + const atlasTexture = getTexture(level.bgRelPath); + const rect = new PIXI.Rectangle(0, 0, level.pxWid, level.pxHei); + const texture = new PIXI.Texture(atlasTexture!, rect); + + textureCache.setLevelBackgroundTexture(level.bgRelPath, texture); + } + + return textureCache; + } +} diff --git a/SharedLibs/TileMapHelper/src/render/tiled/TiledPixiHelper.ts b/SharedLibs/TileMapHelper/src/render/tiled/TiledPixiHelper.ts new file mode 100644 index 000000000000..ec93df0ad202 --- /dev/null +++ b/SharedLibs/TileMapHelper/src/render/tiled/TiledPixiHelper.ts @@ -0,0 +1,113 @@ +import { TileTextureCache } from "../TileTextureCache"; +import { TiledTileMap } from "../../load/tiled/TiledFormat"; +import { getTileIdFromTiledGUI } from "../../load/tiled/TiledTileMapLoaderHelper"; +import PIXI = GlobalPIXIModule.PIXI; + +export 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. + */ + export function parseAtlas( + tileMap: TiledTileMap, + levelIndex: number, + atlasTexture: PIXI.BaseTexture | null, + getTexture: (textureName: string) => PIXI.BaseTexture + ): TileTextureCache | null { + if (!tileMap.tiledversion) { + console.warn( + "The loaded Tiled map does not contain a 'tiledversion' key. Are you sure this file has been exported from Tiled (mapeditor.org)?" + ); + + return null; + } + + // We only handle tileset embedded in the tilemap. Warn if it's not the case. + if (!tileMap.tilesets.length || "source" in tileMap.tilesets[0]) { + console.warn( + "The loaded Tiled map seems not to contain any tileset data (nothing in 'tilesets' key)." + ); + return null; + } + + const tiledSet = tileMap.tilesets[0]; + const { + tilewidth, + tileheight, + tilecount, + image, + columns, + spacing, + margin, + } = tiledSet; + const firstGid = tiledSet.firstgid === undefined ? 1 : tiledSet.firstgid; + if (!atlasTexture) atlasTexture = getTexture(image); + + // We try to detect what size Tiled is expecting. + const rows = tilecount / columns; + const expectedAtlasWidth = + tilewidth * columns + spacing * (columns - 1) + margin * 2; + const expectedAtlasHeight = + tileheight * rows + spacing * (rows - 1) + margin * 2; + // When users use an atlas images that are not divisible by the tile width, + // Tiled automatically chooses a number of column that fit in the atlas for + // a given tile size. + // So the atlas images can have unused pixels at the right and bottom. + if ( + (atlasTexture.width !== 1 && atlasTexture.width < expectedAtlasWidth) || + atlasTexture.width >= expectedAtlasWidth + spacing + tilewidth || + (atlasTexture.height !== 1 && + atlasTexture.height < expectedAtlasHeight) || + atlasTexture.height >= expectedAtlasHeight + spacing + tileheight + ) { + console.error( + "It seems the atlas file was resized, which is not supported. " + + `It should be ${expectedAtlasWidth}x${expectedAtlasHeight} px, ` + + `but it's ${atlasTexture.width}x${atlasTexture.height} px.` + ); + return null; + } + if ( + (atlasTexture.width !== 1 && atlasTexture.width !== expectedAtlasWidth) || + (atlasTexture.height !== 1 && atlasTexture.height !== expectedAtlasHeight) + ) { + console.warn( + "It seems the atlas file has unused pixels. " + + `It should be ${expectedAtlasWidth}x${expectedAtlasHeight} px, ` + + `but it's ${atlasTexture.width}x${atlasTexture.height} px.` + ); + return null; + } + + // Prepare the textures pointing to the base "Atlas" Texture for each tile. + // Note that this cache can be augmented later with rotated/flipped + // versions of the tile textures. + const textureCache = new TileTextureCache(); + for (let tileSetIndex = 0; tileSetIndex < tilecount; tileSetIndex++) { + const columnMultiplier = Math.floor(tileSetIndex % columns); + const rowMultiplier = Math.floor(tileSetIndex / columns); + const x = margin + columnMultiplier * (tilewidth + spacing); + const y = margin + rowMultiplier * (tileheight + spacing); + const tileId = getTileIdFromTiledGUI(firstGid + tileSetIndex); + + try { + const rect = new PIXI.Rectangle(x, y, tilewidth, tileheight); + const texture = new PIXI.Texture(atlasTexture!, rect); + + textureCache.setTexture(tileId, texture); + } catch (error) { + console.error( + "An error occurred while creating a PIXI.Texture to be used in a TileMap:", + error + ); + } + } + + return textureCache; + } +} diff --git a/SharedLibs/TileMapHelper/src/types/index.ts b/SharedLibs/TileMapHelper/src/types/index.ts new file mode 100644 index 000000000000..96e9352f87b4 --- /dev/null +++ b/SharedLibs/TileMapHelper/src/types/index.ts @@ -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; + }; diff --git a/SharedLibs/TileMapHelper/tsconfig.json b/SharedLibs/TileMapHelper/tsconfig.json index 37d877b66217..a5d9b53ca2c2 100644 --- a/SharedLibs/TileMapHelper/tsconfig.json +++ b/SharedLibs/TileMapHelper/tsconfig.json @@ -1,26 +1,26 @@ { - "compileOnSave": false, - "compilerOptions": { - "module": "esnext", - "noImplicitAny": true, - "outDir": "./dist/tsc", - "target": "ES5", - "sourceMap": true, - "declaration": true, - "declarationMap": true, - "declarationDir": "./dts/", - "types" : [ - "mocha", - "expect.js", - "offscreencanvas" - ], - "lib": ["DOM", "ES5", "ES6"], - "esModuleInterop": false, - "downlevelIteration": true, - "moduleResolution": "node", - "allowSyntheticDefaultImports": true, - }, - "exclude": [ - "node_modules" - ] -} \ No newline at end of file + "compileOnSave": false, + "compilerOptions": { + "module": "esnext", + "noImplicitAny": true, + "outDir": "./dist/tsc", + "target": "ES5", + "sourceMap": true, + "declaration": true, + "declarationMap": true, + "declarationDir": "./dts/", + "types" : [ + "mocha", + "expect.js", + "offscreencanvas" + ], + "lib": ["DOM", "ES5", "ES6"], + "esModuleInterop": false, + "downlevelIteration": true, + "moduleResolution": "node", + "allowSyntheticDefaultImports": true, + }, + "exclude": [ + "node_modules" + ] +} diff --git a/newIDE/app/src/AssetStore/ResourceStore/ResourceCard.js b/newIDE/app/src/AssetStore/ResourceStore/ResourceCard.js index 1816f7b726e9..37bd786805a4 100644 --- a/newIDE/app/src/AssetStore/ResourceStore/ResourceCard.js +++ b/newIDE/app/src/AssetStore/ResourceStore/ResourceCard.js @@ -176,6 +176,7 @@ export const ResourceCard = ({ resource, onChoose, size }: Props) => { ); case 'json': + case 'tilemap': return ( diff --git a/newIDE/app/src/EventsSheet/ParameterFields/TilemapResourceField.js b/newIDE/app/src/EventsSheet/ParameterFields/TilemapResourceField.js new file mode 100644 index 000000000000..00aea74d5cab --- /dev/null +++ b/newIDE/app/src/EventsSheet/ParameterFields/TilemapResourceField.js @@ -0,0 +1,44 @@ +// @flow +import { Trans } from '@lingui/macro'; + +import React, { Component } from 'react'; +import ResourceSelector from '../../ResourcesList/ResourceSelector'; +import ResourcesLoader from '../../ResourcesLoader'; +import { type ParameterFieldProps } from './ParameterFieldCommons'; + +export default class TilemapResourceField extends Component< + ParameterFieldProps, + void +> { + _field: ?ResourceSelector; + + focus(selectAll: boolean = false) { + if (this._field) this._field.focus(selectAll); + } + + render() { + if (!this.props.resourceManagementProps || !this.props.project) { + console.error( + 'Missing project or resourceManagementProps for TilemapResourceField' + ); + return null; + } + + return ( + Choose the JSON/LDtk file to use} + onRequestClose={this.props.onRequestClose} + onApply={this.props.onApply} + ref={field => (this._field = field)} + /> + ); + } +} diff --git a/newIDE/app/src/EventsSheet/ParameterRenderingService.js b/newIDE/app/src/EventsSheet/ParameterRenderingService.js index fbe88cd8a17f..9ea4f9e8200b 100644 --- a/newIDE/app/src/EventsSheet/ParameterRenderingService.js +++ b/newIDE/app/src/EventsSheet/ParameterRenderingService.js @@ -61,6 +61,7 @@ import LeaderboardIdField, { renderInlineLeaderboardIdField, } from './ParameterFields/LeaderboardIdField'; import { IdentifierField } from './ParameterFields/IdentifierField'; +import TilemapResourceField from './ParameterFields/TilemapResourceField'; const gd: libGDevelop = global.gd; @@ -105,6 +106,7 @@ const components = { externalLayoutName: ExternalLayoutNameField, leaderboardId: LeaderboardIdField, identifier: IdentifierField, + tilemapResource: TilemapResourceField, }; const inlineRenderers: { [string]: ParameterInlineRenderer } = { default: renderInlineDefaultField, @@ -145,6 +147,7 @@ const userFriendlyTypeName: { [string]: MessageDescriptor } = { bitmapFontResource: t`Bitmap font resource`, fontResource: t`Font resource`, jsonResource: t`JSON resource`, + tilemapResource: t`Tile map resource`, color: t`Color`, forceMultiplier: t`Instant or permanent force`, sceneName: t`Scene name`, diff --git a/newIDE/app/src/ObjectsRendering/PixiResourcesLoader.js b/newIDE/app/src/ObjectsRendering/PixiResourcesLoader.js index 744d48bccf1c..41daacdd1e82 100644 --- a/newIDE/app/src/ObjectsRendering/PixiResourcesLoader.js +++ b/newIDE/app/src/ObjectsRendering/PixiResourcesLoader.js @@ -308,7 +308,7 @@ export default class PixiResourcesLoader { ); const resource = project.getResourcesManager().getResource(resourceName); - if (resource.getKind() !== 'json') + if (resource.getKind() !== 'json' && resource.getKind() !== 'tilemap') return Promise.reject( new Error(`The resource called ${resourceName} is not a json file.`) ); diff --git a/newIDE/app/src/ResourcesList/FileToCloudProjectResourceUploader.js b/newIDE/app/src/ResourcesList/FileToCloudProjectResourceUploader.js index 45ab1e5d63f3..cf72408c8e27 100644 --- a/newIDE/app/src/ResourcesList/FileToCloudProjectResourceUploader.js +++ b/newIDE/app/src/ResourcesList/FileToCloudProjectResourceUploader.js @@ -32,6 +32,7 @@ const resourceKindToInputAcceptedFiles = { font: 'font/ttf,font/otf', video: 'video/mp4,video/webm', json: 'application/json', + tilemap: 'application/json', bitmapFont: '.fnt,.xml', }; diff --git a/newIDE/app/src/ResourcesList/LocalEmbeddedResourceSources.js b/newIDE/app/src/ResourcesList/LocalEmbeddedResourceSources.js new file mode 100644 index 000000000000..57ffde6ec955 --- /dev/null +++ b/newIDE/app/src/ResourcesList/LocalEmbeddedResourceSources.js @@ -0,0 +1,218 @@ +// @flow +import optionalRequire from '../Utils/OptionalRequire'; +import newNameGenerator from '../Utils/NewNameGenerator'; +import { isPathInProjectFolder } from './ResourceUtils'; +import { createNewResource } from './ResourceSource'; +const fs = optionalRequire('fs'); +const path = optionalRequire('path'); + +export type EmbeddedResource = {| + resourceKind: string, + resourceName?: string, + + /** The "path" to the embedded resource (e.g: a tileset) as stored in the parent resource (e.g: a tilemap). */ + relPath: string, + + /** The full path to the file of the embedded resource. */ + fullPath: string, + + /** True if the embedded resource file is outside the project folder. */ + isOutsideProjectFolder: boolean, +|}; + +export type EmbeddedResources = {| + hasAnyEmbeddedResourceOutsideProjectFolder: boolean, + embeddedResources: Map, +|}; + +export type MappedResources = {| + mapping: { [key: string]: string }, +|}; + +type ParseEmbeddedFiles = ( + project: gdProject, + filePath: string +) => Promise; + +/** + * Copy the embedded resources inside the project folder + */ +export async function copyAllEmbeddedResourcesToProjectFolder( + project: gdProject, + filesWithEmbeddedResources: Map +) { + if (!fs || !path) { + return; + } + + const projectPath = path.dirname(project.getProjectFile()); + const copies = []; + + for (const { + hasAnyEmbeddedResourceOutsideProjectFolder, + embeddedResources, + } of filesWithEmbeddedResources.values()) { + if (!hasAnyEmbeddedResourceOutsideProjectFolder) continue; + + for (const embedded of embeddedResources.values()) { + if (!embedded.isOutsideProjectFolder) continue; + + const resourceBasename = path.basename(embedded.fullPath); + const fileExtension = path.extname(resourceBasename); + const fileNameWithoutExtension = path.basename( + resourceBasename, + fileExtension + ); + + const newFileNameWithoutExtension = newNameGenerator( + fileNameWithoutExtension, + tentativeFileName => { + const tentativePath = + path.join(projectPath, tentativeFileName) + fileExtension; + return fs.existsSync(tentativePath); + } + ); + + const resourceNewPath = path.join( + projectPath, + newFileNameWithoutExtension + fileExtension + ); + + embedded.resourceName = newFileNameWithoutExtension + fileExtension; + + copies.push(fs.promises.copyFile(embedded.fullPath, resourceNewPath)); + } + } + + return Promise.all(copies); +} + +/** + * Create the mapping between embedded resource path (e.g: path to a tileset) to its resource name (i.e: the name of + * the resource containing the tileset). + */ +export function createAndMapEmbeddedResources( + project: gdProject, + filesWithEmbeddedResources: Map +): Map { + const projectPath = path.dirname(project.getProjectFile()); + + const filesWithMappedResources = new Map(); + for (const [filePath, { embeddedResources }] of filesWithEmbeddedResources) { + const mapping = {}; + for (let { + resourceKind, + resourceName, + relPath, + fullPath, + } of embeddedResources.values()) { + if (!resourceName) { + resourceName = path.relative(projectPath, fullPath); + } + + const theEmbeddedResource = createNewResource(resourceKind); + if (theEmbeddedResource) { + theEmbeddedResource.setName(resourceName); + theEmbeddedResource.setFile(resourceName); + + mapping[relPath] = resourceName; + + project.getResourcesManager().addResource(theEmbeddedResource); + } + } + + filesWithMappedResources.set(filePath, { + mapping, + }); + } + + return filesWithMappedResources; +} + +/** + * List the embedded resources of a Tilemap (or JSON) resource. + * Supports LDtk tilemaps. + * + * @param project The project + * @param filePath The file path of a resource + * @returns + */ +export async function listTileMapEmbeddedResources( + project: gdProject, + filePath: string +): Promise { + if (!fs || !path) { + return null; + } + + const data = await fs.promises.readFile(filePath, 'utf8'); + try { + const tileMap = JSON.parse(data); + + // For LDtk tilemaps, read the tilesets. + if (tileMap && tileMap.__header__ && tileMap.__header__.app === 'LDtk') { + const dir = path.dirname(filePath); + const embeddedResources = new Map(); + let hasAnyEmbeddedResourceOutsideProjectFolder = false; + + for (const tileset of tileMap.defs.tilesets) { + if (tileset.relPath) { + const relPath = tileset.relPath; + const fullPath = path.resolve(dir, relPath); + const isOutsideProjectFolder = !isPathInProjectFolder( + project, + fullPath + ); + const resource: EmbeddedResource = { + resourceKind: 'image', + relPath, + fullPath, + isOutsideProjectFolder, + }; + + embeddedResources.set(relPath, resource); + + if (isOutsideProjectFolder) + hasAnyEmbeddedResourceOutsideProjectFolder = true; + } + } + + for (const level of tileMap.levels) { + if (level.bgRelPath) { + const relPath = level.bgRelPath; + const fullPath = path.resolve(dir, relPath); + const isOutsideProjectFolder = !isPathInProjectFolder( + project, + fullPath + ); + const resource: EmbeddedResource = { + resourceKind: 'image', + relPath, + fullPath, + isOutsideProjectFolder, + }; + + embeddedResources.set(level.bgRelPath, resource); + + if (isOutsideProjectFolder) + hasAnyEmbeddedResourceOutsideProjectFolder = true; + } + } + + return { + hasAnyEmbeddedResourceOutsideProjectFolder, + embeddedResources, + }; + } + } catch (error) { + console.error( + `Unable to read properly the data from file ${filePath} for use as a tilemap - ignoring any potentially embedded resources.` + ); + return null; + } +} + +export const embeddedResourcesParsers: { [string]: ParseEmbeddedFiles } = { + tilemap: listTileMapEmbeddedResources, + json: listTileMapEmbeddedResources, +}; diff --git a/newIDE/app/src/ResourcesList/LocalResourceSources.js b/newIDE/app/src/ResourcesList/LocalResourceSources.js index 5f6edeec3b1f..b72a75e35480 100644 --- a/newIDE/app/src/ResourcesList/LocalResourceSources.js +++ b/newIDE/app/src/ResourcesList/LocalResourceSources.js @@ -12,9 +12,17 @@ import { ResourceStore } from '../AssetStore/ResourceStore'; import { isPathInProjectFolder, copyAllToProjectFolder } from './ResourceUtils'; import optionalRequire from '../Utils/OptionalRequire'; import Window from '../Utils/Window'; +import { + copyAllEmbeddedResourcesToProjectFolder, + embeddedResourcesParsers, + createAndMapEmbeddedResources, + type EmbeddedResources, + type MappedResources, +} from './LocalEmbeddedResourceSources'; import { Line } from '../UI/Grid'; import RaisedButton from '../UI/RaisedButton'; import { FileToCloudProjectResourceUploader } from './FileToCloudProjectResourceUploader'; + const remote = optionalRequire('@electron/remote'); const dialog = remote ? remote.dialog : null; const path = optionalRequire('path'); @@ -81,11 +89,35 @@ const localResourceSources: Array = [ const lastUsedPath = path.parse(filePaths[0]).dir; setLastUsedPath(project, kind, lastUsedPath); - const outsideProjectFolderPaths = filePaths.filter( + let hasFilesOutsideProjectFolder = filePaths.some( path => !isPathInProjectFolder(project, path) ); - if (outsideProjectFolderPaths.length) { + // Some resources, like tilemaps, can have references to other files. + // We parse these files, optionally copy them, then create a mapping from the previous file name + // as written inside the tilemap to the name of the resource that is representing this file. + const filesWithEmbeddedResources = new Map(); + const parseEmbeddedResources = embeddedResourcesParsers[kind]; + if (parseEmbeddedResources) { + for (const filePath of filePaths) { + const embeddedResources = await parseEmbeddedResources( + project, + filePath + ); + + if (embeddedResources) { + filesWithEmbeddedResources.set(filePath, embeddedResources); + + if (embeddedResources.hasAnyEmbeddedResourceOutsideProjectFolder) + hasFilesOutsideProjectFolder = true; + } + } + } + + // Check if files should be copied in the project folder. + const newToOldFilePaths = new Map(); + let filesWithMappedResources = new Map(); + if (hasFilesOutsideProjectFolder) { const answer = Window.showConfirmDialog( i18n._( t`This/these file(s) are outside the project folder. Would you like to make a copy of them in your project folder first (recommended)?` @@ -93,16 +125,51 @@ const localResourceSources: Array = [ ); if (answer) { - filePaths = await copyAllToProjectFolder(project, filePaths); + filePaths = await copyAllToProjectFolder( + project, + filePaths, + newToOldFilePaths + ); + + await copyAllEmbeddedResourcesToProjectFolder( + project, + filesWithEmbeddedResources + ); } } + // In case of resources embedded inside others, + // create a mapping from the file name + // as written inside the resource (e.g: the tilemap) + // to the name of the resource that was created to + // represent this file. + filesWithMappedResources = createAndMapEmbeddedResources( + project, + filesWithEmbeddedResources + ); + return filePaths.map(filePath => { const newResource = createNewResource(); - const projectPath = path.dirname(project.getProjectFile()); newResource.setFile(path.relative(projectPath, filePath)); newResource.setName(path.relative(projectPath, filePath)); + const filePathWithMapping = newToOldFilePaths.has(filePath) + ? newToOldFilePaths.get(filePath) + : filePath; + if (filePathWithMapping) { + const mappedResources = filesWithMappedResources.get( + filePathWithMapping + ); + + if (mappedResources && mappedResources.mapping) { + newResource.setMetadata( + JSON.stringify({ + embeddedResourcesMapping: mappedResources.mapping, + }) + ); + } + } + return newResource; }); }; diff --git a/newIDE/app/src/ResourcesList/ResourcePreview/index.js b/newIDE/app/src/ResourcesList/ResourcePreview/index.js index 2d2f3ac7b718..0fc734aa043f 100644 --- a/newIDE/app/src/ResourcesList/ResourcePreview/index.js +++ b/newIDE/app/src/ResourcesList/ResourcePreview/index.js @@ -73,6 +73,7 @@ export default class ResourcePreview extends React.PureComponent { } /> ); case 'json': + case 'tilemap': return ( } diff --git a/newIDE/app/src/ResourcesList/ResourceSelector.js b/newIDE/app/src/ResourcesList/ResourceSelector.js index 29ccd19356fc..fb5fa242a8a0 100644 --- a/newIDE/app/src/ResourcesList/ResourceSelector.js +++ b/newIDE/app/src/ResourcesList/ResourceSelector.js @@ -259,7 +259,7 @@ export default class ResourceSelector extends React.Component { }, }; resourceExternalEditor.edit(externalEditorOptions); - } else if (resourceKind === 'json') { + } else if (resourceKind === 'json' || resourceKind === 'tilemap') { const externalEditorOptions = { project, resourcesLoader, diff --git a/newIDE/app/src/ResourcesList/ResourceSource.js b/newIDE/app/src/ResourcesList/ResourceSource.js index ee6350f101ae..7c446cd4a4c2 100644 --- a/newIDE/app/src/ResourcesList/ResourceSource.js +++ b/newIDE/app/src/ResourcesList/ResourceSource.js @@ -17,6 +17,7 @@ export type ResourceKind = | 'font' | 'video' | 'json' + | 'tilemap' | 'bitmapFont'; export const allResourceKindsAndMetadata = [ @@ -50,6 +51,12 @@ export const allResourceKindsAndMetadata = [ fileExtensions: ['json'], createNewResource: () => new gd.JsonResource(), }, + { + kind: 'tilemap', + displayName: t`Tile Map`, + fileExtensions: ['json', 'ldtk'], + createNewResource: () => new gd.TilemapResource(), + }, { kind: 'bitmapFont', displayName: t`Bitmap Font`, @@ -58,6 +65,15 @@ export const allResourceKindsAndMetadata = [ }, ]; +const constructors = {}; +for (const { kind, createNewResource } of allResourceKindsAndMetadata) { + constructors[kind] = createNewResource; +} + +export function createNewResource(kind: string): ?gdResource { + return constructors[kind] ? constructors[kind]() : null; +} + export type ChooseResourceOptions = {| initialSourceName: string, multiSelection: boolean, diff --git a/newIDE/app/src/ResourcesList/ResourceUtils.js b/newIDE/app/src/ResourcesList/ResourceUtils.js index 140a2e2f8569..f8f71828b2ff 100644 --- a/newIDE/app/src/ResourcesList/ResourceUtils.js +++ b/newIDE/app/src/ResourcesList/ResourceUtils.js @@ -61,7 +61,8 @@ export const isPathInProjectFolder = ( export const copyAllToProjectFolder = ( project: gdProject, - resourcePaths: Array + resourcePaths: Array, + newToOldFilePaths: Map ): Promise> => { if (!fs || !path) { return Promise.resolve(resourcePaths); @@ -72,6 +73,8 @@ export const copyAllToProjectFolder = ( return Promise.all( resourcePaths.map(resourcePath => { if (isPathInProjectFolder(project, resourcePath)) { + newToOldFilePaths.set(resourcePath, resourcePath); + return resourcePath; } @@ -99,9 +102,13 @@ export const copyAllToProjectFolder = ( return new Promise(resolve => { fs.copyFile(resourcePath, resourceNewPath, err => { if (err) { + newToOldFilePaths.set(resourcePath, resourcePath); + return resolve(resourcePath); } + newToOldFilePaths.set(resourceNewPath, resourcePath); + return resolve(resourceNewPath); }); }); diff --git a/newIDE/app/src/ResourcesList/index.js b/newIDE/app/src/ResourcesList/index.js index e16ab9414b83..af5232a3f8e2 100644 --- a/newIDE/app/src/ResourcesList/index.js +++ b/newIDE/app/src/ResourcesList/index.js @@ -197,6 +197,8 @@ export default class ResourcesList extends React.Component { return 'res/actions/music24.png'; case 'json': return 'res/actions/fichier24.png'; + case 'tilemap': + return 'res/actions/star24.png'; case 'video': return 'JsPlatform/Extensions/videoicon24.png'; case 'font': diff --git a/newIDE/app/src/stories/componentStories/ParameterFields/ResourceFields.stories.js b/newIDE/app/src/stories/componentStories/ParameterFields/ResourceFields.stories.js index 4ba618767217..6d9e01733f13 100644 --- a/newIDE/app/src/stories/componentStories/ParameterFields/ResourceFields.stories.js +++ b/newIDE/app/src/stories/componentStories/ParameterFields/ResourceFields.stories.js @@ -18,6 +18,7 @@ import VideoResourceField from '../../../EventsSheet/ParameterFields/VideoResour import BitmapFontResourceField from '../../../EventsSheet/ParameterFields/BitmapFontResourceField'; import FontResourceField from '../../../EventsSheet/ParameterFields/FontResourceField'; import JsonResourceField from '../../../EventsSheet/ParameterFields/JsonResourceField'; +import TilemapResourceField from '../../../EventsSheet/ParameterFields/TilemapResourceField'; const gd: libGDevelop = global.gd; @@ -161,6 +162,29 @@ export const AllResourceFields = () => ( )} /> + + ( + emptyStorageProvider, + onFetchNewlyAddedResources: async () => {}, + resourceSources: [], + onChooseResource: () => Promise.reject('Unimplemented'), + resourceExternalEditors: fakeResourceExternalEditors, + }} + /> + )} + /> + );