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

Numeric widget and localized number formatting. #2532

Merged
merged 8 commits into from
Mar 13, 2024
Merged

Numeric widget and localized number formatting. #2532

merged 8 commits into from
Mar 13, 2024

Conversation

AbdielKavash
Copy link
Member

@AbdielKavash AbdielKavash commented Mar 10, 2024

This is the penultimate (still need to do GT++, coming later today) and by far the largest set of changes to support localized number formatting in ModularUI.

 

Notes:

  • Most covers correctly understand the maximum possible amount of whatever they are measuring (items, fluids, EU, ...), so expressions like 50% or 100% - 1000 will correctly evaluate to the desired value.
  • The positions of some fields in the Item Detector and Advanced Item Detector cover UIs have been moved around to be consistent with each other and other wireless covers. (Wireless frequency on top, cover data below.)
  • The UI of Volumetric Flasks was completely redone, as it was godawful.
  • Known bug: Robot Arm cover occasionally resets the adjacent slot value to 0 (instead of any slot). This is not caused by this PR, it was also an issue beforehand (Robot Arm cover resets to external slot 0 if not interacted with after placing. GT-New-Horizons-Modpack#15687). If the player interacts with the UI widget at any point and sets the slot to anything (including "Any" again), this is fixed and never happens again with the same cover.
  • In a few places I have modified the amounts by which a value changes when the player ctrl- or shift-scrolls on a numeric field. For example, fluid-related fields will now change by 144 when ctrl-scrolled.
  • I have specifically only changed places where numbers appear in a ModularUI window. This means that item tooltips, WAILA, scanner text, etc. will show the same number formats as before (almost always either #.# or #,###.#, regardless of regional settings). This could be looked at further if the feature is popular, but not before feature freeze.
  • As a reminder, if a player finds the locally-formatted numbers annoying, the current locale can be forced in ModularUI config. This defaults to the system's locale as detected by JDK, but can be changed to any locale (for example, en-US).
  • Tracking down every single instance where a mod writes a number is nearly impossible. I use a few heuristics and code searches, but it is very likely that I miss some places. If an UI displays an unformatted or wrongly formatted number somewhere, please report it to be fixed.
Some examples (click to expand):

Energy detector cover using the percent function of NumericWidget:

Some other functions in action:

Machine process (fr-FR locale):

New volumetric flask UI:

Copy link
Member

@miozune miozune left a comment

Choose a reason for hiding this comment

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

How about adding defaultFormat or smth to NumberFormatMUI, so that we don't need to write protected static final NumberFormatMUI numberFormat = new NumberFormatMUI(); everywhere?

@AbdielKavash
Copy link
Member Author

How about adding defaultFormat or smth to NumberFormatMUI, so that we don't need to write protected static final NumberFormatMUI numberFormat = new NumberFormatMUI(); everywhere?

I thought about doing something like this, but the issue is somehow guaranteeing that the singleton format will never be modified. If someone decides to screw with, say, minimum number of decimal places of the global format, it will mess up every other UI opened after that one.

I thought about some solutions (strongly worded javadoc comment vs. an immutable subclass with a singleton), this is something that we can certainly return to either with MUI2 or after the stable release. I already have a couple other ideas to simplify this too.

Copy link
Member

@miozune miozune left a comment

Choose a reason for hiding this comment

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

I see, anyways great work!

@boubou19 boubou19 merged commit 26c8407 into GTNewHorizons:master Mar 13, 2024
2 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.

4 participants