Skip to content

Comments

Move "Damaged" overlay to missile tube "Load" button#2465

Merged
daid merged 2 commits intodaid:masterfrom
hawson:2459-tube-dmg-label
Jun 27, 2025
Merged

Move "Damaged" overlay to missile tube "Load" button#2465
daid merged 2 commits intodaid:masterfrom
hawson:2459-tube-dmg-label

Conversation

@hawson
Copy link
Contributor

@hawson hawson commented Jun 26, 2025

Addresses #2459.

Also disables the Load (and "Unload") and Fire buttons when the missile system is 100% damaged, or at 0 power.

…/Unload/Fire when 100% damaged or at 0 power
rows[n].fire_button->enable()->show();
if ((health <= 0) || (power_level <=0)) {
rows[n].fire_button->disable();
rows[n].load_button->disable();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the lacking of show might cause a problem in some edge cases, like opening the weapon screen when the system is broken.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It isn't clear to me when show() should be used or not-used, so I tried to copy existing code. There didn't seem to be a clear precedent for "always call show()" when changing the state of button, but that's easy enough to add.

For test cases, I think I hit all combinations of health==0 (or not) and power==0 (or not) for tubes in all of the states (Empty, Loaded, Loading, Unloading, Firing). The buttons now become non-functional and dimmed when either power or heath hit 0. There is some interplay between the "No Power" and "Damaged" overlays, but I don't think that is new behavior.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Show just calls setVisible(true) https://github.com/daid/EmptyEpsilon/blob/master/src/gui/gui2_element.cpp#L148
And that just sets a member, so it is really cheap to call. Same for enable/disable. And if they are based on another value, it can be easier to just call setVisible / setEnable instead.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hope that makes things a bit clearer?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found the definitions already--quite simple indeed :-) The uncertainly is less about what they do, but more about why it would be needed at one time or another.

For example, in the Empty state case, we have this ~line 99 (after patching)
rows[n].fire_button->disable()->show();

But in the Loading state (~line 115, it's merely
rows[n].load_button->disable();

Is there some difference in handling the fire button vs the load button?

Regardless, adding -show() is easy enough.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly, the code is a bit messy. And there might be edge cases where this currently would go wrong still :)

@daid daid merged commit e25d10f into daid:master Jun 27, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants