Add the main menu #31

Merged
CoCo_Sol merged 25 commits from main-menu into main 2024-02-09 23:42:37 +00:00
2 changed files with 8 additions and 5 deletions
Showing only changes of commit 52c9112585 - Show all commits

View file

@ -1,14 +1,19 @@
//! The file that contains utility functions, enums, structs of the game.
use std::default::Default;
use bevy::prelude::*;
pub mod menu;
/// The state of the game.
#[derive(Debug, Clone, Copy, Default, Eq, PartialEq, Hash, States)]
pub enum GameState {
/// The main menu.
#[default]
Menu,
/// The lobby where the host will wait for other players to join.
Lobby,
/// The game.
Game,
}

View file

@ -12,10 +12,8 @@ pub struct MenuPlugin;
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,
(ui_connect_window, ui_host_window).run_if(in_state(GameState::Menu)),
);
app.add_plugins(EguiPlugin)
.add_systems(Update, menu_ui.run_if(in_state(GameState::Menu)));
println!("{:?}", app.world.resource::<State<GameState>>());
app.add_plugins(EguiPlugin).add_systems(
Update,
@ -24,7 +22,7 @@ impl Plugin for MenuPlugin {
}
}
/// Display a window, with a button to join a game and an input to enter
/// the address or create a new game.
/// TODO
fn menu_ui(mut ctx: EguiContexts, mut connection_string: Local<String>) {
egui::CentralPanel::default().show(ctx.ctx_mut(), |ui| {
ui.heading("Border Wars");