@@ 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(),
}