Skip to content

Commit

Permalink
Merge #129
Browse files Browse the repository at this point in the history
129: Misc fixes r=TristanDebrunner a=TristanDebrunner

- Bump version to 0.1.2
- Clippy fix
- Cleanup dependencies
- Change name of ref warn to ref alert

Co-authored-by: Tristan Debrunner <tdebrunner@atlantissports.org>
  • Loading branch information
bors[bot] and TristanDebrunner authored Dec 2, 2022
2 parents 5101c11 + 09891ee commit a577a03
Show file tree
Hide file tree
Showing 16 changed files with 60 additions and 91 deletions.
39 changes: 4 additions & 35 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion fonts/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "fonts"
version = "0.1.1"
version = "0.1.2"
authors = ["Atlantis Sports <maintainers@atlantissports.org>"]
edition = "2021"

Expand Down
6 changes: 3 additions & 3 deletions matrix-drawing/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "matrix-drawing"
version = "0.1.1"
version = "0.1.2"
authors = ["Atlantis Sports <maintainers@atlantissports.org>"]
edition = "2021"

Expand All @@ -12,8 +12,8 @@ std = ["arrayvec/std", "serde/std", "uwh-common/std"]
arrayref = "0.3.6"
arrayvec = { version = "0.7.2", default-features = false }
embedded-graphics = "0.7.1"
fonts = { version = "0.1.1", path = "../fonts" }
fonts = { version = "0.1.2", path = "../fonts" }
more-asserts = "0.2"
serde = { version = "1.0", default-features = false }
serde_derive = "1.0"
uwh-common = { version = "0.1.1", path = "../uwh-common", default-features = false }
uwh-common = { version = "0.1.2", path = "../uwh-common", default-features = false }
2 changes: 1 addition & 1 deletion overlay/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions refbox/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "refbox"
version = "0.1.1"
version = "0.1.2"
description = "UI for Atlantis Sports's Underwater Hockey Refbox"
authors = ["Atlantis Sports <maintainers@atlantissports.org>"]
edition = "2021"
Expand Down Expand Up @@ -28,7 +28,6 @@ macro-attr-2018 = "2"
more-asserts = "0.2"
paste = "1.0.7"
reqwest = { version = "0.11", features = ["json"] }
rodio = { version = "0.16", default-features = false, features = ["wav"] }
serde = "1.0"
serde_derive = "1.0"
serde_json = "1.0"
Expand All @@ -38,9 +37,9 @@ time = { version = "0.3", features = ["local-offset", "macros", "serde", "serde-
tokio = { version = "1.18", features = ["io-util", "macros", "net", "sync", "time"] }
tokio-serial = "5.4"
toml = "0.5"
uwh-common = { version = "0.1.1", path = "../uwh-common"}
matrix-drawing = { version = "0.1.1", path = "../matrix-drawing"}
web-audio-api = "0.26"
uwh-common = { version = "0.1.2", path = "../uwh-common"}
matrix-drawing = { version = "0.1.2", path = "../matrix-drawing"}
web-audio-api = { version = "0.26", default-features = false, features = ["cpal"] }

[target.'cfg(target_os = "linux")'.dependencies]
futures-lite = "1"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions refbox/src/app/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,14 @@ pub enum BoolGameParameter {
WhiteOnRight,
UsingUwhScores,
SoundEnabled,
RefWarnEnabled,
RefAlertEnabled,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum CyclingParameter {
BuzzerSound,
RemoteBuzzerSound(usize),
WarningVolume,
AlertVolume,
AboveWaterVol,
UnderWaterVol,
}
Expand Down
18 changes: 9 additions & 9 deletions refbox/src/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ impl RefBoxApp {
}

fn maybe_play_sound(&self, new_snapshot: &GameSnapshot) {
let (play_ref_warn, play_buzzer) = match new_snapshot.timeout {
let (play_ref_alert, play_buzzer) = match new_snapshot.timeout {
TimeoutSnapshot::Black(time) | TimeoutSnapshot::White(time) => {
match self.snapshot.timeout {
TimeoutSnapshot::Black(old_time) | TimeoutSnapshot::White(old_time) => (
Expand All @@ -142,7 +142,7 @@ impl RefBoxApp {
let prereqs = new_snapshot.current_period != GamePeriod::SuddenDeath
&& new_snapshot.secs_in_period != self.snapshot.secs_in_period;

let is_warn_period = match new_snapshot.current_period {
let is_alert_period = match new_snapshot.current_period {
GamePeriod::BetweenGames
| GamePeriod::HalfTime
| GamePeriod::PreOvertime
Expand All @@ -169,15 +169,15 @@ impl RefBoxApp {
};

(
prereqs && is_warn_period && new_snapshot.secs_in_period == 35,
prereqs && is_alert_period && new_snapshot.secs_in_period == 35,
prereqs && is_buzz_period && new_snapshot.secs_in_period == 0,
)
}
};

if play_ref_warn {
info!("Triggering ref warning");
self.sound.trigger_ref_warn();
if play_ref_alert {
info!("Triggering ref alert");
self.sound.trigger_ref_alert();
} else if play_buzzer {
info!("Triggering buzzer");
self.sound.trigger_buzzer();
Expand Down Expand Up @@ -1211,8 +1211,8 @@ impl Application for RefBoxApp {
BoolGameParameter::WhiteOnRight => edited_settings.white_on_right ^= true,
BoolGameParameter::UsingUwhScores => edited_settings.using_uwhscores ^= true,
BoolGameParameter::SoundEnabled => edited_settings.sound.sound_enabled ^= true,
BoolGameParameter::RefWarnEnabled => {
edited_settings.sound.ref_warn_enabled ^= true
BoolGameParameter::RefAlertEnabled => {
edited_settings.sound.ref_alert_enabled ^= true
}
}
}
Expand All @@ -1221,7 +1221,7 @@ impl Application for RefBoxApp {
match param {
CyclingParameter::BuzzerSound => sound.buzzer_sound.cycle(),
CyclingParameter::RemoteBuzzerSound(idx) => sound.remotes[idx].sound.cycle(),
CyclingParameter::WarningVolume => sound.ref_warn_vol.cycle(),
CyclingParameter::AlertVolume => sound.ref_alert_vol.cycle(),
CyclingParameter::AboveWaterVol => sound.above_water_vol.cycle(),
CyclingParameter::UnderWaterVol => sound.under_water_vol.cycle(),
}
Expand Down
12 changes: 6 additions & 6 deletions refbox/src/app/view_builders/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -480,10 +480,10 @@ fn make_sound_config_page<'a>(
))
.push(make_value_button(
"REF WARN\nVOLUME:",
sound.ref_warn_vol.to_string().to_uppercase(),
sound.ref_alert_vol.to_string().to_uppercase(),
(false, true),
if sound.sound_enabled && sound.ref_warn_enabled {
Some(Message::CycleParameter(CyclingParameter::WarningVolume))
if sound.sound_enabled && sound.ref_alert_enabled {
Some(Message::CycleParameter(CyclingParameter::AlertVolume))
} else {
None
},
Expand All @@ -502,12 +502,12 @@ fn make_sound_config_page<'a>(
.spacing(SPACING)
.height(Length::Fill)
.push(make_value_button(
"REF WARN\nENABLED:",
bool_string(sound.ref_warn_enabled),
"REF ALERT\nENABLED:",
bool_string(sound.ref_alert_enabled),
(false, true),
if sound.sound_enabled {
Some(Message::ToggleBoolParameter(
BoolGameParameter::RefWarnEnabled,
BoolGameParameter::RefAlertEnabled,
))
} else {
None
Expand Down
4 changes: 2 additions & 2 deletions refbox/src/app/view_builders/shared_elements.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ pub(super) fn make_game_time_button<'a>(
}
TimeoutSnapshot::Ref(_) | TimeoutSnapshot::PenaltyShot(_) => false,
TimeoutSnapshot::None => {
let is_warn_period = match snapshot.current_period {
let is_alert_period = match snapshot.current_period {
GamePeriod::BetweenGames
| GamePeriod::HalfTime
| GamePeriod::PreOvertime
Expand All @@ -266,7 +266,7 @@ pub(super) fn make_game_time_button<'a>(
&& ((snapshot.secs_in_period <= 10
&& (snapshot.secs_in_period % 2 == 0)
&& (snapshot.secs_in_period != 0))
|| (is_warn_period && snapshot.secs_in_period == 30))
|| (is_alert_period && snapshot.secs_in_period == 30))
}
}
};
Expand Down
27 changes: 14 additions & 13 deletions refbox/src/sound_controller/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ pub struct SoundSettings {
#[derivative(Default(value = "true"))]
pub sound_enabled: bool,
#[derivative(Default(value = "true"))]
pub ref_warn_enabled: bool,
pub ref_alert_enabled: bool,
pub buzzer_sound: BuzzerSound,
#[derivative(Default(value = "Volume::Medium"))]
pub ref_warn_vol: Volume,
pub ref_alert_vol: Volume,
pub above_water_vol: Volume,
pub under_water_vol: Volume,
pub remotes: Vec<RemoteInfo>,
Expand Down Expand Up @@ -105,7 +105,7 @@ pub struct RemoteInfo {
#[derive(Debug, Clone, PartialEq, Eq)]
enum SoundMessage {
TriggerBuzzer,
TriggerRefWarning,
TriggerRefAlert,
#[cfg(target_os = "linux")]
StartBuzzer(Option<BuzzerSound>),
#[cfg(target_os = "linux")]
Expand Down Expand Up @@ -146,6 +146,7 @@ impl SoundController {

let mut _stop_rx = stop_rx.clone();
let mut _settings_rx = settings_rx.clone();
#[cfg_attr(not(target_os = "linux"), allow(clippy::redundant_clone))]
let mut _settings = settings.clone();
let _context = context.clone();

Expand All @@ -169,10 +170,10 @@ impl SoundController {
let sound = Sound::new(_context.clone(), volumes, library[_settings.buzzer_sound].clone(), true, true);
last_sound = Some(sound);
}
SoundMessage::TriggerRefWarning => {
info!("Playing ref warning once");
SoundMessage::TriggerRefAlert => {
info!("Playing ref alert once");
let volumes = ChannelVolumes::new(&_settings, true);
let sound = Sound::new(_context.clone(), volumes, library.ref_warn().clone(), false, false);
let sound = Sound::new(_context.clone(), volumes, library.ref_alert().clone(), false, false);
last_sound = Some(sound);
}
#[cfg(target_os = "linux")]
Expand Down Expand Up @@ -444,8 +445,8 @@ impl SoundController {
self.settings_tx.send(settings).unwrap()
}

pub fn trigger_ref_warn(&self) {
self.msg_tx.send(SoundMessage::TriggerRefWarning).unwrap()
pub fn trigger_ref_alert(&self) {
self.msg_tx.send(SoundMessage::TriggerRefAlert).unwrap()
}

pub fn trigger_buzzer(&self) {
Expand Down Expand Up @@ -492,16 +493,16 @@ struct ChannelVolumes {
}

impl ChannelVolumes {
fn new(settings: &SoundSettings, is_ref_warn: bool) -> Self {
fn new(settings: &SoundSettings, is_ref_alert: bool) -> Self {
Self {
left: if settings.sound_enabled && settings.ref_warn_enabled && is_ref_warn {
settings.ref_warn_vol.as_f32()
} else if settings.sound_enabled && !is_ref_warn {
left: if settings.sound_enabled && settings.ref_alert_enabled && is_ref_alert {
settings.ref_alert_vol.as_f32()
} else if settings.sound_enabled && !is_ref_alert {
settings.above_water_vol.as_f32()
} else {
0.0
},
right: if settings.sound_enabled && !is_ref_warn {
right: if settings.sound_enabled && !is_ref_alert {
settings.under_water_vol.as_f32()
} else {
0.0
Expand Down
Loading

0 comments on commit a577a03

Please sign in to comment.