diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/ObserverStatsLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/ObserverStatsLogic.cs index bfb344927e..aec378c6f6 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/ObserverStatsLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/ObserverStatsLogic.cs @@ -271,7 +271,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic combatStatsHeaders.Visible = true; var template = SetupPlayerScrollItemWidget(combatPlayerTemplate, player); - LobbyUtils.AddPlayerFlagAndName(template, player); + AddPlayerFlagAndName(template, player); var playerName = template.Get("PLAYER"); playerName.GetColor = () => Color.White; @@ -299,7 +299,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic productionStatsHeaders.Visible = true; var template = SetupPlayerScrollItemWidget(productionPlayerTemplate, player); - LobbyUtils.AddPlayerFlagAndName(template, player); + AddPlayerFlagAndName(template, player); var playerName = template.Get("PLAYER"); playerName.GetColor = () => Color.White; @@ -320,7 +320,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic supportPowerStatsHeaders.Visible = true; var template = SetupPlayerScrollItemWidget(supportPowersPlayerTemplate, player); - LobbyUtils.AddPlayerFlagAndName(template, player); + AddPlayerFlagAndName(template, player); var playerName = template.Get("PLAYER"); playerName.GetColor = () => Color.White; @@ -341,7 +341,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic economyStatsHeaders.Visible = true; var template = SetupPlayerScrollItemWidget(economyPlayerTemplate, player); - LobbyUtils.AddPlayerFlagAndName(template, player); + AddPlayerFlagAndName(template, player); var playerName = template.Get("PLAYER"); playerName.GetColor = () => Color.White; @@ -377,7 +377,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic basicStatsHeaders.Visible = true; var template = SetupPlayerScrollItemWidget(basicPlayerTemplate, player); - LobbyUtils.AddPlayerFlagAndName(template, player); + AddPlayerFlagAndName(template, player); var playerName = template.Get("PLAYER"); playerName.GetColor = () => Color.White; @@ -460,6 +460,32 @@ namespace OpenRA.Mods.Common.Widgets.Logic } } + static void AddPlayerFlagAndName(ScrollItemWidget template, Player player) + { + var flag = template.Get("FLAG"); + flag.GetImageCollection = () => "flags"; + flag.GetImageName = () => player.Faction.InternalName; + + 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 == Session.ClientState.Disconnected) + suffix = " (Gone)"; + + var sl = suffixLength.Update(suffix); + return name.Update(Pair.New(player.PlayerName, sl)) + suffix; + }; + + playerName.GetColor = () => player.Color; + } + string AverageOrdersPerMinute(double orders) { return (world.WorldTick == 0 ? 0 : orders / (world.WorldTick / 1500.0)).ToString("F1"); diff --git a/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyUtils.cs b/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyUtils.cs index ba84775006..bc5088a2bf 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyUtils.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyUtils.cs @@ -583,35 +583,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic HideChildWidget(parent, "STATUS_IMAGE"); } - public static void AddPlayerFlagAndName(ScrollItemWidget template, Player player) - { - var flag = template.Get("FLAG"); - flag.GetImageCollection = () => "flags"; - if (player.World.RenderPlayer != null && player.World.RenderPlayer.Stances[player] != Stance.Ally) - flag.GetImageName = () => player.DisplayFaction.InternalName; - else - flag.GetImageName = () => player.Faction.InternalName; - - 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 == Session.ClientState.Disconnected) - suffix = " (Gone)"; - - var sl = suffixLength.Update(suffix); - return name.Update(Pair.New(player.PlayerName, sl)) + suffix; - }; - - playerName.GetColor = () => player.Color; - } - public static string GetExternalIP(Session.Client client, OrderManager orderManager) { var address = client != null ? client.IpAddress : "";