mirror of
https://github.com/AlexMacocian/MonoGame.Extended.git
synced 2026-07-16 07:29:29 +00:00
Merge pull request #776 from surprised-turtle/tiled-1.9.0-fix
Tiled: Support class attribute as alias for object types
This commit is contained in:
@@ -69,6 +69,9 @@ namespace MonoGame.Extended.Content.Pipeline.Tiled
|
||||
|
||||
if (string.IsNullOrWhiteSpace(obj.Type) && !string.IsNullOrWhiteSpace(template.Object.Type))
|
||||
obj.Type = template.Object.Type;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(obj.Class) && !string.IsNullOrWhiteSpace(template.Object.Class))
|
||||
obj.Class = template.Object.Class;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace MonoGame.Extended.Content.Pipeline.Tiled
|
||||
|
||||
writer.Write(@object.Identifier);
|
||||
writer.Write(@object.Name ?? string.Empty);
|
||||
writer.Write(@object.Type ?? string.Empty);
|
||||
writer.Write(@object.Class ?? @object.Type ?? string.Empty);
|
||||
writer.Write(@object.X);
|
||||
writer.Write(@object.Y);
|
||||
writer.Write(@object.Width);
|
||||
|
||||
@@ -152,7 +152,7 @@ namespace MonoGame.Extended.Content.Pipeline.Tiled
|
||||
|
||||
writer.Write(@object.Identifier);
|
||||
writer.Write(@object.Name ?? string.Empty);
|
||||
writer.Write(@object.Type ?? string.Empty);
|
||||
writer.Write(@object.Class ?? @object.Type ?? string.Empty);
|
||||
writer.Write(@object.X);
|
||||
writer.Write(@object.Y);
|
||||
writer.Write(@object.Width);
|
||||
|
||||
@@ -29,9 +29,13 @@ namespace MonoGame.Extended.Tiled.Serialization
|
||||
[XmlAttribute(DataType = "string", AttributeName = "name")]
|
||||
public string Name { get; set; }
|
||||
|
||||
// Deprecated as of Tiled 1.9.0 (replaced by "class" attribute)
|
||||
[XmlAttribute(DataType = "string", AttributeName = "type")]
|
||||
public string Type { get; set; }
|
||||
|
||||
[XmlAttribute(DataType = "string", AttributeName = "class")]
|
||||
public string Class { get; set; }
|
||||
|
||||
[XmlAttribute(DataType = "float", AttributeName = "x")]
|
||||
public float X { get => _x ?? 0; set => _x = value; }
|
||||
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
</properties>
|
||||
<ellipse/>
|
||||
</object>
|
||||
<object id="7" x="240" y="440" width="322" height="186" visible="0"/>
|
||||
<object id="7" class="sprite" x="240" y="440" width="322" height="186" visible="0"/>
|
||||
<object id="8" type="rectangle" x="506" y="142" width="136" height="234">
|
||||
<properties>
|
||||
<property name="area" value="player-spawn"/>
|
||||
|
||||
+1
@@ -177,6 +177,7 @@ namespace MonoGame.Extended.Content.Pipeline.Tests.Tiled
|
||||
Assert.Equal((uint)0, tmxObjectGroup.Objects[1].GlobalIdentifier);
|
||||
Assert.Equal((uint)23, tmxObjectGroup.Objects[5].GlobalIdentifier);
|
||||
Assert.Equal("rectangle", tmxObjectGroup.Objects[2].Type);
|
||||
Assert.Equal("sprite", tmxObjectGroup.Objects[1].Class);
|
||||
Assert.NotNull(tmxPolygon);
|
||||
Assert.Equal("0,0 180,90 -8,275 -45,81 38,77", tmxPolygon.Points);
|
||||
Assert.NotNull(tmxPolyline);
|
||||
|
||||
Reference in New Issue
Block a user