|
|
|
@ -1,4 +1,3 @@
|
|
|
|
use bevy::input_focus::tab_navigation::TabGroup;
|
|
|
|
|
|
|
|
use engine::theme::ThemedText;
|
|
|
|
use engine::theme::ThemedText;
|
|
|
|
|
|
|
|
|
|
|
|
use super::*;
|
|
|
|
use super::*;
|
|
|
|
@ -17,6 +16,7 @@ pub struct DebugPlugin;
|
|
|
|
impl Plugin for DebugPlugin {
|
|
|
|
impl Plugin for DebugPlugin {
|
|
|
|
fn build(&self, app: &mut App) {
|
|
|
|
fn build(&self, app: &mut App) {
|
|
|
|
app.init_state::<DebugState>()
|
|
|
|
app.init_state::<DebugState>()
|
|
|
|
|
|
|
|
.init_state::<DebugOutlines>()
|
|
|
|
.add_systems(Startup, setup_ui)
|
|
|
|
.add_systems(Startup, setup_ui)
|
|
|
|
.add_systems(
|
|
|
|
.add_systems(
|
|
|
|
Update,
|
|
|
|
Update,
|
|
|
|
@ -25,6 +25,7 @@ impl Plugin for DebugPlugin {
|
|
|
|
log_transition::<DebugState>.run_if(state_changed::<DebugState>),
|
|
|
|
log_transition::<DebugState>.run_if(state_changed::<DebugState>),
|
|
|
|
log_transition::<Loading>.run_if(state_changed::<Loading>),
|
|
|
|
log_transition::<Loading>.run_if(state_changed::<Loading>),
|
|
|
|
log_transition::<GameState>.run_if(state_changed::<GameState>),
|
|
|
|
log_transition::<GameState>.run_if(state_changed::<GameState>),
|
|
|
|
|
|
|
|
log_transition::<DebugOutlines>.run_if(state_changed::<DebugOutlines>)
|
|
|
|
),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.add_systems(
|
|
|
|
.add_systems(
|
|
|
|
@ -34,10 +35,21 @@ impl Plugin for DebugPlugin {
|
|
|
|
.add_systems(
|
|
|
|
.add_systems(
|
|
|
|
Update,
|
|
|
|
Update,
|
|
|
|
(
|
|
|
|
(
|
|
|
|
toggle_state_visibility::<DebugState>,
|
|
|
|
(
|
|
|
|
sync_state_to_ui::<DebugState>,
|
|
|
|
toggle_state_visibility::<DebugState>,
|
|
|
|
|
|
|
|
sync_state_to_ui::<DebugState>,
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
.run_if(state_changed::<DebugState>),
|
|
|
|
|
|
|
|
(
|
|
|
|
|
|
|
|
toggle_state_visibility::<DebugOutlines>,
|
|
|
|
|
|
|
|
sync_state_to_ui::<DebugOutlines>,
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
.run_if(state_changed::<DebugOutlines>),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.run_if(state_changed::<DebugState>),
|
|
|
|
)
|
|
|
|
|
|
|
|
.add_systems(
|
|
|
|
|
|
|
|
Update,
|
|
|
|
|
|
|
|
draw_outline_gizmos.run_if(in_state(DebugOutlines(true)))
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -79,6 +91,30 @@ fn setup_ui(mut commands: Commands) {
|
|
|
|
],
|
|
|
|
],
|
|
|
|
));
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
commands.spawn((
|
|
|
|
|
|
|
|
Node {
|
|
|
|
|
|
|
|
justify_self: JustifySelf::Center,
|
|
|
|
|
|
|
|
align_self: AlignSelf::Center,
|
|
|
|
|
|
|
|
..default()
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
DebugState(true),
|
|
|
|
|
|
|
|
children![
|
|
|
|
|
|
|
|
(
|
|
|
|
|
|
|
|
Node {
|
|
|
|
|
|
|
|
..default()
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
children![
|
|
|
|
|
|
|
|
Text::new("Outlines"),
|
|
|
|
|
|
|
|
(
|
|
|
|
|
|
|
|
toggle_switch((),),
|
|
|
|
|
|
|
|
observe(checkbox_self_update),
|
|
|
|
|
|
|
|
observe(toggle_outline_state),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
|
|
commands.spawn((
|
|
|
|
commands.spawn((
|
|
|
|
Node {
|
|
|
|
Node {
|
|
|
|
bottom: px(0.0),
|
|
|
|
bottom: px(0.0),
|
|
|
|
@ -93,6 +129,10 @@ fn setup_ui(mut commands: Commands) {
|
|
|
|
Text::new("DebugState State"),
|
|
|
|
Text::new("DebugState State"),
|
|
|
|
SyncState::<DebugState>::default()
|
|
|
|
SyncState::<DebugState>::default()
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
(
|
|
|
|
|
|
|
|
Text::new("DebugOutlines State"),
|
|
|
|
|
|
|
|
SyncState::<DebugOutlines>::default()
|
|
|
|
|
|
|
|
),
|
|
|
|
(Text::new("Loading State"), SyncState::<Loading>::default()),
|
|
|
|
(Text::new("Loading State"), SyncState::<Loading>::default()),
|
|
|
|
(Text::new("Game State"), SyncState::<GameState>::default()),
|
|
|
|
(Text::new("Game State"), SyncState::<GameState>::default()),
|
|
|
|
],
|
|
|
|
],
|
|
|
|
@ -117,3 +157,25 @@ fn debug_toggle(event: On<ValueChange<bool>>, mut next_state: ResMut<NextState<D
|
|
|
|
info!("Debug State Toggled: {:?}", event.event().value);
|
|
|
|
info!("Debug State Toggled: {:?}", event.event().value);
|
|
|
|
next_state.set(event.event().value.into());
|
|
|
|
next_state.set(event.event().value.into());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(States, Default, Clone, Eq, Debug, PartialEq, Hash, Component)]
|
|
|
|
|
|
|
|
struct DebugOutlines(bool);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
impl fmt::Display for DebugOutlines {
|
|
|
|
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
|
|
|
|
write!(f, "Debug Outlines {}", self.0)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn toggle_outline_state(
|
|
|
|
|
|
|
|
event: On<ValueChange<bool>>,
|
|
|
|
|
|
|
|
mut next: ResMut<NextState<DebugOutlines>>,
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
next.set(DebugOutlines(event.event().value));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn draw_debug_outlines(
|
|
|
|
|
|
|
|
gizmos: Gizmos
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
todo!("Draw outlines here")
|
|
|
|
|
|
|
|
}
|
|
|
|
|