make this prettier

This commit is contained in:
Simon Gardling 2022-03-09 10:31:53 -05:00
parent 49225599f2
commit 070293b1d7

View File

@ -58,7 +58,7 @@ struct FileData {
} }
lazy_static::lazy_static! { lazy_static::lazy_static! {
// Load all of the data from the compressed tarballe // Load all of the data from the compressed tarball
static ref FILE_DATA: FileData = { static ref FILE_DATA: FileData = {
let start = instant::Instant::now(); let start = instant::Instant::now();
log_helper("Loading tarball..."); log_helper("Loading tarball...");
@ -93,35 +93,49 @@ lazy_static::lazy_static! {
let path_string = path.to_string_lossy(); let path_string = path.to_string_lossy();
// Match the filename // Match the filename
if path_string.ends_with(".ttf") {
// Parse font files
let font_data = FontData::from_owned(data);
match path_string.as_ref() { match path_string.as_ref() {
"Hack-Regular.ttf" => { "Hack-Regular.ttf" => {
font_hack = Some(FontData::from_owned(data)) font_hack = Some(font_data);
}, },
"NotoEmoji-Regular.ttf" => { "NotoEmoji-Regular.ttf" => {
font_notoemoji = Some(FontData::from_owned(data)) font_notoemoji = Some(font_data);
}, },
"Ubuntu-Light.ttf" => { "Ubuntu-Light.ttf" => {
font_ubuntu_light = Some(FontData::from_owned(data)) font_ubuntu_light = Some(font_data);
},
"text_help_expr.txt" => {
text_help_expr = Some(str::from_utf8(&data).unwrap().to_string());
},
"text_help_vars.txt" => {
text_help_vars = Some(str::from_utf8(&data).unwrap().to_string());
},
"text_help_panel.txt" => {
text_help_panel = Some(str::from_utf8(&data).unwrap().to_string());
},
"text_help_function.txt" => {
text_help_function = Some(str::from_utf8(&data).unwrap().to_string());
},
"text_help_other.txt" => {
text_help_other = Some(str::from_utf8(&data).unwrap().to_string());
}, },
_ => { _ => {
panic!("File {} not expected!", path_string); panic!("Font File {} not expected!", path_string);
} }
} }
} else if path_string.ends_with(".txt") {
// Parse text files
let string_data = str::from_utf8(&data).unwrap().to_string();
match path_string.as_ref() {
"text_help_expr.txt" => {
text_help_expr = Some(string_data);
},
"text_help_vars.txt" => {
text_help_vars = Some(string_data);
},
"text_help_panel.txt" => {
text_help_panel = Some(string_data);
},
"text_help_function.txt" => {
text_help_function = Some(string_data);
},
"text_help_other.txt" => {
text_help_other = Some(string_data);
},
_ => {
panic!("Text file {} not expected!", path_string);
}
}
} else {
panic!("Other file {} not expected!", path_string);
}
} }
log_helper(&format!("Done loading assets! Took: {:?}", start.elapsed())); log_helper(&format!("Done loading assets! Took: {:?}", start.elapsed()));
@ -411,6 +425,7 @@ impl epi::App for MathApp {
fn setup(&mut self, _ctx: &Context, _frame: &Frame, _storage: Option<&dyn Storage>) { fn setup(&mut self, _ctx: &Context, _frame: &Frame, _storage: Option<&dyn Storage>) {
#[cfg(target_arch = "wasm32")] #[cfg(target_arch = "wasm32")]
stop_loading(); stop_loading();
log_helper("Initialized.");
} }
// Called each time the UI needs repainting, which may be many times per second. // Called each time the UI needs repainting, which may be many times per second.