From 7ad0cf1d5bed7109f88768a6f65f16fa53dbe449 Mon Sep 17 00:00:00 2001 From: Jonni Liljamo Date: Fri, 3 Feb 2023 12:39:38 +0200 Subject: [PATCH] feat(sdbclient): init new game management UIs --- sdbclient/src/plugins/menu/mod.rs | 18 +++--- .../src/plugins/menu/play/browsegames.rs | 31 ++++++++++ sdbclient/src/plugins/menu/play/creategame.rs | 31 ++++++++++ .../src/plugins/menu/play/inlobbyguest.rs | 31 ++++++++++ .../src/plugins/menu/play/inlobbyhost.rs | 31 ++++++++++ .../menu/{playscreen.rs => play/main.rs} | 8 +-- sdbclient/src/plugins/menu/play/mod.rs | 59 +++++++++++++++++++ 7 files changed, 194 insertions(+), 15 deletions(-) create mode 100644 sdbclient/src/plugins/menu/play/browsegames.rs create mode 100644 sdbclient/src/plugins/menu/play/creategame.rs create mode 100644 sdbclient/src/plugins/menu/play/inlobbyguest.rs create mode 100644 sdbclient/src/plugins/menu/play/inlobbyhost.rs rename sdbclient/src/plugins/menu/{playscreen.rs => play/main.rs} (78%) create mode 100644 sdbclient/src/plugins/menu/play/mod.rs diff --git a/sdbclient/src/plugins/menu/mod.rs b/sdbclient/src/plugins/menu/mod.rs index 716a871..59e3db1 100644 --- a/sdbclient/src/plugins/menu/mod.rs +++ b/sdbclient/src/plugins/menu/mod.rs @@ -23,12 +23,11 @@ use accountscreenloggedout::*; mod accountscreenloggedin; use accountscreenloggedin::*; -mod playscreen; -use playscreen::*; - mod accountlogin; mod accountregister; +mod play; + pub struct MenuPlugin; impl Plugin for MenuPlugin { @@ -38,7 +37,8 @@ impl Plugin for MenuPlugin { add_loopless_state(MenuState::None) .add_enter_system(GameState::MainMenu, menu_setup) // Systems for main menu screen - .add_enter_system(MenuState::Main, main_menu_setup) + .add_enter_system(MenuState::Main, remove_ui.label("msm_enter_first")) + .add_enter_system(MenuState::Main, main_menu_setup.before("msm_enter_first")) .add_exit_system(MenuState::Main, remove_ui) .add_event::() .add_event::() @@ -64,13 +64,12 @@ impl Plugin for MenuPlugin { .run_in_state(MenuState::AccountLoggedIn) .with_system(handle_logout_event.run_on_event::()) .into() - ) - // Systems for play screen - .add_enter_system(MenuState::Play, play_setup) - .add_exit_system(MenuState::Play, remove_ui); + ); app.add_plugin(accountregister::AccountRegisterPlugin) .add_plugin(accountlogin::AccountLoginPlugin); + + app.add_plugin(play::PlayMenuPlugin); } } @@ -80,9 +79,6 @@ pub enum MenuState { None, Main, Play, - Lobby, - CreateGame, - JoinGame, Settings, AccountLoggedIn, AccountLoggedOut, diff --git a/sdbclient/src/plugins/menu/play/browsegames.rs b/sdbclient/src/plugins/menu/play/browsegames.rs new file mode 100644 index 0000000..2b601a1 --- /dev/null +++ b/sdbclient/src/plugins/menu/play/browsegames.rs @@ -0,0 +1,31 @@ +/* + * This file is part of sdbclient + * Copyright (C) 2023 Jonni Liljamo + * + * Licensed under GPL-3.0-only. + * See LICENSE for licensing information. + */ + +use bevy::prelude::*; +use iyes_loopless::prelude::*; + +use belly::prelude::*; + +use super::PlayMenuState; + +pub fn setup(mut commands: Commands) { + commands.add(eml! { + +
+ + "Browse" + + +
+ + }); +} diff --git a/sdbclient/src/plugins/menu/play/creategame.rs b/sdbclient/src/plugins/menu/play/creategame.rs new file mode 100644 index 0000000..487226e --- /dev/null +++ b/sdbclient/src/plugins/menu/play/creategame.rs @@ -0,0 +1,31 @@ +/* + * This file is part of sdbclient + * Copyright (C) 2023 Jonni Liljamo + * + * Licensed under GPL-3.0-only. + * See LICENSE for licensing information. + */ + +use bevy::prelude::*; +use iyes_loopless::prelude::*; + +use belly::prelude::*; + +use super::PlayMenuState; + +pub fn setup(mut commands: Commands) { + commands.add(eml! { + +
+ + "Create" + + +
+ + }); +} diff --git a/sdbclient/src/plugins/menu/play/inlobbyguest.rs b/sdbclient/src/plugins/menu/play/inlobbyguest.rs new file mode 100644 index 0000000..f026349 --- /dev/null +++ b/sdbclient/src/plugins/menu/play/inlobbyguest.rs @@ -0,0 +1,31 @@ +/* + * This file is part of sdbclient + * Copyright (C) 2023 Jonni Liljamo + * + * Licensed under GPL-3.0-only. + * See LICENSE for licensing information. + */ + +use bevy::prelude::*; +use iyes_loopless::prelude::*; + +use belly::prelude::*; + +use super::PlayMenuState; + +pub fn setup(mut commands: Commands) { + commands.add(eml! { + +
+ + "Lobby (Guest)" + + +
+ + }); +} diff --git a/sdbclient/src/plugins/menu/play/inlobbyhost.rs b/sdbclient/src/plugins/menu/play/inlobbyhost.rs new file mode 100644 index 0000000..14df782 --- /dev/null +++ b/sdbclient/src/plugins/menu/play/inlobbyhost.rs @@ -0,0 +1,31 @@ +/* + * This file is part of sdbclient + * Copyright (C) 2023 Jonni Liljamo + * + * Licensed under GPL-3.0-only. + * See LICENSE for licensing information. + */ + +use bevy::prelude::*; +use iyes_loopless::prelude::*; + +use belly::prelude::*; + +use super::PlayMenuState; + +pub fn setup(mut commands: Commands) { + commands.add(eml! { + +
+ + "Lobby (Host)" + + +
+ + }); +} diff --git a/sdbclient/src/plugins/menu/playscreen.rs b/sdbclient/src/plugins/menu/play/main.rs similarity index 78% rename from sdbclient/src/plugins/menu/playscreen.rs rename to sdbclient/src/plugins/menu/play/main.rs index 198db96..7e063f6 100644 --- a/sdbclient/src/plugins/menu/playscreen.rs +++ b/sdbclient/src/plugins/menu/play/main.rs @@ -11,9 +11,9 @@ use iyes_loopless::prelude::*; use belly::prelude::*; -use super::MenuState; +use super::{MenuState, PlayMenuState}; -pub fn play_setup(mut commands: Commands) { +pub fn setup(mut commands: Commands) { commands.add(eml! {
@@ -21,12 +21,12 @@ pub fn play_setup(mut commands: Commands) { "Play" diff --git a/sdbclient/src/plugins/menu/play/mod.rs b/sdbclient/src/plugins/menu/play/mod.rs new file mode 100644 index 0000000..457b23b --- /dev/null +++ b/sdbclient/src/plugins/menu/play/mod.rs @@ -0,0 +1,59 @@ +/* + * This file is part of sdbclient + * Copyright (C) 2023 Jonni Liljamo + * + * Licensed under GPL-3.0-only. + * See LICENSE for licensing information. + */ + +use bevy::prelude::*; +use iyes_loopless::prelude::*; + +use crate::remove_ui; + +use super::MenuState; + +mod browsegames; +mod creategame; +mod inlobbyguest; +mod inlobbyhost; +mod main; + +pub(super) struct PlayMenuPlugin; + +impl Plugin for PlayMenuPlugin { + fn build(&self, app: &mut App) { + app.add_loopless_state(PlayMenuState::None) + .add_enter_system(MenuState::Play, play_menu_setup) + // Systems for main play menu + .add_enter_system(PlayMenuState::Main, main::setup) + .add_exit_system(PlayMenuState::Main, remove_ui) + // Systems for create game menu + .add_enter_system(PlayMenuState::CreateGame, creategame::setup) + .add_exit_system(PlayMenuState::CreateGame, remove_ui) + // Systems for browse games menu + .add_enter_system(PlayMenuState::BrowseGames, browsegames::setup) + .add_exit_system(PlayMenuState::BrowseGames, remove_ui) + // Systems for in lobby host menu + .add_enter_system(PlayMenuState::InLobbyHost, inlobbyhost::setup) + .add_exit_system(PlayMenuState::InLobbyHost, remove_ui) + // Systems for in lobby guest menu + .add_enter_system(PlayMenuState::InLobbyGuest, inlobbyguest::setup) + .add_exit_system(PlayMenuState::InLobbyGuest, remove_ui); + } +} + +/// Play Menu State +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub(super) enum PlayMenuState { + None, + Main, + CreateGame, + BrowseGames, + InLobbyHost, + InLobbyGuest, +} + +fn play_menu_setup(mut commands: Commands) { + commands.insert_resource(NextState(PlayMenuState::Main)) +} -- 2.44.1