diff --git a/zgui/examples/absolute_coordinates.rs b/zgui/examples/absolute_coordinates.rs index 286066a..9597b4d 100644 --- a/zgui/examples/absolute_coordinates.rs +++ b/zgui/examples/absolute_coordinates.rs @@ -29,7 +29,7 @@ fn draw_scene() { #[mq::main("ZGui: Absolute Coordinates Demo")] #[macroquad(crate_rename = "mq")] async fn main() { - let assets = common::Assets::load().await; + let assets = common::Assets::load().await.expect("Can't load assets"); let mut gui = make_gui(assets.font).expect("Can't create the gui"); loop { // Update the camera and the GUI. diff --git a/zgui/examples/common/mod.rs b/zgui/examples/common/mod.rs index 5c2f272..196d95a 100644 --- a/zgui/examples/common/mod.rs +++ b/zgui/examples/common/mod.rs @@ -7,6 +7,24 @@ use mq::{ texture::{self, Texture2D}, }; +#[derive(Debug)] +pub enum Err { + File(mq::file::FileError), + Font(mq::text::FontError), +} + +impl From for Err { + fn from(err: mq::file::FileError) -> Self { + Err::File(err) + } +} + +impl From for Err { + fn from(err: mq::text::FontError) -> Self { + Err::Font(err) + } +} + pub fn aspect_ratio() -> f32 { mq::window::screen_width() / mq::window::screen_height() } @@ -33,11 +51,9 @@ pub struct Assets { } impl Assets { - pub async fn load() -> Self { - let font = load_ttf_font("zgui/assets/Karla-Regular.ttf") - .await - .unwrap(); - let texture = texture::load_texture("zgui/assets/fire.png").await.unwrap(); - Self { font, texture } + pub async fn load() -> Result { + let font = load_ttf_font("zgui/assets/Karla-Regular.ttf").await?; + let texture = texture::load_texture("zgui/assets/fire.png").await?; + Ok(Self { font, texture }) } } diff --git a/zgui/examples/layers_layout.rs b/zgui/examples/layers_layout.rs index d4afddb..fac68ea 100644 --- a/zgui/examples/layers_layout.rs +++ b/zgui/examples/layers_layout.rs @@ -26,7 +26,7 @@ fn make_gui(assets: common::Assets) -> ui::Result> { #[mq::main("ZGui: Layers Layout Demo")] #[macroquad(crate_rename = "mq")] async fn main() { - let assets = common::Assets::load().await; + let assets = common::Assets::load().await.expect("Can't load assets"); let mut gui = make_gui(assets).expect("Can't create the gui"); loop { // Update the camera and the GUI. diff --git a/zgui/examples/nested.rs b/zgui/examples/nested.rs index 569f943..b46c43a 100644 --- a/zgui/examples/nested.rs +++ b/zgui/examples/nested.rs @@ -70,7 +70,7 @@ fn make_gui(assets: common::Assets) -> ui::Result> { #[mq::main("ZGui: Nested Layouts Demo")] #[macroquad(crate_rename = "mq")] async fn main() { - let assets = common::Assets::load().await; + let assets = common::Assets::load().await.expect("Can't load assets"); let mut gui = make_gui(assets).expect("Can't create the gui"); loop { // Update the camera and the GUI. diff --git a/zgui/examples/pixel_coordinates.rs b/zgui/examples/pixel_coordinates.rs index da6513f..ede486d 100644 --- a/zgui/examples/pixel_coordinates.rs +++ b/zgui/examples/pixel_coordinates.rs @@ -45,7 +45,7 @@ fn draw_scene() { #[mq::main("ZGui: Pixel Coordinates Demo")] #[macroquad(crate_rename = "mq")] async fn main() { - let assets = common::Assets::load().await; + let assets = common::Assets::load().await.expect("Can't load assets"); let mut gui = make_gui(assets.font).expect("Can't create the gui"); loop { // Update the camera and the GUI. diff --git a/zgui/examples/remove.rs b/zgui/examples/remove.rs index 3e5821e..ea2905b 100644 --- a/zgui/examples/remove.rs +++ b/zgui/examples/remove.rs @@ -68,7 +68,7 @@ impl State { #[mq::main("ZGui: Remove Widget Demo")] #[macroquad(crate_rename = "mq")] async fn main() { - let assets = common::Assets::load().await; + let assets = common::Assets::load().await.expect("Can't load assets"); let mut state = State::new(assets).expect("Can't create the game state"); loop { // Update the camera and the GUI. diff --git a/zgui/examples/text_button.rs b/zgui/examples/text_button.rs index b51fa81..62318c8 100644 --- a/zgui/examples/text_button.rs +++ b/zgui/examples/text_button.rs @@ -21,7 +21,7 @@ fn make_gui(font: mq::text::Font) -> ui::Result> { #[mq::main("ZGui: Text Button Demo")] #[macroquad(crate_rename = "mq")] async fn main() { - let assets = common::Assets::load().await; + let assets = common::Assets::load().await.expect("Can't load assets"); let mut gui = make_gui(assets.font).expect("Can't create the gui"); loop { // Update the camera and the GUI.