From aeb1e078238c96abd35364d21e92007c6bb18f81 Mon Sep 17 00:00:00 2001 From: Tyson Liddell Date: Sun, 2 Oct 2016 13:23:22 +1100 Subject: [PATCH] Moved production description from Tooltip to Buildable --- OpenRA.Mods.Common/Traits/Buildable.cs | 3 +++ OpenRA.Mods.Common/Traits/Tooltip.cs | 1 - .../UtilityCommands/UpgradeRules.cs | 19 +++++++++++++++++++ .../Logic/Ingame/ProductionTooltipLogic.cs | 2 +- 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/Buildable.cs b/OpenRA.Mods.Common/Traits/Buildable.cs index f8d2fbd58f..9ca714aba8 100644 --- a/OpenRA.Mods.Common/Traits/Buildable.cs +++ b/OpenRA.Mods.Common/Traits/Buildable.cs @@ -45,6 +45,9 @@ namespace OpenRA.Mods.Common.Traits // TODO: UI fluff; doesn't belong here public readonly int BuildPaletteOrder = 9999; + + [Desc("Text shown in the production tooltip.")] + [Translate] public readonly string Description = ""; } public class Buildable { } diff --git a/OpenRA.Mods.Common/Traits/Tooltip.cs b/OpenRA.Mods.Common/Traits/Tooltip.cs index 0c8dc3b6f3..83154618c6 100644 --- a/OpenRA.Mods.Common/Traits/Tooltip.cs +++ b/OpenRA.Mods.Common/Traits/Tooltip.cs @@ -15,7 +15,6 @@ namespace OpenRA.Mods.Common.Traits { public abstract class TooltipInfoBase : ITraitInfo { - [Translate] public readonly string Description = ""; [Translate] public readonly string Name = ""; public abstract object Create(ActorInitializer init); diff --git a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs index 5ea65e392d..d931a65507 100644 --- a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs +++ b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs @@ -397,6 +397,25 @@ namespace OpenRA.Mods.Common.UtilityCommands } } + // Move production description from Tooltip to Buildable + if (engineVersion < 20161016) + { + var tooltipChild = node.Value.Nodes.FirstOrDefault(n => n.Key == "Tooltip"); + if (tooltipChild != null || (tooltipChild = node.Value.Nodes.FirstOrDefault(n => n.Key == "DisguiseToolTip")) != null) + { + var descNode = tooltipChild.Value.Nodes.FirstOrDefault(n => n.Key == "Description"); + if (descNode != null) + { + var buildableNode = node.Value.Nodes.FirstOrDefault(n => n.Key == "Buildable"); + if (buildableNode == null) + node.Value.Nodes.Add(buildableNode = new MiniYamlNode("Buildable", "")); + + buildableNode.Value.Nodes.Add(descNode); + tooltipChild.Value.Nodes.Remove(descNode); + } + } + } + UpgradeActorRules(modData, engineVersion, ref node.Value.Nodes, node, depth + 1); } diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/ProductionTooltipLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/ProductionTooltipLogic.cs index 381d986f53..630615e129 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/ProductionTooltipLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/ProductionTooltipLogic.cs @@ -93,7 +93,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic costLabel.GetColor = () => pr.Cash + pr.Resources >= cost ? Color.White : Color.Red; - var descString = tooltip.Description.Replace("\\n", "\n"); + var descString = buildable.Description.Replace("\\n", "\n"); descLabel.GetText = () => descString; var leftWidth = new[] { nameWidth + hotkeyWidth, requiresFont.Measure(requiresString).X, descFont.Measure(descString).X }.Aggregate(Math.Max);