mirror of
https://github.com/dcronqvist/DotTiled.git
synced 2025-05-09 01:56:02 +03:00
Move source to src/
This commit is contained in:
parent
580e630148
commit
0a11cdd791
131 changed files with 0 additions and 0 deletions
43
src/DotTiled.Tests/Assert/AssertData.cs
Normal file
43
src/DotTiled.Tests/Assert/AssertData.cs
Normal file
|
@ -0,0 +1,43 @@
|
|||
namespace DotTiled.Tests;
|
||||
|
||||
public static partial class DotTiledAssert
|
||||
{
|
||||
internal static void AssertData(Data? expected, Data? actual)
|
||||
{
|
||||
if (expected is null)
|
||||
{
|
||||
Assert.Null(actual);
|
||||
return;
|
||||
}
|
||||
|
||||
// Attributes
|
||||
Assert.NotNull(actual);
|
||||
AssertEqual(expected.Encoding, actual.Encoding, nameof(Data.Encoding));
|
||||
AssertEqual(expected.Compression, actual.Compression, nameof(Data.Compression));
|
||||
|
||||
// Data
|
||||
AssertEqual(expected.GlobalTileIDs, actual.GlobalTileIDs, nameof(Data.GlobalTileIDs));
|
||||
AssertEqual(expected.FlippingFlags, actual.FlippingFlags, nameof(Data.FlippingFlags));
|
||||
|
||||
if (expected.Chunks is not null)
|
||||
{
|
||||
Assert.NotNull(actual.Chunks);
|
||||
AssertEqual(expected.Chunks.Length, actual.Chunks.Length, "Chunks.Length");
|
||||
for (var i = 0; i < expected.Chunks.Length; i++)
|
||||
AssertChunk(expected.Chunks[i], actual.Chunks[i]);
|
||||
}
|
||||
}
|
||||
|
||||
private static void AssertChunk(Chunk expected, Chunk actual)
|
||||
{
|
||||
// Attributes
|
||||
AssertEqual(expected.X, actual.X, nameof(Chunk.X));
|
||||
AssertEqual(expected.Y, actual.Y, nameof(Chunk.Y));
|
||||
AssertEqual(expected.Width, actual.Width, nameof(Chunk.Width));
|
||||
AssertEqual(expected.Height, actual.Height, nameof(Chunk.Height));
|
||||
|
||||
// Data
|
||||
AssertEqual(expected.GlobalTileIDs, actual.GlobalTileIDs, nameof(Chunk.GlobalTileIDs));
|
||||
AssertEqual(expected.FlippingFlags, actual.FlippingFlags, nameof(Chunk.FlippingFlags));
|
||||
}
|
||||
}
|
21
src/DotTiled.Tests/Assert/AssertImage.cs
Normal file
21
src/DotTiled.Tests/Assert/AssertImage.cs
Normal file
|
@ -0,0 +1,21 @@
|
|||
namespace DotTiled.Tests;
|
||||
|
||||
public static partial class DotTiledAssert
|
||||
{
|
||||
internal static void AssertImage(Image? expected, Image? actual)
|
||||
{
|
||||
if (expected is null)
|
||||
{
|
||||
Assert.Null(actual);
|
||||
return;
|
||||
}
|
||||
|
||||
// Attributes
|
||||
Assert.NotNull(actual);
|
||||
AssertEqual(expected.Format, actual.Format, nameof(Image.Format));
|
||||
AssertEqual(expected.Source, actual.Source, nameof(Image.Source));
|
||||
AssertEqual(expected.TransparentColor, actual.TransparentColor, nameof(Image.TransparentColor));
|
||||
AssertEqual(expected.Width, actual.Width, nameof(Image.Width));
|
||||
AssertEqual(expected.Height, actual.Height, nameof(Image.Height));
|
||||
}
|
||||
}
|
75
src/DotTiled.Tests/Assert/AssertLayer.cs
Normal file
75
src/DotTiled.Tests/Assert/AssertLayer.cs
Normal file
|
@ -0,0 +1,75 @@
|
|||
namespace DotTiled.Tests;
|
||||
|
||||
public static partial class DotTiledAssert
|
||||
{
|
||||
internal static void AssertLayer(BaseLayer? expected, BaseLayer? actual)
|
||||
{
|
||||
if (expected is null)
|
||||
{
|
||||
Assert.Null(actual);
|
||||
return;
|
||||
}
|
||||
|
||||
// Attributes
|
||||
Assert.NotNull(actual);
|
||||
AssertEqual(expected.ID, actual.ID, nameof(BaseLayer.ID));
|
||||
AssertEqual(expected.Name, actual.Name, nameof(BaseLayer.Name));
|
||||
AssertEqual(expected.Class, actual.Class, nameof(BaseLayer.Class));
|
||||
AssertEqual(expected.Opacity, actual.Opacity, nameof(BaseLayer.Opacity));
|
||||
AssertEqual(expected.Visible, actual.Visible, nameof(BaseLayer.Visible));
|
||||
AssertEqual(expected.TintColor, actual.TintColor, nameof(BaseLayer.TintColor));
|
||||
AssertEqual(expected.OffsetX, actual.OffsetX, nameof(BaseLayer.OffsetX));
|
||||
AssertEqual(expected.OffsetY, actual.OffsetY, nameof(BaseLayer.OffsetY));
|
||||
AssertEqual(expected.ParallaxX, actual.ParallaxX, nameof(BaseLayer.ParallaxX));
|
||||
AssertEqual(expected.ParallaxY, actual.ParallaxY, nameof(BaseLayer.ParallaxY));
|
||||
|
||||
AssertProperties(expected.Properties, actual.Properties);
|
||||
AssertLayer((dynamic)expected, (dynamic)actual);
|
||||
}
|
||||
|
||||
private static void AssertLayer(TileLayer expected, TileLayer actual)
|
||||
{
|
||||
// Attributes
|
||||
AssertEqual(expected.Width, actual.Width, nameof(TileLayer.Width));
|
||||
AssertEqual(expected.Height, actual.Height, nameof(TileLayer.Height));
|
||||
AssertEqual(expected.X, actual.X, nameof(TileLayer.X));
|
||||
AssertEqual(expected.Y, actual.Y, nameof(TileLayer.Y));
|
||||
|
||||
Assert.NotNull(actual.Data);
|
||||
AssertData(expected.Data, actual.Data);
|
||||
}
|
||||
|
||||
private static void AssertLayer(ObjectLayer expected, ObjectLayer actual)
|
||||
{
|
||||
// Attributes
|
||||
AssertEqual(expected.DrawOrder, actual.DrawOrder, nameof(ObjectLayer.DrawOrder));
|
||||
AssertEqual(expected.X, actual.X, nameof(ObjectLayer.X));
|
||||
AssertEqual(expected.Y, actual.Y, nameof(ObjectLayer.Y));
|
||||
|
||||
Assert.NotNull(actual.Objects);
|
||||
AssertEqual(expected.Objects.Count, actual.Objects.Count, "Objects.Count");
|
||||
for (var i = 0; i < expected.Objects.Count; i++)
|
||||
AssertObject(expected.Objects[i], actual.Objects[i]);
|
||||
}
|
||||
|
||||
private static void AssertLayer(ImageLayer expected, ImageLayer actual)
|
||||
{
|
||||
// Attributes
|
||||
AssertEqual(expected.RepeatX, actual.RepeatX, nameof(ImageLayer.RepeatX));
|
||||
AssertEqual(expected.RepeatY, actual.RepeatY, nameof(ImageLayer.RepeatY));
|
||||
AssertEqual(expected.X, actual.X, nameof(ImageLayer.X));
|
||||
AssertEqual(expected.Y, actual.Y, nameof(ImageLayer.Y));
|
||||
|
||||
Assert.NotNull(actual.Image);
|
||||
AssertImage(expected.Image, actual.Image);
|
||||
}
|
||||
|
||||
private static void AssertLayer(Group expected, Group actual)
|
||||
{
|
||||
// Attributes
|
||||
Assert.NotNull(actual.Layers);
|
||||
AssertEqual(expected.Layers.Count, actual.Layers.Count, "Layers.Count");
|
||||
for (var i = 0; i < expected.Layers.Count; i++)
|
||||
AssertLayer(expected.Layers[i], actual.Layers[i]);
|
||||
}
|
||||
}
|
105
src/DotTiled.Tests/Assert/AssertMap.cs
Normal file
105
src/DotTiled.Tests/Assert/AssertMap.cs
Normal file
|
@ -0,0 +1,105 @@
|
|||
using System.Collections;
|
||||
using System.Numerics;
|
||||
|
||||
namespace DotTiled.Tests;
|
||||
|
||||
public static partial class DotTiledAssert
|
||||
{
|
||||
private static void AssertEqual<T>(T expected, T actual, string nameof)
|
||||
{
|
||||
if (expected == null)
|
||||
{
|
||||
Assert.Null(actual);
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof(T) == typeof(float))
|
||||
{
|
||||
var expectedFloat = (float)(object)expected;
|
||||
var actualFloat = (float)(object)actual!;
|
||||
|
||||
var expecRounded = MathF.Round(expectedFloat, 3);
|
||||
var actRounded = MathF.Round(actualFloat, 3);
|
||||
|
||||
Assert.True(expecRounded == actRounded, $"Expected {nameof} '{expecRounded}' but got '{actRounded}'");
|
||||
return;
|
||||
}
|
||||
|
||||
if (expected is Vector2)
|
||||
{
|
||||
var expectedVector = (Vector2)(object)expected;
|
||||
var actualVector = (Vector2)(object)actual!;
|
||||
|
||||
AssertEqual(expectedVector.X, actualVector.X, $"{nameof}.X");
|
||||
AssertEqual(expectedVector.Y, actualVector.Y, $"{nameof}.Y");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof(T).IsArray)
|
||||
{
|
||||
var expectedArray = (Array)(object)expected;
|
||||
var actualArray = (Array)(object)actual!;
|
||||
|
||||
Assert.NotNull(actualArray);
|
||||
AssertEqual(expectedArray.Length, actualArray.Length, $"{nameof}.Length");
|
||||
|
||||
for (var i = 0; i < expectedArray.Length; i++)
|
||||
AssertEqual(expectedArray.GetValue(i), actualArray.GetValue(i), $"{nameof}[{i}]");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof(T).IsGenericType && typeof(T).GetGenericTypeDefinition() == typeof(List<>))
|
||||
{
|
||||
var expectedList = (IList)(object)expected;
|
||||
var actualList = (IList)(object)actual!;
|
||||
|
||||
Assert.NotNull(actualList);
|
||||
AssertEqual(expectedList.Count, actualList.Count, $"{nameof}.Count");
|
||||
|
||||
for (var i = 0; i < expectedList.Count; i++)
|
||||
AssertEqual(expectedList[i], actualList[i], $"{nameof}[{i}]");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Assert.True(expected.Equals(actual), $"Expected {nameof} '{expected}' but got '{actual}'");
|
||||
}
|
||||
|
||||
internal static void AssertMap(Map expected, Map actual)
|
||||
{
|
||||
// Attributes
|
||||
AssertEqual(expected.Version, actual.Version, nameof(Map.Version));
|
||||
AssertEqual(expected.TiledVersion, actual.TiledVersion, nameof(Map.TiledVersion));
|
||||
AssertEqual(expected.Class, actual.Class, nameof(Map.Class));
|
||||
AssertEqual(expected.Orientation, actual.Orientation, nameof(Map.Orientation));
|
||||
AssertEqual(expected.RenderOrder, actual.RenderOrder, nameof(Map.RenderOrder));
|
||||
AssertEqual(expected.CompressionLevel, actual.CompressionLevel, nameof(Map.CompressionLevel));
|
||||
AssertEqual(expected.Width, actual.Width, nameof(Map.Width));
|
||||
AssertEqual(expected.Height, actual.Height, nameof(Map.Height));
|
||||
AssertEqual(expected.TileWidth, actual.TileWidth, nameof(Map.TileWidth));
|
||||
AssertEqual(expected.TileHeight, actual.TileHeight, nameof(Map.TileHeight));
|
||||
AssertEqual(expected.HexSideLength, actual.HexSideLength, nameof(Map.HexSideLength));
|
||||
AssertEqual(expected.StaggerAxis, actual.StaggerAxis, nameof(Map.StaggerAxis));
|
||||
AssertEqual(expected.StaggerIndex, actual.StaggerIndex, nameof(Map.StaggerIndex));
|
||||
AssertEqual(expected.ParallaxOriginX, actual.ParallaxOriginX, nameof(Map.ParallaxOriginX));
|
||||
AssertEqual(expected.ParallaxOriginY, actual.ParallaxOriginY, nameof(Map.ParallaxOriginY));
|
||||
AssertEqual(expected.BackgroundColor, actual.BackgroundColor, nameof(Map.BackgroundColor));
|
||||
AssertEqual(expected.NextLayerID, actual.NextLayerID, nameof(Map.NextLayerID));
|
||||
AssertEqual(expected.NextObjectID, actual.NextObjectID, nameof(Map.NextObjectID));
|
||||
AssertEqual(expected.Infinite, actual.Infinite, nameof(Map.Infinite));
|
||||
|
||||
AssertProperties(actual.Properties, expected.Properties);
|
||||
|
||||
Assert.NotNull(actual.Tilesets);
|
||||
AssertEqual(expected.Tilesets.Count, actual.Tilesets.Count, "Tilesets.Count");
|
||||
for (var i = 0; i < expected.Tilesets.Count; i++)
|
||||
AssertTileset(expected.Tilesets[i], actual.Tilesets[i]);
|
||||
|
||||
Assert.NotNull(actual.Layers);
|
||||
AssertEqual(expected.Layers.Count, actual.Layers.Count, "Layers.Count");
|
||||
for (var i = 0; i < expected.Layers.Count; i++)
|
||||
AssertLayer(expected.Layers[i], actual.Layers[i]);
|
||||
}
|
||||
}
|
73
src/DotTiled.Tests/Assert/AssertObject.cs
Normal file
73
src/DotTiled.Tests/Assert/AssertObject.cs
Normal file
|
@ -0,0 +1,73 @@
|
|||
namespace DotTiled.Tests;
|
||||
|
||||
public static partial class DotTiledAssert
|
||||
{
|
||||
internal static void AssertObject(Object expected, Object actual)
|
||||
{
|
||||
// Attributes
|
||||
AssertEqual(expected.ID, actual.ID, nameof(Object.ID));
|
||||
AssertEqual(expected.Name, actual.Name, nameof(Object.Name));
|
||||
AssertEqual(expected.Type, actual.Type, nameof(Object.Type));
|
||||
AssertEqual(expected.X, actual.X, nameof(Object.X));
|
||||
AssertEqual(expected.Y, actual.Y, nameof(Object.Y));
|
||||
AssertEqual(expected.Width, actual.Width, nameof(Object.Width));
|
||||
AssertEqual(expected.Height, actual.Height, nameof(Object.Height));
|
||||
AssertEqual(expected.Rotation, actual.Rotation, nameof(Object.Rotation));
|
||||
AssertEqual(expected.Visible, actual.Visible, nameof(Object.Visible));
|
||||
AssertEqual(expected.Template, actual.Template, nameof(Object.Template));
|
||||
|
||||
AssertProperties(expected.Properties, actual.Properties);
|
||||
|
||||
Assert.True(expected.GetType() == actual.GetType(), $"Expected object type {expected.GetType()} but got {actual.GetType()}");
|
||||
AssertObject((dynamic)expected, (dynamic)actual);
|
||||
}
|
||||
|
||||
private static void AssertObject(RectangleObject expected, RectangleObject actual)
|
||||
{
|
||||
Assert.True(true); // A rectangle object is the same as the abstract Object
|
||||
}
|
||||
|
||||
private static void AssertObject(EllipseObject expected, EllipseObject actual)
|
||||
{
|
||||
Assert.True(true); // An ellipse object is the same as the abstract Object
|
||||
}
|
||||
|
||||
private static void AssertObject(PointObject expected, PointObject actual)
|
||||
{
|
||||
Assert.True(true); // A point object is the same as the abstract Object
|
||||
}
|
||||
|
||||
private static void AssertObject(PolygonObject expected, PolygonObject actual)
|
||||
{
|
||||
AssertEqual(expected.Points, actual.Points, nameof(PolygonObject.Points));
|
||||
}
|
||||
|
||||
private static void AssertObject(PolylineObject expected, PolylineObject actual)
|
||||
{
|
||||
AssertEqual(expected.Points, actual.Points, nameof(PolylineObject.Points));
|
||||
}
|
||||
|
||||
private static void AssertObject(TextObject expected, TextObject actual)
|
||||
{
|
||||
// Attributes
|
||||
AssertEqual(expected.FontFamily, actual.FontFamily, nameof(TextObject.FontFamily));
|
||||
AssertEqual(expected.PixelSize, actual.PixelSize, nameof(TextObject.PixelSize));
|
||||
AssertEqual(expected.Wrap, actual.Wrap, nameof(TextObject.Wrap));
|
||||
AssertEqual(expected.Color, actual.Color, nameof(TextObject.Color));
|
||||
AssertEqual(expected.Bold, actual.Bold, nameof(TextObject.Bold));
|
||||
AssertEqual(expected.Italic, actual.Italic, nameof(TextObject.Italic));
|
||||
AssertEqual(expected.Underline, actual.Underline, nameof(TextObject.Underline));
|
||||
AssertEqual(expected.Strikeout, actual.Strikeout, nameof(TextObject.Strikeout));
|
||||
AssertEqual(expected.Kerning, actual.Kerning, nameof(TextObject.Kerning));
|
||||
AssertEqual(expected.HorizontalAlignment, actual.HorizontalAlignment, nameof(TextObject.HorizontalAlignment));
|
||||
AssertEqual(expected.VerticalAlignment, actual.VerticalAlignment, nameof(TextObject.VerticalAlignment));
|
||||
|
||||
AssertEqual(expected.Text, actual.Text, nameof(TextObject.Text));
|
||||
}
|
||||
|
||||
private static void AssertObject(TileObject expected, TileObject actual)
|
||||
{
|
||||
// Attributes
|
||||
AssertEqual(expected.GID, actual.GID, nameof(TileObject.GID));
|
||||
}
|
||||
}
|
69
src/DotTiled.Tests/Assert/AssertProperties.cs
Normal file
69
src/DotTiled.Tests/Assert/AssertProperties.cs
Normal file
|
@ -0,0 +1,69 @@
|
|||
namespace DotTiled.Tests;
|
||||
|
||||
public static partial class DotTiledAssert
|
||||
{
|
||||
internal static void AssertProperties(Dictionary<string, IProperty>? expected, Dictionary<string, IProperty>? actual)
|
||||
{
|
||||
if (expected is null)
|
||||
{
|
||||
Assert.Null(actual);
|
||||
return;
|
||||
}
|
||||
|
||||
Assert.NotNull(actual);
|
||||
AssertEqual(expected.Count, actual.Count, "Properties.Count");
|
||||
foreach (var kvp in expected)
|
||||
{
|
||||
Assert.Contains(kvp.Key, actual.Keys);
|
||||
AssertProperty((dynamic)kvp.Value, (dynamic)actual[kvp.Key]);
|
||||
}
|
||||
}
|
||||
|
||||
private static void AssertProperty(IProperty expected, IProperty actual)
|
||||
{
|
||||
AssertEqual(expected.Type, actual.Type, "Property.Type");
|
||||
AssertEqual(expected.Name, actual.Name, "Property.Name");
|
||||
AssertProperties((dynamic)actual, (dynamic)expected);
|
||||
}
|
||||
|
||||
private static void AssertProperty(StringProperty expected, StringProperty actual)
|
||||
{
|
||||
AssertEqual(expected.Value, actual.Value, "StringProperty.Value");
|
||||
}
|
||||
|
||||
private static void AssertProperty(IntProperty expected, IntProperty actual)
|
||||
{
|
||||
AssertEqual(expected.Value, actual.Value, "IntProperty.Value");
|
||||
}
|
||||
|
||||
private static void AssertProperty(FloatProperty expected, FloatProperty actual)
|
||||
{
|
||||
AssertEqual(expected.Value, actual.Value, "FloatProperty.Value");
|
||||
}
|
||||
|
||||
private static void AssertProperty(BoolProperty expected, BoolProperty actual)
|
||||
{
|
||||
AssertEqual(expected.Value, actual.Value, "BoolProperty.Value");
|
||||
}
|
||||
|
||||
private static void AssertProperty(ColorProperty expected, ColorProperty actual)
|
||||
{
|
||||
AssertEqual(expected.Value, actual.Value, "ColorProperty.Value");
|
||||
}
|
||||
|
||||
private static void AssertProperty(FileProperty expected, FileProperty actual)
|
||||
{
|
||||
AssertEqual(expected.Value, actual.Value, "FileProperty.Value");
|
||||
}
|
||||
|
||||
private static void AssertProperty(ObjectProperty expected, ObjectProperty actual)
|
||||
{
|
||||
AssertEqual(expected.Value, actual.Value, "ObjectProperty.Value");
|
||||
}
|
||||
|
||||
private static void AssertProperty(ClassProperty expected, ClassProperty actual)
|
||||
{
|
||||
AssertEqual(expected.PropertyType, actual.PropertyType, "ClassProperty.PropertyType");
|
||||
AssertProperties(expected.Properties, actual.Properties);
|
||||
}
|
||||
}
|
160
src/DotTiled.Tests/Assert/AssertTileset.cs
Normal file
160
src/DotTiled.Tests/Assert/AssertTileset.cs
Normal file
|
@ -0,0 +1,160 @@
|
|||
namespace DotTiled.Tests;
|
||||
|
||||
public static partial class DotTiledAssert
|
||||
{
|
||||
internal static void AssertTileset(Tileset expected, Tileset actual)
|
||||
{
|
||||
// Attributes
|
||||
AssertEqual(expected.Version, actual.Version, nameof(Tileset.Version));
|
||||
AssertEqual(expected.TiledVersion, actual.TiledVersion, nameof(Tileset.TiledVersion));
|
||||
AssertEqual(expected.FirstGID, actual.FirstGID, nameof(Tileset.FirstGID));
|
||||
AssertEqual(expected.Source, actual.Source, nameof(Tileset.Source));
|
||||
AssertEqual(expected.Name, actual.Name, nameof(Tileset.Name));
|
||||
AssertEqual(expected.Class, actual.Class, nameof(Tileset.Class));
|
||||
AssertEqual(expected.TileWidth, actual.TileWidth, nameof(Tileset.TileWidth));
|
||||
AssertEqual(expected.TileHeight, actual.TileHeight, nameof(Tileset.TileHeight));
|
||||
AssertEqual(expected.Spacing, actual.Spacing, nameof(Tileset.Spacing));
|
||||
AssertEqual(expected.Margin, actual.Margin, nameof(Tileset.Margin));
|
||||
AssertEqual(expected.TileCount, actual.TileCount, nameof(Tileset.TileCount));
|
||||
AssertEqual(expected.Columns, actual.Columns, nameof(Tileset.Columns));
|
||||
AssertEqual(expected.ObjectAlignment, actual.ObjectAlignment, nameof(Tileset.ObjectAlignment));
|
||||
AssertEqual(expected.RenderSize, actual.RenderSize, nameof(Tileset.RenderSize));
|
||||
AssertEqual(expected.FillMode, actual.FillMode, nameof(Tileset.FillMode));
|
||||
|
||||
// At most one of
|
||||
AssertImage(expected.Image, actual.Image);
|
||||
AssertTileOffset(expected.TileOffset, actual.TileOffset);
|
||||
AssertGrid(expected.Grid, actual.Grid);
|
||||
AssertProperties(expected.Properties, actual.Properties);
|
||||
// TODO: AssertTerrainTypes(actual.TerrainTypes, expected.TerrainTypes);
|
||||
if (expected.Wangsets is not null)
|
||||
{
|
||||
Assert.NotNull(actual.Wangsets);
|
||||
AssertEqual(expected.Wangsets.Count, actual.Wangsets.Count, "Wangsets.Count");
|
||||
for (var i = 0; i < expected.Wangsets.Count; i++)
|
||||
AssertWangset(expected.Wangsets[i], actual.Wangsets[i]);
|
||||
}
|
||||
AssertTransformations(expected.Transformations, actual.Transformations);
|
||||
|
||||
// Any number of
|
||||
Assert.NotNull(actual.Tiles);
|
||||
AssertEqual(expected.Tiles.Count, actual.Tiles.Count, "Tiles.Count");
|
||||
for (var i = 0; i < expected.Tiles.Count; i++)
|
||||
AssertTile(expected.Tiles[i], actual.Tiles[i]);
|
||||
}
|
||||
|
||||
private static void AssertTileOffset(TileOffset? expected, TileOffset? actual)
|
||||
{
|
||||
if (expected is null)
|
||||
{
|
||||
Assert.Null(actual);
|
||||
return;
|
||||
}
|
||||
|
||||
// Attributes
|
||||
Assert.NotNull(actual);
|
||||
AssertEqual(expected.X, actual.X, nameof(TileOffset.X));
|
||||
AssertEqual(expected.Y, actual.Y, nameof(TileOffset.Y));
|
||||
}
|
||||
|
||||
private static void AssertGrid(Grid? expected, Grid? actual)
|
||||
{
|
||||
if (expected is null)
|
||||
{
|
||||
Assert.Null(actual);
|
||||
return;
|
||||
}
|
||||
|
||||
// Attributes
|
||||
Assert.NotNull(actual);
|
||||
AssertEqual(expected.Orientation, actual.Orientation, nameof(Grid.Orientation));
|
||||
AssertEqual(expected.Width, actual.Width, nameof(Grid.Width));
|
||||
AssertEqual(expected.Height, actual.Height, nameof(Grid.Height));
|
||||
}
|
||||
|
||||
private static void AssertWangset(Wangset expected, Wangset actual)
|
||||
{
|
||||
// Attributes
|
||||
AssertEqual(expected.Name, actual.Name, nameof(Wangset.Name));
|
||||
AssertEqual(expected.Class, actual.Class, nameof(Wangset.Class));
|
||||
AssertEqual(expected.Tile, actual.Tile, nameof(Wangset.Tile));
|
||||
|
||||
// At most one of
|
||||
AssertProperties(expected.Properties, actual.Properties);
|
||||
if (expected.WangColors is not null)
|
||||
{
|
||||
Assert.NotNull(actual.WangColors);
|
||||
AssertEqual(expected.WangColors.Count, actual.WangColors.Count, "WangColors.Count");
|
||||
for (var i = 0; i < expected.WangColors.Count; i++)
|
||||
AssertWangColor(expected.WangColors[i], actual.WangColors[i]);
|
||||
}
|
||||
for (var i = 0; i < expected.WangTiles.Count; i++)
|
||||
AssertWangTile(expected.WangTiles[i], actual.WangTiles[i]);
|
||||
}
|
||||
|
||||
private static void AssertWangColor(WangColor expected, WangColor actual)
|
||||
{
|
||||
// Attributes
|
||||
AssertEqual(expected.Name, actual.Name, nameof(WangColor.Name));
|
||||
AssertEqual(expected.Class, actual.Class, nameof(WangColor.Class));
|
||||
AssertEqual(expected.Color, actual.Color, nameof(WangColor.Color));
|
||||
AssertEqual(expected.Tile, actual.Tile, nameof(WangColor.Tile));
|
||||
AssertEqual(expected.Probability, actual.Probability, nameof(WangColor.Probability));
|
||||
|
||||
AssertProperties(expected.Properties, actual.Properties);
|
||||
}
|
||||
|
||||
private static void AssertWangTile(WangTile expected, WangTile actual)
|
||||
{
|
||||
// Attributes
|
||||
AssertEqual(expected.TileID, actual.TileID, nameof(WangTile.TileID));
|
||||
AssertEqual(expected.WangID, actual.WangID, nameof(WangTile.WangID));
|
||||
}
|
||||
|
||||
private static void AssertTransformations(Transformations? expected, Transformations? actual)
|
||||
{
|
||||
if (expected is null)
|
||||
{
|
||||
Assert.Null(actual);
|
||||
return;
|
||||
}
|
||||
|
||||
// Attributes
|
||||
Assert.NotNull(actual);
|
||||
AssertEqual(expected.HFlip, actual.HFlip, nameof(Transformations.HFlip));
|
||||
AssertEqual(expected.VFlip, actual.VFlip, nameof(Transformations.VFlip));
|
||||
AssertEqual(expected.Rotate, actual.Rotate, nameof(Transformations.Rotate));
|
||||
AssertEqual(expected.PreferUntransformed, actual.PreferUntransformed, nameof(Transformations.PreferUntransformed));
|
||||
}
|
||||
|
||||
private static void AssertTile(Tile expected, Tile actual)
|
||||
{
|
||||
// Attributes
|
||||
AssertEqual(expected.ID, actual.ID, nameof(Tile.ID));
|
||||
AssertEqual(expected.Type, actual.Type, nameof(Tile.Type));
|
||||
AssertEqual(expected.Probability, actual.Probability, nameof(Tile.Probability));
|
||||
AssertEqual(expected.X, actual.X, nameof(Tile.X));
|
||||
AssertEqual(expected.Y, actual.Y, nameof(Tile.Y));
|
||||
AssertEqual(expected.Width, actual.Width, nameof(Tile.Width));
|
||||
AssertEqual(expected.Height, actual.Height, nameof(Tile.Height));
|
||||
|
||||
// Elements
|
||||
AssertProperties(actual.Properties, expected.Properties);
|
||||
AssertImage(actual.Image, expected.Image);
|
||||
AssertLayer((BaseLayer?)actual.ObjectLayer, (BaseLayer?)expected.ObjectLayer);
|
||||
if (expected.Animation is not null)
|
||||
{
|
||||
Assert.NotNull(actual.Animation);
|
||||
AssertEqual(expected.Animation.Count, actual.Animation.Count, "Animation.Count");
|
||||
for (var i = 0; i < expected.Animation.Count; i++)
|
||||
AssertFrame(expected.Animation[i], actual.Animation[i]);
|
||||
}
|
||||
}
|
||||
|
||||
private static void AssertFrame(Frame expected, Frame actual)
|
||||
{
|
||||
// Attributes
|
||||
AssertEqual(expected.TileID, actual.TileID, nameof(Frame.TileID));
|
||||
AssertEqual(expected.Duration, actual.Duration, nameof(Frame.Duration));
|
||||
}
|
||||
}
|
32
src/DotTiled.Tests/DotTiled.Tests.csproj
Normal file
32
src/DotTiled.Tests/DotTiled.Tests.csproj
Normal file
|
@ -0,0 +1,32 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
<IsTestProject>true</IsTestProject>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="coverlet.collector" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
|
||||
<PackageReference Include="xunit" Version="2.5.3" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\DotTiled\DotTiled.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Using Include="Xunit" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<!-- Test data -->
|
||||
<EmbeddedResource Include="Serialization/TestData/**/*" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
79
src/DotTiled.Tests/Serialization/TestData.cs
Normal file
79
src/DotTiled.Tests/Serialization/TestData.cs
Normal file
|
@ -0,0 +1,79 @@
|
|||
using System.Xml;
|
||||
|
||||
namespace DotTiled.Tests;
|
||||
|
||||
public static partial class TestData
|
||||
{
|
||||
public static XmlReader GetXmlReaderFor(string testDataFile)
|
||||
{
|
||||
var fullyQualifiedTestDataFile = $"DotTiled.Tests.{ConvertPathToAssemblyResourcePath(testDataFile)}";
|
||||
using var stream = typeof(TestData).Assembly.GetManifestResourceStream(fullyQualifiedTestDataFile)
|
||||
?? throw new ArgumentException($"Test data file '{fullyQualifiedTestDataFile}' not found");
|
||||
|
||||
using var stringReader = new StreamReader(stream);
|
||||
var xml = stringReader.ReadToEnd();
|
||||
var xmlStringReader = new StringReader(xml);
|
||||
return XmlReader.Create(xmlStringReader);
|
||||
}
|
||||
|
||||
public static string GetRawStringFor(string testDataFile)
|
||||
{
|
||||
var fullyQualifiedTestDataFile = $"DotTiled.Tests.{ConvertPathToAssemblyResourcePath(testDataFile)}";
|
||||
using var stream = typeof(TestData).Assembly.GetManifestResourceStream(fullyQualifiedTestDataFile)
|
||||
?? throw new ArgumentException($"Test data file '{fullyQualifiedTestDataFile}' not found");
|
||||
|
||||
using var stringReader = new StreamReader(stream);
|
||||
return stringReader.ReadToEnd();
|
||||
}
|
||||
|
||||
private static string ConvertPathToAssemblyResourcePath(string path) =>
|
||||
path.Replace("/", ".").Replace("\\", ".").Replace(" ", "_");
|
||||
|
||||
public static IEnumerable<object[]> MapTests =>
|
||||
[
|
||||
["Serialization/TestData/Map/default_map/default-map", (string f) => TestData.DefaultMap(), Array.Empty<CustomTypeDefinition>()],
|
||||
["Serialization/TestData/Map/map_with_common_props/map-with-common-props", (string f) => TestData.MapWithCommonProps(), Array.Empty<CustomTypeDefinition>()],
|
||||
["Serialization/TestData/Map/map_with_custom_type_props/map-with-custom-type-props", (string f) => TestData.MapWithCustomTypeProps(), TestData.MapWithCustomTypePropsCustomTypeDefinitions()],
|
||||
["Serialization/TestData/Map/map_with_embedded_tileset/map-with-embedded-tileset", (string f) => TestData.MapWithEmbeddedTileset(), Array.Empty<CustomTypeDefinition>()],
|
||||
["Serialization/TestData/Map/map_with_external_tileset/map-with-external-tileset", (string f) => TestData.MapWithExternalTileset(f), Array.Empty<CustomTypeDefinition>()],
|
||||
["Serialization/TestData/Map/map_with_flippingflags/map-with-flippingflags", (string f) => TestData.MapWithFlippingFlags(f), Array.Empty<CustomTypeDefinition>()],
|
||||
["Serialization/TestData/Map/map_external_tileset_multi/map-external-tileset-multi", (string f) => TestData.MapExternalTilesetMulti(f), Array.Empty<CustomTypeDefinition>()],
|
||||
["Serialization/TestData/Map/map_external_tileset_wangset/map-external-tileset-wangset", (string f) => TestData.MapExternalTilesetWangset(f), Array.Empty<CustomTypeDefinition>()],
|
||||
["Serialization/TestData/Map/map_with_many_layers/map-with-many-layers", (string f) => TestData.MapWithManyLayers(f), Array.Empty<CustomTypeDefinition>()],
|
||||
];
|
||||
|
||||
private static CustomTypeDefinition[] typedefs = [
|
||||
new CustomClassDefinition
|
||||
{
|
||||
Name = "TestClass",
|
||||
ID = 1,
|
||||
UseAs = CustomClassUseAs.Property,
|
||||
Members = [
|
||||
new StringProperty
|
||||
{
|
||||
Name = "Name",
|
||||
Value = ""
|
||||
},
|
||||
new FloatProperty
|
||||
{
|
||||
Name = "Amount",
|
||||
Value = 0f
|
||||
}
|
||||
]
|
||||
},
|
||||
new CustomClassDefinition
|
||||
{
|
||||
Name = "Test",
|
||||
ID = 2,
|
||||
UseAs = CustomClassUseAs.All,
|
||||
Members = [
|
||||
new ClassProperty
|
||||
{
|
||||
Name = "Yep",
|
||||
PropertyType = "TestClass",
|
||||
Properties = []
|
||||
}
|
||||
]
|
||||
}
|
||||
];
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
namespace DotTiled.Tests;
|
||||
|
||||
public partial class TestData
|
||||
{
|
||||
public static Map DefaultMap() => new Map
|
||||
{
|
||||
Class = "",
|
||||
Orientation = MapOrientation.Orthogonal,
|
||||
Width = 5,
|
||||
Height = 5,
|
||||
TileWidth = 32,
|
||||
TileHeight = 32,
|
||||
Infinite = false,
|
||||
HexSideLength = null,
|
||||
StaggerAxis = null,
|
||||
StaggerIndex = null,
|
||||
ParallaxOriginX = 0,
|
||||
ParallaxOriginY = 0,
|
||||
RenderOrder = RenderOrder.RightDown,
|
||||
CompressionLevel = -1,
|
||||
BackgroundColor = new Color { R = 0, G = 0, B = 0, A = 0 },
|
||||
Version = "1.10",
|
||||
TiledVersion = "1.11.0",
|
||||
NextLayerID = 2,
|
||||
NextObjectID = 1,
|
||||
Layers = [
|
||||
new TileLayer
|
||||
{
|
||||
ID = 1,
|
||||
Name = "Tile Layer 1",
|
||||
Width = 5,
|
||||
Height = 5,
|
||||
Data = new Data
|
||||
{
|
||||
Encoding = DataEncoding.Csv,
|
||||
Chunks = null,
|
||||
Compression = null,
|
||||
GlobalTileIDs = [
|
||||
0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0
|
||||
],
|
||||
FlippingFlags = [
|
||||
FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None,
|
||||
FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None,
|
||||
FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None,
|
||||
FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None,
|
||||
FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
{ "compressionlevel":-1,
|
||||
"height":5,
|
||||
"infinite":false,
|
||||
"layers":[
|
||||
{
|
||||
"data":[0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0],
|
||||
"height":5,
|
||||
"id":1,
|
||||
"name":"Tile Layer 1",
|
||||
"opacity":1,
|
||||
"type":"tilelayer",
|
||||
"visible":true,
|
||||
"width":5,
|
||||
"x":0,
|
||||
"y":0
|
||||
}],
|
||||
"nextlayerid":2,
|
||||
"nextobjectid":1,
|
||||
"orientation":"orthogonal",
|
||||
"renderorder":"right-down",
|
||||
"tiledversion":"1.11.0",
|
||||
"tileheight":32,
|
||||
"tilesets":[],
|
||||
"tilewidth":32,
|
||||
"type":"map",
|
||||
"version":"1.10",
|
||||
"width":5
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<map version="1.10" tiledversion="1.11.0" orientation="orthogonal" renderorder="right-down" width="5" height="5" tilewidth="32" tileheight="32" infinite="0" nextlayerid="2" nextobjectid="1">
|
||||
<layer id="1" name="Tile Layer 1" width="5" height="5">
|
||||
<data encoding="csv">
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0
|
||||
</data>
|
||||
</layer>
|
||||
</map>
|
|
@ -0,0 +1,121 @@
|
|||
using System.Globalization;
|
||||
|
||||
namespace DotTiled.Tests;
|
||||
|
||||
public partial class TestData
|
||||
{
|
||||
public static Map MapExternalTilesetMulti(string fileExt) => new Map
|
||||
{
|
||||
Class = "",
|
||||
Orientation = MapOrientation.Orthogonal,
|
||||
Width = 5,
|
||||
Height = 5,
|
||||
TileWidth = 32,
|
||||
TileHeight = 32,
|
||||
Infinite = false,
|
||||
HexSideLength = null,
|
||||
StaggerAxis = null,
|
||||
StaggerIndex = null,
|
||||
ParallaxOriginX = 0,
|
||||
ParallaxOriginY = 0,
|
||||
RenderOrder = RenderOrder.RightDown,
|
||||
CompressionLevel = -1,
|
||||
BackgroundColor = Color.Parse("#00000000", CultureInfo.InvariantCulture),
|
||||
Version = "1.10",
|
||||
TiledVersion = "1.11.0",
|
||||
NextLayerID = 2,
|
||||
NextObjectID = 1,
|
||||
Tilesets = [
|
||||
new Tileset
|
||||
{
|
||||
TileOffset = new TileOffset
|
||||
{
|
||||
X = 1,
|
||||
Y = 5
|
||||
},
|
||||
Version = "1.10",
|
||||
TiledVersion = "1.11.0",
|
||||
FirstGID = 1,
|
||||
Name = "multi-tileset",
|
||||
TileWidth = 256,
|
||||
TileHeight = 96,
|
||||
TileCount = 2,
|
||||
Columns = 0,
|
||||
Source = $"multi-tileset.{(fileExt == "tmx" ? "tsx" : "tsj")}",
|
||||
Grid = new Grid
|
||||
{
|
||||
Orientation = GridOrientation.Orthogonal,
|
||||
Width = 1,
|
||||
Height = 1
|
||||
},
|
||||
Properties = new Dictionary<string, IProperty>
|
||||
{
|
||||
["tilesetbool"] = new BoolProperty { Name = "tilesetbool", Value = true },
|
||||
["tilesetcolor"] = new ColorProperty { Name = "tilesetcolor", Value = Color.Parse("#ffff0000", CultureInfo.InvariantCulture) },
|
||||
["tilesetfile"] = new FileProperty { Name = "tilesetfile", Value = "" },
|
||||
["tilesetfloat"] = new FloatProperty { Name = "tilesetfloat", Value = 5.2f },
|
||||
["tilesetint"] = new IntProperty { Name = "tilesetint", Value = 9 },
|
||||
["tilesetobject"] = new ObjectProperty { Name = "tilesetobject", Value = 0 },
|
||||
["tilesetstring"] = new StringProperty { Name = "tilesetstring", Value = "hello world!" }
|
||||
},
|
||||
Tiles = [
|
||||
new Tile
|
||||
{
|
||||
ID = 0,
|
||||
Width = 256,
|
||||
Height = 96,
|
||||
Image = new Image
|
||||
{
|
||||
Format = ImageFormat.Png,
|
||||
Source = "tileset.png",
|
||||
Width = 256,
|
||||
Height = 96
|
||||
}
|
||||
},
|
||||
new Tile
|
||||
{
|
||||
ID = 1,
|
||||
Width = 256,
|
||||
Height = 96,
|
||||
Image = new Image
|
||||
{
|
||||
Format = ImageFormat.Png,
|
||||
Source = "tileset.png",
|
||||
Width = 256,
|
||||
Height = 96
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
Layers = [
|
||||
new TileLayer
|
||||
{
|
||||
ID = 1,
|
||||
Name = "Tile Layer 1",
|
||||
Width = 5,
|
||||
Height = 5,
|
||||
Data = new Data
|
||||
{
|
||||
Encoding = DataEncoding.Csv,
|
||||
Chunks = null,
|
||||
Compression = null,
|
||||
GlobalTileIDs = [
|
||||
0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0,
|
||||
1, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0,
|
||||
0, 2, 0, 0, 0
|
||||
],
|
||||
FlippingFlags = [
|
||||
FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None,
|
||||
FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None,
|
||||
FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None,
|
||||
FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None,
|
||||
FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
{ "compressionlevel":-1,
|
||||
"height":5,
|
||||
"infinite":false,
|
||||
"layers":[
|
||||
{
|
||||
"data":[0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0,
|
||||
1, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0,
|
||||
0, 2, 0, 0, 0],
|
||||
"height":5,
|
||||
"id":1,
|
||||
"name":"Tile Layer 1",
|
||||
"opacity":1,
|
||||
"type":"tilelayer",
|
||||
"visible":true,
|
||||
"width":5,
|
||||
"x":0,
|
||||
"y":0
|
||||
}],
|
||||
"nextlayerid":2,
|
||||
"nextobjectid":1,
|
||||
"orientation":"orthogonal",
|
||||
"renderorder":"right-down",
|
||||
"tiledversion":"1.11.0",
|
||||
"tileheight":32,
|
||||
"tilesets":[
|
||||
{
|
||||
"firstgid":1,
|
||||
"source":"multi-tileset.tsj"
|
||||
}],
|
||||
"tilewidth":32,
|
||||
"type":"map",
|
||||
"version":"1.10",
|
||||
"width":5
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<map version="1.10" tiledversion="1.11.0" orientation="orthogonal" renderorder="right-down" width="5" height="5" tilewidth="32" tileheight="32" infinite="0" nextlayerid="2" nextobjectid="1">
|
||||
<tileset firstgid="1" source="multi-tileset.tsx"/>
|
||||
<layer id="1" name="Tile Layer 1" width="5" height="5">
|
||||
<data encoding="csv">
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0,
|
||||
1,0,0,0,0,
|
||||
0,0,0,0,0,
|
||||
0,2,0,0,0
|
||||
</data>
|
||||
</layer>
|
||||
</map>
|
|
@ -0,0 +1,71 @@
|
|||
{ "columns":0,
|
||||
"grid":
|
||||
{
|
||||
"height":1,
|
||||
"orientation":"orthogonal",
|
||||
"width":1
|
||||
},
|
||||
"margin":0,
|
||||
"name":"multi-tileset",
|
||||
"properties":[
|
||||
{
|
||||
"name":"tilesetbool",
|
||||
"type":"bool",
|
||||
"value":true
|
||||
},
|
||||
{
|
||||
"name":"tilesetcolor",
|
||||
"type":"color",
|
||||
"value":"#ffff0000"
|
||||
},
|
||||
{
|
||||
"name":"tilesetfile",
|
||||
"type":"file",
|
||||
"value":""
|
||||
},
|
||||
{
|
||||
"name":"tilesetfloat",
|
||||
"type":"float",
|
||||
"value":5.2
|
||||
},
|
||||
{
|
||||
"name":"tilesetint",
|
||||
"type":"int",
|
||||
"value":9
|
||||
},
|
||||
{
|
||||
"name":"tilesetobject",
|
||||
"type":"object",
|
||||
"value":0
|
||||
},
|
||||
{
|
||||
"name":"tilesetstring",
|
||||
"type":"string",
|
||||
"value":"hello world!"
|
||||
}],
|
||||
"spacing":0,
|
||||
"tilecount":2,
|
||||
"tiledversion":"1.11.0",
|
||||
"tileheight":96,
|
||||
"tileoffset":
|
||||
{
|
||||
"x":1,
|
||||
"y":5
|
||||
},
|
||||
"tiles":[
|
||||
{
|
||||
"id":0,
|
||||
"image":"tileset.png",
|
||||
"imageheight":96,
|
||||
"imagewidth":256
|
||||
},
|
||||
{
|
||||
"id":1,
|
||||
"image":"tileset.png",
|
||||
"imageheight":96,
|
||||
"imagewidth":256
|
||||
}],
|
||||
"tilewidth":256,
|
||||
"type":"tileset",
|
||||
"version":"1.10"
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<tileset version="1.10" tiledversion="1.11.0" name="multi-tileset" tilewidth="256" tileheight="96" tilecount="2" columns="0">
|
||||
<tileoffset x="1" y="5"/>
|
||||
<grid orientation="orthogonal" width="1" height="1"/>
|
||||
<properties>
|
||||
<property name="tilesetbool" type="bool" value="true"/>
|
||||
<property name="tilesetcolor" type="color" value="#ffff0000"/>
|
||||
<property name="tilesetfile" type="file" value=""/>
|
||||
<property name="tilesetfloat" type="float" value="5.2"/>
|
||||
<property name="tilesetint" type="int" value="9"/>
|
||||
<property name="tilesetobject" type="object" value="0"/>
|
||||
<property name="tilesetstring" value="hello world!"/>
|
||||
</properties>
|
||||
<tile id="0">
|
||||
<image source="tileset.png" width="256" height="96"/>
|
||||
</tile>
|
||||
<tile id="1">
|
||||
<image source="tileset.png" width="256" height="96"/>
|
||||
</tile>
|
||||
</tileset>
|
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
|
@ -0,0 +1,92 @@
|
|||
using System.Globalization;
|
||||
|
||||
namespace DotTiled.Tests;
|
||||
|
||||
public partial class TestData
|
||||
{
|
||||
public static Map MapExternalTilesetWangset(string fileExt) => new Map
|
||||
{
|
||||
Class = "",
|
||||
Orientation = MapOrientation.Orthogonal,
|
||||
Width = 5,
|
||||
Height = 5,
|
||||
TileWidth = 24,
|
||||
TileHeight = 24,
|
||||
Infinite = false,
|
||||
HexSideLength = null,
|
||||
StaggerAxis = null,
|
||||
StaggerIndex = null,
|
||||
ParallaxOriginX = 0,
|
||||
ParallaxOriginY = 0,
|
||||
RenderOrder = RenderOrder.RightDown,
|
||||
CompressionLevel = -1,
|
||||
BackgroundColor = Color.Parse("#00000000", CultureInfo.InvariantCulture),
|
||||
Version = "1.10",
|
||||
TiledVersion = "1.11.0",
|
||||
NextLayerID = 2,
|
||||
NextObjectID = 1,
|
||||
Tilesets = [
|
||||
new Tileset
|
||||
{
|
||||
Version = "1.10",
|
||||
TiledVersion = "1.11.0",
|
||||
FirstGID = 1,
|
||||
Name = "tileset",
|
||||
TileWidth = 24,
|
||||
TileHeight = 24,
|
||||
TileCount = 48,
|
||||
Columns = 10,
|
||||
Source = $"wangset-tileset.{(fileExt == "tmx" ? "tsx" : "tsj")}",
|
||||
Transformations = new Transformations
|
||||
{
|
||||
HFlip = true,
|
||||
VFlip = true,
|
||||
Rotate = false,
|
||||
PreferUntransformed = false
|
||||
},
|
||||
Grid = new Grid
|
||||
{
|
||||
Orientation = GridOrientation.Orthogonal,
|
||||
Width = 32,
|
||||
Height = 32
|
||||
},
|
||||
Image = new Image
|
||||
{
|
||||
Format = ImageFormat.Png,
|
||||
Source = "tileset.png",
|
||||
Width = 256,
|
||||
Height = 96,
|
||||
}
|
||||
}
|
||||
],
|
||||
Layers = [
|
||||
new TileLayer
|
||||
{
|
||||
ID = 1,
|
||||
Name = "Tile Layer 1",
|
||||
Width = 5,
|
||||
Height = 5,
|
||||
Data = new Data
|
||||
{
|
||||
Encoding = DataEncoding.Csv,
|
||||
Chunks = null,
|
||||
Compression = null,
|
||||
GlobalTileIDs = [
|
||||
2, 2, 12, 11, 0,
|
||||
1, 12, 1, 11, 0,
|
||||
2, 1, 0, 1, 0,
|
||||
12, 11, 12, 2, 0,
|
||||
0, 0, 0, 0, 0
|
||||
],
|
||||
FlippingFlags = [
|
||||
FlippingFlags.FlippedHorizontally, FlippingFlags.None, FlippingFlags.FlippedHorizontally, FlippingFlags.FlippedHorizontally, FlippingFlags.None,
|
||||
FlippingFlags.FlippedVertically, FlippingFlags.None, FlippingFlags.None, FlippingFlags.FlippedVertically | FlippingFlags.FlippedHorizontally, FlippingFlags.None,
|
||||
FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.FlippedVertically | FlippingFlags.FlippedHorizontally, FlippingFlags.None,
|
||||
FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.FlippedHorizontally, FlippingFlags.None,
|
||||
FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
{ "compressionlevel":-1,
|
||||
"height":5,
|
||||
"infinite":false,
|
||||
"layers":[
|
||||
{
|
||||
"data":[2147483650, 2, 2147483660, 2147483659, 0,
|
||||
1073741825, 12, 1, 3221225483, 0,
|
||||
2, 1, 0, 3221225473, 0,
|
||||
12, 11, 12, 2147483650, 0,
|
||||
0, 0, 0, 0, 0],
|
||||
"height":5,
|
||||
"id":1,
|
||||
"name":"Tile Layer 1",
|
||||
"opacity":1,
|
||||
"type":"tilelayer",
|
||||
"visible":true,
|
||||
"width":5,
|
||||
"x":0,
|
||||
"y":0
|
||||
}],
|
||||
"nextlayerid":2,
|
||||
"nextobjectid":1,
|
||||
"orientation":"orthogonal",
|
||||
"renderorder":"right-down",
|
||||
"tiledversion":"1.11.0",
|
||||
"tileheight":24,
|
||||
"tilesets":[
|
||||
{
|
||||
"firstgid":1,
|
||||
"source":"wangset-tileset.tsj"
|
||||
}],
|
||||
"tilewidth":24,
|
||||
"type":"map",
|
||||
"version":"1.10",
|
||||
"width":5
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<map version="1.10" tiledversion="1.11.0" orientation="orthogonal" renderorder="right-down" width="5" height="5" tilewidth="24" tileheight="24" infinite="0" nextlayerid="2" nextobjectid="1">
|
||||
<tileset firstgid="1" source="wangset-tileset.tsx"/>
|
||||
<layer id="1" name="Tile Layer 1" width="5" height="5">
|
||||
<data encoding="csv">
|
||||
2147483650,2,2147483660,2147483659,0,
|
||||
1073741825,12,1,3221225483,0,
|
||||
2,1,0,3221225473,0,
|
||||
12,11,12,2147483650,0,
|
||||
0,0,0,0,0
|
||||
</data>
|
||||
</layer>
|
||||
</map>
|
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
|
@ -0,0 +1,69 @@
|
|||
{ "columns":10,
|
||||
"grid":
|
||||
{
|
||||
"height":32,
|
||||
"orientation":"orthogonal",
|
||||
"width":32
|
||||
},
|
||||
"image":"tileset.png",
|
||||
"imageheight":96,
|
||||
"imagewidth":256,
|
||||
"margin":0,
|
||||
"name":"tileset",
|
||||
"spacing":0,
|
||||
"tilecount":48,
|
||||
"tiledversion":"1.11.0",
|
||||
"tileheight":24,
|
||||
"tilewidth":24,
|
||||
"transformations":
|
||||
{
|
||||
"hflip":true,
|
||||
"preferuntransformed":false,
|
||||
"rotate":false,
|
||||
"vflip":true
|
||||
},
|
||||
"type":"tileset",
|
||||
"version":"1.10",
|
||||
"wangsets":[
|
||||
{
|
||||
"colors":[
|
||||
{
|
||||
"color":"#ff0000",
|
||||
"name":"Water",
|
||||
"probability":1,
|
||||
"tile":0
|
||||
},
|
||||
{
|
||||
"color":"#00ff00",
|
||||
"name":"Grass",
|
||||
"probability":1,
|
||||
"tile":-1
|
||||
},
|
||||
{
|
||||
"color":"#0000ff",
|
||||
"name":"Stone",
|
||||
"probability":1,
|
||||
"tile":29
|
||||
}],
|
||||
"name":"test-terrain",
|
||||
"tile":-1,
|
||||
"type":"mixed",
|
||||
"wangtiles":[
|
||||
{
|
||||
"tileid":0,
|
||||
"wangid":[1, 1, 0, 0, 0, 1, 1, 1]
|
||||
},
|
||||
{
|
||||
"tileid":1,
|
||||
"wangid":[1, 1, 1, 1, 0, 0, 0, 1]
|
||||
},
|
||||
{
|
||||
"tileid":10,
|
||||
"wangid":[0, 0, 0, 1, 1, 1, 1, 1]
|
||||
},
|
||||
{
|
||||
"tileid":11,
|
||||
"wangid":[0, 1, 1, 1, 1, 1, 0, 0]
|
||||
}]
|
||||
}]
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<tileset version="1.10" tiledversion="1.11.0" name="tileset" tilewidth="24" tileheight="24" tilecount="48" columns="10">
|
||||
<grid orientation="orthogonal" width="32" height="32"/>
|
||||
<transformations hflip="1" vflip="1" rotate="0" preferuntransformed="0"/>
|
||||
<image source="tileset.png" width="256" height="96"/>
|
||||
<wangsets>
|
||||
<wangset name="test-terrain" type="mixed" tile="-1">
|
||||
<wangcolor name="Water" color="#ff0000" tile="0" probability="1"/>
|
||||
<wangcolor name="Grass" color="#00ff00" tile="-1" probability="1"/>
|
||||
<wangcolor name="Stone" color="#0000ff" tile="29" probability="1"/>
|
||||
<wangtile tileid="0" wangid="1,1,0,0,0,1,1,1"/>
|
||||
<wangtile tileid="1" wangid="1,1,1,1,0,0,0,1"/>
|
||||
<wangtile tileid="10" wangid="0,0,0,1,1,1,1,1"/>
|
||||
<wangtile tileid="11" wangid="0,1,1,1,1,1,0,0"/>
|
||||
</wangset>
|
||||
</wangsets>
|
||||
</tileset>
|
|
@ -0,0 +1,68 @@
|
|||
using System.Globalization;
|
||||
|
||||
namespace DotTiled.Tests;
|
||||
|
||||
public partial class TestData
|
||||
{
|
||||
public static Map MapWithCommonProps() => new Map
|
||||
{
|
||||
Class = "",
|
||||
Orientation = MapOrientation.Isometric,
|
||||
Width = 5,
|
||||
Height = 5,
|
||||
TileWidth = 32,
|
||||
TileHeight = 16,
|
||||
Infinite = false,
|
||||
HexSideLength = null,
|
||||
StaggerAxis = null,
|
||||
StaggerIndex = null,
|
||||
ParallaxOriginX = 0,
|
||||
ParallaxOriginY = 0,
|
||||
RenderOrder = RenderOrder.RightDown,
|
||||
CompressionLevel = -1,
|
||||
BackgroundColor = Color.Parse("#00ff00", CultureInfo.InvariantCulture),
|
||||
Version = "1.10",
|
||||
TiledVersion = "1.11.0",
|
||||
NextLayerID = 2,
|
||||
NextObjectID = 1,
|
||||
Layers = [
|
||||
new TileLayer
|
||||
{
|
||||
ID = 1,
|
||||
Name = "Tile Layer 1",
|
||||
Width = 5,
|
||||
Height = 5,
|
||||
Data = new Data
|
||||
{
|
||||
Encoding = DataEncoding.Csv,
|
||||
Chunks = null,
|
||||
Compression = null,
|
||||
GlobalTileIDs = [
|
||||
0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0
|
||||
],
|
||||
FlippingFlags = [
|
||||
FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None,
|
||||
FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None,
|
||||
FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None,
|
||||
FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None,
|
||||
FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
Properties = new Dictionary<string, IProperty>
|
||||
{
|
||||
["boolprop"] = new BoolProperty { Name = "boolprop", Value = true },
|
||||
["colorprop"] = new ColorProperty { Name = "colorprop", Value = Color.Parse("#ff55ffff", CultureInfo.InvariantCulture) },
|
||||
["fileprop"] = new FileProperty { Name = "fileprop", Value = "file.txt" },
|
||||
["floatprop"] = new FloatProperty { Name = "floatprop", Value = 4.2f },
|
||||
["intprop"] = new IntProperty { Name = "intprop", Value = 8 },
|
||||
["objectprop"] = new ObjectProperty { Name = "objectprop", Value = 5 },
|
||||
["stringprop"] = new StringProperty { Name = "stringprop", Value = "This is a string, hello world!" }
|
||||
}
|
||||
};
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
{ "backgroundcolor":"#00ff00",
|
||||
"compressionlevel":-1,
|
||||
"height":5,
|
||||
"infinite":false,
|
||||
"layers":[
|
||||
{
|
||||
"data":[0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0],
|
||||
"height":5,
|
||||
"id":1,
|
||||
"name":"Tile Layer 1",
|
||||
"opacity":1,
|
||||
"type":"tilelayer",
|
||||
"visible":true,
|
||||
"width":5,
|
||||
"x":0,
|
||||
"y":0
|
||||
}],
|
||||
"nextlayerid":2,
|
||||
"nextobjectid":1,
|
||||
"orientation":"isometric",
|
||||
"properties":[
|
||||
{
|
||||
"name":"boolprop",
|
||||
"type":"bool",
|
||||
"value":true
|
||||
},
|
||||
{
|
||||
"name":"colorprop",
|
||||
"type":"color",
|
||||
"value":"#ff55ffff"
|
||||
},
|
||||
{
|
||||
"name":"fileprop",
|
||||
"type":"file",
|
||||
"value":"file.txt"
|
||||
},
|
||||
{
|
||||
"name":"floatprop",
|
||||
"type":"float",
|
||||
"value":4.2
|
||||
},
|
||||
{
|
||||
"name":"intprop",
|
||||
"type":"int",
|
||||
"value":8
|
||||
},
|
||||
|
||||
{
|
||||
"name":"objectprop",
|
||||
"type":"object",
|
||||
"value":5
|
||||
},
|
||||
{
|
||||
"name":"stringprop",
|
||||
"type":"string",
|
||||
"value":"This is a string, hello world!"
|
||||
}],
|
||||
"renderorder":"right-down",
|
||||
"tiledversion":"1.11.0",
|
||||
"tileheight":16,
|
||||
"tilesets":[],
|
||||
"tilewidth":32,
|
||||
"type":"map",
|
||||
"version":"1.10",
|
||||
"width":5
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<map version="1.10" tiledversion="1.11.0" orientation="isometric" renderorder="right-down" width="5" height="5" tilewidth="32" tileheight="16" infinite="0" backgroundcolor="#00ff00" nextlayerid="2" nextobjectid="1">
|
||||
<properties>
|
||||
<property name="boolprop" type="bool" value="true"/>
|
||||
<property name="colorprop" type="color" value="#ff55ffff"/>
|
||||
<property name="fileprop" type="file" value="file.txt"/>
|
||||
<property name="floatprop" type="float" value="4.2"/>
|
||||
<property name="intprop" type="int" value="8"/>
|
||||
<property name="objectprop" type="object" value="5"/>
|
||||
<property name="stringprop" value="This is a string, hello world!"/>
|
||||
</properties>
|
||||
<layer id="1" name="Tile Layer 1" width="5" height="5">
|
||||
<data encoding="csv">
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0
|
||||
</data>
|
||||
</layer>
|
||||
</map>
|
|
@ -0,0 +1,122 @@
|
|||
using System.Globalization;
|
||||
|
||||
namespace DotTiled.Tests;
|
||||
|
||||
public partial class TestData
|
||||
{
|
||||
public static Map MapWithCustomTypeProps() => new Map
|
||||
{
|
||||
Class = "",
|
||||
Orientation = MapOrientation.Orthogonal,
|
||||
Width = 5,
|
||||
Height = 5,
|
||||
TileWidth = 32,
|
||||
TileHeight = 32,
|
||||
Infinite = false,
|
||||
HexSideLength = null,
|
||||
StaggerAxis = null,
|
||||
StaggerIndex = null,
|
||||
ParallaxOriginX = 0,
|
||||
ParallaxOriginY = 0,
|
||||
RenderOrder = RenderOrder.RightDown,
|
||||
CompressionLevel = -1,
|
||||
BackgroundColor = Color.Parse("#00000000", CultureInfo.InvariantCulture),
|
||||
Version = "1.10",
|
||||
TiledVersion = "1.11.0",
|
||||
NextLayerID = 2,
|
||||
NextObjectID = 1,
|
||||
Layers = [
|
||||
new TileLayer
|
||||
{
|
||||
ID = 1,
|
||||
Name = "Tile Layer 1",
|
||||
Width = 5,
|
||||
Height = 5,
|
||||
Data = new Data
|
||||
{
|
||||
Encoding = DataEncoding.Csv,
|
||||
Chunks = null,
|
||||
Compression = null,
|
||||
GlobalTileIDs = [
|
||||
0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0
|
||||
],
|
||||
FlippingFlags = [
|
||||
FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None,
|
||||
FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None,
|
||||
FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None,
|
||||
FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None,
|
||||
FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
Properties = new Dictionary<string, IProperty>
|
||||
{
|
||||
["customclassprop"] = new ClassProperty
|
||||
{
|
||||
Name = "customclassprop",
|
||||
PropertyType = "CustomClass",
|
||||
Properties = new Dictionary<string, IProperty>
|
||||
{
|
||||
["boolinclass"] = new BoolProperty { Name = "boolinclass", Value = true },
|
||||
["colorinclass"] = new ColorProperty { Name = "colorinclass", Value = Color.Parse("#000000ff", CultureInfo.InvariantCulture) },
|
||||
["fileinclass"] = new FileProperty { Name = "fileinclass", Value = "" },
|
||||
["floatinclass"] = new FloatProperty { Name = "floatinclass", Value = 13.37f },
|
||||
["intinclass"] = new IntProperty { Name = "intinclass", Value = 0 },
|
||||
["objectinclass"] = new ObjectProperty { Name = "objectinclass", Value = 0 },
|
||||
["stringinclass"] = new StringProperty { Name = "stringinclass", Value = "This is a set string" }
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// This comes from map-with-custom-type-props/propertytypes.json
|
||||
public static IReadOnlyCollection<CustomTypeDefinition> MapWithCustomTypePropsCustomTypeDefinitions() => [
|
||||
new CustomClassDefinition
|
||||
{
|
||||
Name = "CustomClass",
|
||||
UseAs = CustomClassUseAs.Property,
|
||||
Members = [
|
||||
new BoolProperty
|
||||
{
|
||||
Name = "boolinclass",
|
||||
Value = false
|
||||
},
|
||||
new ColorProperty
|
||||
{
|
||||
Name = "colorinclass",
|
||||
Value = Color.Parse("#000000ff", CultureInfo.InvariantCulture)
|
||||
},
|
||||
new FileProperty
|
||||
{
|
||||
Name = "fileinclass",
|
||||
Value = ""
|
||||
},
|
||||
new FloatProperty
|
||||
{
|
||||
Name = "floatinclass",
|
||||
Value = 0f
|
||||
},
|
||||
new IntProperty
|
||||
{
|
||||
Name = "intinclass",
|
||||
Value = 0
|
||||
},
|
||||
new ObjectProperty
|
||||
{
|
||||
Name = "objectinclass",
|
||||
Value = 0
|
||||
},
|
||||
new StringProperty
|
||||
{
|
||||
Name = "stringinclass",
|
||||
Value = ""
|
||||
}
|
||||
]
|
||||
}
|
||||
];
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
{ "compressionlevel":-1,
|
||||
"height":5,
|
||||
"infinite":false,
|
||||
"layers":[
|
||||
{
|
||||
"data":[0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0],
|
||||
"height":5,
|
||||
"id":1,
|
||||
"name":"Tile Layer 1",
|
||||
"opacity":1,
|
||||
"type":"tilelayer",
|
||||
"visible":true,
|
||||
"width":5,
|
||||
"x":0,
|
||||
"y":0
|
||||
}],
|
||||
"nextlayerid":2,
|
||||
"nextobjectid":1,
|
||||
"orientation":"orthogonal",
|
||||
"properties":[
|
||||
{
|
||||
"name":"customclassprop",
|
||||
"propertytype":"CustomClass",
|
||||
"type":"class",
|
||||
"value":
|
||||
{
|
||||
"boolinclass":true,
|
||||
"floatinclass":13.37,
|
||||
"stringinclass":"This is a set string"
|
||||
}
|
||||
}],
|
||||
"renderorder":"right-down",
|
||||
"tiledversion":"1.11.0",
|
||||
"tileheight":32,
|
||||
"tilesets":[],
|
||||
"tilewidth":32,
|
||||
"type":"map",
|
||||
"version":"1.10",
|
||||
"width":5
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<map version="1.10" tiledversion="1.11.0" orientation="orthogonal" renderorder="right-down" width="5" height="5" tilewidth="32" tileheight="32" infinite="0" nextlayerid="2" nextobjectid="1">
|
||||
<properties>
|
||||
<property name="customclassprop" type="class" propertytype="CustomClass">
|
||||
<properties>
|
||||
<property name="boolinclass" type="bool" value="true"/>
|
||||
<property name="floatinclass" type="float" value="13.37"/>
|
||||
<property name="stringinclass" value="This is a set string"/>
|
||||
</properties>
|
||||
</property>
|
||||
</properties>
|
||||
<layer id="1" name="Tile Layer 1" width="5" height="5">
|
||||
<data encoding="csv">
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0
|
||||
</data>
|
||||
</layer>
|
||||
</map>
|
|
@ -0,0 +1,49 @@
|
|||
[
|
||||
{
|
||||
"color": "#ffa0a0a4",
|
||||
"drawFill": true,
|
||||
"id": 8,
|
||||
"members": [
|
||||
{
|
||||
"name": "boolinclass",
|
||||
"type": "bool",
|
||||
"value": false
|
||||
},
|
||||
{
|
||||
"name": "colorinclass",
|
||||
"type": "color",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"name": "fileinclass",
|
||||
"type": "file",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"name": "floatinclass",
|
||||
"type": "float",
|
||||
"value": 0
|
||||
},
|
||||
{
|
||||
"name": "intinclass",
|
||||
"type": "int",
|
||||
"value": 0
|
||||
},
|
||||
{
|
||||
"name": "objectinclass",
|
||||
"type": "object",
|
||||
"value": 0
|
||||
},
|
||||
{
|
||||
"name": "stringinclass",
|
||||
"type": "string",
|
||||
"value": ""
|
||||
}
|
||||
],
|
||||
"name": "CustomClass",
|
||||
"type": "class",
|
||||
"useAs": [
|
||||
"property"
|
||||
]
|
||||
}
|
||||
]
|
|
@ -0,0 +1,76 @@
|
|||
using System.Globalization;
|
||||
|
||||
namespace DotTiled.Tests;
|
||||
|
||||
public partial class TestData
|
||||
{
|
||||
public static Map MapWithEmbeddedTileset() => new Map
|
||||
{
|
||||
Class = "",
|
||||
Orientation = MapOrientation.Orthogonal,
|
||||
Width = 5,
|
||||
Height = 5,
|
||||
TileWidth = 32,
|
||||
TileHeight = 32,
|
||||
Infinite = false,
|
||||
HexSideLength = null,
|
||||
StaggerAxis = null,
|
||||
StaggerIndex = null,
|
||||
ParallaxOriginX = 0,
|
||||
ParallaxOriginY = 0,
|
||||
RenderOrder = RenderOrder.RightDown,
|
||||
CompressionLevel = -1,
|
||||
BackgroundColor = Color.Parse("#00000000", CultureInfo.InvariantCulture),
|
||||
Version = "1.10",
|
||||
TiledVersion = "1.11.0",
|
||||
NextLayerID = 2,
|
||||
NextObjectID = 1,
|
||||
Tilesets = [
|
||||
new Tileset
|
||||
{
|
||||
FirstGID = 1,
|
||||
Name = "tileset",
|
||||
TileWidth = 32,
|
||||
TileHeight = 32,
|
||||
TileCount = 24,
|
||||
Columns = 8,
|
||||
Image = new Image
|
||||
{
|
||||
Format = ImageFormat.Png,
|
||||
Source = "tileset.png",
|
||||
Width = 256,
|
||||
Height = 96,
|
||||
}
|
||||
}
|
||||
],
|
||||
Layers = [
|
||||
new TileLayer
|
||||
{
|
||||
ID = 1,
|
||||
Name = "Tile Layer 1",
|
||||
Width = 5,
|
||||
Height = 5,
|
||||
Data = new Data
|
||||
{
|
||||
Encoding = DataEncoding.Csv,
|
||||
Chunks = null,
|
||||
Compression = null,
|
||||
GlobalTileIDs = [
|
||||
1, 1, 0, 0, 7,
|
||||
1, 1, 0, 0, 7,
|
||||
0, 0, 0, 0, 7,
|
||||
9, 10, 0, 0, 7,
|
||||
17, 18, 0, 0, 0
|
||||
],
|
||||
FlippingFlags = [
|
||||
FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None,
|
||||
FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None,
|
||||
FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None,
|
||||
FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None,
|
||||
FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
{ "compressionlevel":-1,
|
||||
"height":5,
|
||||
"infinite":false,
|
||||
"layers":[
|
||||
{
|
||||
"data":[1, 1, 0, 0, 7,
|
||||
1, 1, 0, 0, 7,
|
||||
0, 0, 0, 0, 7,
|
||||
9, 10, 0, 0, 7,
|
||||
17, 18, 0, 0, 0],
|
||||
"height":5,
|
||||
"id":1,
|
||||
"name":"Tile Layer 1",
|
||||
"opacity":1,
|
||||
"type":"tilelayer",
|
||||
"visible":true,
|
||||
"width":5,
|
||||
"x":0,
|
||||
"y":0
|
||||
}],
|
||||
"nextlayerid":2,
|
||||
"nextobjectid":1,
|
||||
"orientation":"orthogonal",
|
||||
"renderorder":"right-down",
|
||||
"tiledversion":"1.11.0",
|
||||
"tileheight":32,
|
||||
"tilesets":[
|
||||
{
|
||||
"columns":8,
|
||||
"firstgid":1,
|
||||
"image":"tileset.png",
|
||||
"imageheight":96,
|
||||
"imagewidth":256,
|
||||
"margin":0,
|
||||
"name":"tileset",
|
||||
"spacing":0,
|
||||
"tilecount":24,
|
||||
"tileheight":32,
|
||||
"tilewidth":32
|
||||
}],
|
||||
"tilewidth":32,
|
||||
"type":"map",
|
||||
"version":"1.10",
|
||||
"width":5
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<map version="1.10" tiledversion="1.11.0" orientation="orthogonal" renderorder="right-down" width="5" height="5" tilewidth="32" tileheight="32" infinite="0" nextlayerid="2" nextobjectid="1">
|
||||
<tileset firstgid="1" name="tileset" tilewidth="32" tileheight="32" tilecount="24" columns="8">
|
||||
<image source="tileset.png" width="256" height="96"/>
|
||||
</tileset>
|
||||
<layer id="1" name="Tile Layer 1" width="5" height="5">
|
||||
<data encoding="csv">
|
||||
1,1,0,0,7,
|
||||
1,1,0,0,7,
|
||||
0,0,0,0,7,
|
||||
9,10,0,0,7,
|
||||
17,18,0,0,0
|
||||
</data>
|
||||
</layer>
|
||||
</map>
|
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
|
@ -0,0 +1,79 @@
|
|||
using System.Globalization;
|
||||
|
||||
namespace DotTiled.Tests;
|
||||
|
||||
public partial class TestData
|
||||
{
|
||||
public static Map MapWithExternalTileset(string fileExt) => new Map
|
||||
{
|
||||
Class = "",
|
||||
Orientation = MapOrientation.Orthogonal,
|
||||
Width = 5,
|
||||
Height = 5,
|
||||
TileWidth = 32,
|
||||
TileHeight = 32,
|
||||
Infinite = false,
|
||||
HexSideLength = null,
|
||||
StaggerAxis = null,
|
||||
StaggerIndex = null,
|
||||
ParallaxOriginX = 0,
|
||||
ParallaxOriginY = 0,
|
||||
RenderOrder = RenderOrder.RightDown,
|
||||
CompressionLevel = -1,
|
||||
BackgroundColor = Color.Parse("#00000000", CultureInfo.InvariantCulture),
|
||||
Version = "1.10",
|
||||
TiledVersion = "1.11.0",
|
||||
NextLayerID = 2,
|
||||
NextObjectID = 1,
|
||||
Tilesets = [
|
||||
new Tileset
|
||||
{
|
||||
Version = "1.10",
|
||||
TiledVersion = "1.11.0",
|
||||
FirstGID = 1,
|
||||
Name = "tileset",
|
||||
TileWidth = 32,
|
||||
TileHeight = 32,
|
||||
TileCount = 24,
|
||||
Columns = 8,
|
||||
Source = $"tileset.{(fileExt == "tmx" ? "tsx" : "tsj")}",
|
||||
Image = new Image
|
||||
{
|
||||
Format = ImageFormat.Png,
|
||||
Source = "tileset.png",
|
||||
Width = 256,
|
||||
Height = 96,
|
||||
}
|
||||
}
|
||||
],
|
||||
Layers = [
|
||||
new TileLayer
|
||||
{
|
||||
ID = 1,
|
||||
Name = "Tile Layer 1",
|
||||
Width = 5,
|
||||
Height = 5,
|
||||
Data = new Data
|
||||
{
|
||||
Encoding = DataEncoding.Csv,
|
||||
Chunks = null,
|
||||
Compression = null,
|
||||
GlobalTileIDs = [
|
||||
1, 1, 0, 0, 7,
|
||||
1, 1, 0, 0, 7,
|
||||
0, 0, 1, 0, 7,
|
||||
0, 0, 0, 1, 7,
|
||||
21, 21, 21, 21, 1
|
||||
],
|
||||
FlippingFlags = [
|
||||
FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None,
|
||||
FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None,
|
||||
FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None,
|
||||
FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None,
|
||||
FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
{ "compressionlevel":-1,
|
||||
"height":5,
|
||||
"infinite":false,
|
||||
"layers":[
|
||||
{
|
||||
"data":[1, 1, 0, 0, 7,
|
||||
1, 1, 0, 0, 7,
|
||||
0, 0, 1, 0, 7,
|
||||
0, 0, 0, 1, 7,
|
||||
21, 21, 21, 21, 1],
|
||||
"height":5,
|
||||
"id":1,
|
||||
"name":"Tile Layer 1",
|
||||
"opacity":1,
|
||||
"type":"tilelayer",
|
||||
"visible":true,
|
||||
"width":5,
|
||||
"x":0,
|
||||
"y":0
|
||||
}],
|
||||
"nextlayerid":2,
|
||||
"nextobjectid":1,
|
||||
"orientation":"orthogonal",
|
||||
"renderorder":"right-down",
|
||||
"tiledversion":"1.11.0",
|
||||
"tileheight":32,
|
||||
"tilesets":[
|
||||
{
|
||||
"firstgid":1,
|
||||
"source":"tileset.tsj"
|
||||
}],
|
||||
"tilewidth":32,
|
||||
"type":"map",
|
||||
"version":"1.10",
|
||||
"width":5
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<map version="1.10" tiledversion="1.11.0" orientation="orthogonal" renderorder="right-down" width="5" height="5" tilewidth="32" tileheight="32" infinite="0" nextlayerid="2" nextobjectid="1">
|
||||
<tileset firstgid="1" source="tileset.tsx"/>
|
||||
<layer id="1" name="Tile Layer 1" width="5" height="5">
|
||||
<data encoding="csv">
|
||||
1,1,0,0,7,
|
||||
1,1,0,0,7,
|
||||
0,0,1,0,7,
|
||||
0,0,0,1,7,
|
||||
21,21,21,21,1
|
||||
</data>
|
||||
</layer>
|
||||
</map>
|
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
|
@ -0,0 +1,14 @@
|
|||
{ "columns":8,
|
||||
"image":"tileset.png",
|
||||
"imageheight":96,
|
||||
"imagewidth":256,
|
||||
"margin":0,
|
||||
"name":"tileset",
|
||||
"spacing":0,
|
||||
"tilecount":24,
|
||||
"tiledversion":"1.11.0",
|
||||
"tileheight":32,
|
||||
"tilewidth":32,
|
||||
"type":"tileset",
|
||||
"version":"1.10"
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<tileset version="1.10" tiledversion="1.11.0" name="tileset" tilewidth="32" tileheight="32" tilecount="24" columns="8">
|
||||
<image source="tileset.png" width="256" height="96"/>
|
||||
</tileset>
|
|
@ -0,0 +1,79 @@
|
|||
using System.Globalization;
|
||||
|
||||
namespace DotTiled.Tests;
|
||||
|
||||
public partial class TestData
|
||||
{
|
||||
public static Map MapWithFlippingFlags(string fileExt) => new Map
|
||||
{
|
||||
Class = "",
|
||||
Orientation = MapOrientation.Orthogonal,
|
||||
Width = 5,
|
||||
Height = 5,
|
||||
TileWidth = 32,
|
||||
TileHeight = 32,
|
||||
Infinite = false,
|
||||
HexSideLength = null,
|
||||
StaggerAxis = null,
|
||||
StaggerIndex = null,
|
||||
ParallaxOriginX = 0,
|
||||
ParallaxOriginY = 0,
|
||||
RenderOrder = RenderOrder.RightDown,
|
||||
CompressionLevel = -1,
|
||||
BackgroundColor = Color.Parse("#00000000", CultureInfo.InvariantCulture),
|
||||
Version = "1.10",
|
||||
TiledVersion = "1.11.0",
|
||||
NextLayerID = 2,
|
||||
NextObjectID = 1,
|
||||
Tilesets = [
|
||||
new Tileset
|
||||
{
|
||||
Version = "1.10",
|
||||
TiledVersion = "1.11.0",
|
||||
FirstGID = 1,
|
||||
Name = "tileset",
|
||||
TileWidth = 32,
|
||||
TileHeight = 32,
|
||||
TileCount = 24,
|
||||
Columns = 8,
|
||||
Source = $"tileset.{(fileExt == "tmx" ? "tsx" : "tsj")}",
|
||||
Image = new Image
|
||||
{
|
||||
Format = ImageFormat.Png,
|
||||
Source = "tileset.png",
|
||||
Width = 256,
|
||||
Height = 96,
|
||||
}
|
||||
}
|
||||
],
|
||||
Layers = [
|
||||
new TileLayer
|
||||
{
|
||||
ID = 1,
|
||||
Name = "Tile Layer 1",
|
||||
Width = 5,
|
||||
Height = 5,
|
||||
Data = new Data
|
||||
{
|
||||
Encoding = DataEncoding.Csv,
|
||||
Chunks = null,
|
||||
Compression = null,
|
||||
GlobalTileIDs = [
|
||||
1, 1, 0, 0, 7,
|
||||
1, 1, 0, 0, 7,
|
||||
0, 0, 1, 0, 7,
|
||||
0, 0, 0, 1, 7,
|
||||
21, 21, 21, 21, 1
|
||||
],
|
||||
FlippingFlags = [
|
||||
FlippingFlags.None, FlippingFlags.FlippedDiagonally | FlippingFlags.FlippedHorizontally, FlippingFlags.None, FlippingFlags.None, FlippingFlags.FlippedVertically,
|
||||
FlippingFlags.FlippedDiagonally | FlippingFlags.FlippedVertically, FlippingFlags.FlippedVertically | FlippingFlags.FlippedHorizontally, FlippingFlags.None, FlippingFlags.None, FlippingFlags.FlippedVertically,
|
||||
FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.FlippedVertically,
|
||||
FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.FlippedVertically,
|
||||
FlippingFlags.FlippedHorizontally, FlippingFlags.FlippedHorizontally, FlippingFlags.FlippedHorizontally, FlippingFlags.FlippedHorizontally, FlippingFlags.None
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
{ "compressionlevel":-1,
|
||||
"height":5,
|
||||
"infinite":false,
|
||||
"layers":[
|
||||
{
|
||||
"data":[1, 2684354561, 0, 0, 1073741831,
|
||||
1610612737, 3221225473, 0, 0, 1073741831,
|
||||
0, 0, 1, 0, 1073741831,
|
||||
0, 0, 0, 1, 1073741831,
|
||||
2147483669, 2147483669, 2147483669, 2147483669, 1],
|
||||
"height":5,
|
||||
"id":1,
|
||||
"name":"Tile Layer 1",
|
||||
"opacity":1,
|
||||
"type":"tilelayer",
|
||||
"visible":true,
|
||||
"width":5,
|
||||
"x":0,
|
||||
"y":0
|
||||
}],
|
||||
"nextlayerid":2,
|
||||
"nextobjectid":1,
|
||||
"orientation":"orthogonal",
|
||||
"renderorder":"right-down",
|
||||
"tiledversion":"1.11.0",
|
||||
"tileheight":32,
|
||||
"tilesets":[
|
||||
{
|
||||
"firstgid":1,
|
||||
"source":"tileset.tsj"
|
||||
}],
|
||||
"tilewidth":32,
|
||||
"type":"map",
|
||||
"version":"1.10",
|
||||
"width":5
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<map version="1.10" tiledversion="1.11.0" orientation="orthogonal" renderorder="right-down" width="5" height="5" tilewidth="32" tileheight="32" infinite="0" nextlayerid="2" nextobjectid="1">
|
||||
<tileset firstgid="1" source="tileset.tsx"/>
|
||||
<layer id="1" name="Tile Layer 1" width="5" height="5">
|
||||
<data encoding="csv">
|
||||
1,2684354561,0,0,1073741831,
|
||||
1610612737,3221225473,0,0,1073741831,
|
||||
0,0,1,0,1073741831,
|
||||
0,0,0,1,1073741831,
|
||||
2147483669,2147483669,2147483669,2147483669,1
|
||||
</data>
|
||||
</layer>
|
||||
</map>
|
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
|
@ -0,0 +1,14 @@
|
|||
{ "columns":8,
|
||||
"image":"tileset.png",
|
||||
"imageheight":96,
|
||||
"imagewidth":256,
|
||||
"margin":0,
|
||||
"name":"tileset",
|
||||
"spacing":0,
|
||||
"tilecount":24,
|
||||
"tiledversion":"1.11.0",
|
||||
"tileheight":32,
|
||||
"tilewidth":32,
|
||||
"type":"tileset",
|
||||
"version":"1.10"
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<tileset version="1.10" tiledversion="1.11.0" name="tileset" tilewidth="32" tileheight="32" tilecount="24" columns="8">
|
||||
<image source="tileset.png" width="256" height="96"/>
|
||||
</tileset>
|
|
@ -0,0 +1,219 @@
|
|||
using System.Numerics;
|
||||
|
||||
namespace DotTiled.Tests;
|
||||
|
||||
public partial class TestData
|
||||
{
|
||||
public static Map MapWithManyLayers(string fileExt) => new Map
|
||||
{
|
||||
Class = "",
|
||||
Orientation = MapOrientation.Orthogonal,
|
||||
Width = 5,
|
||||
Height = 5,
|
||||
TileWidth = 32,
|
||||
TileHeight = 32,
|
||||
Infinite = false,
|
||||
HexSideLength = null,
|
||||
StaggerAxis = null,
|
||||
StaggerIndex = null,
|
||||
ParallaxOriginX = 0,
|
||||
ParallaxOriginY = 0,
|
||||
RenderOrder = RenderOrder.RightDown,
|
||||
CompressionLevel = -1,
|
||||
BackgroundColor = new Color { R = 0, G = 0, B = 0, A = 0 },
|
||||
Version = "1.10",
|
||||
TiledVersion = "1.11.0",
|
||||
NextLayerID = 8,
|
||||
NextObjectID = 7,
|
||||
Tilesets = [
|
||||
new Tileset
|
||||
{
|
||||
Version = "1.10",
|
||||
TiledVersion = "1.11.0",
|
||||
FirstGID = 1,
|
||||
Name = "tileset",
|
||||
TileWidth = 32,
|
||||
TileHeight = 32,
|
||||
TileCount = 24,
|
||||
Columns = 8,
|
||||
Source = $"tileset.{(fileExt == "tmx" ? "tsx" : "tsj")}",
|
||||
Image = new Image
|
||||
{
|
||||
Format = ImageFormat.Png,
|
||||
Source = "tileset.png",
|
||||
Width = 256,
|
||||
Height = 96,
|
||||
}
|
||||
}
|
||||
],
|
||||
Layers = [
|
||||
new Group
|
||||
{
|
||||
ID = 2,
|
||||
Name = "Root",
|
||||
Layers = [
|
||||
new ObjectLayer
|
||||
{
|
||||
ID = 3,
|
||||
Name = "Objects",
|
||||
Objects = [
|
||||
new RectangleObject
|
||||
{
|
||||
ID = 1,
|
||||
Name = "Object 1",
|
||||
X = 25.6667f,
|
||||
Y = 28.6667f,
|
||||
Width = 31.3333f,
|
||||
Height = 31.3333f
|
||||
},
|
||||
new PointObject
|
||||
{
|
||||
ID = 3,
|
||||
Name = "P1",
|
||||
X = 117.667f,
|
||||
Y = 48.6667f
|
||||
},
|
||||
new EllipseObject
|
||||
{
|
||||
ID = 4,
|
||||
Name = "Circle1",
|
||||
X = 77f,
|
||||
Y = 72.3333f,
|
||||
Width = 34.6667f,
|
||||
Height = 34.6667f
|
||||
},
|
||||
new PolygonObject
|
||||
{
|
||||
ID = 5,
|
||||
Name = "Poly",
|
||||
X = 20.6667f,
|
||||
Y = 114.667f,
|
||||
Points = [
|
||||
new Vector2(0, 0),
|
||||
new Vector2(104,20),
|
||||
new Vector2(35.6667f, 32.3333f)
|
||||
],
|
||||
Template = fileExt == "tmx" ? "poly.tx" : "poly.tj",
|
||||
Properties = new Dictionary<string, IProperty>
|
||||
{
|
||||
["templateprop"] = new StringProperty { Name = "templateprop", Value = "helo there" }
|
||||
}
|
||||
},
|
||||
new TileObject
|
||||
{
|
||||
ID = 6,
|
||||
Name = "TileObj",
|
||||
GID = 7,
|
||||
X = -35,
|
||||
Y = 110.333f,
|
||||
Width = 64,
|
||||
Height = 146
|
||||
}
|
||||
]
|
||||
},
|
||||
new Group
|
||||
{
|
||||
ID = 5,
|
||||
Name = "Sub",
|
||||
Layers = [
|
||||
new TileLayer
|
||||
{
|
||||
ID = 7,
|
||||
Name = "Tile 3",
|
||||
Width = 5,
|
||||
Height = 5,
|
||||
Data = new Data
|
||||
{
|
||||
Encoding = DataEncoding.Csv,
|
||||
Chunks = null,
|
||||
Compression = null,
|
||||
GlobalTileIDs = [
|
||||
0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0
|
||||
],
|
||||
FlippingFlags = [
|
||||
FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None,
|
||||
FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None,
|
||||
FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None,
|
||||
FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None,
|
||||
FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None
|
||||
]
|
||||
}
|
||||
},
|
||||
new TileLayer
|
||||
{
|
||||
ID = 6,
|
||||
Name = "Tile 2",
|
||||
Width = 5,
|
||||
Height = 5,
|
||||
Data = new Data
|
||||
{
|
||||
Encoding = DataEncoding.Csv,
|
||||
Chunks = null,
|
||||
Compression = null,
|
||||
GlobalTileIDs = [
|
||||
0, 15, 15, 0, 0,
|
||||
0, 15, 15, 0, 0,
|
||||
0, 15, 15, 15, 0,
|
||||
15, 15, 15, 0, 0,
|
||||
0, 0, 0, 0, 0
|
||||
],
|
||||
FlippingFlags = [
|
||||
FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None,
|
||||
FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None,
|
||||
FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None,
|
||||
FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None,
|
||||
FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
new ImageLayer
|
||||
{
|
||||
ID = 4,
|
||||
Name = "ImageLayer",
|
||||
Image = new Image
|
||||
{
|
||||
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
|
||||
},
|
||||
RepeatX = true
|
||||
},
|
||||
new TileLayer
|
||||
{
|
||||
ID = 1,
|
||||
Name = "Tile Layer 1",
|
||||
Width = 5,
|
||||
Height = 5,
|
||||
Data = new Data
|
||||
{
|
||||
Encoding = DataEncoding.Csv,
|
||||
Chunks = null,
|
||||
Compression = null,
|
||||
GlobalTileIDs = [
|
||||
1, 1, 1, 1, 1,
|
||||
0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0
|
||||
],
|
||||
FlippingFlags = [
|
||||
FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None,
|
||||
FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None,
|
||||
FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None,
|
||||
FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None,
|
||||
FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
|
@ -0,0 +1,163 @@
|
|||
{ "compressionlevel":-1,
|
||||
"height":5,
|
||||
"infinite":false,
|
||||
"layers":[
|
||||
{
|
||||
"id":2,
|
||||
"layers":[
|
||||
{
|
||||
"draworder":"topdown",
|
||||
"id":3,
|
||||
"name":"Objects",
|
||||
"objects":[
|
||||
{
|
||||
"height":31.3333,
|
||||
"id":1,
|
||||
"name":"Object 1",
|
||||
"rotation":0,
|
||||
"type":"",
|
||||
"visible":true,
|
||||
"width":31.3333,
|
||||
"x":25.6667,
|
||||
"y":28.6667
|
||||
},
|
||||
{
|
||||
"height":0,
|
||||
"id":3,
|
||||
"name":"P1",
|
||||
"point":true,
|
||||
"rotation":0,
|
||||
"type":"",
|
||||
"visible":true,
|
||||
"width":0,
|
||||
"x":117.667,
|
||||
"y":48.6667
|
||||
},
|
||||
{
|
||||
"ellipse":true,
|
||||
"height":34.6667,
|
||||
"id":4,
|
||||
"name":"Circle1",
|
||||
"rotation":0,
|
||||
"type":"",
|
||||
"visible":true,
|
||||
"width":34.6667,
|
||||
"x":77,
|
||||
"y":72.3333
|
||||
},
|
||||
{
|
||||
"id":5,
|
||||
"template":"poly.tj",
|
||||
"x":20.6667,
|
||||
"y":114.667
|
||||
},
|
||||
{
|
||||
"gid":7,
|
||||
"height":146,
|
||||
"id":6,
|
||||
"name":"TileObj",
|
||||
"rotation":0,
|
||||
"type":"",
|
||||
"visible":true,
|
||||
"width":64,
|
||||
"x":-35,
|
||||
"y":110.333
|
||||
}],
|
||||
"opacity":1,
|
||||
"type":"objectgroup",
|
||||
"visible":true,
|
||||
"x":0,
|
||||
"y":0
|
||||
},
|
||||
{
|
||||
"id":5,
|
||||
"layers":[
|
||||
{
|
||||
"data":[0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0],
|
||||
"height":5,
|
||||
"id":7,
|
||||
"name":"Tile 3",
|
||||
"opacity":1,
|
||||
"type":"tilelayer",
|
||||
"visible":true,
|
||||
"width":5,
|
||||
"x":0,
|
||||
"y":0
|
||||
},
|
||||
{
|
||||
"data":[0, 15, 15, 0, 0,
|
||||
0, 15, 15, 0, 0,
|
||||
0, 15, 15, 15, 0,
|
||||
15, 15, 15, 0, 0,
|
||||
0, 0, 0, 0, 0],
|
||||
"height":5,
|
||||
"id":6,
|
||||
"name":"Tile 2",
|
||||
"opacity":1,
|
||||
"type":"tilelayer",
|
||||
"visible":true,
|
||||
"width":5,
|
||||
"x":0,
|
||||
"y":0
|
||||
}],
|
||||
"name":"Sub",
|
||||
"opacity":1,
|
||||
"type":"group",
|
||||
"visible":true,
|
||||
"x":0,
|
||||
"y":0
|
||||
},
|
||||
{
|
||||
"id":4,
|
||||
"image":"tileset.png",
|
||||
"name":"ImageLayer",
|
||||
"opacity":1,
|
||||
"repeatx":true,
|
||||
"type":"imagelayer",
|
||||
"visible":true,
|
||||
"x":0,
|
||||
"y":0
|
||||
},
|
||||
{
|
||||
"data":[1, 1, 1, 1, 1,
|
||||
0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0],
|
||||
"height":5,
|
||||
"id":1,
|
||||
"name":"Tile Layer 1",
|
||||
"opacity":1,
|
||||
"type":"tilelayer",
|
||||
"visible":true,
|
||||
"width":5,
|
||||
"x":0,
|
||||
"y":0
|
||||
}],
|
||||
"name":"Root",
|
||||
"opacity":1,
|
||||
"type":"group",
|
||||
"visible":true,
|
||||
"x":0,
|
||||
"y":0
|
||||
}],
|
||||
"nextlayerid":8,
|
||||
"nextobjectid":7,
|
||||
"orientation":"orthogonal",
|
||||
"renderorder":"right-down",
|
||||
"tiledversion":"1.11.0",
|
||||
"tileheight":32,
|
||||
"tilesets":[
|
||||
{
|
||||
"firstgid":1,
|
||||
"source":"tileset.tsj"
|
||||
}],
|
||||
"tilewidth":32,
|
||||
"type":"map",
|
||||
"version":"1.10",
|
||||
"width":5
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<map version="1.10" tiledversion="1.11.0" orientation="orthogonal" renderorder="right-down" width="5" height="5" tilewidth="32" tileheight="32" infinite="0" nextlayerid="8" nextobjectid="7">
|
||||
<tileset firstgid="1" source="tileset.tsx"/>
|
||||
<group id="2" name="Root">
|
||||
<objectgroup id="3" name="Objects">
|
||||
<object id="1" name="Object 1" x="25.6667" y="28.6667" width="31.3333" height="31.3333"/>
|
||||
<object id="3" name="P1" x="117.667" y="48.6667">
|
||||
<point/>
|
||||
</object>
|
||||
<object id="4" name="Circle1" x="77" y="72.3333" width="34.6667" height="34.6667">
|
||||
<ellipse/>
|
||||
</object>
|
||||
<object id="5" template="poly.tx" x="20.6667" y="114.667"/>
|
||||
<object id="6" name="TileObj" gid="7" x="-35" y="110.333" width="64" height="146"/>
|
||||
</objectgroup>
|
||||
<group id="5" name="Sub">
|
||||
<layer id="7" name="Tile 3" width="5" height="5">
|
||||
<data encoding="csv">
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0
|
||||
</data>
|
||||
</layer>
|
||||
<layer id="6" name="Tile 2" width="5" height="5">
|
||||
<data encoding="csv">
|
||||
0,15,15,0,0,
|
||||
0,15,15,0,0,
|
||||
0,15,15,15,0,
|
||||
15,15,15,0,0,
|
||||
0,0,0,0,0
|
||||
</data>
|
||||
</layer>
|
||||
</group>
|
||||
<imagelayer id="4" name="ImageLayer" repeatx="1">
|
||||
<image source="tileset.png" width="256" height="96"/>
|
||||
</imagelayer>
|
||||
<layer id="1" name="Tile Layer 1" width="5" height="5">
|
||||
<data encoding="csv">
|
||||
1,1,1,1,1,
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0
|
||||
</data>
|
||||
</layer>
|
||||
</group>
|
||||
</map>
|
|
@ -0,0 +1,31 @@
|
|||
{ "object":
|
||||
{
|
||||
"height":0,
|
||||
"id":5,
|
||||
"name":"Poly",
|
||||
"polygon":[
|
||||
{
|
||||
"x":0,
|
||||
"y":0
|
||||
},
|
||||
{
|
||||
"x":104,
|
||||
"y":20
|
||||
},
|
||||
{
|
||||
"x":35.6667,
|
||||
"y":32.3333
|
||||
}],
|
||||
"properties":[
|
||||
{
|
||||
"name":"templateprop",
|
||||
"type":"string",
|
||||
"value":"helo there"
|
||||
}],
|
||||
"rotation":0,
|
||||
"type":"",
|
||||
"visible":true,
|
||||
"width":0
|
||||
},
|
||||
"type":"template"
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<template>
|
||||
<object name="Poly">
|
||||
<properties>
|
||||
<property name="templateprop" value="helo there"/>
|
||||
</properties>
|
||||
<polygon points="0,0 104,20 35.6667,32.3333"/>
|
||||
</object>
|
||||
</template>
|
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
|
@ -0,0 +1,14 @@
|
|||
{ "columns":8,
|
||||
"image":"tileset.png",
|
||||
"imageheight":96,
|
||||
"imagewidth":256,
|
||||
"margin":0,
|
||||
"name":"tileset",
|
||||
"spacing":0,
|
||||
"tilecount":24,
|
||||
"tiledversion":"1.11.0",
|
||||
"tileheight":32,
|
||||
"tilewidth":32,
|
||||
"type":"tileset",
|
||||
"version":"1.10"
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<tileset version="1.10" tiledversion="1.11.0" name="tileset" tilewidth="32" tileheight="32" tilecount="24" columns="8">
|
||||
<image source="tileset.png" width="256" height="96"/>
|
||||
</tileset>
|
38
src/DotTiled.Tests/Serialization/Tmj/TmjMapReaderTests.cs
Normal file
38
src/DotTiled.Tests/Serialization/Tmj/TmjMapReaderTests.cs
Normal file
|
@ -0,0 +1,38 @@
|
|||
namespace DotTiled.Tests;
|
||||
|
||||
public partial class TmjMapReaderTests
|
||||
{
|
||||
public static IEnumerable<object[]> Maps => TestData.MapTests;
|
||||
[Theory]
|
||||
[MemberData(nameof(Maps))]
|
||||
public void TmxMapReaderReadMap_ValidTmjExternalTilesetsAndTemplates_ReturnsMapThatEqualsExpected(
|
||||
string testDataFile,
|
||||
Func<string, Map> expectedMap,
|
||||
IReadOnlyCollection<CustomTypeDefinition> customTypeDefinitions)
|
||||
{
|
||||
// Arrange
|
||||
testDataFile += ".tmj";
|
||||
var fileDir = Path.GetDirectoryName(testDataFile);
|
||||
var json = TestData.GetRawStringFor(testDataFile);
|
||||
Template ResolveTemplate(string source)
|
||||
{
|
||||
var templateJson = TestData.GetRawStringFor($"{fileDir}/{source}");
|
||||
using var templateReader = new TjTemplateReader(templateJson, ResolveTileset, ResolveTemplate, customTypeDefinitions);
|
||||
return templateReader.ReadTemplate();
|
||||
}
|
||||
Tileset ResolveTileset(string source)
|
||||
{
|
||||
var tilesetJson = TestData.GetRawStringFor($"{fileDir}/{source}");
|
||||
using var tilesetReader = new TsjTilesetReader(tilesetJson, ResolveTemplate, customTypeDefinitions);
|
||||
return tilesetReader.ReadTileset();
|
||||
}
|
||||
using var mapReader = new TmjMapReader(json, ResolveTileset, ResolveTemplate, customTypeDefinitions);
|
||||
|
||||
// Act
|
||||
var map = mapReader.ReadMap();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(map);
|
||||
DotTiledAssert.AssertMap(expectedMap("tmj"), map);
|
||||
}
|
||||
}
|
40
src/DotTiled.Tests/Serialization/Tmx/TmxMapReaderTests.cs
Normal file
40
src/DotTiled.Tests/Serialization/Tmx/TmxMapReaderTests.cs
Normal file
|
@ -0,0 +1,40 @@
|
|||
using System.Xml;
|
||||
|
||||
namespace DotTiled.Tests;
|
||||
|
||||
public partial class TmxMapReaderTests
|
||||
{
|
||||
public static IEnumerable<object[]> Maps => TestData.MapTests;
|
||||
[Theory]
|
||||
[MemberData(nameof(Maps))]
|
||||
public void TmxMapReaderReadMap_ValidXmlExternalTilesetsAndTemplates_ReturnsMapThatEqualsExpected(
|
||||
string testDataFile,
|
||||
Func<string, Map> expectedMap,
|
||||
IReadOnlyCollection<CustomTypeDefinition> customTypeDefinitions)
|
||||
{
|
||||
// Arrange
|
||||
testDataFile += ".tmx";
|
||||
var fileDir = Path.GetDirectoryName(testDataFile);
|
||||
using var reader = TestData.GetXmlReaderFor(testDataFile);
|
||||
Template ResolveTemplate(string source)
|
||||
{
|
||||
using var xmlTemplateReader = TestData.GetXmlReaderFor($"{fileDir}/{source}");
|
||||
using var templateReader = new TxTemplateReader(xmlTemplateReader, ResolveTileset, ResolveTemplate, customTypeDefinitions);
|
||||
return templateReader.ReadTemplate();
|
||||
}
|
||||
Tileset ResolveTileset(string source)
|
||||
{
|
||||
using var xmlTilesetReader = TestData.GetXmlReaderFor($"{fileDir}/{source}");
|
||||
using var tilesetReader = new TsxTilesetReader(xmlTilesetReader, ResolveTemplate, customTypeDefinitions);
|
||||
return tilesetReader.ReadTileset();
|
||||
}
|
||||
using var mapReader = new TmxMapReader(reader, ResolveTileset, ResolveTemplate, customTypeDefinitions);
|
||||
|
||||
// Act
|
||||
var map = mapReader.ReadMap();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(map);
|
||||
DotTiledAssert.AssertMap(expectedMap("tmx"), map);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue