Debug info: acive cell info

main
Elijah Voigt 6 days ago
parent 35d6206d5e
commit fbc9389f57

@ -69,6 +69,7 @@ impl SimAction {
mut lifecycle: MessageWriter<Lifecycle>, mut lifecycle: MessageWriter<Lifecycle>,
cells: Query<Entity, With<Cell>>, cells: Query<Entity, With<Cell>>,
mut commands: Commands, mut commands: Commands,
mut playback: ResMut<NextState<SimulationPlayback>>,
) { ) {
// TODO: reconcile board instead of despawn/spawning the world // TODO: reconcile board instead of despawn/spawning the world
cells.iter().for_each(|e| { cells.iter().for_each(|e| {
@ -77,6 +78,7 @@ impl SimAction {
last_board_state.coordinates.iter().for_each(|c| { last_board_state.coordinates.iter().for_each(|c| {
lifecycle.write(Lifecycle::Alive(c.clone())); lifecycle.write(Lifecycle::Alive(c.clone()));
}); });
playback.set(SimulationPlayback::Pause);
} }
// Wipe all cells from the board // Wipe all cells from the board

@ -1,12 +1,13 @@
// TODO: // TODO:
// * Debug Panel
// * Describe cell I am hovering over (Note, Octave, etc)
// * Fix tiling repeating // * Fix tiling repeating
// * Negative coordinates should not mirror // * Negative coordinates should not mirror
// * Fix randomly audio not working // * Fix randomly audio not working
// * On reset: pause // * Make click and drag feel better
// * Show shadow of piece (same tile, just with alpha transparency) // * 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)] #![allow(clippy::complexity)]
// Only because of FromTemplat macros unfortunately... // Only because of FromTemplat macros unfortunately...
#![allow(dead_code)] #![allow(dead_code)]
@ -83,6 +84,7 @@ fn main() {
grid_gizmo, grid_gizmo,
update_debug_info_cell_count, update_debug_info_cell_count,
update_debug_info_coordinates, update_debug_info_coordinates,
update_debug_info_active,
), ),
) )
// Ui Controllers // Ui Controllers
@ -110,6 +112,7 @@ const SCALE: f32 = 100.0;
enum DebugInfo { enum DebugInfo {
CellCount, CellCount,
Coordinates, Coordinates,
Active,
#[default] #[default]
Empty, Empty,
} }
@ -342,6 +345,27 @@ fn debug_ui() -> impl Scene {
Children [ Children [
Text("##,##") ThemedText template_value(DebugInfo::Coordinates) 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( fn update_grid_position(
mut coordinates: ResMut<NextCoordinates>, mut coordinates: ResMut<NextCoordinates>,
q_window: Single<&Window>, q_window: Single<&Window>,
@ -1200,6 +1224,22 @@ fn update_debug_info_coordinates(
}); });
} }
fn update_debug_info_active(
next_coordinates: Res<NextCoordinates>,
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( fn update_note_interactivity(
checked: Query<Entity, (With<Note>, With<Checkbox>, With<Checked>)>, checked: Query<Entity, (With<Note>, With<Checkbox>, With<Checked>)>,
mut commands: Commands, mut commands: Commands,

Loading…
Cancel
Save