Toggle debug state with f12

main
Elijah Voigt 4 days ago
parent 198233236d
commit f3128b9c38

@ -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},

@ -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::<Debugger>()
.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<T: States + PartialEq + Clone>(
curr: Res<State<T>>,

@ -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::<Loading>()
.init_state::<Debugger>()
.init_state::<GameState>()
.init_resource::<AllAssets>()
.init_resource::<SetupChecklist>()

Loading…
Cancel
Save