From b163c214fe83fca7be183fb58fc1b7d5a52fb615 Mon Sep 17 00:00:00 2001 From: Sofia Date: Wed, 22 Jul 2026 03:23:48 +0300 Subject: [PATCH] Update map selection dropdown disable logic --- rust/src/game_manager.rs | 5 ++++- rust/src/ui/lobby.rs | 20 +++++++++++++------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/rust/src/game_manager.rs b/rust/src/game_manager.rs index 0458781..660abe8 100644 --- a/rust/src/game_manager.rs +++ b/rust/src/game_manager.rs @@ -89,15 +89,18 @@ impl GameManager { } pub struct GameOptions { - /// Wether anyone is allowed to change anyone's team, or just the host and + /// Whether anyone is allowed to change anyone's team, or just the host and /// the player itself. pub allow_any_team: bool, + // Whether anyone is allowed to change the map, or just the host. + pub allow_any_map: bool, } impl Default for GameOptions { fn default() -> Self { Self { allow_any_team: false, + allow_any_map: false, } } } diff --git a/rust/src/ui/lobby.rs b/rust/src/ui/lobby.rs index 50908fb..57ee8c5 100644 --- a/rust/src/ui/lobby.rs +++ b/rust/src/ui/lobby.rs @@ -4,7 +4,7 @@ use godot::{ }; use crate::{ - game_manager::{Game, GameManager}, + game_manager::{Game, GameManager, GameOptions}, net::network_manager::{NetworkManager, Package, PeerKind}, ui::player_listing::PlayerListing, }; @@ -68,14 +68,14 @@ impl IPanel for LobbyPanel { for map in game.bind().maps.iter_shared() { map_selection.add_item(&map.bind().name); } - let is_host = if let Some(peer) = &NetworkManager::singleton().bind().peer { - peer.is_host() - } else { - false - }; - map_selection.set_disabled(!is_host); map_selection.select(0); } + let is_host = if let Some(peer) = &NetworkManager::singleton().bind().peer { + peer.is_host() + } else { + false + }; + self.on_game_opts_update(&game.bind().opts, is_host); } self.update_map_selection(0); @@ -117,6 +117,12 @@ impl IPanel for LobbyPanel { } impl LobbyPanel { + fn on_game_opts_update(&mut self, opts: &GameOptions, is_host: bool) { + if let Some(selection) = &mut self.map_selection { + selection.set_disabled(!is_host && !opts.allow_any_map); + } + } + fn update_ready_button(&mut self) { if let Some(game) = Game::singleton() && let Some(peer) = &NetworkManager::singleton().bind().peer