mirror of
https://github.com/IntQuant/noita_entangled_worlds.git
synced 2025-10-19 07:03:16 +00:00
Improve kick/ban ui
This commit is contained in:
parent
d5b71becae
commit
a0c94486ca
3 changed files with 32 additions and 23 deletions
|
@ -1207,22 +1207,26 @@ fn show_player_list_steam(
|
|||
let role = peer_role(peer, netman);
|
||||
let username = steam.get_user_name(peer.into());
|
||||
let avatar = steam.get_avatar(ctx, peer.into());
|
||||
if let Some(avatar) = avatar {
|
||||
avatar.display_with_labels(ui, &username, &role);
|
||||
} else {
|
||||
ui.label(&username);
|
||||
}
|
||||
if netman.peer.is_host() && peer != netman.peer.my_id() {
|
||||
if ui.button("kick").clicked() {
|
||||
netman.kick_list.lock().unwrap().push(peer)
|
||||
ui.group(|ui| {
|
||||
if let Some(avatar) = avatar {
|
||||
avatar.display_with_labels(ui, &username, &role);
|
||||
} else {
|
||||
ui.label(&username);
|
||||
}
|
||||
if ui.button("ban").clicked() {
|
||||
netman.ban_list.lock().unwrap().push(peer)
|
||||
if netman.peer.is_host() && peer != netman.peer.my_id() {
|
||||
if avatar.is_some() {
|
||||
ui.add_space(5.0);
|
||||
}
|
||||
ui.horizontal(|ui| {
|
||||
if ui.button("Kick").clicked() {
|
||||
netman.kick_list.lock().unwrap().push(peer)
|
||||
}
|
||||
if ui.button("Ban").clicked() {
|
||||
netman.ban_list.lock().unwrap().push(peer)
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
if avatar.is_some() {
|
||||
ui.add_space(5.0);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -119,7 +119,7 @@ pub struct NetManager {
|
|||
pub peer: omni::PeerVariant,
|
||||
pub pending_settings: Mutex<GameSettings>,
|
||||
pub settings: Mutex<GameSettings>,
|
||||
pub continue_running: AtomicBool, // TODO stop on drop
|
||||
pub continue_running: AtomicBool,
|
||||
pub accept_local: AtomicBool,
|
||||
pub local_connected: AtomicBool,
|
||||
pub stopped: AtomicBool,
|
||||
|
@ -293,7 +293,10 @@ impl NetManager {
|
|||
state.try_ws_write(ws_encode_proxy("leave", peer.as_hex()));
|
||||
state.world.handle_peer_left(*peer);
|
||||
self.send(*peer, &NetMsg::Kick, Reliability::Reliable);
|
||||
self.broadcast(&NetMsg::PeerDisconnected {id: *peer}, Reliability::Reliable);
|
||||
self.broadcast(
|
||||
&NetMsg::PeerDisconnected { id: *peer },
|
||||
Reliability::Reliable,
|
||||
);
|
||||
}
|
||||
list.clear();
|
||||
let list = self.ban_list.lock().unwrap();
|
||||
|
@ -302,7 +305,10 @@ impl NetManager {
|
|||
state.try_ws_write(ws_encode_proxy("leave", peer.as_hex()));
|
||||
state.world.handle_peer_left(*peer);
|
||||
self.send(*peer, &NetMsg::Kick, Reliability::Reliable);
|
||||
self.broadcast(&NetMsg::PeerDisconnected {id: *peer}, Reliability::Reliable);
|
||||
self.broadcast(
|
||||
&NetMsg::PeerDisconnected { id: *peer },
|
||||
Reliability::Reliable,
|
||||
);
|
||||
}
|
||||
for net_event in self.peer.recv() {
|
||||
match net_event {
|
||||
|
@ -354,7 +360,7 @@ impl NetManager {
|
|||
};
|
||||
match net_msg {
|
||||
NetMsg::Welcome => {}
|
||||
NetMsg::PeerDisconnected{id} => {
|
||||
NetMsg::PeerDisconnected { id } => {
|
||||
info!("player kicked: {}", id);
|
||||
state.try_ws_write(ws_encode_proxy("leave", id.as_hex()));
|
||||
state.world.handle_peer_left(id);
|
||||
|
@ -390,9 +396,7 @@ impl NetManager {
|
|||
host,
|
||||
);
|
||||
}
|
||||
NetMsg::Kick => {
|
||||
std::process::exit(0)
|
||||
},
|
||||
NetMsg::Kick => std::process::exit(0),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -662,4 +666,4 @@ impl Drop for NetManager {
|
|||
info!("Skip saving run info: not a host");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ pub struct SteamUserAvatar {
|
|||
impl SteamUserAvatar {
|
||||
pub fn display_with_labels(&self, ui: &mut Ui, label_top: &str, label_bottom: &str) {
|
||||
let image = egui::Image::new(&self.avatar).fit_to_exact_size([32.0, 32.0].into());
|
||||
ui.group(|ui| {
|
||||
ui.scope(|ui| {
|
||||
ui.set_min_width(200.0);
|
||||
ui.horizontal(|ui| {
|
||||
ui.add(image);
|
||||
|
@ -76,6 +76,7 @@ impl SteamState {
|
|||
friend
|
||||
.small_avatar()
|
||||
.map(|(width, height, data)| {
|
||||
info!("Loaded avatar for {:?}", id);
|
||||
ctx.load_texture(
|
||||
format!("steam_avatar_for_{:?}", id),
|
||||
ColorImage::from_rgba_unmultiplied(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue