Moved production description from Tooltip to Buildable

This commit is contained in:
Tyson Liddell
2016-10-02 13:23:22 +11:00
parent e9d2da948e
commit aeb1e07823
4 changed files with 23 additions and 2 deletions

View File

@@ -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 { }

View File

@@ -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);

View File

@@ -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);
}

View File

@@ -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);