Merge pull request #3441 from Mailaender/display-server-error

Display ServerError in CONNECTIONFAILED_PANEL
This commit is contained in:
Paul Chote
2013-06-21 18:45:24 -07:00
5 changed files with 56 additions and 61 deletions

View File

@@ -162,7 +162,7 @@ namespace OpenRA
if (orderManager.GameStarted) if (orderManager.GameStarted)
++Viewport.TicksSinceLastMove; ++Viewport.TicksSinceLastMove;
Sound.Tick(); Sound.Tick();
Sync.CheckSyncUnchanged( world, () => { orderManager.TickImmediate(); } ); Sync.CheckSyncUnchanged(world, orderManager.TickImmediate);
if (world != null) if (world != null)
{ {
@@ -315,7 +315,6 @@ namespace OpenRA
Renderer.InitializeFonts(modData.Manifest); Renderer.InitializeFonts(modData.Manifest);
modData.InitializeLoaders(); modData.InitializeLoaders();
PerfHistory.items["render"].hasNormalTick = false; PerfHistory.items["render"].hasNormalTick = false;
PerfHistory.items["batches"].hasNormalTick = false; PerfHistory.items["batches"].hasNormalTick = false;
PerfHistory.items["render_widgets"].hasNormalTick = false; PerfHistory.items["render_widgets"].hasNormalTick = false;

View File

@@ -27,7 +27,8 @@ namespace OpenRA.Network
public readonly string Host; public readonly string Host;
public readonly int Port; public readonly int Port;
public string ServerError;
public string ServerError = "Server is not responding.";
public int NetFrameNumber { get; private set; } public int NetFrameNumber { get; private set; }
public int LocalFrameNumber; public int LocalFrameNumber;
@@ -47,7 +48,7 @@ namespace OpenRA.Network
if (GameStarted) return; if (GameStarted) return;
NetFrameNumber = 1; NetFrameNumber = 1;
for( int i = NetFrameNumber ; i <= FramesAhead ; i++ ) for (var i = NetFrameNumber ; i <= FramesAhead ; i++)
Connection.Send(i, new List<byte[]>()); Connection.Send(i, new List<byte[]>());
} }

View File

@@ -154,8 +154,10 @@ namespace OpenRA.Network
} }
case "ServerError": case "ServerError":
{
orderManager.ServerError = order.TargetString; orderManager.ServerError = order.TargetString;
break; break;
}
case "SyncInfo": case "SyncInfo":
{ {

View File

@@ -17,8 +17,6 @@ namespace OpenRA.Mods.RA.Widgets.Logic
public class ConnectionLogic public class ConnectionLogic
{ {
Action onConnect, onRetry, onAbort; Action onConnect, onRetry, onAbort;
string host;
int port;
void ConnectionStateChanged(OrderManager om) void ConnectionStateChanged(OrderManager om)
{ {
@@ -29,14 +27,12 @@ namespace OpenRA.Mods.RA.Widgets.Logic
} }
else if (om.Connection.ConnectionState == ConnectionState.NotConnected) else if (om.Connection.ConnectionState == ConnectionState.NotConnected)
{ {
// Show connection failed dialog
CloseWindow(); CloseWindow();
Ui.OpenWindow("CONNECTIONFAILED_PANEL", new WidgetArgs() Ui.OpenWindow("CONNECTIONFAILED_PANEL", new WidgetArgs()
{ {
{ "orderManager", om },
{ "onAbort", onAbort }, { "onAbort", onAbort },
{ "onRetry", onRetry }, { "onRetry", onRetry }
{ "host", host },
{ "port", port }
}); });
} }
} }
@@ -50,8 +46,6 @@ namespace OpenRA.Mods.RA.Widgets.Logic
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public ConnectionLogic(Widget widget, string host, int port, Action onConnect, Action onRetry, Action onAbort) public ConnectionLogic(Widget widget, string host, int port, Action onConnect, Action onRetry, 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;
@@ -82,14 +76,14 @@ namespace OpenRA.Mods.RA.Widgets.Logic
public class ConnectionFailedLogic public class ConnectionFailedLogic
{ {
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public ConnectionFailedLogic(Widget widget, string host, int port, Action onRetry, Action onAbort) public ConnectionFailedLogic(Widget widget, OrderManager orderManager, Action onRetry, Action onAbort)
{ {
var panel = widget; var panel = widget;
panel.Get<ButtonWidget>("ABORT_BUTTON").OnClick = () => { Ui.CloseWindow(); onAbort(); }; panel.Get<ButtonWidget>("ABORT_BUTTON").OnClick = () => { Ui.CloseWindow(); onAbort(); };
panel.Get<ButtonWidget>("RETRY_BUTTON").OnClick = () => { Ui.CloseWindow(); onRetry(); }; panel.Get<ButtonWidget>("RETRY_BUTTON").OnClick = () => { Ui.CloseWindow(); onRetry(); };
widget.Get<LabelWidget>("CONNECTING_DESC").GetText = () => widget.Get<LabelWidget>("CONNECTING_DESC").GetText = () =>
"Could not connect to {0}:{1}".F(host, port); "Could not connect to {0}:{1}\n{2}".F(orderManager.Host, orderManager.Port, orderManager.ServerError);
} }
} }
} }

View File

@@ -63,10 +63,9 @@ namespace OpenRA.Mods.RA.Widgets.Logic
Ui.OpenWindow("CONNECTIONFAILED_PANEL", new WidgetArgs() Ui.OpenWindow("CONNECTIONFAILED_PANEL", new WidgetArgs()
{ {
{ "orderManager", om },
{ "onAbort", onExit }, { "onAbort", onExit },
{ "onRetry", onRetry }, { "onRetry", onRetry }
{ "host", om.Host },
{ "port", om.Port }
}); });
} }
} }