diff --git a/src/layers.rs b/src/layers.rs index b802c569add9753496fd1fb37a210bf5ce313eb5..2b2a6c3a4ce3441e44f7f252c9006ffc75462bcd 100644 --- a/src/layers.rs +++ b/src/layers.rs @@ -54,6 +54,7 @@ pub struct Layer { pub tiles: LayerData, pub properties: Properties, pub layer_index: u32, + pub id: u32, } impl Layer { @@ -64,7 +65,7 @@ impl Layer { layer_index: u32, infinite: bool, ) -> Result<Layer, TiledError> { - let ((o, v, ox, oy), n) = get_attrs!( + let ((o, v, ox, oy), (n, id)) = get_attrs!( attrs, optionals: [ ("opacity", opacity, |v:String| v.parse().ok()), @@ -74,6 +75,7 @@ impl Layer { ], required: [ ("name", name, |v| Some(v)), + ("id", id, |v:String| v.parse::<u32>().ok()), ], TiledError::MalformedAttributes("layer must have a name".to_string()) ); @@ -103,6 +105,7 @@ impl Layer { tiles: tiles, properties: properties, layer_index, + id, }) } } diff --git a/src/objects.rs b/src/objects.rs index 3e5edf919dea4938bee8111f7f77ce5597455203..36dcd6a1dd928267e94233dc0029d73555547303 100644 --- a/src/objects.rs +++ b/src/objects.rs @@ -20,6 +20,7 @@ pub struct ObjectGroup { */ pub layer_index: Option<u32>, pub properties: Properties, + pub id: u32, } impl ObjectGroup { @@ -28,7 +29,7 @@ impl ObjectGroup { attrs: Vec<OwnedAttribute>, layer_index: Option<u32>, ) -> Result<ObjectGroup, TiledError> { - let ((o, v, c, n), ()) = get_attrs!( + let ((o, v, c, n), id) = get_attrs!( attrs, optionals: [ ("opacity", opacity, |v:String| v.parse().ok()), @@ -36,7 +37,9 @@ impl ObjectGroup { ("color", colour, |v:String| v.parse().ok()), ("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()) ); let mut objects = Vec::new(); @@ -59,6 +62,7 @@ impl ObjectGroup { colour: c, layer_index, properties, + id, }) } }