use bevy::{time::Stopwatch, window::WindowResized}; use crate::prelude::*; pub(crate) struct UiPlugin; impl Plugin for UiPlugin { fn build(&self, app: &mut App) { app.add_systems(Startup, load_assets) .init_state::() .add_systems(OnExit(GameState::Loading), init_prompts) .add_systems( Update, ( manage_cursor.run_if( any_component_changed::().or_else(state_changed::), ), interactive_button.run_if(any_component_changed::()), scale_ui.run_if( on_event::>() .or_else(on_event::()) .and_then(resource_exists::), ), ), ) .add_systems(OnEnter(GameState::Intro), show_click_prompt) .add_systems(OnExit(GameState::Title), hide_click_prompt); } } #[derive(Debug, Resource)] pub(crate) struct UiFont { pub handle: Handle, } #[derive(Debug, Component)] pub(crate) struct TextScroll { pub progress: usize, pub stopwatch: Stopwatch, } #[derive(Debug, Component)] pub(crate) struct TextScrollAnimation; #[derive(Debug, States, Hash, Default, PartialEq, Eq, Clone, Component)] pub(crate) enum Prompt { #[default] None, ClickToContinue, } fn load_assets(server: ResMut, mut commands: Commands) { commands.insert_resource(UiFont { handle: server.load("fonts/Silkscreen/Silkscreen-Regular.ttf"), }); } fn manage_cursor( mut window: Query<&mut Window, With>, state: Res>, buttons: Query<&Interaction, With