diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/GameInfoStatsLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/GameInfoStatsLogic.cs index 26b7def067..69098611e8 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/GameInfoStatsLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/GameInfoStatsLogic.cs @@ -93,7 +93,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic LobbyUtils.SetupProfileWidget(item, client, orderManager, worldRenderer); var nameLabel = item.Get("NAME"); - WidgetUtils.AddSuffixToPlayerNameLabel(nameLabel, pp); + WidgetUtils.BindPlayerNameAndStatus(nameLabel, pp); nameLabel.GetColor = () => pp.Color; var flag = item.Get("FACTIONFLAG"); diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/ObserverShroudSelectorLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/ObserverShroudSelectorLogic.cs index 810c46bf71..1963365b12 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/ObserverShroudSelectorLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/ObserverShroudSelectorLogic.cs @@ -33,6 +33,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic readonly World world; CameraOption selected; + LabelWidget shroudLabel; class CameraOption { @@ -50,7 +51,13 @@ namespace OpenRA.Mods.Common.Widgets.Logic Color = p.Color; Faction = p.Faction.InternalName; IsSelected = () => p.World.RenderPlayer == p; - OnClick = () => { p.World.RenderPlayer = p; logic.selected = this; p.World.Selection.Clear(); }; + OnClick = () => + { + p.World.RenderPlayer = p; + logic.selected = this; + p.World.Selection.Clear(); + WidgetUtils.BindPlayerNameAndStatus(logic.shroudLabel, p); + }; } public CameraOption(ObserverShroudSelectorLogic logic, World w, string label, Player p) @@ -107,9 +114,13 @@ namespace OpenRA.Mods.Common.Widgets.Logic var label = item.Get("LABEL"); label.IsVisible = () => showFlag; - label.GetText = () => option.Label; label.GetColor = () => option.Color; + if (showFlag) + WidgetUtils.BindPlayerNameAndStatus(label, option.Player); + else + label.GetText = () => option.Label; + var flag = item.Get("FLAG"); flag.IsVisible = () => showFlag; flag.GetImageCollection = () => "flags"; @@ -126,7 +137,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic shroudSelector.ShowDropDown("SPECTATOR_DROPDOWN_TEMPLATE", 400, groups, setupItem); }; - var shroudLabel = shroudSelector.Get("LABEL"); + shroudLabel = shroudSelector.Get("LABEL"); shroudLabel.IsVisible = () => selected.Faction != null; shroudLabel.GetText = () => selected.Label; shroudLabel.GetColor = () => selected.Color; diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/ObserverStatsLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/ObserverStatsLogic.cs index 34edc08101..0f62bafeda 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/ObserverStatsLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/ObserverStatsLogic.cs @@ -526,7 +526,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic flag.GetImageName = () => player.Faction.InternalName; var playerName = template.Get("PLAYER"); - WidgetUtils.AddSuffixToPlayerNameLabel(playerName, player); + WidgetUtils.BindPlayerNameAndStatus(playerName, player); playerName.GetColor = () => player.Color; } diff --git a/OpenRA.Mods.Common/Widgets/WidgetUtils.cs b/OpenRA.Mods.Common/Widgets/WidgetUtils.cs index a9eadd0c9e..9b0be7c142 100644 --- a/OpenRA.Mods.Common/Widgets/WidgetUtils.cs +++ b/OpenRA.Mods.Common/Widgets/WidgetUtils.cs @@ -272,21 +272,23 @@ namespace OpenRA.Mods.Common.Widgets button.GetTooltipText = null; } - public static void AddSuffixToPlayerNameLabel(LabelWidget label, Player p) + public static void BindPlayerNameAndStatus(LabelWidget label, Player p) { var client = p.World.LobbyInfo.ClientWithIndex(p.ClientIndex); - var playerNameFont = Game.Renderer.Fonts[label.Font]; - var suffixLength = new CachedTransform(s => playerNameFont.Measure(s).X); - var name = new CachedTransform, string>(c => - WidgetUtils.TruncateText(c.First, label.Bounds.Width - suffixLength.Update(c.Second), playerNameFont)); + var nameFont = Game.Renderer.Fonts[label.Font]; + var name = new CachedTransform, string>(c => + { + var suffix = c.Item2 == WinState.Undefined ? "" : " (" + c.Item2 + ")"; + if (c.Item3 == Session.ClientState.Disconnected) + suffix = " (Gone)"; + + return TruncateText(c.Item1, label.Bounds.Width - nameFont.Measure(suffix).X, nameFont) + suffix; + }); label.GetText = () => { - var suffix = p.WinState == WinState.Undefined ? "" : " (" + p.WinState + ")"; - if (client != null && client.State == Session.ClientState.Disconnected) - suffix = " (Gone)"; - - return name.Update(Pair.New(p.PlayerName, suffix)) + suffix; + var clientState = client != null ? client.State : Session.ClientState.Ready; + return name.Update(Tuple.Create(p.PlayerName, p.WinState, clientState)); }; } } diff --git a/mods/cnc/chrome/dialogs.yaml b/mods/cnc/chrome/dialogs.yaml index 69af7bb12f..1f2f5a81bb 100644 --- a/mods/cnc/chrome/dialogs.yaml +++ b/mods/cnc/chrome/dialogs.yaml @@ -142,7 +142,7 @@ ScrollPanel@SPECTATOR_DROPDOWN_TEMPLATE: Height: 16 Label@LABEL: X: 40 - Width: 60 + Width: PARENT_RIGHT Height: 25 Shadow: True Label@NOFLAG_LABEL: diff --git a/mods/cnc/chrome/ingame.yaml b/mods/cnc/chrome/ingame.yaml index 834b71032f..8e1079406a 100644 --- a/mods/cnc/chrome/ingame.yaml +++ b/mods/cnc/chrome/ingame.yaml @@ -271,7 +271,7 @@ Container@OBSERVER_WIDGETS: Height: 16 Label@LABEL: X: 40 - Width: 60 + Width: PARENT_RIGHT Height: 25 Shadow: True Label@NOFLAG_LABEL: diff --git a/mods/common/chrome/dropdowns.yaml b/mods/common/chrome/dropdowns.yaml index e860642606..4a81624144 100644 --- a/mods/common/chrome/dropdowns.yaml +++ b/mods/common/chrome/dropdowns.yaml @@ -108,7 +108,7 @@ ScrollPanel@SPECTATOR_DROPDOWN_TEMPLATE: Height: 16 Label@LABEL: X: 40 - Width: 60 + Width: PARENT_RIGHT Height: 25 Shadow: True Label@NOFLAG_LABEL: diff --git a/mods/common/chrome/ingame-observer.yaml b/mods/common/chrome/ingame-observer.yaml index 61e6fb9d70..6dba5fa223 100644 --- a/mods/common/chrome/ingame-observer.yaml +++ b/mods/common/chrome/ingame-observer.yaml @@ -74,7 +74,7 @@ Container@OBSERVER_WIDGETS: Y: 2 Label@LABEL: X: 34 - Width: 60 + Width: PARENT_RIGHT Height: 25 Shadow: True Label@NOFLAG_LABEL: diff --git a/mods/d2k/chrome/dropdowns.yaml b/mods/d2k/chrome/dropdowns.yaml index 7f751d9267..17923ac792 100644 --- a/mods/d2k/chrome/dropdowns.yaml +++ b/mods/d2k/chrome/dropdowns.yaml @@ -104,7 +104,7 @@ ScrollPanel@SPECTATOR_DROPDOWN_TEMPLATE: Y: 2 Label@LABEL: X: 34 - Width: 60 + Width: PARENT_RIGHT Height: 25 Shadow: True Label@NOFLAG_LABEL: diff --git a/mods/d2k/chrome/ingame-observer.yaml b/mods/d2k/chrome/ingame-observer.yaml index 1578cf96a4..be02cd6359 100644 --- a/mods/d2k/chrome/ingame-observer.yaml +++ b/mods/d2k/chrome/ingame-observer.yaml @@ -94,7 +94,7 @@ Container@OBSERVER_WIDGETS: Y: 2 Label@LABEL: X: 34 - Width: 60 + Width: PARENT_RIGHT Height: 25 Shadow: True Label@NOFLAG_LABEL: diff --git a/mods/ra/chrome/ingame-observer.yaml b/mods/ra/chrome/ingame-observer.yaml index 3768e8fdf4..cc21e7cd07 100644 --- a/mods/ra/chrome/ingame-observer.yaml +++ b/mods/ra/chrome/ingame-observer.yaml @@ -108,7 +108,7 @@ Container@OBSERVER_WIDGETS: Height: 16 Label@LABEL: X: 40 - Width: 60 + Width: PARENT_RIGHT Height: 25 Shadow: True Label@NOFLAG_LABEL: diff --git a/mods/ts/chrome/dropdowns.yaml b/mods/ts/chrome/dropdowns.yaml index 409641d3ab..b9dd35c547 100644 --- a/mods/ts/chrome/dropdowns.yaml +++ b/mods/ts/chrome/dropdowns.yaml @@ -104,7 +104,7 @@ ScrollPanel@SPECTATOR_DROPDOWN_TEMPLATE: Height: 16 Label@LABEL: X: 40 - Width: 60 + Width: PARENT_RIGHT Height: 25 Shadow: True Label@NOFLAG_LABEL: diff --git a/mods/ts/chrome/ingame-observer.yaml b/mods/ts/chrome/ingame-observer.yaml index e8d1c3f86c..d6b0b8eae7 100644 --- a/mods/ts/chrome/ingame-observer.yaml +++ b/mods/ts/chrome/ingame-observer.yaml @@ -94,7 +94,7 @@ Container@OBSERVER_WIDGETS: Y: 5 Label@LABEL: X: 34 - Width: 60 + Width: PARENT_RIGHT Height: 25 Shadow: True Label@NOFLAG_LABEL: