Compare commits

..

2 Commits

Author SHA1 Message Date
Max Bradbury 46f8831c7b tidyup 2020-10-18 18:05:14 +01:00
Max Bradbury 66cb9bdd4d font errors 2020-10-18 18:05:04 +01:00
4 changed files with 10 additions and 11 deletions

View File

@ -27,6 +27,7 @@ pub enum Error {
Dialogue,
Ending,
Exit,
Font,
Game {
missing: NotFound,
},

View File

@ -255,7 +255,7 @@ impl Game {
}
if ! avatar_exists {
warnings.push(crate::Error::Game { missing: NotFound::Avatar});
warnings.push(crate::Error::Game { missing: NotFound::Avatar });
}
Ok(

View File

@ -51,9 +51,7 @@ impl Sprite {
format!("\n{}", lines.join("\n"))
}
}
}
impl Sprite {
pub fn from_str(str: &str) -> Result<Sprite, crate::Error> {
let mut lines: Vec<&str> = str.lines().collect();

View File

@ -13,19 +13,19 @@ impl Font {
match str {
"unicode_european_small" => Font::UnicodeEuropeanSmall,
"unicode_european_large" => Font::UnicodeEuropeanLarge,
"unicode_asian" => Font::UnicodeAsian,
"arabic" => Font::Arabic,
_ => Font::Custom,
"unicode_asian" => Font::UnicodeAsian,
"arabic" => Font::Arabic,
_ => Font::Custom,
}
}
pub(crate) fn to_string(&self) -> Result<String, &'static str> {
pub(crate) fn to_string(&self) -> Result<String, crate::Error> {
match &self {
Font::UnicodeEuropeanSmall => Ok("unicode_european_small".to_string()),
Font::UnicodeEuropeanLarge => Ok("unicode_european_large".to_string()),
Font::UnicodeAsian => Ok("unicode_asian".to_string()),
Font::Arabic => Ok("arabic".to_string()),
_ => Err("No string available for this Font"),
Font::UnicodeAsian => Ok("unicode_asian".to_string()),
Font::Arabic => Ok("arabic".to_string()),
_ => Err(crate::Error::Font),
}
}
}