DEVELOPMENT ENVIRONMENT

~liljamo/deck-builder

040d9aa32bdeb9d6db02807e73ef079759d3fb17 — Jonni Liljamo 1 year, 11 months ago ba90264
Add logout
1 files changed, 14 insertions(+), 2 deletions(-)

M sdbclient/src/plugins/menu/mod.rs
M sdbclient/src/plugins/menu/mod.rs => sdbclient/src/plugins/menu/mod.rs +14 -2
@@ 33,6 33,8 @@ use accountscreenloggedout::*;
mod accountscreenloggedin;
use accountscreenloggedin::*;

use super::config::{SaveEvent, SaveEventValue};

mod accountlogin;
mod accountregister;



@@ 127,8 129,9 @@ fn menu_action(
    mut menu_state: ResMut<State<MenuState>>,
    mut register_state: ResMut<State<accountregister::RegisterState>>,
    mut login_state: ResMut<State<accountlogin::LoginState>>,
    mut cfg_user: ResMut<CfgUser>,
    mut save_event_writer: EventWriter<SaveEvent>,
    //mut game_state: ResMut<State<GameState>>,
    cfg_user: Res<CfgUser>,
) {
    for (interaction, menu_button_action) in &interaction_query {
        if *interaction == Interaction::Clicked {


@@ 160,7 163,16 @@ fn menu_action(
                        .set(accountregister::RegisterState::Input)
                        .unwrap();
                }
                MenuButtonAction::AccountLogout => warn!("todo"),
                MenuButtonAction::AccountLogout => {
                    // Reset CfgUser to default.
                    *cfg_user = CfgUser::default();

                    save_event_writer.send(SaveEvent {
                        value: SaveEventValue::User(cfg_user.clone()),
                    });

                    menu_state.set(MenuState::AccountLoggedOut).unwrap()
                }
                MenuButtonAction::BackToSettings => menu_state.set(MenuState::Settings).unwrap(),
                MenuButtonAction::BackToMainMenu => menu_state.set(MenuState::Main).unwrap(),
            }