diff --git a/src/features/hud/components.rs b/src/features/hud/components.rs index be49eb9..ccd9a63 100644 --- a/src/features/hud/components.rs +++ b/src/features/hud/components.rs @@ -1,5 +1,6 @@ use crate::{features::phase::components::TimerSettings, prelude::*}; +/// Markers for root UI nodes. #[derive(Component)] pub enum RootMarker { Status, @@ -7,12 +8,14 @@ pub enum RootMarker { ShovelOverlay, } +/// Markers for text components in the HUD. #[derive(Component)] pub enum TextType { Phase, Timer, } +/// Markers for buttons in the HUD and settings. #[derive(Component)] pub enum ButtonType { SettingsOpen, @@ -24,6 +27,7 @@ pub enum ButtonType { }, } +/// Types of timers available in the game. #[derive(Clone)] pub enum TimerType { Focus, @@ -32,6 +36,7 @@ pub enum TimerType { } impl TimerSettings { + /// Changes the duration of a specific timer. pub fn change(&mut self, timer_type: &TimerType, amount: i32) { match timer_type { TimerType::Focus => { @@ -59,6 +64,7 @@ impl TimerSettings { } } +/// Input types for adjusting timer settings. #[derive(Component, Clone)] pub enum SettingsTimerInput { Minutes(TimerType), diff --git a/src/features/hud/mod.rs b/src/features/hud/mod.rs index 41937d0..3d50a06 100644 --- a/src/features/hud/mod.rs +++ b/src/features/hud/mod.rs @@ -8,6 +8,7 @@ use ui::*; pub mod components; pub mod ui; +/// Plugin for the Head-Up Display (HUD) containing status bars and buttons. pub struct HudPlugin; impl Plugin for HudPlugin { @@ -27,6 +28,7 @@ impl Plugin for HudPlugin { } } +/// Initializes the HUD UI. fn setup(mut commands: Commands, game_config: Res, asset_server: Res) { commands.spawn(( RootMarker::Status, @@ -126,6 +128,7 @@ fn setup(mut commands: Commands, game_config: Res, asset_server: Res )); } +/// Updates the status text (phase and timer). fn update_status(phase_res: Res, mut text_query: Query<(&mut Text, &TextType)>) { if !phase_res.is_changed() { return; @@ -140,6 +143,7 @@ fn update_status(phase_res: Res, mut text_query: Query<(&mut Text, } } +/// Handles HUD button interactions. fn buttons( mut commands: Commands, mut interaction_query: Query<(&Interaction, &ButtonType), (Changed, With