Adding a lobby scene #34

Merged
tipragot merged 13 commits from lobby-menu into main 2024-02-10 18:07:50 +00:00
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;
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::<CurrentScene>()
.add_plugins(menu::MenuPlugin);
.add_plugins(menu::MenuPlugin)
.add_plugins(lobby::LobbyPlugin);
}
}