diff --git a/crates/border-wars/src/scenes/lobby.rs b/crates/border-wars/src/scenes/lobby.rs new file mode 100644 index 0000000..84a0348 --- /dev/null +++ b/crates/border-wars/src/scenes/lobby.rs @@ -0,0 +1,38 @@ +//! The lobby of the game. + +use bevy::prelude::*; +use bevy_egui::{egui, EguiContexts}; + +use crate::CurrentScene; + +/// The plugin for the lobby. +pub struct LobbyPlugin; + +impl Plugin for LobbyPlugin { + fn build(&self, app: &mut App) { + app.add_systems(Update, lobby_ui.run_if(in_state(CurrentScene::Lobby))); + } +} + +/// Display the UI of the lobby. +fn lobby_ui(mut ctx: EguiContexts, mut next_scene: ResMut>) { + egui::CentralPanel::default().show(ctx.ctx_mut(), |ui| { + ui.heading("Border Wars"); + + ui.separator(); + + ui.label("Game created"); + ui.horizontal(|ui| { + ui.label("Game ID: "); + // TODO : get the game ID and display it. + ui.label("connection_string"); + }); + + ui.separator(); + + if ui.button("Run the game").clicked() { + next_scene.set(CurrentScene::Game); + // TODO: run the game + } + }); +} diff --git a/crates/border-wars/src/scenes/mod.rs b/crates/border-wars/src/scenes/mod.rs index 06e9603..2a788fd 100644 --- a/crates/border-wars/src/scenes/mod.rs +++ b/crates/border-wars/src/scenes/mod.rs @@ -5,6 +5,7 @@ use bevy_egui::EguiPlugin; use crate::CurrentScene; +pub mod lobby; pub mod menu; /// The plugin for all scenes. @@ -14,6 +15,7 @@ impl Plugin for ScenesPlugin { fn build(&self, app: &mut App) { app.add_plugins(EguiPlugin) .add_state::() - .add_plugins(menu::MenuPlugin); + .add_plugins(menu::MenuPlugin) + .add_plugins(lobby::LobbyPlugin); } }