diff --git a/docs/docs/essentials/loading-maps.md b/docs/docs/essentials/loading-maps.md index d262ec9..7b6f0c1 100644 --- a/docs/docs/essentials/loading-maps.md +++ b/docs/docs/essentials/loading-maps.md @@ -5,13 +5,10 @@ Loading maps with DotTiled is very flexible and allows you as a developer to fre > [!TIP] > For a quick and easy way to load maps from the filesystem, please refer to the [quickstart guide](../quickstart.md). -## File format caveats +## File formats The class is a representation of a Tiled map, mimicking the structure of a Tiled XML map file. Map files can either be in the [`.tmx`/XML](https://doc.mapeditor.org/en/stable/reference/tmx-map-format/) or [`.tmj`/json](https://doc.mapeditor.org/en/stable/reference/json-map-format/) format. DotTiled supports **both** formats fully. -> [!WARNING] -> Using the `.tmj` file format will result in (the source image for image layers) not having the same amount of information as for the `.tmx` format. This is due to the fact that the `.tmj` format does not include the full information that the `.tmx` format does. This is not a problem with DotTiled, but rather a limitation of the `.tmj` format. - ## The process of loading a map Loading a map with DotTiled is not a complex process, but one that at least demands a basic understanding of how Tiled maps are structured. The process can be broken down into the following flow(-ish) chart: diff --git a/docs/docs/essentials/representation-model.md b/docs/docs/essentials/representation-model.md index b1b6ef7..ab3ce6e 100644 --- a/docs/docs/essentials/representation-model.md +++ b/docs/docs/essentials/representation-model.md @@ -12,6 +12,9 @@ Certain properties throughout the representation model are marked as *optional* The representation model is designed to be compatible with the latest version of Tiled. This means that it may not be able to read files from older versions of Tiled, or files that use features that are not yet supported by the representation model. However, here is a table of which versions of Tiled are supported by which versions of DotTiled. -| Tiled version | Compatible DotTiled version(s) | -|---------------|--------------------------------| -| 1.11 | 0.1.0, 0.2.0, 0.2.1, 0.3.0 | \ No newline at end of file +You should use one of the versions of DotTiled that is compatible with the version of Tiled you are using. + +| Tiled version | Compatible DotTiled version(s) | +|----------------|--------------------------------| +| 1.11.1, 1.11.2 | 0.4.0 | +| 1.11 | 0.1.0, 0.2.0, 0.2.1, 0.3.0 | \ No newline at end of file diff --git a/src/DotTiled.Tests/TestData/Maps/map-with-many-layers/map-with-many-layers.cs b/src/DotTiled.Tests/TestData/Maps/map-with-many-layers/map-with-many-layers.cs index 35c4cbd..593eec7 100644 --- a/src/DotTiled.Tests/TestData/Maps/map-with-many-layers/map-with-many-layers.cs +++ b/src/DotTiled.Tests/TestData/Maps/map-with-many-layers/map-with-many-layers.cs @@ -19,7 +19,7 @@ public partial class TestData CompressionLevel = -1, BackgroundColor = new TiledColor { R = 0, G = 0, B = 0, A = 0 }, Version = "1.10", - TiledVersion = "1.11.0", + TiledVersion = "1.11.2", NextLayerID = 8, NextObjectID = 7, Tilesets = [ @@ -172,8 +172,8 @@ public partial class TestData { Format = ImageFormat.Png, Source = "tileset.png", - Width = fileExt == "tmx" ? 256 : 0, // Currently, json format does not - Height = fileExt == "tmx" ? 96 : 0 // include image dimensions in image layer https://github.com/mapeditor/tiled/issues/4028 + Width = 256, + Height = 96 }, RepeatX = true }, diff --git a/src/DotTiled.Tests/TestData/Maps/map-with-many-layers/map-with-many-layers.tmj b/src/DotTiled.Tests/TestData/Maps/map-with-many-layers/map-with-many-layers.tmj index 9e9f669..427f404 100644 --- a/src/DotTiled.Tests/TestData/Maps/map-with-many-layers/map-with-many-layers.tmj +++ b/src/DotTiled.Tests/TestData/Maps/map-with-many-layers/map-with-many-layers.tmj @@ -114,6 +114,8 @@ { "id":4, "image":"tileset.png", + "imageheight":96, + "imagewidth":256, "name":"ImageLayer", "opacity":1, "repeatx":true, @@ -149,7 +151,7 @@ "nextobjectid":7, "orientation":"orthogonal", "renderorder":"right-down", - "tiledversion":"1.11.0", + "tiledversion":"1.11.2", "tileheight":32, "tilesets":[ { diff --git a/src/DotTiled.Tests/TestData/Maps/map-with-many-layers/map-with-many-layers.tmx b/src/DotTiled.Tests/TestData/Maps/map-with-many-layers/map-with-many-layers.tmx index 5888069..512a7a4 100644 --- a/src/DotTiled.Tests/TestData/Maps/map-with-many-layers/map-with-many-layers.tmx +++ b/src/DotTiled.Tests/TestData/Maps/map-with-many-layers/map-with-many-layers.tmx @@ -1,5 +1,5 @@ - + diff --git a/src/DotTiled/DotTiled.csproj b/src/DotTiled/DotTiled.csproj index 6e8de2a..d8d83a5 100644 --- a/src/DotTiled/DotTiled.csproj +++ b/src/DotTiled/DotTiled.csproj @@ -18,7 +18,7 @@ true Copyright © 2024 dcronqvist LICENSE - 0.3.0 + 0.4.0 diff --git a/src/DotTiled/Serialization/Tmj/TmjReaderBase.ImageLayer.cs b/src/DotTiled/Serialization/Tmj/TmjReaderBase.ImageLayer.cs index 0da963d..c0c2c5b 100644 --- a/src/DotTiled/Serialization/Tmj/TmjReaderBase.ImageLayer.cs +++ b/src/DotTiled/Serialization/Tmj/TmjReaderBase.ImageLayer.cs @@ -19,6 +19,8 @@ public abstract partial class TmjReaderBase var properties = ResolveAndMergeProperties(@class, element.GetOptionalPropertyCustom("properties", ReadProperties).GetValueOr([])); var image = element.GetRequiredProperty("image"); + var imageWidth = element.GetOptionalProperty("imagewidth").GetValueOr(0); + var imageHeight = element.GetOptionalProperty("imageheight").GetValueOr(0); var repeatX = element.GetOptionalProperty("repeatx").GetValueOr(false); var repeatY = element.GetOptionalProperty("repeaty").GetValueOr(false); var transparentColor = element.GetOptionalPropertyParseable("transparentcolor"); @@ -28,8 +30,8 @@ public abstract partial class TmjReaderBase var imgModel = new Image { Format = Helpers.ParseImageFormatFromSource(image), - Height = 0, - Width = 0, + Height = imageHeight, + Width = imageWidth, Source = image, TransparentColor = transparentColor };