Update options for client as well

This commit is contained in:
Sofia 2026-07-22 04:17:15 +03:00
parent 0a330b9d89
commit d3e082084a

View File

@ -1,3 +1,5 @@
use std::collections::HashMap;
use godot::{ use godot::{
classes::{ classes::{
Button, CheckBox, Control, GridContainer, IPanel, Label, OptionButton, Panel, TextEdit, Button, CheckBox, Control, GridContainer, IPanel, Label, OptionButton, Panel, TextEdit,
@ -30,6 +32,8 @@ pub struct LobbyPanel {
#[export] #[export]
options_grid: Option<Gd<GridContainer>>, options_grid: Option<Gd<GridContainer>>,
option_nodes: HashMap<GameOption, Gd<Control>>,
is_ready: bool, is_ready: bool,
base: Base<Panel>, base: Base<Panel>,
@ -154,6 +158,8 @@ impl IPanel for LobbyPanel {
); );
}); });
self.option_nodes.insert(option, checkbox.clone().upcast());
checkbox.upcast::<Control>() checkbox.upcast::<Control>()
} }
}; };
@ -195,6 +201,17 @@ impl LobbyPanel {
if let Some(selection) = &mut self.map_selection { if let Some(selection) = &mut self.map_selection {
selection.set_disabled(!is_host && !opts.is_true(GameOption::AllowAnyMap)); 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);
}
}
}
}
}
} }
fn update_ready_button(&mut self) { fn update_ready_button(&mut self) {