From 70243fc189a7907f530fd76837afd10cccbbce96 Mon Sep 17 00:00:00 2001 From: CoCoSol007 Date: Sat, 10 Feb 2024 00:29:42 +0100 Subject: [PATCH] change doncstring --- crates/border-wars/src/lib.rs | 2 +- crates/border-wars/src/menu.rs | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/crates/border-wars/src/lib.rs b/crates/border-wars/src/lib.rs index a3fbdd3..2c740d6 100644 --- a/crates/border-wars/src/lib.rs +++ b/crates/border-wars/src/lib.rs @@ -12,7 +12,7 @@ pub enum GameState { /// When we are in the main menu. #[default] Menu, - /// The lobby where the host will wait for other players to join. + /// When we are in the lobby waiting for players. Lobby, /// When we play this wonderful game. Game, diff --git a/crates/border-wars/src/menu.rs b/crates/border-wars/src/menu.rs index fb490c2..914bea2 100644 --- a/crates/border-wars/src/menu.rs +++ b/crates/border-wars/src/menu.rs @@ -8,9 +8,7 @@ use crate::GameState; /// The plugin for the menu. pub struct MenuPlugin; -/// Implement a trait in order to transform the struc into a plugin. impl Plugin for MenuPlugin { - /// A function that is called when the plugin is added to the application. fn build(&self, app: &mut App) { app.add_plugins(EguiPlugin) .add_systems(Update, menu_ui.run_if(in_state(GameState::Menu))); @@ -22,25 +20,27 @@ impl Plugin for MenuPlugin { } } /// Display the UI of the menu to host a game or join one. -fn menu_ui(mut ctx: EguiContexts, mut connection_string: Local) { +fn menu_ui(mut ctx: EguiContexts, mut connection_string: Local, mut next_state: ResMut>) { egui::CentralPanel::default().show(ctx.ctx_mut(), |ui| { ui.heading("Border Wars"); ui.separator(); - ui.label("Connect to an existing game:"); + ui.label("Connect to an existing game:"); ui.horizontal(|ui| { ui.label("Game ID: "); ui.text_edit_singleline(&mut *connection_string); if ui.button("Join").clicked() { - println!("clicked"); + next_state.set(GameState::Game); } }); + ui.separator(); if ui.button("Create new game").clicked() { - println!("clicked"); + next_state.set(GameState::Lobby); + } }); }