Fill out UI parts for the remaining machines

This commit is contained in:
2025-08-27 15:27:09 -05:00
parent c7fd053fd1
commit e169750923
2 changed files with 99 additions and 29 deletions

View File

@@ -2,7 +2,7 @@ use bevy::{color::palettes::css::*, prelude::*, window::WindowResolution};
use bevy_inspector_egui::{bevy_egui::EguiPlugin, quick::WorldInspectorPlugin};
use crate::{
game::machines::{CuttingMachine, RotatingMachine},
game::machines::{CuttingMachine, FlippingMachine, RotatingMachine, TransposingMachine},
resources::UiTheme,
widgets::SpawnUi,
};
@@ -61,17 +61,21 @@ fn dummy_machines(mut commands: Commands) {
.observe(spawn_machine_ui::<RotatingMachine>);
// TODO: The other observers, once they have a spawner struct & impl.
commands.spawn((
commands
.spawn((
Sprite::from_color(PURPLE, Vec2::splat(40.)),
Transform::from_translation(Vec3::new(-40.0, -40.0, 0.0)),
Pickable::default(),
));
))
.observe(spawn_machine_ui::<FlippingMachine>);
commands.spawn((
commands
.spawn((
Sprite::from_color(DARK_ORANGE, Vec2::splat(40.)),
Transform::from_translation(Vec3::new(40.0, -40.0, 0.0)),
Pickable::default(),
));
))
.observe(spawn_machine_ui::<TransposingMachine>);
}
fn spawn_machine_ui<M: SpawnUi>(

View File

@@ -11,15 +11,7 @@ impl SpawnUi for CuttingMachine {
let base_entity = machine_ui_base(&mut commands, "Cutting Machine", &theme);
commands.entity(base_entity).with_children(|commands| {
// Left panel. For fuel or machine stats or whatever.
commands.spawn((
Node {
padding: UiRect::all(Px(10.0)),
..default()
},
BackgroundColor(GREEN.into()),
Pickable::default(),
children![(Text::new("Uses: <n>"), TextColor(BLACK.into()),)],
));
commands.spawn(fuel_gauge_placeholder());
// Center panel (placeholder for the Card view)
commands.spawn((
@@ -55,15 +47,7 @@ impl SpawnUi for RotatingMachine {
fn spawn_ui(mut commands: Commands, theme: Res<UiTheme>) {
let base_entity = machine_ui_base(&mut commands, "Rotating Machine", &theme);
commands.entity(base_entity).with_children(|commands| {
commands.spawn((
Node {
padding: UiRect::all(Px(10.0)),
..Default::default()
},
BackgroundColor(GREEN.into()),
Pickable::default(),
children![(Text::new("Uses: <n>"), TextColor(BLACK.into()))],
));
commands.spawn(fuel_gauge_placeholder());
// Center panel (placeholder for input-output rotation)
commands.spawn((
@@ -93,3 +77,85 @@ impl SpawnUi for RotatingMachine {
});
}
}
impl SpawnUi for FlippingMachine {
fn spawn_ui(mut commands: Commands, theme: Res<UiTheme>) {
let base_entity = machine_ui_base(&mut commands, "Flipping Machine", &theme);
commands.entity(base_entity).with_children(|commands| {
commands.spawn(fuel_gauge_placeholder());
// Center panel (placeholder)
commands.spawn((
Node::default(),
BackgroundColor(BLUE.into()),
Pickable::default(),
children![
Text::new("Card Flipping placeholder"),
TextColor(MAGENTA.into()),
],
));
// Right panel go button
commands
.spawn((
Node {
align_items: AlignItems::End,
..Default::default()
},
BackgroundColor(DARK_GRAY.into()),
Pickable::default(),
))
.with_children(|cmds| {
let _button_cmds = cmds.spawn(BigRedButton::bundle("FLIP"));
// TODO: Attach on-press observer to the button.
});
});
}
}
impl SpawnUi for TransposingMachine {
fn spawn_ui(mut commands: Commands, theme: Res<UiTheme>) {
let base_entity = machine_ui_base(&mut commands, "Transposing Machine", &theme);
commands.entity(base_entity).with_children(|commands| {
commands.spawn(fuel_gauge_placeholder());
// Center panel (placeholder)
commands.spawn((
Node::default(),
BackgroundColor(BLUE.into()),
Pickable::default(),
children![
Text::new("Card Transposition placeholder"),
TextColor(MAGENTA.into()),
],
));
// Right panel go button
commands
.spawn((
Node {
align_items: AlignItems::End,
..Default::default()
},
BackgroundColor(DARK_GRAY.into()),
Pickable::default(),
))
.with_children(|cmds| {
let _button_cmds = cmds.spawn(BigRedButton::bundle("SWAP"));
// TODO: Attach on-press observer to the button.
});
});
}
}
fn fuel_gauge_placeholder() -> impl Bundle {
(
Node {
padding: UiRect::all(Px(10.0)),
..default()
},
BackgroundColor(GREEN.into()),
Pickable::default(),
children![(Text::new("Uses: <n>"), TextColor(BLACK.into()),)],
)
}