DEVELOPMENT ENVIRONMENT

~liljamo/deck-builder

3b77fff573d6891ffeac062b831a72008243b8d7 — Jonni Liljamo 1 year, 9 months ago c52f5b1
feat!(client, server): finish transition to bevy 0.10, and in addition
* change from bevy_inspector_egui to bevy_editor_pls
* remove iyes_loopless, as it is now obsolete
* remove bevy_console and swap logs to terminal only, in preperation
  for my own console logging crate
M Cargo.lock => Cargo.lock +2 -2
@@ 1096,9 1096,9 @@ dependencies = [

[[package]]
name = "bevy_egui"
version = "0.20.0"
version = "0.20.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bf0efb32c83ae6d2cc36bda08a029d74fdeb45870489599d3779a36649802bce"
checksum = "1ae1391dc1820f8bb3f8f489f2348cfa5f5bd0970a4c6bcb0c1a011f65ae1b4d"
dependencies = [
 "arboard",
 "bevy",

M client/Cargo.toml => client/Cargo.toml +11 -2
@@ 11,6 11,15 @@ publish = false

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[features]
default = [
    "dev",
]

dev = [
    "dep:bevy_editor_pls",
]

[dependencies]
laurelin_shared = { package = "shared", path = "../shared" }



@@ 24,8 33,8 @@ toml = "0.7.1"
proc-macro2 = "1.0.50"

bevy = { version = "0.10.0", features = [ "wayland" ] }
bevy_editor_pls = "0.3.0"
bevy_egui = "0.20.0"
bevy_editor_pls = { version = "0.3.0", optional = true }
bevy_egui = "0.20.1"

# lua scripting
#bevy_mod_scripting = { version = "0.2.1", features = ["lua", "lua54", "lua_script_api"] }

A client/src/dev.rs => client/src/dev.rs +35 -0
@@ 0,0 1,35 @@
/*
 * This file is part of laurelin/client
 * Copyright (C) 2023 Jonni Liljamo <jonni@liljamo.com>
 *
 * Licensed under GPL-3.0-only.
 * See LICENSE for licensing information.
 */

use bevy::{diagnostic::FrameTimeDiagnosticsPlugin, prelude::*};
use bevy_editor_pls::{controls, EditorPlugin};

pub struct DevPlugin;

impl Plugin for DevPlugin {
    fn build(&self, app: &mut App) {
        app.add_plugin(EditorPlugin)
            .insert_resource(editor_controls())
            .add_plugin(FrameTimeDiagnosticsPlugin::default());
    }
}

fn editor_controls() -> controls::EditorControls {
    let mut editor_controls = controls::EditorControls::default_bindings();
    editor_controls.unbind(controls::Action::PlayPauseEditor);

    editor_controls.insert(
        controls::Action::PlayPauseEditor,
        controls::Binding {
            input: controls::UserInput::Single(controls::Button::Keyboard(KeyCode::Q)),
            conditions: vec![controls::BindingCondition::ListeningForText(false)],
        },
    );

    editor_controls
}

M client/src/main.rs => client/src/main.rs +22 -14
@@ 10,13 10,14 @@ use bevy::{
    app::AppExit,
    prelude::*,
    window::{
        CompositeAlphaMode, Cursor, CursorGrabMode, PresentMode, WindowLevel, WindowMode,
        WindowResizeConstraints, WindowResolution,
        CompositeAlphaMode, Cursor, PresentMode, WindowLevel, WindowMode, WindowResizeConstraints,
        WindowResolution,
    },
};
#[cfg(feature = "dev")]
use bevy_editor_pls::EditorPlugin;
use naia_bevy_client::{Client, ClientConfig as NaiaClientConfig, Plugin as NaiaClientPlugin};
use bevy_egui::EguiPlugin;
use naia_bevy_client::{
    Client, ClientConfig as NaiaClientConfig, Plugin as NaiaClientPlugin, ReceiveEvents,
};

use laurelin_shared::server::protocol::protocol;



@@ 26,6 27,9 @@ mod plugins;
mod runtime;
mod util;

#[cfg(feature = "dev")]
mod dev;

// NOTE: lua things, currently not in use
//use bevy_mod_scripting::prelude::*;
//mod lua;


@@ 40,20 44,18 @@ pub enum GameState {
    Game,
}

#[derive(SystemSet, Debug, Hash, PartialEq, Eq, Clone)]
struct MainLoop;

#[derive(SystemSet, Debug, Hash, PartialEq, Eq, Clone)]
struct AfterMainLoop;

fn main() {
    let mut app = App::new();

    app.add_plugins(DefaultPlugins.set(WindowPlugin {
        primary_window: Some(Window {
            cursor: Cursor {
                icon: CursorIcon::Default,
                visible: true,
                grab_mode: CursorGrabMode::None,
                hit_test: true,
                ..Default::default()
            },
            cursor: Cursor::default(),
            present_mode: PresentMode::Fifo,
            mode: WindowMode::Windowed,
            position: WindowPosition::Centered(MonitorSelection::Primary),


@@ 80,8 82,14 @@ fn main() {
        ..Default::default()
    }));

    app.configure_set(MainLoop.after(ReceiveEvents))
        .configure_set(AfterMainLoop.after(MainLoop));

    #[cfg(feature = "dev")]
    app.add_plugin(EditorPlugin);
    app.add_plugin(dev::DevPlugin);
    if !app.is_plugin_added::<EguiPlugin>() {
        app.add_plugin(EguiPlugin);
    }

    //app.add_plugin(ScriptingPlugin).add_plugin(lua::LuaPlugin);



@@ 114,7 122,7 @@ fn main() {

    // Graceful exit
    app.add_event::<GracefulExit>()
        .add_system(handle_graceful_exit);
        .add_system(handle_graceful_exit.in_set(AfterMainLoop));

    app.run();
}

M client/src/plugins/config/mod.rs => client/src/plugins/config/mod.rs +2 -3
@@ 8,7 8,7 @@

use bevy::prelude::*;

use crate::{cfg, util};
use crate::{cfg, util, AfterMainLoop};

/// This plugin will handle config related tasks, like saving and loading
pub struct ConfigPlugin;


@@ 17,8 17,7 @@ impl Plugin for ConfigPlugin {
    fn build(&self, app: &mut App) {
        app.init_resource::<Events<LoadEvent>>()
            .init_resource::<Events<SaveEvent>>()
            .add_system(handle_load_events)
            .add_system(handle_save_events);
            .add_systems((handle_load_events, handle_save_events).in_set(AfterMainLoop));
    }
}


M client/src/plugins/menu/mod.rs => client/src/plugins/menu/mod.rs +9 -5
@@ 8,7 8,7 @@

use bevy::prelude::*;

use crate::GameState;
use crate::{GameState, MainLoop};

pub mod ui;



@@ 22,10 22,14 @@ impl Plugin for MenuPlugin {
            .add_system(menu_setup.in_schedule(OnEnter(GameState::MainMenu)))
            .insert_resource(ui::connect::ConnectScreenData::default())
            .insert_resource(ui::play::PlayScreenData::default())
            .add_system(ui::connect::ui.run_if(in_state(MenuState::Connect)))
            .add_system(ui::menu::ui.run_if(in_state(MenuState::Menu)))
            .add_system(ui::settings::ui.run_if(in_state(MenuState::Settings)))
            .add_system(ui::play::ui.run_if(in_state(MenuState::Play)));
            .add_systems(
                (
                    ui::connect::ui.run_if(in_state(MenuState::Connect)),
                    ui::menu::ui.run_if(in_state(MenuState::Menu)),
                    ui::settings::ui.run_if(in_state(MenuState::Settings)),
                    ui::play::ui.run_if(in_state(MenuState::Play)),
                ).in_set(MainLoop)
            );
    }
}


M client/src/plugins/networking/mod.rs => client/src/plugins/networking/mod.rs +12 -5
@@ 7,6 7,7 @@
 */

use bevy::prelude::*;
use naia_bevy_client::ReceiveEvents;

mod systems;



@@ 14,10 15,16 @@ pub struct NetworkingPlugin;

impl Plugin for NetworkingPlugin {
    fn build(&self, app: &mut App) {
        app.add_system_to_stage(CoreStage::PreUpdate, systems::events::connect_events)
            .add_system_to_stage(CoreStage::PreUpdate, systems::events::reject_events)
            .add_system_to_stage(CoreStage::PreUpdate, systems::events::disconnect_events)
            .add_system_to_stage(CoreStage::PreUpdate, systems::events::message_events)
            .add_system_to_stage(CoreStage::PreUpdate, systems::events::tick_events);
        app.add_systems(
            (
                systems::events::connect_events,
                systems::events::reject_events,
                systems::events::disconnect_events,
                systems::events::message_events,
                systems::events::tick_events,
            )
                .chain()
                .in_set(ReceiveEvents),
        );
    }
}

M client/src/util/egui/password.rs => client/src/util/egui/password.rs +2 -2
@@ 11,7 11,7 @@ use bevy_egui::egui;
fn password_ui(ui: &mut egui::Ui, password: &mut String) -> egui::Response {
    let state_id = ui.id().with("show_plaintext");

    let mut show_plaintext = ui.data(|d| d.get_temp::<bool>(state_id).unwrap_or(false));
    let mut show_plaintext = ui.data_mut(|d| d.get_temp::<bool>(state_id).unwrap_or(false));

    let result = ui.with_layout(egui::Layout::left_to_right(egui::Align::Center), |ui| {
        // TODO: this was previously add_sized() with a max of ui.available_size()


@@ 27,7 27,7 @@ fn password_ui(ui: &mut egui::Ui, password: &mut String) -> egui::Response {
        }
    });

    ui.data(|d| d.insert_temp(state_id, show_plaintext));
    ui.data_mut(|d| d.insert_temp(state_id, show_plaintext));

    result.response
}

M server/src/systems/event/mod.rs => server/src/systems/event/mod.rs +2 -2
@@ 8,7 8,7 @@

use bevy_ecs::{
    event::EventReader,
    system::{Commands, Res, ResMut},
    system::{Res, ResMut},
};
use bevy_log::info;
use laurelin_shared::{


@@ 20,7 20,7 @@ use laurelin_shared::{
};
use naia_bevy_server::{
    events::{AuthEvents, ConnectEvent, DisconnectEvent, ErrorEvent, TickEvent},
    CommandsExt, Random, Server,
    Server,
};

use crate::{Config, RuntimeTemp};