Update options for client as well
This commit is contained in:
parent
0a330b9d89
commit
d3e082084a
@ -1,3 +1,5 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use godot::{
|
||||
classes::{
|
||||
Button, CheckBox, Control, GridContainer, IPanel, Label, OptionButton, Panel, TextEdit,
|
||||
@ -30,6 +32,8 @@ pub struct LobbyPanel {
|
||||
#[export]
|
||||
options_grid: Option<Gd<GridContainer>>,
|
||||
|
||||
option_nodes: HashMap<GameOption, Gd<Control>>,
|
||||
|
||||
is_ready: bool,
|
||||
|
||||
base: Base<Panel>,
|
||||
@ -154,6 +158,8 @@ impl IPanel for LobbyPanel {
|
||||
);
|
||||
});
|
||||
|
||||
self.option_nodes.insert(option, checkbox.clone().upcast());
|
||||
|
||||
checkbox.upcast::<Control>()
|
||||
}
|
||||
};
|
||||
@ -195,6 +201,17 @@ 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn update_ready_button(&mut self) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user