make trees debug menu look good enough

main
Elijah Voigt 3 months ago
parent 145008a52d
commit 2a1d7fe8c2

@ -61,8 +61,6 @@ fn main() {
.add_observer(add_dialog_option)
.add_observer(add_tree_monologue)
.add_observer(remove_tree_monologue)
.add_observer(show_monologue_list)
.add_observer(hide_monologue_list)
.run();
}
@ -125,7 +123,9 @@ fn init_debug_ui(mut commands: Commands) {
commands
.spawn((
Name::new("Tree Planter"),
Text::new("+Tree"),
children![
Text::new("+Tree"),
],
Node {
top: Val::Px(0.0),
left: Val::Px(0.0),
@ -133,7 +133,6 @@ fn init_debug_ui(mut commands: Commands) {
min_height: Val::Px(25.0),
..default()
},
BackgroundColor(RED.into()),
DebuggingState::On,
MonologuesContainer,
Button,
@ -143,7 +142,9 @@ fn init_debug_ui(mut commands: Commands) {
let monologue_button = commands
.spawn((
Name::new("Monologue Assignment Menu"),
Text::new("+Monologue"),
children![
Text::new("+Monologue"),
],
Node {
top: Val::Px(25.0),
left: Val::Px(0.0),
@ -151,7 +152,6 @@ fn init_debug_ui(mut commands: Commands) {
min_height: Val::Px(25.0),
..default()
},
BackgroundColor(RED.into()),
DebuggingState::On,
MonologuesContainer,
))
@ -168,7 +168,6 @@ fn init_debug_ui(mut commands: Commands) {
width: Val::Percent(80.0),
..default()
},
BackgroundColor(BLACK.into()),
))
.with_children(|parent| {
parent
@ -182,7 +181,6 @@ fn init_debug_ui(mut commands: Commands) {
..default()
},
ScrollPosition::default(),
BackgroundColor(ORANGE.into()),
MonologuesList,
))
.observe(scroll);
@ -199,7 +197,6 @@ fn init_debug_ui(mut commands: Commands) {
width: Val::Percent(60.0),
..default()
},
BackgroundColor(ORANGE_RED.into()),
));
});
}
@ -595,46 +592,27 @@ fn spawn_debug_buttons(
parent
.spawn((
Button,
Text::new(
handle
.path()
.unwrap()
.to_string()
.trim_prefix("trees/")
.trim_suffix(".mono"),
),
TextLayout::new(JustifyText::Left, LineBreak::WordBoundary),
children![
Text::new(
handle
.path()
.unwrap()
.to_string()
.trim_prefix("trees/")
.trim_suffix(".mono"),
),
TextLayout::new(JustifyText::Left, LineBreak::WordBoundary),
],
TreeMonologue(handle.clone()),
MonologuesList,
BackgroundColor(PINK.into()),
))
.observe(assign_monologue_event)
.observe(preview_monologue)
.observe(toggle_debug_button_color_over)
.observe(toggle_debug_button_color_out);
.observe(preview_monologue);
});
}
});
}
fn toggle_debug_button_color_over(
trigger: Trigger<Pointer<Over>>,
mut buttons: Query<&mut BackgroundColor, With<Button>>,
) {
if let Ok(mut bg) = buttons.get_mut(trigger.target()) {
bg.0 = RED.into();
}
}
fn toggle_debug_button_color_out(
trigger: Trigger<Pointer<Out>>,
mut buttons: Query<&mut BackgroundColor, With<Button>>,
) {
if let Ok(mut bg) = buttons.get_mut(trigger.target()) {
bg.0 = PINK.into();
}
}
fn preview_monologue(
trigger: Trigger<Pointer<Over>>,
container: Single<Entity, (With<MonologuePreview>, Without<Button>, Without<Text>)>,
@ -671,32 +649,6 @@ fn preview_monologue(
}
}
fn show_monologue_list(
trigger: Trigger<Pointer<Over>>,
container: Query<Entity, With<MonologuesContainer>>,
children: Query<&Children>,
mut visibility: Query<&mut Visibility>,
) {
if let Ok(root) = container.get(trigger.target()) {
children.iter_descendants(root).for_each(|e| {
*visibility.get_mut(e).unwrap() = Visibility::Inherited;
});
}
}
fn hide_monologue_list(
trigger: Trigger<Pointer<Out>>,
container: Query<Entity, With<MonologuesContainer>>,
children: Query<&Children>,
mut visibility: Query<&mut Visibility>,
) {
if let Ok(root) = container.get(trigger.target()) {
children.iter_descendants(root).for_each(|e| {
*visibility.get_mut(e).unwrap() = Visibility::Hidden;
});
}
}
#[derive(Event)]
struct PlantTree;

Loading…
Cancel
Save