M => +7 -11
@@ 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::<ToAccountEvent>()
.add_event::<ExitEvent>()
@@ 64,13 64,12 @@ impl Plugin for MenuPlugin {
.run_in_state(MenuState::AccountLoggedIn)
.with_system(handle_logout_event.run_on_event::<LogoutEvent>())
.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,
A => +31 -0
@@ 0,0 1,31 @@
/*
* This file is part of sdbclient
* Copyright (C) 2023 Jonni Liljamo <jonni@liljamo.com>
*
* 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! {
<body>
<div c:menu>
<span c:menutitle>
"Browse"
</span>
<button c:menubutton on:press=connect!(|ctx| {
ctx.commands().insert_resource(NextState(PlayMenuState::Main))
})>
"Back"
</button>
</div>
</body>
});
}
A => +31 -0
@@ 0,0 1,31 @@
/*
* This file is part of sdbclient
* Copyright (C) 2023 Jonni Liljamo <jonni@liljamo.com>
*
* 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! {
<body>
<div c:menu>
<span c:menutitle>
"Create"
</span>
<button c:menubutton on:press=connect!(|ctx| {
ctx.commands().insert_resource(NextState(PlayMenuState::Main))
})>
"Back"
</button>
</div>
</body>
});
}
A => +31 -0
@@ 0,0 1,31 @@
/*
* This file is part of sdbclient
* Copyright (C) 2023 Jonni Liljamo <jonni@liljamo.com>
*
* 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! {
<body>
<div c:menu>
<span c:menutitle>
"Lobby (Guest)"
</span>
<button c:menubutton on:press=connect!(|ctx| {
ctx.commands().insert_resource(NextState(PlayMenuState::BrowseGames))
})>
"Back"
</button>
</div>
</body>
});
}
A => +31 -0
@@ 0,0 1,31 @@
/*
* This file is part of sdbclient
* Copyright (C) 2023 Jonni Liljamo <jonni@liljamo.com>
*
* 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! {
<body>
<div c:menu>
<span c:menutitle>
"Lobby (Host)"
</span>
<button c:menubutton on:press=connect!(|ctx| {
ctx.commands().insert_resource(NextState(PlayMenuState::BrowseGames))
})>
"Back"
</button>
</div>
</body>
});
}
R => sdbclient/src/plugins/menu/play/main.rs +4 -4
@@ 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! {
<body>
<div c:menu>
@@ 21,12 21,12 @@ pub fn play_setup(mut commands: Commands) {
"Play"
</span>
<button c:menubutton on:press=connect!(|ctx| {
ctx.commands().insert_resource(NextState(MenuState::CreateGame))
ctx.commands().insert_resource(NextState(PlayMenuState::CreateGame))
})>
"Create"
</button>
<button c:menubutton on:press=connect!(|ctx| {
ctx.commands().insert_resource(NextState(MenuState::JoinGame))
ctx.commands().insert_resource(NextState(PlayMenuState::BrowseGames))
})>
"Join"
</button>
A => +59 -0
@@ 0,0 1,59 @@
/*
* This file is part of sdbclient
* Copyright (C) 2023 Jonni Liljamo <jonni@liljamo.com>
*
* 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))
}