diff --git a/Cargo.lock b/Cargo.lock index 9f157adc..c30367aa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4593,7 +4593,6 @@ dependencies = [ name = "sandpolis-bootagent" version = "0.0.1" dependencies = [ - "ring", "smoltcp", "uefi", ] @@ -4725,15 +4724,6 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" -[[package]] -name = "signal-hook-registry" -version = "1.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1" -dependencies = [ - "libc", -] - [[package]] name = "simba" version = "0.9.0" @@ -5115,9 +5105,7 @@ dependencies = [ "libc", "mio", "num_cpus", - "parking_lot", "pin-project-lite", - "signal-hook-registry", "socket2", "tokio-macros", "windows-sys 0.48.0", diff --git a/sandpolis/Cargo.toml b/sandpolis/Cargo.toml index 6aa619b9..1dcb92cd 100644 --- a/sandpolis/Cargo.toml +++ b/sandpolis/Cargo.toml @@ -19,7 +19,7 @@ reqwest = { version = "0.12.5", default-features = false, features = ["stream", serde_bytes = "0.11.15" serde = { version = "1.0.203", features = ["derive"] } strum = { version = "0.26.3", features = ["derive"] } -tokio = { version = "1.34.0", features = ["full"] } +tokio = { version = "1.34.0", default-features = false, features = ["rt", "macros"] } tracing = "0.1.40" tracing-subscriber = { version = "0.3.18", features = ["env-filter"] } uuid = { version = "1.10.0", features = ["v7", "serde"] } diff --git a/sandpolis/src/client/ui/input.rs b/sandpolis/src/client/ui/input.rs index 63e6d5ca..6eec20ca 100644 --- a/sandpolis/src/client/ui/input.rs +++ b/sandpolis/src/client/ui/input.rs @@ -119,13 +119,20 @@ pub fn handle_camera( } /// Show a help window with keyboard shortcuts. -pub fn handle_keymap(mut contexts: EguiContexts, keyboard_input: Res>) { +pub fn handle_keymap( + mut contexts: EguiContexts, + keyboard_input: Res>, + mut windows: Query<&mut Window>, +) { if keyboard_input.pressed(KeyCode::KeyK) { + let window_size = windows.single_mut().size(); egui::Window::new("Keyboard shortcuts") .id(egui::Id::new("keymap")) + .pivot(egui::Align2::CENTER_CENTER) .resizable(false) .movable(false) .collapsible(false) + .fixed_pos(egui::Pos2::new(window_size.x / 2.0, window_size.y / 2.0)) .show(contexts.ctx_mut(), |ui| { ui.label("W - Pan camera upwards"); ui.label("A - Pan camera upwards"); @@ -159,13 +166,11 @@ pub fn handle_layer_change( let window_size = windows.single_mut().size(); egui::Window::new("Current layer") .id(egui::Id::new("current_layer")) + .pivot(egui::Align2::CENTER_CENTER) .resizable(false) .movable(false) .collapsible(false) - .fixed_pos(egui::Pos2::new( - window_size.x / 2.0, - window_size.y + window_size.y / 3.0, - )) + .fixed_pos(egui::Pos2::new(window_size.x / 2.0, window_size.y - 30.0)) .show(contexts.ctx_mut(), |ui| { ui.label(format!("{:?}", **current_layer)); }); diff --git a/sandpolis/src/client/ui/layer/desktop.rs b/sandpolis/src/client/ui/layer/desktop.rs new file mode 100644 index 00000000..db75a282 --- /dev/null +++ b/sandpolis/src/client/ui/layer/desktop.rs @@ -0,0 +1,9 @@ +use bevy::prelude::*; + +use crate::{client::ui::CurrentLayer, core::Layer}; + +pub fn check_layer_active(current_layer: Res) -> bool { + return **current_layer == Layer::Desktop; +} + +pub fn handle_layer(mut commands: Commands) {} diff --git a/sandpolis/src/client/ui/layer/mod.rs b/sandpolis/src/client/ui/layer/mod.rs new file mode 100644 index 00000000..86d21061 --- /dev/null +++ b/sandpolis/src/client/ui/layer/mod.rs @@ -0,0 +1,2 @@ +#[cfg(feature = "layer-desktop")] +pub mod desktop; diff --git a/sandpolis/src/client/ui/mod.rs b/sandpolis/src/client/ui/mod.rs index e63e80b4..cac0ec21 100644 --- a/sandpolis/src/client/ui/mod.rs +++ b/sandpolis/src/client/ui/mod.rs @@ -17,6 +17,7 @@ use crate::core::{database::Database, Layer}; use self::{input::MousePressed, node::spawn_node}; pub mod input; +pub mod layer; pub mod node; #[derive(Resource)] @@ -73,6 +74,12 @@ pub fn run(state: AppState) { ), ); + #[cfg(feature = "layer-desktop")] + app.add_systems( + Update, + self::layer::desktop::handle_layer.run_if(self::layer::desktop::check_layer_active), + ); + // MSAA makes some Android devices panic, this is under investigation // https://github.com/bevyengine/bevy/issues/8229 #[cfg(target_os = "android")] diff --git a/sandpolis/src/client/ui/node.rs b/sandpolis/src/client/ui/node.rs index 7e71b83f..997ebbd9 100644 --- a/sandpolis/src/client/ui/node.rs +++ b/sandpolis/src/client/ui/node.rs @@ -16,7 +16,7 @@ pub struct Node { pub collier: Collider, pub rigid_body: RigidBody, // /// User indication of whether an entity is visible - // pub visibility: Visibility, + pub visibility: Visibility, pub sprite: SpriteBundle, // // Inherited visibility of an entity. // pub inherited_visibility: InheritedVisibility, @@ -38,6 +38,7 @@ pub fn spawn_node( rigid_body: RigidBody::Dynamic, // visibility: todo!(), restitution: Restitution::coefficient(0.7), + visibility: Visibility::Visible, sprite: SpriteBundle { texture: asset_server.load(get_os_image(os_type)), ..default() @@ -45,12 +46,12 @@ pub fn spawn_node( }; // TODO store a handle somehow - egui::Window::new("Hello") - .resizable(false) - .movable(false) - .show(contexts.ctx_mut(), |ui| { - ui.label("world"); - }); + // egui::Window::new("Hello") + // .resizable(false) + // .movable(false) + // .show(contexts.ctx_mut(), |ui| { + // ui.label("world"); + // }); commands.spawn(node); } diff --git a/sandpolis/src/core/mod.rs b/sandpolis/src/core/mod.rs index 76457d6b..b907cedf 100644 --- a/sandpolis/src/core/mod.rs +++ b/sandpolis/src/core/mod.rs @@ -81,7 +81,7 @@ impl InstanceId { } } -#[derive(Serialize, Deserialize, Clone, Copy, EnumIter, Debug)] +#[derive(Serialize, Deserialize, Clone, Copy, EnumIter, Debug, PartialEq, Eq)] pub enum Layer { /// Interact with Desktop environments. #[cfg(feature = "layer-desktop")]