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.Examples/DotTiled.Example.MonoGame/.config/dotnet-tools.json b/src/DotTiled.Examples/DotTiled.Example.MonoGame/.config/dotnet-tools.json new file mode 100644 index 0000000..afd4e2c --- /dev/null +++ b/src/DotTiled.Examples/DotTiled.Example.MonoGame/.config/dotnet-tools.json @@ -0,0 +1,36 @@ +{ + "version": 1, + "isRoot": true, + "tools": { + "dotnet-mgcb": { + "version": "3.8.3", + "commands": [ + "mgcb" + ] + }, + "dotnet-mgcb-editor": { + "version": "3.8.3", + "commands": [ + "mgcb-editor" + ] + }, + "dotnet-mgcb-editor-linux": { + "version": "3.8.3", + "commands": [ + "mgcb-editor-linux" + ] + }, + "dotnet-mgcb-editor-windows": { + "version": "3.8.3", + "commands": [ + "mgcb-editor-windows" + ] + }, + "dotnet-mgcb-editor-mac": { + "version": "3.8.3", + "commands": [ + "mgcb-editor-mac" + ] + } + } +} \ No newline at end of file diff --git a/src/DotTiled.Examples/DotTiled.Example.MonoGame/Camera2D.cs b/src/DotTiled.Examples/DotTiled.Example.MonoGame/Camera2D.cs new file mode 100644 index 0000000..58f724b --- /dev/null +++ b/src/DotTiled.Examples/DotTiled.Example.MonoGame/Camera2D.cs @@ -0,0 +1,52 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; + +namespace DotTiled.Example.MonoGame; + +public class Camera2D +{ + public float Zoom { get; set; } + public Vector2 Position { get; set; } + public Rectangle Bounds { get; protected set; } + public Rectangle VisibleArea { get; protected set; } + public Matrix Transform { get; protected set; } + + public Camera2D(Viewport viewport) + { + Bounds = viewport.Bounds; + Zoom = 1f; + Position = Vector2.Zero; + } + + private void UpdateVisibleArea() + { + var inverseViewMatrix = Matrix.Invert(Transform); + + var tl = Vector2.Transform(Vector2.Zero, inverseViewMatrix); + var tr = Vector2.Transform(new Vector2(Bounds.X, 0), inverseViewMatrix); + var bl = Vector2.Transform(new Vector2(0, Bounds.Y), inverseViewMatrix); + var br = Vector2.Transform(new Vector2(Bounds.Width, Bounds.Height), inverseViewMatrix); + + var min = new Vector2( + MathHelper.Min(tl.X, MathHelper.Min(tr.X, MathHelper.Min(bl.X, br.X))), + MathHelper.Min(tl.Y, MathHelper.Min(tr.Y, MathHelper.Min(bl.Y, br.Y)))); + var max = new Vector2( + MathHelper.Max(tl.X, MathHelper.Max(tr.X, MathHelper.Max(bl.X, br.X))), + MathHelper.Max(tl.Y, MathHelper.Max(tr.Y, MathHelper.Max(bl.Y, br.Y)))); + VisibleArea = new Rectangle((int)min.X, (int)min.Y, (int)(max.X - min.X), (int)(max.Y - min.Y)); + } + + private void UpdateMatrix() + { + Transform = Matrix.CreateTranslation(new Vector3(-Position.X, -Position.Y, 0)) * + Matrix.CreateScale(Zoom) * + Matrix.CreateTranslation(new Vector3(Bounds.Width * 0.5f, Bounds.Height * 0.5f, 0)); + UpdateVisibleArea(); + } + + public void UpdateCamera(Viewport bounds) + { + Bounds = bounds.Bounds; + UpdateMatrix(); + } +} diff --git a/src/DotTiled.Examples/DotTiled.Example.MonoGame/Content/Content.mgcb b/src/DotTiled.Examples/DotTiled.Example.MonoGame/Content/Content.mgcb new file mode 100644 index 0000000..2a28765 --- /dev/null +++ b/src/DotTiled.Examples/DotTiled.Example.MonoGame/Content/Content.mgcb @@ -0,0 +1,33 @@ + +#----------------------------- Global Properties ----------------------------# + +/outputDir:bin/$(Platform) +/intermediateDir:obj/$(Platform) +/platform:DesktopGL +/config: +/profile:Reach +/compress:False + +#-------------------------------- References --------------------------------# + + +#---------------------------------- Content ---------------------------------# + +#begin kenney_roguelike-rpg-pack/roguelikeSheet_transparent.png +/importer:TextureImporter +/processor:TextureProcessor +/processorParam:ColorKeyColor=255,0,255,255 +/processorParam:ColorKeyEnabled=True +/processorParam:GenerateMipmaps=False +/processorParam:PremultiplyAlpha=True +/processorParam:ResizeToPowerOfTwo=False +/processorParam:MakeSquare=False +/processorParam:TextureFormat=Color +/build:kenney_roguelike-rpg-pack/roguelikeSheet_transparent.png + +#begin world-tileset.tsx +/copy:world-tileset.tsx + +#begin world.tmx +/copy:world.tmx + diff --git a/src/DotTiled.Examples/DotTiled.Example.MonoGame/Content/kenney_roguelike-rpg-pack/License.txt b/src/DotTiled.Examples/DotTiled.Example.MonoGame/Content/kenney_roguelike-rpg-pack/License.txt new file mode 100644 index 0000000..3b4c9db --- /dev/null +++ b/src/DotTiled.Examples/DotTiled.Example.MonoGame/Content/kenney_roguelike-rpg-pack/License.txt @@ -0,0 +1,23 @@ + +############################################################################### + + + Roguelike pack + by Kenney Vleugels for Kenney (www.kenney.nl) + with help by Lynn Evers (Twitter: @EversLynn) + + ------------------------------ + + License (Creative Commons Zero, CC0) + http://creativecommons.org/publicdomain/zero/1.0/ + + You may use these graphics in personal and commercial projects. + Credit (Kenney or www.kenney.nl) would be nice but is not mandatory. + + ------------------------------ + + Donate: http://donate.kenney.nl/ + Request: http://request.kenney.nl/ + + +############################################################################### \ No newline at end of file diff --git a/src/DotTiled.Examples/DotTiled.Example.MonoGame/Content/kenney_roguelike-rpg-pack/roguelikeSheet_transparent.png b/src/DotTiled.Examples/DotTiled.Example.MonoGame/Content/kenney_roguelike-rpg-pack/roguelikeSheet_transparent.png new file mode 100644 index 0000000..79b1332 Binary files /dev/null and b/src/DotTiled.Examples/DotTiled.Example.MonoGame/Content/kenney_roguelike-rpg-pack/roguelikeSheet_transparent.png differ diff --git a/src/DotTiled.Examples/DotTiled.Example.MonoGame/Content/world-tileset.tsx b/src/DotTiled.Examples/DotTiled.Example.MonoGame/Content/world-tileset.tsx new file mode 100644 index 0000000..ee710e9 --- /dev/null +++ b/src/DotTiled.Examples/DotTiled.Example.MonoGame/Content/world-tileset.tsx @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/DotTiled.Examples/DotTiled.Example.MonoGame/Content/world.tmx b/src/DotTiled.Examples/DotTiled.Example.MonoGame/Content/world.tmx new file mode 100644 index 0000000..6056474 --- /dev/null +++ b/src/DotTiled.Examples/DotTiled.Example.MonoGame/Content/world.tmx @@ -0,0 +1,434 @@ + + +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117,118,59,61,61,61,62,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,60,61,61,58,119,0,0,0,0,0,0,60,61,61,61,62,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,116,61,61,62,0,0,0,0,0,0,3,116,61,61,61,62,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,60,61,61,61,115,5,0,0,0,0,0,60,61,61,61,61,62,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,60,61,61,61,61,115,4,4,4,4,4,116,61,61,61,61,62,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,60,61,61,61,61,61,61,61,61,61,61,61,61,61,61,58,119,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,117,59,61,61,61,61,61,61,61,61,61,61,61,61,61,62,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,60,61,61,61,61,61,61,61,61,61,61,61,58,118,119,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,117,118,118,118,118,118,118,118,118,118,118,118,119,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,3,4,4,4,4,4,4,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,60,61,61,61,61,61,61,115,4,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,3,116,61,61,61,61,61,61,61,61,115,4,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,60,61,61,61,61,61,61,61,61,61,61,61,115,4,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,3,116,61,61,61,61,61,61,61,61,61,61,61,61,61,115,4,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,60,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,115,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,60,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,62,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,3,116,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,58,119,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,60,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,58,119,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,3,116,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,58,119,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,60,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,58,119,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,60,61,61,61,61,61,61,61,61,61,61,61,61,61,58,118,119,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,117,59,61,61,61,61,61,61,61,61,61,58,118,118,119,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,117,118,118,59,61,61,61,58,118,118,119,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,117,118,118,118,119,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0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,0,0,0,0,407,466,466,465,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,407,466,466,466,466,465,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,407,466,466,466,466,465,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,407,466,405,465,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,407,466,465,0,409,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,407,465,0,0,0,409,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,407,466,465,0,0,0,0,409,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,407,466,465,0,0,0,0,0,0,409,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,407,466,466,466,466,466,466,466,466,466,466,466,466,466,466,466,465,0,0,0,0,0,0,0,0,464,408,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,409,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,464,408,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,409,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,464,408,0,0,0,0,0,0,0,0,0,0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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/DotTiled.Examples/DotTiled.Example.MonoGame/DotTiled.Example.MonoGame.csproj b/src/DotTiled.Examples/DotTiled.Example.MonoGame/DotTiled.Example.MonoGame.csproj new file mode 100644 index 0000000..07a4569 --- /dev/null +++ b/src/DotTiled.Examples/DotTiled.Example.MonoGame/DotTiled.Example.MonoGame.csproj @@ -0,0 +1,36 @@ + + + Exe + net8.0 + Major + false + false + + + app.manifest + Icon.ico + + + + + + + + Icon.ico + + + Icon.bmp + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/DotTiled.Examples/DotTiled.Example.MonoGame/Game1.cs b/src/DotTiled.Examples/DotTiled.Example.MonoGame/Game1.cs new file mode 100644 index 0000000..3c38bf8 --- /dev/null +++ b/src/DotTiled.Examples/DotTiled.Example.MonoGame/Game1.cs @@ -0,0 +1,231 @@ +using System.Collections.Generic; +using System.IO; +using System.Linq; +using DotTiled.Serialization; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework.Input; + +namespace DotTiled.Example.MonoGame; + +/// +/// A beginner-friendly example of using DotTiled with MonoGame. +/// Loads a Tiled map, renders its layers, and allows basic player movement with collision. +/// +public class Game1 : Game +{ + private readonly GraphicsDeviceManager _graphics; + private SpriteBatch _spriteBatch; + + // Camera for following the player + private Camera2D _camera; + + // DotTiled map and tileset textures + private Map _map; + private Dictionary _tilesetTextures; + + // Layers for collisions and points of interest + private ObjectLayer _collisionLayer; + private ObjectLayer _pointsOfInterestLayer; + + // Player state + private Vector2 _playerPosition; + private Texture2D _playerTexture; + + // Used for drawing rectangles (player) + private Texture2D _whitePixel; + + public Game1() + { + _graphics = new GraphicsDeviceManager(this) + { + PreferredBackBufferWidth = 1280, + PreferredBackBufferHeight = 720 + }; + Content.RootDirectory = "Content"; + IsMouseVisible = true; + } + + /// + /// MonoGame initialization. + /// + protected override void Initialize() => base.Initialize(); + + /// + /// Load map, textures, and initialize player/camera. + /// + protected override void LoadContent() + { + _spriteBatch = new SpriteBatch(GraphicsDevice); + + // Used for drawing rectangles (player) + _whitePixel = new Texture2D(GraphicsDevice, 1, 1); + _whitePixel.SetData(new[] { Color.White }); + + // Load the Tiled map using DotTiled + var loader = Loader.Default(); + _map = loader.LoadMap(Path.Combine(Content.RootDirectory, "world.tmx")); + + // Load all tileset textures referenced by the map + _tilesetTextures = LoadTilesetTextures(_map); + + // Extract layers for collisions and points of interest + _collisionLayer = _map.Layers.OfType().Single(l => l.Name == "Collisions"); + _pointsOfInterestLayer = (ObjectLayer)_map.Layers.Single(l => l.Name == "PointsOfInterest"); + + // Get the player's spawn point from the PointsOfInterest layer + var playerSpawn = _pointsOfInterestLayer.Objects.Single(obj => obj.Name == "PlayerSpawn"); + _playerPosition = new Vector2(playerSpawn.X, playerSpawn.Y); + + // Set up the camera to follow the player + _camera = new Camera2D(GraphicsDevice.Viewport); + + // Optionally, create a simple player texture (blue rectangle) + _playerTexture = new Texture2D(GraphicsDevice, 1, 1); + _playerTexture.SetData(new[] { Color.Blue }); + } + + /// + /// Loads all tileset textures referenced by the map. + /// + private Dictionary LoadTilesetTextures(Map map) + { + // Remove ".png" for MonoGame Content Pipeline compatibility + return map.Tilesets.ToDictionary( + tileset => tileset.Image.Value.Source.Value, + tileset => Content.Load(Path.GetDirectoryName(tileset.Image.Value.Source.Value) + "/" + Path.GetFileNameWithoutExtension(tileset.Image.Value.Source.Value)) + ); + } + + /// + /// Handles player input and updates game logic. + /// + protected override void Update(GameTime gameTime) + { + // Exit on Escape + if (Keyboard.GetState().IsKeyDown(Keys.Escape)) + Exit(); + + _camera.UpdateCamera(GraphicsDevice.Viewport); + + // Handle player movement input + var move = HandlePlayerInput(gameTime); + + // Define the player's collision rectangle + var playerRect = new Rectangle((int)_playerPosition.X, (int)_playerPosition.Y, 12, 12); + + // Collision detection with rectangles in the collision layer + foreach (var obj in _collisionLayer.Objects.OfType()) + { + var objRect = new Rectangle((int)obj.X, (int)obj.Y, (int)obj.Width, (int)obj.Height); + + // Horizontal collision + var movePlayerHRect = new Rectangle(playerRect.X + (int)move.X, playerRect.Y, playerRect.Width, playerRect.Height); + if (move.X != 0 && movePlayerHRect.Intersects(objRect)) + move.X = 0; + + // Vertical collision + var movePlayerVRect = new Rectangle(playerRect.X, playerRect.Y + (int)move.Y, playerRect.Width, playerRect.Height); + if (move.Y != 0 && movePlayerVRect.Intersects(objRect)) + move.Y = 0; + } + + // Update player position + _playerPosition += move; + + // Smoothly update the camera to follow the player + var newCameraTarget = new Vector2(_playerPosition.X, _playerPosition.Y); + _camera.Position += (newCameraTarget - _camera.Position) * 15f * (float)gameTime.ElapsedGameTime.TotalSeconds; + + base.Update(gameTime); + } + + /// + /// Handles WASD input for player movement. + /// + private static Vector2 HandlePlayerInput(GameTime gameTime) + { + var move = Vector2.Zero; + var speed = 150f * (float)gameTime.ElapsedGameTime.TotalSeconds; + var state = Keyboard.GetState(); + + if (state.IsKeyDown(Keys.W)) move.Y -= speed; + if (state.IsKeyDown(Keys.S)) move.Y += speed; + if (state.IsKeyDown(Keys.A)) move.X -= speed; + if (state.IsKeyDown(Keys.D)) move.X += speed; + + return move; + } + + /// + /// Draws the map, player, and handles layer ordering. + /// + protected override void Draw(GameTime gameTime) + { + GraphicsDevice.Clear(Color.Black); + + _spriteBatch.Begin(transformMatrix: _camera.Transform); + + // Get all visual tile layers from the "Visuals" group + var visualLayers = _map.Layers.OfType().Single(l => l.Name == "Visuals").Layers.OfType(); + + // Render layers below the player + RenderLayers(_map, visualLayers, _tilesetTextures, ["Ground", "Ponds", "Paths", "HouseWalls", "HouseDoors", "FencesBushes"]); + + // Draw the player as a blue rectangle (centered on tile) + var playerVisualRect = new Rectangle((int)_playerPosition.X, (int)_playerPosition.Y - 12, 12, 24); + _spriteBatch.Draw(_playerTexture, playerVisualRect, Color.White); + + // Render layers above the player + RenderLayers(_map, visualLayers, _tilesetTextures, ["HouseRoofs"]); + + _spriteBatch.End(); + + base.Draw(gameTime); + } + + /// + /// Renders specific named layers from the map. + /// + private void RenderLayers(Map map, IEnumerable visualLayers, Dictionary tilesetTextures, string[] layerNames) + { + foreach (var layerName in layerNames) + { + var layer = visualLayers.Single(l => l.Name == layerName); + RenderLayer(map, layer, tilesetTextures); + } + } + + /// + /// Renders a single tile layer. + /// + private void RenderLayer(Map map, TileLayer layer, Dictionary tilesetTextures) + { + for (var y = 0; y < layer.Height; y++) + { + for (var x = 0; x < layer.Width; x++) + { + var tileGID = layer.GetGlobalTileIDAtCoord(x, y); + if (tileGID == 0) continue; + + var tileset = map.ResolveTilesetForGlobalTileID(tileGID, out var localTileID); + var sourceRect = tileset.GetSourceRectangleForLocalTileID(localTileID); + + var destination = new Vector2(x * tileset.TileWidth, y * tileset.TileHeight); + var sourceRectangle = new Rectangle(sourceRect.X + 1, sourceRect.Y + 1, sourceRect.Width - 2, sourceRect.Height - 2); + + _spriteBatch.Draw( + tilesetTextures[tileset.Image.Value.Source.Value], + destination, + sourceRectangle, + Color.White, + 0f, + Vector2.Zero, + Vector2.One * (1f / (14f / 16f)), // Shrink by a tiny amount to avoid seams (not a perfect solution) + SpriteEffects.None, + 0f + ); + } + } + } +} diff --git a/src/DotTiled.Examples/DotTiled.Example.MonoGame/Icon.bmp b/src/DotTiled.Examples/DotTiled.Example.MonoGame/Icon.bmp new file mode 100644 index 0000000..2b48165 Binary files /dev/null and b/src/DotTiled.Examples/DotTiled.Example.MonoGame/Icon.bmp differ diff --git a/src/DotTiled.Examples/DotTiled.Example.MonoGame/Icon.ico b/src/DotTiled.Examples/DotTiled.Example.MonoGame/Icon.ico new file mode 100644 index 0000000..7d9dec1 Binary files /dev/null and b/src/DotTiled.Examples/DotTiled.Example.MonoGame/Icon.ico differ diff --git a/src/DotTiled.Examples/DotTiled.Example.MonoGame/Program.cs b/src/DotTiled.Examples/DotTiled.Example.MonoGame/Program.cs new file mode 100644 index 0000000..399af18 --- /dev/null +++ b/src/DotTiled.Examples/DotTiled.Example.MonoGame/Program.cs @@ -0,0 +1,2 @@ +using var game = new DotTiled.Example.MonoGame.Game1(); +game.Run(); diff --git a/src/DotTiled.Examples/DotTiled.Example.MonoGame/app.manifest b/src/DotTiled.Examples/DotTiled.Example.MonoGame/app.manifest new file mode 100644 index 0000000..b399c95 --- /dev/null +++ b/src/DotTiled.Examples/DotTiled.Example.MonoGame/app.manifest @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true/pm + permonitorv2,permonitor + + + + diff --git a/src/DotTiled.Tests/IntegrationTests/CustomTypes/FromTypeUsedInLoaderTests.cs b/src/DotTiled.Tests/IntegrationTests/CustomTypes/FromTypeUsedInLoaderTests.cs index c0d580f..4b4c226 100644 --- a/src/DotTiled.Tests/IntegrationTests/CustomTypes/FromTypeUsedInLoaderTests.cs +++ b/src/DotTiled.Tests/IntegrationTests/CustomTypes/FromTypeUsedInLoaderTests.cs @@ -48,7 +48,7 @@ public class FromTypeUsedInLoaderTests ParallaxOriginY = 0, RenderOrder = RenderOrder.RightDown, CompressionLevel = -1, - BackgroundColor = new Color { R = 0, G = 0, B = 0, A = 0 }, + BackgroundColor = new TiledColor { R = 0, G = 0, B = 0, A = 0 }, Version = "1.10", TiledVersion = "1.11.0", NextLayerID = 2, @@ -133,7 +133,7 @@ public class FromTypeUsedInLoaderTests ParallaxOriginY = 0, RenderOrder = RenderOrder.RightDown, CompressionLevel = -1, - BackgroundColor = new Color { R = 0, G = 0, B = 0, A = 0 }, + BackgroundColor = new TiledColor { R = 0, G = 0, B = 0, A = 0 }, Version = "1.10", TiledVersion = "1.11.0", NextLayerID = 2, @@ -226,7 +226,7 @@ public class FromTypeUsedInLoaderTests ParallaxOriginY = 0, RenderOrder = RenderOrder.RightDown, CompressionLevel = -1, - BackgroundColor = new Color { R = 0, G = 0, B = 0, A = 0 }, + BackgroundColor = new TiledColor { R = 0, G = 0, B = 0, A = 0 }, Version = "1.10", TiledVersion = "1.11.0", NextLayerID = 2, diff --git a/src/DotTiled.Tests/TestData/Maps/default-map/default-map.cs b/src/DotTiled.Tests/TestData/Maps/default-map/default-map.cs index 8aeae0d..cee4c6b 100644 --- a/src/DotTiled.Tests/TestData/Maps/default-map/default-map.cs +++ b/src/DotTiled.Tests/TestData/Maps/default-map/default-map.cs @@ -15,7 +15,7 @@ public partial class TestData ParallaxOriginY = 0, RenderOrder = RenderOrder.RightDown, CompressionLevel = -1, - BackgroundColor = new Color { R = 0, G = 0, B = 0, A = 0 }, + BackgroundColor = new TiledColor { R = 0, G = 0, B = 0, A = 0 }, Version = "1.10", TiledVersion = "1.11.0", NextLayerID = 2, diff --git a/src/DotTiled.Tests/TestData/Maps/map-external-tileset-multi/map-external-tileset-multi.cs b/src/DotTiled.Tests/TestData/Maps/map-external-tileset-multi/map-external-tileset-multi.cs index 2500a4d..93c4c31 100644 --- a/src/DotTiled.Tests/TestData/Maps/map-external-tileset-multi/map-external-tileset-multi.cs +++ b/src/DotTiled.Tests/TestData/Maps/map-external-tileset-multi/map-external-tileset-multi.cs @@ -17,7 +17,7 @@ public partial class TestData ParallaxOriginY = 0, RenderOrder = RenderOrder.RightDown, CompressionLevel = -1, - BackgroundColor = Color.Parse("#00000000", CultureInfo.InvariantCulture), + BackgroundColor = TiledColor.Parse("#00000000", CultureInfo.InvariantCulture), Version = "1.10", TiledVersion = "1.11.0", NextLayerID = 2, @@ -47,7 +47,7 @@ public partial class TestData }, Properties = [ new BoolProperty { Name = "tilesetbool", Value = true }, - new ColorProperty { Name = "tilesetcolor", Value = Color.Parse("#ffff0000", CultureInfo.InvariantCulture) }, + new ColorProperty { Name = "tilesetcolor", Value = TiledColor.Parse("#ffff0000", CultureInfo.InvariantCulture) }, new FileProperty { Name = "tilesetfile", Value = "" }, new FloatProperty { Name = "tilesetfloat", Value = 5.2f }, new IntProperty { Name = "tilesetint", Value = 9 }, diff --git a/src/DotTiled.Tests/TestData/Maps/map-external-tileset-wangset/map-external-tileset-wangset.cs b/src/DotTiled.Tests/TestData/Maps/map-external-tileset-wangset/map-external-tileset-wangset.cs index 756c59f..164aa0e 100644 --- a/src/DotTiled.Tests/TestData/Maps/map-external-tileset-wangset/map-external-tileset-wangset.cs +++ b/src/DotTiled.Tests/TestData/Maps/map-external-tileset-wangset/map-external-tileset-wangset.cs @@ -17,7 +17,7 @@ public partial class TestData ParallaxOriginY = 0, RenderOrder = RenderOrder.RightDown, CompressionLevel = -1, - BackgroundColor = Color.Parse("#00000000", CultureInfo.InvariantCulture), + BackgroundColor = TiledColor.Parse("#00000000", CultureInfo.InvariantCulture), Version = "1.10", TiledVersion = "1.11.0", NextLayerID = 2, @@ -63,21 +63,21 @@ public partial class TestData new WangColor { Name = "Water", - Color = Color.Parse("#ff0000", CultureInfo.InvariantCulture), + Color = TiledColor.Parse("#ff0000", CultureInfo.InvariantCulture), Tile = 0, Probability = 1 }, new WangColor { Name = "Grass", - Color = Color.Parse("#00ff00", CultureInfo.InvariantCulture), + Color = TiledColor.Parse("#00ff00", CultureInfo.InvariantCulture), Tile = -1, Probability = 1 }, new WangColor { Name = "Stone", - Color = Color.Parse("#0000ff", CultureInfo.InvariantCulture), + Color = TiledColor.Parse("#0000ff", CultureInfo.InvariantCulture), Tile = 29, Probability = 1 } diff --git a/src/DotTiled.Tests/TestData/Maps/map-override-object-bug/map-override-object-bug.cs b/src/DotTiled.Tests/TestData/Maps/map-override-object-bug/map-override-object-bug.cs index 82dfd29..32755ca 100644 --- a/src/DotTiled.Tests/TestData/Maps/map-override-object-bug/map-override-object-bug.cs +++ b/src/DotTiled.Tests/TestData/Maps/map-override-object-bug/map-override-object-bug.cs @@ -17,7 +17,7 @@ public partial class TestData ParallaxOriginY = 0, RenderOrder = RenderOrder.RightDown, CompressionLevel = -1, - BackgroundColor = new Color { R = 0, G = 0, B = 0, A = 0 }, + BackgroundColor = new TiledColor { R = 0, G = 0, B = 0, A = 0 }, Version = "1.10", TiledVersion = "1.11.0", NextLayerID = 8, @@ -181,8 +181,8 @@ public partial class TestData { Format = ImageFormat.Png, Source = "tileset.png", - Width = fileExt == "tmx" ? 256u : 0, // Currently, json format does not - Height = fileExt == "tmx" ? 96u : 0 // include image dimensions in image layer https://github.com/mapeditor/tiled/issues/4028 + 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 }, RepeatX = true }, diff --git a/src/DotTiled.Tests/TestData/Maps/map-with-class-and-props/map-with-class-and-props.cs b/src/DotTiled.Tests/TestData/Maps/map-with-class-and-props/map-with-class-and-props.cs index 8cbd6bd..0511454 100644 --- a/src/DotTiled.Tests/TestData/Maps/map-with-class-and-props/map-with-class-and-props.cs +++ b/src/DotTiled.Tests/TestData/Maps/map-with-class-and-props/map-with-class-and-props.cs @@ -15,7 +15,7 @@ public partial class TestData ParallaxOriginY = 0, RenderOrder = RenderOrder.RightDown, CompressionLevel = -1, - BackgroundColor = new Color { R = 0, G = 0, B = 0, A = 0 }, + BackgroundColor = new TiledColor { R = 0, G = 0, B = 0, A = 0 }, Version = "1.10", TiledVersion = "1.11.0", NextLayerID = 2, diff --git a/src/DotTiled.Tests/TestData/Maps/map-with-class/map-with-class.cs b/src/DotTiled.Tests/TestData/Maps/map-with-class/map-with-class.cs index ef98d02..d1e7d7b 100644 --- a/src/DotTiled.Tests/TestData/Maps/map-with-class/map-with-class.cs +++ b/src/DotTiled.Tests/TestData/Maps/map-with-class/map-with-class.cs @@ -15,7 +15,7 @@ public partial class TestData ParallaxOriginY = 0, RenderOrder = RenderOrder.RightDown, CompressionLevel = -1, - BackgroundColor = new Color { R = 0, G = 0, B = 0, A = 0 }, + BackgroundColor = new TiledColor { R = 0, G = 0, B = 0, A = 0 }, Version = "1.10", TiledVersion = "1.11.0", NextLayerID = 2, diff --git a/src/DotTiled.Tests/TestData/Maps/map-with-common-props/map-with-common-props.cs b/src/DotTiled.Tests/TestData/Maps/map-with-common-props/map-with-common-props.cs index 2437d0b..ff184ff 100644 --- a/src/DotTiled.Tests/TestData/Maps/map-with-common-props/map-with-common-props.cs +++ b/src/DotTiled.Tests/TestData/Maps/map-with-common-props/map-with-common-props.cs @@ -17,7 +17,7 @@ public partial class TestData ParallaxOriginY = 0, RenderOrder = RenderOrder.RightDown, CompressionLevel = -1, - BackgroundColor = Color.Parse("#00ff00", CultureInfo.InvariantCulture), + BackgroundColor = TiledColor.Parse("#00ff00", CultureInfo.InvariantCulture), Version = "1.10", TiledVersion = "1.11.0", NextLayerID = 2, @@ -52,13 +52,13 @@ public partial class TestData Properties = [ new BoolProperty { Name = "boolprop", Value = true }, - new ColorProperty { Name = "colorprop", Value = Color.Parse("#ff55ffff", CultureInfo.InvariantCulture) }, + new ColorProperty { Name = "colorprop", Value = TiledColor.Parse("#ff55ffff", CultureInfo.InvariantCulture) }, new FileProperty { Name = "fileprop", Value = "file.txt" }, new FloatProperty { Name = "floatprop", Value = 4.2f }, new IntProperty { Name = "intprop", Value = 8 }, new ObjectProperty { Name = "objectprop", Value = 5 }, new StringProperty { Name = "stringprop", Value = "This is a string, hello world!" }, - new ColorProperty { Name = "unsetcolorprop", Value = Optional.Empty } + new ColorProperty { Name = "unsetcolorprop", Value = Optional.Empty } ] }; } diff --git a/src/DotTiled.Tests/TestData/Maps/map-with-custom-type-props-without-defs/map-with-custom-type-props-without-defs.cs b/src/DotTiled.Tests/TestData/Maps/map-with-custom-type-props-without-defs/map-with-custom-type-props-without-defs.cs index 4134dac..91d4e07 100644 --- a/src/DotTiled.Tests/TestData/Maps/map-with-custom-type-props-without-defs/map-with-custom-type-props-without-defs.cs +++ b/src/DotTiled.Tests/TestData/Maps/map-with-custom-type-props-without-defs/map-with-custom-type-props-without-defs.cs @@ -17,7 +17,7 @@ public partial class TestData ParallaxOriginY = 0, RenderOrder = RenderOrder.RightDown, CompressionLevel = -1, - BackgroundColor = Color.Parse("#00000000", CultureInfo.InvariantCulture), + BackgroundColor = TiledColor.Parse("#00000000", CultureInfo.InvariantCulture), Version = "1.10", TiledVersion = "1.11.0", NextLayerID = 2, diff --git a/src/DotTiled.Tests/TestData/Maps/map-with-custom-type-props/map-with-custom-type-props.cs b/src/DotTiled.Tests/TestData/Maps/map-with-custom-type-props/map-with-custom-type-props.cs index f77638b..6a2b6bf 100644 --- a/src/DotTiled.Tests/TestData/Maps/map-with-custom-type-props/map-with-custom-type-props.cs +++ b/src/DotTiled.Tests/TestData/Maps/map-with-custom-type-props/map-with-custom-type-props.cs @@ -17,7 +17,7 @@ public partial class TestData ParallaxOriginY = 0, RenderOrder = RenderOrder.RightDown, CompressionLevel = -1, - BackgroundColor = Color.Parse("#00000000", CultureInfo.InvariantCulture), + BackgroundColor = TiledColor.Parse("#00000000", CultureInfo.InvariantCulture), Version = "1.10", TiledVersion = "1.11.0", NextLayerID = 2, @@ -56,7 +56,7 @@ public partial class TestData PropertyType = "CustomClass", Value = [ new BoolProperty { Name = "boolinclass", Value = true }, - new ColorProperty { Name = "colorinclass", Value = Color.Parse("#000000ff", CultureInfo.InvariantCulture) }, + new ColorProperty { Name = "colorinclass", Value = TiledColor.Parse("#000000ff", CultureInfo.InvariantCulture) }, new FileProperty { Name = "fileinclass", Value = "" }, new FloatProperty { Name = "floatinclass", Value = 13.37f }, new IntProperty { Name = "intinclass", Value = 0 }, @@ -106,7 +106,7 @@ public partial class TestData new ColorProperty { Name = "colorinclass", - Value = Color.Parse("#000000ff", CultureInfo.InvariantCulture) + Value = TiledColor.Parse("#000000ff", CultureInfo.InvariantCulture) }, new FileProperty { diff --git a/src/DotTiled.Tests/TestData/Maps/map-with-deep-props/map-with-deep-props.cs b/src/DotTiled.Tests/TestData/Maps/map-with-deep-props/map-with-deep-props.cs index b67548a..76e34fb 100644 --- a/src/DotTiled.Tests/TestData/Maps/map-with-deep-props/map-with-deep-props.cs +++ b/src/DotTiled.Tests/TestData/Maps/map-with-deep-props/map-with-deep-props.cs @@ -17,7 +17,7 @@ public partial class TestData ParallaxOriginY = 0, RenderOrder = RenderOrder.RightDown, CompressionLevel = -1, - BackgroundColor = Color.Parse("#00000000", CultureInfo.InvariantCulture), + BackgroundColor = TiledColor.Parse("#00000000", CultureInfo.InvariantCulture), Version = "1.10", TiledVersion = "1.11.0", NextLayerID = 2, @@ -61,7 +61,7 @@ public partial class TestData PropertyType = "CustomClass", Value = [ new BoolProperty { Name = "boolinclass", Value = false }, - new ColorProperty { Name = "colorinclass", Value = Color.Parse("#000000ff", CultureInfo.InvariantCulture) }, + new ColorProperty { Name = "colorinclass", Value = TiledColor.Parse("#000000ff", CultureInfo.InvariantCulture) }, new FileProperty { Name = "fileinclass", Value = "" }, new FloatProperty { Name = "floatinclass", Value = 0f }, new IntProperty { Name = "intinclass", Value = 0 }, @@ -82,7 +82,7 @@ public partial class TestData PropertyType = "CustomClass", Value = [ new BoolProperty { Name = "boolinclass", Value = true }, - new ColorProperty { Name = "colorinclass", Value = Color.Parse("#000000ff", CultureInfo.InvariantCulture) }, + new ColorProperty { Name = "colorinclass", Value = TiledColor.Parse("#000000ff", CultureInfo.InvariantCulture) }, new FileProperty { Name = "fileinclass", Value = "" }, new FloatProperty { Name = "floatinclass", Value = 13.37f }, new IntProperty { Name = "intinclass", Value = 0 }, @@ -109,7 +109,7 @@ public partial class TestData new ColorProperty { Name = "colorinclass", - Value = Color.Parse("#000000ff", CultureInfo.InvariantCulture) + Value = TiledColor.Parse("#000000ff", CultureInfo.InvariantCulture) }, new FileProperty { diff --git a/src/DotTiled.Tests/TestData/Maps/map-with-embedded-tileset/map-with-embedded-tileset.cs b/src/DotTiled.Tests/TestData/Maps/map-with-embedded-tileset/map-with-embedded-tileset.cs index 0056fd1..8bb3724 100644 --- a/src/DotTiled.Tests/TestData/Maps/map-with-embedded-tileset/map-with-embedded-tileset.cs +++ b/src/DotTiled.Tests/TestData/Maps/map-with-embedded-tileset/map-with-embedded-tileset.cs @@ -17,7 +17,7 @@ public partial class TestData ParallaxOriginY = 0, RenderOrder = RenderOrder.RightDown, CompressionLevel = -1, - BackgroundColor = Color.Parse("#00000000", CultureInfo.InvariantCulture), + BackgroundColor = TiledColor.Parse("#00000000", CultureInfo.InvariantCulture), Version = "1.10", TiledVersion = "1.11.0", NextLayerID = 2, diff --git a/src/DotTiled.Tests/TestData/Maps/map-with-external-tileset/map-with-external-tileset.cs b/src/DotTiled.Tests/TestData/Maps/map-with-external-tileset/map-with-external-tileset.cs index 15b9873..34bd69f 100644 --- a/src/DotTiled.Tests/TestData/Maps/map-with-external-tileset/map-with-external-tileset.cs +++ b/src/DotTiled.Tests/TestData/Maps/map-with-external-tileset/map-with-external-tileset.cs @@ -17,7 +17,7 @@ public partial class TestData ParallaxOriginY = 0, RenderOrder = RenderOrder.RightDown, CompressionLevel = -1, - BackgroundColor = Color.Parse("#00000000", CultureInfo.InvariantCulture), + BackgroundColor = TiledColor.Parse("#00000000", CultureInfo.InvariantCulture), Version = "1.10", TiledVersion = "1.11.0", NextLayerID = 2, diff --git a/src/DotTiled.Tests/TestData/Maps/map-with-flippingflags/map-with-flippingflags.cs b/src/DotTiled.Tests/TestData/Maps/map-with-flippingflags/map-with-flippingflags.cs index aef25d3..8dde14b 100644 --- a/src/DotTiled.Tests/TestData/Maps/map-with-flippingflags/map-with-flippingflags.cs +++ b/src/DotTiled.Tests/TestData/Maps/map-with-flippingflags/map-with-flippingflags.cs @@ -17,7 +17,7 @@ public partial class TestData ParallaxOriginY = 0, RenderOrder = RenderOrder.RightDown, CompressionLevel = -1, - BackgroundColor = Color.Parse("#00000000", CultureInfo.InvariantCulture), + BackgroundColor = TiledColor.Parse("#00000000", CultureInfo.InvariantCulture), Version = "1.10", TiledVersion = "1.11.0", NextLayerID = 3, 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 1b06285..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 @@ -17,9 +17,9 @@ public partial class TestData ParallaxOriginY = 0, RenderOrder = RenderOrder.RightDown, CompressionLevel = -1, - BackgroundColor = new Color { R = 0, G = 0, B = 0, A = 0 }, + 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" ? 256u : 0, // Currently, json format does not - Height = fileExt == "tmx" ? 96u : 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.Tests/TestData/Maps/map-with-multiline-string-prop/map-with-multiline-string-prop.cs b/src/DotTiled.Tests/TestData/Maps/map-with-multiline-string-prop/map-with-multiline-string-prop.cs index 06fc07f..68b196c 100644 --- a/src/DotTiled.Tests/TestData/Maps/map-with-multiline-string-prop/map-with-multiline-string-prop.cs +++ b/src/DotTiled.Tests/TestData/Maps/map-with-multiline-string-prop/map-with-multiline-string-prop.cs @@ -17,7 +17,7 @@ public partial class TestData ParallaxOriginY = 0, RenderOrder = RenderOrder.RightDown, CompressionLevel = -1, - BackgroundColor = Color.Parse("#00ff00", CultureInfo.InvariantCulture), + BackgroundColor = TiledColor.Parse("#00ff00", CultureInfo.InvariantCulture), Version = "1.10", TiledVersion = "1.11.0", NextLayerID = 2, @@ -52,7 +52,7 @@ public partial class TestData Properties = [ new BoolProperty { Name = "boolprop", Value = true }, - new ColorProperty { Name = "colorprop", Value = Color.Parse("#ff55ffff", CultureInfo.InvariantCulture) }, + new ColorProperty { Name = "colorprop", Value = TiledColor.Parse("#ff55ffff", CultureInfo.InvariantCulture) }, new FileProperty { Name = "fileprop", Value = "file.txt" }, new FloatProperty { Name = "floatprop", Value = 4.2f }, new IntProperty { Name = "intprop", Value = 8 }, diff --git a/src/DotTiled.Tests/UnitTests/Properties/HasPropertiesBaseTests.cs b/src/DotTiled.Tests/UnitTests/Properties/HasPropertiesBaseTests.cs index 4f9ab0f..cbf84c2 100644 --- a/src/DotTiled.Tests/UnitTests/Properties/HasPropertiesBaseTests.cs +++ b/src/DotTiled.Tests/UnitTests/Properties/HasPropertiesBaseTests.cs @@ -80,7 +80,7 @@ public class HasPropertiesBaseTests private sealed class MapTo { public bool MapToBool { get; set; } = false; - public Color MapToColor { get; set; } = Color.Parse("#00000000", CultureInfo.InvariantCulture); + public TiledColor MapToColor { get; set; } = TiledColor.Parse("#00000000", CultureInfo.InvariantCulture); public float MapToFloat { get; set; } = 0.0f; public string MapToFile { get; set; } = ""; public int MapToInt { get; set; } = 0; @@ -130,7 +130,7 @@ public class HasPropertiesBaseTests PropertyType = "MapTo", Value = [ new BoolProperty { Name = "MapToBool", Value = true }, - new ColorProperty { Name = "MapToColor", Value = Color.Parse("#FF0000FF", CultureInfo.InvariantCulture) }, + new ColorProperty { Name = "MapToColor", Value = TiledColor.Parse("#FF0000FF", CultureInfo.InvariantCulture) }, new FloatProperty { Name = "MapToFloat", Value = 1.0f }, new StringProperty { Name = "MapToFile", Value = "Test" }, new IntProperty { Name = "MapToInt", Value = 1 }, @@ -146,7 +146,7 @@ public class HasPropertiesBaseTests // Assert Assert.True(mappedProperty.MapToBool); - Assert.Equal(Color.Parse("#FF0000FF", CultureInfo.InvariantCulture), mappedProperty.MapToColor); + Assert.Equal(TiledColor.Parse("#FF0000FF", CultureInfo.InvariantCulture), mappedProperty.MapToColor); Assert.Equal(1.0f, mappedProperty.MapToFloat); Assert.Equal("Test", mappedProperty.MapToFile); Assert.Equal(1, mappedProperty.MapToInt); @@ -175,7 +175,7 @@ public class HasPropertiesBaseTests PropertyType = "MapTo", Value = [ new BoolProperty { Name = "MapToBool", Value = true }, - new ColorProperty { Name = "MapToColor", Value = Color.Parse("#FF0000FF", CultureInfo.InvariantCulture) }, + new ColorProperty { Name = "MapToColor", Value = TiledColor.Parse("#FF0000FF", CultureInfo.InvariantCulture) }, new FloatProperty { Name = "MapToFloat", Value = 1.0f }, new StringProperty { Name = "MapToFile", Value = "Test" }, new IntProperty { Name = "MapToInt", Value = 1 }, @@ -194,7 +194,7 @@ public class HasPropertiesBaseTests // Assert Assert.Equal("Test", mappedProperty.NestedMapToString); Assert.True(mappedProperty.MapToInNested.MapToBool); - Assert.Equal(Color.Parse("#FF0000FF", CultureInfo.InvariantCulture), mappedProperty.MapToInNested.MapToColor); + Assert.Equal(TiledColor.Parse("#FF0000FF", CultureInfo.InvariantCulture), mappedProperty.MapToInNested.MapToColor); Assert.Equal(1.0f, mappedProperty.MapToInNested.MapToFloat); Assert.Equal("Test", mappedProperty.MapToInNested.MapToFile); Assert.Equal(1, mappedProperty.MapToInNested.MapToInt); @@ -276,7 +276,7 @@ public class HasPropertiesBaseTests // Arrange List props = [ new BoolProperty { Name = "MapToBool", Value = true }, - new ColorProperty { Name = "MapToColor", Value = Color.Parse("#FF0000FF", CultureInfo.InvariantCulture) }, + new ColorProperty { Name = "MapToColor", Value = TiledColor.Parse("#FF0000FF", CultureInfo.InvariantCulture) }, new FloatProperty { Name = "MapToFloat", Value = 1.0f }, new StringProperty { Name = "MapToFile", Value = "Test" }, new IntProperty { Name = "MapToInt", Value = 1 }, @@ -290,7 +290,7 @@ public class HasPropertiesBaseTests // Assert Assert.True(mappedProperty.MapToBool); - Assert.Equal(Color.Parse("#FF0000FF", CultureInfo.InvariantCulture), mappedProperty.MapToColor); + Assert.Equal(TiledColor.Parse("#FF0000FF", CultureInfo.InvariantCulture), mappedProperty.MapToColor); Assert.Equal(1.0f, mappedProperty.MapToFloat); Assert.Equal("Test", mappedProperty.MapToFile); Assert.Equal(1, mappedProperty.MapToInt); diff --git a/src/DotTiled.sln b/src/DotTiled.sln index 5505021..add5504 100644 --- a/src/DotTiled.sln +++ b/src/DotTiled.sln @@ -19,6 +19,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DotTiled.Examples", "DotTil EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotTiled.Example.Raylib", "DotTiled.Examples\DotTiled.Example.Raylib\DotTiled.Example.Raylib.csproj", "{53585FB8-6E94-46F0-87E2-9692874E1714}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotTiled.Example.MonoGame", "DotTiled.Examples\DotTiled.Example.MonoGame\DotTiled.Example.MonoGame.csproj", "{F074756C-F84C-4F50-AE42-01017CD68AF7}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -52,10 +54,15 @@ Global {53585FB8-6E94-46F0-87E2-9692874E1714}.Debug|Any CPU.Build.0 = Debug|Any CPU {53585FB8-6E94-46F0-87E2-9692874E1714}.Release|Any CPU.ActiveCfg = Release|Any CPU {53585FB8-6E94-46F0-87E2-9692874E1714}.Release|Any CPU.Build.0 = Release|Any CPU + {F074756C-F84C-4F50-AE42-01017CD68AF7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F074756C-F84C-4F50-AE42-01017CD68AF7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F074756C-F84C-4F50-AE42-01017CD68AF7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F074756C-F84C-4F50-AE42-01017CD68AF7}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(NestedProjects) = preSolution {F9892295-6C2C-4ABD-9D6F-2AC81D2C6E67} = {8C54542E-3C2C-486C-9BEF-4C510391AFDA} {7541A9B3-43A5-45A7-939E-6F542319D990} = {8C54542E-3C2C-486C-9BEF-4C510391AFDA} {53585FB8-6E94-46F0-87E2-9692874E1714} = {F3D6E648-AF8F-4EC9-A810-8C348DBB9924} + {F074756C-F84C-4F50-AE42-01017CD68AF7} = {F3D6E648-AF8F-4EC9-A810-8C348DBB9924} EndGlobalSection EndGlobal 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/Layers/BaseLayer.cs b/src/DotTiled/Layers/BaseLayer.cs index 26a6416..4da3443 100644 --- a/src/DotTiled/Layers/BaseLayer.cs +++ b/src/DotTiled/Layers/BaseLayer.cs @@ -37,7 +37,7 @@ public abstract class BaseLayer : HasPropertiesBase /// /// A tint color that is multiplied with any tiles drawn by this layer. /// - public Optional TintColor { get; set; } = Optional.Empty; + public Optional TintColor { get; set; } = Optional.Empty; /// /// Horizontal offset for this layer in pixels. diff --git a/src/DotTiled/Layers/Data.cs b/src/DotTiled/Layers/Data.cs index 16bf34e..958c2b3 100644 --- a/src/DotTiled/Layers/Data.cs +++ b/src/DotTiled/Layers/Data.cs @@ -90,12 +90,12 @@ public class Chunk /// /// The width of the chunk in tiles. /// - public required uint Width { get; set; } + public required int Width { get; set; } /// /// The height of the chunk in tiles. /// - public required uint Height { get; set; } + public required int Height { get; set; } /// /// The parsed chunk data, as a list of tile GIDs. diff --git a/src/DotTiled/Layers/ImageLayer.cs b/src/DotTiled/Layers/ImageLayer.cs index 5d8de82..6bd8ead 100644 --- a/src/DotTiled/Layers/ImageLayer.cs +++ b/src/DotTiled/Layers/ImageLayer.cs @@ -8,12 +8,12 @@ public class ImageLayer : BaseLayer /// /// The X position of the image layer in pixels. /// - public uint X { get; set; } = 0; + public int X { get; set; } = 0; /// /// The Y position of the image layer in pixels. /// - public Optional Y { get; set; } = 0; + public int Y { get; set; } = 0; /// /// Whether the image drawn by this layer is repeated along the X axis. diff --git a/src/DotTiled/Layers/ObjectLayer.cs b/src/DotTiled/Layers/ObjectLayer.cs index 77ecc02..1e825e1 100644 --- a/src/DotTiled/Layers/ObjectLayer.cs +++ b/src/DotTiled/Layers/ObjectLayer.cs @@ -26,27 +26,27 @@ public class ObjectLayer : BaseLayer /// /// The X coordinate of the object layer in tiles. /// - public uint X { get; set; } = 0; + public int X { get; set; } = 0; /// /// The Y coordinate of the object layer in tiles. /// - public uint Y { get; set; } = 0; + public int Y { get; set; } = 0; /// /// The width of the object layer in tiles. Meaningless. /// - public uint Width { get; set; } = 0; + public int Width { get; set; } = 0; /// /// The height of the object layer in tiles. Meaningless. /// - public uint Height { get; set; } = 0; + public int Height { get; set; } = 0; /// /// A color that is multiplied with any tile objects drawn by this layer. /// - public Optional Color { get; set; } = Optional.Empty; + public Optional Color { get; set; } = Optional.Empty; /// /// Whether the objects are drawn according to the order of appearance () or sorted by their Y coordinate (). diff --git a/src/DotTiled/Layers/Objects/TextObject.cs b/src/DotTiled/Layers/Objects/TextObject.cs index 48a095c..42b07d0 100644 --- a/src/DotTiled/Layers/Objects/TextObject.cs +++ b/src/DotTiled/Layers/Objects/TextObject.cs @@ -72,7 +72,7 @@ public class TextObject : Object /// /// The color of the text. /// - public Color Color { get; set; } = Color.Parse("#000000", CultureInfo.InvariantCulture); + public TiledColor Color { get; set; } = TiledColor.Parse("#000000", CultureInfo.InvariantCulture); /// /// Whether the text is bold. diff --git a/src/DotTiled/Layers/TileLayer.cs b/src/DotTiled/Layers/TileLayer.cs index 2b9e70d..2e37b99 100644 --- a/src/DotTiled/Layers/TileLayer.cs +++ b/src/DotTiled/Layers/TileLayer.cs @@ -10,22 +10,22 @@ public class TileLayer : BaseLayer /// /// The X coordinate of the layer in tiles. /// - public uint X { get; set; } = 0; + public int X { get; set; } = 0; /// /// The Y coordinate of the layer in tiles. /// - public uint Y { get; set; } = 0; + public int Y { get; set; } = 0; /// /// The width of the layer in tiles. Always the same as the map width for fixed-size maps. /// - public required uint Width { get; set; } + public required int Width { get; set; } /// /// The height of the layer in tiles. Always the same as the map height for fixed-size maps. /// - public required uint Height { get; set; } + public required int Height { get; set; } /// /// The tile layer data. diff --git a/src/DotTiled/Map.cs b/src/DotTiled/Map.cs index d2ebf3a..8305e71 100644 --- a/src/DotTiled/Map.cs +++ b/src/DotTiled/Map.cs @@ -127,27 +127,27 @@ public class Map : HasPropertiesBase /// /// The width of the map in tiles. /// - public required uint Width { get; set; } + public required int Width { get; set; } /// /// The height of the map in tiles. /// - public required uint Height { get; set; } + public required int Height { get; set; } /// /// The width of a tile. /// - public required uint TileWidth { get; set; } + public required int TileWidth { get; set; } /// /// The height of a tile. /// - public required uint TileHeight { get; set; } + public required int TileHeight { get; set; } /// /// Only for hexagonal maps. Determines the width or height (depending on the staggered axis) of the tile's edge, in pixels. /// - public Optional HexSideLength { get; set; } = Optional.Empty; + public Optional HexSideLength { get; set; } = Optional.Empty; /// /// For staggered and hexagonal maps, determines which axis (X or Y) is staggered. @@ -172,7 +172,7 @@ public class Map : HasPropertiesBase /// /// The background color of the map. /// - public Color BackgroundColor { get; set; } = Color.Parse("#00000000", CultureInfo.InvariantCulture); + public TiledColor BackgroundColor { get; set; } = TiledColor.Parse("#00000000", CultureInfo.InvariantCulture); /// /// Stores the next available ID for new layers. This number is used to prevent reuse of the same ID after layers have been removed. diff --git a/src/DotTiled/Properties/ColorProperty.cs b/src/DotTiled/Properties/ColorProperty.cs index 295096e..9e5cc0d 100644 --- a/src/DotTiled/Properties/ColorProperty.cs +++ b/src/DotTiled/Properties/ColorProperty.cs @@ -3,7 +3,7 @@ namespace DotTiled; /// /// Represents a color property. /// -public class ColorProperty : IProperty> +public class ColorProperty : IProperty> { /// public required string Name { get; set; } @@ -14,7 +14,7 @@ public class ColorProperty : IProperty> /// /// The color value of the property. /// - public required Optional Value { get; set; } + public required Optional Value { get; set; } /// public IProperty Clone() => new ColorProperty diff --git a/src/DotTiled/Properties/CustomTypes/CustomClassDefinition.cs b/src/DotTiled/Properties/CustomTypes/CustomClassDefinition.cs index 37b8c6e..7d799ca 100644 --- a/src/DotTiled/Properties/CustomTypes/CustomClassDefinition.cs +++ b/src/DotTiled/Properties/CustomTypes/CustomClassDefinition.cs @@ -78,7 +78,7 @@ public class CustomClassDefinition : HasPropertiesBase, ICustomTypeDefinition /// /// The color of the custom class inside the Tiled editor. /// - public Color Color { get; set; } + public TiledColor Color { get; set; } /// /// Whether the custom class should be drawn with a fill color. @@ -155,8 +155,8 @@ public class CustomClassDefinition : HasPropertiesBase, ICustomTypeDefinition { case Type t when t == typeof(bool): return new BoolProperty { Name = propertyInfo.Name, Value = (bool)propertyInfo.GetValue(instance) }; - case Type t when t == typeof(Color): - return new ColorProperty { Name = propertyInfo.Name, Value = (Color)propertyInfo.GetValue(instance) }; + case Type t when t == typeof(TiledColor): + return new ColorProperty { Name = propertyInfo.Name, Value = (TiledColor)propertyInfo.GetValue(instance) }; case Type t when t == typeof(float): return new FloatProperty { Name = propertyInfo.Name, Value = (float)propertyInfo.GetValue(instance) }; case Type t when t == typeof(string): diff --git a/src/DotTiled/Color.cs b/src/DotTiled/Properties/TiledColor.cs similarity index 77% rename from src/DotTiled/Color.cs rename to src/DotTiled/Properties/TiledColor.cs index 78d0b80..cebc1f6 100644 --- a/src/DotTiled/Color.cs +++ b/src/DotTiled/Properties/TiledColor.cs @@ -7,7 +7,7 @@ namespace DotTiled; /// /// Represents a Tiled color. /// -public class Color : IParsable, IEquatable +public class TiledColor : IParsable, IEquatable { /// /// The red component of the color. @@ -30,31 +30,31 @@ public class Color : IParsable, IEquatable public byte A { get; set; } = 255; /// - /// Attempts to parse the specified string into a . Expects strings in the format #RRGGBB or #AARRGGBB. + /// Attempts to parse the specified string into a . Expects strings in the format #RRGGBB or #AARRGGBB. /// The leading # is optional. /// - /// A string value to parse into a + /// A string value to parse into a /// An object that supplies culture-specific information about the format of s. - /// The parsed + /// The parsed /// Thrown in case the provided string is not in a valid format. - public static Color Parse(string s, IFormatProvider provider) + public static TiledColor Parse(string s, IFormatProvider provider) { _ = TryParse(s, provider, out var result); return result ?? throw new FormatException($"Invalid format for TiledColor: {s}"); } /// - /// Attempts to parse the specified string into a . Expects strings in the format #RRGGBB or #AARRGGBB. + /// Attempts to parse the specified string into a . Expects strings in the format #RRGGBB or #AARRGGBB. /// The leading # is optional. /// - /// A string value to parse into a + /// A string value to parse into a /// An object that supplies culture-specific information about the format of s. - /// When this method returns, contains the parsed or null on failure. + /// When this method returns, contains the parsed or null on failure. /// true if was successfully parsed; otherwise, false. public static bool TryParse( [NotNullWhen(true)] string s, IFormatProvider provider, - [MaybeNullWhen(false)] out Color result) + [MaybeNullWhen(false)] out TiledColor result) { if (s is not null && !s.StartsWith('#')) return TryParse($"#{s}", provider, out result); @@ -68,7 +68,7 @@ public class Color : IParsable, IEquatable if (s.Length == 7) { - result = new Color + result = new TiledColor { R = byte.Parse(s[1..3], NumberStyles.HexNumber, provider), G = byte.Parse(s[3..5], NumberStyles.HexNumber, provider), @@ -77,7 +77,7 @@ public class Color : IParsable, IEquatable } else { - result = new Color + result = new TiledColor { A = byte.Parse(s[1..3], NumberStyles.HexNumber, provider), R = byte.Parse(s[3..5], NumberStyles.HexNumber, provider), @@ -90,7 +90,7 @@ public class Color : IParsable, IEquatable } /// - public bool Equals(Color other) + public bool Equals(TiledColor other) { if (other is null) return false; @@ -99,7 +99,7 @@ public class Color : IParsable, IEquatable } /// - public override bool Equals(object obj) => obj is Color other && Equals(other); + public override bool Equals(object obj) => obj is TiledColor other && Equals(other); /// public override int GetHashCode() => HashCode.Combine(R, G, B, A); diff --git a/src/DotTiled/Serialization/Tmj/TmjReaderBase.Data.cs b/src/DotTiled/Serialization/Tmj/TmjReaderBase.Data.cs index 47b9b75..afd6734 100644 --- a/src/DotTiled/Serialization/Tmj/TmjReaderBase.Data.cs +++ b/src/DotTiled/Serialization/Tmj/TmjReaderBase.Data.cs @@ -23,8 +23,8 @@ public abstract partial class TmjReaderBase var x = element.GetRequiredProperty("x"); var y = element.GetRequiredProperty("y"); - var width = element.GetRequiredProperty("width"); - var height = element.GetRequiredProperty("height"); + var width = element.GetRequiredProperty("width"); + var height = element.GetRequiredProperty("height"); return new Chunk { diff --git a/src/DotTiled/Serialization/Tmj/TmjReaderBase.Group.cs b/src/DotTiled/Serialization/Tmj/TmjReaderBase.Group.cs index 0df3c10..4c6ac38 100644 --- a/src/DotTiled/Serialization/Tmj/TmjReaderBase.Group.cs +++ b/src/DotTiled/Serialization/Tmj/TmjReaderBase.Group.cs @@ -12,7 +12,7 @@ public abstract partial class TmjReaderBase var @class = element.GetOptionalProperty("class").GetValueOr(""); var opacity = element.GetOptionalProperty("opacity").GetValueOr(1.0f); var visible = element.GetOptionalProperty("visible").GetValueOr(true); - var tintColor = element.GetOptionalPropertyParseable("tintcolor"); + var tintColor = element.GetOptionalPropertyParseable("tintcolor"); var offsetX = element.GetOptionalProperty("offsetx").GetValueOr(0.0f); var offsetY = element.GetOptionalProperty("offsety").GetValueOr(0.0f); var parallaxX = element.GetOptionalProperty("parallaxx").GetValueOr(1.0f); diff --git a/src/DotTiled/Serialization/Tmj/TmjReaderBase.ImageLayer.cs b/src/DotTiled/Serialization/Tmj/TmjReaderBase.ImageLayer.cs index 3d59779..c0c2c5b 100644 --- a/src/DotTiled/Serialization/Tmj/TmjReaderBase.ImageLayer.cs +++ b/src/DotTiled/Serialization/Tmj/TmjReaderBase.ImageLayer.cs @@ -11,7 +11,7 @@ public abstract partial class TmjReaderBase var @class = element.GetOptionalProperty("class").GetValueOr(""); var opacity = element.GetOptionalProperty("opacity").GetValueOr(1.0f); var visible = element.GetOptionalProperty("visible").GetValueOr(true); - var tintColor = element.GetOptionalPropertyParseable("tintcolor"); + var tintColor = element.GetOptionalPropertyParseable("tintcolor"); var offsetX = element.GetOptionalProperty("offsetx").GetValueOr(0.0f); var offsetY = element.GetOptionalProperty("offsety").GetValueOr(0.0f); var parallaxX = element.GetOptionalProperty("parallaxx").GetValueOr(1.0f); @@ -19,17 +19,19 @@ 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"); - var x = element.GetOptionalProperty("x").GetValueOr(0); - var y = element.GetOptionalProperty("y").GetValueOr(0); + var transparentColor = element.GetOptionalPropertyParseable("transparentcolor"); + var x = element.GetOptionalProperty("x").GetValueOr(0); + var y = element.GetOptionalProperty("y").GetValueOr(0); var imgModel = new Image { Format = Helpers.ParseImageFormatFromSource(image), - Height = 0, - Width = 0, + Height = imageHeight, + Width = imageWidth, Source = image, TransparentColor = transparentColor }; diff --git a/src/DotTiled/Serialization/Tmj/TmjReaderBase.Map.cs b/src/DotTiled/Serialization/Tmj/TmjReaderBase.Map.cs index caecb7e..dfe7eee 100644 --- a/src/DotTiled/Serialization/Tmj/TmjReaderBase.Map.cs +++ b/src/DotTiled/Serialization/Tmj/TmjReaderBase.Map.cs @@ -28,11 +28,11 @@ public abstract partial class TmjReaderBase _ => throw new JsonException($"Unknown render order '{s}'") }).GetValueOr(RenderOrder.RightDown); var compressionLevel = element.GetOptionalProperty("compressionlevel").GetValueOr(-1); - var width = element.GetRequiredProperty("width"); - var height = element.GetRequiredProperty("height"); - var tileWidth = element.GetRequiredProperty("tilewidth"); - var tileHeight = element.GetRequiredProperty("tileheight"); - var hexSideLength = element.GetOptionalProperty("hexsidelength"); + var width = element.GetRequiredProperty("width"); + var height = element.GetRequiredProperty("height"); + var tileWidth = element.GetRequiredProperty("tilewidth"); + var tileHeight = element.GetRequiredProperty("tileheight"); + var hexSideLength = element.GetOptionalProperty("hexsidelength"); var staggerAxis = element.GetOptionalPropertyParseable("staggeraxis", s => s switch { "x" => StaggerAxis.X, @@ -47,7 +47,7 @@ public abstract partial class TmjReaderBase }); var parallaxOriginX = element.GetOptionalProperty("parallaxoriginx").GetValueOr(0f); var parallaxOriginY = element.GetOptionalProperty("parallaxoriginy").GetValueOr(0f); - var backgroundColor = element.GetOptionalPropertyParseable("backgroundcolor").GetValueOr(Color.Parse("#00000000", CultureInfo.InvariantCulture)); + var backgroundColor = element.GetOptionalPropertyParseable("backgroundcolor").GetValueOr(TiledColor.Parse("#00000000", CultureInfo.InvariantCulture)); var nextLayerID = element.GetRequiredProperty("nextlayerid"); var nextObjectID = element.GetRequiredProperty("nextobjectid"); var infinite = element.GetOptionalProperty("infinite").GetValueOr(false); diff --git a/src/DotTiled/Serialization/Tmj/TmjReaderBase.ObjectLayer.cs b/src/DotTiled/Serialization/Tmj/TmjReaderBase.ObjectLayer.cs index ced3f64..132ceba 100644 --- a/src/DotTiled/Serialization/Tmj/TmjReaderBase.ObjectLayer.cs +++ b/src/DotTiled/Serialization/Tmj/TmjReaderBase.ObjectLayer.cs @@ -15,18 +15,18 @@ public abstract partial class TmjReaderBase var @class = element.GetOptionalProperty("class").GetValueOr(""); var opacity = element.GetOptionalProperty("opacity").GetValueOr(1.0f); var visible = element.GetOptionalProperty("visible").GetValueOr(true); - var tintColor = element.GetOptionalPropertyParseable("tintcolor"); + var tintColor = element.GetOptionalPropertyParseable("tintcolor"); var offsetX = element.GetOptionalProperty("offsetx").GetValueOr(0.0f); var offsetY = element.GetOptionalProperty("offsety").GetValueOr(0.0f); var parallaxX = element.GetOptionalProperty("parallaxx").GetValueOr(1.0f); var parallaxY = element.GetOptionalProperty("parallaxy").GetValueOr(1.0f); var properties = ResolveAndMergeProperties(@class, element.GetOptionalPropertyCustom("properties", ReadProperties).GetValueOr([])); - var x = element.GetOptionalProperty("x").GetValueOr(0); - var y = element.GetOptionalProperty("y").GetValueOr(0); - var width = element.GetOptionalProperty("width").GetValueOr(0); - var height = element.GetOptionalProperty("height").GetValueOr(0); - var color = element.GetOptionalPropertyParseable("color"); + var x = element.GetOptionalProperty("x").GetValueOr(0); + var y = element.GetOptionalProperty("y").GetValueOr(0); + var width = element.GetOptionalProperty("width").GetValueOr(0); + var height = element.GetOptionalProperty("height").GetValueOr(0); + var color = element.GetOptionalPropertyParseable("color"); var drawOrder = element.GetOptionalPropertyParseable("draworder", s => s switch { "topdown" => DrawOrder.TopDown, @@ -255,7 +255,7 @@ public abstract partial class TmjReaderBase internal static TextObject ReadText(JsonElement element) { var bold = element.GetOptionalProperty("bold").GetValueOr(false); - var color = element.GetOptionalPropertyParseable("color").GetValueOr(Color.Parse("#00000000", CultureInfo.InvariantCulture)); + var color = element.GetOptionalPropertyParseable("color").GetValueOr(TiledColor.Parse("#00000000", CultureInfo.InvariantCulture)); var fontfamily = element.GetOptionalProperty("fontfamily").GetValueOr("sans-serif"); var halign = element.GetOptionalPropertyParseable("halign", s => s switch { diff --git a/src/DotTiled/Serialization/Tmj/TmjReaderBase.Properties.cs b/src/DotTiled/Serialization/Tmj/TmjReaderBase.Properties.cs index ae7ea1c..1ad6e53 100644 --- a/src/DotTiled/Serialization/Tmj/TmjReaderBase.Properties.cs +++ b/src/DotTiled/Serialization/Tmj/TmjReaderBase.Properties.cs @@ -36,7 +36,7 @@ public abstract partial class TmjReaderBase PropertyType.Int => new IntProperty { Name = name, Value = e.GetRequiredProperty("value") }, PropertyType.Float => new FloatProperty { Name = name, Value = e.GetRequiredProperty("value") }, PropertyType.Bool => new BoolProperty { Name = name, Value = e.GetRequiredProperty("value") }, - PropertyType.Color => new ColorProperty { Name = name, Value = e.GetRequiredPropertyParseable("value", s => s == "" ? default : Color.Parse(s, CultureInfo.InvariantCulture)) }, + PropertyType.Color => new ColorProperty { Name = name, Value = e.GetRequiredPropertyParseable("value", s => s == "" ? default : TiledColor.Parse(s, CultureInfo.InvariantCulture)) }, PropertyType.File => new FileProperty { Name = name, Value = e.GetRequiredProperty("value") }, PropertyType.Object => new ObjectProperty { Name = name, Value = e.GetRequiredProperty("value") }, PropertyType.Class => throw new JsonException("Class property must have a property type"), @@ -163,7 +163,7 @@ public abstract partial class TmjReaderBase PropertyType.Int => new IntProperty { Name = prop.Name, Value = propElement.GetValueAs() }, PropertyType.Float => new FloatProperty { Name = prop.Name, Value = propElement.GetValueAs() }, PropertyType.Bool => new BoolProperty { Name = prop.Name, Value = propElement.GetValueAs() }, - PropertyType.Color => new ColorProperty { Name = prop.Name, Value = Color.Parse(propElement.GetValueAs(), CultureInfo.InvariantCulture) }, + PropertyType.Color => new ColorProperty { Name = prop.Name, Value = TiledColor.Parse(propElement.GetValueAs(), CultureInfo.InvariantCulture) }, PropertyType.File => new FileProperty { Name = prop.Name, Value = propElement.GetValueAs() }, PropertyType.Object => new ObjectProperty { Name = prop.Name, Value = propElement.GetValueAs() }, PropertyType.Enum => ReadEnumProperty(propElement), diff --git a/src/DotTiled/Serialization/Tmj/TmjReaderBase.TileLayer.cs b/src/DotTiled/Serialization/Tmj/TmjReaderBase.TileLayer.cs index f33840d..287ef18 100644 --- a/src/DotTiled/Serialization/Tmj/TmjReaderBase.TileLayer.cs +++ b/src/DotTiled/Serialization/Tmj/TmjReaderBase.TileLayer.cs @@ -22,7 +22,7 @@ public abstract partial class TmjReaderBase var chunks = element.GetOptionalPropertyCustom("chunks", e => ReadDataAsChunks(e, compression, encoding)); var @class = element.GetOptionalProperty("class").GetValueOr(""); var data = element.GetOptionalPropertyCustom("data", e => ReadDataWithoutChunks(e, compression, encoding)); - var height = element.GetRequiredProperty("height"); + var height = element.GetRequiredProperty("height"); var id = element.GetRequiredProperty("id"); var name = element.GetRequiredProperty("name"); var offsetX = element.GetOptionalProperty("offsetx").GetValueOr(0.0f); @@ -35,12 +35,12 @@ public abstract partial class TmjReaderBase var repeatY = element.GetOptionalProperty("repeaty").GetValueOr(false); var startX = element.GetOptionalProperty("startx").GetValueOr(0); var startY = element.GetOptionalProperty("starty").GetValueOr(0); - var tintColor = element.GetOptionalPropertyParseable("tintcolor"); - var transparentColor = element.GetOptionalPropertyParseable("transparentcolor"); + var tintColor = element.GetOptionalPropertyParseable("tintcolor"); + var transparentColor = element.GetOptionalPropertyParseable("transparentcolor"); var visible = element.GetOptionalProperty("visible").GetValueOr(true); - var width = element.GetRequiredProperty("width"); - var x = element.GetRequiredProperty("x"); - var y = element.GetRequiredProperty("y"); + var width = element.GetRequiredProperty("width"); + var x = element.GetRequiredProperty("x"); + var y = element.GetRequiredProperty("y"); if (!data.HasValue && !chunks.HasValue) throw new JsonException("Tile layer does not contain data."); diff --git a/src/DotTiled/Serialization/Tmj/TmjReaderBase.Tileset.cs b/src/DotTiled/Serialization/Tmj/TmjReaderBase.Tileset.cs index 9263fa9..fae87fe 100644 --- a/src/DotTiled/Serialization/Tmj/TmjReaderBase.Tileset.cs +++ b/src/DotTiled/Serialization/Tmj/TmjReaderBase.Tileset.cs @@ -10,9 +10,9 @@ public abstract partial class TmjReaderBase Optional parentVersion = null, Optional parentTiledVersion = null) { - var backgroundColor = element.GetOptionalPropertyParseable("backgroundcolor"); + var backgroundColor = element.GetOptionalPropertyParseable("backgroundcolor"); var @class = element.GetOptionalProperty("class").GetValueOr(""); - var columns = element.GetOptionalProperty("columns"); + var columns = element.GetOptionalProperty("columns"); var fillMode = element.GetOptionalPropertyParseable("fillmode", s => s switch { "stretch" => FillMode.Stretch, @@ -22,9 +22,9 @@ public abstract partial class TmjReaderBase var firstGID = element.GetOptionalProperty("firstgid"); var grid = element.GetOptionalPropertyCustom("grid", ReadGrid); var image = element.GetOptionalProperty("image"); - var imageHeight = element.GetOptionalProperty("imageheight"); - var imageWidth = element.GetOptionalProperty("imagewidth"); - var margin = element.GetOptionalProperty("margin"); + var imageHeight = element.GetOptionalProperty("imageheight"); + var imageWidth = element.GetOptionalProperty("imagewidth"); + var margin = element.GetOptionalProperty("margin"); var name = element.GetOptionalProperty("name"); var objectAlignment = element.GetOptionalPropertyParseable("objectalignment", s => s switch { @@ -42,10 +42,10 @@ public abstract partial class TmjReaderBase }).GetValueOr(ObjectAlignment.Unspecified); var properties = ResolveAndMergeProperties(@class, element.GetOptionalPropertyCustom("properties", ReadProperties).GetValueOr([])); var source = element.GetOptionalProperty("source"); - var spacing = element.GetOptionalProperty("spacing"); - var tileCount = element.GetOptionalProperty("tilecount"); + var spacing = element.GetOptionalProperty("spacing"); + var tileCount = element.GetOptionalProperty("tilecount"); var tiledVersion = element.GetOptionalProperty("tiledversion").GetValueOrOptional(parentTiledVersion); - var tileHeight = element.GetOptionalProperty("tileheight"); + var tileHeight = element.GetOptionalProperty("tileheight"); var tileOffset = element.GetOptionalPropertyCustom("tileoffset", ReadTileOffset); var tileRenderSize = element.GetOptionalPropertyParseable("tilerendersize", s => s switch { @@ -54,9 +54,8 @@ public abstract partial class TmjReaderBase _ => throw new JsonException($"Unknown tile render size '{s}'") }).GetValueOr(TileRenderSize.Tile); var tiles = element.GetOptionalPropertyCustom>("tiles", ReadTiles).GetValueOr([]); - var tileWidth = element.GetOptionalProperty("tilewidth"); - var transparentColor = element.GetOptionalPropertyParseable("transparentcolor"); - var type = element.GetOptionalProperty("type"); + var tileWidth = element.GetOptionalProperty("tilewidth"); + var transparentColor = element.GetOptionalPropertyParseable("transparentcolor"); var version = element.GetOptionalProperty("version").GetValueOrOptional(parentVersion); var transformations = element.GetOptionalPropertyCustom("transformations", ReadTransformations); var wangsets = element.GetOptionalPropertyCustom>("wangsets", el => el.GetValueAsList(e => ReadWangset(e))).GetValueOr([]); @@ -129,8 +128,8 @@ public abstract partial class TmjReaderBase "isometric" => GridOrientation.Isometric, _ => throw new JsonException($"Unknown grid orientation '{s}'") }).GetValueOr(GridOrientation.Orthogonal); - var height = element.GetRequiredProperty("height"); - var width = element.GetRequiredProperty("width"); + var height = element.GetRequiredProperty("height"); + var width = element.GetRequiredProperty("width"); return new Grid { @@ -158,12 +157,12 @@ public abstract partial class TmjReaderBase var animation = e.GetOptionalPropertyCustom>("animation", e => e.GetValueAsList(ReadFrame)).GetValueOr([]); var id = e.GetRequiredProperty("id"); var image = e.GetOptionalProperty("image"); - var imageHeight = e.GetOptionalProperty("imageheight"); - var imageWidth = e.GetOptionalProperty("imagewidth"); - var x = e.GetOptionalProperty("x").GetValueOr(0); - var y = e.GetOptionalProperty("y").GetValueOr(0); - var width = e.GetOptionalProperty("width").GetValueOr(imageWidth.GetValueOr(0)); - var height = e.GetOptionalProperty("height").GetValueOr(imageHeight.GetValueOr(0)); + var imageHeight = e.GetOptionalProperty("imageheight"); + var imageWidth = e.GetOptionalProperty("imagewidth"); + var x = e.GetOptionalProperty("x").GetValueOr(0); + var y = e.GetOptionalProperty("y").GetValueOr(0); + var width = e.GetOptionalProperty("width").GetValueOr(imageWidth.GetValueOr(0)); + var height = e.GetOptionalProperty("height").GetValueOr(imageHeight.GetValueOr(0)); var objectGroup = e.GetOptionalPropertyCustom("objectgroup", e => ReadObjectLayer(e)); var probability = e.GetOptionalProperty("probability").GetValueOr(0.0f); var type = e.GetOptionalProperty("type").GetValueOr(""); @@ -195,7 +194,7 @@ public abstract partial class TmjReaderBase internal static Frame ReadFrame(JsonElement element) { - var duration = element.GetRequiredProperty("duration"); + var duration = element.GetRequiredProperty("duration"); var tileID = element.GetRequiredProperty("tileid"); return new Frame @@ -229,7 +228,7 @@ public abstract partial class TmjReaderBase internal WangColor ReadWangColor(JsonElement element) { var @class = element.GetOptionalProperty("class").GetValueOr(""); - var color = element.GetRequiredPropertyParseable("color"); + var color = element.GetRequiredPropertyParseable("color"); var name = element.GetRequiredProperty("name"); var probability = element.GetOptionalProperty("probability").GetValueOr(1.0f); var properties = ResolveAndMergeProperties(@class, element.GetOptionalPropertyCustom("properties", ReadProperties).GetValueOr([])); diff --git a/src/DotTiled/Serialization/Tmx/TmxReaderBase.Chunk.cs b/src/DotTiled/Serialization/Tmx/TmxReaderBase.Chunk.cs index be10819..31a21f6 100644 --- a/src/DotTiled/Serialization/Tmx/TmxReaderBase.Chunk.cs +++ b/src/DotTiled/Serialization/Tmx/TmxReaderBase.Chunk.cs @@ -6,8 +6,8 @@ public abstract partial class TmxReaderBase { var x = _reader.GetRequiredAttributeParseable("x"); var y = _reader.GetRequiredAttributeParseable("y"); - var width = _reader.GetRequiredAttributeParseable("width"); - var height = _reader.GetRequiredAttributeParseable("height"); + var width = _reader.GetRequiredAttributeParseable("width"); + var height = _reader.GetRequiredAttributeParseable("height"); var usesTileChildrenInsteadOfRawData = !encoding.HasValue; if (usesTileChildrenInsteadOfRawData) diff --git a/src/DotTiled/Serialization/Tmx/TmxReaderBase.Map.cs b/src/DotTiled/Serialization/Tmx/TmxReaderBase.Map.cs index ed3a492..9f48633 100644 --- a/src/DotTiled/Serialization/Tmx/TmxReaderBase.Map.cs +++ b/src/DotTiled/Serialization/Tmx/TmxReaderBase.Map.cs @@ -32,11 +32,11 @@ public abstract partial class TmxReaderBase _ => throw new InvalidOperationException($"Unknown render order '{s}'") }).GetValueOr(RenderOrder.RightDown); var compressionLevel = _reader.GetOptionalAttributeParseable("compressionlevel").GetValueOr(-1); - var width = _reader.GetRequiredAttributeParseable("width"); - var height = _reader.GetRequiredAttributeParseable("height"); - var tileWidth = _reader.GetRequiredAttributeParseable("tilewidth"); - var tileHeight = _reader.GetRequiredAttributeParseable("tileheight"); - var hexSideLength = _reader.GetOptionalAttributeParseable("hexsidelength"); + var width = _reader.GetRequiredAttributeParseable("width"); + var height = _reader.GetRequiredAttributeParseable("height"); + var tileWidth = _reader.GetRequiredAttributeParseable("tilewidth"); + var tileHeight = _reader.GetRequiredAttributeParseable("tileheight"); + var hexSideLength = _reader.GetOptionalAttributeParseable("hexsidelength"); var staggerAxis = _reader.GetOptionalAttributeEnum("staggeraxis", s => s switch { "x" => StaggerAxis.X, @@ -51,7 +51,7 @@ public abstract partial class TmxReaderBase }); var parallaxOriginX = _reader.GetOptionalAttributeParseable("parallaxoriginx").GetValueOr(0.0f); var parallaxOriginY = _reader.GetOptionalAttributeParseable("parallaxoriginy").GetValueOr(0.0f); - var backgroundColor = _reader.GetOptionalAttributeClass("backgroundcolor").GetValueOr(Color.Parse("#00000000", CultureInfo.InvariantCulture)); + var backgroundColor = _reader.GetOptionalAttributeClass("backgroundcolor").GetValueOr(TiledColor.Parse("#00000000", CultureInfo.InvariantCulture)); var nextLayerID = _reader.GetRequiredAttributeParseable("nextlayerid"); var nextObjectID = _reader.GetRequiredAttributeParseable("nextobjectid"); var infinite = _reader.GetOptionalAttributeParseable("infinite").GetValueOr(0) == 1; diff --git a/src/DotTiled/Serialization/Tmx/TmxReaderBase.ObjectLayer.cs b/src/DotTiled/Serialization/Tmx/TmxReaderBase.ObjectLayer.cs index b2e0c56..5e70f5e 100644 --- a/src/DotTiled/Serialization/Tmx/TmxReaderBase.ObjectLayer.cs +++ b/src/DotTiled/Serialization/Tmx/TmxReaderBase.ObjectLayer.cs @@ -14,18 +14,18 @@ public abstract partial class TmxReaderBase var id = _reader.GetRequiredAttributeParseable("id"); var name = _reader.GetOptionalAttribute("name").GetValueOr(""); var @class = _reader.GetOptionalAttribute("class").GetValueOr(""); - var x = _reader.GetOptionalAttributeParseable("x").GetValueOr(0); - var y = _reader.GetOptionalAttributeParseable("y").GetValueOr(0); - var width = _reader.GetOptionalAttributeParseable("width").GetValueOr(0); - var height = _reader.GetOptionalAttributeParseable("height").GetValueOr(0); + var x = _reader.GetOptionalAttributeParseable("x").GetValueOr(0); + var y = _reader.GetOptionalAttributeParseable("y").GetValueOr(0); + var width = _reader.GetOptionalAttributeParseable("width").GetValueOr(0); + var height = _reader.GetOptionalAttributeParseable("height").GetValueOr(0); var opacity = _reader.GetOptionalAttributeParseable("opacity").GetValueOr(1.0f); var visible = _reader.GetOptionalAttributeParseable("visible").GetValueOr(1) == 1; - var tintColor = _reader.GetOptionalAttributeClass("tintcolor"); + var tintColor = _reader.GetOptionalAttributeClass("tintcolor"); var offsetX = _reader.GetOptionalAttributeParseable("offsetx").GetValueOr(0.0f); var offsetY = _reader.GetOptionalAttributeParseable("offsety").GetValueOr(0.0f); var parallaxX = _reader.GetOptionalAttributeParseable("parallaxx").GetValueOr(1.0f); var parallaxY = _reader.GetOptionalAttributeParseable("parallaxy").GetValueOr(1.0f); - var color = _reader.GetOptionalAttributeClass("color"); + var color = _reader.GetOptionalAttributeClass("color"); var drawOrder = _reader.GetOptionalAttributeEnum("draworder", s => s switch { "topdown" => DrawOrder.TopDown, @@ -245,7 +245,7 @@ public abstract partial class TmxReaderBase var fontFamily = _reader.GetOptionalAttribute("fontfamily") ?? "sans-serif"; var pixelSize = _reader.GetOptionalAttributeParseable("pixelsize") ?? 16; var wrap = _reader.GetOptionalAttributeParseable("wrap") ?? false; - var color = _reader.GetOptionalAttributeClass("color") ?? Color.Parse("#000000", CultureInfo.InvariantCulture); + var color = _reader.GetOptionalAttributeClass("color") ?? TiledColor.Parse("#000000", CultureInfo.InvariantCulture); var bold = _reader.GetOptionalAttributeParseable("bold") ?? false; var italic = _reader.GetOptionalAttributeParseable("italic") ?? false; var underline = _reader.GetOptionalAttributeParseable("underline") ?? false; diff --git a/src/DotTiled/Serialization/Tmx/TmxReaderBase.Properties.cs b/src/DotTiled/Serialization/Tmx/TmxReaderBase.Properties.cs index 5770056..94b730b 100644 --- a/src/DotTiled/Serialization/Tmx/TmxReaderBase.Properties.cs +++ b/src/DotTiled/Serialization/Tmx/TmxReaderBase.Properties.cs @@ -45,7 +45,7 @@ public abstract partial class TmxReaderBase PropertyType.Int => new IntProperty { Name = name, Value = r.GetRequiredAttributeParseable("value") }, PropertyType.Float => new FloatProperty { Name = name, Value = r.GetRequiredAttributeParseable("value") }, PropertyType.Bool => new BoolProperty { Name = name, Value = r.GetRequiredAttributeParseable("value") }, - PropertyType.Color => new ColorProperty { Name = name, Value = r.GetRequiredAttributeParseable("value", s => s == "" ? default : Color.Parse(s, CultureInfo.InvariantCulture)) }, + PropertyType.Color => new ColorProperty { Name = name, Value = r.GetRequiredAttributeParseable("value", s => s == "" ? default : TiledColor.Parse(s, CultureInfo.InvariantCulture)) }, PropertyType.File => new FileProperty { Name = name, Value = r.GetRequiredAttribute("value") }, PropertyType.Object => new ObjectProperty { Name = name, Value = r.GetRequiredAttributeParseable("value") }, PropertyType.Class => throw new XmlException("Class property must have a property type"), diff --git a/src/DotTiled/Serialization/Tmx/TmxReaderBase.TileLayer.cs b/src/DotTiled/Serialization/Tmx/TmxReaderBase.TileLayer.cs index 974215b..2df44b4 100644 --- a/src/DotTiled/Serialization/Tmx/TmxReaderBase.TileLayer.cs +++ b/src/DotTiled/Serialization/Tmx/TmxReaderBase.TileLayer.cs @@ -10,13 +10,13 @@ public abstract partial class TmxReaderBase var id = _reader.GetRequiredAttributeParseable("id"); var name = _reader.GetOptionalAttribute("name").GetValueOr(""); var @class = _reader.GetOptionalAttribute("class").GetValueOr(""); - var x = _reader.GetOptionalAttributeParseable("x").GetValueOr(0); - var y = _reader.GetOptionalAttributeParseable("y").GetValueOr(0); - var width = _reader.GetRequiredAttributeParseable("width"); - var height = _reader.GetRequiredAttributeParseable("height"); + var x = _reader.GetOptionalAttributeParseable("x").GetValueOr(0); + var y = _reader.GetOptionalAttributeParseable("y").GetValueOr(0); + var width = _reader.GetRequiredAttributeParseable("width"); + var height = _reader.GetRequiredAttributeParseable("height"); var opacity = _reader.GetOptionalAttributeParseable("opacity").GetValueOr(1.0f); var visible = _reader.GetOptionalAttributeParseable("visible").GetValueOr(1) == 1; - var tintColor = _reader.GetOptionalAttributeClass("tintcolor"); + var tintColor = _reader.GetOptionalAttributeClass("tintcolor"); var offsetX = _reader.GetOptionalAttributeParseable("offsetx").GetValueOr(0.0f); var offsetY = _reader.GetOptionalAttributeParseable("offsety").GetValueOr(0.0f); var parallaxX = _reader.GetOptionalAttributeParseable("parallaxx").GetValueOr(1.0f); @@ -59,11 +59,11 @@ public abstract partial class TmxReaderBase var id = _reader.GetRequiredAttributeParseable("id"); var name = _reader.GetOptionalAttribute("name").GetValueOr(""); var @class = _reader.GetOptionalAttribute("class").GetValueOr(""); - var x = _reader.GetOptionalAttributeParseable("x").GetValueOr(0); - var y = _reader.GetOptionalAttributeParseable("y").GetValueOr(0); + var x = _reader.GetOptionalAttributeParseable("x").GetValueOr(0); + var y = _reader.GetOptionalAttributeParseable("y").GetValueOr(0); var opacity = _reader.GetOptionalAttributeParseable("opacity").GetValueOr(1f); var visible = _reader.GetOptionalAttributeParseable("visible").GetValueOr(true); - var tintColor = _reader.GetOptionalAttributeClass("tintcolor"); + var tintColor = _reader.GetOptionalAttributeClass("tintcolor"); var offsetX = _reader.GetOptionalAttributeParseable("offsetx").GetValueOr(0.0f); var offsetY = _reader.GetOptionalAttributeParseable("offsety").GetValueOr(0.0f); var parallaxX = _reader.GetOptionalAttributeParseable("parallaxx").GetValueOr(1.0f); @@ -110,7 +110,7 @@ public abstract partial class TmxReaderBase var @class = _reader.GetOptionalAttribute("class").GetValueOr(""); var opacity = _reader.GetOptionalAttributeParseable("opacity").GetValueOr(1.0f); var visible = _reader.GetOptionalAttributeParseable("visible").GetValueOr(1) == 1; - var tintColor = _reader.GetOptionalAttributeClass("tintcolor"); + var tintColor = _reader.GetOptionalAttributeClass("tintcolor"); var offsetX = _reader.GetOptionalAttributeParseable("offsetx").GetValueOr(0f); var offsetY = _reader.GetOptionalAttributeParseable("offsety").GetValueOr(0f); var parallaxX = _reader.GetOptionalAttributeParseable("parallaxx").GetValueOr(1f); diff --git a/src/DotTiled/Serialization/Tmx/TmxReaderBase.Tileset.cs b/src/DotTiled/Serialization/Tmx/TmxReaderBase.Tileset.cs index bc7e0e8..4180bfe 100644 --- a/src/DotTiled/Serialization/Tmx/TmxReaderBase.Tileset.cs +++ b/src/DotTiled/Serialization/Tmx/TmxReaderBase.Tileset.cs @@ -31,12 +31,12 @@ public abstract partial class TmxReaderBase var tiledVersion = _reader.GetOptionalAttribute("tiledversion").GetValueOrOptional(parentTiledVersion); var name = _reader.GetRequiredAttribute("name"); var @class = _reader.GetOptionalAttribute("class").GetValueOr(""); - var tileWidth = _reader.GetRequiredAttributeParseable("tilewidth"); - var tileHeight = _reader.GetRequiredAttributeParseable("tileheight"); - var spacing = _reader.GetOptionalAttributeParseable("spacing").GetValueOr(0); - var margin = _reader.GetOptionalAttributeParseable("margin").GetValueOr(0); - var tileCount = _reader.GetRequiredAttributeParseable("tilecount"); - var columns = _reader.GetRequiredAttributeParseable("columns"); + var tileWidth = _reader.GetRequiredAttributeParseable("tilewidth"); + var tileHeight = _reader.GetRequiredAttributeParseable("tileheight"); + var spacing = _reader.GetOptionalAttributeParseable("spacing").GetValueOr(0); + var margin = _reader.GetOptionalAttributeParseable("margin").GetValueOr(0); + var tileCount = _reader.GetRequiredAttributeParseable("tilecount"); + var columns = _reader.GetRequiredAttributeParseable("columns"); var objectAlignment = _reader.GetOptionalAttributeEnum("objectalignment", s => s switch { "unspecified" => ObjectAlignment.Unspecified, @@ -125,9 +125,9 @@ public abstract partial class TmxReaderBase _ => throw new InvalidOperationException($"Unknown image format '{s}'") }); var source = _reader.GetOptionalAttribute("source"); - var transparentColor = _reader.GetOptionalAttributeClass("trans"); - var width = _reader.GetOptionalAttributeParseable("width"); - var height = _reader.GetOptionalAttributeParseable("height"); + var transparentColor = _reader.GetOptionalAttributeClass("trans"); + var width = _reader.GetOptionalAttributeParseable("width"); + var height = _reader.GetOptionalAttributeParseable("height"); _reader.ProcessChildren("image", (r, elementName) => elementName switch { @@ -167,8 +167,8 @@ public abstract partial class TmxReaderBase "isometric" => GridOrientation.Isometric, _ => throw new InvalidOperationException($"Unknown orientation '{s}'") }).GetValueOr(GridOrientation.Orthogonal); - var width = _reader.GetRequiredAttributeParseable("width"); - var height = _reader.GetRequiredAttributeParseable("height"); + var width = _reader.GetRequiredAttributeParseable("width"); + var height = _reader.GetRequiredAttributeParseable("height"); _reader.ReadStartElement("grid"); return new Grid { Orientation = orientation, Width = width, Height = height }; @@ -192,10 +192,10 @@ public abstract partial class TmxReaderBase var id = _reader.GetRequiredAttributeParseable("id"); var type = _reader.GetOptionalAttribute("type").GetValueOr(""); var probability = _reader.GetOptionalAttributeParseable("probability").GetValueOr(0f); - var x = _reader.GetOptionalAttributeParseable("x").GetValueOr(0); - var y = _reader.GetOptionalAttributeParseable("y").GetValueOr(0); - var width = _reader.GetOptionalAttributeParseable("width"); - var height = _reader.GetOptionalAttributeParseable("height"); + var x = _reader.GetOptionalAttributeParseable("x").GetValueOr(0); + var y = _reader.GetOptionalAttributeParseable("y").GetValueOr(0); + var width = _reader.GetOptionalAttributeParseable("width"); + var height = _reader.GetOptionalAttributeParseable("height"); // Elements var propertiesCounter = 0; @@ -212,7 +212,7 @@ public abstract partial class TmxReaderBase "animation" => () => Helpers.SetAtMostOnce(ref animation, r.ReadList("animation", "frame", (ar) => { var tileID = ar.GetRequiredAttributeParseable("tileid"); - var duration = ar.GetRequiredAttributeParseable("duration"); + var duration = ar.GetRequiredAttributeParseable("duration"); return new Frame { TileID = tileID, Duration = duration }; }), "Animation"), _ => r.Skip @@ -277,7 +277,7 @@ public abstract partial class TmxReaderBase // Attributes var name = _reader.GetRequiredAttribute("name"); var @class = _reader.GetOptionalAttribute("class").GetValueOr(""); - var color = _reader.GetRequiredAttributeParseable("color"); + var color = _reader.GetRequiredAttributeParseable("color"); var tile = _reader.GetRequiredAttributeParseable("tile"); var probability = _reader.GetOptionalAttributeParseable("probability").GetValueOr(0f); diff --git a/src/DotTiled/Tilesets/Frame.cs b/src/DotTiled/Tilesets/Frame.cs index ff37133..fe76b22 100644 --- a/src/DotTiled/Tilesets/Frame.cs +++ b/src/DotTiled/Tilesets/Frame.cs @@ -13,5 +13,5 @@ public class Frame /// /// How long (in milliseconds) this frame should be displayed before advancing to the next frame. /// - public required uint Duration { get; set; } + public required int Duration { get; set; } } diff --git a/src/DotTiled/Tilesets/Grid.cs b/src/DotTiled/Tilesets/Grid.cs index c063dd1..a50ed54 100644 --- a/src/DotTiled/Tilesets/Grid.cs +++ b/src/DotTiled/Tilesets/Grid.cs @@ -29,10 +29,10 @@ public class Grid /// /// Width of a grid cell. /// - public required uint Width { get; set; } + public required int Width { get; set; } /// /// Height of a grid cell. /// - public required uint Height { get; set; } + public required int Height { get; set; } } diff --git a/src/DotTiled/Tilesets/Image.cs b/src/DotTiled/Tilesets/Image.cs index 5a2e49c..8685617 100644 --- a/src/DotTiled/Tilesets/Image.cs +++ b/src/DotTiled/Tilesets/Image.cs @@ -44,15 +44,15 @@ public class Image /// /// Defines a specific color that is treated as transparent. /// - public Optional TransparentColor { get; set; } = Optional.Empty; + public Optional TransparentColor { get; set; } = Optional.Empty; /// /// The image width in pixels, used for tile index correction when the image changes. /// - public Optional Width { get; set; } = Optional.Empty; + public Optional Width { get; set; } = Optional.Empty; /// /// The image height in pixels, used for tile index correction when the image changes. /// - public Optional Height { get; set; } = Optional.Empty; + public Optional Height { get; set; } = Optional.Empty; } diff --git a/src/DotTiled/Tilesets/Tile.cs b/src/DotTiled/Tilesets/Tile.cs index 6b679e1..0f8addb 100644 --- a/src/DotTiled/Tilesets/Tile.cs +++ b/src/DotTiled/Tilesets/Tile.cs @@ -26,22 +26,22 @@ public class Tile : HasPropertiesBase /// /// The X position of the sub-rectangle representing this tile within the tileset image. /// - public uint X { get; set; } = 0; + public int X { get; set; } = 0; /// /// The Y position of the sub-rectangle representing this tile within the tileset image. /// - public uint Y { get; set; } = 0; + public int Y { get; set; } = 0; /// /// The width of the sub-rectangle representing this tile within the tileset image. /// - public required uint Width { get; set; } + public required int Width { get; set; } /// /// The height of the sub-rectangle representing this tile within the tileset image. /// - public required uint Height { get; set; } + public required int Height { get; set; } /// /// Tile properties. diff --git a/src/DotTiled/Tilesets/Tileset.cs b/src/DotTiled/Tilesets/Tileset.cs index a00b400..4261261 100644 --- a/src/DotTiled/Tilesets/Tileset.cs +++ b/src/DotTiled/Tilesets/Tileset.cs @@ -156,32 +156,32 @@ public class Tileset : HasPropertiesBase /// /// The width of the tiles in this tileset, which should be at least 1 (non-zero) except in the case of image collection tilesets (in which case it stores the maximum tile width). /// - public required uint TileWidth { get; set; } + public required int TileWidth { get; set; } /// /// The height of the tiles in this tileset, which should be at least 1 (non-zero) except in the case of image collection tilesets (in which case it stores the maximum tile height). /// - public required uint TileHeight { get; set; } + public required int TileHeight { get; set; } /// /// The spacing in pixels between the tiles in this tileset (applies to the tileset image). Irrelevant for image collection tilesets. /// - public uint Spacing { get; set; } = 0; + public int Spacing { get; set; } = 0; /// /// The margin around the tiles in this tileset (applies to the tileset image). Irrelevant for image collection tilesets. /// - public uint Margin { get; set; } = 0; + public int Margin { get; set; } = 0; /// /// The number of tiles in this tileset. /// - public required uint TileCount { get; set; } + public required int TileCount { get; set; } /// /// The number of tile columns in the tileset. /// - public required uint Columns { get; set; } + public required int Columns { get; set; } /// /// Controls the aligntment for tile objects. @@ -254,25 +254,25 @@ public class Tileset : HasPropertiesBase { return new SourceRectangle { - X = (int)tileInTiles.X, - Y = (int)tileInTiles.Y, - Width = (int)tileInTiles.Width, - Height = (int)tileInTiles.Height + X = tileInTiles.X, + Y = tileInTiles.Y, + Width = tileInTiles.Width, + Height = tileInTiles.Height }; } - var column = localTileID % Columns; - var row = localTileID / Columns; + var column = (int)(localTileID % Columns); + var row = (int)(localTileID / Columns); var x = Margin + ((TileWidth + Spacing) * column); var y = Margin + ((TileHeight + Spacing) * row); return new SourceRectangle { - X = (int)x, - Y = (int)y, - Width = (int)TileWidth, - Height = (int)TileHeight + X = x, + Y = y, + Width = TileWidth, + Height = TileHeight }; } } diff --git a/src/DotTiled/Tilesets/WangColor.cs b/src/DotTiled/Tilesets/WangColor.cs index b5ef482..58131bd 100644 --- a/src/DotTiled/Tilesets/WangColor.cs +++ b/src/DotTiled/Tilesets/WangColor.cs @@ -20,7 +20,7 @@ public class WangColor : HasPropertiesBase /// /// The color of the Wang color. /// - public required Color Color { get; set; } + public required TiledColor Color { get; set; } /// /// The tile ID of the tile representing this color.