Improve translation of power/silo usage tooltip

- Fix an instance where "silo-usage" translation was used without
arguments
- Use the same translation reference for the "Power usage"
- Make the ResourceBarWidget accept a cached transform with the tooltip
text
so it won't have to build the string itself
- Display an infinity symbol when the infinite power cheat is used
- Removes a magic number that is no longer used (>1000000 to check for
unlimited power)
This commit is contained in:
Ivaylo Draganov
2022-09-13 14:26:09 +03:00
committed by Matthias Mailänder
parent ba763ac0f0
commit e7dcbb3c2d
6 changed files with 53 additions and 16 deletions

View File

@@ -23,7 +23,7 @@ namespace OpenRA.Mods.Common.Widgets
public readonly string TooltipContainer;
readonly Lazy<TooltipContainerWidget> tooltipContainer;
public string TooltipFormat = "";
public CachedTransform<(float, float), string> TooltipTextCached;
public ResourceBarOrientation Orientation = ResourceBarOrientation.Vertical;
public string IndicatorCollection = "sidebar-bits";
public string IndicatorImage = "indicator";
@@ -56,7 +56,7 @@ namespace OpenRA.Mods.Common.Widgets
if (TooltipContainer == null)
return;
Func<string> getText = () => TooltipFormat.F(GetUsed(), GetProvided());
Func<string> getText = () => TooltipTextCached.Update((GetUsed(), GetProvided()));
tooltipContainer.Value.SetTooltip(TooltipTemplate, new WidgetArgs() { { "getText", getText }, { "world", world } });
}