Fix support power name not really being optional

This commit is contained in:
Gustas
2024-04-03 13:16:55 +03:00
committed by abcdefg30
parent 7859b913bc
commit cf21c8e906
3 changed files with 9 additions and 8 deletions

View File

@@ -157,6 +157,8 @@ namespace OpenRA.Mods.Common.Traits
oneShotFired; oneShotFired;
public SupportPowerInfo Info { get { return Instances.Select(i => i.Info).FirstOrDefault(); } } public SupportPowerInfo Info { get { return Instances.Select(i => i.Info).FirstOrDefault(); } }
public readonly string Name;
public readonly string Description;
public bool Ready => Active && RemainingTicks == 0; public bool Ready => Active && RemainingTicks == 0;
bool instancesEnabled; bool instancesEnabled;
@@ -175,6 +177,8 @@ namespace OpenRA.Mods.Common.Traits
Key = key; Key = key;
TotalTicks = info.ChargeInterval; TotalTicks = info.ChargeInterval;
remainingSubTicks = info.StartFullyCharged ? 0 : TotalTicks * 100; remainingSubTicks = info.StartFullyCharged ? 0 : TotalTicks * 100;
Name = info.Name == null ? string.Empty : TranslationProvider.GetString(info.Name);
Description = info.Description == null ? string.Empty : TranslationProvider.GetString(info.Description);
Manager = manager; Manager = manager;
} }

View File

@@ -53,13 +53,11 @@ namespace OpenRA.Mods.Common.Widgets.Logic
if (sp == lastPower && hotkey == lastHotkey && lastRemainingSeconds == remainingSeconds) if (sp == lastPower && hotkey == lastHotkey && lastRemainingSeconds == remainingSeconds)
return; return;
var nameText = TranslationProvider.GetString(sp.Info.Name); nameLabel.GetText = () => sp.Name;
nameLabel.GetText = () => nameText; var nameSize = nameFont.Measure(sp.Name);
var nameSize = nameFont.Measure(nameText);
var descText = TranslationProvider.GetString(sp.Info.Description); descLabel.GetText = () => sp.Description;
descLabel.GetText = () => descText; var descSize = descFont.Measure(sp.Description);
var descSize = descFont.Measure(descText);
var timeText = sp.TooltipTimeTextOverride(); var timeText = sp.TooltipTimeTextOverride();
if (timeText == null) if (timeText == null)

View File

@@ -59,8 +59,7 @@ namespace OpenRA.Mods.Common.Widgets
{ {
var self = p.Instances[0].Self; var self = p.Instances[0].Self;
var time = WidgetUtils.FormatTime(p.RemainingTicks, false, self.World.Timestep); var time = WidgetUtils.FormatTime(p.RemainingTicks, false, self.World.Timestep);
var supportPowerName = TranslationProvider.GetString(p.Info.Name); var text = TranslationProvider.GetString(Format, Translation.Arguments("player", self.Owner.PlayerName, "support-power", p.Name, "time", time));
var text = TranslationProvider.GetString(Format, Translation.Arguments("player", self.Owner.PlayerName, "support-power", supportPowerName, "time", time));
var playerColor = self.Owner.Color; var playerColor = self.Owner.Color;