From cf21c8e9064b6225c7b5f6adeb99b522e42952fa Mon Sep 17 00:00:00 2001 From: Gustas Date: Wed, 3 Apr 2024 13:16:55 +0300 Subject: [PATCH] Fix support power name not really being optional --- .../Traits/SupportPowers/SupportPowerManager.cs | 4 ++++ .../Widgets/Logic/Ingame/SupportPowerTooltipLogic.cs | 10 ++++------ OpenRA.Mods.Common/Widgets/SupportPowerTimerWidget.cs | 3 +-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/SupportPowers/SupportPowerManager.cs b/OpenRA.Mods.Common/Traits/SupportPowers/SupportPowerManager.cs index 15fd3c0fc1..5fa46f4cd9 100644 --- a/OpenRA.Mods.Common/Traits/SupportPowers/SupportPowerManager.cs +++ b/OpenRA.Mods.Common/Traits/SupportPowers/SupportPowerManager.cs @@ -157,6 +157,8 @@ namespace OpenRA.Mods.Common.Traits 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; @@ -175,6 +177,8 @@ namespace OpenRA.Mods.Common.Traits 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; } diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/SupportPowerTooltipLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/SupportPowerTooltipLogic.cs index 94ba7758da..203834f700 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/SupportPowerTooltipLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/SupportPowerTooltipLogic.cs @@ -53,13 +53,11 @@ namespace OpenRA.Mods.Common.Widgets.Logic 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) diff --git a/OpenRA.Mods.Common/Widgets/SupportPowerTimerWidget.cs b/OpenRA.Mods.Common/Widgets/SupportPowerTimerWidget.cs index dfd867c756..c234ad1a29 100644 --- a/OpenRA.Mods.Common/Widgets/SupportPowerTimerWidget.cs +++ b/OpenRA.Mods.Common/Widgets/SupportPowerTimerWidget.cs @@ -59,8 +59,7 @@ namespace OpenRA.Mods.Common.Widgets { 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;