From 6a5eed397950af6549f117d00e8d5c29b77bcf48 Mon Sep 17 00:00:00 2001 From: raphael Date: Sat, 6 Apr 2024 16:42:31 +0200 Subject: [PATCH] save --- crates/border-wars/src/scenes/menu.rs | 112 +++++++++++++------------- 1 file changed, 57 insertions(+), 55 deletions(-) diff --git a/crates/border-wars/src/scenes/menu.rs b/crates/border-wars/src/scenes/menu.rs index 6577e33..ebb135a 100644 --- a/crates/border-wars/src/scenes/menu.rs +++ b/crates/border-wars/src/scenes/menu.rs @@ -1,13 +1,14 @@ //! The main menu of the game. -use bevnet::{Connection, SendTo, Uuid}; +// use bevnet::{Connection, SendTo, Uuid}; use bevy::prelude::*; -use bevy_egui::{egui, EguiContexts}; +// use bevy_egui::{egui, EguiContexts}; -use crate::networking::connection::RequestJoin; -use crate::networking::PlayerRank; +// use crate::networking::connection::RequestJoin; +// use crate::networking::PlayerRank; use crate::ui::hover::HoveredTexture; -use crate::{CurrentScene, Player}; +use crate::CurrentScene; +// use crate::Player; /// The plugin for the menu. pub struct MenuPlugin; @@ -26,65 +27,65 @@ struct Host; struct Join; // Display the UI of the menu to host a game or join one. -fn old_menu( - mut ctx: EguiContexts, - mut connection_string: Local, - mut next_scene: ResMut>, - mut request_join: EventWriter>, - mut name: Local, - connection: Res, - mut commands: Commands, -) { - let Some(uuid) = connection.identifier() else { - return; - }; +// fn old_menu( +// mut ctx: EguiContexts, +// mut connection_string: Local, +// mut next_scene: ResMut>, +// mut request_join: EventWriter>, +// mut name: Local, +// connection: Res, +// mut commands: Commands, +// ) { +// let Some(uuid) = connection.identifier() else { +// return; +// }; - egui::CentralPanel::default().show(ctx.ctx_mut(), |ui| { - ui.heading("Border Wars"); +// egui::CentralPanel::default().show(ctx.ctx_mut(), |ui| { +// ui.heading("Border Wars"); - ui.separator(); +// ui.separator(); - ui.label("Name"); - ui.text_edit_singleline(&mut *name); +// ui.label("Name"); +// ui.text_edit_singleline(&mut *name); - ui.separator(); +// ui.separator(); - ui.label("Connect to an existing game:"); - ui.horizontal(|ui| { - ui.label("Game ID: "); - ui.text_edit_singleline(&mut *connection_string); +// ui.label("Connect to an existing game:"); +// ui.horizontal(|ui| { +// ui.label("Game ID: "); +// ui.text_edit_singleline(&mut *connection_string); - let Ok(game_id) = Uuid::parse_str(&connection_string) else { - return; - }; +// let Ok(game_id) = Uuid::parse_str(&connection_string) else { +// return; +// }; - if ui.button("Join").clicked() { - next_scene.set(CurrentScene::Lobby); - request_join.send(SendTo( - game_id, - RequestJoin(Player { - name: name.clone(), - rank: PlayerRank::Player, - uuid, - color: rand::random::<(u8, u8, u8)>(), - }), - )); - } - }); +// if ui.button("Join").clicked() { +// next_scene.set(CurrentScene::Lobby); +// request_join.send(SendTo( +// game_id, +// RequestJoin(Player { +// name: name.clone(), +// rank: PlayerRank::Player, +// uuid, +// color: rand::random::<(u8, u8, u8)>(), +// }), +// )); +// } +// }); - ui.separator(); +// ui.separator(); - if ui.button("Create new game").clicked() { - next_scene.set(CurrentScene::Lobby); - commands.spawn(Player { - name: name.clone(), - rank: PlayerRank::Admin, - uuid, - color: rand::random::<(u8, u8, u8)>(), - }); - } - }); -} +// if ui.button("Create new game").clicked() { +// next_scene.set(CurrentScene::Lobby); +// commands.spawn(Player { +// name: name.clone(), +// rank: PlayerRank::Admin, +// uuid, +// color: rand::random::<(u8, u8, u8)>(), +// }); +// } +// }); +// } /// A Component to identify menus entities. /// In order to be able to remove them later. @@ -93,6 +94,7 @@ struct MenuEntity; type TargetScene = crate::Scene; +/// Create main element for the menu fn menu_ui(mut commands: Commands, asset_server: Res) { // Create the background. commands