From f9208821d4ad1e194f7ccb15741c9842ddbaf305 Mon Sep 17 00:00:00 2001 From: Jonni Liljamo Date: Tue, 21 Mar 2023 09:35:01 +0200 Subject: [PATCH] feat(client): enable other game browse views --- client/src/plugins/menu/ui/play/ui.rs | 33 +++++++++++++-------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/client/src/plugins/menu/ui/play/ui.rs b/client/src/plugins/menu/ui/play/ui.rs index f974f06..f77def1 100644 --- a/client/src/plugins/menu/ui/play/ui.rs +++ b/client/src/plugins/menu/ui/play/ui.rs @@ -8,6 +8,7 @@ use bevy::prelude::*; use bevy_egui::{egui, EguiContexts}; +use laurelin_shared::types::game::{GAMESTATE_FINISHED, GAMESTATE_INPROGRESS}; use crate::{ cfg::CfgUser, @@ -200,19 +201,18 @@ fn browse_forming(ui: &mut egui::Ui, data: &mut PlayScreenData, cfg_user: &CfgUs } } -fn browse_inprogress(ui: &mut egui::Ui, rtdmenu: &mut PlayScreenData) { - /* - if rtdmenu.waiting_for_my_games_call { +fn browse_inprogress(ui: &mut egui::Ui, data: &mut PlayScreenData) { + if data.waiting_for_my_games { ui.horizontal(|ui| { ui.spinner(); ui.label("loading..."); }); } else { - if rtdmenu.my_games.is_empty() { + if data.my_games.is_empty() { ui.label("No games found."); } else { - let mut games = rtdmenu.my_games.clone(); - games.retain(|g| g.state == GameState::InProgress); + let mut games = data.my_games.clone(); + games.retain(|g| g.state == GAMESTATE_INPROGRESS); for game in games { egui::Frame::none() @@ -222,12 +222,13 @@ fn browse_inprogress(ui: &mut egui::Ui, rtdmenu: &mut PlayScreenData) { .inner_margin(4.) .show(ui, |ui| { ui.horizontal(|ui| { - ui.label(format!("Host: {}", game.host.username)); + //ui.label(format!("Host: {}", game.host.username)); + ui.label("Host: host-username-here"); ui.with_layout( egui::Layout::right_to_left(egui::Align::Center), |ui| { if ui.button("Resume").clicked() { - rtdmenu.cur_game = Some(game.clone()); + data.cur_game = Some(game.clone()); //resumegame_ev_w.send(ResumeGameEvent); } }, @@ -237,22 +238,20 @@ fn browse_inprogress(ui: &mut egui::Ui, rtdmenu: &mut PlayScreenData) { } } } - */ } -fn browse_finished(ui: &mut egui::Ui, rtdmenu: &mut PlayScreenData) { - /* - if rtdmenu.waiting_for_my_games_call { +fn browse_finished(ui: &mut egui::Ui, data: &mut PlayScreenData) { + if data.waiting_for_my_games { ui.horizontal(|ui| { ui.spinner(); ui.label("loading..."); }); } else { - if rtdmenu.my_games.is_empty() { + if data.my_games.is_empty() { ui.label("No games found."); } else { - let mut games = rtdmenu.my_games.clone(); - games.retain(|g| g.state == GameState::Finished); + let mut games = data.my_games.clone(); + games.retain(|g| g.state == GAMESTATE_FINISHED); for game in games { egui::Frame::none() @@ -262,11 +261,11 @@ fn browse_finished(ui: &mut egui::Ui, rtdmenu: &mut PlayScreenData) { .inner_margin(4.) .show(ui, |ui| { ui.horizontal(|ui| { - ui.label(format!("Host: {}", game.host.username)); + ui.label("Host: host-username-here"); + //ui.label(format!("Host: {}", game.host.username)); }); }); } } } - */ } -- 2.44.1