use crate::lobby::LobbyUiState; use bevy::prelude::*; use bevy_inspector_egui::{ bevy_egui::EguiPlugin, quick::{ResourceInspectorPlugin, WorldInspectorPlugin}, }; // TODO: compile these in only if debug build /// 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(WorldInspectorPlugin::new()) .add_plugins( ResourceInspectorPlugin::::new() .run_if(|enabled: Res| enabled.0), ) .add_systems(Update, (toggle_inspector, toggle_ui_layout_debug)); } } fn toggle_inspector(keys: Res>, mut enabled: ResMut) { if !keys.just_pressed(KeyCode::F1) { return; } enabled.0 = !enabled.0; info!( "lobby ui inspector toggled {}", if enabled.0 { "on" } else { "off" } ); } fn toggle_ui_layout_debug( keys: Res>, mut debug_options: ResMut, ) { if !keys.just_pressed(KeyCode::F2) { return; } if debug_options.enabled { debug_options.enabled = false; } else { debug_options.enabled = true; debug_options.outline_border_box = true; debug_options.outline_padding_box = true; debug_options.outline_content_box = true; } info!( "ui layout debug toggled {}", if debug_options.enabled { "on" } else { "off" } ); }