startgame order and lobby changes
This commit is contained in:
@@ -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))
|
||||
{
|
||||
|
||||
@@ -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<CheckboxWidget>("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<ButtonWidget>("CHANGEMAP_BUTTON").Visible
|
||||
= (Game.IsHost && Game.LocalClient.State == Session.ClientState.Ready);
|
||||
Game.IssueOrder(Order.Command("ready"));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user