Files
pomomon-garden/src/features/hud/components.rs

68 lines
1.6 KiB
Rust

use crate::{features::phase::components::TimerSettings, prelude::*};
#[derive(Component)]
pub enum RootMarker {
Status,
Settings,
}
#[derive(Component)]
pub enum TextType {
Phase,
Timer,
}
#[derive(Component)]
pub enum ButtonType {
SavegameDump,
SettingsOpen,
SettingsClose,
SettingsExit,
SettingsSave,
SettingsTimerChange {
input: SettingsTimerInput,
amount: i32,
},
}
#[derive(Clone)]
pub enum TimerType {
Focus,
ShortBreak,
LongBreak,
}
impl TimerSettings {
pub fn change(&mut self, timer_type: &TimerType, amount: i32) {
match timer_type {
TimerType::Focus => {
self.focus_duration = (self.focus_duration as i32 + amount) as u32;
if self.focus_duration > 7259 {
// 120:59
self.focus_duration = 7259;
}
}
TimerType::LongBreak => {
self.long_break_duration = (self.long_break_duration as i32 + amount) as u32;
if self.long_break_duration > 7259 {
// 120:59
self.long_break_duration = 7259;
}
}
TimerType::ShortBreak => {
self.short_break_duration = (self.short_break_duration as i32 + amount) as u32;
if self.short_break_duration > 7259 {
// 120:59
self.short_break_duration = 7259;
}
}
}
}
}
#[derive(Component, Clone)]
pub enum SettingsTimerInput {
Minutes(TimerType),
Seconds(TimerType),
}