DEVELOPMENT ENVIRONMENT

~liljamo/deck-builder

dc3ac2f8c9aa307ff0ab7216de407e85142a09c1 — Jonni Liljamo 2 years ago 8d3ea6f
Naming changes
3 files changed, 40 insertions(+), 34 deletions(-)

M sdbclient/src/main.rs
M sdbclient/src/menu/accountloginui.rs
M sdbclient/src/menu/mod.rs
M sdbclient/src/main.rs => sdbclient/src/main.rs +35 -29
@@ 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);


M sdbclient/src/menu/accountloginui.rs => sdbclient/src/menu/accountloginui.rs +2 -2
@@ 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<EguiContext>,
    mut menu_state: ResMut<State<MenuState>>,
    mut inputs: ResMut<CfgUserLoginInputs>,
    mut inputs: ResMut<InputsUserLogin>,
) {
    egui::Window::new("Login")
        .collapsible(false)

M sdbclient/src/menu/mod.rs => sdbclient/src/menu/mod.rs +3 -3
@@ 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<AppExit>,
    mut menu_state: ResMut<State<MenuState>>,
    mut game_state: ResMut<State<GameState>>,
    mut logged_in: Res<CfgLoggedIn>,
    mut cfg_hidden: Res<CfgHidden>,
) {
    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()