Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix support power name not really being optional #21387

Merged
merged 1 commit into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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