From fbc9389f57cdcb91e50a6c524f80f567df1b7692 Mon Sep 17 00:00:00 2001 From: Elijah Voigt Date: Thu, 16 Jul 2026 16:15:44 -0700 Subject: [PATCH] Debug info: acive cell info --- life/src/actions.rs | 2 ++ life/src/main.rs | 50 ++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 47 insertions(+), 5 deletions(-) diff --git a/life/src/actions.rs b/life/src/actions.rs index 0e0f9fd..31e4a49 100644 --- a/life/src/actions.rs +++ b/life/src/actions.rs @@ -69,6 +69,7 @@ impl SimAction { mut lifecycle: MessageWriter, cells: Query>, mut commands: Commands, + mut playback: ResMut>, ) { // TODO: reconcile board instead of despawn/spawning the world cells.iter().for_each(|e| { @@ -77,6 +78,7 @@ impl SimAction { last_board_state.coordinates.iter().for_each(|c| { lifecycle.write(Lifecycle::Alive(c.clone())); }); + playback.set(SimulationPlayback::Pause); } // Wipe all cells from the board diff --git a/life/src/main.rs b/life/src/main.rs index b9ae0a1..20c9fcc 100644 --- a/life/src/main.rs +++ b/life/src/main.rs @@ -1,12 +1,13 @@ // TODO: -// * Debug Panel -// * Describe cell I am hovering over (Note, Octave, etc) // * Fix tiling repeating // * Negative coordinates should not mirror // * Fix randomly audio not working -// * On reset: pause +// * Make click and drag feel better // * Show shadow of piece (same tile, just with alpha transparency) -// * UI: Swap buttons mutually exclusive instead of disabling +// * UI widget explaining rules/hotkeys +// * UI minimize widgets +// * Start with an interesting pattern +// * Lock down system scheduling/run_if conditions #![allow(clippy::complexity)] // Only because of FromTemplat macros unfortunately... #![allow(dead_code)] @@ -83,6 +84,7 @@ fn main() { grid_gizmo, update_debug_info_cell_count, update_debug_info_coordinates, + update_debug_info_active, ), ) // Ui Controllers @@ -110,6 +112,7 @@ const SCALE: f32 = 100.0; enum DebugInfo { CellCount, Coordinates, + Active, #[default] Empty, } @@ -342,6 +345,27 @@ fn debug_ui() -> impl Scene { Children [ Text("##,##") ThemedText template_value(DebugInfo::Coordinates) ] + ], + subpane() + Node { + display: Display::Flex, + flex_direction: FlexDirection::Row, + } + Children [ + subpane_header() Children [ + Text("Active Cell") ThemedText + ] + subpane_body() + Node { + display: Display::Flex, + flex_direction: FlexDirection::Row, + align_items: AlignItems::Stretch, + justify_content: JustifyContent::Start, + } + text_setup() + Children [ + Text("Foo/Bar") ThemedText template_value(DebugInfo::Active) + ] ] ] ] @@ -584,7 +608,7 @@ impl Coordinates { } } -/// When the cursor moves, update the Coordiantes +/// When the cursor moves, update the Coordinates fn update_grid_position( mut coordinates: ResMut, q_window: Single<&Window>, @@ -1200,6 +1224,22 @@ fn update_debug_info_coordinates( }); } +fn update_debug_info_active( + next_coordinates: Res, + cells: Query<(&CellPitch, &Coordinates)>, + mut text: Query<(&DebugInfo, &mut Text)>, +) { + text.iter_mut() + .filter(|(di, _)| **di == DebugInfo::Active) + .for_each(|(_, mut t)| { + if let Some((cp, _c)) = cells.iter().find(|(_cp, c)| **c == next_coordinates.0) { + *t = Text::new(format!("Note: {:?} | Octave: {}", cp.note, cp.octave)); + } else { + *t = Text::new(String::from("N/A")); + } + }); +} + fn update_note_interactivity( checked: Query, With, With)>, mut commands: Commands,