From dc3ac2f8c9aa307ff0ab7216de407e85142a09c1 Mon Sep 17 00:00:00 2001 From: Jonni Liljamo Date: Mon, 19 Dec 2022 13:25:00 +0200 Subject: [PATCH] Naming changes --- sdbclient/src/main.rs | 64 +++++++++++++++------------- sdbclient/src/menu/accountloginui.rs | 4 +- sdbclient/src/menu/mod.rs | 6 +-- 3 files changed, 40 insertions(+), 34 deletions(-) diff --git a/sdbclient/src/main.rs b/sdbclient/src/main.rs index 5fb170a..0d44ace 100644 --- a/sdbclient/src/main.rs +++ b/sdbclient/src/main.rs @@ -26,30 +26,32 @@ pub enum GameState { Game, } -// Various settings that can be changed from the... Settings. -/// Volume -#[derive(Resource, Debug, Component, PartialEq, Eq, Clone, Copy)] -pub struct CfgVolume(u32); -/// Fullscreen -#[derive(Resource, Debug, Component, PartialEq, Eq, Clone, Copy)] -pub struct CfgFullscreen(bool); -/// Resolution -#[derive(Resource, Debug, Component, PartialEq, Clone, Copy)] -pub struct CfgResolution(f32, f32); - -// Settings that the user has no access to, or can only access through developer settings -/// API Server -#[derive(Resource, Debug, Component, PartialEq, Eq, Clone)] -pub struct CfgAPIServer(String); -/// User logged in status -#[derive(Resource, Debug, Component, PartialEq, Eq, Clone, Copy)] -pub struct CfgLoggedIn(bool); +/// Various settings that can be changed from the... Settings. +#[derive(Resource, Debug, Component, PartialEq, Clone)] +pub struct CfgSettings { + /// Master Volume + pub volume_master: u32, + /// Fulsscreen + pub fullscreen: bool, + /// Resolution + pub resolution: (f32, f32), +} + +/// 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, + /// User logged in status + pub logged_in: bool, + /// User Token + pub user_token: String, +} + +// Input structs /// Login username inputs #[derive(Resource, Debug, Component, PartialEq, Eq, Clone)] -pub struct CfgUserLoginInputs(String, String); -/// User Token -#[derive(Resource, Debug, Component, PartialEq, Eq, Clone)] -pub struct CfgUserToken(String); +pub struct InputsUserLogin(String, String); fn main() { let mut app = App::new(); @@ -85,13 +87,17 @@ fn main() { app.add_plugin(EguiPlugin); app.add_plugin(WorldInspectorPlugin::new()); - app.insert_resource(CfgVolume(7)) - .insert_resource(CfgFullscreen(false)) - .insert_resource(CfgResolution(1280., 720.)) - .insert_resource(CfgAPIServer("http://localhost:8080".to_string())) - .insert_resource(CfgUserLoginInputs("".to_string(), "".to_string())) - .insert_resource(CfgLoggedIn(false)) - .insert_resource(CfgUserToken("".to_string())); + app.insert_resource(CfgSettings { + volume_master: 7, + fullscreen: false, + resolution: (1280., 720.), + }) + .insert_resource(CfgHidden { + api_server: "http://localhost:8080".to_string(), + logged_in: false, + user_token: "".to_string(), + }) + .insert_resource(InputsUserLogin("".to_string(), "".to_string())); app.add_startup_system(setup).add_state(GameState::Splash); diff --git a/sdbclient/src/menu/accountloginui.rs b/sdbclient/src/menu/accountloginui.rs index 953ab17..549d357 100644 --- a/sdbclient/src/menu/accountloginui.rs +++ b/sdbclient/src/menu/accountloginui.rs @@ -9,14 +9,14 @@ use bevy::prelude::*; use bevy_egui::{egui, EguiContext}; -use crate::{util::eguipwd, CfgUserLoginInputs}; +use crate::{util::eguipwd, InputsUserLogin}; use super::MenuState; pub fn account_login_ui( mut egui_context: ResMut, mut menu_state: ResMut>, - mut inputs: ResMut, + mut inputs: ResMut, ) { egui::Window::new("Login") .collapsible(false) diff --git a/sdbclient/src/menu/mod.rs b/sdbclient/src/menu/mod.rs index 6257e95..8c6fc27 100644 --- a/sdbclient/src/menu/mod.rs +++ b/sdbclient/src/menu/mod.rs @@ -8,7 +8,7 @@ use bevy::{app::AppExit, prelude::*}; -use crate::CfgLoggedIn; +use crate::CfgHidden; use super::{despawn_screen, GameState}; @@ -134,7 +134,7 @@ fn menu_action( mut app_exit_events: EventWriter, mut menu_state: ResMut>, mut game_state: ResMut>, - mut logged_in: Res, + mut cfg_hidden: Res, ) { for (interaction, menu_button_action) in &interaction_query { if *interaction == Interaction::Clicked { @@ -150,7 +150,7 @@ fn menu_action( } MenuButtonAction::SettingsMisc => menu_state.set(MenuState::SettingsMisc).unwrap(), MenuButtonAction::Account => { - if logged_in.0 { + if cfg_hidden.logged_in { menu_state.set(MenuState::AccountLoggedIn).unwrap() } else { menu_state.set(MenuState::AccountLoggedOut).unwrap() -- 2.44.1