diff --git a/assets/tiled_object_groups.tmx b/assets/tiled_object_groups.tmx new file mode 100644 index 0000000000000000000000000000000000000000..89d09b478e032e993fbfc81f6aef38efc05bc0fb --- /dev/null +++ b/assets/tiled_object_groups.tmx @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<map version="1.2" tiledversion="1.2.3" orientation="orthogonal" renderorder="right-down" width="10" height="10" tilewidth="32" tileheight="32" infinite="0" nextlayerid="4" nextobjectid="1"> + <layer id="1" name="Tile Layer 1" width="10" height="10"> + <data encoding="csv"> +0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0 +</data> + </layer> + <group id="2" name="group"> + <objectgroup id="3" name="sub_layer"> + <properties> + <property name="an object group property" type="bool" value="true"/> + </properties> + </objectgroup> + </group> +</map> diff --git a/src/lib.rs b/src/lib.rs index 96f5e02dcaa2aa1b7f4cabc403e5bf9c5ecb4112..be48dd690a9b0f973ce86c55709e0c04245d49dd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -743,6 +743,7 @@ pub struct ObjectGroup { * Layer index is not preset for tile collision boxes */ pub layer_index: Option<u32>, + pub properties: Properties, } impl ObjectGroup { @@ -763,11 +764,16 @@ impl ObjectGroup { TiledError::MalformedAttributes("object groups must have a name".to_string()) ); let mut objects = Vec::new(); + let mut properties = HashMap::new(); parse_tag!(parser, "objectgroup", { "object" => |attrs| { objects.push(try!(Object::new(parser, attrs))); Ok(()) }, + "properties" => |_| { + properties = try!(parse_properties(parser)); + Ok(()) + }, }); Ok(ObjectGroup { name: n.unwrap_or(String::new()), @@ -776,6 +782,7 @@ impl ObjectGroup { objects: objects, colour: c, layer_index, + properties, }) } } diff --git a/tests/lib.rs b/tests/lib.rs index 8e2c2c77bd8c94e41dad0700362ac844778062c0..bf4b2739235e27e8bc437ab69fda5dce2e24c327 100644 --- a/tests/lib.rs +++ b/tests/lib.rs @@ -68,3 +68,14 @@ fn test_tile_property() { }; assert_eq!("123", prop_value); } + +#[test] +fn test_object_group_property() { + let r = read_from_file(&Path::new("assets/tiled_object_groups.tmx")).unwrap(); + let prop_value: bool = if let Some(&PropertyValue::BoolValue(ref v)) = r.object_groups[0].properties.get("an object group property") { + *v + } else { + false + }; + assert!(prop_value); +}