Skip to content

Commit

Permalink
Added support for layer properties
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBoneJarmer committed Sep 4, 2021
1 parent 9fc3ced commit 69068b8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/TiledCS.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Version>2.2.3</Version>
<Version>2.3.0</Version>
<Authors>Ruben Labruyere</Authors>
<Company>Ruben Labruyere</Company>
<PackageId>TiledCS</PackageId>
Expand Down
16 changes: 14 additions & 2 deletions src/TiledMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ private TiledLayer[] ParseLayers(XmlNodeList nodeListLayers, XmlNodeList nodeLis
foreach (XmlNode node in nodeListLayers)
{
var nodeData = node.SelectSingleNode("data");
var nodesProperty = node.SelectNodes("properties/property");
var encoding = nodeData.Attributes["encoding"].Value;
var attrVisible = node.Attributes["visible"];

Expand All @@ -194,9 +195,14 @@ private TiledLayer[] ParseLayers(XmlNodeList nodeListLayers, XmlNodeList nodeLis
tiledLayer.type = "tilelayer";
tiledLayer.visible = true;

if (attrVisible != null) {
if (attrVisible != null)
{
tiledLayer.visible = attrVisible.Value == "1";
}
if (nodesProperty != null)
{
tiledLayer.properties = ParseProperties(nodesProperty);
}

if (encoding == "csv")
{
Expand Down Expand Up @@ -317,6 +323,7 @@ private TiledLayer[] ParseLayers(XmlNodeList nodeListLayers, XmlNodeList nodeLis

foreach (XmlNode node in nodeListObjGroups)
{
var nodesProperty = node.SelectNodes("properties/property");
var nodesObject = node.SelectNodes("object");
var attrVisible = node.Attributes["visible"];

Expand All @@ -327,9 +334,14 @@ private TiledLayer[] ParseLayers(XmlNodeList nodeListLayers, XmlNodeList nodeLis
tiledLayer.type = "objectgroup";
tiledLayer.visible = true;

if (attrVisible != null) {
if (attrVisible != null)
{
tiledLayer.visible = attrVisible.Value == "1";
}
if (nodesProperty != null)
{
tiledLayer.properties = ParseProperties(nodesProperty);
}

result.Add(tiledLayer);
}
Expand Down
4 changes: 4 additions & 0 deletions src/TiledModels.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ public class TiledLayer
/// The list of objects in case of an objectgroup layer. Is null when the layer has no objects.
/// </summary>
public TiledObject[] objects;
/// <summary>
/// The layer properties if set
/// </summary>
public TiledProperty[] properties;
}

/// <summary>
Expand Down

0 comments on commit 69068b8

Please sign in to comment.