-
-
Notifications
You must be signed in to change notification settings - Fork 603
Support localized mutation point percentages #6948
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,12 +32,33 @@ public partial class MutationPointsBar : HBoxContainer | |
| #pragma warning restore CA2213 | ||
|
|
||
| private string freebuildingText = string.Empty; | ||
| private bool hasMutationPointDisplayState; | ||
| private bool lastFreebuilding; | ||
| private bool lastShowResultingPoints; | ||
| private double lastCurrentMutationPoints; | ||
| private double lastPossibleMutationPoints; | ||
|
|
||
| public override void _Ready() | ||
| { | ||
| freebuildingText = Localization.Translate("FREEBUILDING"); | ||
| } | ||
|
|
||
| public override void _Notification(int what) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you check if this was necessary? There's already code in editors that should re-trigger the mutation points bar build. See: This is coded extremely sloppy. This is the kind of AI output I absolutely do not want to read. |
||
| { | ||
| base._Notification(what); | ||
|
|
||
| if (what != NotificationTranslationChanged) | ||
| return; | ||
|
|
||
| freebuildingText = Localization.Translate("FREEBUILDING"); | ||
|
|
||
| if (hasMutationPointDisplayState) | ||
| { | ||
| UpdateMutationPoints(lastFreebuilding, lastShowResultingPoints, lastCurrentMutationPoints, | ||
| lastPossibleMutationPoints); | ||
| } | ||
| } | ||
|
|
||
| public void UpdateBar(double currentMutationPoints, double possibleMutationPoints, bool tween = true) | ||
| { | ||
| if (tween) | ||
|
|
@@ -63,6 +84,12 @@ public void UpdateBar(double currentMutationPoints, double possibleMutationPoint | |
| public void UpdateMutationPoints(bool freebuilding, bool showResultingPoints, double currentMutationPoints, | ||
| double possibleMutationPoints) | ||
| { | ||
| hasMutationPointDisplayState = true; | ||
| lastFreebuilding = freebuilding; | ||
| lastShowResultingPoints = showResultingPoints; | ||
| lastCurrentMutationPoints = currentMutationPoints; | ||
| lastPossibleMutationPoints = possibleMutationPoints; | ||
|
|
||
| // Make sure tiny negative values aren't shown improperly | ||
| if (currentMutationPoints < 0 && currentMutationPoints > Constants.ALLOWED_MP_OVERSHOOT) | ||
| currentMutationPoints = 0; | ||
|
|
@@ -82,35 +109,41 @@ public void UpdateMutationPoints(bool freebuilding, bool showResultingPoints, do | |
| mutationPointsArrow.Show(); | ||
| resultingMutationPointsLabel.Show(); | ||
|
|
||
| currentMutationPointsLabel.Text = $"({currentMutationPoints:0.#}"; | ||
| resultingMutationPointsLabel.Text = $"{possibleMutationPoints:F0})"; | ||
| currentMutationPointsLabel.Text = FormatMutationPoints( | ||
| "MUTATION_POINTS_CURRENT_WITH_RESULT", | ||
| "MUTATION_POINTS_CURRENT_WITH_RESULT_WITH_PERCENTAGE", | ||
| $"({currentMutationPoints:0.#}"); | ||
| resultingMutationPointsLabel.Text = FormatMutationPoints( | ||
| "MUTATION_POINTS_RESULTING", | ||
| "MUTATION_POINTS_RESULTING_WITH_PERCENTAGE", | ||
| $"{possibleMutationPoints:F0})"); | ||
| } | ||
| else | ||
| { | ||
| mutationPointsArrow.Hide(); | ||
| resultingMutationPointsLabel.Hide(); | ||
|
|
||
| currentMutationPointsLabel.Text = $"{currentMutationPoints:0.#}"; | ||
| currentMutationPointsLabel.Text = FormatMutationPoints( | ||
| "MUTATION_POINTS_CURRENT", | ||
| "MUTATION_POINTS_CURRENT_WITH_PERCENTAGE", | ||
| $"{currentMutationPoints:0.#}"); | ||
| } | ||
|
|
||
| // TODO: implement full support for free percentage symbol placement within the mutation points bar | ||
| // for now we detect a format we cannot support and suppress the percentage symbol | ||
| // The reason is that the "100 / 100" is logically the unit that is a percentage so we would need an | ||
| // approach where the percentage symbol can escape the current label and go all the way to the start. | ||
| // See: https://github.com/Revolutionary-Games/Thrive/issues/6584 | ||
| if (ShowPercentageSymbol && Localization.Translate("PERCENTAGE_VALUE").EndsWith('%')) | ||
| { | ||
| baseMutationPointsLabel.Text = $"/ {Constants.BASE_MUTATION_POINTS:F0} %"; | ||
| } | ||
| else | ||
| { | ||
| baseMutationPointsLabel.Text = $"/ {Constants.BASE_MUTATION_POINTS:F0}"; | ||
| } | ||
| baseMutationPointsLabel.Text = FormatMutationPoints( | ||
| "MUTATION_POINTS_BASE", | ||
| "MUTATION_POINTS_BASE_WITH_PERCENTAGE", | ||
| $"{Constants.BASE_MUTATION_POINTS:F0}"); | ||
| } | ||
| } | ||
|
|
||
| public void PlayFlashAnimation() | ||
| { | ||
| animationPlayer.Play("FlashBar"); | ||
| } | ||
|
|
||
| private string FormatMutationPoints(string normalTranslation, string percentageTranslation, string value) | ||
| { | ||
| return Localization.Translate(ShowPercentageSymbol ? percentageTranslation : normalTranslation) | ||
| .FormatSafe(value); | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are literally all totally pointless because they are either the equivalent of a value to string conversion, or the percentage format.
Also you have directly edited this en.po file without using our localization script which is absolutely required when adding text.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By the way, here is a documentation on how to work with Thrive's translation system. The system automatically adds these entries based on what translation tokens are present in the code.