Skip to content

Commit

Permalink
Move Generic Prefixes to yaml and add prefix for Neutral
Browse files Browse the repository at this point in the history
  • Loading branch information
MustaphaTR authored and pchote committed Dec 28, 2017
1 parent 841c873 commit 7014393
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions OpenRA.Mods.Common/Traits/Tooltip.cs
Expand Up @@ -31,9 +31,18 @@ public class TooltipInfo : TooltipInfoBase, ITooltipInfo
"to be shown to chosen players.")]
[Translate] public readonly string GenericName = null;

[Desc("Prefix generic tooltip name with 'Enemy' or 'Allied'.")]
[Desc("Prefix generic tooltip name with 'Ally/Neutral/EnemyPrefix'.")]
public readonly bool GenericStancePrefix = true;

[Desc("Prefix to display in the tooltip for allied units.")]
[Translate] public readonly string AllyPrefix = "Allied";

[Desc("Prefix to display in the tooltip for neutral units.")]
[Translate] public readonly string NeutralPrefix = null;

[Desc("Prefix to display in the tooltip for enemy units.")]
[Translate] public readonly string EnemyPrefix = "Enemy";

[Desc("Player stances that the generic name should be shown to.")]
public readonly Stance GenericVisibility = Stance.None;

Expand All @@ -47,11 +56,14 @@ public string TooltipForPlayerStance(Stance stance)
if (stance == Stance.None || !GenericVisibility.HasStance(stance))
return Name;

if (GenericStancePrefix && stance == Stance.Ally)
return "Allied " + GenericName;
if (GenericStancePrefix && !string.IsNullOrEmpty(AllyPrefix) && stance == Stance.Ally)
return AllyPrefix + " " + GenericName;

if (GenericStancePrefix && !string.IsNullOrEmpty(NeutralPrefix) && stance == Stance.Neutral)
return NeutralPrefix + " " + GenericName;

if (GenericStancePrefix && stance == Stance.Enemy)
return "Enemy " + GenericName;
if (GenericStancePrefix && !string.IsNullOrEmpty(EnemyPrefix) && stance == Stance.Enemy)
return EnemyPrefix + " " + GenericName;

return GenericName;
}
Expand All @@ -74,4 +86,4 @@ public Tooltip(Actor self, TooltipInfo info)
this.info = info;
}
}
}
}

0 comments on commit 7014393

Please sign in to comment.