Add truncation to FactionLabel

This commit is contained in:
Gustas
2022-08-08 19:20:08 +03:00
parent 1b1868fca6
commit ae3a1c2561
4 changed files with 14 additions and 8 deletions

View File

@@ -97,17 +97,17 @@ namespace OpenRA.Mods.Common.Widgets.Logic
var flag = item.Get<ImageWidget>("FACTIONFLAG"); var flag = item.Get<ImageWidget>("FACTIONFLAG");
flag.GetImageCollection = () => "flags"; flag.GetImageCollection = () => "flags";
var factionName = pp.DisplayFaction.Name;
if (player == null || player.RelationshipWith(pp) == PlayerRelationship.Ally || player.WinState != WinState.Undefined) if (player == null || player.RelationshipWith(pp) == PlayerRelationship.Ally || player.WinState != WinState.Undefined)
{ {
flag.GetImageName = () => pp.Faction.InternalName; flag.GetImageName = () => pp.Faction.InternalName;
var factionName = pp.Faction.Name != pp.DisplayFaction.Name ? $"{pp.DisplayFaction.Name} ({pp.Faction.Name})" : pp.Faction.Name; factionName = pp.Faction.Name != factionName ? $"{factionName} ({pp.Faction.Name})" : pp.Faction.Name;
item.Get<LabelWidget>("FACTION").GetText = () => factionName;
} }
else else
{
flag.GetImageName = () => pp.DisplayFaction.InternalName; flag.GetImageName = () => pp.DisplayFaction.InternalName;
item.Get<LabelWidget>("FACTION").GetText = () => pp.DisplayFaction.Name;
} WidgetUtils.TruncateLabelToTooltip(item.Get<LabelWithTooltipWidget>("FACTION"), factionName);
var scoreCache = new CachedTransform<int, string>(s => s.ToString()); var scoreCache = new CachedTransform<int, string>(s => s.ToString());
item.Get<LabelWidget>("SCORE").GetText = () => scoreCache.Update(p.PlayerStatistics?.Experience ?? 0); item.Get<LabelWidget>("SCORE").GetText = () => scoreCache.Update(p.PlayerStatistics?.Experience ?? 0);

View File

@@ -109,11 +109,13 @@ Container@SKIRMISH_STATS:
Y: 4 Y: 4
Width: 32 Width: 32
Height: 16 Height: 16
Label@FACTION: LabelWithTooltip@FACTION:
X: 264 X: 264
Width: 86 Width: 86
Height: 25 Height: 25
Shadow: True Shadow: True
TooltipContainer: TOOLTIP_CONTAINER
TooltipTemplate: SIMPLE_TOOLTIP
Label@SCORE: Label@SCORE:
X: 360 X: 360
Width: 75 Width: 75

View File

@@ -107,11 +107,13 @@ Container@SKIRMISH_STATS:
Y: 5 Y: 5
Width: 32 Width: 32
Height: 16 Height: 16
Label@FACTION: LabelWithTooltip@FACTION:
X: 264 X: 264
Width: 86 Width: 86
Height: 25 Height: 25
Shadow: True Shadow: True
TooltipContainer: TOOLTIP_CONTAINER
TooltipTemplate: SIMPLE_TOOLTIP
Label@SCORE: Label@SCORE:
X: 360 X: 360
Width: 75 Width: 75

View File

@@ -108,11 +108,13 @@ Container@SKIRMISH_STATS:
Y: 4 Y: 4
Width: 32 Width: 32
Height: 16 Height: 16
Label@FACTION: LabelWithTooltip@FACTION:
X: 264 X: 264
Width: 86 Width: 86
Height: 25 Height: 25
Shadow: True Shadow: True
TooltipContainer: TOOLTIP_CONTAINER
TooltipTemplate: SIMPLE_TOOLTIP
Label@SCORE: Label@SCORE:
X: 360 X: 360
Width: 75 Width: 75