From 782e771a4146533e464ceda1f353dc63f40484d2 Mon Sep 17 00:00:00 2001 From: Anders Kehlet Date: Thu, 3 Oct 2024 22:26:47 +0200 Subject: [PATCH 1/4] Fix type of visible attribute in tileset object group. --- src/DotTiled/Serialization/Tmx/TmxReaderBase.ObjectLayer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DotTiled/Serialization/Tmx/TmxReaderBase.ObjectLayer.cs b/src/DotTiled/Serialization/Tmx/TmxReaderBase.ObjectLayer.cs index 85c669c..46626e6 100644 --- a/src/DotTiled/Serialization/Tmx/TmxReaderBase.ObjectLayer.cs +++ b/src/DotTiled/Serialization/Tmx/TmxReaderBase.ObjectLayer.cs @@ -97,7 +97,7 @@ public abstract partial class TmxReaderBase var height = _reader.GetOptionalAttributeParseable("height").GetValueOr(heightDefault); var rotation = _reader.GetOptionalAttributeParseable("rotation").GetValueOr(rotationDefault); var gid = _reader.GetOptionalAttributeParseable("gid").GetValueOrOptional(gidDefault); - var visible = _reader.GetOptionalAttributeParseable("visible").GetValueOr(visibleDefault); + var visible = _reader.GetOptionalAttributeParseable("visible").GetValueOr(visibleDefault ? 1u : 0u) == 1; // Elements DotTiled.Object foundObject = null; From e411d515732aa81a2105962dc2182c1af34215d1 Mon Sep 17 00:00:00 2001 From: Daniel Cronqvist Date: Fri, 4 Oct 2024 21:16:00 +0200 Subject: [PATCH 2/4] Make sure to run console example application as part of test suite --- Makefile | 1 + .../DotTiled.Example.Console.csproj | 24 +++--------------- .../DotTiled.Example.Console/Program.cs | 21 ++++++++------- .../embedded-tilemap.tmx | 12 --------- .../embedded-tileset.png | Bin 149 -> 0 bytes .../embedded-tileset.tsx | 4 --- 6 files changed, 16 insertions(+), 46 deletions(-) delete mode 100644 src/DotTiled.Examples/DotTiled.Example.Console/embedded-tilemap.tmx delete mode 100644 src/DotTiled.Examples/DotTiled.Example.Console/embedded-tileset.png delete mode 100644 src/DotTiled.Examples/DotTiled.Example.Console/embedded-tileset.tsx diff --git a/Makefile b/Makefile index f7382f5..30ddf7e 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ test: dotnet build src/DotTiled.sln dotnet test src/DotTiled.sln + dotnet run --project src/DotTiled.Examples/DotTiled.Example.Console/DotTiled.Example.Console.csproj -- src/DotTiled.Examples/DotTiled.Example.Console docs-serve: docs/index.md docfx docs/docfx.json --serve diff --git a/src/DotTiled.Examples/DotTiled.Example.Console/DotTiled.Example.Console.csproj b/src/DotTiled.Examples/DotTiled.Example.Console/DotTiled.Example.Console.csproj index c9bf1a8..0dbaba2 100644 --- a/src/DotTiled.Examples/DotTiled.Example.Console/DotTiled.Example.Console.csproj +++ b/src/DotTiled.Examples/DotTiled.Example.Console/DotTiled.Example.Console.csproj @@ -12,27 +12,9 @@ - - Always - - - Always - - - Always - - - Always - - - - - - - - - - + + + diff --git a/src/DotTiled.Examples/DotTiled.Example.Console/Program.cs b/src/DotTiled.Examples/DotTiled.Example.Console/Program.cs index 234012a..9dba3df 100644 --- a/src/DotTiled.Examples/DotTiled.Example.Console/Program.cs +++ b/src/DotTiled.Examples/DotTiled.Example.Console/Program.cs @@ -5,18 +5,20 @@ namespace DotTiled.Example; public class Program { - private static void Main() + private static void Main(string[] args) { - Quick(); + Quick(args[0]); Manual(); } // QUICK START // Automatic and easy way to load tilemaps. - private static void Quick() + private static void Quick(string basePath) { + var tilemapPath = Path.Combine(basePath, "tilemap.tmx"); + var loader = Loader.Default(); - var map = loader.LoadMap("tilemap.tmx"); + var map = loader.LoadMap(tilemapPath); // You can do stuff with it like... Console.WriteLine($"Tile width and height: {map.TileWidth}x{map.TileHeight}"); @@ -28,9 +30,10 @@ public class Program // Manually load a map, if you need to load from a custom source private static void Manual() { - using var mapFileReader = new StreamReader("tilemap.tmx"); - var mapString = mapFileReader.ReadToEnd(); - using var mapReader = new MapReader(mapString, ResolveTileset, ResolveTemplate, ResolveCustomType); + using Stream? tilemapStream = Assembly.GetExecutingAssembly().GetManifestResourceStream($"DotTiled.Example.Console.tilemap.tmx") + ?? throw new FileLoadException($"DotTiled.Example.Console.tilemap.tmx not found in assembly."); + string tileMapString = new StreamReader(tilemapStream).ReadToEnd(); + using var mapReader = new MapReader(tileMapString, ResolveTileset, ResolveTemplate, ResolveCustomType); var map = mapReader.ReadMap(); // Now do some other stuff with it... @@ -50,7 +53,7 @@ public class Program { // Read a file from assembly // You can use any other source for files, eg. compressed archive, or even file from internet. - using Stream? tilesetStream = Assembly.GetExecutingAssembly().GetManifestResourceStream($"DotTiled.Example.embedded-{source}") + using Stream? tilesetStream = Assembly.GetExecutingAssembly().GetManifestResourceStream($"DotTiled.Example.Console.{source}") ?? throw new FileLoadException($"{source} not found in assembly."); string tilesetString = new StreamReader(tilesetStream).ReadToEnd(); @@ -62,7 +65,7 @@ public class Program // This is pretty similar to above, but instead it loads templates, not tilesets. private static Template ResolveTemplate(string source) { - using Stream? templateStream = Assembly.GetExecutingAssembly().GetManifestResourceStream($"DotTiled.Example.{source}") + using Stream? templateStream = Assembly.GetExecutingAssembly().GetManifestResourceStream($"DotTiled.Example.Console.{source}") ?? throw new FileLoadException($"{source} not found in assembly."); string templateString = new StreamReader(templateStream).ReadToEnd(); diff --git a/src/DotTiled.Examples/DotTiled.Example.Console/embedded-tilemap.tmx b/src/DotTiled.Examples/DotTiled.Example.Console/embedded-tilemap.tmx deleted file mode 100644 index 7a9a294..0000000 --- a/src/DotTiled.Examples/DotTiled.Example.Console/embedded-tilemap.tmx +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAA== - - - diff --git a/src/DotTiled.Examples/DotTiled.Example.Console/embedded-tileset.png b/src/DotTiled.Examples/DotTiled.Example.Console/embedded-tileset.png deleted file mode 100644 index 67b9eeea3c0801c3a7092d76b229e2560ee5d7c0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 149 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61SBU+%rFB|jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1qucK`l=g#}Etu})QSZQ qC$3zWaLH~Bhp(&*Z!NEp7Q<%lsS3|M&zb^tF?hQAxvX - - - From 69f68d5853b294b03d95a7c389cad9f6f7a7ba35 Mon Sep 17 00:00:00 2001 From: Daniel Cronqvist Date: Fri, 4 Oct 2024 21:22:43 +0200 Subject: [PATCH 3/4] Update version compatibility matrix --- docs/docs/essentials/representation-model.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/essentials/representation-model.md b/docs/docs/essentials/representation-model.md index 88dbdff..9fef3e0 100644 --- a/docs/docs/essentials/representation-model.md +++ b/docs/docs/essentials/representation-model.md @@ -14,4 +14,4 @@ The representation model is designed to be compatible with the latest version of | Tiled version | Compatible DotTiled version(s) | |---------------|--------------------------------| -| 1.11 | 0.1.0, 0.2.0 | \ No newline at end of file +| 1.11 | 0.1.0, 0.2.0, 0.2.1 | \ No newline at end of file From d943a8d8b72038696cc65cd60d522c3b936f99c5 Mon Sep 17 00:00:00 2001 From: Daniel Cronqvist Date: Fri, 4 Oct 2024 21:25:36 +0200 Subject: [PATCH 4/4] Update version in .csproj --- src/DotTiled/DotTiled.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DotTiled/DotTiled.csproj b/src/DotTiled/DotTiled.csproj index acf3e99..a5d41c3 100644 --- a/src/DotTiled/DotTiled.csproj +++ b/src/DotTiled/DotTiled.csproj @@ -18,7 +18,7 @@ true Copyright © 2024 dcronqvist LICENSE - 0.2.0 + 0.2.1