From 69068b83ec30f6444221e907f75c777002b45950 Mon Sep 17 00:00:00 2001 From: Ruben Labruyere Date: Sat, 4 Sep 2021 11:22:23 +0200 Subject: [PATCH] Added support for layer properties --- src/TiledCS.csproj | 2 +- src/TiledMap.cs | 16 ++++++++++++++-- src/TiledModels.cs | 4 ++++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/TiledCS.csproj b/src/TiledCS.csproj index c501b5e..19fe989 100644 --- a/src/TiledCS.csproj +++ b/src/TiledCS.csproj @@ -1,7 +1,7 @@ - 2.2.3 + 2.3.0 Ruben Labruyere Ruben Labruyere TiledCS diff --git a/src/TiledMap.cs b/src/TiledMap.cs index 6dab4dd..68a4780 100755 --- a/src/TiledMap.cs +++ b/src/TiledMap.cs @@ -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"]; @@ -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") { @@ -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"]; @@ -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); } diff --git a/src/TiledModels.cs b/src/TiledModels.cs index 37dc6c4..8e4ebf5 100644 --- a/src/TiledModels.cs +++ b/src/TiledModels.cs @@ -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. /// public TiledObject[] objects; + /// + /// The layer properties if set + /// + public TiledProperty[] properties; } ///