diff --git a/OpenRA.Mods.Cnc/Widgets/CncConnectionLogic.cs b/OpenRA.Mods.Cnc/Widgets/CncConnectionLogic.cs index 7ae2f0d5a7..8729d7c09d 100644 --- a/OpenRA.Mods.Cnc/Widgets/CncConnectionLogic.cs +++ b/OpenRA.Mods.Cnc/Widgets/CncConnectionLogic.cs @@ -19,6 +19,8 @@ namespace OpenRA.Mods.Cnc.Widgets { static bool staticSetup; Action onConnect, onRetry, onAbort; + string host; + int port; static void ConnectionStateChangedStub(OrderManager om) { @@ -47,17 +49,23 @@ namespace OpenRA.Mods.Cnc.Widgets Widget.OpenWindow("CONNECTIONFAILED_PANEL", new Dictionary() { { "onAbort", onAbort }, - { "onRetry", onRetry } + { "onRetry", onRetry }, + { "host", host }, + { "port", port } }); } } [ObjectCreator.UseCtor] public CncConnectingLogic([ObjectCreator.Param] Widget widget, + [ObjectCreator.Param] string host, + [ObjectCreator.Param] int port, [ObjectCreator.Param] Action onConnect, [ObjectCreator.Param] Action onRetry, [ObjectCreator.Param] Action onAbort) { + this.host = host; + this.port = port; this.onConnect = onConnect; this.onRetry = onRetry; this.onAbort = onAbort; @@ -70,8 +78,8 @@ namespace OpenRA.Mods.Cnc.Widgets var panel = widget.GetWidget("CONNECTING_PANEL"); panel.GetWidget("ABORT_BUTTON").OnClick = onAbort; - //widget.GetWidget("CONNECTING_DESC").GetText = () => - // "Connecting to {0}:{1}...".F(host, port); + widget.GetWidget("CONNECTING_DESC").GetText = () => + "Connecting to {0}:{1}...".F(host, port); } public static void Connect(string host, int port, Action onConnect, Action onAbort) @@ -79,6 +87,8 @@ namespace OpenRA.Mods.Cnc.Widgets Game.JoinServer(host, port); Widget.OpenWindow("CONNECTING_PANEL", new Dictionary() { + { "host", host }, + { "port", port }, { "onConnect", onConnect }, { "onAbort", onAbort }, { "onRetry", new Action(() => { Widget.CloseWindow(); Connect(host, port, onConnect, onAbort); }) } @@ -90,14 +100,16 @@ namespace OpenRA.Mods.Cnc.Widgets { [ObjectCreator.UseCtor] public CncConnectionFailedLogic([ObjectCreator.Param] Widget widget, - [ObjectCreator.Param] Action onRetry, - [ObjectCreator.Param] Action onAbort) + [ObjectCreator.Param] string host, + [ObjectCreator.Param] int port, + [ObjectCreator.Param] Action onRetry, + [ObjectCreator.Param] Action onAbort) { var panel = widget.GetWidget("CONNECTIONFAILED_PANEL"); panel.GetWidget("ABORT_BUTTON").OnClick = onAbort; panel.GetWidget("RETRY_BUTTON").OnClick = onRetry; - //widget.GetWidget("CONNECTING_DESC").GetText = () => - // "Connecting to {0}:{1}...".F(host, port); + widget.GetWidget("CONNECTING_DESC").GetText = () => + "Could not connect to {0}:{1}".F(host, port); } }} diff --git a/OpenRA.Mods.Cnc/Widgets/CncLobbyLogic.cs b/OpenRA.Mods.Cnc/Widgets/CncLobbyLogic.cs index 9572bf5108..577cf0a459 100755 --- a/OpenRA.Mods.Cnc/Widgets/CncLobbyLogic.cs +++ b/OpenRA.Mods.Cnc/Widgets/CncLobbyLogic.cs @@ -88,12 +88,34 @@ namespace OpenRA.Mods.Cnc.Widgets // Listen for connection failures void ConnectionStateChanged(OrderManager om) { - // TODO: Show a connection failed dialog if (om.Connection.ConnectionState == ConnectionState.NotConnected) - onExit(); - - //Widget.CloseWindow(); - //Widget.OpenWindow("CONNECTION_FAILED_BG", new Dictionary { { "orderManager", orderManager } }); + { + // Show connection failed dialog + Widget.CloseWindow(); + + Action onConnect = new Action(() => + { + Game.OpenWindow("SERVER_LOBBY", new Dictionary() + { + { "onExit", onExit }, + { "onStart", onGameStart } + }); + }); + + Action onRetry = new Action(() => + { + Widget.CloseWindow(); + CncConnectingLogic.Connect(om.Host, om.Port, onConnect, onExit); + }); + + Widget.OpenWindow("CONNECTIONFAILED_PANEL", new Dictionary() + { + { "onAbort", onExit }, + { "onRetry", onRetry }, + { "host", om.Host }, + { "port", om.Port } + }); + } } readonly Action onGameStart;