diff --git a/OpenRA.Game/Traits/Player/TechTreeCache.cs b/OpenRA.Game/Traits/Player/TechTreeCache.cs index cccd86084e..15ff04a027 100755 --- a/OpenRA.Game/Traits/Player/TechTreeCache.cs +++ b/OpenRA.Game/Traits/Player/TechTreeCache.cs @@ -34,6 +34,9 @@ namespace OpenRA.Traits public void Tick( Player owner, Cache> buildings ) { + if (owner.Country == null) + return; + var effectivePrereq = prerequisites.Where( a => a.Traits.Get().Owner.Contains( owner.Country.Race ) ); var nowHasPrerequisites = effectivePrereq.Any() && effectivePrereq.All( a => buildings[ a.Name ].Any( b => !b.Trait().Disabled ) ); diff --git a/OpenRA.Game/Widgets/Delegates/LobbyDelegate.cs b/OpenRA.Game/Widgets/Delegates/LobbyDelegate.cs index c61d5ffa23..57db3751a9 100644 --- a/OpenRA.Game/Widgets/Delegates/LobbyDelegate.cs +++ b/OpenRA.Game/Widgets/Delegates/LobbyDelegate.cs @@ -12,14 +12,13 @@ using System.Collections.Generic; using System.Drawing; using System.Linq; using OpenRA.FileFormats; -using OpenRA.Traits; using OpenRA.Network; namespace OpenRA.Widgets.Delegates { public class LobbyDelegate : IWidgetDelegate { - Widget Players, LocalPlayerTemplate, RemotePlayerTemplate; + Widget Players, LocalPlayerTemplate, RemotePlayerTemplate, EmptySlotTemplate; Dictionary CountryNames; string MapUid; @@ -41,7 +40,7 @@ namespace OpenRA.Widgets.Delegates Players = Widget.RootWidget.GetWidget("SERVER_LOBBY").GetWidget("PLAYERS"); LocalPlayerTemplate = Players.GetWidget("TEMPLATE_LOCAL"); RemotePlayerTemplate = Players.GetWidget("TEMPLATE_REMOTE"); - + EmptySlotTemplate = Players.GetWidget("TEMPLATE_EMPTY"); var mapPreview = lobby.GetWidget("LOBBY_MAP_PREVIEW"); mapPreview.Map = () => Map; @@ -235,6 +234,11 @@ namespace OpenRA.Widgets.Delegates if (Game.orderManager.Connection.ConnectionState == ConnectionState.PreConnecting) hasJoined = false; } + + static Session.Client GetClientInSlot(Session.Slot slot) + { + return Game.LobbyInfo.Clients.FirstOrDefault(c => c.Slot == slot.Index); + } void UpdatePlayerList() { @@ -243,12 +247,18 @@ namespace OpenRA.Widgets.Delegates Players.Children.Clear(); int offset = 0; - foreach (var client in Game.LobbyInfo.Clients) + foreach (var slot in Game.LobbyInfo.Slots) { - var c = client; + var s = slot; + var c = GetClientInSlot(s); Widget template; - if (client.Index == Game.LocalClient.Index && c.State != Session.ClientState.Ready) + template = EmptySlotTemplate.Clone(); // FIXME + + var name = template.GetWidget("NAME"); + name.Text = s.Bot ?? (s.Closed ? "Closed" : c != null ? c.Name : "Open"); + + /*if (client.Index == Game.LocalClient.Index && c.State != Session.ClientState.Ready) { template = LocalPlayerTemplate.Clone(); var name = template.GetWidget("NAME"); @@ -331,8 +341,9 @@ namespace OpenRA.Widgets.Delegates status.Checked = () => c.State == Session.ClientState.Ready; if (client.Index == Game.LocalClient.Index) status.OnMouseDown = CycleReady; } + * */ - template.Id = "PLAYER_{0}".F(c.Index); + template.Id = "SLOT_{0}".F(s.Index); template.Parent = Players; template.Bounds = new Rectangle(0, offset, template.Bounds.Width, template.Bounds.Height); diff --git a/mods/cnc/chrome/gamelobby.yaml b/mods/cnc/chrome/gamelobby.yaml index ef9bb4cfa6..c396253eb1 100644 --- a/mods/cnc/chrome/gamelobby.yaml +++ b/mods/cnc/chrome/gamelobby.yaml @@ -155,6 +155,21 @@ Container@ROOT: Y:2 Width:20 Height:20 + Container@TEMPLATE_EMPTY: + Id:TEMPLATE_EMPTY + X:0 + Y:0 + Width:500 + Height:30 + Visible:false + Children: + Label@NAME: + Id:NAME + Text:Name + Width:139 + Height:25 + X:0 + Y:0 Container@LABEL_CONTAINER: X:30 Y:45