diff --git a/src/main.rs b/src/main.rs index b33dc9d..6c72801 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,8 @@ use bevy::{prelude::*, window::WindowResolution}; use bevy_inspector_egui::{bevy_egui::EguiPlugin, quick::WorldInspectorPlugin}; +use crate::game::machines::RotatingMachine; + mod assets; mod card; mod game; @@ -25,7 +27,7 @@ fn main() { ( setup, assets::load_assets, - widgets::spawn_rotator_machine_ui, + RotatingMachine::spawn_rotator_machine_ui, ), ) .run(); diff --git a/src/widgets/machines.rs b/src/widgets/machines.rs new file mode 100644 index 0000000..425aa29 --- /dev/null +++ b/src/widgets/machines.rs @@ -0,0 +1,89 @@ +use bevy::{color::palettes::css::*, prelude::*, ui::Val::*}; + +use crate::{ + game::machines::*, + widgets::{machine_ui_base, spawn_machine_button}, +}; + +impl CuttingMachine { + pub fn spawn_cutter_machine_ui(mut commands: Commands) { + commands + .spawn((machine_ui_base("Cutting Machine"),)) + .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()),)], + )); + + // Center panel (placeholder for the Card view) + commands.spawn(( + Node::default(), + BackgroundColor(BLUE.into()), + Pickable::default(), + children![( + Text::new("Card cut view placeholder"), + TextColor(MAGENTA.into()), + TextShadow::default(), + ),], + )); + // Right panel for the "CUT" button + commands + .spawn(( + Node { + align_items: AlignItems::End, + ..Default::default() + }, + BackgroundColor(DARK_GRAY.into()), + Pickable::default(), + )) + .with_children(|cmds| spawn_machine_button(cmds, "CUT")); + }); + } +} + +impl RotatingMachine { + pub fn spawn_rotator_machine_ui(mut commands: Commands) { + commands + .spawn((machine_ui_base("Rotating Machine"),)) + .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()))], + )); + + // Center panel (placeholder for input-output rotation) + commands.spawn(( + Node::default(), + BackgroundColor(BLUE.into()), + Pickable::default(), + children![ + Text::new("Card rotation side-by-side placeholder"), + TextColor(MAGENTA.into()), + ], + )); + + // Right panel for the rotation controls + commands + .spawn(( + Node { + align_items: AlignItems::End, + ..Default::default() + }, + BackgroundColor(DARK_GRAY.into()), + Pickable::default(), + )) + .with_children(|cmds| spawn_machine_button(cmds, "TURN")); + }); + } +} diff --git a/src/widgets/mod.rs b/src/widgets/mod.rs index 80d5cc3..d946810 100644 --- a/src/widgets/mod.rs +++ b/src/widgets/mod.rs @@ -1,5 +1,7 @@ //! Catch-all location for UI bits +pub mod machines; + use bevy::{ color::palettes::{css::*, tailwind::*}, prelude::*, @@ -8,85 +10,6 @@ use bevy::{ use crate::resources::UiTheme; -pub fn spawn_cutter_machine_ui(mut commands: Commands) { - commands - .spawn((machine_ui_base("Cutting Machine"),)) - .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()),)], - )); - - // Center panel (placeholder for the Card view) - commands.spawn(( - Node::default(), - BackgroundColor(BLUE.into()), - Pickable::default(), - children![( - Text::new("Card cut view placeholder"), - TextColor(MAGENTA.into()), - TextShadow::default(), - ),], - )); - // Right panel for the "CUT" button - commands - .spawn(( - Node { - align_items: AlignItems::End, - ..Default::default() - }, - BackgroundColor(DARK_GRAY.into()), - Pickable::default(), - )) - .with_children(|cmds| spawn_machine_button(cmds, "CUT")); - }); -} - -pub fn spawn_rotator_machine_ui(mut commands: Commands) { - commands - .spawn((machine_ui_base("Rotating Machine"),)) - .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()))], - )); - - // Center panel (placeholder for input-output rotation) - commands.spawn(( - Node::default(), - BackgroundColor(BLUE.into()), - Pickable::default(), - children![ - Text::new("Card rotation side-by-side placeholder"), - TextColor(MAGENTA.into()), - ] - )); - - // Right panel for the rotation controls - commands - .spawn(( - Node { - align_items: AlignItems::End, - ..Default::default() - }, - BackgroundColor(DARK_GRAY.into()), - Pickable::default(), - )) - .with_children(|cmds| spawn_machine_button(cmds, "TURN")); - }); -} - /// The base panel for the machines that manipulate the room cards. fn machine_ui_base(header: impl Into) -> impl Bundle { (