Move the machine UI spawners to a new submodule
This commit is contained in:
@@ -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();
|
||||
|
||||
89
src/widgets/machines.rs
Normal file
89
src/widgets/machines.rs
Normal file
@@ -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: <n>"), 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: <n>"), 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"));
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -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: <n>"), 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: <n>"), 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<String>) -> impl Bundle {
|
||||
(
|
||||
|
||||
Reference in New Issue
Block a user