5 files changed, 1 insertions(+), 288 deletions(-)
D client/src/plugins/menu/accountscreenloggedin.rs
D client/src/plugins/menu/accountscreenloggedout.rs
D client/src/plugins/menu/mainmenuscreen.rs
M client/src/plugins/menu/mod.rs
D client/src/plugins/menu/settingsscreen.rs
D => +0 -69
@@ 1,69 0,0 @@
/*
* This file is part of laurelin/client
* 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 crate::{
cfg::CfgUser,
plugins::config::{SaveEvent, SaveEventValue},
};
use super::MenuState;
pub(super) struct LogoutEvent;
pub(super) fn account_loggedin_setup(mut commands: Commands, cfg_user: Res<CfgUser>) {
let username = cfg_user.username.clone();
commands.add(eml! {
<body>
<div c:menu>
<span c:menutitle>
"Account"
</span>
<span>
"Logged in as:"
</span>
<span>
{ username }
</span>
<button c:menubutton on:press=connect!(|ctx| {
ctx.send_event(LogoutEvent)
})>
"Logout"
</button>
<button c:menubutton on:press=connect!(|ctx| {
ctx.commands().insert_resource(NextState(MenuState::Main))
})>
"Back"
</button>
</div>
</body>
});
}
pub(super) fn handle_logout_event(
mut events: EventReader<LogoutEvent>,
mut commands: Commands,
mut cfg_user: ResMut<CfgUser>,
mut save_event_writer: EventWriter<SaveEvent>,
) {
for _event in events.iter() {
// Reset CfgUser to default
*cfg_user = CfgUser::default();
save_event_writer.send(SaveEvent {
value: SaveEventValue::User(cfg_user.clone()),
});
commands.insert_resource(NextState(MenuState::AccountLoggedOut));
}
}
D => +0 -43
@@ 1,43 0,0 @@
/*
* This file is part of laurelin/client
* 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::{accountlogin::LoginState, accountregister::RegisterState, MenuState};
pub(super) fn account_loggedout_setup(mut commands: Commands) {
commands.add(eml! {
<body>
<div c:menu>
<span c:menutitle>
"Account"
</span>
<button c:menubutton on:press=connect!(|ctx| {
ctx.commands().insert_resource(NextState(MenuState::AccountLogin));
ctx.commands().insert_resource(NextState(LoginState::Input));
})>
"Login"
</button>
<button c:menubutton on:press=connect!(|ctx| {
ctx.commands().insert_resource(NextState(MenuState::AccountRegister));
ctx.commands().insert_resource(NextState(RegisterState::Input));
})>
"Register"
</button>
<button c:menubutton on:press=connect!(|ctx| {
ctx.commands().insert_resource(NextState(MenuState::Main))
})>
"Back"
</button>
</div>
</body>
});
}
D client/src/plugins/menu/mainmenuscreen.rs => client/src/plugins/menu/mainmenuscreen.rs +0 -81
@@ 1,81 0,0 @@
-/*
- * This file is part of laurelin/client
- * Copyright (C) 2023 Jonni Liljamo <jonni@liljamo.com>
- *
- * Licensed under GPL-3.0-only.
- * See LICENSE for licensing information.
- */
-
-use bevy::{app::AppExit, prelude::*};
-use iyes_loopless::prelude::*;
-
-use belly::prelude::*;
-
-use crate::cfg::CfgUser;
-
-use super::MenuState;
-
-pub(super) struct ToAccountEvent;
-pub(super) struct ExitEvent;
-
-pub(super) fn main_menu_setup(mut commands: Commands, cfg_user: Res<CfgUser>) {
- let logged_in = cfg_user.logged_in.clone();
-
- // TODO: Change the title to a fancy image logo thingy
- commands.add(eml! {
- <body>
- <div c:menu>
- <span c:mainmenutitle>
- "Deck Builder"
- </span>
- <button c:menubutton s:width="250px" on:press=connect!(|ctx| {
- // FIXME: I guess hiding the button would be better, but this is something for
- // now.
- if logged_in {
- ctx.commands().insert_resource(NextState(MenuState::Play))
- }
- })>
- "Play"
- </button>
- <button c:menubutton s:width="250px" on:press=connect!(|ctx| {
- ctx.send_event(ToAccountEvent)
- })>
- "Account"
- </button>
- <button c:menubutton s:width="250px" on:press=connect!(|ctx| {
- ctx.commands().insert_resource(NextState(MenuState::Settings))
- })>
- "Settings"
- </button>
- <button c:menubutton s:width="250px" on:press=connect!(|ctx| {
- ctx.send_event(ExitEvent)
- })>
- "Exit"
- </button>
- </div>
- </body>
- });
-}
-
-pub(super) fn handle_to_account_event(
- mut events: EventReader<ToAccountEvent>,
- mut commands: Commands,
- cfg_user: Res<CfgUser>,
-) {
- for _event in events.iter() {
- if cfg_user.logged_in {
- commands.insert_resource(NextState(MenuState::AccountLoggedIn))
- } else {
- commands.insert_resource(NextState(MenuState::AccountLoggedOut))
- }
- }
-}
-
-pub(super) fn handle_exit_event(
- mut events: EventReader<ExitEvent>,
- mut app_exit_event_writer: EventWriter<AppExit>,
-) {
- for _event in events.iter() {
- app_exit_event_writer.send(AppExit);
- }
-}
M => +1 -53
@@ 9,69 9,17 @@
use bevy::prelude::*;
use iyes_loopless::prelude::*;
use crate::{remove_ui, GameState};
use crate::GameState;
//mod mainmenuscreen;
//use mainmenuscreen::*;
//mod settingsscreen;
//use settingsscreen::*;
//mod accountscreenloggedout;
//use accountscreenloggedout::*;
//mod accountscreenloggedin;
//use accountscreenloggedin::*;
//mod accountlogin;
//mod accountregister;
//mod play;
pub struct MenuPlugin;
impl Plugin for MenuPlugin {
fn build(&self, app: &mut App) {
/*
app.
// Start with no menu. The menu is loaded when the GameState::MainMenu is entered.
add_loopless_state(MenuState::None)
.add_enter_system(GameState::MainMenu, menu_setup)
// Systems for main menu screen
.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>()
.add_system_set(
ConditionSet::new()
.run_in_state(MenuState::Main)
.with_system(handle_to_account_event.run_on_event::<ToAccountEvent>())
.with_system(handle_exit_event.run_on_event::<ExitEvent>())
.into()
);
*/
// Systems for the settings screen
//.add_enter_system(MenuState::Settings, settings_setup)
//.add_exit_system(MenuState::Settings, remove_ui)
// Systems for account loggedout screen
//.add_enter_system(MenuState::AccountLoggedOut, account_loggedout_setup)
//.add_exit_system(MenuState::AccountLoggedOut, remove_ui)
// Systems for account loggedin screen
//.add_enter_system(MenuState::AccountLoggedIn, account_loggedin_setup)
//.add_exit_system(MenuState::AccountLoggedIn, remove_ui)
//.add_event::<LogoutEvent>()
//.add_system_set(
// ConditionSet::new()
// .run_in_state(MenuState::AccountLoggedIn)
// .with_system(handle_logout_event.run_on_event::<LogoutEvent>())
// .into()
//);
//app.add_plugin(accountregister::AccountRegisterPlugin)
// .add_plugin(accountlogin::AccountLoginPlugin);
//app.add_plugin(play::PlayMenuPlugin);
}
}
D => +0 -42
@@ 1,42 0,0 @@
/*
* This file is part of laurelin/client
* 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::MenuState;
pub(super) fn settings_setup(mut commands: Commands) {
commands.add(eml! {
<body>
<div c:settingsmenu>
<buttongroup on:value_change=connect!(|ctx| {
let ev = ctx.event();
ctx.select(ev.old_value()).add_class("hidden");
ctx.select(ev.new_value()).remove_class("hidden");
})>
<button c:settingstab value=".tabdisplay" pressed>"Display"</button>
<button c:settingstab value=".tabaudio">"Audio"</button>
<button c:settingstab value=".tabmisc">"Misc"</button>
</buttongroup>
<div>
<div c:tabdisplay>"display"</div>
<div c:tabaudio c:hidden>"audio"</div>
<div c:tabmisc c:hidden>"misc"</div>
</div>
<button c:menubutton on:press=connect!(|ctx| {
ctx.commands().insert_resource(NextState(MenuState::Main))
})>
"Back"
</button>
</div>
</body>
});
}