diff --git a/Cargo.lock b/Cargo.lock index 79c5eeb..cffbac5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -212,9 +212,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0348a1c054491f4bfe6ab86a7b6ab1e44e45d899005de92f58b3df180b36ddaf" dependencies = [ "clipboard-win", + "image", "log", "objc2 0.6.4", "objc2-app-kit 0.3.2", + "objc2-core-foundation", + "objc2-core-graphics", "objc2-foundation 0.3.2", "parking_lot", "percent-encoding", @@ -388,6 +391,57 @@ dependencies = [ "bevy_internal", ] +[[package]] +name = "bevy-inspector-egui" +version = "0.37.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38e425288304f5ec24cd026d39c813883225e670a88c94655272066d43d38078" +dependencies = [ + "bevy-inspector-egui-derive", + "bevy_app", + "bevy_asset", + "bevy_camera", + "bevy_color", + "bevy_core_pipeline", + "bevy_ecs", + "bevy_egui", + "bevy_gizmos", + "bevy_image", + "bevy_light", + "bevy_log", + "bevy_math", + "bevy_mesh", + "bevy_mikktspace", + "bevy_pbr", + "bevy_platform", + "bevy_reflect", + "bevy_render", + "bevy_state", + "bevy_time", + "bevy_utils", + "bevy_window", + "bytemuck", + "disqualified", + "egui", + "fuzzy-matcher", + "image", + "opener", + "smallvec", + "uuid", + "winit", +] + +[[package]] +name = "bevy-inspector-egui-derive" +version = "0.37.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99bdb0f08cbcec82bf7909b880acd52d7a527e6d47156b99f8b60e4cb9765f3f" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + [[package]] name = "bevy_a11y" version = "0.19.1" @@ -770,6 +824,51 @@ dependencies = [ "syn 2.0.119", ] +[[package]] +name = "bevy_egui" +version = "0.40.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7466095822999850fc52074c0b65e9f8b42da100bf7bbd10e5dc87415c6b3401" +dependencies = [ + "arboard", + "bevy_app", + "bevy_asset", + "bevy_camera", + "bevy_color", + "bevy_core_pipeline", + "bevy_derive", + "bevy_ecs", + "bevy_image", + "bevy_input", + "bevy_log", + "bevy_math", + "bevy_mesh", + "bevy_platform", + "bevy_reflect", + "bevy_render", + "bevy_shader", + "bevy_time", + "bevy_transform", + "bevy_utils", + "bevy_window", + "bevy_winit", + "bytemuck", + "crossbeam-channel", + "egui", + "encase", + "getrandom 0.4.3", + "image", + "itertools", + "js-sys", + "smithay-clipboard", + "thread_local", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "wgpu-types", + "winit", +] + [[package]] name = "bevy_encase_derive" version = "0.19.1" @@ -1899,6 +1998,17 @@ dependencies = [ "piper", ] +[[package]] +name = "bstr" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6bb31b46c14244e20ee9984b11bf5c992b91fb6939fea616e3512c8baecdbe5f" +dependencies = [ + "memchr", + "regex-automata", + "serde_core", +] + [[package]] name = "bumpalo" version = "3.20.3" @@ -1957,18 +2067,43 @@ dependencies = [ "thiserror 1.0.69", ] +[[package]] +name = "calloop" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4dbf9978365bac10f54d1d4b04f7ce4427e51f71d61f2fe15e3fed5166474df7" +dependencies = [ + "bitflags 2.13.1", + "polling", + "rustix 1.1.4", + "slab", + "tracing", +] + [[package]] name = "calloop-wayland-source" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95a66a987056935f7efce4ab5668920b5d0dac4a7c99991a67395f13702ddd20" dependencies = [ - "calloop", + "calloop 0.13.0", "rustix 0.38.44", "wayland-backend", "wayland-client", ] +[[package]] +name = "calloop-wayland-source" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "138efcf0940a02ebf0cc8d1eff41a1682a46b431630f4c52450d6265876021fa" +dependencies = [ + "calloop 0.14.4", + "rustix 1.1.4", + "wayland-backend", + "wayland-client", +] + [[package]] name = "cc" version = "1.4.3" @@ -2030,6 +2165,15 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "color" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ec7c5eb7a16992b1904d76c517d170ab353b0e0b3d5a0c81a8a0cd1037893cf" +dependencies = [ + "bytemuck", +] + [[package]] name = "combine" version = "4.6.7" @@ -2406,12 +2550,49 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d8b14ccef22fc6f5a8f4d7d768562a182c04ce9a3b3157b91390b52ddfdf1a76" +[[package]] +name = "ecolor" +version = "0.34.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a05fbfa222ffb51989d5ccf33e5f7aebfcf96c5023413856b0c3618a7f79896e" +dependencies = [ + "bytemuck", + "emath", +] + +[[package]] +name = "egui" +version = "0.34.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42112be0ae157289312b92b3dfaf20e911b5a3c4c65d4aab0e7c47fbc0ce16e3" +dependencies = [ + "accesskit", + "ahash", + "bitflags 2.13.1", + "emath", + "epaint", + "log", + "nohash-hasher", + "profiling", + "smallvec", + "unicode-segmentation", +] + [[package]] name = "either" version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e5e8f6c15a24b9a3ee5efec809ccd006d3b30e8b3bb63c39af737c7f87daa1d" +[[package]] +name = "emath" +version = "0.34.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b53f0d33a479321da6b0caa71366c9f67e8a2c149762d90bdc0d16e601ee8ecb" +dependencies = [ + "bytemuck", +] + [[package]] name = "encase" version = "0.12.1" @@ -2443,6 +2624,34 @@ dependencies = [ "syn 2.0.119", ] +[[package]] +name = "epaint" +version = "0.34.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6675898a291ec212fc3df04f537d177fce8496120244590e6359dcaa4c25da79" +dependencies = [ + "ahash", + "bytemuck", + "ecolor", + "emath", + "epaint_default_fonts", + "font-types 0.11.3", + "log", + "nohash-hasher", + "parking_lot", + "profiling", + "self_cell", + "skrifa 0.40.0", + "smallvec", + "vello_cpu", +] + +[[package]] +name = "epaint_default_fonts" +version = "0.34.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8970033a4282a7bcf899b38b5ed3a58b732fe093d03785d58648515d8d309da" + [[package]] name = "equivalent" version = "1.0.2" @@ -2511,6 +2720,12 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da7c62ceae207dd37ea5b845da6a0696c799f85e97da1ab5b7910be3c1c80223" +[[package]] +name = "fax" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "caf1079563223d5d59d83c85886a56e586cfd5c1a26292e971a0fa266531ac5a" + [[package]] name = "fdeflate" version = "0.3.7" @@ -2520,6 +2735,15 @@ dependencies = [ "simd-adler32", ] +[[package]] +name = "fearless_simd" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fb2907d1f08b2b316b9223ced5b0e89d87028ba8deae9764741dba8ff7f3903" +dependencies = [ + "bytemuck", +] + [[package]] name = "find-msvc-tools" version = "0.1.11" @@ -2683,6 +2907,15 @@ dependencies = [ "slab", ] +[[package]] +name = "fuzzy-matcher" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54614a3312934d066701a80f20f15fa3b56d67ac7722b39eea5b4c9dd1d66c94" +dependencies = [ + "thread_local", +] + [[package]] name = "gethostname" version = "1.1.0" @@ -2712,8 +2945,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099" dependencies = [ "cfg-if", + "js-sys", "libc", "r-efi 6.0.0", + "wasm-bindgen", ] [[package]] @@ -3120,6 +3355,7 @@ dependencies = [ "moxcms", "num-traits", "png", + "tiff", ] [[package]] @@ -3358,6 +3594,18 @@ dependencies = [ "bitflags 2.13.1", ] +[[package]] +name = "kurbo" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b60dfc32f652b926df6192e55525b16d186c69d47876c3ead4da5cc9f8450e2" +dependencies = [ + "arrayvec", + "euclid", + "polycool", + "smallvec", +] + [[package]] name = "lazy_static" version = "1.5.0" @@ -3603,6 +3851,12 @@ dependencies = [ "libc", ] +[[package]] +name = "nohash-hasher" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451" + [[package]] name = "nom" version = "8.0.0" @@ -3618,6 +3872,15 @@ version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "610a5acd306ec67f907abe5567859a3c693fb9886eb1f012ab8f2a47bef3db51" +[[package]] +name = "normpath" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9985ef7269fa99f3b12437bb698381da2428743ab90f20393f399fa14cab21a" +dependencies = [ + "windows-sys 0.61.2", +] + [[package]] name = "ntapi" version = "0.4.3" @@ -4092,6 +4355,17 @@ version = "1.21.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" +[[package]] +name = "opener" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2b03ff07a220d0d0ec9a1f0f238951b7967a5a2e96aefcd21a117b1083415e9" +dependencies = [ + "bstr", + "normpath", + "windows-sys 0.61.2", +] + [[package]] name = "orbclient" version = "0.3.55" @@ -4192,6 +4466,19 @@ dependencies = [ "icu_properties", ] +[[package]] +name = "peniko" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "839c8299360d2e998bdb106dc0a6cd71dcc5f4df51df1b620361bf50e283cca6" +dependencies = [ + "bytemuck", + "color", + "kurbo", + "linebender_resource_handle", + "smallvec", +] + [[package]] name = "percent-encoding" version = "2.3.2" @@ -4287,6 +4574,15 @@ dependencies = [ "windows-sys 0.61.2", ] +[[package]] +name = "polycool" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50596ddc09eb5ad5f75cacd40209568e66df71baf86e1499a0e99c4cff12a5a6" +dependencies = [ + "arrayvec", +] + [[package]] name = "portable-atomic" version = "1.15.0" @@ -4358,6 +4654,12 @@ version = "0.1.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d55d956fa96f5ec02be2e13af0e20391a5aa83d6a074e3ad368959d0fab299ea" +[[package]] +name = "quick-error" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3" + [[package]] name = "quick-xml" version = "0.41.0" @@ -4444,6 +4746,16 @@ dependencies = [ "objc2-quartz-core 0.3.2", ] +[[package]] +name = "read-fonts" +version = "0.37.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b634fabf032fab15307ffd272149b622260f55974d9fad689292a5d33df02e5" +dependencies = [ + "bytemuck", + "font-types 0.11.3", +] + [[package]] name = "read-fonts" version = "0.39.2" @@ -4647,10 +4959,16 @@ dependencies = [ "ab_glyph", "log", "memmap2", - "smithay-client-toolkit", + "smithay-client-toolkit 0.19.2", "tiny-skia", ] +[[package]] +name = "self_cell" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ab42ca02749e120097e328d91d415325bdf43b1c72c4c8badf37375fe40a813" + [[package]] name = "semver" version = "1.0.28" @@ -4743,6 +5061,16 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e" +[[package]] +name = "skrifa" +version = "0.40.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fbdfe3d2475fbd7ddd1f3e5cf8288a30eb3e5f95832829570cd88115a7434ac" +dependencies = [ + "bytemuck", + "read-fonts 0.37.0", +] + [[package]] name = "skrifa" version = "0.42.1" @@ -4791,8 +5119,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3457dea1f0eb631b4034d61d4d8c32074caa6cd1ab2d59f2327bd8461e2c0016" dependencies = [ "bitflags 2.13.1", - "calloop", - "calloop-wayland-source", + "calloop 0.13.0", + "calloop-wayland-source 0.3.0", "cursor-icon", "libc", "log", @@ -4809,6 +5137,44 @@ dependencies = [ "xkeysym", ] +[[package]] +name = "smithay-client-toolkit" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0512da38f5e2b31201a93524adb8d3136276fa4fe4aafab4e1f727a82b534cc0" +dependencies = [ + "bitflags 2.13.1", + "calloop 0.14.4", + "calloop-wayland-source 0.4.1", + "cursor-icon", + "libc", + "log", + "memmap2", + "rustix 1.1.4", + "thiserror 2.0.20", + "wayland-backend", + "wayland-client", + "wayland-csd-frame", + "wayland-cursor", + "wayland-protocols", + "wayland-protocols-experimental", + "wayland-protocols-misc", + "wayland-protocols-wlr", + "wayland-scanner", + "xkeysym", +] + +[[package]] +name = "smithay-clipboard" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71704c03f739f7745053bde45fa203a46c58d25bc5c4efba1d9a60e9dba81226" +dependencies = [ + "libc", + "smithay-client-toolkit 0.20.0", + "wayland-backend", +] + [[package]] name = "smol_str" version = "0.2.2" @@ -5006,6 +5372,20 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "tiff" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b63feaf3343d35b6ca4d50483f94843803b0f51634937cc2ec519fc32232bc52" +dependencies = [ + "fax", + "flate2", + "half", + "quick-error", + "weezl", + "zune-jpeg", +] + [[package]] name = "tiny-skia" version = "0.11.4" @@ -5093,6 +5473,7 @@ version = "0.1.44" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100" dependencies = [ + "log", "pin-project-lite", "tracing-attributes", "tracing-core", @@ -5188,6 +5569,7 @@ version = "0.1.0" dependencies = [ "app_dirs2", "bevy", + "bevy-inspector-egui", "derive_more", "jiff", "ron", @@ -5284,6 +5666,32 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" +[[package]] +name = "vello_common" +version = "0.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bd1a4c633ce09e7d713df1a6e036644a125e15e0c169cfb5180ddf5836ca04b" +dependencies = [ + "bytemuck", + "fearless_simd", + "hashbrown 0.16.1", + "log", + "peniko", + "skrifa 0.40.0", + "smallvec", +] + +[[package]] +name = "vello_cpu" +version = "0.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0162bfe48aabf6a9fdcd401b628c7d9f260c2cbabb343c70a65feba6f7849edc" +dependencies = [ + "bytemuck", + "hashbrown 0.16.1", + "vello_common", +] + [[package]] name = "version_check" version = "0.9.5" @@ -5424,6 +5832,32 @@ dependencies = [ "wayland-scanner", ] +[[package]] +name = "wayland-protocols-experimental" +version = "20250721.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40a1f863128dcaaec790d7b4b396cc9b9a7a079e878e18c47e6c2d2c5a8dcbb1" +dependencies = [ + "bitflags 2.13.1", + "wayland-backend", + "wayland-client", + "wayland-protocols", + "wayland-scanner", +] + +[[package]] +name = "wayland-protocols-misc" +version = "0.3.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e9567599ef23e09b8dad6e429e5738d4509dfc46b3b21f32841a304d16b29c8" +dependencies = [ + "bitflags 2.13.1", + "wayland-backend", + "wayland-client", + "wayland-protocols", + "wayland-scanner", +] + [[package]] name = "wayland-protocols-plasma" version = "0.3.12" @@ -5511,6 +5945,12 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "weezl" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a28ac98ddc8b9274cb41bb4d9d4d5c425b6020c50c46f25559911905610b4a88" + [[package]] name = "wgpu" version = "29.0.4" @@ -6062,7 +6502,7 @@ dependencies = [ "bitflags 2.13.1", "block2 0.5.1", "bytemuck", - "calloop", + "calloop 0.13.0", "cfg_aliases", "concurrent-queue", "core-foundation", @@ -6084,7 +6524,7 @@ dependencies = [ "redox_syscall 0.4.1", "rustix 0.38.44", "sctk-adwaita", - "smithay-client-toolkit", + "smithay-client-toolkit 0.19.2", "smol_str", "tracing", "unicode-segmentation", @@ -6332,3 +6772,18 @@ name = "zmij" version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b" + +[[package]] +name = "zune-core" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d56377fd46368984a170bc5aac5567e52ca5da874caa60bea39fcbca78fb658b" + +[[package]] +name = "zune-jpeg" +version = "0.5.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27bc9d5b815bc103f142aa054f561d9187d191692ec7c2d1e2b4737f8dbd7296" +dependencies = [ + "zune-core", +] diff --git a/Cargo.toml b/Cargo.toml index c500d5f..92cf712 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,6 +6,7 @@ edition = "2024" [dependencies] app_dirs2 = "2.5.5" bevy = { version = "0.19", features = ["system_clipboard", "debug"] } +bevy-inspector-egui = "0.37" derive_more = { version = "2.1.1", features = ["deref", "deref_mut"] } jiff = { version = "0.2.35", features = ["serde"] } ron = "0.12.2" diff --git a/src/debug.rs b/src/debug.rs new file mode 100644 index 0000000..802f240 --- /dev/null +++ b/src/debug.rs @@ -0,0 +1,29 @@ +use bevy::prelude::*; +use bevy_inspector_egui::{bevy_egui::EguiPlugin, quick::ResourceInspectorPlugin}; + +use crate::lobby::LobbyUiState; + +/// Whether the debug inspector is currently shown. +#[derive(Resource, Debug, Default)] +pub struct InspectorEnabled(bool); + +pub struct DebugInspectorPlugin; + +impl Plugin for DebugInspectorPlugin { + fn build(&self, app: &mut App) { + app.init_resource::() + .add_plugins(EguiPlugin::default()) + .add_plugins( + ResourceInspectorPlugin::::new() + .run_if(|enabled: Res| enabled.0), + ) + .add_systems(Update, toggle_inspector); + } +} + +fn toggle_inspector(keys: Res>, mut enabled: ResMut) { + if keys.just_pressed(KeyCode::F1) { + enabled.0 = !enabled.0; + info!("lobby ui inspector toggled {}", if enabled.0 { "on" } else { "off" }); + } +} diff --git a/src/lobby.rs b/src/lobby.rs index 411d27a..e445244 100644 --- a/src/lobby.rs +++ b/src/lobby.rs @@ -3,19 +3,53 @@ use bevy::{ input_focus::tab_navigation::TabIndex, prelude::*, text::{EditableText, EditableTextFilter, TextCursorStyle}, - ui_widgets::{RadioButton, RadioGroup}, + ui::{Checked, Pressed}, + ui_widgets::{RadioButton, RadioGroup, ValueChange, radio_self_update}, }; use crate::AppState; pub struct LobbyPlugin; +#[derive(Resource, Debug, Clone, Copy, PartialEq, Eq, Reflect)] +#[reflect(Resource)] +pub struct LobbyUiState { + pub visibility: LobbyVisibility, +} + +impl Default for LobbyUiState { + fn default() -> Self { + Self { + visibility: LobbyVisibility::Public, + } + } +} + +#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Reflect)] +pub enum LobbyVisibility { + #[default] + Public, + FriendsOnly, + InviteOnly, +} + +#[derive(Component, Debug, Clone, Copy, Default, PartialEq, Eq)] +struct LobbyVisibilityOption(LobbyVisibility); + impl Plugin for LobbyPlugin { fn build(&self, app: &mut App) { + app.init_resource::(); + app.register_type::(); app.add_systems( OnEnter(AppState::Lobby), (setup_lobby, build_lobby_ui).chain(), + ) + .add_systems( + Update, + (sync_visibility_options, style_visibility_options).chain(), ); + app.add_observer(radio_self_update); + app.add_observer(on_visibility_changed); } } @@ -67,12 +101,15 @@ fn build_lobby_ui(mut commands: Commands, root_ui: Single impl Scene { +fn visibility_option( + label: &'static str, + visibility: LobbyVisibility, + border_radius: BorderRadius, +) -> impl Scene { bsn! { RadioButton + LobbyVisibilityOption(visibility) Node { display: Display::Flex, - flex_direction: FlexDirection::Row, - justify_content: JustifyContent::FlexStart, + flex_grow: 1., + justify_content: JustifyContent::Center, align_items: AlignItems::Center, - align_content: AlignContent::Center, - column_gap: px(8), + border: UiRect::all(px(3)), + border_radius, } - Children [ - #RadioOuter - Node { - display: Display::Flex, - width: px(32), - height: px(32), - border: UiRect::all(px(4)), - border_radius: BorderRadius::MAX, - } - BorderColor::all(Color::BLACK) - Children [ - #RadioInner - Node { - display: Display::Flex, - width: px(16), - height: px(16), - position_type: PositionType::Absolute, - left: px(4), - top: px(4), - border_radius: BorderRadius::MAX, - } - BackgroundColor(Color::srgb(0.35, 0.75, 0.35)) - ], - Text::new("Radio Button") + BorderColor::all(Color::srgb(0.12, 0.16, 0.22)) + BackgroundColor(Color::srgb(0.18, 0.22, 0.29)) + Children [( + Text(label) TextFont { - font_size: FontSize::Px(33.0), + font_size: px(38.0), } - ] + TextColor(Color::srgb(0.92, 0.94, 0.98)) + )] + } +} + +fn sync_visibility_options( + lobby_ui: Res, + mut commands: Commands, + options: Query< + (Entity, &LobbyVisibilityOption), + (With, Added), + >, +) { + for (entity, option) in &options { + if option.0 == lobby_ui.visibility { + commands.entity(entity).insert(Checked); + } else { + commands.entity(entity).remove::(); + } + } +} + +fn on_visibility_changed( + value_change: On>, + options: Query<&LobbyVisibilityOption>, + mut lobby_ui: ResMut, +) { + if let Ok(option) = options.get(value_change.value) { + lobby_ui.visibility = option.0; + } +} + +fn style_visibility_options( + mut options: Query< + ( + &Interaction, + Has, + Has, + &mut BackgroundColor, + ), + ( + With, + // Or<(Changed, Changed, Changed)>, + ), + >, +) { + for (interaction, checked, pressed, mut background) in &mut options { + background.0 = match (checked, pressed, *interaction) { + (true, true, _) => Color::srgb(0.08, 0.48, 0.58), + (true, _, Interaction::Hovered) => Color::srgb(0.10, 0.58, 0.68), + (true, _, _) => Color::srgb(0.08, 0.42, 0.52), + (false, _, Interaction::Hovered) => Color::srgb(0.26, 0.33, 0.42), + (false, _, _) => Color::srgb(0.18, 0.22, 0.29), + }; } } diff --git a/src/main.rs b/src/main.rs index a37ce8e..f053901 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,9 +2,10 @@ use bevy::{camera::ScalingMode, color::palettes::css::GREEN, prelude::*}; use main_menu::MainMenuPlugin; use networking::NetworkingPlugin; -use crate::{lobby::LobbyPlugin, save::SavePlugin}; +use crate::{debug::DebugInspectorPlugin, lobby::LobbyPlugin, save::SavePlugin}; mod lobby; +mod debug; mod main_menu; mod networking; mod save; @@ -35,6 +36,7 @@ fn main() { NetworkingPlugin, SavePlugin, LobbyPlugin, + DebugInspectorPlugin, )) .add_systems(Startup, setup) .add_systems(Update, debug_border)