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:
committed by
Matthias Mailänder
parent
ba763ac0f0
commit
e7dcbb3c2d
@@ -17,18 +17,32 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
public class IngamePowerBarLogic : ChromeLogic
|
||||
{
|
||||
[TranslationReference]
|
||||
[TranslationReference("usage", "capacity")]
|
||||
static readonly string PowerUsage = "power-usage";
|
||||
|
||||
[TranslationReference]
|
||||
static readonly string Infinite = "infinite-power";
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
public IngamePowerBarLogic(Widget widget, ModData modData, World world)
|
||||
{
|
||||
var developerMode = world.LocalPlayer.PlayerActor.Trait<DeveloperMode>();
|
||||
var powerManager = world.LocalPlayer.PlayerActor.Trait<PowerManager>();
|
||||
var powerBar = widget.Get<ResourceBarWidget>("POWERBAR");
|
||||
|
||||
powerBar.GetProvided = () => powerManager.PowerProvided;
|
||||
powerBar.GetProvided = () => developerMode.UnlimitedPower ? -1 : powerManager.PowerProvided;
|
||||
powerBar.GetUsed = () => powerManager.PowerDrained;
|
||||
powerBar.TooltipFormat = modData.Translation.GetString(PowerUsage) + ": {0}/{1}";
|
||||
powerBar.TooltipTextCached = new CachedTransform<(float Current, float Capacity), string>(usage =>
|
||||
{
|
||||
var capacity = developerMode.UnlimitedPower ?
|
||||
modData.Translation.GetString(Infinite) :
|
||||
powerManager.PowerProvided.ToString();
|
||||
|
||||
return modData.Translation.GetString(
|
||||
PowerUsage,
|
||||
Translation.Arguments("usage", usage.Current, "capacity", capacity));
|
||||
});
|
||||
|
||||
powerBar.GetBarColor = () =>
|
||||
{
|
||||
if (powerManager.PowerState == PowerState.Critical)
|
||||
|
||||
Reference in New Issue
Block a user