diff --git a/src/main.rs b/src/main.rs index 6400d5d..ee33d3b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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::); // TODO: The other observers, once they have a spawner struct & impl. - commands.spawn(( - Sprite::from_color(PURPLE, Vec2::splat(40.)), - Transform::from_translation(Vec3::new(-40.0, -40.0, 0.0)), - Pickable::default(), - )); + 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::); - commands.spawn(( - Sprite::from_color(DARK_ORANGE, Vec2::splat(40.)), - Transform::from_translation(Vec3::new(40.0, -40.0, 0.0)), - Pickable::default(), - )); + 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::); } fn spawn_machine_ui( diff --git a/src/widgets/machines.rs b/src/widgets/machines.rs index c96ec32..5b86618 100644 --- a/src/widgets/machines.rs +++ b/src/widgets/machines.rs @@ -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: "), 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) { 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: "), 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) { + 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) { + 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: "), TextColor(BLACK.into()),)], + ) +}