Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release v0.2.1 #39

Merged
merged 6 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/essentials/representation-model.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Original file line number Diff line number Diff line change
Expand Up @@ -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>
21 changes: 12 additions & 9 deletions src/DotTiled.Examples/DotTiled.Example.Console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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}");
Expand All @@ -28,9 +30,10 @@ private static void Quick()
// 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...
Expand All @@ -50,7 +53,7 @@ private static Tileset ResolveTileset(string source)
{
// 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();

Expand All @@ -62,7 +65,7 @@ private static Tileset ResolveTileset(string source)
// 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();

Expand Down

This file was deleted.

Binary file not shown.

This file was deleted.

2 changes: 1 addition & 1 deletion src/DotTiled/DotTiled.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ internal DotTiled.Object ReadObject()
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;
Expand Down
Loading