67 Commits

Author SHA1 Message Date
ea9055e46c (autoformat) 2025-08-30 09:24:38 -05:00
be9cb3fe69 Fix: pass the machine ID through, not PLACEHOLDER
Oops. Yay for rushed work.
2025-08-30 09:23:59 -05:00
6fb3539329 Use hook on FuelGauge to show text on first spawn
There is an on-add hook that can be used to maintain invariants. I'll
use it to ensure the label text always gets the current fuel value upon
spawning the widget, regardless of whether or not the caller remembers
to set it up themselves.
2025-08-30 09:21:57 -05:00
fb8a27325e Add machine components to the other dummies 2025-08-29 10:08:13 -05:00
4a80b4f4ad Make Fuel a required component on machines
It will be pulled in automatically by Bevy, now. I've also set a default
fuel level of 5 units.
2025-08-29 09:55:16 -05:00
f470687494 Fix Fuel's field visibility, add it to the cutter
*Now* the fuel change events will work (and compile).
2025-08-28 15:35:46 -05:00
ed2e1e75ef Impl the FuelGauge text update logic
This does a linear search through all existing FuelGauges, but we're not
expecting that to be a problem. There should only be zero or one of them
on screen at any moment.

It also doesn't work because the rest of the game state isn't correct...
2025-08-28 15:33:21 -05:00
21c00d4a02 Pass target ID through the cutter's button handler
Use the machine entity ID in the button handler prototype. Now to see
about getting the FuelGauge to show the value after a button press.
2025-08-28 12:27:53 -05:00
5f1f283500 Change trait SpawnUi to require a target entity
The UIs aren't *any* UIs. They are specifically *machine* UIs. They need
to be able to fetch data from components on those machine entities,
which means they need some way to find the machine. Passing an entity ID
is the easiest way, IMO.
2025-08-28 12:27:45 -05:00
8f6dfc3e49 Proof-of-concept for fuel change event handling
Added a `FuelChanged` event which is to be used to trigger Observers
watching for a machine's fuel level change.

I've written a slapdash observer to emit these events when the cutting
machine's big red button is pressed. That observer *must* be replaced
because of how it feeds the machine ID into the UI (it only works when
there is exactly 1 CuttingMachine, which won't be the case).

The dummy machines are missing their machine components. I've added the
`CuttingMachine` component to the cutting machine just to test the event
passing.
2025-08-28 12:01:30 -05:00
e169750923 Fill out UI parts for the remaining machines 2025-08-27 15:27:09 -05:00
c7fd053fd1 Add other machine placeholder sprites 2025-08-27 13:48:55 -05:00
0c254b2ed0 Expand the dummy_machines spawner
Spawn a machine entity for each kind of machine. This is where the trait
impl becomes important -- now the compiler will make copies of that
function for each concrete machine struct so I don't have to.
2025-08-27 13:37:36 -05:00
3b0dad7063 Impl SpawnUi for the machine structs
Just add the `SpawnUi for` text to the impl blocks on the machine
widgets.
2025-08-27 13:35:31 -05:00
04fb8519f6 Trait SpawnUi for things that can spawn a UI
I don't want to copy-paste a bunch of code, so I'm going to get the
compiler to do it for me.
2025-08-27 13:34:31 -05:00
4d8c8b5302 Demo the UI with a dummy machine
This finally shows the basic operating principle of the machine UIs.
There will be some object out in the world that, when clicked, will open
a new UI screen to operate the machine.

Next up is to attach various bits of info, like a `Fuel` component on
the machine which the UI widget locates and displays as text. This gives
me the infrastructure necessary to begin that work.
2025-08-26 16:34:18 -05:00
112b22875a Fix doc on CloseButton::bundle() 2025-08-26 13:38:12 -05:00
9411e57759 Make CloseButton observer functions private
Now that there's a UI plugin, these systems don't need to be public. So
they won't be.
2025-08-26 13:35:40 -05:00
a489cdc5e8 Add some theme TODOs on the button widgets 2025-08-26 13:35:20 -05:00
5f617a67f6 Fix a couple of lints 2025-08-26 13:28:39 -05:00
9fb374059a Fix: Delete trailing semicolon in BRB::bundle()
Normally this would be a compilation error, but Bevy has an
`impl Bundle for ()` somewhere.

The intended bundle content gets discarded and a unit is implicitly
returned. That unit is implicitly converted into a `Bundle`, satisfying
the compiler.
2025-08-26 13:17:38 -05:00
cf9b415bb7 Update BigRedButton usage sites, add callback note 2025-08-26 13:17:03 -05:00
9bb15b7511 Convert BigRedButton ctor into just a Bundle
The BigRedButton isn't doing anything that requires the `Commands`, so
it'll be turned back into just a Bundle.
2025-08-26 13:01:49 -05:00
c567bc3706 Fix: Filter for BigRedButton in it's observers
There was no BRB component so the Observer systems would only filter for
`Button`, which matched against the close button by accident.
2025-08-26 12:54:46 -05:00
85499f4156 Move BigRedButton's input handling observers
But there's a bug... the `CloseButton`s now get colored red and pink.
2025-08-26 12:49:37 -05:00
1c0681e67e Create a BigRedButton struct, like CloseButton
The `BigRedButton` should be a real struct and component so that I can
query for it later.

I'm following the same API pattern as the `CloseButton` struct, in that
there is a spawner using the `Commands` (or `ChildSpawnerCommands`) and
the observer functions are static methods.
2025-08-26 12:46:48 -05:00
da7f9b3152 Create a custom plugin to centralize UI setup
The UI elements need some things set up for them to work properly.
Namely, the `UiTheme` resource and the Observers which handle button
presses.
2025-08-26 12:34:35 -05:00
fb1b954262 Replace base-ui bundle with a spawning function 2025-08-26 12:25:49 -05:00
f1ce30bde5 Rename machine UI spawners 2025-08-26 11:47:32 -05:00
c833572f69 Reattach the close button to the rotator machine
That was much easier than I expected it to be. I'm still going to alter
how the `machine_ui_base` function works so that I don't have to
remember to attach a button all the time.
2025-08-26 09:49:47 -05:00
f89a0d2e66 Record target entity in CloseButton
I was originally planning to search up the entity hierarchy to find the
top-most entity and despawn that. This will become a problem if I ever
want to have panels in panels.

Instead, just record the target entity and despawn it.

This means the current usage doesn't work, so I've removed it from the
base machine UI bundle.
2025-08-26 09:10:34 -05:00
bda0bb7de3 Add most of a "CloseButton" widget
I'm trying out a new scope strategy. The CloseButton exists as a real
struct with the `Component` trait. There's a bundle spawning utility
function and several observer systems. The observer systems have been
added directly to the app, which I *believe* means they won't be
duplicated the way the Big Red Button's observers will.
2025-08-26 09:02:08 -05:00
f2f1674451 Rename machine button spawner, "big red button"
It's the big red button. Don't press it.

Or do.
2025-08-25 19:45:35 -05:00
d235d6af5e (autoformat) 2025-08-25 19:18:06 -05:00
e2b2d5b5d9 Move the machine UI spawners to a new submodule 2025-08-25 19:17:54 -05:00
655bc5d3e2 Add new module for game bits 2025-08-25 18:55:38 -05:00
Patrick Gelvin
d98b28cb36 Cut triangle test 2025-08-25 18:25:59 -05:00
4bf3c44b5e Move widgets to a folder module 2025-08-25 18:17:39 -05:00
45e44ef8b1 Begin work on a rotator UI 2025-08-25 18:07:53 -05:00
e362df8682 Plug in the new UiTheme resource
Fixed struct field visibility, initialize the resource, and register it
with the EGUI Debug overlay. The button observers have also been updated
to use the resource.
2025-08-25 13:10:09 -05:00
4d8a178b74 Remove print-debug observer system
This was just so I could see two Observers executing from the same
trigger.
2025-08-25 13:04:40 -05:00
74302afab1 Replace "constants" module with "resources"
These aren't constants and they were never meant to be.

I've also started collecting the UI theme values. For now, just button
colors.
2025-08-25 12:54:29 -05:00
aa0c8b421b Handle machine button UI events with observers
Observers are "just" systems with a Trigger as their first parameter.
I've made 4 systems to handle the start and stop of the press and hover
actions.

Having the button *actually* do something (not just change colors) will
be achieved by attaching another button to the on-press trigger. I'm
expecting that the machine-ui-spawning system will do that, but in
principle it could be done by anything with access to the UI's button
entity ID.
2025-08-25 11:36:26 -05:00
875d157a21 Check-in the progress
Lots of nested components are making my head hurt. I'm not sure how to
solve the button call-back problem, yet.
2025-08-25 08:22:08 -05:00
a0cfc86f59 Center & Span the red rectangle to be a banner
Figured out how to place nodes in the grid. This will eventually become
the banner that says what the machine does.
2025-08-25 08:22:08 -05:00
79f66b2868 Colored squares on a grid layout
I'm still kinda figuring out how to do more complex UIs, so I'll be
making several commits that aren't very interesting to review... such as
this one.
2025-08-25 08:22:08 -05:00
Patrick Gelvin
7fb798edbe Initial asset library impl + tile images 2025-08-24 11:33:31 -07:00
Patrick Gelvin
b0ddc9236b Fix my busted implementations 2025-08-23 12:56:10 -07:00
031a487fb5 Add rotation unit tests 2025-08-23 13:33:44 -05:00
8d75a40475 Add unit tests for transposition 2025-08-23 13:27:39 -05:00