Merge pull request #39 from dcronqvist/release-v0.2.1

Release v0.2.1
This commit is contained in:
dcronqvist 2024-10-04 21:26:48 +02:00 committed by GitHub
commit 88352cfa45
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 19 additions and 49 deletions

View file

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

View file

@ -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 |
| 1.11 | 0.1.0, 0.2.0, 0.2.1 |

View file

@ -12,27 +12,9 @@
</ItemGroup>
<ItemGroup>
<None Update="tilemap.tmx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="tileset.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="assets\tileset.tsx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="tileset.tsx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<None Remove="embedded-tilemap.tmx" />
<EmbeddedResource Include="embedded-tilemap.tmx" />
<None Remove="embedded-tileset.png" />
<EmbeddedResource Include="embedded-tileset.png" />
<None Remove="embedded-tileset.tsx" />
<EmbeddedResource Include="embedded-tileset.tsx" />
<EmbeddedResource Include="tilemap.tmx" />
<EmbeddedResource Include="tileset.png" />
<EmbeddedResource Include="tileset.tsx" />
</ItemGroup>
</Project>

View file

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

View file

@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.10" tiledversion="1.11.0" orientation="orthogonal" renderorder="right-down" width="10" height="10" tilewidth="16" tileheight="16" infinite="0" nextlayerid="5" nextobjectid="1">
<properties>
<property name="hello" value="Hello from DotTiled!"/>
</properties>
<tileset firstgid="1" source="tileset.tsx"/>
<layer id="1" name="Tile Layer 1" width="10" height="10">
<data encoding="base64">
AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAA==
</data>
</layer>
</map>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 149 B

View file

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<tileset version="1.8" tiledversion="1.10.2" name="tileset" tilewidth="16" tileheight="16" tilecount="1" columns="1">
<image source="tileset.png" width="16" height="16"/>
</tileset>

View file

@ -18,7 +18,7 @@
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<Copyright>Copyright © 2024 dcronqvist</Copyright>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<Version>0.2.0</Version>
<Version>0.2.1</Version>
</PropertyGroup>
<ItemGroup>

View file

@ -97,7 +97,7 @@ public abstract partial class TmxReaderBase
var height = _reader.GetOptionalAttributeParseable<float>("height").GetValueOr(heightDefault);
var rotation = _reader.GetOptionalAttributeParseable<float>("rotation").GetValueOr(rotationDefault);
var gid = _reader.GetOptionalAttributeParseable<uint>("gid").GetValueOrOptional(gidDefault);
var visible = _reader.GetOptionalAttributeParseable<bool>("visible").GetValueOr(visibleDefault);
var visible = _reader.GetOptionalAttributeParseable<uint>("visible").GetValueOr(visibleDefault ? 1u : 0u) == 1;
// Elements
DotTiled.Object foundObject = null;