Merge pull request #84 from dcronqvist/tiled-color

Rename Color to TiledColor
This commit is contained in:
dcronqvist 2025-04-25 21:19:32 +02:00 committed by GitHub
commit c27049780a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
38 changed files with 85 additions and 86 deletions

View file

@ -48,7 +48,7 @@ public class FromTypeUsedInLoaderTests
ParallaxOriginY = 0, ParallaxOriginY = 0,
RenderOrder = RenderOrder.RightDown, RenderOrder = RenderOrder.RightDown,
CompressionLevel = -1, CompressionLevel = -1,
BackgroundColor = new Color { R = 0, G = 0, B = 0, A = 0 }, BackgroundColor = new TiledColor { R = 0, G = 0, B = 0, A = 0 },
Version = "1.10", Version = "1.10",
TiledVersion = "1.11.0", TiledVersion = "1.11.0",
NextLayerID = 2, NextLayerID = 2,
@ -133,7 +133,7 @@ public class FromTypeUsedInLoaderTests
ParallaxOriginY = 0, ParallaxOriginY = 0,
RenderOrder = RenderOrder.RightDown, RenderOrder = RenderOrder.RightDown,
CompressionLevel = -1, CompressionLevel = -1,
BackgroundColor = new Color { R = 0, G = 0, B = 0, A = 0 }, BackgroundColor = new TiledColor { R = 0, G = 0, B = 0, A = 0 },
Version = "1.10", Version = "1.10",
TiledVersion = "1.11.0", TiledVersion = "1.11.0",
NextLayerID = 2, NextLayerID = 2,
@ -226,7 +226,7 @@ public class FromTypeUsedInLoaderTests
ParallaxOriginY = 0, ParallaxOriginY = 0,
RenderOrder = RenderOrder.RightDown, RenderOrder = RenderOrder.RightDown,
CompressionLevel = -1, CompressionLevel = -1,
BackgroundColor = new Color { R = 0, G = 0, B = 0, A = 0 }, BackgroundColor = new TiledColor { R = 0, G = 0, B = 0, A = 0 },
Version = "1.10", Version = "1.10",
TiledVersion = "1.11.0", TiledVersion = "1.11.0",
NextLayerID = 2, NextLayerID = 2,

View file

@ -15,7 +15,7 @@ public partial class TestData
ParallaxOriginY = 0, ParallaxOriginY = 0,
RenderOrder = RenderOrder.RightDown, RenderOrder = RenderOrder.RightDown,
CompressionLevel = -1, CompressionLevel = -1,
BackgroundColor = new Color { R = 0, G = 0, B = 0, A = 0 }, BackgroundColor = new TiledColor { R = 0, G = 0, B = 0, A = 0 },
Version = "1.10", Version = "1.10",
TiledVersion = "1.11.0", TiledVersion = "1.11.0",
NextLayerID = 2, NextLayerID = 2,

View file

@ -17,7 +17,7 @@ public partial class TestData
ParallaxOriginY = 0, ParallaxOriginY = 0,
RenderOrder = RenderOrder.RightDown, RenderOrder = RenderOrder.RightDown,
CompressionLevel = -1, CompressionLevel = -1,
BackgroundColor = Color.Parse("#00000000", CultureInfo.InvariantCulture), BackgroundColor = TiledColor.Parse("#00000000", CultureInfo.InvariantCulture),
Version = "1.10", Version = "1.10",
TiledVersion = "1.11.0", TiledVersion = "1.11.0",
NextLayerID = 2, NextLayerID = 2,
@ -47,7 +47,7 @@ public partial class TestData
}, },
Properties = [ Properties = [
new BoolProperty { Name = "tilesetbool", Value = true }, new BoolProperty { Name = "tilesetbool", Value = true },
new ColorProperty { Name = "tilesetcolor", Value = Color.Parse("#ffff0000", CultureInfo.InvariantCulture) }, new ColorProperty { Name = "tilesetcolor", Value = TiledColor.Parse("#ffff0000", CultureInfo.InvariantCulture) },
new FileProperty { Name = "tilesetfile", Value = "" }, new FileProperty { Name = "tilesetfile", Value = "" },
new FloatProperty { Name = "tilesetfloat", Value = 5.2f }, new FloatProperty { Name = "tilesetfloat", Value = 5.2f },
new IntProperty { Name = "tilesetint", Value = 9 }, new IntProperty { Name = "tilesetint", Value = 9 },

View file

@ -17,7 +17,7 @@ public partial class TestData
ParallaxOriginY = 0, ParallaxOriginY = 0,
RenderOrder = RenderOrder.RightDown, RenderOrder = RenderOrder.RightDown,
CompressionLevel = -1, CompressionLevel = -1,
BackgroundColor = Color.Parse("#00000000", CultureInfo.InvariantCulture), BackgroundColor = TiledColor.Parse("#00000000", CultureInfo.InvariantCulture),
Version = "1.10", Version = "1.10",
TiledVersion = "1.11.0", TiledVersion = "1.11.0",
NextLayerID = 2, NextLayerID = 2,
@ -63,21 +63,21 @@ public partial class TestData
new WangColor new WangColor
{ {
Name = "Water", Name = "Water",
Color = Color.Parse("#ff0000", CultureInfo.InvariantCulture), Color = TiledColor.Parse("#ff0000", CultureInfo.InvariantCulture),
Tile = 0, Tile = 0,
Probability = 1 Probability = 1
}, },
new WangColor new WangColor
{ {
Name = "Grass", Name = "Grass",
Color = Color.Parse("#00ff00", CultureInfo.InvariantCulture), Color = TiledColor.Parse("#00ff00", CultureInfo.InvariantCulture),
Tile = -1, Tile = -1,
Probability = 1 Probability = 1
}, },
new WangColor new WangColor
{ {
Name = "Stone", Name = "Stone",
Color = Color.Parse("#0000ff", CultureInfo.InvariantCulture), Color = TiledColor.Parse("#0000ff", CultureInfo.InvariantCulture),
Tile = 29, Tile = 29,
Probability = 1 Probability = 1
} }

View file

@ -17,7 +17,7 @@ public partial class TestData
ParallaxOriginY = 0, ParallaxOriginY = 0,
RenderOrder = RenderOrder.RightDown, RenderOrder = RenderOrder.RightDown,
CompressionLevel = -1, CompressionLevel = -1,
BackgroundColor = new Color { R = 0, G = 0, B = 0, A = 0 }, BackgroundColor = new TiledColor { R = 0, G = 0, B = 0, A = 0 },
Version = "1.10", Version = "1.10",
TiledVersion = "1.11.0", TiledVersion = "1.11.0",
NextLayerID = 8, NextLayerID = 8,

View file

@ -15,7 +15,7 @@ public partial class TestData
ParallaxOriginY = 0, ParallaxOriginY = 0,
RenderOrder = RenderOrder.RightDown, RenderOrder = RenderOrder.RightDown,
CompressionLevel = -1, CompressionLevel = -1,
BackgroundColor = new Color { R = 0, G = 0, B = 0, A = 0 }, BackgroundColor = new TiledColor { R = 0, G = 0, B = 0, A = 0 },
Version = "1.10", Version = "1.10",
TiledVersion = "1.11.0", TiledVersion = "1.11.0",
NextLayerID = 2, NextLayerID = 2,

View file

@ -15,7 +15,7 @@ public partial class TestData
ParallaxOriginY = 0, ParallaxOriginY = 0,
RenderOrder = RenderOrder.RightDown, RenderOrder = RenderOrder.RightDown,
CompressionLevel = -1, CompressionLevel = -1,
BackgroundColor = new Color { R = 0, G = 0, B = 0, A = 0 }, BackgroundColor = new TiledColor { R = 0, G = 0, B = 0, A = 0 },
Version = "1.10", Version = "1.10",
TiledVersion = "1.11.0", TiledVersion = "1.11.0",
NextLayerID = 2, NextLayerID = 2,

View file

@ -17,7 +17,7 @@ public partial class TestData
ParallaxOriginY = 0, ParallaxOriginY = 0,
RenderOrder = RenderOrder.RightDown, RenderOrder = RenderOrder.RightDown,
CompressionLevel = -1, CompressionLevel = -1,
BackgroundColor = Color.Parse("#00ff00", CultureInfo.InvariantCulture), BackgroundColor = TiledColor.Parse("#00ff00", CultureInfo.InvariantCulture),
Version = "1.10", Version = "1.10",
TiledVersion = "1.11.0", TiledVersion = "1.11.0",
NextLayerID = 2, NextLayerID = 2,
@ -52,13 +52,13 @@ public partial class TestData
Properties = Properties =
[ [
new BoolProperty { Name = "boolprop", Value = true }, new BoolProperty { Name = "boolprop", Value = true },
new ColorProperty { Name = "colorprop", Value = Color.Parse("#ff55ffff", CultureInfo.InvariantCulture) }, new ColorProperty { Name = "colorprop", Value = TiledColor.Parse("#ff55ffff", CultureInfo.InvariantCulture) },
new FileProperty { Name = "fileprop", Value = "file.txt" }, new FileProperty { Name = "fileprop", Value = "file.txt" },
new FloatProperty { Name = "floatprop", Value = 4.2f }, new FloatProperty { Name = "floatprop", Value = 4.2f },
new IntProperty { Name = "intprop", Value = 8 }, new IntProperty { Name = "intprop", Value = 8 },
new ObjectProperty { Name = "objectprop", Value = 5 }, new ObjectProperty { Name = "objectprop", Value = 5 },
new StringProperty { Name = "stringprop", Value = "This is a string, hello world!" }, new StringProperty { Name = "stringprop", Value = "This is a string, hello world!" },
new ColorProperty { Name = "unsetcolorprop", Value = Optional<Color>.Empty } new ColorProperty { Name = "unsetcolorprop", Value = Optional<TiledColor>.Empty }
] ]
}; };
} }

View file

@ -17,7 +17,7 @@ public partial class TestData
ParallaxOriginY = 0, ParallaxOriginY = 0,
RenderOrder = RenderOrder.RightDown, RenderOrder = RenderOrder.RightDown,
CompressionLevel = -1, CompressionLevel = -1,
BackgroundColor = Color.Parse("#00000000", CultureInfo.InvariantCulture), BackgroundColor = TiledColor.Parse("#00000000", CultureInfo.InvariantCulture),
Version = "1.10", Version = "1.10",
TiledVersion = "1.11.0", TiledVersion = "1.11.0",
NextLayerID = 2, NextLayerID = 2,

View file

@ -17,7 +17,7 @@ public partial class TestData
ParallaxOriginY = 0, ParallaxOriginY = 0,
RenderOrder = RenderOrder.RightDown, RenderOrder = RenderOrder.RightDown,
CompressionLevel = -1, CompressionLevel = -1,
BackgroundColor = Color.Parse("#00000000", CultureInfo.InvariantCulture), BackgroundColor = TiledColor.Parse("#00000000", CultureInfo.InvariantCulture),
Version = "1.10", Version = "1.10",
TiledVersion = "1.11.0", TiledVersion = "1.11.0",
NextLayerID = 2, NextLayerID = 2,
@ -56,7 +56,7 @@ public partial class TestData
PropertyType = "CustomClass", PropertyType = "CustomClass",
Value = [ Value = [
new BoolProperty { Name = "boolinclass", Value = true }, new BoolProperty { Name = "boolinclass", Value = true },
new ColorProperty { Name = "colorinclass", Value = Color.Parse("#000000ff", CultureInfo.InvariantCulture) }, new ColorProperty { Name = "colorinclass", Value = TiledColor.Parse("#000000ff", CultureInfo.InvariantCulture) },
new FileProperty { Name = "fileinclass", Value = "" }, new FileProperty { Name = "fileinclass", Value = "" },
new FloatProperty { Name = "floatinclass", Value = 13.37f }, new FloatProperty { Name = "floatinclass", Value = 13.37f },
new IntProperty { Name = "intinclass", Value = 0 }, new IntProperty { Name = "intinclass", Value = 0 },
@ -106,7 +106,7 @@ public partial class TestData
new ColorProperty new ColorProperty
{ {
Name = "colorinclass", Name = "colorinclass",
Value = Color.Parse("#000000ff", CultureInfo.InvariantCulture) Value = TiledColor.Parse("#000000ff", CultureInfo.InvariantCulture)
}, },
new FileProperty new FileProperty
{ {

View file

@ -17,7 +17,7 @@ public partial class TestData
ParallaxOriginY = 0, ParallaxOriginY = 0,
RenderOrder = RenderOrder.RightDown, RenderOrder = RenderOrder.RightDown,
CompressionLevel = -1, CompressionLevel = -1,
BackgroundColor = Color.Parse("#00000000", CultureInfo.InvariantCulture), BackgroundColor = TiledColor.Parse("#00000000", CultureInfo.InvariantCulture),
Version = "1.10", Version = "1.10",
TiledVersion = "1.11.0", TiledVersion = "1.11.0",
NextLayerID = 2, NextLayerID = 2,
@ -61,7 +61,7 @@ public partial class TestData
PropertyType = "CustomClass", PropertyType = "CustomClass",
Value = [ Value = [
new BoolProperty { Name = "boolinclass", Value = false }, new BoolProperty { Name = "boolinclass", Value = false },
new ColorProperty { Name = "colorinclass", Value = Color.Parse("#000000ff", CultureInfo.InvariantCulture) }, new ColorProperty { Name = "colorinclass", Value = TiledColor.Parse("#000000ff", CultureInfo.InvariantCulture) },
new FileProperty { Name = "fileinclass", Value = "" }, new FileProperty { Name = "fileinclass", Value = "" },
new FloatProperty { Name = "floatinclass", Value = 0f }, new FloatProperty { Name = "floatinclass", Value = 0f },
new IntProperty { Name = "intinclass", Value = 0 }, new IntProperty { Name = "intinclass", Value = 0 },
@ -82,7 +82,7 @@ public partial class TestData
PropertyType = "CustomClass", PropertyType = "CustomClass",
Value = [ Value = [
new BoolProperty { Name = "boolinclass", Value = true }, new BoolProperty { Name = "boolinclass", Value = true },
new ColorProperty { Name = "colorinclass", Value = Color.Parse("#000000ff", CultureInfo.InvariantCulture) }, new ColorProperty { Name = "colorinclass", Value = TiledColor.Parse("#000000ff", CultureInfo.InvariantCulture) },
new FileProperty { Name = "fileinclass", Value = "" }, new FileProperty { Name = "fileinclass", Value = "" },
new FloatProperty { Name = "floatinclass", Value = 13.37f }, new FloatProperty { Name = "floatinclass", Value = 13.37f },
new IntProperty { Name = "intinclass", Value = 0 }, new IntProperty { Name = "intinclass", Value = 0 },
@ -109,7 +109,7 @@ public partial class TestData
new ColorProperty new ColorProperty
{ {
Name = "colorinclass", Name = "colorinclass",
Value = Color.Parse("#000000ff", CultureInfo.InvariantCulture) Value = TiledColor.Parse("#000000ff", CultureInfo.InvariantCulture)
}, },
new FileProperty new FileProperty
{ {

View file

@ -17,7 +17,7 @@ public partial class TestData
ParallaxOriginY = 0, ParallaxOriginY = 0,
RenderOrder = RenderOrder.RightDown, RenderOrder = RenderOrder.RightDown,
CompressionLevel = -1, CompressionLevel = -1,
BackgroundColor = Color.Parse("#00000000", CultureInfo.InvariantCulture), BackgroundColor = TiledColor.Parse("#00000000", CultureInfo.InvariantCulture),
Version = "1.10", Version = "1.10",
TiledVersion = "1.11.0", TiledVersion = "1.11.0",
NextLayerID = 2, NextLayerID = 2,

View file

@ -17,7 +17,7 @@ public partial class TestData
ParallaxOriginY = 0, ParallaxOriginY = 0,
RenderOrder = RenderOrder.RightDown, RenderOrder = RenderOrder.RightDown,
CompressionLevel = -1, CompressionLevel = -1,
BackgroundColor = Color.Parse("#00000000", CultureInfo.InvariantCulture), BackgroundColor = TiledColor.Parse("#00000000", CultureInfo.InvariantCulture),
Version = "1.10", Version = "1.10",
TiledVersion = "1.11.0", TiledVersion = "1.11.0",
NextLayerID = 2, NextLayerID = 2,

View file

@ -17,7 +17,7 @@ public partial class TestData
ParallaxOriginY = 0, ParallaxOriginY = 0,
RenderOrder = RenderOrder.RightDown, RenderOrder = RenderOrder.RightDown,
CompressionLevel = -1, CompressionLevel = -1,
BackgroundColor = Color.Parse("#00000000", CultureInfo.InvariantCulture), BackgroundColor = TiledColor.Parse("#00000000", CultureInfo.InvariantCulture),
Version = "1.10", Version = "1.10",
TiledVersion = "1.11.0", TiledVersion = "1.11.0",
NextLayerID = 3, NextLayerID = 3,

View file

@ -17,7 +17,7 @@ public partial class TestData
ParallaxOriginY = 0, ParallaxOriginY = 0,
RenderOrder = RenderOrder.RightDown, RenderOrder = RenderOrder.RightDown,
CompressionLevel = -1, CompressionLevel = -1,
BackgroundColor = new Color { R = 0, G = 0, B = 0, A = 0 }, BackgroundColor = new TiledColor { R = 0, G = 0, B = 0, A = 0 },
Version = "1.10", Version = "1.10",
TiledVersion = "1.11.0", TiledVersion = "1.11.0",
NextLayerID = 8, NextLayerID = 8,

View file

@ -17,7 +17,7 @@ public partial class TestData
ParallaxOriginY = 0, ParallaxOriginY = 0,
RenderOrder = RenderOrder.RightDown, RenderOrder = RenderOrder.RightDown,
CompressionLevel = -1, CompressionLevel = -1,
BackgroundColor = Color.Parse("#00ff00", CultureInfo.InvariantCulture), BackgroundColor = TiledColor.Parse("#00ff00", CultureInfo.InvariantCulture),
Version = "1.10", Version = "1.10",
TiledVersion = "1.11.0", TiledVersion = "1.11.0",
NextLayerID = 2, NextLayerID = 2,
@ -52,7 +52,7 @@ public partial class TestData
Properties = Properties =
[ [
new BoolProperty { Name = "boolprop", Value = true }, new BoolProperty { Name = "boolprop", Value = true },
new ColorProperty { Name = "colorprop", Value = Color.Parse("#ff55ffff", CultureInfo.InvariantCulture) }, new ColorProperty { Name = "colorprop", Value = TiledColor.Parse("#ff55ffff", CultureInfo.InvariantCulture) },
new FileProperty { Name = "fileprop", Value = "file.txt" }, new FileProperty { Name = "fileprop", Value = "file.txt" },
new FloatProperty { Name = "floatprop", Value = 4.2f }, new FloatProperty { Name = "floatprop", Value = 4.2f },
new IntProperty { Name = "intprop", Value = 8 }, new IntProperty { Name = "intprop", Value = 8 },

View file

@ -80,7 +80,7 @@ public class HasPropertiesBaseTests
private sealed class MapTo private sealed class MapTo
{ {
public bool MapToBool { get; set; } = false; public bool MapToBool { get; set; } = false;
public Color MapToColor { get; set; } = Color.Parse("#00000000", CultureInfo.InvariantCulture); public TiledColor MapToColor { get; set; } = TiledColor.Parse("#00000000", CultureInfo.InvariantCulture);
public float MapToFloat { get; set; } = 0.0f; public float MapToFloat { get; set; } = 0.0f;
public string MapToFile { get; set; } = ""; public string MapToFile { get; set; } = "";
public int MapToInt { get; set; } = 0; public int MapToInt { get; set; } = 0;
@ -130,7 +130,7 @@ public class HasPropertiesBaseTests
PropertyType = "MapTo", PropertyType = "MapTo",
Value = [ Value = [
new BoolProperty { Name = "MapToBool", Value = true }, new BoolProperty { Name = "MapToBool", Value = true },
new ColorProperty { Name = "MapToColor", Value = Color.Parse("#FF0000FF", CultureInfo.InvariantCulture) }, new ColorProperty { Name = "MapToColor", Value = TiledColor.Parse("#FF0000FF", CultureInfo.InvariantCulture) },
new FloatProperty { Name = "MapToFloat", Value = 1.0f }, new FloatProperty { Name = "MapToFloat", Value = 1.0f },
new StringProperty { Name = "MapToFile", Value = "Test" }, new StringProperty { Name = "MapToFile", Value = "Test" },
new IntProperty { Name = "MapToInt", Value = 1 }, new IntProperty { Name = "MapToInt", Value = 1 },
@ -146,7 +146,7 @@ public class HasPropertiesBaseTests
// Assert // Assert
Assert.True(mappedProperty.MapToBool); Assert.True(mappedProperty.MapToBool);
Assert.Equal(Color.Parse("#FF0000FF", CultureInfo.InvariantCulture), mappedProperty.MapToColor); Assert.Equal(TiledColor.Parse("#FF0000FF", CultureInfo.InvariantCulture), mappedProperty.MapToColor);
Assert.Equal(1.0f, mappedProperty.MapToFloat); Assert.Equal(1.0f, mappedProperty.MapToFloat);
Assert.Equal("Test", mappedProperty.MapToFile); Assert.Equal("Test", mappedProperty.MapToFile);
Assert.Equal(1, mappedProperty.MapToInt); Assert.Equal(1, mappedProperty.MapToInt);
@ -175,7 +175,7 @@ public class HasPropertiesBaseTests
PropertyType = "MapTo", PropertyType = "MapTo",
Value = [ Value = [
new BoolProperty { Name = "MapToBool", Value = true }, new BoolProperty { Name = "MapToBool", Value = true },
new ColorProperty { Name = "MapToColor", Value = Color.Parse("#FF0000FF", CultureInfo.InvariantCulture) }, new ColorProperty { Name = "MapToColor", Value = TiledColor.Parse("#FF0000FF", CultureInfo.InvariantCulture) },
new FloatProperty { Name = "MapToFloat", Value = 1.0f }, new FloatProperty { Name = "MapToFloat", Value = 1.0f },
new StringProperty { Name = "MapToFile", Value = "Test" }, new StringProperty { Name = "MapToFile", Value = "Test" },
new IntProperty { Name = "MapToInt", Value = 1 }, new IntProperty { Name = "MapToInt", Value = 1 },
@ -194,7 +194,7 @@ public class HasPropertiesBaseTests
// Assert // Assert
Assert.Equal("Test", mappedProperty.NestedMapToString); Assert.Equal("Test", mappedProperty.NestedMapToString);
Assert.True(mappedProperty.MapToInNested.MapToBool); Assert.True(mappedProperty.MapToInNested.MapToBool);
Assert.Equal(Color.Parse("#FF0000FF", CultureInfo.InvariantCulture), mappedProperty.MapToInNested.MapToColor); Assert.Equal(TiledColor.Parse("#FF0000FF", CultureInfo.InvariantCulture), mappedProperty.MapToInNested.MapToColor);
Assert.Equal(1.0f, mappedProperty.MapToInNested.MapToFloat); Assert.Equal(1.0f, mappedProperty.MapToInNested.MapToFloat);
Assert.Equal("Test", mappedProperty.MapToInNested.MapToFile); Assert.Equal("Test", mappedProperty.MapToInNested.MapToFile);
Assert.Equal(1, mappedProperty.MapToInNested.MapToInt); Assert.Equal(1, mappedProperty.MapToInNested.MapToInt);
@ -276,7 +276,7 @@ public class HasPropertiesBaseTests
// Arrange // Arrange
List<IProperty> props = [ List<IProperty> props = [
new BoolProperty { Name = "MapToBool", Value = true }, new BoolProperty { Name = "MapToBool", Value = true },
new ColorProperty { Name = "MapToColor", Value = Color.Parse("#FF0000FF", CultureInfo.InvariantCulture) }, new ColorProperty { Name = "MapToColor", Value = TiledColor.Parse("#FF0000FF", CultureInfo.InvariantCulture) },
new FloatProperty { Name = "MapToFloat", Value = 1.0f }, new FloatProperty { Name = "MapToFloat", Value = 1.0f },
new StringProperty { Name = "MapToFile", Value = "Test" }, new StringProperty { Name = "MapToFile", Value = "Test" },
new IntProperty { Name = "MapToInt", Value = 1 }, new IntProperty { Name = "MapToInt", Value = 1 },
@ -290,7 +290,7 @@ public class HasPropertiesBaseTests
// Assert // Assert
Assert.True(mappedProperty.MapToBool); Assert.True(mappedProperty.MapToBool);
Assert.Equal(Color.Parse("#FF0000FF", CultureInfo.InvariantCulture), mappedProperty.MapToColor); Assert.Equal(TiledColor.Parse("#FF0000FF", CultureInfo.InvariantCulture), mappedProperty.MapToColor);
Assert.Equal(1.0f, mappedProperty.MapToFloat); Assert.Equal(1.0f, mappedProperty.MapToFloat);
Assert.Equal("Test", mappedProperty.MapToFile); Assert.Equal("Test", mappedProperty.MapToFile);
Assert.Equal(1, mappedProperty.MapToInt); Assert.Equal(1, mappedProperty.MapToInt);

View file

@ -37,7 +37,7 @@ public abstract class BaseLayer : HasPropertiesBase
/// <summary> /// <summary>
/// A tint color that is multiplied with any tiles drawn by this layer. /// A tint color that is multiplied with any tiles drawn by this layer.
/// </summary> /// </summary>
public Optional<Color> TintColor { get; set; } = Optional<Color>.Empty; public Optional<TiledColor> TintColor { get; set; } = Optional<TiledColor>.Empty;
/// <summary> /// <summary>
/// Horizontal offset for this layer in pixels. /// Horizontal offset for this layer in pixels.

View file

@ -46,7 +46,7 @@ public class ObjectLayer : BaseLayer
/// <summary> /// <summary>
/// A color that is multiplied with any tile objects drawn by this layer. /// A color that is multiplied with any tile objects drawn by this layer.
/// </summary> /// </summary>
public Optional<Color> Color { get; set; } = Optional<Color>.Empty; public Optional<TiledColor> Color { get; set; } = Optional<TiledColor>.Empty;
/// <summary> /// <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"/>). /// 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"/>).

View file

@ -72,7 +72,7 @@ public class TextObject : Object
/// <summary> /// <summary>
/// The color of the text. /// The color of the text.
/// </summary> /// </summary>
public Color Color { get; set; } = Color.Parse("#000000", CultureInfo.InvariantCulture); public TiledColor Color { get; set; } = TiledColor.Parse("#000000", CultureInfo.InvariantCulture);
/// <summary> /// <summary>
/// Whether the text is bold. /// Whether the text is bold.

View file

@ -171,7 +171,7 @@ public class Map : HasPropertiesBase
/// <summary> /// <summary>
/// The background color of the map. /// The background color of the map.
/// </summary> /// </summary>
public Color BackgroundColor { get; set; } = Color.Parse("#00000000", CultureInfo.InvariantCulture); public TiledColor BackgroundColor { get; set; } = TiledColor.Parse("#00000000", CultureInfo.InvariantCulture);
/// <summary> /// <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. /// Stores the next available ID for new layers. This number is used to prevent reuse of the same ID after layers have been removed.

View file

@ -3,7 +3,7 @@ namespace DotTiled;
/// <summary> /// <summary>
/// Represents a color property. /// Represents a color property.
/// </summary> /// </summary>
public class ColorProperty : IProperty<Optional<Color>> public class ColorProperty : IProperty<Optional<TiledColor>>
{ {
/// <inheritdoc/> /// <inheritdoc/>
public required string Name { get; set; } public required string Name { get; set; }
@ -14,7 +14,7 @@ public class ColorProperty : IProperty<Optional<Color>>
/// <summary> /// <summary>
/// The color value of the property. /// The color value of the property.
/// </summary> /// </summary>
public required Optional<Color> Value { get; set; } public required Optional<TiledColor> Value { get; set; }
/// <inheritdoc/> /// <inheritdoc/>
public IProperty Clone() => new ColorProperty public IProperty Clone() => new ColorProperty

View file

@ -78,7 +78,7 @@ public class CustomClassDefinition : HasPropertiesBase, ICustomTypeDefinition
/// <summary> /// <summary>
/// The color of the custom class inside the Tiled editor. /// The color of the custom class inside the Tiled editor.
/// </summary> /// </summary>
public Color Color { get; set; } public TiledColor Color { get; set; }
/// <summary> /// <summary>
/// Whether the custom class should be drawn with a fill color. /// 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): case Type t when t == typeof(bool):
return new BoolProperty { Name = propertyInfo.Name, Value = (bool)propertyInfo.GetValue(instance) }; return new BoolProperty { Name = propertyInfo.Name, Value = (bool)propertyInfo.GetValue(instance) };
case Type t when t == typeof(Color): case Type t when t == typeof(TiledColor):
return new ColorProperty { Name = propertyInfo.Name, Value = (Color)propertyInfo.GetValue(instance) }; return new ColorProperty { Name = propertyInfo.Name, Value = (TiledColor)propertyInfo.GetValue(instance) };
case Type t when t == typeof(float): case Type t when t == typeof(float):
return new FloatProperty { Name = propertyInfo.Name, Value = (float)propertyInfo.GetValue(instance) }; return new FloatProperty { Name = propertyInfo.Name, Value = (float)propertyInfo.GetValue(instance) };
case Type t when t == typeof(string): case Type t when t == typeof(string):

View file

@ -7,7 +7,7 @@ namespace DotTiled;
/// <summary> /// <summary>
/// Represents a Tiled color. /// Represents a Tiled color.
/// </summary> /// </summary>
public class Color : IParsable<Color>, IEquatable<Color> public class TiledColor : IParsable<TiledColor>, IEquatable<TiledColor>
{ {
/// <summary> /// <summary>
/// The red component of the color. /// The red component of the color.
@ -30,31 +30,31 @@ public class Color : IParsable<Color>, IEquatable<Color>
public byte A { get; set; } = 255; public byte A { get; set; } = 255;
/// <summary> /// <summary>
/// Attempts to parse the specified string into a <see cref="Color"/>. Expects strings in the format <c>#RRGGBB</c> or <c>#AARRGGBB</c>. /// Attempts to parse the specified string into a <see cref="TiledColor"/>. Expects strings in the format <c>#RRGGBB</c> or <c>#AARRGGBB</c>.
/// The leading <c>#</c> is optional. /// The leading <c>#</c> is optional.
/// </summary> /// </summary>
/// <param name="s">A string value to parse into a <see cref="Color"/></param> /// <param name="s">A string value to parse into a <see cref="TiledColor"/></param>
/// <param name="provider">An object that supplies culture-specific information about the format of s.</param> /// <param name="provider">An object that supplies culture-specific information about the format of s.</param>
/// <returns>The parsed <see cref="Color"/></returns> /// <returns>The parsed <see cref="TiledColor"/></returns>
/// <exception cref="FormatException">Thrown in case the provided string <paramref name="s"/> is not in a valid format.</exception> /// <exception cref="FormatException">Thrown in case the provided string <paramref name="s"/> is not in a valid format.</exception>
public static Color Parse(string s, IFormatProvider provider) public static TiledColor Parse(string s, IFormatProvider provider)
{ {
_ = TryParse(s, provider, out var result); _ = TryParse(s, provider, out var result);
return result ?? throw new FormatException($"Invalid format for TiledColor: {s}"); return result ?? throw new FormatException($"Invalid format for TiledColor: {s}");
} }
/// <summary> /// <summary>
/// Attempts to parse the specified string into a <see cref="Color"/>. Expects strings in the format <c>#RRGGBB</c> or <c>#AARRGGBB</c>. /// Attempts to parse the specified string into a <see cref="TiledColor"/>. Expects strings in the format <c>#RRGGBB</c> or <c>#AARRGGBB</c>.
/// The leading <c>#</c> is optional. /// The leading <c>#</c> is optional.
/// </summary> /// </summary>
/// <param name="s">A string value to parse into a <see cref="Color"/></param> /// <param name="s">A string value to parse into a <see cref="TiledColor"/></param>
/// <param name="provider">An object that supplies culture-specific information about the format of s.</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="Color"/> or <c>null</c> on failure.</param> /// <param name="result">When this method returns, contains the parsed <see cref="TiledColor"/> or <c>null</c> on failure.</param>
/// <returns><c>true</c> if <paramref name="s"/> was successfully parsed; otherwise, <c>false</c>.</returns> /// <returns><c>true</c> if <paramref name="s"/> was successfully parsed; otherwise, <c>false</c>.</returns>
public static bool TryParse( public static bool TryParse(
[NotNullWhen(true)] string s, [NotNullWhen(true)] string s,
IFormatProvider provider, IFormatProvider provider,
[MaybeNullWhen(false)] out Color result) [MaybeNullWhen(false)] out TiledColor result)
{ {
if (s is not null && !s.StartsWith('#')) if (s is not null && !s.StartsWith('#'))
return TryParse($"#{s}", provider, out result); return TryParse($"#{s}", provider, out result);
@ -68,7 +68,7 @@ public class Color : IParsable<Color>, IEquatable<Color>
if (s.Length == 7) if (s.Length == 7)
{ {
result = new Color result = new TiledColor
{ {
R = byte.Parse(s[1..3], NumberStyles.HexNumber, provider), R = byte.Parse(s[1..3], NumberStyles.HexNumber, provider),
G = byte.Parse(s[3..5], NumberStyles.HexNumber, provider), G = byte.Parse(s[3..5], NumberStyles.HexNumber, provider),
@ -77,7 +77,7 @@ public class Color : IParsable<Color>, IEquatable<Color>
} }
else else
{ {
result = new Color result = new TiledColor
{ {
A = byte.Parse(s[1..3], NumberStyles.HexNumber, provider), A = byte.Parse(s[1..3], NumberStyles.HexNumber, provider),
R = byte.Parse(s[3..5], NumberStyles.HexNumber, provider), R = byte.Parse(s[3..5], NumberStyles.HexNumber, provider),
@ -90,7 +90,7 @@ public class Color : IParsable<Color>, IEquatable<Color>
} }
/// <inheritdoc/> /// <inheritdoc/>
public bool Equals(Color other) public bool Equals(TiledColor other)
{ {
if (other is null) if (other is null)
return false; return false;
@ -99,7 +99,7 @@ public class Color : IParsable<Color>, IEquatable<Color>
} }
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(object obj) => obj is Color other && Equals(other); public override bool Equals(object obj) => obj is TiledColor other && Equals(other);
/// <inheritdoc/> /// <inheritdoc/>
public override int GetHashCode() => HashCode.Combine(R, G, B, A); public override int GetHashCode() => HashCode.Combine(R, G, B, A);

View file

@ -12,7 +12,7 @@ public abstract partial class TmjReaderBase
var @class = element.GetOptionalProperty<string>("class").GetValueOr(""); var @class = element.GetOptionalProperty<string>("class").GetValueOr("");
var opacity = element.GetOptionalProperty<float>("opacity").GetValueOr(1.0f); var opacity = element.GetOptionalProperty<float>("opacity").GetValueOr(1.0f);
var visible = element.GetOptionalProperty<bool>("visible").GetValueOr(true); var visible = element.GetOptionalProperty<bool>("visible").GetValueOr(true);
var tintColor = element.GetOptionalPropertyParseable<Color>("tintcolor"); var tintColor = element.GetOptionalPropertyParseable<TiledColor>("tintcolor");
var offsetX = element.GetOptionalProperty<float>("offsetx").GetValueOr(0.0f); var offsetX = element.GetOptionalProperty<float>("offsetx").GetValueOr(0.0f);
var offsetY = element.GetOptionalProperty<float>("offsety").GetValueOr(0.0f); var offsetY = element.GetOptionalProperty<float>("offsety").GetValueOr(0.0f);
var parallaxX = element.GetOptionalProperty<float>("parallaxx").GetValueOr(1.0f); var parallaxX = element.GetOptionalProperty<float>("parallaxx").GetValueOr(1.0f);

View file

@ -11,7 +11,7 @@ public abstract partial class TmjReaderBase
var @class = element.GetOptionalProperty<string>("class").GetValueOr(""); var @class = element.GetOptionalProperty<string>("class").GetValueOr("");
var opacity = element.GetOptionalProperty<float>("opacity").GetValueOr(1.0f); var opacity = element.GetOptionalProperty<float>("opacity").GetValueOr(1.0f);
var visible = element.GetOptionalProperty<bool>("visible").GetValueOr(true); var visible = element.GetOptionalProperty<bool>("visible").GetValueOr(true);
var tintColor = element.GetOptionalPropertyParseable<Color>("tintcolor"); var tintColor = element.GetOptionalPropertyParseable<TiledColor>("tintcolor");
var offsetX = element.GetOptionalProperty<float>("offsetx").GetValueOr(0.0f); var offsetX = element.GetOptionalProperty<float>("offsetx").GetValueOr(0.0f);
var offsetY = element.GetOptionalProperty<float>("offsety").GetValueOr(0.0f); var offsetY = element.GetOptionalProperty<float>("offsety").GetValueOr(0.0f);
var parallaxX = element.GetOptionalProperty<float>("parallaxx").GetValueOr(1.0f); var parallaxX = element.GetOptionalProperty<float>("parallaxx").GetValueOr(1.0f);
@ -21,7 +21,7 @@ public abstract partial class TmjReaderBase
var image = element.GetRequiredProperty<string>("image"); var image = element.GetRequiredProperty<string>("image");
var repeatX = element.GetOptionalProperty<bool>("repeatx").GetValueOr(false); var repeatX = element.GetOptionalProperty<bool>("repeatx").GetValueOr(false);
var repeatY = element.GetOptionalProperty<bool>("repeaty").GetValueOr(false); var repeatY = element.GetOptionalProperty<bool>("repeaty").GetValueOr(false);
var transparentColor = element.GetOptionalPropertyParseable<Color>("transparentcolor"); var transparentColor = element.GetOptionalPropertyParseable<TiledColor>("transparentcolor");
var x = element.GetOptionalProperty<int>("x").GetValueOr(0); var x = element.GetOptionalProperty<int>("x").GetValueOr(0);
var y = element.GetOptionalProperty<int>("y").GetValueOr(0); var y = element.GetOptionalProperty<int>("y").GetValueOr(0);

View file

@ -47,7 +47,7 @@ public abstract partial class TmjReaderBase
}); });
var parallaxOriginX = element.GetOptionalProperty<float>("parallaxoriginx").GetValueOr(0f); var parallaxOriginX = element.GetOptionalProperty<float>("parallaxoriginx").GetValueOr(0f);
var parallaxOriginY = element.GetOptionalProperty<float>("parallaxoriginy").GetValueOr(0f); var parallaxOriginY = element.GetOptionalProperty<float>("parallaxoriginy").GetValueOr(0f);
var backgroundColor = element.GetOptionalPropertyParseable<Color>("backgroundcolor").GetValueOr(Color.Parse("#00000000", CultureInfo.InvariantCulture)); var backgroundColor = element.GetOptionalPropertyParseable<TiledColor>("backgroundcolor").GetValueOr(TiledColor.Parse("#00000000", CultureInfo.InvariantCulture));
var nextLayerID = element.GetRequiredProperty<uint>("nextlayerid"); var nextLayerID = element.GetRequiredProperty<uint>("nextlayerid");
var nextObjectID = element.GetRequiredProperty<uint>("nextobjectid"); var nextObjectID = element.GetRequiredProperty<uint>("nextobjectid");
var infinite = element.GetOptionalProperty<bool>("infinite").GetValueOr(false); var infinite = element.GetOptionalProperty<bool>("infinite").GetValueOr(false);

View file

@ -15,7 +15,7 @@ public abstract partial class TmjReaderBase
var @class = element.GetOptionalProperty<string>("class").GetValueOr(""); var @class = element.GetOptionalProperty<string>("class").GetValueOr("");
var opacity = element.GetOptionalProperty<float>("opacity").GetValueOr(1.0f); var opacity = element.GetOptionalProperty<float>("opacity").GetValueOr(1.0f);
var visible = element.GetOptionalProperty<bool>("visible").GetValueOr(true); var visible = element.GetOptionalProperty<bool>("visible").GetValueOr(true);
var tintColor = element.GetOptionalPropertyParseable<Color>("tintcolor"); var tintColor = element.GetOptionalPropertyParseable<TiledColor>("tintcolor");
var offsetX = element.GetOptionalProperty<float>("offsetx").GetValueOr(0.0f); var offsetX = element.GetOptionalProperty<float>("offsetx").GetValueOr(0.0f);
var offsetY = element.GetOptionalProperty<float>("offsety").GetValueOr(0.0f); var offsetY = element.GetOptionalProperty<float>("offsety").GetValueOr(0.0f);
var parallaxX = element.GetOptionalProperty<float>("parallaxx").GetValueOr(1.0f); var parallaxX = element.GetOptionalProperty<float>("parallaxx").GetValueOr(1.0f);
@ -26,7 +26,7 @@ public abstract partial class TmjReaderBase
var y = element.GetOptionalProperty<int>("y").GetValueOr(0); var y = element.GetOptionalProperty<int>("y").GetValueOr(0);
var width = element.GetOptionalProperty<int>("width").GetValueOr(0); var width = element.GetOptionalProperty<int>("width").GetValueOr(0);
var height = element.GetOptionalProperty<int>("height").GetValueOr(0); var height = element.GetOptionalProperty<int>("height").GetValueOr(0);
var color = element.GetOptionalPropertyParseable<Color>("color"); var color = element.GetOptionalPropertyParseable<TiledColor>("color");
var drawOrder = element.GetOptionalPropertyParseable<DrawOrder>("draworder", s => s switch var drawOrder = element.GetOptionalPropertyParseable<DrawOrder>("draworder", s => s switch
{ {
"topdown" => DrawOrder.TopDown, "topdown" => DrawOrder.TopDown,
@ -255,7 +255,7 @@ public abstract partial class TmjReaderBase
internal static TextObject ReadText(JsonElement element) internal static TextObject ReadText(JsonElement element)
{ {
var bold = element.GetOptionalProperty<bool>("bold").GetValueOr(false); var bold = element.GetOptionalProperty<bool>("bold").GetValueOr(false);
var color = element.GetOptionalPropertyParseable<Color>("color").GetValueOr(Color.Parse("#00000000", CultureInfo.InvariantCulture)); var color = element.GetOptionalPropertyParseable<TiledColor>("color").GetValueOr(TiledColor.Parse("#00000000", CultureInfo.InvariantCulture));
var fontfamily = element.GetOptionalProperty<string>("fontfamily").GetValueOr("sans-serif"); var fontfamily = element.GetOptionalProperty<string>("fontfamily").GetValueOr("sans-serif");
var halign = element.GetOptionalPropertyParseable<TextHorizontalAlignment>("halign", s => s switch var halign = element.GetOptionalPropertyParseable<TextHorizontalAlignment>("halign", s => s switch
{ {

View file

@ -36,7 +36,7 @@ public abstract partial class TmjReaderBase
PropertyType.Int => new IntProperty { Name = name, Value = e.GetRequiredProperty<int>("value") }, PropertyType.Int => new IntProperty { Name = name, Value = e.GetRequiredProperty<int>("value") },
PropertyType.Float => new FloatProperty { Name = name, Value = e.GetRequiredProperty<float>("value") }, PropertyType.Float => new FloatProperty { Name = name, Value = e.GetRequiredProperty<float>("value") },
PropertyType.Bool => new BoolProperty { Name = name, Value = e.GetRequiredProperty<bool>("value") }, PropertyType.Bool => new BoolProperty { Name = name, Value = e.GetRequiredProperty<bool>("value") },
PropertyType.Color => new ColorProperty { Name = name, Value = e.GetRequiredPropertyParseable<Color>("value", s => s == "" ? default : Color.Parse(s, CultureInfo.InvariantCulture)) }, PropertyType.Color => new ColorProperty { Name = name, Value = e.GetRequiredPropertyParseable<TiledColor>("value", s => s == "" ? default : TiledColor.Parse(s, CultureInfo.InvariantCulture)) },
PropertyType.File => new FileProperty { Name = name, Value = e.GetRequiredProperty<string>("value") }, PropertyType.File => new FileProperty { Name = name, Value = e.GetRequiredProperty<string>("value") },
PropertyType.Object => new ObjectProperty { Name = name, Value = e.GetRequiredProperty<uint>("value") }, PropertyType.Object => new ObjectProperty { Name = name, Value = e.GetRequiredProperty<uint>("value") },
PropertyType.Class => throw new JsonException("Class property must have a property type"), 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.Int => new IntProperty { Name = prop.Name, Value = propElement.GetValueAs<int>() },
PropertyType.Float => new FloatProperty { Name = prop.Name, Value = propElement.GetValueAs<float>() }, PropertyType.Float => new FloatProperty { Name = prop.Name, Value = propElement.GetValueAs<float>() },
PropertyType.Bool => new BoolProperty { Name = prop.Name, Value = propElement.GetValueAs<bool>() }, PropertyType.Bool => new BoolProperty { Name = prop.Name, Value = propElement.GetValueAs<bool>() },
PropertyType.Color => new ColorProperty { Name = prop.Name, Value = Color.Parse(propElement.GetValueAs<string>(), CultureInfo.InvariantCulture) }, PropertyType.Color => new ColorProperty { Name = prop.Name, Value = TiledColor.Parse(propElement.GetValueAs<string>(), CultureInfo.InvariantCulture) },
PropertyType.File => new FileProperty { Name = prop.Name, Value = propElement.GetValueAs<string>() }, PropertyType.File => new FileProperty { Name = prop.Name, Value = propElement.GetValueAs<string>() },
PropertyType.Object => new ObjectProperty { Name = prop.Name, Value = propElement.GetValueAs<uint>() }, PropertyType.Object => new ObjectProperty { Name = prop.Name, Value = propElement.GetValueAs<uint>() },
PropertyType.Enum => ReadEnumProperty(propElement), PropertyType.Enum => ReadEnumProperty(propElement),

View file

@ -35,8 +35,8 @@ public abstract partial class TmjReaderBase
var repeatY = element.GetOptionalProperty<bool>("repeaty").GetValueOr(false); var repeatY = element.GetOptionalProperty<bool>("repeaty").GetValueOr(false);
var startX = element.GetOptionalProperty<int>("startx").GetValueOr(0); var startX = element.GetOptionalProperty<int>("startx").GetValueOr(0);
var startY = element.GetOptionalProperty<int>("starty").GetValueOr(0); var startY = element.GetOptionalProperty<int>("starty").GetValueOr(0);
var tintColor = element.GetOptionalPropertyParseable<Color>("tintcolor"); var tintColor = element.GetOptionalPropertyParseable<TiledColor>("tintcolor");
var transparentColor = element.GetOptionalPropertyParseable<Color>("transparentcolor"); var transparentColor = element.GetOptionalPropertyParseable<TiledColor>("transparentcolor");
var visible = element.GetOptionalProperty<bool>("visible").GetValueOr(true); var visible = element.GetOptionalProperty<bool>("visible").GetValueOr(true);
var width = element.GetRequiredProperty<int>("width"); var width = element.GetRequiredProperty<int>("width");
var x = element.GetRequiredProperty<int>("x"); var x = element.GetRequiredProperty<int>("x");

View file

@ -10,7 +10,7 @@ public abstract partial class TmjReaderBase
Optional<string> parentVersion = null, Optional<string> parentVersion = null,
Optional<string> parentTiledVersion = null) Optional<string> parentTiledVersion = null)
{ {
var backgroundColor = element.GetOptionalPropertyParseable<Color>("backgroundcolor"); var backgroundColor = element.GetOptionalPropertyParseable<TiledColor>("backgroundcolor");
var @class = element.GetOptionalProperty<string>("class").GetValueOr(""); var @class = element.GetOptionalProperty<string>("class").GetValueOr("");
var columns = element.GetOptionalProperty<int>("columns"); var columns = element.GetOptionalProperty<int>("columns");
var fillMode = element.GetOptionalPropertyParseable<FillMode>("fillmode", s => s switch var fillMode = element.GetOptionalPropertyParseable<FillMode>("fillmode", s => s switch
@ -55,8 +55,7 @@ public abstract partial class TmjReaderBase
}).GetValueOr(TileRenderSize.Tile); }).GetValueOr(TileRenderSize.Tile);
var tiles = element.GetOptionalPropertyCustom<List<Tile>>("tiles", ReadTiles).GetValueOr([]); var tiles = element.GetOptionalPropertyCustom<List<Tile>>("tiles", ReadTiles).GetValueOr([]);
var tileWidth = element.GetOptionalProperty<int>("tilewidth"); var tileWidth = element.GetOptionalProperty<int>("tilewidth");
var transparentColor = element.GetOptionalPropertyParseable<Color>("transparentcolor"); var transparentColor = element.GetOptionalPropertyParseable<TiledColor>("transparentcolor");
var type = element.GetOptionalProperty<string>("type");
var version = element.GetOptionalProperty<string>("version").GetValueOrOptional(parentVersion); var version = element.GetOptionalProperty<string>("version").GetValueOrOptional(parentVersion);
var transformations = element.GetOptionalPropertyCustom<Transformations>("transformations", ReadTransformations); var transformations = element.GetOptionalPropertyCustom<Transformations>("transformations", ReadTransformations);
var wangsets = element.GetOptionalPropertyCustom<List<Wangset>>("wangsets", el => el.GetValueAsList<Wangset>(e => ReadWangset(e))).GetValueOr([]); var wangsets = element.GetOptionalPropertyCustom<List<Wangset>>("wangsets", el => el.GetValueAsList<Wangset>(e => ReadWangset(e))).GetValueOr([]);
@ -229,7 +228,7 @@ public abstract partial class TmjReaderBase
internal WangColor ReadWangColor(JsonElement element) internal WangColor ReadWangColor(JsonElement element)
{ {
var @class = element.GetOptionalProperty<string>("class").GetValueOr(""); var @class = element.GetOptionalProperty<string>("class").GetValueOr("");
var color = element.GetRequiredPropertyParseable<Color>("color"); var color = element.GetRequiredPropertyParseable<TiledColor>("color");
var name = element.GetRequiredProperty<string>("name"); var name = element.GetRequiredProperty<string>("name");
var probability = element.GetOptionalProperty<float>("probability").GetValueOr(1.0f); var probability = element.GetOptionalProperty<float>("probability").GetValueOr(1.0f);
var properties = ResolveAndMergeProperties(@class, element.GetOptionalPropertyCustom("properties", ReadProperties).GetValueOr([])); var properties = ResolveAndMergeProperties(@class, element.GetOptionalPropertyCustom("properties", ReadProperties).GetValueOr([]));

View file

@ -51,7 +51,7 @@ public abstract partial class TmxReaderBase
}); });
var parallaxOriginX = _reader.GetOptionalAttributeParseable<float>("parallaxoriginx").GetValueOr(0.0f); var parallaxOriginX = _reader.GetOptionalAttributeParseable<float>("parallaxoriginx").GetValueOr(0.0f);
var parallaxOriginY = _reader.GetOptionalAttributeParseable<float>("parallaxoriginy").GetValueOr(0.0f); var parallaxOriginY = _reader.GetOptionalAttributeParseable<float>("parallaxoriginy").GetValueOr(0.0f);
var backgroundColor = _reader.GetOptionalAttributeClass<Color>("backgroundcolor").GetValueOr(Color.Parse("#00000000", CultureInfo.InvariantCulture)); var backgroundColor = _reader.GetOptionalAttributeClass<TiledColor>("backgroundcolor").GetValueOr(TiledColor.Parse("#00000000", CultureInfo.InvariantCulture));
var nextLayerID = _reader.GetRequiredAttributeParseable<uint>("nextlayerid"); var nextLayerID = _reader.GetRequiredAttributeParseable<uint>("nextlayerid");
var nextObjectID = _reader.GetRequiredAttributeParseable<uint>("nextobjectid"); var nextObjectID = _reader.GetRequiredAttributeParseable<uint>("nextobjectid");
var infinite = _reader.GetOptionalAttributeParseable<uint>("infinite").GetValueOr(0) == 1; var infinite = _reader.GetOptionalAttributeParseable<uint>("infinite").GetValueOr(0) == 1;

View file

@ -20,12 +20,12 @@ public abstract partial class TmxReaderBase
var height = _reader.GetOptionalAttributeParseable<int>("height").GetValueOr(0); var height = _reader.GetOptionalAttributeParseable<int>("height").GetValueOr(0);
var opacity = _reader.GetOptionalAttributeParseable<float>("opacity").GetValueOr(1.0f); var opacity = _reader.GetOptionalAttributeParseable<float>("opacity").GetValueOr(1.0f);
var visible = _reader.GetOptionalAttributeParseable<uint>("visible").GetValueOr(1) == 1; var visible = _reader.GetOptionalAttributeParseable<uint>("visible").GetValueOr(1) == 1;
var tintColor = _reader.GetOptionalAttributeClass<Color>("tintcolor"); var tintColor = _reader.GetOptionalAttributeClass<TiledColor>("tintcolor");
var offsetX = _reader.GetOptionalAttributeParseable<float>("offsetx").GetValueOr(0.0f); var offsetX = _reader.GetOptionalAttributeParseable<float>("offsetx").GetValueOr(0.0f);
var offsetY = _reader.GetOptionalAttributeParseable<float>("offsety").GetValueOr(0.0f); var offsetY = _reader.GetOptionalAttributeParseable<float>("offsety").GetValueOr(0.0f);
var parallaxX = _reader.GetOptionalAttributeParseable<float>("parallaxx").GetValueOr(1.0f); var parallaxX = _reader.GetOptionalAttributeParseable<float>("parallaxx").GetValueOr(1.0f);
var parallaxY = _reader.GetOptionalAttributeParseable<float>("parallaxy").GetValueOr(1.0f); var parallaxY = _reader.GetOptionalAttributeParseable<float>("parallaxy").GetValueOr(1.0f);
var color = _reader.GetOptionalAttributeClass<Color>("color"); var color = _reader.GetOptionalAttributeClass<TiledColor>("color");
var drawOrder = _reader.GetOptionalAttributeEnum<DrawOrder>("draworder", s => s switch var drawOrder = _reader.GetOptionalAttributeEnum<DrawOrder>("draworder", s => s switch
{ {
"topdown" => DrawOrder.TopDown, "topdown" => DrawOrder.TopDown,
@ -245,7 +245,7 @@ public abstract partial class TmxReaderBase
var fontFamily = _reader.GetOptionalAttribute("fontfamily") ?? "sans-serif"; var fontFamily = _reader.GetOptionalAttribute("fontfamily") ?? "sans-serif";
var pixelSize = _reader.GetOptionalAttributeParseable<int>("pixelsize") ?? 16; var pixelSize = _reader.GetOptionalAttributeParseable<int>("pixelsize") ?? 16;
var wrap = _reader.GetOptionalAttributeParseable<bool>("wrap") ?? false; var wrap = _reader.GetOptionalAttributeParseable<bool>("wrap") ?? false;
var color = _reader.GetOptionalAttributeClass<Color>("color") ?? Color.Parse("#000000", CultureInfo.InvariantCulture); var color = _reader.GetOptionalAttributeClass<TiledColor>("color") ?? TiledColor.Parse("#000000", CultureInfo.InvariantCulture);
var bold = _reader.GetOptionalAttributeParseable<bool>("bold") ?? false; var bold = _reader.GetOptionalAttributeParseable<bool>("bold") ?? false;
var italic = _reader.GetOptionalAttributeParseable<bool>("italic") ?? false; var italic = _reader.GetOptionalAttributeParseable<bool>("italic") ?? false;
var underline = _reader.GetOptionalAttributeParseable<bool>("underline") ?? false; var underline = _reader.GetOptionalAttributeParseable<bool>("underline") ?? false;

View file

@ -45,7 +45,7 @@ public abstract partial class TmxReaderBase
PropertyType.Int => new IntProperty { Name = name, Value = r.GetRequiredAttributeParseable<int>("value") }, PropertyType.Int => new IntProperty { Name = name, Value = r.GetRequiredAttributeParseable<int>("value") },
PropertyType.Float => new FloatProperty { Name = name, Value = r.GetRequiredAttributeParseable<float>("value") }, PropertyType.Float => new FloatProperty { Name = name, Value = r.GetRequiredAttributeParseable<float>("value") },
PropertyType.Bool => new BoolProperty { Name = name, Value = r.GetRequiredAttributeParseable<bool>("value") }, PropertyType.Bool => new BoolProperty { Name = name, Value = r.GetRequiredAttributeParseable<bool>("value") },
PropertyType.Color => new ColorProperty { Name = name, Value = r.GetRequiredAttributeParseable<Color>("value", s => s == "" ? default : Color.Parse(s, CultureInfo.InvariantCulture)) }, PropertyType.Color => new ColorProperty { Name = name, Value = r.GetRequiredAttributeParseable<TiledColor>("value", s => s == "" ? default : TiledColor.Parse(s, CultureInfo.InvariantCulture)) },
PropertyType.File => new FileProperty { Name = name, Value = r.GetRequiredAttribute("value") }, PropertyType.File => new FileProperty { Name = name, Value = r.GetRequiredAttribute("value") },
PropertyType.Object => new ObjectProperty { Name = name, Value = r.GetRequiredAttributeParseable<uint>("value") }, PropertyType.Object => new ObjectProperty { Name = name, Value = r.GetRequiredAttributeParseable<uint>("value") },
PropertyType.Class => throw new XmlException("Class property must have a property type"), PropertyType.Class => throw new XmlException("Class property must have a property type"),

View file

@ -16,7 +16,7 @@ public abstract partial class TmxReaderBase
var height = _reader.GetRequiredAttributeParseable<int>("height"); var height = _reader.GetRequiredAttributeParseable<int>("height");
var opacity = _reader.GetOptionalAttributeParseable<float>("opacity").GetValueOr(1.0f); var opacity = _reader.GetOptionalAttributeParseable<float>("opacity").GetValueOr(1.0f);
var visible = _reader.GetOptionalAttributeParseable<uint>("visible").GetValueOr(1) == 1; var visible = _reader.GetOptionalAttributeParseable<uint>("visible").GetValueOr(1) == 1;
var tintColor = _reader.GetOptionalAttributeClass<Color>("tintcolor"); var tintColor = _reader.GetOptionalAttributeClass<TiledColor>("tintcolor");
var offsetX = _reader.GetOptionalAttributeParseable<float>("offsetx").GetValueOr(0.0f); var offsetX = _reader.GetOptionalAttributeParseable<float>("offsetx").GetValueOr(0.0f);
var offsetY = _reader.GetOptionalAttributeParseable<float>("offsety").GetValueOr(0.0f); var offsetY = _reader.GetOptionalAttributeParseable<float>("offsety").GetValueOr(0.0f);
var parallaxX = _reader.GetOptionalAttributeParseable<float>("parallaxx").GetValueOr(1.0f); var parallaxX = _reader.GetOptionalAttributeParseable<float>("parallaxx").GetValueOr(1.0f);
@ -63,7 +63,7 @@ public abstract partial class TmxReaderBase
var y = _reader.GetOptionalAttributeParseable<int>("y").GetValueOr(0); var y = _reader.GetOptionalAttributeParseable<int>("y").GetValueOr(0);
var opacity = _reader.GetOptionalAttributeParseable<float>("opacity").GetValueOr(1f); var opacity = _reader.GetOptionalAttributeParseable<float>("opacity").GetValueOr(1f);
var visible = _reader.GetOptionalAttributeParseable<bool>("visible").GetValueOr(true); var visible = _reader.GetOptionalAttributeParseable<bool>("visible").GetValueOr(true);
var tintColor = _reader.GetOptionalAttributeClass<Color>("tintcolor"); var tintColor = _reader.GetOptionalAttributeClass<TiledColor>("tintcolor");
var offsetX = _reader.GetOptionalAttributeParseable<float>("offsetx").GetValueOr(0.0f); var offsetX = _reader.GetOptionalAttributeParseable<float>("offsetx").GetValueOr(0.0f);
var offsetY = _reader.GetOptionalAttributeParseable<float>("offsety").GetValueOr(0.0f); var offsetY = _reader.GetOptionalAttributeParseable<float>("offsety").GetValueOr(0.0f);
var parallaxX = _reader.GetOptionalAttributeParseable<float>("parallaxx").GetValueOr(1.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 @class = _reader.GetOptionalAttribute("class").GetValueOr("");
var opacity = _reader.GetOptionalAttributeParseable<float>("opacity").GetValueOr(1.0f); var opacity = _reader.GetOptionalAttributeParseable<float>("opacity").GetValueOr(1.0f);
var visible = _reader.GetOptionalAttributeParseable<uint>("visible").GetValueOr(1) == 1; var visible = _reader.GetOptionalAttributeParseable<uint>("visible").GetValueOr(1) == 1;
var tintColor = _reader.GetOptionalAttributeClass<Color>("tintcolor"); var tintColor = _reader.GetOptionalAttributeClass<TiledColor>("tintcolor");
var offsetX = _reader.GetOptionalAttributeParseable<float>("offsetx").GetValueOr(0f); var offsetX = _reader.GetOptionalAttributeParseable<float>("offsetx").GetValueOr(0f);
var offsetY = _reader.GetOptionalAttributeParseable<float>("offsety").GetValueOr(0f); var offsetY = _reader.GetOptionalAttributeParseable<float>("offsety").GetValueOr(0f);
var parallaxX = _reader.GetOptionalAttributeParseable<float>("parallaxx").GetValueOr(1f); var parallaxX = _reader.GetOptionalAttributeParseable<float>("parallaxx").GetValueOr(1f);

View file

@ -125,7 +125,7 @@ public abstract partial class TmxReaderBase
_ => throw new InvalidOperationException($"Unknown image format '{s}'") _ => throw new InvalidOperationException($"Unknown image format '{s}'")
}); });
var source = _reader.GetOptionalAttribute("source"); var source = _reader.GetOptionalAttribute("source");
var transparentColor = _reader.GetOptionalAttributeClass<Color>("trans"); var transparentColor = _reader.GetOptionalAttributeClass<TiledColor>("trans");
var width = _reader.GetOptionalAttributeParseable<int>("width"); var width = _reader.GetOptionalAttributeParseable<int>("width");
var height = _reader.GetOptionalAttributeParseable<int>("height"); var height = _reader.GetOptionalAttributeParseable<int>("height");
@ -277,7 +277,7 @@ public abstract partial class TmxReaderBase
// Attributes // Attributes
var name = _reader.GetRequiredAttribute("name"); var name = _reader.GetRequiredAttribute("name");
var @class = _reader.GetOptionalAttribute("class").GetValueOr(""); var @class = _reader.GetOptionalAttribute("class").GetValueOr("");
var color = _reader.GetRequiredAttributeParseable<Color>("color"); var color = _reader.GetRequiredAttributeParseable<TiledColor>("color");
var tile = _reader.GetRequiredAttributeParseable<int>("tile"); var tile = _reader.GetRequiredAttributeParseable<int>("tile");
var probability = _reader.GetOptionalAttributeParseable<float>("probability").GetValueOr(0f); var probability = _reader.GetOptionalAttributeParseable<float>("probability").GetValueOr(0f);

View file

@ -44,7 +44,7 @@ public class Image
/// <summary> /// <summary>
/// Defines a specific color that is treated as transparent. /// Defines a specific color that is treated as transparent.
/// </summary> /// </summary>
public Optional<Color> TransparentColor { get; set; } = Optional<Color>.Empty; public Optional<TiledColor> TransparentColor { get; set; } = Optional<TiledColor>.Empty;
/// <summary> /// <summary>
/// The image width in pixels, used for tile index correction when the image changes. /// The image width in pixels, used for tile index correction when the image changes.

View file

@ -20,7 +20,7 @@ public class WangColor : HasPropertiesBase
/// <summary> /// <summary>
/// The color of the Wang color. /// The color of the Wang color.
/// </summary> /// </summary>
public required Color Color { get; set; } public required TiledColor Color { get; set; }
/// <summary> /// <summary>
/// The tile ID of the tile representing this color. /// The tile ID of the tile representing this color.