Skip to content

Conversation

@ApocDev
Copy link

@ApocDev ApocDev commented Aug 4, 2025

This pull request introduces a feature that displays a detailed cost breakdown when holding the Ctrl key over an item.

image

@ApocDev
Copy link
Author

ApocDev commented Aug 4, 2025

Something to note;

The current UI rendering pipeline is a "draw-once" pipeline, that can't react to keyboard modifier changes currently. That means you have to hold control then hover an item to see the tooltip change, as we only build the tooltip content when we hover.

I can add a way to react to control state changes and redraw portions of the UI, but it's not relevant to this PR.

@ApocDev ApocDev marked this pull request as ready for review August 4, 2025 14:21
@ApocDev ApocDev requested a review from shpaass as a code owner August 4, 2025 14:21
@shpaass
Copy link
Owner

shpaass commented Aug 4, 2025

I can add a way to react to control state changes

Depends on how much it's going to complicate the current code. I have many questions to Yafc UI code, but I need to read quite a bit of theory before I can formulate my opinion about it.
Overall, we don't want to put too many crutches now because we'll have to untangle it down the line.

Copy link
Collaborator

@DaleStan DaleStan left a comment

Choose a reason for hiding this comment

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

I don't understand the numbers displayed in the sample tooltip. The logistics cost is negative, and I expected the per unit cost to be either ¥305 (per-50-units or per-recipe-cycle) or ¥6.1 (per single unit).

Are the displayed values the expected ones?

@Dorus
Copy link
Collaborator

Dorus commented Aug 4, 2025

Unsure if this code is broke, or the YaFC cost calculation, but for empty barrels it uses a completely unrealistic recipe:

afbeelding

It should be using the steel to empty barrel recipe, not some expensive fluid unbarrelling recipe. To produce those barrels you need barrels as input anyway. It ends up with a hugely negative logistic value to compensate.

@ApocDev
Copy link
Author

ApocDev commented Aug 4, 2025

Unsure if this code is broke, or the YaFC cost calculation, but for empty barrels it uses a completely unrealistic recipe:
afbeelding

It should be using the steel to empty barrel recipe, not some expensive fluid unbarrelling recipe. To produce those barrels you need barrels as input anyway. It ends up with a hugely negative logistic value to compensate.

Thanks! I fixed this. I noticed it as well and forgot to move it over from my "all the changes" branch I have locally.

@Dorus
Copy link
Collaborator

Dorus commented Aug 4, 2025

Nice, it's picking much better source recipes now.
I did notice it fails to pick a recipe if you mouse over the recipe instead of the ingredient.

afbeelding

(Also ctrl hover doesn't work when YaFC has no focus, but that might be a UI bug unrelated to this)

@DaleStan
Copy link
Collaborator

DaleStan commented Aug 5, 2025

The cost breakdowns don't consider additional recipe outputs:
image

The difference between ¥7.97 and ¥6.88 is (almost) the cost of 100 units of muddy sludge.
I think I'd add this to the breakdown:

  Other products: ¥1.08
    Muddy sludge: ¥1.08

The cost contribution of other products is typically negative, but is positive in this case. (These numbers are with PyHM. Without it, Muddy sludge adds ¥0.05 to the cost instead.)

Without PyHM, I don't know what's going on here; it might be another case of using the wrong recipe like what Dorus found. The breakdown is internally consistent, but the final price is off by a lot:
image

(Also ctrl hover doesn't work when YaFC has no focus, but that might be a UI bug unrelated to this)

At least in Windows, that's long-standing; ctrl-hovering when not focused doesn't display the internal object names either. Windows prefers to tell only the active window about keyboard activity.

@ApocDev
Copy link
Author

ApocDev commented Aug 6, 2025

At least in Windows, that's long-standing; ctrl-hovering when not focused doesn't display the internal object names either. Windows prefers to tell only the active window about keyboard activity.

Not entirely true, you just need to use different Win32 APIs to handle inputs. The SDL input events are only fired while the window is focused (for the most part). You can simply use GetAsyncKeyState to get the current state of any key (including modifiers), even when not focused.

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.

4 participants