From f3128b9c3875761ce83f3779ad49f6fbc88200f0 Mon Sep 17 00:00:00 2001 From: Elijah Voigt Date: Wed, 10 Dec 2025 22:52:59 -0800 Subject: [PATCH] Toggle debug state with f12 --- engine/src/lib.rs | 1 + tetris/src/debug.rs | 15 +++++++++++++-- tetris/src/main.rs | 5 +++-- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/engine/src/lib.rs b/engine/src/lib.rs index 9c472e2..2dab364 100644 --- a/engine/src/lib.rs +++ b/engine/src/lib.rs @@ -39,6 +39,7 @@ pub use bevy::{ render::render_resource::{Extent3d, TextureDimension, TextureFormat, TextureUsages}, sprite_render::*, time::common_conditions::*, + feathers::*, ui::*, ui_widgets::{Button, *}, window::{WindowResized, WindowResolution}, diff --git a/tetris/src/debug.rs b/tetris/src/debug.rs index 3d6fc4f..ae8e180 100644 --- a/tetris/src/debug.rs +++ b/tetris/src/debug.rs @@ -6,14 +6,16 @@ use super::*; pub struct DebugPlugin; // Debugging wish-list: -// - Toggle debug on/off with f12 key // - Bounding boxes around entities +// - Toggleable in UI // - Cursor at the center of the world -// - Show current state(s) +// - Toggleable in UI +// - Show current state(s) in UI impl Plugin for DebugPlugin { fn build(&self, app: &mut App) { app .init_state::() + .add_systems(Startup, setup_ui) .add_systems(Update, // Logging state transitions ( @@ -33,6 +35,15 @@ pub enum Debugger { On, } +/// Setup the debugger UI +fn setup_ui( + mut commands: Commands, +) { + commands.spawn( + (toggle_switch((),), observe(checkbox_self_update)), + ); +} + /// Logs all state transitions for state T fn log_transition( curr: Res>, diff --git a/tetris/src/main.rs b/tetris/src/main.rs index b0d35b2..93ccd38 100644 --- a/tetris/src/main.rs +++ b/tetris/src/main.rs @@ -12,9 +12,10 @@ use fighter::*; fn main() { App::new() - .add_plugins((DefaultPlugins, BlocksPlugin, FighterPlugin, DebugPlugin)) + .add_plugins(DefaultPlugins) + .add_plugins(FeathersPlugins) + .add_plugins((BlocksPlugin, FighterPlugin, DebugPlugin)) .init_state::() - .init_state::() .init_state::() .init_resource::() .init_resource::()