diff --git a/game/src/scenes/loading_screen.rs b/game/src/scenes/loading_screen.rs index 1c1409f..6197cd2 100644 --- a/game/src/scenes/loading_screen.rs +++ b/game/src/scenes/loading_screen.rs @@ -1,5 +1,6 @@ use std::ops::{Div, Sub}; +use cfg_if::cfg_if; use chrono::{DateTime, Utc}; use dirty_fsm::{Action, ActionFlag}; use raylib::prelude::*; @@ -68,10 +69,20 @@ impl Action for LoadingScreen { trace!("execute() called on LoadingScreen"); self.render_screen_space(&mut context.renderer.borrow_mut()); + // Check for a quick skip button in debug builds + cfg_if! { + if #[cfg(debug_assertions)] { + let debug_skip_screen = context.renderer.borrow_mut().is_key_pressed(KeyboardKey::KEY_ESCAPE); + } else { + let debug_skip_screen = false; + } + } + // Keep rendering until we pass the loading screen duration if let Some(start_timestamp) = self.start_timestamp { let duration = Utc::now().signed_duration_since(start_timestamp); - if duration.num_seconds() >= LOADING_SCREEN_DURATION_SECONDS as i64 { + if duration.num_seconds() >= LOADING_SCREEN_DURATION_SECONDS as i64 || debug_skip_screen + { info!("LoadingScreen duration reached, moving to next screen"); Ok(ActionFlag::SwitchState(Scenes::MainMenuScreen)) } else { @@ -128,7 +139,11 @@ impl ScreenSpaceRender for LoadingScreen { // Only in debug mode, render a debug message #[cfg(debug_assertions)] { - raylib.draw_rectangle_v(Vector2::zero(), Vector2::new(screen_size.x, 40.0), Color::RED); + raylib.draw_rectangle_v( + Vector2::zero(), + Vector2::new(screen_size.x, 40.0), + Color::RED, + ); raylib.draw_text( "Game in DEBUG MODE. Do not redistribute!", 10,