Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions locale/en.po
Original file line number Diff line number Diff line change
Expand Up @@ -4293,6 +4293,30 @@ msgstr "(cost of organelles, membranes and other items in the editor)"
msgid "MUTATION_POINTS"
msgstr "Mutation Points"

msgid "MUTATION_POINTS_BASE"
msgstr "/ {0}"

msgid "MUTATION_POINTS_BASE_WITH_PERCENTAGE"
msgstr "/ {0}%"

msgid "MUTATION_POINTS_CURRENT"
msgstr "{0}"

msgid "MUTATION_POINTS_CURRENT_WITH_PERCENTAGE"
msgstr "{0}%"

msgid "MUTATION_POINTS_CURRENT_WITH_RESULT"
msgstr "{0}"

msgid "MUTATION_POINTS_CURRENT_WITH_RESULT_WITH_PERCENTAGE"
msgstr "{0}%"

msgid "MUTATION_POINTS_RESULTING"
msgstr "{0}"

msgid "MUTATION_POINTS_RESULTING_WITH_PERCENTAGE"
msgstr "{0}%"
Comment on lines +4303 to +4318
Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
Member

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.


msgid "MUTE"
msgstr "Mute"

Expand Down
24 changes: 24 additions & 0 deletions locale/tr.po

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

65 changes: 49 additions & 16 deletions src/microbe_stage/editor/MutationPointsBar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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: UpdateMutationPointsBar called in CellEditorComponent.OnTranslationsChanged.

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)
Expand All @@ -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;
Expand All @@ -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);
}
}