From c4ffd2fcddd3c8e5e5bca48fd02bd4fd5044ffec Mon Sep 17 00:00:00 2001 From: Sofia Date: Sat, 15 Aug 2026 00:15:09 +0300 Subject: [PATCH] Update hud on host player leave --- rust/src/ui/hud.rs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/rust/src/ui/hud.rs b/rust/src/ui/hud.rs index e3a8809..f18a0e7 100644 --- a/rust/src/ui/hud.rs +++ b/rust/src/ui/hud.rs @@ -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()); + } + }); + } }