From 172416d7d57fded0eac73666fccab457fec4bc9a Mon Sep 17 00:00:00 2001 From: Tristan Debrunner Date: Wed, 25 Jan 2023 13:35:32 -0700 Subject: [PATCH 1/4] Fix bottom line of pixels not flashing --- matrix-drawing/src/drawing.rs | 1 - 1 file changed, 1 deletion(-) 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)?; From 0da0289495c39875850f984c30feaede447d7866 Mon Sep 17 00:00:00 2001 From: Tristan Debrunner Date: Wed, 25 Jan 2023 13:42:40 -0700 Subject: [PATCH 2/4] Don't panic if timeout ends while editing time --- refbox/src/app/mod.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/refbox/src/app/mod.rs b/refbox/src/app/mod.rs index fdc47a00..d3e9dc78 100644 --- a/refbox/src/app/mod.rs +++ b/refbox/src/app/mod.rs @@ -1455,6 +1455,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 { From 60f31f6eccb1dc37c9ad06ea58b4afeabdba12f5 Mon Sep 17 00:00:00 2001 From: Tristan Debrunner Date: Wed, 25 Jan 2023 14:10:40 -0700 Subject: [PATCH 3/4] Actually apply config changes on end and apply confirmation --- refbox/src/app/mod.rs | 21 +++++++++++++------- refbox/src/app/view_builders/confirmation.rs | 4 ++-- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/refbox/src/app/mod.rs b/refbox/src/app/mod.rs index d3e9dc78..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 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, From 965fc8b06ac0401422a65886be8ea76ecf61f615 Mon Sep 17 00:00:00 2001 From: Tristan Debrunner Date: Wed, 25 Jan 2023 17:08:15 -0700 Subject: [PATCH 4/4] Ignore broken test --- refbox/src/app/update_sender.rs | 1 + 1 file changed, 1 insertion(+) 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);