export font and text direction to string
This commit is contained in:
parent
e1bf7cbae4
commit
16e399b312
20
src/game.rs
20
src/game.rs
|
@ -209,10 +209,12 @@ impl ToString for Game {
|
||||||
}
|
}
|
||||||
|
|
||||||
format!(
|
format!(
|
||||||
"{}\n{}\n{}\n\n{}\n\n",
|
"{}\n{}\n{}{}{}\n\n{}\n\n",
|
||||||
&self.name,
|
&self.name,
|
||||||
&self.version_line(),
|
&self.version_line(),
|
||||||
&self.room_format_line(),
|
&self.room_format_line(),
|
||||||
|
&self.font_line(),
|
||||||
|
&self.text_direction_line(),
|
||||||
segments.join("\n\n"),
|
segments.join("\n\n"),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -257,6 +259,22 @@ impl Game {
|
||||||
fn room_format_line(&self) -> String {
|
fn room_format_line(&self) -> String {
|
||||||
optional_data_line("! ROOM_FORMAT", Some(self.room_format))
|
optional_data_line("! ROOM_FORMAT", Some(self.room_format))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn font_line(&self) -> String {
|
||||||
|
if self.font == Font::AsciiSmall {
|
||||||
|
"".to_string()
|
||||||
|
} else {
|
||||||
|
if self.font == Font::Custom {
|
||||||
|
format!("\n\nDEFAULT FONT {}", self.custom_font.as_ref().unwrap())
|
||||||
|
} else {
|
||||||
|
format!("\n\nDEFAULT FONT {}", self.font.to_string().unwrap())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn text_direction_line(&self) -> &str {
|
||||||
|
if self.text_direction == TextDirection::RightToLeft {"\n\nTEXT_DIRECTION RTL"} else {""}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
10
src/text.rs
10
src/text.rs
|
@ -18,6 +18,16 @@ impl Font {
|
||||||
_ => Font::Custom,
|
_ => Font::Custom,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn to_string(&self) -> Result<String, &'static str> {
|
||||||
|
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"),
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Eq, PartialEq)]
|
#[derive(Debug, Eq, PartialEq)]
|
||||||
|
|
Loading…
Reference in New Issue