diff --git a/OpenRA.Game/Server/Server.cs b/OpenRA.Game/Server/Server.cs index aa44dce58d..4a7725981e 100644 --- a/OpenRA.Game/Server/Server.cs +++ b/OpenRA.Game/Server/Server.cs @@ -372,6 +372,16 @@ namespace OpenRA.Server SyncLobbyInfo(); return true; }}, + { "slot", + s => + { + int slot; + if (!int.TryParse(s, out slot)) { Log.Write("server", "Invalid slot: {0}", s ); return false; } + + GetClient(conn).Slot = slot; + SyncLobbyInfo(); + return true; + }}, { "map", s => { diff --git a/OpenRA.Game/Widgets/Delegates/LobbyDelegate.cs b/OpenRA.Game/Widgets/Delegates/LobbyDelegate.cs index 4d5a1680c1..d32ff54467 100644 --- a/OpenRA.Game/Widgets/Delegates/LobbyDelegate.cs +++ b/OpenRA.Game/Widgets/Delegates/LobbyDelegate.cs @@ -18,7 +18,7 @@ namespace OpenRA.Widgets.Delegates { public class LobbyDelegate : IWidgetDelegate { - Widget Players, LocalPlayerTemplate, RemotePlayerTemplate, EmptySlotTemplate; + Widget Players, LocalPlayerTemplate, RemotePlayerTemplate, EmptySlotTemplate, EmptySlotTemplateHost; Dictionary CountryNames; string MapUid; @@ -41,6 +41,7 @@ namespace OpenRA.Widgets.Delegates LocalPlayerTemplate = Players.GetWidget("TEMPLATE_LOCAL"); RemotePlayerTemplate = Players.GetWidget("TEMPLATE_REMOTE"); EmptySlotTemplate = Players.GetWidget("TEMPLATE_EMPTY"); + EmptySlotTemplateHost = Players.GetWidget("TEMPLATE_EMPTY_HOST"); var mapPreview = lobby.GetWidget("LOBBY_MAP_PREVIEW"); mapPreview.Map = () => Map; @@ -253,12 +254,26 @@ namespace OpenRA.Widgets.Delegates var c = GetClientInSlot(s); Widget template; - template = EmptySlotTemplate.Clone(); // FIXME + if (c == null) + { + if (Game.IsHost) + { + template = EmptySlotTemplateHost.Clone(); + var name = template.GetWidget("NAME"); + name.GetText = () => s.Closed ? "Closed" : "Open"; + } + else + { + template = EmptySlotTemplate.Clone(); + var name = template.GetWidget("NAME"); + name.GetText = () => s.Closed ? "Closed" : "Open"; + } - var name = template.GetWidget("NAME"); - name.GetText = () => s.Bot ?? (s.Closed ? "Closed" : c != null ? c.Name : "Open"); - - /*if (client.Index == Game.LocalClient.Index && c.State != Session.ClientState.Ready) + var join = template.GetWidget("JOIN"); + if (join != null) + join.OnMouseUp = _ => { Game.IssueOrder(Order.Command("slot " + s.Index)); return true; }; + } + else if (c.Index == Game.LocalClient.Index && c.State != Session.ClientState.Ready) { template = LocalPlayerTemplate.Clone(); var name = template.GetWidget("NAME"); @@ -339,9 +354,8 @@ namespace OpenRA.Widgets.Delegates var status = template.GetWidget("STATUS"); status.Checked = () => c.State == Session.ClientState.Ready; - if (client.Index == Game.LocalClient.Index) status.OnMouseDown = CycleReady; + if (c.Index == Game.LocalClient.Index) status.OnMouseDown = CycleReady; } - * */ template.Id = "SLOT_{0}".F(s.Index); template.Parent = Players; diff --git a/mods/cnc/chrome/gamelobby.yaml b/mods/cnc/chrome/gamelobby.yaml index c396253eb1..9938bc2d73 100644 --- a/mods/cnc/chrome/gamelobby.yaml +++ b/mods/cnc/chrome/gamelobby.yaml @@ -32,7 +32,7 @@ Container@ROOT: Height:244 Container@PLAYERS: Id:PLAYERS - X:30 + X:20 Y:75 Width:500 Height:200 @@ -170,6 +170,35 @@ Container@ROOT: Height:25 X:0 Y:0 + Button@JOIN: + Id:JOIN + Text:Play in this slot + Width:PARENT_RIGHT - 160 + Height:25 + X:160 + Y:0 + Container@TEMPLATE_EMPTY_HOST: + Id:TEMPLATE_EMPTY_HOST + X:0 + Y:0 + Width:500 + Height:30 + Visible:false + Children: + Button@NAME: -- TODO: replace with dropdown + Id:NAME + Text:Name + Width:155 + Height:25 + X:0 + Y:0 + Button@JOIN: + Id:JOIN + Text:Play in this slot + Width:PARENT_RIGHT - 160 + Height:25 + X:160 + Y:0 Container@LABEL_CONTAINER: X:30 Y:45