Skip to content

Commit

Permalink
Fix support power name not really being optional
Browse files Browse the repository at this point in the history
  • Loading branch information
PunkPun authored and abcdefg30 committed Apr 10, 2024
1 parent 7859b91 commit cf21c8e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
Expand Up @@ -157,6 +157,8 @@ public class SupportPowerInstance
oneShotFired;

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;

bool instancesEnabled;
Expand All @@ -175,6 +177,8 @@ public SupportPowerInstance(string key, SupportPowerInfo info, SupportPowerManag
Key = key;
TotalTicks = info.ChargeInterval;
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;
}
Expand Down
Expand Up @@ -53,13 +53,11 @@ public SupportPowerTooltipLogic(Widget widget, TooltipContainerWidget tooltipCon
if (sp == lastPower && hotkey == lastHotkey && lastRemainingSeconds == remainingSeconds)
return;
var nameText = TranslationProvider.GetString(sp.Info.Name);
nameLabel.GetText = () => nameText;
var nameSize = nameFont.Measure(nameText);
nameLabel.GetText = () => sp.Name;
var nameSize = nameFont.Measure(sp.Name);
var descText = TranslationProvider.GetString(sp.Info.Description);
descLabel.GetText = () => descText;
var descSize = descFont.Measure(descText);
descLabel.GetText = () => sp.Description;
var descSize = descFont.Measure(sp.Description);
var timeText = sp.TooltipTimeTextOverride();
if (timeText == null)
Expand Down
3 changes: 1 addition & 2 deletions OpenRA.Mods.Common/Widgets/SupportPowerTimerWidget.cs
Expand Up @@ -59,8 +59,7 @@ public override void Tick()
{
var self = p.Instances[0].Self;
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", supportPowerName, "time", time));
var text = TranslationProvider.GetString(Format, Translation.Arguments("player", self.Owner.PlayerName, "support-power", p.Name, "time", time));
var playerColor = self.Owner.Color;
Expand Down

0 comments on commit cf21c8e

Please sign in to comment.