DEVELOPMENT ENVIRONMENT

~liljamo/deck-builder

5a980b1115ecc7e2113bcde7e3a4fc55e8f162c2 — Jonni Liljamo 1 year, 9 months ago 4846d74
feat(client): derive Reflect for some types
M client/src/cfg/mod.rs => client/src/cfg/mod.rs +6 -3
@@ 20,7 20,8 @@ pub const FILE_CFG_DEV: &str = ".cfgdev.json";
pub struct CfgDirs(pub directories::ProjectDirs);

/// Various settings that can be changed from the... Settings.
#[derive(Serialize, Deserialize, Resource, Debug, Component, PartialEq, Clone)]
#[derive(Serialize, Deserialize, Resource, Reflect, Debug, Component, PartialEq, Clone)]
#[reflect(Resource)]
pub struct CfgSettings {
    /// Master Volume
    pub volume_master: u32,


@@ 41,7 42,8 @@ impl Default for CfgSettings {
}

/// User details and status
#[derive(Serialize, Deserialize, Resource, Debug, Component, PartialEq, Clone)]
#[derive(Serialize, Deserialize, Resource, Reflect, Debug, Component, PartialEq, Clone)]
#[reflect(Resource)]
pub struct CfgUser {
    /// User logged in status
    pub logged_in: bool,


@@ 62,7 64,8 @@ impl Default for CfgUser {
}

/// Settings that the user has no access to, or can only access through developer settings
#[derive(Serialize, Deserialize, Resource, Debug, Component, PartialEq, Clone)]
#[derive(Serialize, Deserialize, Resource, Reflect, Debug, Component, PartialEq, Clone)]
#[reflect(Resource)]
pub struct CfgDev {
    /// Server
    pub server_address: String,

M client/src/main.rs => client/src/main.rs +4 -1
@@ 99,8 99,11 @@ fn main() {
    ));

    app.insert_resource(cfg::CfgSettings::default())
        .register_type::<cfg::CfgSettings>()
        .insert_resource(cfg::CfgUser::default())
        .insert_resource(cfg::CfgDev::default());
        .register_type::<cfg::CfgUser>()
        .insert_resource(cfg::CfgDev::default())
        .register_type::<cfg::CfgDev>();

    app.add_startup_system(setup).add_state::<GameState>();


M client/src/plugins/menu/mod.rs => client/src/plugins/menu/mod.rs +2 -0
@@ 21,7 21,9 @@ impl Plugin for MenuPlugin {
            add_state::<MenuState>()
            .add_system(menu_setup.in_schedule(OnEnter(GameState::MainMenu)))
            .insert_resource(ui::connect::ConnectScreenData::default())
            .register_type::<ui::connect::ConnectScreenData>()
            .insert_resource(ui::play::PlayScreenData::default())
            .register_type::<ui::play::PlayScreenData>()
            .add_systems(
                (
                    ui::connect::ui.run_if(in_state(MenuState::Connect)),

M client/src/plugins/menu/ui/connect/mod.rs => client/src/plugins/menu/ui/connect/mod.rs +7 -4
@@ 6,15 6,18 @@
 * See LICENSE for licensing information.
 */

use bevy::ecs::system::Resource;
use bevy::{
    ecs::{reflect::ReflectResource, system::Resource},
    reflect::Reflect,
};

mod ui;
pub use ui::*;

#[derive(Default, Resource)]
#[derive(Default, Resource, Reflect)]
#[reflect(Resource)]
pub struct ConnectScreenData {
    pub state: ConnectState,
    pub connecting: bool,
    pub username: String,
    pub email: String,
    pub password: String,


@@ 22,7 25,7 @@ pub struct ConnectScreenData {
    pub error: String,
}

#[derive(Default, PartialEq)]
#[derive(Default, PartialEq, Reflect)]
pub enum ConnectState {
    #[default]
    Login,

M client/src/plugins/menu/ui/play/mod.rs => client/src/plugins/menu/ui/play/mod.rs +8 -4
@@ 6,18 6,22 @@
 * See LICENSE for licensing information.
 */

use bevy::ecs::system::Resource;
use bevy::{
    ecs::{reflect::ReflectResource, system::Resource},
    reflect::Reflect,
};

mod ui;
pub use ui::*;

#[derive(Default, Resource)]
#[derive(Default, Resource, Reflect)]
#[reflect(Resource)]
pub struct PlayScreenData {
    pub state: PlayScreenState,
    pub browse_state: PlayScreenBrowseState,
}

#[derive(Default, PartialEq, Clone)]
#[derive(Default, PartialEq, Clone, Reflect)]
pub enum PlayScreenState {
    #[default]
    Main,


@@ 37,7 41,7 @@ impl PlayScreenState {
    }
}

#[derive(Default, PartialEq)]
#[derive(Default, PartialEq, Reflect)]
pub enum PlayScreenBrowseState {
    #[default]
    Forming,