From ccb1903569be666dcce005ea00cf35579944d314 Mon Sep 17 00:00:00 2001 From: Jonni Liljamo Date: Fri, 31 Mar 2023 12:59:53 +0300 Subject: [PATCH] feat(client): show player names in lobby screen --- client/src/plugins/menu/ui/play/ui.rs | 87 +++++++++++++++++++++++++-- 1 file changed, 82 insertions(+), 5 deletions(-) diff --git a/client/src/plugins/menu/ui/play/ui.rs b/client/src/plugins/menu/ui/play/ui.rs index d6efc91..652c5bb 100644 --- a/client/src/plugins/menu/ui/play/ui.rs +++ b/client/src/plugins/menu/ui/play/ui.rs @@ -133,6 +133,47 @@ pub fn ui( }); } PlayScreenState::InLobbyHost => { + ui.label(egui::RichText::new(format!( + "Host: {}", + global + .users_cache + .iter() + .filter(|u| u.id == global.cur_game.as_ref().unwrap().host_id) + .cloned() + .collect::>() + .first() + .unwrap_or(&UserPub { + id: "".to_string(), + created_at: "".to_string(), + username: "N/A".to_string() + }) + .username + ))); + + ui.label(egui::RichText::new(format!( + "Guest: {}", + global + .users_cache + .iter() + .filter(|u| &u.id + == global + .cur_game + .as_ref() + .unwrap() + .guest_id + .as_ref() + .unwrap_or(&"".to_string())) + .cloned() + .collect::>() + .first() + .unwrap_or(&UserPub { + id: "".to_string(), + created_at: "".to_string(), + username: "N/A".to_string() + }) + .username + ))); + if ui.button("Start").clicked() { //startgame_ev_w.send(StartGameEvent); } @@ -142,10 +183,46 @@ pub fn ui( } } PlayScreenState::InLobbyGuest => { - //ui.label(egui::RichText::new(format!( - // "Host: {}", - // rtdmenu.cur_game.as_ref().unwrap().host.username - //))); + ui.label(egui::RichText::new(format!( + "Host: {}", + global + .users_cache + .iter() + .filter(|u| u.id == global.cur_game.as_ref().unwrap().host_id) + .cloned() + .collect::>() + .first() + .unwrap_or(&UserPub { + id: "".to_string(), + created_at: "".to_string(), + username: "N/A".to_string() + }) + .username + ))); + + ui.label(egui::RichText::new(format!( + "Guest: {}", + global + .users_cache + .iter() + .filter(|u| &u.id + == global + .cur_game + .as_ref() + .unwrap() + .guest_id + .as_ref() + .unwrap_or(&"".to_string())) + .cloned() + .collect::>() + .first() + .unwrap_or(&UserPub { + id: "".to_string(), + created_at: "".to_string(), + username: "N/A".to_string() + }) + .username + ))); if ui.button("Back").clicked() { data.state = PlayScreenState::Main; @@ -273,7 +350,7 @@ fn browse_inprogress( .unwrap_or(&UserPub { id: "".to_string(), created_at: "".to_string(), - username: "".to_string() + username: "N/A".to_string() }) .username )); -- 2.44.1