From 7a871654ee73b2eb5be6279514469d5ac378b674 Mon Sep 17 00:00:00 2001 From: Tristan Debrunner Date: Wed, 22 Jun 2022 09:50:31 -0600 Subject: [PATCH 1/2] Fixes to make the overlay work --- uwh-common/src/game_snapshot.rs | 2 +- uwh-refbox/src/app/mod.rs | 5 ++++- uwh-refbox/src/app/update_sender.rs | 6 +++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/uwh-common/src/game_snapshot.rs b/uwh-common/src/game_snapshot.rs index 9d6c2abc..a4d8e23c 100644 --- a/uwh-common/src/game_snapshot.rs +++ b/uwh-common/src/game_snapshot.rs @@ -44,7 +44,7 @@ pub struct GameSnapshot { pub is_old_game: bool, pub game_number: u32, pub next_game_number: u32, - pub tournament_id: u64, + pub tournament_id: u32, } #[cfg(feature = "std")] diff --git a/uwh-refbox/src/app/mod.rs b/uwh-refbox/src/app/mod.rs index 81f64b46..58155784 100644 --- a/uwh-refbox/src/app/mod.rs +++ b/uwh-refbox/src/app/mod.rs @@ -264,7 +264,7 @@ pub enum ConfirmationOption { } impl RefBoxApp { - fn apply_snapshot(&mut self, new_snapshot: GameSnapshot) { + fn apply_snapshot(&mut self, mut new_snapshot: GameSnapshot) { if new_snapshot.current_period != self.snapshot.current_period { if new_snapshot.current_period == GamePeriod::BetweenGames { self.handle_game_end(); @@ -272,6 +272,9 @@ impl RefBoxApp { self.handle_game_start(new_snapshot.game_number); } } + if let Some(tid) = self.current_tid { + new_snapshot.tournament_id = tid; + } self.maybe_play_sound(&new_snapshot); self.update_sender .send_snapshot(new_snapshot.clone(), self.config.hardware.white_on_right) diff --git a/uwh-refbox/src/app/update_sender.rs b/uwh-refbox/src/app/update_sender.rs index 94fff788..089aae8b 100644 --- a/uwh-refbox/src/app/update_sender.rs +++ b/uwh-refbox/src/app/update_sender.rs @@ -232,7 +232,7 @@ impl Server { ServerMessage::NewSnapshot(snapshot, white_on_right) => { //info!("Server received snapshot: {snapshot:?}"); let json = if self.has_json { - serde_json::to_string(&snapshot).unwrap().into_bytes() + (serde_json::to_string(&snapshot).unwrap() + "\n").into_bytes() } else { vec![] }; @@ -290,8 +290,8 @@ impl Drop for Server { async fn listener_loop(tx: mpsc::Sender, binary_port: u16, json_port: u16) { info!("Strating Listeners for JSON (port {json_port}) and binary (port {binary_port})"); - let binary_listener = TcpListener::bind(("localhost", binary_port)).await.unwrap(); - let json_listener = TcpListener::bind(("localhost", json_port)).await.unwrap(); + let binary_listener = TcpListener::bind(("::", binary_port)).await.unwrap(); + let json_listener = TcpListener::bind(("::", json_port)).await.unwrap(); info!("Listeners started"); loop { From 5922dd71eece814319ff7544194eaf5471d6dd31 Mon Sep 17 00:00:00 2001 From: Tristan Debrunner Date: Wed, 22 Jun 2022 09:51:10 -0600 Subject: [PATCH 2/2] Add a fullscreen option --- uwh-refbox/src/app/mod.rs | 12 ++++++++++++ uwh-refbox/src/main.rs | 5 +++++ 2 files changed, 17 insertions(+) diff --git a/uwh-refbox/src/app/mod.rs b/uwh-refbox/src/app/mod.rs index 58155784..80f19bcb 100644 --- a/uwh-refbox/src/app/mod.rs +++ b/uwh-refbox/src/app/mod.rs @@ -63,6 +63,7 @@ pub struct RefBoxApp { current_pool: Option, sound: Option<(OutputStream, OutputStreamHandle)>, sim_child: Option, + fullscreen: bool, } #[derive(Debug)] @@ -73,6 +74,7 @@ pub struct RefBoxAppFlags { pub json_port: u16, pub sim_child: Option, pub require_https: bool, + pub fullscreen: bool, } #[derive(Debug, Clone)] @@ -571,6 +573,7 @@ impl Application for RefBoxApp { json_port, sim_child, require_https, + fullscreen, } = flags; let sound = match OutputStream::try_default() { @@ -631,6 +634,7 @@ impl Application for RefBoxApp { current_pool: None, sound, sim_child, + fullscreen, }, Command::none(), ) @@ -647,6 +651,14 @@ impl Application for RefBoxApp { "UWH Ref Box".into() } + fn mode(&self) -> iced::window::Mode { + if self.fullscreen { + iced::window::Mode::Fullscreen + } else { + iced::window::Mode::Windowed + } + } + fn update(&mut self, message: Message) -> Command { trace!("Handling message: {message:?}"); match message { diff --git a/uwh-refbox/src/main.rs b/uwh-refbox/src/main.rs index 7cfeefd6..63be29fc 100644 --- a/uwh-refbox/src/main.rs +++ b/uwh-refbox/src/main.rs @@ -32,6 +32,10 @@ struct Cli { /// Spacing between pixels in the panel the simulator spacing: Option, + #[clap(long, short)] + /// Make the app fullscreen + fullscreen: bool, + #[clap(long, default_value = "8001")] /// Port to listen on for TCP connections with a binary send type binary_port: u16, @@ -167,6 +171,7 @@ fn main() -> std::result::Result<(), Box> { json_port: args.json_port, sim_child: child, require_https: !args.allow_http, + fullscreen: args.fullscreen, }; let mut settings = Settings::with_flags(flags);