diff --git a/matrix-drawing/src/drawing.rs b/matrix-drawing/src/drawing.rs index e921d4f9..59d3c6ff 100644 --- a/matrix-drawing/src/drawing.rs +++ b/matrix-drawing/src/drawing.rs @@ -50,7 +50,6 @@ pub fn draw_panels>( .build(); if flash { - // display.clear(WHITE)?; Rectangle::new(Point::new(0, 0), Size::new(255, 64)) .into_styled(PrimitiveStyle::with_fill(FLASH_COLOR)) .draw(display)?; diff --git a/refbox/src/app/mod.rs b/refbox/src/app/mod.rs index fdc47a00..5f5c6b1c 100644 --- a/refbox/src/app/mod.rs +++ b/refbox/src/app/mod.rs @@ -25,6 +25,7 @@ use tokio::{ }; use tokio_serial::SerialPortBuilder; use uwh_common::{ + config::Game as GameConfig, drawing_support::*, game_snapshot::{Color as GameColor, GamePeriod, GameSnapshot, TimeoutSnapshot}, uwhscores::*, @@ -102,7 +103,7 @@ enum AppState { #[derive(Debug, Clone, PartialEq, Eq)] enum ConfirmationKind { GameNumberChanged, - GameConfigChanged, + GameConfigChanged(GameConfig), Error(String), UwhScoresIncomplete, } @@ -955,7 +956,9 @@ impl Application for RefBoxApp { AppState::ConfirmationPage(ConfirmationKind::UwhScoresIncomplete) } else if new_config != *tm.config() { if tm.current_period() != GamePeriod::BetweenGames { - AppState::ConfirmationPage(ConfirmationKind::GameConfigChanged) + AppState::ConfirmationPage(ConfirmationKind::GameConfigChanged( + new_config, + )) } else { tm.set_config(new_config.clone()).unwrap(); self.config.game = new_config; @@ -1274,10 +1277,13 @@ impl Application for RefBoxApp { } } Message::ConfirmationSelected(selection) => { - let config_changed = if let AppState::ConfirmationPage(ref kind) = self.app_state { - kind == &ConfirmationKind::GameConfigChanged + let new_config = if let AppState::ConfirmationPage( + ConfirmationKind::GameConfigChanged(ref config), + ) = self.app_state + { + Some(config.clone()) } else { - unreachable!() + None }; self.app_state = match selection { @@ -1288,8 +1294,9 @@ impl Application for RefBoxApp { let mut tm = self.tm.lock().unwrap(); let now = Instant::now(); tm.reset_game(now); - if config_changed { - tm.set_config(self.config.game.clone()).unwrap(); + if let Some(config) = new_config { + tm.set_config(config.clone()).unwrap(); + self.config.game = config; } let game = edited_settings @@ -1455,6 +1462,10 @@ impl Application for RefBoxApp { let snapshot = tm.generate_snapshot(Instant::now()).unwrap(); std::mem::drop(tm); self.apply_snapshot(snapshot); + if let AppState::TimeEdit(_, _, ref mut timeout) = self.app_state { + *timeout = None; + } + trace!("AppState changed to {:?}", self.app_state); } Message::RecvTournamentList(t_list) => { let active_filter = if self.list_all_tournaments { diff --git a/refbox/src/app/update_sender.rs b/refbox/src/app/update_sender.rs index f2f252f4..53a818f9 100644 --- a/refbox/src/app/update_sender.rs +++ b/refbox/src/app/update_sender.rs @@ -556,6 +556,7 @@ mod test { const MAX_CONN_FAILS: usize = 20; #[tokio::test(flavor = "multi_thread", worker_threads = 2)] + #[ignore] async fn test_update_sender() { let update_sender = UpdateSender::new(vec![], BINARY_PORT, JSON_PORT); diff --git a/refbox/src/app/view_builders/confirmation.rs b/refbox/src/app/view_builders/confirmation.rs index b3f6cae5..da0a522d 100644 --- a/refbox/src/app/view_builders/confirmation.rs +++ b/refbox/src/app/view_builders/confirmation.rs @@ -16,14 +16,14 @@ pub(in super::super) fn build_confirmation_page<'a>( kind: &ConfirmationKind, ) -> Element<'a, Message> { let header_text = match kind { - ConfirmationKind::GameConfigChanged => "The game configuration can not be changed while a game is in progress.\n\nWhat would you like to do?", + ConfirmationKind::GameConfigChanged(_) => "The game configuration can not be changed while a game is in progress.\n\nWhat would you like to do?", ConfirmationKind::GameNumberChanged => "How would you like to apply this game number change?", ConfirmationKind::Error(string) => string, ConfirmationKind::UwhScoresIncomplete => "When UWHScores is enabled, all fields must be filled out." }; let buttons = match kind { - ConfirmationKind::GameConfigChanged => vec![ + ConfirmationKind::GameConfigChanged(_) => vec![ ( "GO BACK TO EDITOR", style::Button::Green,