diff --git a/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyUtils.cs b/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyUtils.cs index 4af9cf8755..cfe9f0ae20 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyUtils.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyUtils.cs @@ -474,14 +474,23 @@ namespace OpenRA.Mods.Common.Widgets.Logic else flag.GetImageName = () => player.Faction.InternalName; - var playerName = template.Get("PLAYER"); var client = player.World.LobbyInfo.ClientWithIndex(player.ClientIndex); + var playerName = template.Get("PLAYER"); + var playerNameFont = Game.Renderer.Fonts[playerName.Font]; + var suffixLength = new CachedTransform(s => playerNameFont.Measure(s).X); + var name = new CachedTransform, string>(c => + WidgetUtils.TruncateText(c.First, playerName.Bounds.Width - c.Second, playerNameFont)); + playerName.GetText = () => { + var suffix = player.WinState == WinState.Undefined ? "" : " (" + player.WinState + ")"; if (client != null && client.State == Network.Session.ClientState.Disconnected) - return player.PlayerName + " (Gone)"; - return player.PlayerName + (player.WinState == WinState.Undefined ? "" : " (" + player.WinState + ")"); + suffix = " (Gone)"; + + var sl = suffixLength.Update(suffix); + return name.Update(Pair.New(player.PlayerName, sl)) + suffix; }; + playerName.GetColor = () => player.Color.RGB; }