From 4d768e5ac4d5bcd2a655bc428a4c194dba1c12f8 Mon Sep 17 00:00:00 2001 From: Jonni Liljamo Date: Mon, 19 Dec 2022 22:42:34 +0200 Subject: [PATCH] Move user cfgs to CfgUser --- sdbclient/src/main.rs | 19 +++++++++++++------ sdbclient/src/menu/mod.rs | 6 +++--- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/sdbclient/src/main.rs b/sdbclient/src/main.rs index 56d00fc..b3d0559 100644 --- a/sdbclient/src/main.rs +++ b/sdbclient/src/main.rs @@ -37,17 +37,22 @@ pub struct CfgSettings { pub resolution: (f32, f32), } -/// Settings that the user has no access to, or can only access through developer settings +/// User details and status #[derive(Resource, Debug, Component, PartialEq, Clone)] -pub struct CfgHidden { - /// API Server - pub api_server: String, +pub struct CfgUser { /// User logged in status pub logged_in: bool, /// User Token pub user_token: String, } +/// Settings that the user has no access to, or can only access through developer settings +#[derive(Resource, Debug, Component, PartialEq, Clone)] +pub struct CfgHidden { + /// API Server + pub api_server: String, +} + // Input structs /// Login inputs #[derive(Resource, Debug, Component, PartialEq, Eq, Clone)] @@ -95,11 +100,13 @@ fn main() { fullscreen: false, resolution: (1280., 720.), }) - .insert_resource(CfgHidden { - api_server: "http://localhost:8080".to_string(), + .insert_resource(CfgUser { logged_in: false, user_token: "".to_string(), }) + .insert_resource(CfgHidden { + api_server: "http://localhost:8080".to_string(), + }) .insert_resource(InputsUserLogin("".to_string(), "".to_string())) .insert_resource(InputsUserRegister( "".to_string(), diff --git a/sdbclient/src/menu/mod.rs b/sdbclient/src/menu/mod.rs index 8ebaf94..164d443 100644 --- a/sdbclient/src/menu/mod.rs +++ b/sdbclient/src/menu/mod.rs @@ -8,7 +8,7 @@ use bevy::{app::AppExit, prelude::*}; -use crate::CfgHidden; +use crate::CfgUser; use super::{despawn_screen, GameState}; @@ -138,7 +138,7 @@ fn menu_action( mut app_exit_events: EventWriter, mut menu_state: ResMut>, //mut game_state: ResMut>, - cfg_hidden: Res, + cfg_user: Res, ) { for (interaction, menu_button_action) in &interaction_query { if *interaction == Interaction::Clicked { @@ -154,7 +154,7 @@ fn menu_action( } MenuButtonAction::SettingsMisc => menu_state.set(MenuState::SettingsMisc).unwrap(), MenuButtonAction::Account => { - if cfg_hidden.logged_in { + if cfg_user.logged_in { menu_state.set(MenuState::AccountLoggedIn).unwrap() } else { menu_state.set(MenuState::AccountLoggedOut).unwrap() -- 2.44.1