Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/mattyhall/rs-tiled
Browse files Browse the repository at this point in the history
  • Loading branch information
mattyhall committed May 2, 2021
2 parents 2402e1d + c547746 commit d7d19cf
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ pub enum PropertyValue {
IntValue(i32),
ColorValue(u32),
StringValue(String),
/// Holds the path relative to the map or tileset
FileValue(String),
}

impl PropertyValue {
Expand All @@ -175,6 +177,7 @@ impl PropertyValue {
))),
},
"string" => Ok(PropertyValue::StringValue(value)),
"file" => Ok(PropertyValue::FileValue(value)),
_ => Err(TiledError::Other(format!(
"Unknown property type \"{}\"",
property_type
Expand Down Expand Up @@ -214,7 +217,9 @@ fn parse_properties<R: Read>(parser: &mut EventReader<R>) -> Result<Properties,
pub struct Map {
pub version: String,
pub orientation: Orientation,
/// Width of the map, in tiles
pub width: u32,
/// Height of the map, in tiles
pub height: u32,
pub tile_width: u32,
pub tile_height: u32,
Expand Down Expand Up @@ -334,6 +339,17 @@ impl FromStr for Orientation {
}
}

impl fmt::Display for Orientation {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Orientation::Orthogonal => write!(f, "orthogonal"),
Orientation::Isometric => write!(f, "isometric"),
Orientation::Staggered => write!(f, "staggered"),
Orientation::Hexagonal => write!(f, "hexagonal"),
}
}
}

/// A tileset, usually the tilesheet image.
#[derive(Debug, PartialEq, Clone)]
pub struct Tileset {
Expand Down

0 comments on commit d7d19cf

Please sign in to comment.