Fix goal game option propagating to client

This commit is contained in:
Sofia 2026-07-26 00:49:41 +03:00
parent b53b6289bd
commit 0527567350
2 changed files with 19 additions and 11 deletions

View File

@ -132,6 +132,7 @@ impl GameManager {
}
}
#[derive(Debug)]
pub struct GameOptions {
pub values: HashMap<GameOption, GameOptionValue>,
}

View File

@ -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>() {
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>() {
checkbox.set_pressed(value);
}
}
}
GameOptionValue::Number(value) => {
if let Ok(mut spinbox) = control.try_cast::<SpinBox>() {
spinbox.set_value(*value);
GameOptionValue::Number(value) => {
if let Ok(mut spinbox) = control.try_cast::<SpinBox>() {
spinbox.set_value(value);
}
}
}
}
}
}
});
}
fn update_ready_button(&mut self) {