Fill out UI parts for the remaining machines
This commit is contained in:
26
src/main.rs
26
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 bevy_inspector_egui::{bevy_egui::EguiPlugin, quick::WorldInspectorPlugin};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
game::machines::{CuttingMachine, RotatingMachine},
|
game::machines::{CuttingMachine, FlippingMachine, RotatingMachine, TransposingMachine},
|
||||||
resources::UiTheme,
|
resources::UiTheme,
|
||||||
widgets::SpawnUi,
|
widgets::SpawnUi,
|
||||||
};
|
};
|
||||||
@@ -61,17 +61,21 @@ fn dummy_machines(mut commands: Commands) {
|
|||||||
.observe(spawn_machine_ui::<RotatingMachine>);
|
.observe(spawn_machine_ui::<RotatingMachine>);
|
||||||
|
|
||||||
// TODO: The other observers, once they have a spawner struct & impl.
|
// TODO: The other observers, once they have a spawner struct & impl.
|
||||||
commands.spawn((
|
commands
|
||||||
Sprite::from_color(PURPLE, Vec2::splat(40.)),
|
.spawn((
|
||||||
Transform::from_translation(Vec3::new(-40.0, -40.0, 0.0)),
|
Sprite::from_color(PURPLE, Vec2::splat(40.)),
|
||||||
Pickable::default(),
|
Transform::from_translation(Vec3::new(-40.0, -40.0, 0.0)),
|
||||||
));
|
Pickable::default(),
|
||||||
|
))
|
||||||
|
.observe(spawn_machine_ui::<FlippingMachine>);
|
||||||
|
|
||||||
commands.spawn((
|
commands
|
||||||
Sprite::from_color(DARK_ORANGE, Vec2::splat(40.)),
|
.spawn((
|
||||||
Transform::from_translation(Vec3::new(40.0, -40.0, 0.0)),
|
Sprite::from_color(DARK_ORANGE, Vec2::splat(40.)),
|
||||||
Pickable::default(),
|
Transform::from_translation(Vec3::new(40.0, -40.0, 0.0)),
|
||||||
));
|
Pickable::default(),
|
||||||
|
))
|
||||||
|
.observe(spawn_machine_ui::<TransposingMachine>);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn spawn_machine_ui<M: SpawnUi>(
|
fn spawn_machine_ui<M: SpawnUi>(
|
||||||
|
|||||||
@@ -11,15 +11,7 @@ impl SpawnUi for CuttingMachine {
|
|||||||
let base_entity = machine_ui_base(&mut commands, "Cutting Machine", &theme);
|
let base_entity = machine_ui_base(&mut commands, "Cutting Machine", &theme);
|
||||||
commands.entity(base_entity).with_children(|commands| {
|
commands.entity(base_entity).with_children(|commands| {
|
||||||
// Left panel. For fuel or machine stats or whatever.
|
// Left panel. For fuel or machine stats or whatever.
|
||||||
commands.spawn((
|
commands.spawn(fuel_gauge_placeholder());
|
||||||
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)
|
// Center panel (placeholder for the Card view)
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
@@ -55,15 +47,7 @@ impl SpawnUi for RotatingMachine {
|
|||||||
fn spawn_ui(mut commands: Commands, theme: Res<UiTheme>) {
|
fn spawn_ui(mut commands: Commands, theme: Res<UiTheme>) {
|
||||||
let base_entity = machine_ui_base(&mut commands, "Rotating Machine", &theme);
|
let base_entity = machine_ui_base(&mut commands, "Rotating Machine", &theme);
|
||||||
commands.entity(base_entity).with_children(|commands| {
|
commands.entity(base_entity).with_children(|commands| {
|
||||||
commands.spawn((
|
commands.spawn(fuel_gauge_placeholder());
|
||||||
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)
|
// Center panel (placeholder for input-output rotation)
|
||||||
commands.spawn((
|
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()),)],
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user