Update map selection dropdown disable logic
This commit is contained in:
parent
5d14a2675c
commit
b163c214fe
@ -89,15 +89,18 @@ impl GameManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub struct GameOptions {
|
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.
|
/// the player itself.
|
||||||
pub allow_any_team: bool,
|
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 {
|
impl Default for GameOptions {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
allow_any_team: false,
|
allow_any_team: false,
|
||||||
|
allow_any_map: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,7 +4,7 @@ use godot::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
game_manager::{Game, GameManager},
|
game_manager::{Game, GameManager, GameOptions},
|
||||||
net::network_manager::{NetworkManager, Package, PeerKind},
|
net::network_manager::{NetworkManager, Package, PeerKind},
|
||||||
ui::player_listing::PlayerListing,
|
ui::player_listing::PlayerListing,
|
||||||
};
|
};
|
||||||
@ -68,14 +68,14 @@ impl IPanel for LobbyPanel {
|
|||||||
for map in game.bind().maps.iter_shared() {
|
for map in game.bind().maps.iter_shared() {
|
||||||
map_selection.add_item(&map.bind().name);
|
map_selection.add_item(&map.bind().name);
|
||||||
}
|
}
|
||||||
|
map_selection.select(0);
|
||||||
|
}
|
||||||
let is_host = if let Some(peer) = &NetworkManager::singleton().bind().peer {
|
let is_host = if let Some(peer) = &NetworkManager::singleton().bind().peer {
|
||||||
peer.is_host()
|
peer.is_host()
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
};
|
};
|
||||||
map_selection.set_disabled(!is_host);
|
self.on_game_opts_update(&game.bind().opts, is_host);
|
||||||
map_selection.select(0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
self.update_map_selection(0);
|
self.update_map_selection(0);
|
||||||
|
|
||||||
@ -117,6 +117,12 @@ impl IPanel for LobbyPanel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl 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) {
|
fn update_ready_button(&mut self) {
|
||||||
if let Some(game) = Game::singleton()
|
if let Some(game) = Game::singleton()
|
||||||
&& let Some(peer) = &NetworkManager::singleton().bind().peer
|
&& let Some(peer) = &NetworkManager::singleton().bind().peer
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user