diff --git a/OpenRA.Game/Server/Server.cs b/OpenRA.Game/Server/Server.cs index a23d1e12b2..efb41acf81 100644 --- a/OpenRA.Game/Server/Server.cs +++ b/OpenRA.Game/Server/Server.cs @@ -240,11 +240,13 @@ namespace OpenRA.Server conn.socket.RemoteEndPoint, client.State); SyncLobbyInfo(); - - // start the game if everyone is ready. + return true; + }}, + { "startgame", + s => + { if (conns.Count > 0 && conns.All(c => GetClient(c).State == Session.ClientState.Ready)) { - Console.WriteLine("All players are ready. Starting the game!"); GameStarted = true; foreach( var c in conns ) foreach( var d in conns ) @@ -255,7 +257,6 @@ namespace OpenRA.Server PingMasterServer(); } - return true; }}, { "name", @@ -396,7 +397,7 @@ namespace OpenRA.Server { if(GameStarted) SendChatTo(conn, "Cannot change state when game started."); - else if (GetClient(conn).State == Session.ClientState.Ready && so.Data != "ready") + else if (GetClient(conn).State == Session.ClientState.Ready && !(so.Data == "ready" || so.Data == "startgame") ) SendChatTo(conn, "Cannot change state when marked as ready."); else if (!InterpretCommand(conn, so.Data)) { diff --git a/OpenRA.Game/Widgets/Delegates/LobbyDelegate.cs b/OpenRA.Game/Widgets/Delegates/LobbyDelegate.cs index 1e8a25ea7b..06f527e7fc 100644 --- a/OpenRA.Game/Widgets/Delegates/LobbyDelegate.cs +++ b/OpenRA.Game/Widgets/Delegates/LobbyDelegate.cs @@ -83,6 +83,15 @@ namespace OpenRA.Widgets.Delegates Game.Disconnect(); return true; }; + + var startGameButton = lobby.GetWidget("START_GAME_BUTTON"); + startGameButton.OnMouseUp = mi => + { + mapButton.Visible = false; + Game.IssueOrder(Order.Command("startgame")); + return true; + }; + startGameButton.IsVisible = () => Game.IsHost && Game.LobbyInfo.Clients.All(c => c.State == Session.ClientState.Ready); var lockTeamsCheckbox = lobby.GetWidget("LOCKTEAMS_CHECKBOX"); lockTeamsCheckbox.IsVisible = () => true; @@ -347,9 +356,6 @@ namespace OpenRA.Widgets.Delegates bool CycleReady(MouseInput mi) { - //HACK: Can't set this as part of the fuction as LocalClient/State not initalised yet - Widget.RootWidget.GetWidget("SERVER_LOBBY").GetWidget("CHANGEMAP_BUTTON").Visible - = (Game.IsHost && Game.LocalClient.State == Session.ClientState.Ready); Game.IssueOrder(Order.Command("ready")); return true; } diff --git a/mods/cnc/chrome/gamelobby.yaml b/mods/cnc/chrome/gamelobby.yaml index f177a041d9..5a6193d1a2 100644 --- a/mods/cnc/chrome/gamelobby.yaml +++ b/mods/cnc/chrome/gamelobby.yaml @@ -234,10 +234,19 @@ Container@ROOT: Y:PARENT_BOTTOM - 74 Width:710 Height:25 + Button@START_GAME_BUTTON: + Id:START_GAME_BUTTON + Visible:true + X:PARENT_RIGHT-140 + Y:PARENT_BOTTOM-43 + Width:120 + Height:25 + Text:Start Game + Bold:True Button@DISCONNECT_BUTTON: Id:DISCONNECT_BUTTON Visible:true - X:PARENT_RIGHT-140 + X:20 Y:PARENT_BOTTOM-43 Width:120 Height:25 diff --git a/mods/ra/chrome/gamelobby.yaml b/mods/ra/chrome/gamelobby.yaml index 8d42b5367c..eadeeefb4a 100644 --- a/mods/ra/chrome/gamelobby.yaml +++ b/mods/ra/chrome/gamelobby.yaml @@ -234,10 +234,19 @@ Container@ROOT: Y:PARENT_BOTTOM - 74 Width:710 Height:25 + Button@START_GAME_BUTTON: + Id:START_GAME_BUTTON + Visible:true + X:PARENT_RIGHT-140 + Y:PARENT_BOTTOM-43 + Width:120 + Height:25 + Text:Start Game + Bold:True Button@DISCONNECT_BUTTON: Id:DISCONNECT_BUTTON Visible:true - X:PARENT_RIGHT-140 + X:20 Y:PARENT_BOTTOM-43 Width:120 Height:25