mirror of
https://github.com/dcronqvist/DotTiled.git
synced 2025-05-08 23:06:03 +03:00
Compare commits
No commits in common. "d20aff1d6679f837ec4ec8d75e687a01ff0a199c" and "de41fb550877fb1062f36b977a0b750f65605006" have entirely different histories.
d20aff1d66
...
de41fb5508
52 changed files with 201 additions and 204 deletions
|
@ -5,10 +5,13 @@ 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 formats
|
||||
## File format caveats
|
||||
|
||||
The <xref:DotTiled.Map> 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 <xref:DotTiled.ImageLayer.Image> (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:
|
||||
|
|
|
@ -12,9 +12,6 @@ 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.
|
||||
|
||||
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 |
|
||||
| Tiled version | Compatible DotTiled version(s) |
|
||||
|---------------|--------------------------------|
|
||||
| 1.11 | 0.1.0, 0.2.0, 0.2.1, 0.3.0 |
|
|
@ -48,7 +48,7 @@ public class FromTypeUsedInLoaderTests
|
|||
ParallaxOriginY = 0,
|
||||
RenderOrder = RenderOrder.RightDown,
|
||||
CompressionLevel = -1,
|
||||
BackgroundColor = new TiledColor { R = 0, G = 0, B = 0, A = 0 },
|
||||
BackgroundColor = new Color { 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 TiledColor { R = 0, G = 0, B = 0, A = 0 },
|
||||
BackgroundColor = new Color { 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 TiledColor { R = 0, G = 0, B = 0, A = 0 },
|
||||
BackgroundColor = new Color { R = 0, G = 0, B = 0, A = 0 },
|
||||
Version = "1.10",
|
||||
TiledVersion = "1.11.0",
|
||||
NextLayerID = 2,
|
||||
|
|
|
@ -15,7 +15,7 @@ public partial class TestData
|
|||
ParallaxOriginY = 0,
|
||||
RenderOrder = RenderOrder.RightDown,
|
||||
CompressionLevel = -1,
|
||||
BackgroundColor = new TiledColor { R = 0, G = 0, B = 0, A = 0 },
|
||||
BackgroundColor = new Color { R = 0, G = 0, B = 0, A = 0 },
|
||||
Version = "1.10",
|
||||
TiledVersion = "1.11.0",
|
||||
NextLayerID = 2,
|
||||
|
|
|
@ -17,7 +17,7 @@ public partial class TestData
|
|||
ParallaxOriginY = 0,
|
||||
RenderOrder = RenderOrder.RightDown,
|
||||
CompressionLevel = -1,
|
||||
BackgroundColor = TiledColor.Parse("#00000000", CultureInfo.InvariantCulture),
|
||||
BackgroundColor = Color.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 = TiledColor.Parse("#ffff0000", CultureInfo.InvariantCulture) },
|
||||
new ColorProperty { Name = "tilesetcolor", Value = Color.Parse("#ffff0000", CultureInfo.InvariantCulture) },
|
||||
new FileProperty { Name = "tilesetfile", Value = "" },
|
||||
new FloatProperty { Name = "tilesetfloat", Value = 5.2f },
|
||||
new IntProperty { Name = "tilesetint", Value = 9 },
|
||||
|
|
|
@ -17,7 +17,7 @@ public partial class TestData
|
|||
ParallaxOriginY = 0,
|
||||
RenderOrder = RenderOrder.RightDown,
|
||||
CompressionLevel = -1,
|
||||
BackgroundColor = TiledColor.Parse("#00000000", CultureInfo.InvariantCulture),
|
||||
BackgroundColor = Color.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 = TiledColor.Parse("#ff0000", CultureInfo.InvariantCulture),
|
||||
Color = Color.Parse("#ff0000", CultureInfo.InvariantCulture),
|
||||
Tile = 0,
|
||||
Probability = 1
|
||||
},
|
||||
new WangColor
|
||||
{
|
||||
Name = "Grass",
|
||||
Color = TiledColor.Parse("#00ff00", CultureInfo.InvariantCulture),
|
||||
Color = Color.Parse("#00ff00", CultureInfo.InvariantCulture),
|
||||
Tile = -1,
|
||||
Probability = 1
|
||||
},
|
||||
new WangColor
|
||||
{
|
||||
Name = "Stone",
|
||||
Color = TiledColor.Parse("#0000ff", CultureInfo.InvariantCulture),
|
||||
Color = Color.Parse("#0000ff", CultureInfo.InvariantCulture),
|
||||
Tile = 29,
|
||||
Probability = 1
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ public partial class TestData
|
|||
ParallaxOriginY = 0,
|
||||
RenderOrder = RenderOrder.RightDown,
|
||||
CompressionLevel = -1,
|
||||
BackgroundColor = new TiledColor { R = 0, G = 0, B = 0, A = 0 },
|
||||
BackgroundColor = new Color { 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" ? 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
|
||||
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
|
||||
},
|
||||
|
|
|
@ -15,7 +15,7 @@ public partial class TestData
|
|||
ParallaxOriginY = 0,
|
||||
RenderOrder = RenderOrder.RightDown,
|
||||
CompressionLevel = -1,
|
||||
BackgroundColor = new TiledColor { R = 0, G = 0, B = 0, A = 0 },
|
||||
BackgroundColor = new Color { R = 0, G = 0, B = 0, A = 0 },
|
||||
Version = "1.10",
|
||||
TiledVersion = "1.11.0",
|
||||
NextLayerID = 2,
|
||||
|
|
|
@ -15,7 +15,7 @@ public partial class TestData
|
|||
ParallaxOriginY = 0,
|
||||
RenderOrder = RenderOrder.RightDown,
|
||||
CompressionLevel = -1,
|
||||
BackgroundColor = new TiledColor { R = 0, G = 0, B = 0, A = 0 },
|
||||
BackgroundColor = new Color { R = 0, G = 0, B = 0, A = 0 },
|
||||
Version = "1.10",
|
||||
TiledVersion = "1.11.0",
|
||||
NextLayerID = 2,
|
||||
|
|
|
@ -17,7 +17,7 @@ public partial class TestData
|
|||
ParallaxOriginY = 0,
|
||||
RenderOrder = RenderOrder.RightDown,
|
||||
CompressionLevel = -1,
|
||||
BackgroundColor = TiledColor.Parse("#00ff00", CultureInfo.InvariantCulture),
|
||||
BackgroundColor = Color.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 = TiledColor.Parse("#ff55ffff", CultureInfo.InvariantCulture) },
|
||||
new ColorProperty { Name = "colorprop", Value = Color.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<TiledColor>.Empty }
|
||||
new ColorProperty { Name = "unsetcolorprop", Value = Optional<Color>.Empty }
|
||||
]
|
||||
};
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ public partial class TestData
|
|||
ParallaxOriginY = 0,
|
||||
RenderOrder = RenderOrder.RightDown,
|
||||
CompressionLevel = -1,
|
||||
BackgroundColor = TiledColor.Parse("#00000000", CultureInfo.InvariantCulture),
|
||||
BackgroundColor = Color.Parse("#00000000", CultureInfo.InvariantCulture),
|
||||
Version = "1.10",
|
||||
TiledVersion = "1.11.0",
|
||||
NextLayerID = 2,
|
||||
|
|
|
@ -17,7 +17,7 @@ public partial class TestData
|
|||
ParallaxOriginY = 0,
|
||||
RenderOrder = RenderOrder.RightDown,
|
||||
CompressionLevel = -1,
|
||||
BackgroundColor = TiledColor.Parse("#00000000", CultureInfo.InvariantCulture),
|
||||
BackgroundColor = Color.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 = TiledColor.Parse("#000000ff", CultureInfo.InvariantCulture) },
|
||||
new ColorProperty { Name = "colorinclass", Value = Color.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 = TiledColor.Parse("#000000ff", CultureInfo.InvariantCulture)
|
||||
Value = Color.Parse("#000000ff", CultureInfo.InvariantCulture)
|
||||
},
|
||||
new FileProperty
|
||||
{
|
||||
|
|
|
@ -17,7 +17,7 @@ public partial class TestData
|
|||
ParallaxOriginY = 0,
|
||||
RenderOrder = RenderOrder.RightDown,
|
||||
CompressionLevel = -1,
|
||||
BackgroundColor = TiledColor.Parse("#00000000", CultureInfo.InvariantCulture),
|
||||
BackgroundColor = Color.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 = TiledColor.Parse("#000000ff", CultureInfo.InvariantCulture) },
|
||||
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 },
|
||||
|
@ -82,7 +82,7 @@ public partial class TestData
|
|||
PropertyType = "CustomClass",
|
||||
Value = [
|
||||
new BoolProperty { Name = "boolinclass", Value = true },
|
||||
new ColorProperty { Name = "colorinclass", Value = TiledColor.Parse("#000000ff", CultureInfo.InvariantCulture) },
|
||||
new ColorProperty { Name = "colorinclass", Value = Color.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 = TiledColor.Parse("#000000ff", CultureInfo.InvariantCulture)
|
||||
Value = Color.Parse("#000000ff", CultureInfo.InvariantCulture)
|
||||
},
|
||||
new FileProperty
|
||||
{
|
||||
|
|
|
@ -17,7 +17,7 @@ public partial class TestData
|
|||
ParallaxOriginY = 0,
|
||||
RenderOrder = RenderOrder.RightDown,
|
||||
CompressionLevel = -1,
|
||||
BackgroundColor = TiledColor.Parse("#00000000", CultureInfo.InvariantCulture),
|
||||
BackgroundColor = Color.Parse("#00000000", CultureInfo.InvariantCulture),
|
||||
Version = "1.10",
|
||||
TiledVersion = "1.11.0",
|
||||
NextLayerID = 2,
|
||||
|
|
|
@ -17,7 +17,7 @@ public partial class TestData
|
|||
ParallaxOriginY = 0,
|
||||
RenderOrder = RenderOrder.RightDown,
|
||||
CompressionLevel = -1,
|
||||
BackgroundColor = TiledColor.Parse("#00000000", CultureInfo.InvariantCulture),
|
||||
BackgroundColor = Color.Parse("#00000000", CultureInfo.InvariantCulture),
|
||||
Version = "1.10",
|
||||
TiledVersion = "1.11.0",
|
||||
NextLayerID = 2,
|
||||
|
|
|
@ -17,7 +17,7 @@ public partial class TestData
|
|||
ParallaxOriginY = 0,
|
||||
RenderOrder = RenderOrder.RightDown,
|
||||
CompressionLevel = -1,
|
||||
BackgroundColor = TiledColor.Parse("#00000000", CultureInfo.InvariantCulture),
|
||||
BackgroundColor = Color.Parse("#00000000", CultureInfo.InvariantCulture),
|
||||
Version = "1.10",
|
||||
TiledVersion = "1.11.0",
|
||||
NextLayerID = 3,
|
||||
|
|
|
@ -17,9 +17,9 @@ public partial class TestData
|
|||
ParallaxOriginY = 0,
|
||||
RenderOrder = RenderOrder.RightDown,
|
||||
CompressionLevel = -1,
|
||||
BackgroundColor = new TiledColor { R = 0, G = 0, B = 0, A = 0 },
|
||||
BackgroundColor = new Color { R = 0, G = 0, B = 0, A = 0 },
|
||||
Version = "1.10",
|
||||
TiledVersion = "1.11.2",
|
||||
TiledVersion = "1.11.0",
|
||||
NextLayerID = 8,
|
||||
NextObjectID = 7,
|
||||
Tilesets = [
|
||||
|
@ -172,8 +172,8 @@ public partial class TestData
|
|||
{
|
||||
Format = ImageFormat.Png,
|
||||
Source = "tileset.png",
|
||||
Width = 256,
|
||||
Height = 96
|
||||
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
|
||||
},
|
||||
|
|
|
@ -114,8 +114,6 @@
|
|||
{
|
||||
"id":4,
|
||||
"image":"tileset.png",
|
||||
"imageheight":96,
|
||||
"imagewidth":256,
|
||||
"name":"ImageLayer",
|
||||
"opacity":1,
|
||||
"repeatx":true,
|
||||
|
@ -151,7 +149,7 @@
|
|||
"nextobjectid":7,
|
||||
"orientation":"orthogonal",
|
||||
"renderorder":"right-down",
|
||||
"tiledversion":"1.11.2",
|
||||
"tiledversion":"1.11.0",
|
||||
"tileheight":32,
|
||||
"tilesets":[
|
||||
{
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<map version="1.10" tiledversion="1.11.2" orientation="orthogonal" renderorder="right-down" width="5" height="5" tilewidth="32" tileheight="32" infinite="0" nextlayerid="8" nextobjectid="7">
|
||||
<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">
|
||||
|
|
|
@ -17,7 +17,7 @@ public partial class TestData
|
|||
ParallaxOriginY = 0,
|
||||
RenderOrder = RenderOrder.RightDown,
|
||||
CompressionLevel = -1,
|
||||
BackgroundColor = TiledColor.Parse("#00ff00", CultureInfo.InvariantCulture),
|
||||
BackgroundColor = Color.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 = TiledColor.Parse("#ff55ffff", CultureInfo.InvariantCulture) },
|
||||
new ColorProperty { Name = "colorprop", Value = Color.Parse("#ff55ffff", CultureInfo.InvariantCulture) },
|
||||
new FileProperty { Name = "fileprop", Value = "file.txt" },
|
||||
new FloatProperty { Name = "floatprop", Value = 4.2f },
|
||||
new IntProperty { Name = "intprop", Value = 8 },
|
||||
|
|
|
@ -80,7 +80,7 @@ public class HasPropertiesBaseTests
|
|||
private sealed class MapTo
|
||||
{
|
||||
public bool MapToBool { get; set; } = false;
|
||||
public TiledColor MapToColor { get; set; } = TiledColor.Parse("#00000000", CultureInfo.InvariantCulture);
|
||||
public Color MapToColor { get; set; } = Color.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 = TiledColor.Parse("#FF0000FF", CultureInfo.InvariantCulture) },
|
||||
new ColorProperty { Name = "MapToColor", Value = Color.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(TiledColor.Parse("#FF0000FF", CultureInfo.InvariantCulture), mappedProperty.MapToColor);
|
||||
Assert.Equal(Color.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 = TiledColor.Parse("#FF0000FF", CultureInfo.InvariantCulture) },
|
||||
new ColorProperty { Name = "MapToColor", Value = Color.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(TiledColor.Parse("#FF0000FF", CultureInfo.InvariantCulture), mappedProperty.MapToInNested.MapToColor);
|
||||
Assert.Equal(Color.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<IProperty> props = [
|
||||
new BoolProperty { Name = "MapToBool", Value = true },
|
||||
new ColorProperty { Name = "MapToColor", Value = TiledColor.Parse("#FF0000FF", CultureInfo.InvariantCulture) },
|
||||
new ColorProperty { Name = "MapToColor", Value = Color.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(TiledColor.Parse("#FF0000FF", CultureInfo.InvariantCulture), mappedProperty.MapToColor);
|
||||
Assert.Equal(Color.Parse("#FF0000FF", CultureInfo.InvariantCulture), mappedProperty.MapToColor);
|
||||
Assert.Equal(1.0f, mappedProperty.MapToFloat);
|
||||
Assert.Equal("Test", mappedProperty.MapToFile);
|
||||
Assert.Equal(1, mappedProperty.MapToInt);
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace DotTiled;
|
|||
/// <summary>
|
||||
/// Represents a Tiled color.
|
||||
/// </summary>
|
||||
public class TiledColor : IParsable<TiledColor>, IEquatable<TiledColor>
|
||||
public class Color : IParsable<Color>, IEquatable<Color>
|
||||
{
|
||||
/// <summary>
|
||||
/// The red component of the color.
|
||||
|
@ -30,31 +30,31 @@ public class TiledColor : IParsable<TiledColor>, IEquatable<TiledColor>
|
|||
public byte A { get; set; } = 255;
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to parse the specified string into a <see cref="TiledColor"/>. Expects strings in the format <c>#RRGGBB</c> or <c>#AARRGGBB</c>.
|
||||
/// Attempts to parse the specified string into a <see cref="Color"/>. Expects strings in the format <c>#RRGGBB</c> or <c>#AARRGGBB</c>.
|
||||
/// The leading <c>#</c> is optional.
|
||||
/// </summary>
|
||||
/// <param name="s">A string value to parse into a <see cref="TiledColor"/></param>
|
||||
/// <param name="s">A string value to parse into a <see cref="Color"/></param>
|
||||
/// <param name="provider">An object that supplies culture-specific information about the format of s.</param>
|
||||
/// <returns>The parsed <see cref="TiledColor"/></returns>
|
||||
/// <returns>The parsed <see cref="Color"/></returns>
|
||||
/// <exception cref="FormatException">Thrown in case the provided string <paramref name="s"/> is not in a valid format.</exception>
|
||||
public static TiledColor Parse(string s, IFormatProvider provider)
|
||||
public static Color Parse(string s, IFormatProvider provider)
|
||||
{
|
||||
_ = TryParse(s, provider, out var result);
|
||||
return result ?? throw new FormatException($"Invalid format for TiledColor: {s}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to parse the specified string into a <see cref="TiledColor"/>. Expects strings in the format <c>#RRGGBB</c> or <c>#AARRGGBB</c>.
|
||||
/// Attempts to parse the specified string into a <see cref="Color"/>. Expects strings in the format <c>#RRGGBB</c> or <c>#AARRGGBB</c>.
|
||||
/// The leading <c>#</c> is optional.
|
||||
/// </summary>
|
||||
/// <param name="s">A string value to parse into a <see cref="TiledColor"/></param>
|
||||
/// <param name="s">A string value to parse into a <see cref="Color"/></param>
|
||||
/// <param name="provider">An object that supplies culture-specific information about the format of s.</param>
|
||||
/// <param name="result">When this method returns, contains the parsed <see cref="TiledColor"/> or <c>null</c> on failure.</param>
|
||||
/// <param name="result">When this method returns, contains the parsed <see cref="Color"/> or <c>null</c> on failure.</param>
|
||||
/// <returns><c>true</c> if <paramref name="s"/> was successfully parsed; otherwise, <c>false</c>.</returns>
|
||||
public static bool TryParse(
|
||||
[NotNullWhen(true)] string s,
|
||||
IFormatProvider provider,
|
||||
[MaybeNullWhen(false)] out TiledColor result)
|
||||
[MaybeNullWhen(false)] out Color result)
|
||||
{
|
||||
if (s is not null && !s.StartsWith('#'))
|
||||
return TryParse($"#{s}", provider, out result);
|
||||
|
@ -68,7 +68,7 @@ public class TiledColor : IParsable<TiledColor>, IEquatable<TiledColor>
|
|||
|
||||
if (s.Length == 7)
|
||||
{
|
||||
result = new TiledColor
|
||||
result = new Color
|
||||
{
|
||||
R = byte.Parse(s[1..3], NumberStyles.HexNumber, provider),
|
||||
G = byte.Parse(s[3..5], NumberStyles.HexNumber, provider),
|
||||
|
@ -77,7 +77,7 @@ public class TiledColor : IParsable<TiledColor>, IEquatable<TiledColor>
|
|||
}
|
||||
else
|
||||
{
|
||||
result = new TiledColor
|
||||
result = new Color
|
||||
{
|
||||
A = byte.Parse(s[1..3], NumberStyles.HexNumber, provider),
|
||||
R = byte.Parse(s[3..5], NumberStyles.HexNumber, provider),
|
||||
|
@ -90,7 +90,7 @@ public class TiledColor : IParsable<TiledColor>, IEquatable<TiledColor>
|
|||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public bool Equals(TiledColor other)
|
||||
public bool Equals(Color other)
|
||||
{
|
||||
if (other is null)
|
||||
return false;
|
||||
|
@ -99,7 +99,7 @@ public class TiledColor : IParsable<TiledColor>, IEquatable<TiledColor>
|
|||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool Equals(object obj) => obj is TiledColor other && Equals(other);
|
||||
public override bool Equals(object obj) => obj is Color other && Equals(other);
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override int GetHashCode() => HashCode.Combine(R, G, B, A);
|
|
@ -18,7 +18,7 @@
|
|||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<Copyright>Copyright © 2024 dcronqvist</Copyright>
|
||||
<PackageLicenseFile>LICENSE</PackageLicenseFile>
|
||||
<Version>0.4.0</Version>
|
||||
<Version>0.3.0</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -37,7 +37,7 @@ public abstract class BaseLayer : HasPropertiesBase
|
|||
/// <summary>
|
||||
/// A tint color that is multiplied with any tiles drawn by this layer.
|
||||
/// </summary>
|
||||
public Optional<TiledColor> TintColor { get; set; } = Optional<TiledColor>.Empty;
|
||||
public Optional<Color> TintColor { get; set; } = Optional<Color>.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Horizontal offset for this layer in pixels.
|
||||
|
|
|
@ -90,12 +90,12 @@ public class Chunk
|
|||
/// <summary>
|
||||
/// The width of the chunk in tiles.
|
||||
/// </summary>
|
||||
public required int Width { get; set; }
|
||||
public required uint Width { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The height of the chunk in tiles.
|
||||
/// </summary>
|
||||
public required int Height { get; set; }
|
||||
public required uint Height { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The parsed chunk data, as a list of tile GIDs.
|
||||
|
|
|
@ -8,12 +8,12 @@ public class ImageLayer : BaseLayer
|
|||
/// <summary>
|
||||
/// The X position of the image layer in pixels.
|
||||
/// </summary>
|
||||
public int X { get; set; } = 0;
|
||||
public uint X { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// The Y position of the image layer in pixels.
|
||||
/// </summary>
|
||||
public int Y { get; set; } = 0;
|
||||
public Optional<uint> Y { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Whether the image drawn by this layer is repeated along the X axis.
|
||||
|
|
|
@ -26,27 +26,27 @@ public class ObjectLayer : BaseLayer
|
|||
/// <summary>
|
||||
/// The X coordinate of the object layer in tiles.
|
||||
/// </summary>
|
||||
public int X { get; set; } = 0;
|
||||
public uint X { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// The Y coordinate of the object layer in tiles.
|
||||
/// </summary>
|
||||
public int Y { get; set; } = 0;
|
||||
public uint Y { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// The width of the object layer in tiles. Meaningless.
|
||||
/// </summary>
|
||||
public int Width { get; set; } = 0;
|
||||
public uint Width { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// The height of the object layer in tiles. Meaningless.
|
||||
/// </summary>
|
||||
public int Height { get; set; } = 0;
|
||||
public uint Height { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// A color that is multiplied with any tile objects drawn by this layer.
|
||||
/// </summary>
|
||||
public Optional<TiledColor> Color { get; set; } = Optional<TiledColor>.Empty;
|
||||
public Optional<Color> Color { get; set; } = Optional<Color>.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Whether the objects are drawn according to the order of appearance (<see cref="DrawOrder.Index"/>) or sorted by their Y coordinate (<see cref="DrawOrder.TopDown"/>).
|
||||
|
|
|
@ -72,7 +72,7 @@ public class TextObject : Object
|
|||
/// <summary>
|
||||
/// The color of the text.
|
||||
/// </summary>
|
||||
public TiledColor Color { get; set; } = TiledColor.Parse("#000000", CultureInfo.InvariantCulture);
|
||||
public Color Color { get; set; } = Color.Parse("#000000", CultureInfo.InvariantCulture);
|
||||
|
||||
/// <summary>
|
||||
/// Whether the text is bold.
|
||||
|
|
|
@ -8,22 +8,22 @@ public class TileLayer : BaseLayer
|
|||
/// <summary>
|
||||
/// The X coordinate of the layer in tiles.
|
||||
/// </summary>
|
||||
public int X { get; set; } = 0;
|
||||
public uint X { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// The Y coordinate of the layer in tiles.
|
||||
/// </summary>
|
||||
public int Y { get; set; } = 0;
|
||||
public uint Y { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// The width of the layer in tiles. Always the same as the map width for fixed-size maps.
|
||||
/// </summary>
|
||||
public required int Width { get; set; }
|
||||
public required uint Width { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The height of the layer in tiles. Always the same as the map height for fixed-size maps.
|
||||
/// </summary>
|
||||
public required int Height { get; set; }
|
||||
public required uint Height { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The tile layer data.
|
||||
|
|
|
@ -126,27 +126,27 @@ public class Map : HasPropertiesBase
|
|||
/// <summary>
|
||||
/// The width of the map in tiles.
|
||||
/// </summary>
|
||||
public required int Width { get; set; }
|
||||
public required uint Width { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The height of the map in tiles.
|
||||
/// </summary>
|
||||
public required int Height { get; set; }
|
||||
public required uint Height { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The width of a tile.
|
||||
/// </summary>
|
||||
public required int TileWidth { get; set; }
|
||||
public required uint TileWidth { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The height of a tile.
|
||||
/// </summary>
|
||||
public required int TileHeight { get; set; }
|
||||
public required uint TileHeight { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Only for hexagonal maps. Determines the width or height (depending on the staggered axis) of the tile's edge, in pixels.
|
||||
/// </summary>
|
||||
public Optional<int> HexSideLength { get; set; } = Optional<int>.Empty;
|
||||
public Optional<uint> HexSideLength { get; set; } = Optional<uint>.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// For staggered and hexagonal maps, determines which axis (X or Y) is staggered.
|
||||
|
@ -171,7 +171,7 @@ public class Map : HasPropertiesBase
|
|||
/// <summary>
|
||||
/// The background color of the map.
|
||||
/// </summary>
|
||||
public TiledColor BackgroundColor { get; set; } = TiledColor.Parse("#00000000", CultureInfo.InvariantCulture);
|
||||
public Color BackgroundColor { get; set; } = Color.Parse("#00000000", CultureInfo.InvariantCulture);
|
||||
|
||||
/// <summary>
|
||||
/// Stores the next available ID for new layers. This number is used to prevent reuse of the same ID after layers have been removed.
|
||||
|
|
|
@ -3,7 +3,7 @@ namespace DotTiled;
|
|||
/// <summary>
|
||||
/// Represents a color property.
|
||||
/// </summary>
|
||||
public class ColorProperty : IProperty<Optional<TiledColor>>
|
||||
public class ColorProperty : IProperty<Optional<Color>>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public required string Name { get; set; }
|
||||
|
@ -14,7 +14,7 @@ public class ColorProperty : IProperty<Optional<TiledColor>>
|
|||
/// <summary>
|
||||
/// The color value of the property.
|
||||
/// </summary>
|
||||
public required Optional<TiledColor> Value { get; set; }
|
||||
public required Optional<Color> Value { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public IProperty Clone() => new ColorProperty
|
||||
|
|
|
@ -78,7 +78,7 @@ public class CustomClassDefinition : HasPropertiesBase, ICustomTypeDefinition
|
|||
/// <summary>
|
||||
/// The color of the custom class inside the Tiled editor.
|
||||
/// </summary>
|
||||
public TiledColor Color { get; set; }
|
||||
public Color Color { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 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(TiledColor):
|
||||
return new ColorProperty { Name = propertyInfo.Name, Value = (TiledColor)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(float):
|
||||
return new FloatProperty { Name = propertyInfo.Name, Value = (float)propertyInfo.GetValue(instance) };
|
||||
case Type t when t == typeof(string):
|
||||
|
|
|
@ -23,8 +23,8 @@ public abstract partial class TmjReaderBase
|
|||
|
||||
var x = element.GetRequiredProperty<int>("x");
|
||||
var y = element.GetRequiredProperty<int>("y");
|
||||
var width = element.GetRequiredProperty<int>("width");
|
||||
var height = element.GetRequiredProperty<int>("height");
|
||||
var width = element.GetRequiredProperty<uint>("width");
|
||||
var height = element.GetRequiredProperty<uint>("height");
|
||||
|
||||
return new Chunk
|
||||
{
|
||||
|
|
|
@ -12,7 +12,7 @@ public abstract partial class TmjReaderBase
|
|||
var @class = element.GetOptionalProperty<string>("class").GetValueOr("");
|
||||
var opacity = element.GetOptionalProperty<float>("opacity").GetValueOr(1.0f);
|
||||
var visible = element.GetOptionalProperty<bool>("visible").GetValueOr(true);
|
||||
var tintColor = element.GetOptionalPropertyParseable<TiledColor>("tintcolor");
|
||||
var tintColor = element.GetOptionalPropertyParseable<Color>("tintcolor");
|
||||
var offsetX = element.GetOptionalProperty<float>("offsetx").GetValueOr(0.0f);
|
||||
var offsetY = element.GetOptionalProperty<float>("offsety").GetValueOr(0.0f);
|
||||
var parallaxX = element.GetOptionalProperty<float>("parallaxx").GetValueOr(1.0f);
|
||||
|
|
|
@ -11,7 +11,7 @@ public abstract partial class TmjReaderBase
|
|||
var @class = element.GetOptionalProperty<string>("class").GetValueOr("");
|
||||
var opacity = element.GetOptionalProperty<float>("opacity").GetValueOr(1.0f);
|
||||
var visible = element.GetOptionalProperty<bool>("visible").GetValueOr(true);
|
||||
var tintColor = element.GetOptionalPropertyParseable<TiledColor>("tintcolor");
|
||||
var tintColor = element.GetOptionalPropertyParseable<Color>("tintcolor");
|
||||
var offsetX = element.GetOptionalProperty<float>("offsetx").GetValueOr(0.0f);
|
||||
var offsetY = element.GetOptionalProperty<float>("offsety").GetValueOr(0.0f);
|
||||
var parallaxX = element.GetOptionalProperty<float>("parallaxx").GetValueOr(1.0f);
|
||||
|
@ -19,19 +19,17 @@ public abstract partial class TmjReaderBase
|
|||
var properties = ResolveAndMergeProperties(@class, element.GetOptionalPropertyCustom("properties", ReadProperties).GetValueOr([]));
|
||||
|
||||
var image = element.GetRequiredProperty<string>("image");
|
||||
var imageWidth = element.GetOptionalProperty<int>("imagewidth").GetValueOr(0);
|
||||
var imageHeight = element.GetOptionalProperty<int>("imageheight").GetValueOr(0);
|
||||
var repeatX = element.GetOptionalProperty<bool>("repeatx").GetValueOr(false);
|
||||
var repeatY = element.GetOptionalProperty<bool>("repeaty").GetValueOr(false);
|
||||
var transparentColor = element.GetOptionalPropertyParseable<TiledColor>("transparentcolor");
|
||||
var x = element.GetOptionalProperty<int>("x").GetValueOr(0);
|
||||
var y = element.GetOptionalProperty<int>("y").GetValueOr(0);
|
||||
var transparentColor = element.GetOptionalPropertyParseable<Color>("transparentcolor");
|
||||
var x = element.GetOptionalProperty<uint>("x").GetValueOr(0);
|
||||
var y = element.GetOptionalProperty<uint>("y").GetValueOr(0);
|
||||
|
||||
var imgModel = new Image
|
||||
{
|
||||
Format = Helpers.ParseImageFormatFromSource(image),
|
||||
Height = imageHeight,
|
||||
Width = imageWidth,
|
||||
Height = 0,
|
||||
Width = 0,
|
||||
Source = image,
|
||||
TransparentColor = transparentColor
|
||||
};
|
||||
|
|
|
@ -28,11 +28,11 @@ public abstract partial class TmjReaderBase
|
|||
_ => throw new JsonException($"Unknown render order '{s}'")
|
||||
}).GetValueOr(RenderOrder.RightDown);
|
||||
var compressionLevel = element.GetOptionalProperty<int>("compressionlevel").GetValueOr(-1);
|
||||
var width = element.GetRequiredProperty<int>("width");
|
||||
var height = element.GetRequiredProperty<int>("height");
|
||||
var tileWidth = element.GetRequiredProperty<int>("tilewidth");
|
||||
var tileHeight = element.GetRequiredProperty<int>("tileheight");
|
||||
var hexSideLength = element.GetOptionalProperty<int>("hexsidelength");
|
||||
var width = element.GetRequiredProperty<uint>("width");
|
||||
var height = element.GetRequiredProperty<uint>("height");
|
||||
var tileWidth = element.GetRequiredProperty<uint>("tilewidth");
|
||||
var tileHeight = element.GetRequiredProperty<uint>("tileheight");
|
||||
var hexSideLength = element.GetOptionalProperty<uint>("hexsidelength");
|
||||
var staggerAxis = element.GetOptionalPropertyParseable<StaggerAxis>("staggeraxis", s => s switch
|
||||
{
|
||||
"x" => StaggerAxis.X,
|
||||
|
@ -47,7 +47,7 @@ public abstract partial class TmjReaderBase
|
|||
});
|
||||
var parallaxOriginX = element.GetOptionalProperty<float>("parallaxoriginx").GetValueOr(0f);
|
||||
var parallaxOriginY = element.GetOptionalProperty<float>("parallaxoriginy").GetValueOr(0f);
|
||||
var backgroundColor = element.GetOptionalPropertyParseable<TiledColor>("backgroundcolor").GetValueOr(TiledColor.Parse("#00000000", CultureInfo.InvariantCulture));
|
||||
var backgroundColor = element.GetOptionalPropertyParseable<Color>("backgroundcolor").GetValueOr(Color.Parse("#00000000", CultureInfo.InvariantCulture));
|
||||
var nextLayerID = element.GetRequiredProperty<uint>("nextlayerid");
|
||||
var nextObjectID = element.GetRequiredProperty<uint>("nextobjectid");
|
||||
var infinite = element.GetOptionalProperty<bool>("infinite").GetValueOr(false);
|
||||
|
|
|
@ -15,18 +15,18 @@ public abstract partial class TmjReaderBase
|
|||
var @class = element.GetOptionalProperty<string>("class").GetValueOr("");
|
||||
var opacity = element.GetOptionalProperty<float>("opacity").GetValueOr(1.0f);
|
||||
var visible = element.GetOptionalProperty<bool>("visible").GetValueOr(true);
|
||||
var tintColor = element.GetOptionalPropertyParseable<TiledColor>("tintcolor");
|
||||
var tintColor = element.GetOptionalPropertyParseable<Color>("tintcolor");
|
||||
var offsetX = element.GetOptionalProperty<float>("offsetx").GetValueOr(0.0f);
|
||||
var offsetY = element.GetOptionalProperty<float>("offsety").GetValueOr(0.0f);
|
||||
var parallaxX = element.GetOptionalProperty<float>("parallaxx").GetValueOr(1.0f);
|
||||
var parallaxY = element.GetOptionalProperty<float>("parallaxy").GetValueOr(1.0f);
|
||||
var properties = ResolveAndMergeProperties(@class, element.GetOptionalPropertyCustom("properties", ReadProperties).GetValueOr([]));
|
||||
|
||||
var x = element.GetOptionalProperty<int>("x").GetValueOr(0);
|
||||
var y = element.GetOptionalProperty<int>("y").GetValueOr(0);
|
||||
var width = element.GetOptionalProperty<int>("width").GetValueOr(0);
|
||||
var height = element.GetOptionalProperty<int>("height").GetValueOr(0);
|
||||
var color = element.GetOptionalPropertyParseable<TiledColor>("color");
|
||||
var x = element.GetOptionalProperty<uint>("x").GetValueOr(0);
|
||||
var y = element.GetOptionalProperty<uint>("y").GetValueOr(0);
|
||||
var width = element.GetOptionalProperty<uint>("width").GetValueOr(0);
|
||||
var height = element.GetOptionalProperty<uint>("height").GetValueOr(0);
|
||||
var color = element.GetOptionalPropertyParseable<Color>("color");
|
||||
var drawOrder = element.GetOptionalPropertyParseable<DrawOrder>("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<bool>("bold").GetValueOr(false);
|
||||
var color = element.GetOptionalPropertyParseable<TiledColor>("color").GetValueOr(TiledColor.Parse("#00000000", CultureInfo.InvariantCulture));
|
||||
var color = element.GetOptionalPropertyParseable<Color>("color").GetValueOr(Color.Parse("#00000000", CultureInfo.InvariantCulture));
|
||||
var fontfamily = element.GetOptionalProperty<string>("fontfamily").GetValueOr("sans-serif");
|
||||
var halign = element.GetOptionalPropertyParseable<TextHorizontalAlignment>("halign", s => s switch
|
||||
{
|
||||
|
|
|
@ -36,7 +36,7 @@ public abstract partial class TmjReaderBase
|
|||
PropertyType.Int => new IntProperty { Name = name, Value = e.GetRequiredProperty<int>("value") },
|
||||
PropertyType.Float => new FloatProperty { Name = name, Value = e.GetRequiredProperty<float>("value") },
|
||||
PropertyType.Bool => new BoolProperty { Name = name, Value = e.GetRequiredProperty<bool>("value") },
|
||||
PropertyType.Color => new ColorProperty { Name = name, Value = e.GetRequiredPropertyParseable<TiledColor>("value", s => s == "" ? default : TiledColor.Parse(s, CultureInfo.InvariantCulture)) },
|
||||
PropertyType.Color => new ColorProperty { Name = name, Value = e.GetRequiredPropertyParseable<Color>("value", s => s == "" ? default : Color.Parse(s, CultureInfo.InvariantCulture)) },
|
||||
PropertyType.File => new FileProperty { Name = name, Value = e.GetRequiredProperty<string>("value") },
|
||||
PropertyType.Object => new ObjectProperty { Name = name, Value = e.GetRequiredProperty<uint>("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<int>() },
|
||||
PropertyType.Float => new FloatProperty { Name = prop.Name, Value = propElement.GetValueAs<float>() },
|
||||
PropertyType.Bool => new BoolProperty { Name = prop.Name, Value = propElement.GetValueAs<bool>() },
|
||||
PropertyType.Color => new ColorProperty { Name = prop.Name, Value = TiledColor.Parse(propElement.GetValueAs<string>(), CultureInfo.InvariantCulture) },
|
||||
PropertyType.Color => new ColorProperty { Name = prop.Name, Value = Color.Parse(propElement.GetValueAs<string>(), CultureInfo.InvariantCulture) },
|
||||
PropertyType.File => new FileProperty { Name = prop.Name, Value = propElement.GetValueAs<string>() },
|
||||
PropertyType.Object => new ObjectProperty { Name = prop.Name, Value = propElement.GetValueAs<uint>() },
|
||||
PropertyType.Enum => ReadEnumProperty(propElement),
|
||||
|
|
|
@ -22,7 +22,7 @@ public abstract partial class TmjReaderBase
|
|||
var chunks = element.GetOptionalPropertyCustom<Data>("chunks", e => ReadDataAsChunks(e, compression, encoding));
|
||||
var @class = element.GetOptionalProperty<string>("class").GetValueOr("");
|
||||
var data = element.GetOptionalPropertyCustom<Data>("data", e => ReadDataWithoutChunks(e, compression, encoding));
|
||||
var height = element.GetRequiredProperty<int>("height");
|
||||
var height = element.GetRequiredProperty<uint>("height");
|
||||
var id = element.GetRequiredProperty<uint>("id");
|
||||
var name = element.GetRequiredProperty<string>("name");
|
||||
var offsetX = element.GetOptionalProperty<float>("offsetx").GetValueOr(0.0f);
|
||||
|
@ -35,12 +35,12 @@ public abstract partial class TmjReaderBase
|
|||
var repeatY = element.GetOptionalProperty<bool>("repeaty").GetValueOr(false);
|
||||
var startX = element.GetOptionalProperty<int>("startx").GetValueOr(0);
|
||||
var startY = element.GetOptionalProperty<int>("starty").GetValueOr(0);
|
||||
var tintColor = element.GetOptionalPropertyParseable<TiledColor>("tintcolor");
|
||||
var transparentColor = element.GetOptionalPropertyParseable<TiledColor>("transparentcolor");
|
||||
var tintColor = element.GetOptionalPropertyParseable<Color>("tintcolor");
|
||||
var transparentColor = element.GetOptionalPropertyParseable<Color>("transparentcolor");
|
||||
var visible = element.GetOptionalProperty<bool>("visible").GetValueOr(true);
|
||||
var width = element.GetRequiredProperty<int>("width");
|
||||
var x = element.GetRequiredProperty<int>("x");
|
||||
var y = element.GetRequiredProperty<int>("y");
|
||||
var width = element.GetRequiredProperty<uint>("width");
|
||||
var x = element.GetRequiredProperty<uint>("x");
|
||||
var y = element.GetRequiredProperty<uint>("y");
|
||||
|
||||
if (!data.HasValue && !chunks.HasValue)
|
||||
throw new JsonException("Tile layer does not contain data.");
|
||||
|
|
|
@ -10,9 +10,9 @@ public abstract partial class TmjReaderBase
|
|||
Optional<string> parentVersion = null,
|
||||
Optional<string> parentTiledVersion = null)
|
||||
{
|
||||
var backgroundColor = element.GetOptionalPropertyParseable<TiledColor>("backgroundcolor");
|
||||
var backgroundColor = element.GetOptionalPropertyParseable<Color>("backgroundcolor");
|
||||
var @class = element.GetOptionalProperty<string>("class").GetValueOr("");
|
||||
var columns = element.GetOptionalProperty<int>("columns");
|
||||
var columns = element.GetOptionalProperty<uint>("columns");
|
||||
var fillMode = element.GetOptionalPropertyParseable<FillMode>("fillmode", s => s switch
|
||||
{
|
||||
"stretch" => FillMode.Stretch,
|
||||
|
@ -22,9 +22,9 @@ public abstract partial class TmjReaderBase
|
|||
var firstGID = element.GetOptionalProperty<uint>("firstgid");
|
||||
var grid = element.GetOptionalPropertyCustom<Grid>("grid", ReadGrid);
|
||||
var image = element.GetOptionalProperty<string>("image");
|
||||
var imageHeight = element.GetOptionalProperty<int>("imageheight");
|
||||
var imageWidth = element.GetOptionalProperty<int>("imagewidth");
|
||||
var margin = element.GetOptionalProperty<int>("margin");
|
||||
var imageHeight = element.GetOptionalProperty<uint>("imageheight");
|
||||
var imageWidth = element.GetOptionalProperty<uint>("imagewidth");
|
||||
var margin = element.GetOptionalProperty<uint>("margin");
|
||||
var name = element.GetOptionalProperty<string>("name");
|
||||
var objectAlignment = element.GetOptionalPropertyParseable<ObjectAlignment>("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<string>("source");
|
||||
var spacing = element.GetOptionalProperty<int>("spacing");
|
||||
var tileCount = element.GetOptionalProperty<int>("tilecount");
|
||||
var spacing = element.GetOptionalProperty<uint>("spacing");
|
||||
var tileCount = element.GetOptionalProperty<uint>("tilecount");
|
||||
var tiledVersion = element.GetOptionalProperty<string>("tiledversion").GetValueOrOptional(parentTiledVersion);
|
||||
var tileHeight = element.GetOptionalProperty<int>("tileheight");
|
||||
var tileHeight = element.GetOptionalProperty<uint>("tileheight");
|
||||
var tileOffset = element.GetOptionalPropertyCustom<TileOffset>("tileoffset", ReadTileOffset);
|
||||
var tileRenderSize = element.GetOptionalPropertyParseable<TileRenderSize>("tilerendersize", s => s switch
|
||||
{
|
||||
|
@ -54,8 +54,9 @@ public abstract partial class TmjReaderBase
|
|||
_ => throw new JsonException($"Unknown tile render size '{s}'")
|
||||
}).GetValueOr(TileRenderSize.Tile);
|
||||
var tiles = element.GetOptionalPropertyCustom<List<Tile>>("tiles", ReadTiles).GetValueOr([]);
|
||||
var tileWidth = element.GetOptionalProperty<int>("tilewidth");
|
||||
var transparentColor = element.GetOptionalPropertyParseable<TiledColor>("transparentcolor");
|
||||
var tileWidth = element.GetOptionalProperty<uint>("tilewidth");
|
||||
var transparentColor = element.GetOptionalPropertyParseable<Color>("transparentcolor");
|
||||
var type = element.GetOptionalProperty<string>("type");
|
||||
var version = element.GetOptionalProperty<string>("version").GetValueOrOptional(parentVersion);
|
||||
var transformations = element.GetOptionalPropertyCustom<Transformations>("transformations", ReadTransformations);
|
||||
var wangsets = element.GetOptionalPropertyCustom<List<Wangset>>("wangsets", el => el.GetValueAsList<Wangset>(e => ReadWangset(e))).GetValueOr([]);
|
||||
|
@ -128,8 +129,8 @@ public abstract partial class TmjReaderBase
|
|||
"isometric" => GridOrientation.Isometric,
|
||||
_ => throw new JsonException($"Unknown grid orientation '{s}'")
|
||||
}).GetValueOr(GridOrientation.Orthogonal);
|
||||
var height = element.GetRequiredProperty<int>("height");
|
||||
var width = element.GetRequiredProperty<int>("width");
|
||||
var height = element.GetRequiredProperty<uint>("height");
|
||||
var width = element.GetRequiredProperty<uint>("width");
|
||||
|
||||
return new Grid
|
||||
{
|
||||
|
@ -157,12 +158,12 @@ public abstract partial class TmjReaderBase
|
|||
var animation = e.GetOptionalPropertyCustom<List<Frame>>("animation", e => e.GetValueAsList<Frame>(ReadFrame)).GetValueOr([]);
|
||||
var id = e.GetRequiredProperty<uint>("id");
|
||||
var image = e.GetOptionalProperty<string>("image");
|
||||
var imageHeight = e.GetOptionalProperty<int>("imageheight");
|
||||
var imageWidth = e.GetOptionalProperty<int>("imagewidth");
|
||||
var x = e.GetOptionalProperty<int>("x").GetValueOr(0);
|
||||
var y = e.GetOptionalProperty<int>("y").GetValueOr(0);
|
||||
var width = e.GetOptionalProperty<int>("width").GetValueOr(imageWidth.GetValueOr(0));
|
||||
var height = e.GetOptionalProperty<int>("height").GetValueOr(imageHeight.GetValueOr(0));
|
||||
var imageHeight = e.GetOptionalProperty<uint>("imageheight");
|
||||
var imageWidth = e.GetOptionalProperty<uint>("imagewidth");
|
||||
var x = e.GetOptionalProperty<uint>("x").GetValueOr(0);
|
||||
var y = e.GetOptionalProperty<uint>("y").GetValueOr(0);
|
||||
var width = e.GetOptionalProperty<uint>("width").GetValueOr(imageWidth.GetValueOr(0));
|
||||
var height = e.GetOptionalProperty<uint>("height").GetValueOr(imageHeight.GetValueOr(0));
|
||||
var objectGroup = e.GetOptionalPropertyCustom<ObjectLayer>("objectgroup", e => ReadObjectLayer(e));
|
||||
var probability = e.GetOptionalProperty<float>("probability").GetValueOr(0.0f);
|
||||
var type = e.GetOptionalProperty<string>("type").GetValueOr("");
|
||||
|
@ -194,7 +195,7 @@ public abstract partial class TmjReaderBase
|
|||
|
||||
internal static Frame ReadFrame(JsonElement element)
|
||||
{
|
||||
var duration = element.GetRequiredProperty<int>("duration");
|
||||
var duration = element.GetRequiredProperty<uint>("duration");
|
||||
var tileID = element.GetRequiredProperty<uint>("tileid");
|
||||
|
||||
return new Frame
|
||||
|
@ -228,7 +229,7 @@ public abstract partial class TmjReaderBase
|
|||
internal WangColor ReadWangColor(JsonElement element)
|
||||
{
|
||||
var @class = element.GetOptionalProperty<string>("class").GetValueOr("");
|
||||
var color = element.GetRequiredPropertyParseable<TiledColor>("color");
|
||||
var color = element.GetRequiredPropertyParseable<Color>("color");
|
||||
var name = element.GetRequiredProperty<string>("name");
|
||||
var probability = element.GetOptionalProperty<float>("probability").GetValueOr(1.0f);
|
||||
var properties = ResolveAndMergeProperties(@class, element.GetOptionalPropertyCustom("properties", ReadProperties).GetValueOr([]));
|
||||
|
|
|
@ -6,8 +6,8 @@ public abstract partial class TmxReaderBase
|
|||
{
|
||||
var x = _reader.GetRequiredAttributeParseable<int>("x");
|
||||
var y = _reader.GetRequiredAttributeParseable<int>("y");
|
||||
var width = _reader.GetRequiredAttributeParseable<int>("width");
|
||||
var height = _reader.GetRequiredAttributeParseable<int>("height");
|
||||
var width = _reader.GetRequiredAttributeParseable<uint>("width");
|
||||
var height = _reader.GetRequiredAttributeParseable<uint>("height");
|
||||
|
||||
var usesTileChildrenInsteadOfRawData = !encoding.HasValue;
|
||||
if (usesTileChildrenInsteadOfRawData)
|
||||
|
|
|
@ -32,11 +32,11 @@ public abstract partial class TmxReaderBase
|
|||
_ => throw new InvalidOperationException($"Unknown render order '{s}'")
|
||||
}).GetValueOr(RenderOrder.RightDown);
|
||||
var compressionLevel = _reader.GetOptionalAttributeParseable<int>("compressionlevel").GetValueOr(-1);
|
||||
var width = _reader.GetRequiredAttributeParseable<int>("width");
|
||||
var height = _reader.GetRequiredAttributeParseable<int>("height");
|
||||
var tileWidth = _reader.GetRequiredAttributeParseable<int>("tilewidth");
|
||||
var tileHeight = _reader.GetRequiredAttributeParseable<int>("tileheight");
|
||||
var hexSideLength = _reader.GetOptionalAttributeParseable<int>("hexsidelength");
|
||||
var width = _reader.GetRequiredAttributeParseable<uint>("width");
|
||||
var height = _reader.GetRequiredAttributeParseable<uint>("height");
|
||||
var tileWidth = _reader.GetRequiredAttributeParseable<uint>("tilewidth");
|
||||
var tileHeight = _reader.GetRequiredAttributeParseable<uint>("tileheight");
|
||||
var hexSideLength = _reader.GetOptionalAttributeParseable<uint>("hexsidelength");
|
||||
var staggerAxis = _reader.GetOptionalAttributeEnum<StaggerAxis>("staggeraxis", s => s switch
|
||||
{
|
||||
"x" => StaggerAxis.X,
|
||||
|
@ -51,7 +51,7 @@ public abstract partial class TmxReaderBase
|
|||
});
|
||||
var parallaxOriginX = _reader.GetOptionalAttributeParseable<float>("parallaxoriginx").GetValueOr(0.0f);
|
||||
var parallaxOriginY = _reader.GetOptionalAttributeParseable<float>("parallaxoriginy").GetValueOr(0.0f);
|
||||
var backgroundColor = _reader.GetOptionalAttributeClass<TiledColor>("backgroundcolor").GetValueOr(TiledColor.Parse("#00000000", CultureInfo.InvariantCulture));
|
||||
var backgroundColor = _reader.GetOptionalAttributeClass<Color>("backgroundcolor").GetValueOr(Color.Parse("#00000000", CultureInfo.InvariantCulture));
|
||||
var nextLayerID = _reader.GetRequiredAttributeParseable<uint>("nextlayerid");
|
||||
var nextObjectID = _reader.GetRequiredAttributeParseable<uint>("nextobjectid");
|
||||
var infinite = _reader.GetOptionalAttributeParseable<uint>("infinite").GetValueOr(0) == 1;
|
||||
|
|
|
@ -14,18 +14,18 @@ public abstract partial class TmxReaderBase
|
|||
var id = _reader.GetRequiredAttributeParseable<uint>("id");
|
||||
var name = _reader.GetOptionalAttribute("name").GetValueOr("");
|
||||
var @class = _reader.GetOptionalAttribute("class").GetValueOr("");
|
||||
var x = _reader.GetOptionalAttributeParseable<int>("x").GetValueOr(0);
|
||||
var y = _reader.GetOptionalAttributeParseable<int>("y").GetValueOr(0);
|
||||
var width = _reader.GetOptionalAttributeParseable<int>("width").GetValueOr(0);
|
||||
var height = _reader.GetOptionalAttributeParseable<int>("height").GetValueOr(0);
|
||||
var x = _reader.GetOptionalAttributeParseable<uint>("x").GetValueOr(0);
|
||||
var y = _reader.GetOptionalAttributeParseable<uint>("y").GetValueOr(0);
|
||||
var width = _reader.GetOptionalAttributeParseable<uint>("width").GetValueOr(0);
|
||||
var height = _reader.GetOptionalAttributeParseable<uint>("height").GetValueOr(0);
|
||||
var opacity = _reader.GetOptionalAttributeParseable<float>("opacity").GetValueOr(1.0f);
|
||||
var visible = _reader.GetOptionalAttributeParseable<uint>("visible").GetValueOr(1) == 1;
|
||||
var tintColor = _reader.GetOptionalAttributeClass<TiledColor>("tintcolor");
|
||||
var tintColor = _reader.GetOptionalAttributeClass<Color>("tintcolor");
|
||||
var offsetX = _reader.GetOptionalAttributeParseable<float>("offsetx").GetValueOr(0.0f);
|
||||
var offsetY = _reader.GetOptionalAttributeParseable<float>("offsety").GetValueOr(0.0f);
|
||||
var parallaxX = _reader.GetOptionalAttributeParseable<float>("parallaxx").GetValueOr(1.0f);
|
||||
var parallaxY = _reader.GetOptionalAttributeParseable<float>("parallaxy").GetValueOr(1.0f);
|
||||
var color = _reader.GetOptionalAttributeClass<TiledColor>("color");
|
||||
var color = _reader.GetOptionalAttributeClass<Color>("color");
|
||||
var drawOrder = _reader.GetOptionalAttributeEnum<DrawOrder>("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<int>("pixelsize") ?? 16;
|
||||
var wrap = _reader.GetOptionalAttributeParseable<bool>("wrap") ?? false;
|
||||
var color = _reader.GetOptionalAttributeClass<TiledColor>("color") ?? TiledColor.Parse("#000000", CultureInfo.InvariantCulture);
|
||||
var color = _reader.GetOptionalAttributeClass<Color>("color") ?? Color.Parse("#000000", CultureInfo.InvariantCulture);
|
||||
var bold = _reader.GetOptionalAttributeParseable<bool>("bold") ?? false;
|
||||
var italic = _reader.GetOptionalAttributeParseable<bool>("italic") ?? false;
|
||||
var underline = _reader.GetOptionalAttributeParseable<bool>("underline") ?? false;
|
||||
|
|
|
@ -45,7 +45,7 @@ public abstract partial class TmxReaderBase
|
|||
PropertyType.Int => new IntProperty { Name = name, Value = r.GetRequiredAttributeParseable<int>("value") },
|
||||
PropertyType.Float => new FloatProperty { Name = name, Value = r.GetRequiredAttributeParseable<float>("value") },
|
||||
PropertyType.Bool => new BoolProperty { Name = name, Value = r.GetRequiredAttributeParseable<bool>("value") },
|
||||
PropertyType.Color => new ColorProperty { Name = name, Value = r.GetRequiredAttributeParseable<TiledColor>("value", s => s == "" ? default : TiledColor.Parse(s, CultureInfo.InvariantCulture)) },
|
||||
PropertyType.Color => new ColorProperty { Name = name, Value = r.GetRequiredAttributeParseable<Color>("value", s => s == "" ? default : Color.Parse(s, CultureInfo.InvariantCulture)) },
|
||||
PropertyType.File => new FileProperty { Name = name, Value = r.GetRequiredAttribute("value") },
|
||||
PropertyType.Object => new ObjectProperty { Name = name, Value = r.GetRequiredAttributeParseable<uint>("value") },
|
||||
PropertyType.Class => throw new XmlException("Class property must have a property type"),
|
||||
|
|
|
@ -10,13 +10,13 @@ public abstract partial class TmxReaderBase
|
|||
var id = _reader.GetRequiredAttributeParseable<uint>("id");
|
||||
var name = _reader.GetOptionalAttribute("name").GetValueOr("");
|
||||
var @class = _reader.GetOptionalAttribute("class").GetValueOr("");
|
||||
var x = _reader.GetOptionalAttributeParseable<int>("x").GetValueOr(0);
|
||||
var y = _reader.GetOptionalAttributeParseable<int>("y").GetValueOr(0);
|
||||
var width = _reader.GetRequiredAttributeParseable<int>("width");
|
||||
var height = _reader.GetRequiredAttributeParseable<int>("height");
|
||||
var x = _reader.GetOptionalAttributeParseable<uint>("x").GetValueOr(0);
|
||||
var y = _reader.GetOptionalAttributeParseable<uint>("y").GetValueOr(0);
|
||||
var width = _reader.GetRequiredAttributeParseable<uint>("width");
|
||||
var height = _reader.GetRequiredAttributeParseable<uint>("height");
|
||||
var opacity = _reader.GetOptionalAttributeParseable<float>("opacity").GetValueOr(1.0f);
|
||||
var visible = _reader.GetOptionalAttributeParseable<uint>("visible").GetValueOr(1) == 1;
|
||||
var tintColor = _reader.GetOptionalAttributeClass<TiledColor>("tintcolor");
|
||||
var tintColor = _reader.GetOptionalAttributeClass<Color>("tintcolor");
|
||||
var offsetX = _reader.GetOptionalAttributeParseable<float>("offsetx").GetValueOr(0.0f);
|
||||
var offsetY = _reader.GetOptionalAttributeParseable<float>("offsety").GetValueOr(0.0f);
|
||||
var parallaxX = _reader.GetOptionalAttributeParseable<float>("parallaxx").GetValueOr(1.0f);
|
||||
|
@ -59,11 +59,11 @@ public abstract partial class TmxReaderBase
|
|||
var id = _reader.GetRequiredAttributeParseable<uint>("id");
|
||||
var name = _reader.GetOptionalAttribute("name").GetValueOr("");
|
||||
var @class = _reader.GetOptionalAttribute("class").GetValueOr("");
|
||||
var x = _reader.GetOptionalAttributeParseable<int>("x").GetValueOr(0);
|
||||
var y = _reader.GetOptionalAttributeParseable<int>("y").GetValueOr(0);
|
||||
var x = _reader.GetOptionalAttributeParseable<uint>("x").GetValueOr(0);
|
||||
var y = _reader.GetOptionalAttributeParseable<uint>("y").GetValueOr(0);
|
||||
var opacity = _reader.GetOptionalAttributeParseable<float>("opacity").GetValueOr(1f);
|
||||
var visible = _reader.GetOptionalAttributeParseable<bool>("visible").GetValueOr(true);
|
||||
var tintColor = _reader.GetOptionalAttributeClass<TiledColor>("tintcolor");
|
||||
var tintColor = _reader.GetOptionalAttributeClass<Color>("tintcolor");
|
||||
var offsetX = _reader.GetOptionalAttributeParseable<float>("offsetx").GetValueOr(0.0f);
|
||||
var offsetY = _reader.GetOptionalAttributeParseable<float>("offsety").GetValueOr(0.0f);
|
||||
var parallaxX = _reader.GetOptionalAttributeParseable<float>("parallaxx").GetValueOr(1.0f);
|
||||
|
@ -110,7 +110,7 @@ public abstract partial class TmxReaderBase
|
|||
var @class = _reader.GetOptionalAttribute("class").GetValueOr("");
|
||||
var opacity = _reader.GetOptionalAttributeParseable<float>("opacity").GetValueOr(1.0f);
|
||||
var visible = _reader.GetOptionalAttributeParseable<uint>("visible").GetValueOr(1) == 1;
|
||||
var tintColor = _reader.GetOptionalAttributeClass<TiledColor>("tintcolor");
|
||||
var tintColor = _reader.GetOptionalAttributeClass<Color>("tintcolor");
|
||||
var offsetX = _reader.GetOptionalAttributeParseable<float>("offsetx").GetValueOr(0f);
|
||||
var offsetY = _reader.GetOptionalAttributeParseable<float>("offsety").GetValueOr(0f);
|
||||
var parallaxX = _reader.GetOptionalAttributeParseable<float>("parallaxx").GetValueOr(1f);
|
||||
|
|
|
@ -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<int>("tilewidth");
|
||||
var tileHeight = _reader.GetRequiredAttributeParseable<int>("tileheight");
|
||||
var spacing = _reader.GetOptionalAttributeParseable<int>("spacing").GetValueOr(0);
|
||||
var margin = _reader.GetOptionalAttributeParseable<int>("margin").GetValueOr(0);
|
||||
var tileCount = _reader.GetRequiredAttributeParseable<int>("tilecount");
|
||||
var columns = _reader.GetRequiredAttributeParseable<int>("columns");
|
||||
var tileWidth = _reader.GetRequiredAttributeParseable<uint>("tilewidth");
|
||||
var tileHeight = _reader.GetRequiredAttributeParseable<uint>("tileheight");
|
||||
var spacing = _reader.GetOptionalAttributeParseable<uint>("spacing").GetValueOr(0);
|
||||
var margin = _reader.GetOptionalAttributeParseable<uint>("margin").GetValueOr(0);
|
||||
var tileCount = _reader.GetRequiredAttributeParseable<uint>("tilecount");
|
||||
var columns = _reader.GetRequiredAttributeParseable<uint>("columns");
|
||||
var objectAlignment = _reader.GetOptionalAttributeEnum<ObjectAlignment>("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<TiledColor>("trans");
|
||||
var width = _reader.GetOptionalAttributeParseable<int>("width");
|
||||
var height = _reader.GetOptionalAttributeParseable<int>("height");
|
||||
var transparentColor = _reader.GetOptionalAttributeClass<Color>("trans");
|
||||
var width = _reader.GetOptionalAttributeParseable<uint>("width");
|
||||
var height = _reader.GetOptionalAttributeParseable<uint>("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<int>("width");
|
||||
var height = _reader.GetRequiredAttributeParseable<int>("height");
|
||||
var width = _reader.GetRequiredAttributeParseable<uint>("width");
|
||||
var height = _reader.GetRequiredAttributeParseable<uint>("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<uint>("id");
|
||||
var type = _reader.GetOptionalAttribute("type").GetValueOr("");
|
||||
var probability = _reader.GetOptionalAttributeParseable<float>("probability").GetValueOr(0f);
|
||||
var x = _reader.GetOptionalAttributeParseable<int>("x").GetValueOr(0);
|
||||
var y = _reader.GetOptionalAttributeParseable<int>("y").GetValueOr(0);
|
||||
var width = _reader.GetOptionalAttributeParseable<int>("width");
|
||||
var height = _reader.GetOptionalAttributeParseable<int>("height");
|
||||
var x = _reader.GetOptionalAttributeParseable<uint>("x").GetValueOr(0);
|
||||
var y = _reader.GetOptionalAttributeParseable<uint>("y").GetValueOr(0);
|
||||
var width = _reader.GetOptionalAttributeParseable<uint>("width");
|
||||
var height = _reader.GetOptionalAttributeParseable<uint>("height");
|
||||
|
||||
// Elements
|
||||
var propertiesCounter = 0;
|
||||
|
@ -212,7 +212,7 @@ public abstract partial class TmxReaderBase
|
|||
"animation" => () => Helpers.SetAtMostOnce(ref animation, r.ReadList<Frame>("animation", "frame", (ar) =>
|
||||
{
|
||||
var tileID = ar.GetRequiredAttributeParseable<uint>("tileid");
|
||||
var duration = ar.GetRequiredAttributeParseable<int>("duration");
|
||||
var duration = ar.GetRequiredAttributeParseable<uint>("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<TiledColor>("color");
|
||||
var color = _reader.GetRequiredAttributeParseable<Color>("color");
|
||||
var tile = _reader.GetRequiredAttributeParseable<int>("tile");
|
||||
var probability = _reader.GetOptionalAttributeParseable<float>("probability").GetValueOr(0f);
|
||||
|
||||
|
|
|
@ -13,5 +13,5 @@ public class Frame
|
|||
/// <summary>
|
||||
/// How long (in milliseconds) this frame should be displayed before advancing to the next frame.
|
||||
/// </summary>
|
||||
public required int Duration { get; set; }
|
||||
public required uint Duration { get; set; }
|
||||
}
|
||||
|
|
|
@ -29,10 +29,10 @@ public class Grid
|
|||
/// <summary>
|
||||
/// Width of a grid cell.
|
||||
/// </summary>
|
||||
public required int Width { get; set; }
|
||||
public required uint Width { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Height of a grid cell.
|
||||
/// </summary>
|
||||
public required int Height { get; set; }
|
||||
public required uint Height { get; set; }
|
||||
}
|
||||
|
|
|
@ -44,15 +44,15 @@ public class Image
|
|||
/// <summary>
|
||||
/// Defines a specific color that is treated as transparent.
|
||||
/// </summary>
|
||||
public Optional<TiledColor> TransparentColor { get; set; } = Optional<TiledColor>.Empty;
|
||||
public Optional<Color> TransparentColor { get; set; } = Optional<Color>.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// The image width in pixels, used for tile index correction when the image changes.
|
||||
/// </summary>
|
||||
public Optional<int> Width { get; set; } = Optional<int>.Empty;
|
||||
public Optional<uint> Width { get; set; } = Optional<uint>.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// The image height in pixels, used for tile index correction when the image changes.
|
||||
/// </summary>
|
||||
public Optional<int> Height { get; set; } = Optional<int>.Empty;
|
||||
public Optional<uint> Height { get; set; } = Optional<uint>.Empty;
|
||||
}
|
||||
|
|
|
@ -26,22 +26,22 @@ public class Tile : HasPropertiesBase
|
|||
/// <summary>
|
||||
/// The X position of the sub-rectangle representing this tile within the tileset image.
|
||||
/// </summary>
|
||||
public int X { get; set; } = 0;
|
||||
public uint X { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// The Y position of the sub-rectangle representing this tile within the tileset image.
|
||||
/// </summary>
|
||||
public int Y { get; set; } = 0;
|
||||
public uint Y { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// The width of the sub-rectangle representing this tile within the tileset image.
|
||||
/// </summary>
|
||||
public required int Width { get; set; }
|
||||
public required uint Width { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The height of the sub-rectangle representing this tile within the tileset image.
|
||||
/// </summary>
|
||||
public required int Height { get; set; }
|
||||
public required uint Height { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Tile properties.
|
||||
|
|
|
@ -128,32 +128,32 @@ public class Tileset : HasPropertiesBase
|
|||
/// <summary>
|
||||
/// 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).
|
||||
/// </summary>
|
||||
public required int TileWidth { get; set; }
|
||||
public required uint TileWidth { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 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).
|
||||
/// </summary>
|
||||
public required int TileHeight { get; set; }
|
||||
public required uint TileHeight { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The spacing in pixels between the tiles in this tileset (applies to the tileset image). Irrelevant for image collection tilesets.
|
||||
/// </summary>
|
||||
public int Spacing { get; set; } = 0;
|
||||
public uint Spacing { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// The margin around the tiles in this tileset (applies to the tileset image). Irrelevant for image collection tilesets.
|
||||
/// </summary>
|
||||
public int Margin { get; set; } = 0;
|
||||
public uint Margin { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// The number of tiles in this tileset.
|
||||
/// </summary>
|
||||
public required int TileCount { get; set; }
|
||||
public required uint TileCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The number of tile columns in the tileset.
|
||||
/// </summary>
|
||||
public required int Columns { get; set; }
|
||||
public required uint Columns { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Controls the aligntment for tile objects.
|
||||
|
|
|
@ -20,7 +20,7 @@ public class WangColor : HasPropertiesBase
|
|||
/// <summary>
|
||||
/// The color of the Wang color.
|
||||
/// </summary>
|
||||
public required TiledColor Color { get; set; }
|
||||
public required Color Color { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The tile ID of the tile representing this color.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue