Update hud on host player leave
This commit is contained in:
parent
97ee080970
commit
c4ffd2fcdd
@ -42,11 +42,13 @@ pub struct Hud {
|
||||
#[godot_api]
|
||||
impl IControl for Hud {
|
||||
fn ready(&mut self) {
|
||||
self.on_update_host_privileges();
|
||||
|
||||
self.run_deferred(|s| {
|
||||
if let Some(exit_to_lobby) = &mut s.exit_to_lobby
|
||||
&& let Some(game) = &Game::singleton()
|
||||
{
|
||||
exit_to_lobby.set_visible(game.bind().has_host_privileges());
|
||||
if let Some(game) = &Game::singleton() {
|
||||
game.signals()
|
||||
.on_host_privileges_changed()
|
||||
.connect_other(s, |s| s.on_update_host_privileges());
|
||||
}
|
||||
});
|
||||
|
||||
@ -176,4 +178,14 @@ impl Hud {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn on_update_host_privileges(&mut self) {
|
||||
self.run_deferred(|s| {
|
||||
if let Some(exit_to_lobby) = &mut s.exit_to_lobby
|
||||
&& let Some(game) = &Game::singleton()
|
||||
{
|
||||
exit_to_lobby.set_visible(game.bind().has_host_privileges());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user