From ae3a1c256167ec5daebbad9cbf483680eeaaa910 Mon Sep 17 00:00:00 2001 From: Gustas <37534529+PunkPun@users.noreply.github.com> Date: Mon, 8 Aug 2022 19:20:08 +0300 Subject: [PATCH] Add truncation to FactionLabel --- .../Widgets/Logic/Ingame/GameInfoStatsLogic.cs | 10 +++++----- mods/cnc/chrome/ingame-infostats.yaml | 4 +++- mods/common/chrome/ingame-infostats.yaml | 4 +++- mods/d2k/chrome/ingame-infostats.yaml | 4 +++- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/GameInfoStatsLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/GameInfoStatsLogic.cs index 88ade69eb7..47e254e4c1 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/GameInfoStatsLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/GameInfoStatsLogic.cs @@ -97,17 +97,17 @@ namespace OpenRA.Mods.Common.Widgets.Logic var flag = item.Get("FACTIONFLAG"); flag.GetImageCollection = () => "flags"; + + var factionName = pp.DisplayFaction.Name; if (player == null || player.RelationshipWith(pp) == PlayerRelationship.Ally || player.WinState != WinState.Undefined) { flag.GetImageName = () => pp.Faction.InternalName; - var factionName = pp.Faction.Name != pp.DisplayFaction.Name ? $"{pp.DisplayFaction.Name} ({pp.Faction.Name})" : pp.Faction.Name; - item.Get("FACTION").GetText = () => factionName; + factionName = pp.Faction.Name != factionName ? $"{factionName} ({pp.Faction.Name})" : pp.Faction.Name; } else - { flag.GetImageName = () => pp.DisplayFaction.InternalName; - item.Get("FACTION").GetText = () => pp.DisplayFaction.Name; - } + + WidgetUtils.TruncateLabelToTooltip(item.Get("FACTION"), factionName); var scoreCache = new CachedTransform(s => s.ToString()); item.Get("SCORE").GetText = () => scoreCache.Update(p.PlayerStatistics?.Experience ?? 0); diff --git a/mods/cnc/chrome/ingame-infostats.yaml b/mods/cnc/chrome/ingame-infostats.yaml index 4a9a08e00a..143f9f7aa2 100644 --- a/mods/cnc/chrome/ingame-infostats.yaml +++ b/mods/cnc/chrome/ingame-infostats.yaml @@ -109,11 +109,13 @@ Container@SKIRMISH_STATS: Y: 4 Width: 32 Height: 16 - Label@FACTION: + LabelWithTooltip@FACTION: X: 264 Width: 86 Height: 25 Shadow: True + TooltipContainer: TOOLTIP_CONTAINER + TooltipTemplate: SIMPLE_TOOLTIP Label@SCORE: X: 360 Width: 75 diff --git a/mods/common/chrome/ingame-infostats.yaml b/mods/common/chrome/ingame-infostats.yaml index 156af8bfe7..8f41b94466 100644 --- a/mods/common/chrome/ingame-infostats.yaml +++ b/mods/common/chrome/ingame-infostats.yaml @@ -107,11 +107,13 @@ Container@SKIRMISH_STATS: Y: 5 Width: 32 Height: 16 - Label@FACTION: + LabelWithTooltip@FACTION: X: 264 Width: 86 Height: 25 Shadow: True + TooltipContainer: TOOLTIP_CONTAINER + TooltipTemplate: SIMPLE_TOOLTIP Label@SCORE: X: 360 Width: 75 diff --git a/mods/d2k/chrome/ingame-infostats.yaml b/mods/d2k/chrome/ingame-infostats.yaml index d6aa6d72f9..adac91c31c 100644 --- a/mods/d2k/chrome/ingame-infostats.yaml +++ b/mods/d2k/chrome/ingame-infostats.yaml @@ -108,11 +108,13 @@ Container@SKIRMISH_STATS: Y: 4 Width: 32 Height: 16 - Label@FACTION: + LabelWithTooltip@FACTION: X: 264 Width: 86 Height: 25 Shadow: True + TooltipContainer: TOOLTIP_CONTAINER + TooltipTemplate: SIMPLE_TOOLTIP Label@SCORE: X: 360 Width: 75