Adding a lobby scene (#34)
All checks were successful
Rust Checks / checks (push) Successful in 1m4s

Closes #29

Reviewed-on: corentin/border-wars#34
Reviewed-by: Tipragot <contact@tipragot.fr>
Co-authored-by: CoCoSol007 <solois.corentin@gmail.com>
Co-committed-by: CoCoSol007 <solois.corentin@gmail.com>
This commit is contained in:
CoCo_Sol 2024-02-10 18:07:47 +00:00 committed by Tipragot
parent 12ada59b8c
commit 1a587a2588
2 changed files with 41 additions and 1 deletions

View file

@ -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<NextState<CurrentScene>>) {
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
}
});
}

View file

@ -5,6 +5,7 @@ use bevy_egui::EguiPlugin;
use crate::CurrentScene; use crate::CurrentScene;
pub mod lobby;
pub mod menu; pub mod menu;
/// The plugin for all scenes. /// The plugin for all scenes.
@ -14,6 +15,7 @@ impl Plugin for ScenesPlugin {
fn build(&self, app: &mut App) { fn build(&self, app: &mut App) {
app.add_plugins(EguiPlugin) app.add_plugins(EguiPlugin)
.add_state::<CurrentScene>() .add_state::<CurrentScene>()
.add_plugins(menu::MenuPlugin); .add_plugins(menu::MenuPlugin)
.add_plugins(lobby::LobbyPlugin);
} }
} }