Replace base-ui bundle with a spawning function
This commit is contained in:
@@ -2,89 +2,87 @@ use bevy::{color::palettes::css::*, prelude::*, ui::Val::*};
|
||||
|
||||
use crate::{
|
||||
game::machines::*,
|
||||
widgets::{CloseButton, machine_ui_base, spawn_big_red_button},
|
||||
resources::UiTheme,
|
||||
widgets::{machine_ui_base, spawn_big_red_button},
|
||||
};
|
||||
|
||||
impl CuttingMachine {
|
||||
pub fn spawn_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()),)],
|
||||
));
|
||||
pub fn spawn_ui(mut commands: Commands, theme: Res<UiTheme>) {
|
||||
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()),)],
|
||||
));
|
||||
|
||||
// Center panel (placeholder for the Card view)
|
||||
commands.spawn((
|
||||
Node::default(),
|
||||
BackgroundColor(BLUE.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(),
|
||||
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_big_red_button(cmds, "CUT"));
|
||||
});
|
||||
))
|
||||
.with_children(|cmds| spawn_big_red_button(cmds, "CUT"));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
impl RotatingMachine {
|
||||
pub fn spawn_ui(mut commands: Commands) {
|
||||
commands
|
||||
.spawn((machine_ui_base("Rotating Machine"),))
|
||||
.with_children(|commands| {
|
||||
commands.spawn(CloseButton::bundle(commands.target_entity()));
|
||||
commands.spawn((
|
||||
pub 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()))],
|
||||
));
|
||||
|
||||
// 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 {
|
||||
padding: UiRect::all(Px(10.0)),
|
||||
align_items: AlignItems::End,
|
||||
..Default::default()
|
||||
},
|
||||
BackgroundColor(GREEN.into()),
|
||||
BackgroundColor(DARK_GRAY.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_big_red_button(cmds, "TURN"));
|
||||
});
|
||||
))
|
||||
.with_children(|cmds| spawn_big_red_button(cmds, "TURN"));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user