Merge pull request #10015 from atlimit8/MapEditorTooltips

Add map editor only tooltips
This commit is contained in:
Paul Chote
2015-12-28 18:46:07 +00:00
10 changed files with 56 additions and 5 deletions

View File

@@ -12,12 +12,23 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits
{
[Desc("Shown in the build palette widget.")]
public class TooltipInfo : ITraitInfo, ITooltipInfo
public abstract class TooltipInfoBase : ITraitInfo
{
[Translate] public readonly string Description = "";
[Translate] public readonly string Name = "";
public abstract object Create(ActorInitializer init);
}
[Desc("Shown in map editor.")]
public class EditorOnlyTooltipInfo : TooltipInfoBase
{
public override object Create(ActorInitializer init) { return this; }
}
[Desc("Shown in the build palette widget.")]
public class TooltipInfo : TooltipInfoBase, ITooltipInfo
{
[Desc("An optional generic name (i.e. \"Soldier\" or \"Structure\")" +
"to be shown to chosen players.")]
[Translate] public readonly string GenericName = null;
@@ -34,7 +45,7 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Sequence of the actor that contains the cameo.")]
public readonly string Icon = "icon";
public virtual object Create(ActorInitializer init) { return new Tooltip(init.Self, this); }
public override object Create(ActorInitializer init) { return new Tooltip(init.Self, this); }
public string TooltipForPlayerStance(Stance stance)
{

View File

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