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;
|
||||
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<string, object>()
|
||||
{
|
||||
{ "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<CncMenuButtonWidget>("ABORT_BUTTON").OnClick = onAbort;
|
||||
|
||||
//widget.GetWidget<LabelWidget>("CONNECTING_DESC").GetText = () =>
|
||||
// "Connecting to {0}:{1}...".F(host, port);
|
||||
widget.GetWidget<LabelWidget>("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<string, object>()
|
||||
{
|
||||
{ "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<CncMenuButtonWidget>("ABORT_BUTTON").OnClick = onAbort;
|
||||
panel.GetWidget<CncMenuButtonWidget>("RETRY_BUTTON").OnClick = onRetry;
|
||||
|
||||
//widget.GetWidget<LabelWidget>("CONNECTING_DESC").GetText = () =>
|
||||
// "Connecting to {0}:{1}...".F(host, port);
|
||||
widget.GetWidget<LabelWidget>("CONNECTING_DESC").GetText = () =>
|
||||
"Could not connect to {0}:{1}".F(host, port);
|
||||
}
|
||||
}}
|
||||
|
||||
@@ -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<string, object> { { "orderManager", orderManager } });
|
||||
{
|
||||
// Show connection failed dialog
|
||||
Widget.CloseWindow();
|
||||
|
||||
Action onConnect = new Action(() =>
|
||||
{
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user