Show the host/port in the dialogs. Show the failed dialog in the lobby when the server vanishes.
This commit is contained in:
@@ -19,6 +19,8 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
{
|
{
|
||||||
static bool staticSetup;
|
static bool staticSetup;
|
||||||
Action onConnect, onRetry, onAbort;
|
Action onConnect, onRetry, onAbort;
|
||||||
|
string host;
|
||||||
|
int port;
|
||||||
|
|
||||||
static void ConnectionStateChangedStub(OrderManager om)
|
static void ConnectionStateChangedStub(OrderManager om)
|
||||||
{
|
{
|
||||||
@@ -47,17 +49,23 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
Widget.OpenWindow("CONNECTIONFAILED_PANEL", new Dictionary<string, object>()
|
Widget.OpenWindow("CONNECTIONFAILED_PANEL", new Dictionary<string, object>()
|
||||||
{
|
{
|
||||||
{ "onAbort", onAbort },
|
{ "onAbort", onAbort },
|
||||||
{ "onRetry", onRetry }
|
{ "onRetry", onRetry },
|
||||||
|
{ "host", host },
|
||||||
|
{ "port", port }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[ObjectCreator.UseCtor]
|
[ObjectCreator.UseCtor]
|
||||||
public CncConnectingLogic([ObjectCreator.Param] Widget widget,
|
public CncConnectingLogic([ObjectCreator.Param] Widget widget,
|
||||||
|
[ObjectCreator.Param] string host,
|
||||||
|
[ObjectCreator.Param] int port,
|
||||||
[ObjectCreator.Param] Action onConnect,
|
[ObjectCreator.Param] Action onConnect,
|
||||||
[ObjectCreator.Param] Action onRetry,
|
[ObjectCreator.Param] Action onRetry,
|
||||||
[ObjectCreator.Param] Action onAbort)
|
[ObjectCreator.Param] Action onAbort)
|
||||||
{
|
{
|
||||||
|
this.host = host;
|
||||||
|
this.port = port;
|
||||||
this.onConnect = onConnect;
|
this.onConnect = onConnect;
|
||||||
this.onRetry = onRetry;
|
this.onRetry = onRetry;
|
||||||
this.onAbort = onAbort;
|
this.onAbort = onAbort;
|
||||||
@@ -70,8 +78,8 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
var panel = widget.GetWidget("CONNECTING_PANEL");
|
var panel = widget.GetWidget("CONNECTING_PANEL");
|
||||||
panel.GetWidget<CncMenuButtonWidget>("ABORT_BUTTON").OnClick = onAbort;
|
panel.GetWidget<CncMenuButtonWidget>("ABORT_BUTTON").OnClick = onAbort;
|
||||||
|
|
||||||
//widget.GetWidget<LabelWidget>("CONNECTING_DESC").GetText = () =>
|
widget.GetWidget<LabelWidget>("CONNECTING_DESC").GetText = () =>
|
||||||
// "Connecting to {0}:{1}...".F(host, port);
|
"Connecting to {0}:{1}...".F(host, port);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Connect(string host, int port, Action onConnect, Action onAbort)
|
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);
|
Game.JoinServer(host, port);
|
||||||
Widget.OpenWindow("CONNECTING_PANEL", new Dictionary<string, object>()
|
Widget.OpenWindow("CONNECTING_PANEL", new Dictionary<string, object>()
|
||||||
{
|
{
|
||||||
|
{ "host", host },
|
||||||
|
{ "port", port },
|
||||||
{ "onConnect", onConnect },
|
{ "onConnect", onConnect },
|
||||||
{ "onAbort", onAbort },
|
{ "onAbort", onAbort },
|
||||||
{ "onRetry", new Action(() => { Widget.CloseWindow(); Connect(host, port, onConnect, onAbort); }) }
|
{ "onRetry", new Action(() => { Widget.CloseWindow(); Connect(host, port, onConnect, onAbort); }) }
|
||||||
@@ -90,6 +100,8 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
{
|
{
|
||||||
[ObjectCreator.UseCtor]
|
[ObjectCreator.UseCtor]
|
||||||
public CncConnectionFailedLogic([ObjectCreator.Param] Widget widget,
|
public CncConnectionFailedLogic([ObjectCreator.Param] Widget widget,
|
||||||
|
[ObjectCreator.Param] string host,
|
||||||
|
[ObjectCreator.Param] int port,
|
||||||
[ObjectCreator.Param] Action onRetry,
|
[ObjectCreator.Param] Action onRetry,
|
||||||
[ObjectCreator.Param] Action onAbort)
|
[ObjectCreator.Param] Action onAbort)
|
||||||
{
|
{
|
||||||
@@ -97,7 +109,7 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
panel.GetWidget<CncMenuButtonWidget>("ABORT_BUTTON").OnClick = onAbort;
|
panel.GetWidget<CncMenuButtonWidget>("ABORT_BUTTON").OnClick = onAbort;
|
||||||
panel.GetWidget<CncMenuButtonWidget>("RETRY_BUTTON").OnClick = onRetry;
|
panel.GetWidget<CncMenuButtonWidget>("RETRY_BUTTON").OnClick = onRetry;
|
||||||
|
|
||||||
//widget.GetWidget<LabelWidget>("CONNECTING_DESC").GetText = () =>
|
widget.GetWidget<LabelWidget>("CONNECTING_DESC").GetText = () =>
|
||||||
// "Connecting to {0}:{1}...".F(host, port);
|
"Could not connect to {0}:{1}".F(host, port);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -88,12 +88,34 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
// Listen for connection failures
|
// Listen for connection failures
|
||||||
void ConnectionStateChanged(OrderManager om)
|
void ConnectionStateChanged(OrderManager om)
|
||||||
{
|
{
|
||||||
// TODO: Show a connection failed dialog
|
|
||||||
if (om.Connection.ConnectionState == ConnectionState.NotConnected)
|
if (om.Connection.ConnectionState == ConnectionState.NotConnected)
|
||||||
onExit();
|
{
|
||||||
|
// Show connection failed dialog
|
||||||
|
Widget.CloseWindow();
|
||||||
|
|
||||||
//Widget.CloseWindow();
|
Action onConnect = new Action(() =>
|
||||||
//Widget.OpenWindow("CONNECTION_FAILED_BG", new Dictionary<string, object> { { "orderManager", orderManager } });
|
{
|
||||||
|
Game.OpenWindow("SERVER_LOBBY", new Dictionary<string, object>()
|
||||||
|
{
|
||||||
|
{ "onExit", onExit },
|
||||||
|
{ "onStart", onGameStart }
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
Action onRetry = new Action(() =>
|
||||||
|
{
|
||||||
|
Widget.CloseWindow();
|
||||||
|
CncConnectingLogic.Connect(om.Host, om.Port, onConnect, onExit);
|
||||||
|
});
|
||||||
|
|
||||||
|
Widget.OpenWindow("CONNECTIONFAILED_PANEL", new Dictionary<string, object>()
|
||||||
|
{
|
||||||
|
{ "onAbort", onExit },
|
||||||
|
{ "onRetry", onRetry },
|
||||||
|
{ "host", om.Host },
|
||||||
|
{ "port", om.Port }
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
readonly Action onGameStart;
|
readonly Action onGameStart;
|
||||||
|
|||||||
Reference in New Issue
Block a user