diff --git a/refbox/src/app/message.rs b/refbox/src/app/message.rs index 3669d89e..877e0bae 100644 --- a/refbox/src/app/message.rs +++ b/refbox/src/app/message.rs @@ -20,6 +20,7 @@ pub enum Message { }, StartPlayNow, EditScores, + AddNewScore(GameColor), ChangeScore { color: GameColor, increase: bool, @@ -102,6 +103,7 @@ impl Message { | Self::TimeEditComplete { .. } | Self::StartPlayNow | Self::EditScores + | Self::AddNewScore(_) | Self::ScoreEditComplete { .. } | Self::PenaltyOverview | Self::PenaltyOverviewComplete { .. } @@ -172,6 +174,7 @@ pub enum BoolGameParameter { AutoSoundStartPlay, AutoSoundStopPlay, HideTime, + ScorerCapNum, } #[derive(Debug, Clone, Copy, PartialEq, Eq)] diff --git a/refbox/src/app/mod.rs b/refbox/src/app/mod.rs index 665a7293..cc434d3f 100644 --- a/refbox/src/app/mod.rs +++ b/refbox/src/app/mod.rs @@ -647,6 +647,23 @@ impl Application for RefBoxApp { }; trace!("AppState changed to {:?}", self.app_state); } + Message::AddNewScore(color) => { + if self.config.collect_scorer_cap_num { + self.app_state = AppState::KeypadPage(KeypadPage::AddScore(color), 0); + trace!("AppState changed to {:?}", self.app_state); + } else { + let mut tm = self.tm.lock().unwrap(); + let now = Instant::now(); + match color { + GameColor::Black => tm.add_b_score(0, now), + GameColor::White => tm.add_w_score(0, now), + } + let snapshot = tm.generate_snapshot(now).unwrap(); // TODO: Remove this unwrap + std::mem::drop(tm); + self.apply_snapshot(snapshot); + } + } + Message::ChangeScore { color, increase } => { if let AppState::ScoreEdit { ref mut scores, .. } = self.app_state { if increase { @@ -914,6 +931,7 @@ impl Application for RefBoxApp { sound: self.config.sound.clone(), mode: self.config.mode, hide_time: self.config.hide_time, + collect_scorer_cap_num: self.config.collect_scorer_cap_num, }; self.edited_settings = Some(edited_settings); @@ -1009,6 +1027,8 @@ impl Application for RefBoxApp { self.config.sound = edited_settings.sound; self.sound.update_settings(self.config.sound.clone()); self.config.mode = edited_settings.mode; + self.config.collect_scorer_cap_num = + edited_settings.collect_scorer_cap_num; if self.config.hide_time != edited_settings.hide_time { self.config.hide_time = edited_settings.hide_time; @@ -1033,6 +1053,8 @@ impl Application for RefBoxApp { self.config.sound = edited_settings.sound; self.sound.update_settings(self.config.sound.clone()); self.config.mode = edited_settings.mode; + self.config.collect_scorer_cap_num = + edited_settings.collect_scorer_cap_num; if self.config.hide_time != edited_settings.hide_time { self.config.hide_time = edited_settings.hide_time; @@ -1082,6 +1104,7 @@ impl Application for RefBoxApp { self.config.sound = edited_settings.sound; self.sound.update_settings(self.config.sound.clone()); self.config.mode = edited_settings.mode; + self.config.collect_scorer_cap_num = edited_settings.collect_scorer_cap_num; if self.config.hide_time != edited_settings.hide_time { self.config.hide_time = edited_settings.hide_time; @@ -1270,6 +1293,9 @@ impl Application for RefBoxApp { edited_settings.sound.auto_sound_stop_play ^= true } BoolGameParameter::HideTime => edited_settings.hide_time ^= true, + BoolGameParameter::ScorerCapNum => { + edited_settings.collect_scorer_cap_num ^= true + } } } Message::CycleParameter(param) => { diff --git a/refbox/src/app/view_builders/configuration.rs b/refbox/src/app/view_builders/configuration.rs index df7e702b..5f349b0a 100644 --- a/refbox/src/app/view_builders/configuration.rs +++ b/refbox/src/app/view_builders/configuration.rs @@ -30,6 +30,7 @@ pub(in super::super) struct EditableSettings { pub sound: SoundSettings, pub mode: Mode, pub hide_time: bool, + pub collect_scorer_cap_num: bool, } pub(in super::super) trait Cyclable @@ -201,9 +202,9 @@ fn make_main_config_page<'a>( .width(Length::Fill) .height(Length::Fill) .push(make_value_button( - "MODE", + "APP\nMODE", settings.mode.to_string().to_uppercase(), - (true, true), + (false, true), Some(Message::CycleParameter(CyclingParameter::Mode)), )) .push(make_value_button( @@ -211,6 +212,14 @@ fn make_main_config_page<'a>( bool_string(settings.hide_time), (false, true), Some(Message::ToggleBoolParameter(BoolGameParameter::HideTime)), + )) + .push(make_value_button( + "TRACK CAP NUMBER\nOF SCORER", + bool_string(settings.collect_scorer_cap_num), + (false, true), + Some(Message::ToggleBoolParameter( + BoolGameParameter::ScorerCapNum, + )), )), ) .push( diff --git a/refbox/src/app/view_builders/main_view.rs b/refbox/src/app/view_builders/main_view.rs index 680e5c56..96828c0f 100644 --- a/refbox/src/app/view_builders/main_view.rs +++ b/refbox/src/app/view_builders/main_view.rs @@ -166,11 +166,9 @@ pub(in super::super) fn build_main_view<'a>( if snapshot.current_period != GamePeriod::BetweenGames { black_score_btn = black_score_btn.on_press(Message::EditScores); - black_new_score_btn = black_new_score_btn - .on_press(Message::KeypadPage(KeypadPage::AddScore(GameColor::Black))); + black_new_score_btn = black_new_score_btn.on_press(Message::AddNewScore(GameColor::Black)); white_score_btn = white_score_btn.on_press(Message::EditScores); - white_new_score_btn = white_new_score_btn - .on_press(Message::KeypadPage(KeypadPage::AddScore(GameColor::White))); + white_new_score_btn = white_new_score_btn.on_press(Message::AddNewScore(GameColor::White)); } let black_col = column() diff --git a/refbox/src/config.rs b/refbox/src/config.rs index 748e1e70..d22fe73e 100644 --- a/refbox/src/config.rs +++ b/refbox/src/config.rs @@ -46,6 +46,7 @@ impl Default for UwhScores { pub struct Config { pub mode: Mode, pub hide_time: bool, + pub collect_scorer_cap_num: bool, pub game: Game, pub hardware: Hardware, pub uwhscores: UwhScores,