change doncstring
Some checks failed
Rust Checks / checks (push) Failing after 5s
Rust Checks / checks (pull_request) Failing after 5s

This commit is contained in:
CoCo_Sol 2024-02-10 00:29:42 +01:00
parent 35c6636ce8
commit 70243fc189
2 changed files with 7 additions and 7 deletions

View file

@ -12,7 +12,7 @@ pub enum GameState {
/// When we are in the main menu. /// When we are in the main menu.
#[default] #[default]
Menu, Menu,
/// The lobby where the host will wait for other players to join. /// When we are in the lobby waiting for players.
Lobby, Lobby,
/// When we play this wonderful game. /// When we play this wonderful game.
Game, Game,

View file

@ -8,9 +8,7 @@ use crate::GameState;
/// The plugin for the menu. /// The plugin for the menu.
pub struct MenuPlugin; pub struct MenuPlugin;
/// Implement a trait in order to transform the struc into a plugin.
impl Plugin for MenuPlugin { impl Plugin for MenuPlugin {
/// A function that is called when the plugin is added to the application.
fn build(&self, app: &mut App) { fn build(&self, app: &mut App) {
app.add_plugins(EguiPlugin) app.add_plugins(EguiPlugin)
.add_systems(Update, menu_ui.run_if(in_state(GameState::Menu))); .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. /// Display the UI of the menu to host a game or join one.
fn menu_ui(mut ctx: EguiContexts, mut connection_string: Local<String>) { fn menu_ui(mut ctx: EguiContexts, mut connection_string: Local<String>, mut next_state: ResMut<NextState<GameState>>) {
egui::CentralPanel::default().show(ctx.ctx_mut(), |ui| { egui::CentralPanel::default().show(ctx.ctx_mut(), |ui| {
ui.heading("Border Wars"); ui.heading("Border Wars");
ui.separator(); ui.separator();
ui.label("Connect to an existing game:");
ui.label("Connect to an existing game:");
ui.horizontal(|ui| { ui.horizontal(|ui| {
ui.label("Game ID: "); ui.label("Game ID: ");
ui.text_edit_singleline(&mut *connection_string); ui.text_edit_singleline(&mut *connection_string);
if ui.button("Join").clicked() { if ui.button("Join").clicked() {
println!("clicked"); next_state.set(GameState::Game);
} }
}); });
ui.separator(); ui.separator();
if ui.button("Create new game").clicked() { if ui.button("Create new game").clicked() {
println!("clicked"); next_state.set(GameState::Lobby);
} }
}); });
} }