Can now start a game and disconnect from lobby without triggering a reload.
It is now possible to crash the game by starting a new server before the previous one has had time to timeout and release the port binding (the previous loadscreen pause meant this was always hidden).
This commit is contained in:
@@ -29,18 +29,63 @@ namespace OpenRA.Mods.Cnc.Widgets
|
||||
Map Map;
|
||||
|
||||
public static ColorRamp CurrentColorPreview;
|
||||
|
||||
|
||||
// Must be set only once on game start
|
||||
// TODO: This is stupid
|
||||
static bool staticSetup;
|
||||
|
||||
|
||||
public static void GameStartingStub()
|
||||
{
|
||||
var panel = Widget.RootWidget.GetWidget("SERVER_LOBBY");
|
||||
|
||||
// The panel may not be open anymore
|
||||
if (panel == null)
|
||||
return;
|
||||
|
||||
var lobbyLogic = panel.DelegateObject as CncLobbyLogic;
|
||||
if (lobbyLogic == null)
|
||||
return;
|
||||
|
||||
lobbyLogic.onGameStart();
|
||||
}
|
||||
|
||||
public static void UpdateCurrentMapStub()
|
||||
{
|
||||
var panel = Widget.RootWidget.GetWidget("SERVER_LOBBY");
|
||||
|
||||
// The panel may not be open anymore
|
||||
if (panel == null)
|
||||
return;
|
||||
|
||||
var lobbyLogic = panel.DelegateObject as CncLobbyLogic;
|
||||
if (lobbyLogic == null)
|
||||
return;
|
||||
|
||||
lobbyLogic.UpdateCurrentMap();
|
||||
}
|
||||
|
||||
readonly Action onGameStart;
|
||||
readonly OrderManager orderManager;
|
||||
readonly WorldRenderer worldRenderer;
|
||||
[ObjectCreator.UseCtor]
|
||||
internal CncLobbyLogic([ObjectCreator.Param( "widget" )] Widget lobby,
|
||||
[ObjectCreator.Param] OrderManager orderManager,
|
||||
[ObjectCreator.Param] Action onExit,
|
||||
[ObjectCreator.Param] Action onStart,
|
||||
[ObjectCreator.Param] WorldRenderer worldRenderer)
|
||||
{
|
||||
this.orderManager = orderManager;
|
||||
this.worldRenderer = worldRenderer;
|
||||
this.onGameStart = onStart;
|
||||
|
||||
if (!staticSetup)
|
||||
{
|
||||
staticSetup = true;
|
||||
Game.LobbyInfoChanged += UpdateCurrentMapStub;
|
||||
Game.BeforeGameStart += GameStartingStub;
|
||||
}
|
||||
|
||||
Game.LobbyInfoChanged += UpdateCurrentMap;
|
||||
UpdateCurrentMap();
|
||||
|
||||
CurrentColorPreview = Game.Settings.Player.ColorRamp;
|
||||
@@ -103,9 +148,7 @@ namespace OpenRA.Mods.Cnc.Widgets
|
||||
var disconnectButton = lobby.GetWidget("DISCONNECT_BUTTON");
|
||||
disconnectButton.OnMouseUp = mi =>
|
||||
{
|
||||
Game.Disconnect();
|
||||
Widget.CloseWindow();
|
||||
Widget.LoadWidget("MENU_BACKGROUND");
|
||||
onExit();
|
||||
return true;
|
||||
};
|
||||
|
||||
|
||||
@@ -51,11 +51,10 @@ namespace OpenRA.Mods.Cnc.Widgets
|
||||
multiplayerMenu.GetWidget("JOIN_BUTTON").OnMouseUp = mi =>
|
||||
{
|
||||
Menu = MenuType.None;
|
||||
Widget.OpenWindow("SERVERBROWSER_PANEL",
|
||||
new Dictionary<string, object>()
|
||||
{
|
||||
{"onExit", new Action(() => {Menu = MenuType.Multiplayer; Widget.CloseWindow();})}
|
||||
});
|
||||
Widget.OpenWindow("SERVERBROWSER_PANEL", new Dictionary<string, object>()
|
||||
{
|
||||
{"onExit", new Action(() => {Menu = MenuType.Multiplayer; Widget.CloseWindow();})}
|
||||
});
|
||||
return true;
|
||||
};
|
||||
|
||||
@@ -77,6 +76,28 @@ namespace OpenRA.Mods.Cnc.Widgets
|
||||
settings.Server.ListenPort = 1234;
|
||||
settings.Server.ExternalPort = 1234;
|
||||
Game.CreateAndJoinServer(settings, map);
|
||||
|
||||
Menu = MenuType.None;
|
||||
|
||||
Game.OpenWindow("SERVER_LOBBY", new Dictionary<string, object>()
|
||||
{
|
||||
// Returning to main menu
|
||||
{"onExit", new Action(() =>
|
||||
{
|
||||
Game.DisconnectOnly();
|
||||
Menu = MenuType.Main;
|
||||
Widget.CloseWindow();
|
||||
})
|
||||
},
|
||||
|
||||
// Starting a game: remove all shellmap ui
|
||||
{"onStart", new Action(() =>
|
||||
{
|
||||
Widget.CloseWindow();
|
||||
Widget.RootWidget.RemoveChild(Widget.RootWidget.GetWidget("MENU_BACKGROUND"));
|
||||
})
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user