Reattach the close button to the rotator machine

That was much easier than I expected it to be. I'm still going to alter
how the `machine_ui_base` function works so that I don't have to
remember to attach a button all the time.
This commit is contained in:
2025-08-26 09:18:36 -05:00
parent f89a0d2e66
commit c833572f69
2 changed files with 17 additions and 18 deletions

View File

@@ -2,7 +2,7 @@ use bevy::{color::palettes::css::*, prelude::*, ui::Val::*};
use crate::{ use crate::{
game::machines::*, game::machines::*,
widgets::{machine_ui_base, spawn_big_red_button}, widgets::{CloseButton, machine_ui_base, spawn_big_red_button},
}; };
impl CuttingMachine { impl CuttingMachine {
@@ -52,6 +52,7 @@ impl RotatingMachine {
commands commands
.spawn((machine_ui_base("Rotating Machine"),)) .spawn((machine_ui_base("Rotating Machine"),))
.with_children(|commands| { .with_children(|commands| {
commands.spawn(CloseButton::bundle(commands.target_entity()));
commands.spawn(( commands.spawn((
Node { Node {
padding: UiRect::all(Px(10.0)), padding: UiRect::all(Px(10.0)),

View File

@@ -38,23 +38,21 @@ fn machine_ui_base(header: impl Into<String>) -> impl Bundle {
}, },
BackgroundColor(SLATE_100.into()), BackgroundColor(SLATE_100.into()),
BorderRadius::all(Percent(2.0)), BorderRadius::all(Percent(2.0)),
children![ children![(
( // TODO: A real node with stuff in it (buttons, maybe?)
// TODO: A real node with stuff in it (buttons, maybe?) Node {
Node { justify_content: JustifyContent::Center,
justify_content: JustifyContent::Center, grid_column: GridPlacement::span(2),
grid_column: GridPlacement::span(2), ..default()
..default() },
}, BackgroundColor(RED.into()),
BackgroundColor(RED.into()), Pickable::default(),
Pickable::default(), children![(
children![( Text::new(header),
Text::new(header), TextColor(BLACK.into()),
TextColor(BLACK.into()), // TODO: Text shadow, maybe. I couldn't make it look good.
// TODO: Text shadow, maybe. I couldn't make it look good. )],
)], ),],
),
],
) )
} }