Skip to content

Commit

Permalink
Refbox bug fixes (#372)
Browse files Browse the repository at this point in the history
* Fix possible crash when starting penalty/warning/foul edit session

* Fix showing infraction options in penalties when disabled
  • Loading branch information
TristanDebrunner authored Jul 24, 2024
1 parent f448bf6 commit 5c87dff
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
18 changes: 15 additions & 3 deletions refbox/src/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -819,17 +819,29 @@ impl Application for RefBoxApp {
trace!("AppState changed to {:?}", self.app_state);
}
Message::PenaltyOverview => {
self.pen_edit.start_session().unwrap();
if let Err(e) = self.pen_edit.start_session() {
warn!("Failed to start penalty edit session: {e}");
self.pen_edit.abort_session();
self.pen_edit.start_session().unwrap();
}
self.app_state = AppState::PenaltyOverview(BlackWhiteBundle { black: 0, white: 0 });
trace!("AppState changed to {:?}", self.app_state);
}
Message::WarningOverview => {
self.warn_edit.start_session().unwrap();
if let Err(e) = self.warn_edit.start_session() {
warn!("Failed to start warning edit session: {e}");
self.warn_edit.abort_session();
self.warn_edit.start_session().unwrap();
}
self.app_state = AppState::WarningOverview(BlackWhiteBundle { black: 0, white: 0 });
trace!("AppState changed to {:?}", self.app_state);
}
Message::FoulOverview => {
self.foul_edit.start_session().unwrap();
if let Err(e) = self.foul_edit.start_session() {
warn!("Failed to start foul edit session: {e}");
self.foul_edit.abort_session();
self.foul_edit.start_session().unwrap();
}
self.app_state = AppState::FoulOverview(OptColorBundle {
black: 0,
equal: 0,
Expand Down
12 changes: 10 additions & 2 deletions refbox/src/app/view_builders/keypad_pages/penalty_edit.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::{style::Element, *};
use iced::{
widget::{column, row},
widget::{column, row, vertical_space},
Length,
};
use uwh_common::game_snapshot::Color as GameColor;
Expand Down Expand Up @@ -132,7 +132,11 @@ pub(super) fn make_penalty_edit_page<'a>(
.spacing(SPACING)]
.spacing(SPACING);

content = content.push(make_penalty_dropdown(infraction));
if config.track_fouls_and_warnings {
content = content.push(make_penalty_dropdown(infraction));
} else {
content = content.push(vertical_space(Length::Fill));
}

content = content.push(
row![
Expand All @@ -152,6 +156,10 @@ pub(super) fn make_penalty_edit_page<'a>(
.spacing(SPACING),
);

if !config.track_fouls_and_warnings {
content = content.push(vertical_space(Length::Fill));
}

content = content.push(exit_row);
content.into()
}

0 comments on commit 5c87dff

Please sign in to comment.