From dba81d38792caad88bb3daae4e2e7a9c50e31dcd Mon Sep 17 00:00:00 2001 From: Jonni Liljamo Date: Tue, 20 Dec 2022 10:54:27 +0200 Subject: [PATCH] Move Cfg things to a new mod --- sdbclient/src/cfg/mod.rs | 36 ++++++++++++++++++++++++++++++++++++ sdbclient/src/main.rs | 34 ++++------------------------------ sdbclient/src/menu/mod.rs | 2 +- 3 files changed, 41 insertions(+), 31 deletions(-) create mode 100644 sdbclient/src/cfg/mod.rs diff --git a/sdbclient/src/cfg/mod.rs b/sdbclient/src/cfg/mod.rs new file mode 100644 index 0000000..b7ab898 --- /dev/null +++ b/sdbclient/src/cfg/mod.rs @@ -0,0 +1,36 @@ +/* + * This file is part of sdbclient + * Copyright (C) 2022 Jonni Liljamo + * + * Licensed under GPL-3.0-only. + * See LICENSE for licensing information. + */ + +use bevy::prelude::*; + +/// 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), +} + +/// User details and status +#[derive(Resource, Debug, Component, PartialEq, Clone)] +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, +} diff --git a/sdbclient/src/main.rs b/sdbclient/src/main.rs index 50165e4..534f180 100644 --- a/sdbclient/src/main.rs +++ b/sdbclient/src/main.rs @@ -14,6 +14,7 @@ use bevy::{ use bevy_egui::EguiPlugin; use bevy_inspector_egui::WorldInspectorPlugin; +mod cfg; mod menu; mod plugins; mod util; @@ -26,33 +27,6 @@ pub enum GameState { Game, } -/// 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), -} - -/// User details and status -#[derive(Resource, Debug, Component, PartialEq, Clone)] -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,16 +69,16 @@ fn main() { app.add_plugin(EguiPlugin); app.add_plugin(WorldInspectorPlugin::new()); - app.insert_resource(CfgSettings { + app.insert_resource(cfg::CfgSettings { volume_master: 7, fullscreen: false, resolution: (1280., 720.), }) - .insert_resource(CfgUser { + .insert_resource(cfg::CfgUser { logged_in: false, user_token: "".to_string(), }) - .insert_resource(CfgHidden { + .insert_resource(cfg::CfgHidden { api_server: "http://localhost:8080".to_string(), }) .insert_resource(InputsUserLogin("".to_string(), "".to_string())) diff --git a/sdbclient/src/menu/mod.rs b/sdbclient/src/menu/mod.rs index 164d443..67ea7ef 100644 --- a/sdbclient/src/menu/mod.rs +++ b/sdbclient/src/menu/mod.rs @@ -8,7 +8,7 @@ use bevy::{app::AppExit, prelude::*}; -use crate::CfgUser; +use crate::cfg::CfgUser; use super::{despawn_screen, GameState}; -- 2.44.1