Improve how popups appear

This commit is contained in:
Sofia 2026-07-23 19:48:25 +03:00
parent 8efe18007f
commit 3980439a91
2 changed files with 8 additions and 32 deletions

View File

@ -12,6 +12,7 @@ use crate::{
game_manager::{Game, GameManager, GameOption, GameOptionValue, NetPlayer},
net::{net_stats::Stats, util::NetVector3},
player::{DamageSource, NetTransform},
popup_queue::{Popup, PopupQueue},
ui::cli::{CliColor, CommandLinePanel},
weapon::WeaponType,
};
@ -205,7 +206,13 @@ impl NetworkManager {
self.run_deferred(move |s| {
s.signals()
.on_error_hosting_server()
.emit(&format!("{}", err))
.emit(&format!("{}", err));
PopupQueue::singleton().bind_mut().queue(Popup {
title: "Error hosting server".to_owned(),
message: err.to_string(),
ok: true,
});
});
}
}

View File

@ -64,37 +64,6 @@ pub struct MainMenu {
impl INode3D for MainMenu {
fn ready(&mut self) {
self.hide_popup();
NetworkManager::singleton()
.bind_mut()
.signals()
.on_client_disconnected()
.connect_other(self, |_, msg| {
if msg.is_empty() {
PopupQueue::singleton().bind_mut().queue(Popup {
title: "Disconnected".to_owned(),
message: "disconnected".to_owned(),
ok: true,
});
} else {
PopupQueue::singleton().bind_mut().queue(Popup {
title: "Error".to_owned(),
message: msg.to_string(),
ok: true,
});
}
});
NetworkManager::singleton()
.bind_mut()
.signals()
.on_error_hosting_server()
.connect_other(self, |_, msg| {
PopupQueue::singleton().bind_mut().queue(Popup {
title: "Error hosting server".to_owned(),
message: msg.to_string(),
ok: true,
});
});
}
fn process(&mut self, _delta: f64) {