Skip to content
Snippets Groups Projects
Unverified Commit d603b761 authored by Matt Hall's avatar Matt Hall Committed by GitHub
Browse files

Merge pull request #78 from JoNil/pr2

Added Optional tilecount to Tileset
parents 290d805c c0390646
No related branches found
No related tags found
No related merge requests found
......@@ -353,6 +353,7 @@ pub struct Tileset {
pub tile_height: u32,
pub spacing: u32,
pub margin: u32,
pub tilecount: Option<u32>,
/// The Tiled spec says that a tileset can have mutliple images so a `Vec`
/// is used. Usually you will only use one.
pub images: Vec<Image>,
......@@ -372,11 +373,12 @@ impl Tileset {
parser: &mut EventReader<R>,
attrs: &Vec<OwnedAttribute>,
) -> Result<Tileset, TiledError> {
let ((spacing, margin), (first_gid, name, width, height)) = get_attrs!(
let ((spacing, margin, tilecount), (first_gid, name, width, height)) = get_attrs!(
attrs,
optionals: [
("spacing", spacing, |v:String| v.parse().ok()),
("margin", margin, |v:String| v.parse().ok()),
("tilecount", tilecount, |v:String| v.parse().ok()),
],
required: [
("firstgid", first_gid, |v:String| v.parse().ok()),
......@@ -407,6 +409,7 @@ impl Tileset {
tile_height: height,
spacing: spacing.unwrap_or(0),
margin: margin.unwrap_or(0),
tilecount: tilecount,
images: images,
tiles: tiles,
})
......@@ -469,11 +472,12 @@ impl Tileset {
parser: &mut EventReader<R>,
attrs: &Vec<OwnedAttribute>,
) -> Result<Tileset, TiledError> {
let ((spacing, margin), (name, width, height)) = get_attrs!(
let ((spacing, margin, tilecount), (name, width, height)) = get_attrs!(
attrs,
optionals: [
("spacing", spacing, |v:String| v.parse().ok()),
("margin", margin, |v:String| v.parse().ok()),
("tilecount", tilecount, |v:String| v.parse().ok()),
],
required: [
("name", name, |v| Some(v)),
......@@ -503,6 +507,7 @@ impl Tileset {
tile_height: height,
spacing: spacing.unwrap_or(0),
margin: margin.unwrap_or(0),
tilecount: tilecount,
images: images,
tiles: tiles,
})
......
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