Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unit reclaim statistics in non-default unit layouts #6162

Merged

Conversation

PaletzTheWise
Copy link
Contributor

Description of the proposed changes

There are three UI layouts one can cycle through using the alt-up and alt-down shortcuts.

  • unitview_mini - unit bars at the bottom and command bar on the left side. This is the default and works OK. OriginalMini
  • unitview_right - unit bars at the bottom and command bar on the right side. This one reports lazyvars errors and does not display reclaim statistics in the unit tooltip. Right.log OriginalRight
  • unitview_left - vertical unit bars on the left side. This one also reports lazyvars errors and displays a white rectangle instead of reclaim statistics in the unit tooltip. Left.log OriginalLeft

Root cause:

  • unitview_right is completely missing reclaim statistic UI positioning code.
  • unitview_left is missing the vast majority of reclaim statistic UI positioning code
  • Almost nobody uses the alternate layouts. Even I did so only because I hit the shortcut by accident and did not know how to go back.

Notable observations:

  • the unitview_x class selection is made when the game starts so in-game layout change (alt-up or alt-down) does not immediately apply the above characteristics. (This is also why the tooltip is not docking correctly until restart.)
  • The observer factory build queue tooltip probably works only in mini.

Changes:

  • Made cosmetic whitespace changes in unitview_mini for consistency.
  • Copied UI positioning code to unitview_left and unitview_right, made them look the same. The layout within the tooltip is the same for all layouts so this works.
    • In unitview_left there already was a line to set the group position, but the offset was different. It was the same as veterancy bar but the bar has text positioned above it so the position for the reclaim group from unitview_mini is, indeed, the correct one.
    • In unitview_left there was a line to set MassIcon color. This is not needed since we have an actual texture and, indeed, unitview_mini does not use it.
  • Removed duplicate unit tooltip Veterancy bar positioning code from unitview_left.lua, which was introduced in the same commit that introduced Reclaim statistics.

Testing done on the proposed changes

  • For each layout
    • Selected the layout
    • Restarted the game
    • Verified the unit tooltip renders correctly for an engineer and a combat unit.
    • Cycled through layouts and verified the unit tooltip still renders correctly albeit in the wrong place for non-startup layouts.
    • Checked the logs and found no lazyvar issues.

FixedLeft
FixedMini
FixedRight

Additional context

There probably should not be three copies of the same code but there are differences in the tooltip queue that need to be reconciled first.

Checklist

  • Changes are annotated, including comments where useful
  • Changes are documented in the changelog for the next game version

 * Root cause:
    * unitview_mini (unit bars at the bottom and command bar on the left side) is the default and works
    * unitview_right (unit bars at the bottom and command bar on the right side) is completely missing reclaim statistic UI positioning code.
    * unitview_left (vertical unit bars on the left side) is missing vast majority of reclaim statistic UI positioning code
    * the unitview_x class selection is made when the game starts so in-game layout change (alt-up or alt-down) does not immediately apply the above characteristics. (This is also why the tooltip is not docking correctly until restart.)
 * unitview_mini cosmetic whitespace changes.
 * copied UI positioning code to unitview_left and unitview_right, made them look the same. The layout within the tooltip is the same for all layouts so this works.
    * In unitview_left there already was a line to set the group position, but the offset was different. It was the same as veterancy bar but the bar has text positioned above it so the position for the reclaim group from unitview_mini is, indeed, the correct one.
    * In unitview_left there was a line to set MassIcon color. This is not needed since we have an actual texture and, indeed, unitview_mini does not use it.
 * Removed duplicate unit tooltip Veterancy bar positioning code from unitview_left.lua, which was introduced in the same commit that introduced Reclaim statistics.
@PaletzTheWise PaletzTheWise marked this pull request as ready for review May 9, 2024 20:56
@Garanas
Copy link
Member

Garanas commented May 11, 2024

@clyfordv given that you're working on similar files in #6148, would you be available to review this pull request?

Copy link
Contributor

@clyfordv clyfordv left a comment

Choose a reason for hiding this comment

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

Looks good to me. Test is good (rest of the surrounding non-standard layouts are still a mess of course).

P.S.--For future layout endeavors, check the Layouter. I'm just getting started with it myself, but aside from the performance improvements it makes applying multiple layout functions to the same element much cleaner. See an incomplete but functional example here: lua/ui/game/layouts/construction_mini.lua

@lL1l1 lL1l1 merged commit 28cae22 into FAForever:deploy/fafdevelop May 15, 2024
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.

None yet

4 participants