mirror of
https://github.com/dcronqvist/DotTiled.git
synced 2025-02-05 08:52:50 +02:00
More property changes
This commit is contained in:
parent
1c1ba326b2
commit
b46eed774a
29 changed files with 99 additions and 61 deletions
|
@ -32,14 +32,14 @@ public static partial class TestData
|
|||
|
||||
public static IEnumerable<object[]> MapTests =>
|
||||
[
|
||||
["Serialization/TestData/Map/default_map/default-map", (string f) => DefaultMap(), Array.Empty<CustomTypeDefinition>()],
|
||||
["Serialization/TestData/Map/map_with_common_props/map-with-common-props", (string f) => MapWithCommonProps(), Array.Empty<CustomTypeDefinition>()],
|
||||
["Serialization/TestData/Map/default_map/default-map", (string f) => DefaultMap(), Array.Empty<ICustomTypeDefinition>()],
|
||||
["Serialization/TestData/Map/map_with_common_props/map-with-common-props", (string f) => MapWithCommonProps(), Array.Empty<ICustomTypeDefinition>()],
|
||||
["Serialization/TestData/Map/map_with_custom_type_props/map-with-custom-type-props", (string f) => MapWithCustomTypeProps(), MapWithCustomTypePropsCustomTypeDefinitions()],
|
||||
["Serialization/TestData/Map/map_with_embedded_tileset/map-with-embedded-tileset", (string f) => MapWithEmbeddedTileset(), Array.Empty<CustomTypeDefinition>()],
|
||||
["Serialization/TestData/Map/map_with_external_tileset/map-with-external-tileset", (string f) => MapWithExternalTileset(f), Array.Empty<CustomTypeDefinition>()],
|
||||
["Serialization/TestData/Map/map_with_flippingflags/map-with-flippingflags", (string f) => MapWithFlippingFlags(f), Array.Empty<CustomTypeDefinition>()],
|
||||
["Serialization/TestData/Map/map_external_tileset_multi/map-external-tileset-multi", (string f) => MapExternalTilesetMulti(f), Array.Empty<CustomTypeDefinition>()],
|
||||
["Serialization/TestData/Map/map_external_tileset_wangset/map-external-tileset-wangset", (string f) => MapExternalTilesetWangset(f), Array.Empty<CustomTypeDefinition>()],
|
||||
["Serialization/TestData/Map/map_with_many_layers/map-with-many-layers", (string f) => MapWithManyLayers(f), Array.Empty<CustomTypeDefinition>()],
|
||||
["Serialization/TestData/Map/map_with_embedded_tileset/map-with-embedded-tileset", (string f) => MapWithEmbeddedTileset(), Array.Empty<ICustomTypeDefinition>()],
|
||||
["Serialization/TestData/Map/map_with_external_tileset/map-with-external-tileset", (string f) => MapWithExternalTileset(f), Array.Empty<ICustomTypeDefinition>()],
|
||||
["Serialization/TestData/Map/map_with_flippingflags/map-with-flippingflags", (string f) => MapWithFlippingFlags(f), Array.Empty<ICustomTypeDefinition>()],
|
||||
["Serialization/TestData/Map/map_external_tileset_multi/map-external-tileset-multi", (string f) => MapExternalTilesetMulti(f), Array.Empty<ICustomTypeDefinition>()],
|
||||
["Serialization/TestData/Map/map_external_tileset_wangset/map-external-tileset-wangset", (string f) => MapExternalTilesetWangset(f), Array.Empty<ICustomTypeDefinition>()],
|
||||
["Serialization/TestData/Map/map_with_many_layers/map-with-many-layers", (string f) => MapWithManyLayers(f), Array.Empty<ICustomTypeDefinition>()],
|
||||
];
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ public partial class TestData
|
|||
};
|
||||
|
||||
// This comes from map-with-custom-type-props/propertytypes.json
|
||||
public static IReadOnlyCollection<CustomTypeDefinition> MapWithCustomTypePropsCustomTypeDefinitions() => [
|
||||
public static IReadOnlyCollection<ICustomTypeDefinition> MapWithCustomTypePropsCustomTypeDefinitions() => [
|
||||
new CustomClassDefinition
|
||||
{
|
||||
Name = "CustomClass",
|
||||
|
|
|
@ -11,7 +11,7 @@ public partial class TmjMapReaderTests
|
|||
public void TmxMapReaderReadMap_ValidTmjExternalTilesetsAndTemplates_ReturnsMapThatEqualsExpected(
|
||||
string testDataFile,
|
||||
Func<string, Map> expectedMap,
|
||||
IReadOnlyCollection<CustomTypeDefinition> customTypeDefinitions)
|
||||
IReadOnlyCollection<ICustomTypeDefinition> customTypeDefinitions)
|
||||
{
|
||||
// Arrange
|
||||
testDataFile += ".tmj";
|
||||
|
|
|
@ -11,7 +11,7 @@ public partial class TmxMapReaderTests
|
|||
public void TmxMapReaderReadMap_ValidXmlExternalTilesetsAndTemplates_ReturnsMapThatEqualsExpected(
|
||||
string testDataFile,
|
||||
Func<string, Map> expectedMap,
|
||||
IReadOnlyCollection<CustomTypeDefinition> customTypeDefinitions)
|
||||
IReadOnlyCollection<ICustomTypeDefinition> customTypeDefinitions)
|
||||
{
|
||||
// Arrange
|
||||
testDataFile += ".tmx";
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
|
@ -38,7 +39,16 @@ public class ClassProperty : IHasProperties, IProperty<IList<IProperty>>
|
|||
public IList<IProperty> GetProperties() => Value;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public T GetProperty<T>(string name) where T : IProperty => throw new System.NotImplementedException();
|
||||
public T GetProperty<T>(string name) where T : IProperty
|
||||
{
|
||||
var property = Value.FirstOrDefault(_properties => _properties.Name == name) ?? throw new InvalidOperationException($"Property '{name}' not found.");
|
||||
if (property is T prop)
|
||||
{
|
||||
return prop;
|
||||
}
|
||||
|
||||
throw new InvalidOperationException($"Property '{name}' is not of type '{typeof(T).Name}'.");
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public bool TryGetProperty<T>(string name, [NotNullWhen(true)] out T? property) where T : IProperty
|
||||
|
|
|
@ -65,8 +65,14 @@ public enum CustomClassUseAs
|
|||
/// Represents a custom class definition in Tiled. Refer to the
|
||||
/// <see href="https://doc.mapeditor.org/en/stable/manual/custom-properties/#custom-types">documentation of custom types to understand how they work</see>.
|
||||
/// </summary>
|
||||
public class CustomClassDefinition : CustomTypeDefinition
|
||||
public class CustomClassDefinition : HasPropertiesBase, ICustomTypeDefinition
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public uint ID { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public required string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The color of the custom class inside the Tiled editor.
|
||||
/// </summary>
|
||||
|
@ -86,4 +92,7 @@ public class CustomClassDefinition : CustomTypeDefinition
|
|||
/// The members of the custom class, with their names, types and default values.
|
||||
/// </summary>
|
||||
public List<IProperty> Members { get; set; } = [];
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override IList<IProperty> GetProperties() => Members;
|
||||
}
|
||||
|
|
|
@ -22,8 +22,14 @@ public enum CustomEnumStorageType
|
|||
/// Represents a custom enum definition in Tiled. Refer to the
|
||||
/// <see href="https://doc.mapeditor.org/en/stable/manual/custom-properties/#custom-types">documentation of custom types to understand how they work</see>.
|
||||
/// </summary>
|
||||
public class CustomEnumDefinition : CustomTypeDefinition
|
||||
public class CustomEnumDefinition : ICustomTypeDefinition
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public uint ID { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public required string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The storage type of the custom enum.
|
||||
/// </summary>
|
||||
|
|
|
@ -3,7 +3,7 @@ namespace DotTiled.Model;
|
|||
/// <summary>
|
||||
/// Base class for custom type definitions.
|
||||
/// </summary>
|
||||
public abstract class CustomTypeDefinition
|
||||
public interface ICustomTypeDefinition
|
||||
{
|
||||
/// <summary>
|
||||
/// The ID of the custom type.
|
||||
|
@ -13,5 +13,5 @@ public abstract class CustomTypeDefinition
|
|||
/// <summary>
|
||||
/// The name of the custom type.
|
||||
/// </summary>
|
||||
public string Name { get; set; } = "";
|
||||
public string Name { get; set; }
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
|
@ -33,7 +34,7 @@ public interface IHasProperties
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Base class for objects that have properties attached to them.
|
||||
/// Interface for objects that have properties attached to them.
|
||||
/// </summary>
|
||||
public abstract class HasPropertiesBase : IHasProperties
|
||||
{
|
||||
|
@ -41,7 +42,19 @@ public abstract class HasPropertiesBase : IHasProperties
|
|||
public abstract IList<IProperty> GetProperties();
|
||||
|
||||
/// <inheritdoc/>
|
||||
public T GetProperty<T>(string name) where T : IProperty => throw new System.NotImplementedException();
|
||||
/// <exception cref="KeyNotFoundException">Thrown when a property with the specified name is not found.</exception>
|
||||
/// <exception cref="InvalidCastException">Thrown when a property with the specified name is not of the specified type.</exception>
|
||||
public T GetProperty<T>(string name) where T : IProperty
|
||||
{
|
||||
var properties = GetProperties();
|
||||
var property = properties.FirstOrDefault(_properties => _properties.Name == name) ?? throw new KeyNotFoundException($"Property '{name}' not found.");
|
||||
if (property is T prop)
|
||||
{
|
||||
return prop;
|
||||
}
|
||||
|
||||
throw new InvalidCastException($"Property '{name}' is not of type '{typeof(T).Name}'.");
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public bool TryGetProperty<T>(string name, [NotNullWhen(true)] out T? property) where T : IProperty
|
||||
|
|
|
@ -16,7 +16,7 @@ public class TjTemplateReader : ITemplateReader
|
|||
private readonly string _jsonString;
|
||||
private bool disposedValue;
|
||||
|
||||
private readonly IReadOnlyCollection<CustomTypeDefinition> _customTypeDefinitions;
|
||||
private readonly IReadOnlyCollection<ICustomTypeDefinition> _customTypeDefinitions;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new <see cref="TjTemplateReader"/>.
|
||||
|
@ -30,7 +30,7 @@ public class TjTemplateReader : ITemplateReader
|
|||
string jsonString,
|
||||
Func<string, Tileset> externalTilesetResolver,
|
||||
Func<string, Template> externalTemplateResolver,
|
||||
IReadOnlyCollection<CustomTypeDefinition> customTypeDefinitions)
|
||||
IReadOnlyCollection<ICustomTypeDefinition> customTypeDefinitions)
|
||||
{
|
||||
_jsonString = jsonString ?? throw new ArgumentNullException(nameof(jsonString));
|
||||
_externalTilesetResolver = externalTilesetResolver ?? throw new ArgumentNullException(nameof(externalTilesetResolver));
|
||||
|
|
|
@ -11,7 +11,7 @@ internal partial class Tmj
|
|||
internal static Group ReadGroup(
|
||||
JsonElement element,
|
||||
Func<string, Template> externalTemplateResolver,
|
||||
IReadOnlyCollection<CustomTypeDefinition> customTypeDefinitions)
|
||||
IReadOnlyCollection<ICustomTypeDefinition> customTypeDefinitions)
|
||||
{
|
||||
var id = element.GetRequiredProperty<uint>("id");
|
||||
var name = element.GetRequiredProperty<string>("name");
|
||||
|
|
|
@ -9,7 +9,7 @@ internal partial class Tmj
|
|||
{
|
||||
internal static ImageLayer ReadImageLayer(
|
||||
JsonElement element,
|
||||
IReadOnlyCollection<CustomTypeDefinition> customTypeDefinitions)
|
||||
IReadOnlyCollection<ICustomTypeDefinition> customTypeDefinitions)
|
||||
{
|
||||
var id = element.GetRequiredProperty<uint>("id");
|
||||
var name = element.GetRequiredProperty<string>("name");
|
||||
|
|
|
@ -10,7 +10,7 @@ internal partial class Tmj
|
|||
internal static BaseLayer ReadLayer(
|
||||
JsonElement element,
|
||||
Func<string, Template> externalTemplateResolver,
|
||||
IReadOnlyCollection<CustomTypeDefinition> customTypeDefinitions)
|
||||
IReadOnlyCollection<ICustomTypeDefinition> customTypeDefinitions)
|
||||
{
|
||||
var type = element.GetRequiredProperty<string>("type");
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ internal partial class Tmj
|
|||
JsonElement element,
|
||||
Func<string, Tileset>? externalTilesetResolver,
|
||||
Func<string, Template> externalTemplateResolver,
|
||||
IReadOnlyCollection<CustomTypeDefinition> customTypeDefinitions)
|
||||
IReadOnlyCollection<ICustomTypeDefinition> customTypeDefinitions)
|
||||
{
|
||||
var version = element.GetRequiredProperty<string>("version");
|
||||
var tiledVersion = element.GetRequiredProperty<string>("tiledversion");
|
||||
|
|
|
@ -12,7 +12,7 @@ internal partial class Tmj
|
|||
internal static ObjectLayer ReadObjectLayer(
|
||||
JsonElement element,
|
||||
Func<string, Template> externalTemplateResolver,
|
||||
IReadOnlyCollection<CustomTypeDefinition> customTypeDefinitions)
|
||||
IReadOnlyCollection<ICustomTypeDefinition> customTypeDefinitions)
|
||||
{
|
||||
var id = element.GetRequiredProperty<uint>("id");
|
||||
var name = element.GetRequiredProperty<string>("name");
|
||||
|
@ -66,7 +66,7 @@ internal partial class Tmj
|
|||
internal static Model.Object ReadObject(
|
||||
JsonElement element,
|
||||
Func<string, Template> externalTemplateResolver,
|
||||
IReadOnlyCollection<CustomTypeDefinition> customTypeDefinitions)
|
||||
IReadOnlyCollection<ICustomTypeDefinition> customTypeDefinitions)
|
||||
{
|
||||
uint? idDefault = null;
|
||||
string nameDefault = "";
|
||||
|
|
|
@ -10,7 +10,7 @@ internal partial class Tmj
|
|||
{
|
||||
internal static Dictionary<string, IProperty> ReadProperties(
|
||||
JsonElement element,
|
||||
IReadOnlyCollection<CustomTypeDefinition> customTypeDefinitions) =>
|
||||
IReadOnlyCollection<ICustomTypeDefinition> customTypeDefinitions) =>
|
||||
element.GetValueAsList<IProperty>(e =>
|
||||
{
|
||||
var name = e.GetRequiredProperty<string>("name");
|
||||
|
@ -45,7 +45,7 @@ internal partial class Tmj
|
|||
|
||||
internal static List<IProperty> ReadPropertiesList(
|
||||
JsonElement element,
|
||||
IReadOnlyCollection<CustomTypeDefinition> customTypeDefinitions) =>
|
||||
IReadOnlyCollection<ICustomTypeDefinition> customTypeDefinitions) =>
|
||||
element.GetValueAsList<IProperty>(e =>
|
||||
{
|
||||
var name = e.GetRequiredProperty<string>("name");
|
||||
|
@ -80,7 +80,7 @@ internal partial class Tmj
|
|||
|
||||
internal static ClassProperty ReadClassProperty(
|
||||
JsonElement element,
|
||||
IReadOnlyCollection<CustomTypeDefinition> customTypeDefinitions)
|
||||
IReadOnlyCollection<ICustomTypeDefinition> customTypeDefinitions)
|
||||
{
|
||||
var name = element.GetRequiredProperty<string>("name");
|
||||
var propertyType = element.GetRequiredProperty<string>("propertytype");
|
||||
|
@ -108,7 +108,7 @@ internal partial class Tmj
|
|||
internal static List<IProperty> ReadCustomClassProperties(
|
||||
JsonElement element,
|
||||
CustomClassDefinition customClassDefinition,
|
||||
IReadOnlyCollection<CustomTypeDefinition> customTypeDefinitions)
|
||||
IReadOnlyCollection<ICustomTypeDefinition> customTypeDefinitions)
|
||||
{
|
||||
List<IProperty> resultingProps = Helpers.CreateInstanceOfCustomClass(customClassDefinition);
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ internal partial class Tmj
|
|||
JsonElement element,
|
||||
Func<string, Tileset> externalTilesetResolver,
|
||||
Func<string, Template> externalTemplateResolver,
|
||||
IReadOnlyCollection<CustomTypeDefinition> customTypeDefinitions)
|
||||
IReadOnlyCollection<ICustomTypeDefinition> customTypeDefinitions)
|
||||
{
|
||||
var type = element.GetRequiredProperty<string>("type");
|
||||
var tileset = element.GetOptionalPropertyCustom<Tileset?>("tileset", el => ReadTileset(el, externalTilesetResolver, externalTemplateResolver, customTypeDefinitions), null);
|
||||
|
|
|
@ -9,7 +9,7 @@ internal partial class Tmj
|
|||
{
|
||||
internal static TileLayer ReadTileLayer(
|
||||
JsonElement element,
|
||||
IReadOnlyCollection<CustomTypeDefinition> customTypeDefinitions)
|
||||
IReadOnlyCollection<ICustomTypeDefinition> customTypeDefinitions)
|
||||
{
|
||||
var compression = element.GetOptionalPropertyParseable<DataCompression?>("compression", s => s switch
|
||||
{
|
||||
|
|
|
@ -12,7 +12,7 @@ internal partial class Tmj
|
|||
JsonElement element,
|
||||
Func<string, Tileset>? externalTilesetResolver,
|
||||
Func<string, Template> externalTemplateResolver,
|
||||
IReadOnlyCollection<CustomTypeDefinition> customTypeDefinitions)
|
||||
IReadOnlyCollection<ICustomTypeDefinition> customTypeDefinitions)
|
||||
{
|
||||
var backgroundColor = element.GetOptionalPropertyParseable<Color?>("backgroundcolor", s => Color.Parse(s, CultureInfo.InvariantCulture), null);
|
||||
var @class = element.GetOptionalProperty<string>("class", "");
|
||||
|
@ -162,7 +162,7 @@ internal partial class Tmj
|
|||
internal static List<Tile> ReadTiles(
|
||||
JsonElement element,
|
||||
Func<string, Template> externalTemplateResolver,
|
||||
IReadOnlyCollection<CustomTypeDefinition> customTypeDefinitions) =>
|
||||
IReadOnlyCollection<ICustomTypeDefinition> customTypeDefinitions) =>
|
||||
element.GetValueAsList<Tile>(e =>
|
||||
{
|
||||
var animation = e.GetOptionalPropertyCustom<List<Frame>?>("animation", e => e.GetValueAsList<Frame>(ReadFrame), null);
|
||||
|
@ -218,7 +218,7 @@ internal partial class Tmj
|
|||
|
||||
internal static Wangset ReadWangset(
|
||||
JsonElement element,
|
||||
IReadOnlyCollection<CustomTypeDefinition> customTypeDefinitions)
|
||||
IReadOnlyCollection<ICustomTypeDefinition> customTypeDefinitions)
|
||||
{
|
||||
var @clalss = element.GetOptionalProperty<string>("class", "");
|
||||
var colors = element.GetOptionalPropertyCustom<List<WangColor>>("colors", e => e.GetValueAsList<WangColor>(el => ReadWangColor(el, customTypeDefinitions)), []);
|
||||
|
@ -241,7 +241,7 @@ internal partial class Tmj
|
|||
|
||||
internal static WangColor ReadWangColor(
|
||||
JsonElement element,
|
||||
IReadOnlyCollection<CustomTypeDefinition> customTypeDefinitions)
|
||||
IReadOnlyCollection<ICustomTypeDefinition> customTypeDefinitions)
|
||||
{
|
||||
var @class = element.GetOptionalProperty<string>("class", "");
|
||||
var color = element.GetRequiredPropertyParseable<Color>("color", s => Color.Parse(s, CultureInfo.InvariantCulture));
|
||||
|
|
|
@ -17,7 +17,7 @@ public class TmjMapReader : IMapReader
|
|||
private readonly string _jsonString;
|
||||
private bool disposedValue;
|
||||
|
||||
private readonly IReadOnlyCollection<CustomTypeDefinition> _customTypeDefinitions;
|
||||
private readonly IReadOnlyCollection<ICustomTypeDefinition> _customTypeDefinitions;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new <see cref="TmjMapReader"/>.
|
||||
|
@ -31,7 +31,7 @@ public class TmjMapReader : IMapReader
|
|||
string jsonString,
|
||||
Func<string, Tileset> externalTilesetResolver,
|
||||
Func<string, Template> externalTemplateResolver,
|
||||
IReadOnlyCollection<CustomTypeDefinition> customTypeDefinitions)
|
||||
IReadOnlyCollection<ICustomTypeDefinition> customTypeDefinitions)
|
||||
{
|
||||
_jsonString = jsonString ?? throw new ArgumentNullException(nameof(jsonString));
|
||||
_externalTilesetResolver = externalTilesetResolver ?? throw new ArgumentNullException(nameof(externalTilesetResolver));
|
||||
|
|
|
@ -15,7 +15,7 @@ public class TsjTilesetReader : ITilesetReader
|
|||
private readonly string _jsonString;
|
||||
private bool disposedValue;
|
||||
|
||||
private readonly IReadOnlyCollection<CustomTypeDefinition> _customTypeDefinitions;
|
||||
private readonly IReadOnlyCollection<ICustomTypeDefinition> _customTypeDefinitions;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new <see cref="TsjTilesetReader"/>.
|
||||
|
@ -27,7 +27,7 @@ public class TsjTilesetReader : ITilesetReader
|
|||
public TsjTilesetReader(
|
||||
string jsonString,
|
||||
Func<string, Template> externalTemplateResolver,
|
||||
IReadOnlyCollection<CustomTypeDefinition> customTypeDefinitions)
|
||||
IReadOnlyCollection<ICustomTypeDefinition> customTypeDefinitions)
|
||||
{
|
||||
_jsonString = jsonString ?? throw new ArgumentNullException(nameof(jsonString));
|
||||
_externalTemplateResolver = externalTemplateResolver ?? throw new ArgumentNullException(nameof(externalTemplateResolver));
|
||||
|
|
|
@ -13,7 +13,7 @@ internal partial class Tmx
|
|||
XmlReader reader,
|
||||
Func<string, Tileset> externalTilesetResolver,
|
||||
Func<string, Template> externalTemplateResolver,
|
||||
IReadOnlyCollection<CustomTypeDefinition> customTypeDefinitions)
|
||||
IReadOnlyCollection<ICustomTypeDefinition> customTypeDefinitions)
|
||||
{
|
||||
// Attributes
|
||||
var version = reader.GetRequiredAttribute("version");
|
||||
|
|
|
@ -13,7 +13,7 @@ internal partial class Tmx
|
|||
internal static ObjectLayer ReadObjectLayer(
|
||||
XmlReader reader,
|
||||
Func<string, Template> externalTemplateResolver,
|
||||
IReadOnlyCollection<CustomTypeDefinition> customTypeDefinitions)
|
||||
IReadOnlyCollection<ICustomTypeDefinition> customTypeDefinitions)
|
||||
{
|
||||
// Attributes
|
||||
var id = reader.GetRequiredAttributeParseable<uint>("id");
|
||||
|
@ -75,7 +75,7 @@ internal partial class Tmx
|
|||
internal static Model.Object ReadObject(
|
||||
XmlReader reader,
|
||||
Func<string, Template> externalTemplateResolver,
|
||||
IReadOnlyCollection<CustomTypeDefinition> customTypeDefinitions)
|
||||
IReadOnlyCollection<ICustomTypeDefinition> customTypeDefinitions)
|
||||
{
|
||||
// Attributes
|
||||
var template = reader.GetOptionalAttribute("template");
|
||||
|
@ -308,7 +308,7 @@ internal partial class Tmx
|
|||
XmlReader reader,
|
||||
Func<string, Tileset> externalTilesetResolver,
|
||||
Func<string, Template> externalTemplateResolver,
|
||||
IReadOnlyCollection<CustomTypeDefinition> customTypeDefinitions)
|
||||
IReadOnlyCollection<ICustomTypeDefinition> customTypeDefinitions)
|
||||
{
|
||||
// No attributes
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ internal partial class Tmx
|
|||
{
|
||||
internal static Dictionary<string, IProperty> ReadProperties(
|
||||
XmlReader reader,
|
||||
IReadOnlyCollection<CustomTypeDefinition> customTypeDefinitions)
|
||||
IReadOnlyCollection<ICustomTypeDefinition> customTypeDefinitions)
|
||||
{
|
||||
return reader.ReadList("properties", "property", (r) =>
|
||||
{
|
||||
|
@ -45,7 +45,7 @@ internal partial class Tmx
|
|||
|
||||
internal static List<IProperty> ReadPropertiesList(
|
||||
XmlReader reader,
|
||||
IReadOnlyCollection<CustomTypeDefinition> customTypeDefinitions)
|
||||
IReadOnlyCollection<ICustomTypeDefinition> customTypeDefinitions)
|
||||
{
|
||||
return reader.ReadList("properties", "property", (r) =>
|
||||
{
|
||||
|
@ -81,7 +81,7 @@ internal partial class Tmx
|
|||
|
||||
internal static ClassProperty ReadClassProperty(
|
||||
XmlReader reader,
|
||||
IReadOnlyCollection<CustomTypeDefinition> customTypeDefinitions)
|
||||
IReadOnlyCollection<ICustomTypeDefinition> customTypeDefinitions)
|
||||
{
|
||||
var name = reader.GetRequiredAttribute("name");
|
||||
var propertyType = reader.GetRequiredAttribute("propertytype");
|
||||
|
|
|
@ -11,7 +11,7 @@ internal partial class Tmx
|
|||
internal static TileLayer ReadTileLayer(
|
||||
XmlReader reader,
|
||||
bool dataUsesChunks,
|
||||
IReadOnlyCollection<CustomTypeDefinition> customTypeDefinitions)
|
||||
IReadOnlyCollection<ICustomTypeDefinition> customTypeDefinitions)
|
||||
{
|
||||
var id = reader.GetRequiredAttributeParseable<uint>("id");
|
||||
var name = reader.GetOptionalAttribute("name") ?? "";
|
||||
|
@ -61,7 +61,7 @@ internal partial class Tmx
|
|||
|
||||
internal static ImageLayer ReadImageLayer(
|
||||
XmlReader reader,
|
||||
IReadOnlyCollection<CustomTypeDefinition> customTypeDefinitions)
|
||||
IReadOnlyCollection<ICustomTypeDefinition> customTypeDefinitions)
|
||||
{
|
||||
var id = reader.GetRequiredAttributeParseable<uint>("id");
|
||||
var name = reader.GetOptionalAttribute("name") ?? "";
|
||||
|
@ -112,7 +112,7 @@ internal partial class Tmx
|
|||
internal static Group ReadGroup(
|
||||
XmlReader reader,
|
||||
Func<string, Template> externalTemplateResolver,
|
||||
IReadOnlyCollection<CustomTypeDefinition> customTypeDefinitions)
|
||||
IReadOnlyCollection<ICustomTypeDefinition> customTypeDefinitions)
|
||||
{
|
||||
var id = reader.GetRequiredAttributeParseable<uint>("id");
|
||||
var name = reader.GetOptionalAttribute("name") ?? "";
|
||||
|
|
|
@ -14,7 +14,7 @@ internal partial class Tmx
|
|||
XmlReader reader,
|
||||
Func<string, Tileset>? externalTilesetResolver,
|
||||
Func<string, Template> externalTemplateResolver,
|
||||
IReadOnlyCollection<CustomTypeDefinition> customTypeDefinitions)
|
||||
IReadOnlyCollection<ICustomTypeDefinition> customTypeDefinitions)
|
||||
{
|
||||
// Attributes
|
||||
var version = reader.GetOptionalAttribute("version");
|
||||
|
@ -207,7 +207,7 @@ internal partial class Tmx
|
|||
internal static Tile ReadTile(
|
||||
XmlReader reader,
|
||||
Func<string, Template> externalTemplateResolver,
|
||||
IReadOnlyCollection<CustomTypeDefinition> customTypeDefinitions)
|
||||
IReadOnlyCollection<ICustomTypeDefinition> customTypeDefinitions)
|
||||
{
|
||||
// Attributes
|
||||
var id = reader.GetRequiredAttributeParseable<uint>("id");
|
||||
|
@ -256,12 +256,12 @@ internal partial class Tmx
|
|||
|
||||
internal static List<Wangset> ReadWangsets(
|
||||
XmlReader reader,
|
||||
IReadOnlyCollection<CustomTypeDefinition> customTypeDefinitions) =>
|
||||
IReadOnlyCollection<ICustomTypeDefinition> customTypeDefinitions) =>
|
||||
reader.ReadList<Wangset>("wangsets", "wangset", r => ReadWangset(r, customTypeDefinitions));
|
||||
|
||||
internal static Wangset ReadWangset(
|
||||
XmlReader reader,
|
||||
IReadOnlyCollection<CustomTypeDefinition> customTypeDefinitions)
|
||||
IReadOnlyCollection<ICustomTypeDefinition> customTypeDefinitions)
|
||||
{
|
||||
// Attributes
|
||||
var name = reader.GetRequiredAttribute("name");
|
||||
|
@ -297,7 +297,7 @@ internal partial class Tmx
|
|||
|
||||
internal static WangColor ReadWangColor(
|
||||
XmlReader reader,
|
||||
IReadOnlyCollection<CustomTypeDefinition> customTypeDefinitions)
|
||||
IReadOnlyCollection<ICustomTypeDefinition> customTypeDefinitions)
|
||||
{
|
||||
// Attributes
|
||||
var name = reader.GetRequiredAttribute("name");
|
||||
|
|
|
@ -17,7 +17,7 @@ public class TmxMapReader : IMapReader
|
|||
private readonly XmlReader _reader;
|
||||
private bool disposedValue;
|
||||
|
||||
private readonly IReadOnlyCollection<CustomTypeDefinition> _customTypeDefinitions;
|
||||
private readonly IReadOnlyCollection<ICustomTypeDefinition> _customTypeDefinitions;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new <see cref="TmxMapReader"/>.
|
||||
|
@ -31,7 +31,7 @@ public class TmxMapReader : IMapReader
|
|||
XmlReader reader,
|
||||
Func<string, Tileset> externalTilesetResolver,
|
||||
Func<string, Template> externalTemplateResolver,
|
||||
IReadOnlyCollection<CustomTypeDefinition> customTypeDefinitions)
|
||||
IReadOnlyCollection<ICustomTypeDefinition> customTypeDefinitions)
|
||||
{
|
||||
_reader = reader ?? throw new ArgumentNullException(nameof(reader));
|
||||
_externalTilesetResolver = externalTilesetResolver ?? throw new ArgumentNullException(nameof(externalTilesetResolver));
|
||||
|
|
|
@ -16,7 +16,7 @@ public class TsxTilesetReader : ITilesetReader
|
|||
private readonly XmlReader _reader;
|
||||
private bool disposedValue;
|
||||
|
||||
private readonly IReadOnlyCollection<CustomTypeDefinition> _customTypeDefinitions;
|
||||
private readonly IReadOnlyCollection<ICustomTypeDefinition> _customTypeDefinitions;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new <see cref="TsxTilesetReader"/>.
|
||||
|
@ -28,7 +28,7 @@ public class TsxTilesetReader : ITilesetReader
|
|||
public TsxTilesetReader(
|
||||
XmlReader reader,
|
||||
Func<string, Template> externalTemplateResolver,
|
||||
IReadOnlyCollection<CustomTypeDefinition> customTypeDefinitions)
|
||||
IReadOnlyCollection<ICustomTypeDefinition> customTypeDefinitions)
|
||||
{
|
||||
_reader = reader ?? throw new ArgumentNullException(nameof(reader));
|
||||
_externalTemplateResolver = externalTemplateResolver ?? throw new ArgumentNullException(nameof(externalTemplateResolver));
|
||||
|
|
|
@ -17,7 +17,7 @@ public class TxTemplateReader : ITemplateReader
|
|||
private readonly XmlReader _reader;
|
||||
private bool disposedValue;
|
||||
|
||||
private readonly IReadOnlyCollection<CustomTypeDefinition> _customTypeDefinitions;
|
||||
private readonly IReadOnlyCollection<ICustomTypeDefinition> _customTypeDefinitions;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new <see cref="TxTemplateReader"/>.
|
||||
|
@ -31,7 +31,7 @@ public class TxTemplateReader : ITemplateReader
|
|||
XmlReader reader,
|
||||
Func<string, Tileset> externalTilesetResolver,
|
||||
Func<string, Template> externalTemplateResolver,
|
||||
IReadOnlyCollection<CustomTypeDefinition> customTypeDefinitions)
|
||||
IReadOnlyCollection<ICustomTypeDefinition> customTypeDefinitions)
|
||||
{
|
||||
_reader = reader ?? throw new ArgumentNullException(nameof(reader));
|
||||
_externalTilesetResolver = externalTilesetResolver ?? throw new ArgumentNullException(nameof(externalTilesetResolver));
|
||||
|
|
Loading…
Add table
Reference in a new issue