Skip to content
Snippets Groups Projects
Unverified Commit 46f80546 authored by David M's avatar David M
Browse files

Add parsing layer id

parent 0ca8ff1a
No related branches found
No related tags found
No related merge requests found
...@@ -54,6 +54,7 @@ pub struct Layer { ...@@ -54,6 +54,7 @@ pub struct Layer {
pub tiles: LayerData, pub tiles: LayerData,
pub properties: Properties, pub properties: Properties,
pub layer_index: u32, pub layer_index: u32,
pub id: u32,
} }
impl Layer { impl Layer {
...@@ -64,7 +65,7 @@ impl Layer { ...@@ -64,7 +65,7 @@ impl Layer {
layer_index: u32, layer_index: u32,
infinite: bool, infinite: bool,
) -> Result<Layer, TiledError> { ) -> Result<Layer, TiledError> {
let ((o, v, ox, oy), n) = get_attrs!( let ((o, v, ox, oy), (n, id)) = get_attrs!(
attrs, attrs,
optionals: [ optionals: [
("opacity", opacity, |v:String| v.parse().ok()), ("opacity", opacity, |v:String| v.parse().ok()),
...@@ -74,6 +75,7 @@ impl Layer { ...@@ -74,6 +75,7 @@ impl Layer {
], ],
required: [ required: [
("name", name, |v| Some(v)), ("name", name, |v| Some(v)),
("id", id, |v:String| v.parse::<u32>().ok()),
], ],
TiledError::MalformedAttributes("layer must have a name".to_string()) TiledError::MalformedAttributes("layer must have a name".to_string())
); );
...@@ -103,6 +105,7 @@ impl Layer { ...@@ -103,6 +105,7 @@ impl Layer {
tiles: tiles, tiles: tiles,
properties: properties, properties: properties,
layer_index, layer_index,
id,
}) })
} }
} }
......
...@@ -20,6 +20,7 @@ pub struct ObjectGroup { ...@@ -20,6 +20,7 @@ pub struct ObjectGroup {
*/ */
pub layer_index: Option<u32>, pub layer_index: Option<u32>,
pub properties: Properties, pub properties: Properties,
pub id: u32,
} }
impl ObjectGroup { impl ObjectGroup {
...@@ -28,7 +29,7 @@ impl ObjectGroup { ...@@ -28,7 +29,7 @@ impl ObjectGroup {
attrs: Vec<OwnedAttribute>, attrs: Vec<OwnedAttribute>,
layer_index: Option<u32>, layer_index: Option<u32>,
) -> Result<ObjectGroup, TiledError> { ) -> Result<ObjectGroup, TiledError> {
let ((o, v, c, n), ()) = get_attrs!( let ((o, v, c, n), id) = get_attrs!(
attrs, attrs,
optionals: [ optionals: [
("opacity", opacity, |v:String| v.parse().ok()), ("opacity", opacity, |v:String| v.parse().ok()),
...@@ -36,7 +37,9 @@ impl ObjectGroup { ...@@ -36,7 +37,9 @@ impl ObjectGroup {
("color", colour, |v:String| v.parse().ok()), ("color", colour, |v:String| v.parse().ok()),
("name", name, |v:String| v.into()), ("name", name, |v:String| v.into()),
], ],
required: [], required: [
("id", id, |v:String| v.parse::<u32>().ok()),
],
TiledError::MalformedAttributes("object groups must have a name".to_string()) TiledError::MalformedAttributes("object groups must have a name".to_string())
); );
let mut objects = Vec::new(); let mut objects = Vec::new();
...@@ -59,6 +62,7 @@ impl ObjectGroup { ...@@ -59,6 +62,7 @@ impl ObjectGroup {
colour: c, colour: c,
layer_index, layer_index,
properties, properties,
id,
}) })
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment