From 0527567350006677875ec76c85a432da0bb23b85 Mon Sep 17 00:00:00 2001 From: Sofia Date: Sun, 26 Jul 2026 00:49:41 +0300 Subject: [PATCH] Fix goal game option propagating to client --- rust/src/game_manager.rs | 1 + rust/src/ui/lobby.rs | 29 ++++++++++++++++++----------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/rust/src/game_manager.rs b/rust/src/game_manager.rs index 9d4d9ea..1f73c9a 100644 --- a/rust/src/game_manager.rs +++ b/rust/src/game_manager.rs @@ -132,6 +132,7 @@ impl GameManager { } } +#[derive(Debug)] pub struct GameOptions { pub values: HashMap, } diff --git a/rust/src/ui/lobby.rs b/rust/src/ui/lobby.rs index 975818e..270695d 100644 --- a/rust/src/ui/lobby.rs +++ b/rust/src/ui/lobby.rs @@ -174,6 +174,8 @@ impl IPanel for LobbyPanel { }, ); + self.option_nodes.insert(option, spinbox.clone().upcast()); + spinbox.upcast() } }; @@ -221,22 +223,27 @@ impl LobbyPanel { if let Some(selection) = &mut self.map_selection { selection.set_disabled(!is_host && !opts.is_true(GameOption::AllowAnyMap)); } - for (key, value) in &opts.values { - if let Some(control) = self.option_nodes.get(key).cloned() { - match value { - GameOptionValue::Boolean(value) => { - if let Ok(mut checkbox) = control.try_cast::() { - checkbox.set_pressed(*value); + + let values = opts.values.clone(); + let nodes = self.option_nodes.clone(); + self.run_deferred_gd(move |_| { + for (key, value) in values { + if let Some(control) = nodes.get(&key).cloned() { + match value { + GameOptionValue::Boolean(value) => { + if let Ok(mut checkbox) = control.try_cast::() { + checkbox.set_pressed(value); + } } - } - GameOptionValue::Number(value) => { - if let Ok(mut spinbox) = control.try_cast::() { - spinbox.set_value(*value); + GameOptionValue::Number(value) => { + if let Ok(mut spinbox) = control.try_cast::() { + spinbox.set_value(value); + } } } } } - } + }); } fn update_ready_button(&mut self) {