Skip to content

Commit

Permalink
Merge #156
Browse files Browse the repository at this point in the history
156: Various bug fixes r=TristanDebrunner a=TristanDebrunner

- Fix bottom line of pixels not flashing
- Don't panic if timeout ends while editing time (Fixes #155)
- Actually apply config changes on end and apply confirmation (Fixes #154)

Co-authored-by: Tristan Debrunner <tdebrunner@atlantissports.org>
  • Loading branch information
bors[bot] and TristanDebrunner authored Jan 26, 2023
2 parents 2564036 + 965fc8b commit 7ebc5b0
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 10 deletions.
1 change: 0 additions & 1 deletion matrix-drawing/src/drawing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ pub fn draw_panels<D: DrawTarget<Color = Rgb888>>(
.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)?;
Expand Down
25 changes: 18 additions & 7 deletions refbox/src/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*,
Expand Down Expand Up @@ -102,7 +103,7 @@ enum AppState {
#[derive(Debug, Clone, PartialEq, Eq)]
enum ConfirmationKind {
GameNumberChanged,
GameConfigChanged,
GameConfigChanged(GameConfig),
Error(String),
UwhScoresIncomplete,
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand All @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions refbox/src/app/update_sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions refbox/src/app/view_builders/confirmation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 7ebc5b0

Please sign in to comment.