Made Tooltip trait upgradable

This commit is contained in:
reaperrr
2016-09-05 21:11:08 +02:00
parent 1a99e716de
commit 074bb78cbd
6 changed files with 25 additions and 13 deletions

View File

@@ -13,11 +13,9 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits
{
public abstract class TooltipInfoBase : ITraitInfo
public abstract class TooltipInfoBase : UpgradableTraitInfo
{
[Translate] public readonly string Name = "";
public abstract object Create(ActorInitializer init);
}
[Desc("Shown in map editor.")]
@@ -61,7 +59,7 @@ namespace OpenRA.Mods.Common.Traits
public bool IsOwnerRowVisible { get { return ShowOwnerRow; } }
}
public class Tooltip : ITooltip
public class Tooltip : UpgradableTrait<TooltipInfo>, ITooltip
{
readonly Actor self;
readonly TooltipInfo info;
@@ -70,6 +68,7 @@ namespace OpenRA.Mods.Common.Traits
public Player Owner { get { return self.Owner; } }
public Tooltip(Actor self, TooltipInfo info)
: base(info)
{
this.self = self;
this.info = info;

View File

@@ -70,7 +70,9 @@ namespace OpenRA.Mods.Common.Traits
Footprint = new ReadOnlyDictionary<CPos, SubCell>(footprint);
}
var tooltip = Info.TraitInfoOrDefault<EditorOnlyTooltipInfo>() as TooltipInfoBase ?? Info.TraitInfoOrDefault<TooltipInfo>();
var tooltip = Info.TraitInfos<EditorOnlyTooltipInfo>().FirstOrDefault(Exts.IsTraitEnabled) as TooltipInfoBase
?? Info.TraitInfos<TooltipInfo>().FirstOrDefault(Exts.IsTraitEnabled);
Tooltip = (tooltip == null ? " < " + Info.Name + " >" : tooltip.Name) + "\n" + owner.Name + " (" + owner.Faction + ")"
+ "\nID: " + ID + "\nType: " + Info.Name;