Slight debug menu styling

main
Elijah Voigt 2 months ago
parent b01a7f73e5
commit fc0f665afc

@ -52,7 +52,7 @@ impl Plugin for BlocksPlugin {
}
}
const SCALE: f32 = 20.0;
pub(crate) const SCALE: f32 = 20.0;
const X_MAX: usize = 10;
const Y_MAX: usize = 20;

@ -78,6 +78,8 @@ fn setup_ui(mut commands: Commands) {
flex_direction: FlexDirection::Row,
align_items: AlignItems::Center,
justify_content: JustifyContent::Start,
justify_self: JustifySelf::Center,
align_self: AlignSelf::Start,
column_gap: px(8),
..default()
},
@ -93,8 +95,8 @@ fn setup_ui(mut commands: Commands) {
commands.spawn((
Node {
justify_self: JustifySelf::Center,
align_self: AlignSelf::Center,
justify_self: JustifySelf::Start,
align_self: AlignSelf::Start,
..default()
},
DebugState(true),
@ -104,11 +106,11 @@ fn setup_ui(mut commands: Commands) {
..default()
},
children![
Text::new("Outlines"),
(
toggle_switch((),),
observe(checkbox_self_update),
DebugState(true),
checkbox((), Spawn((Text::new("outlines"), ThemedText))),
observe(toggle_outline_state),
observe(check_box),
),
]
),
@ -176,7 +178,7 @@ fn toggle_outline_state(
fn draw_outline_gizmos(
mut gizmos: Gizmos,
query: Query<(Entity, &GlobalTransform)>,
query: Query<(Entity, &GlobalTransform), Without<Camera>>,
meshed: Query<&Mesh2d>,
meshes: Res<Assets<Mesh>>,
) {
@ -184,9 +186,7 @@ fn draw_outline_gizmos(
let entity_center = gt.translation().truncate();
let entity_size = gt.scale().truncate();
if let Some(Mesh2d(h)) = meshed.get(e) {
if let Ok(Mesh2d(h)) = meshed.get(e) {
let mesh = meshes.get(h).unwrap();
let aabb = mesh.compute_aabb().unwrap();
@ -198,8 +198,17 @@ fn draw_outline_gizmos(
gizmos.rect_2d(center, size, MAGENTA);
} else {
let size = Vec2::new(SCALE / 2.0, SCALE / 2.0);
let size = SCALE * 0.6;
gizmos.cross_2d(entity_center, size, MAGENTA);
}
});
}
fn check_box(change: On<ValueChange<bool>>, mut commands: Commands) {
let mut checkbox = commands.entity(change.source);
if change.value {
checkbox.insert(Checked);
} else {
checkbox.remove::<Checked>();
}
}

Loading…
Cancel
Save