Show an error dialog if disconnected from the server.

This commit is contained in:
Paul Chote
2014-01-31 20:50:26 +13:00
parent 7e8e427449
commit a32d440b05
6 changed files with 51 additions and 0 deletions

View File

@@ -485,6 +485,7 @@
<Compile Include="ShroudRenderer.cs" /> <Compile Include="ShroudRenderer.cs" />
<Compile Include="Render\WithCrateBody.cs" /> <Compile Include="Render\WithCrateBody.cs" />
<Compile Include="Buildings\Demolishable.cs" /> <Compile Include="Buildings\Demolishable.cs" />
<Compile Include="Widgets\Logic\DisconnectWatcherLogic.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj"> <ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">

View File

@@ -88,7 +88,10 @@ namespace OpenRA.Mods.RA.Widgets.Logic
var abortButton = panel.Get<ButtonWidget>("ABORT_BUTTON"); var abortButton = panel.Get<ButtonWidget>("ABORT_BUTTON");
var retryButton = panel.Get<ButtonWidget>("RETRY_BUTTON"); var retryButton = panel.Get<ButtonWidget>("RETRY_BUTTON");
abortButton.Visible = onAbort != null;
abortButton.OnClick = () => { Ui.CloseWindow(); onAbort(); }; abortButton.OnClick = () => { Ui.CloseWindow(); onAbort(); };
retryButton.Visible = onRetry != null;
retryButton.OnClick = () => retryButton.OnClick = () =>
{ {
var password = passwordField != null && passwordField.IsVisible() ? passwordField.Text : orderManager.Password; var password = passwordField != null && passwordField.IsVisible() ? passwordField.Text : orderManager.Password;

View File

@@ -0,0 +1,41 @@
#region Copyright & License Information
/*
* Copyright 2007-2014 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
*/
#endregion
using OpenRA.Network;
using OpenRA.Widgets;
namespace OpenRA.Mods.RA.Widgets.Logic
{
public class DisconnectWatcherLogic
{
[ObjectCreator.UseCtor]
public DisconnectWatcherLogic(Widget widget, OrderManager orderManager)
{
var disconnected = false;
widget.Get<LogicTickerWidget>("DISCONNECT_WATCHER").OnTick = () =>
{
if (!disconnected && orderManager.Connection.ConnectionState == ConnectionState.NotConnected)
{
Game.RunAfterTick(() =>
{
Ui.OpenWindow("CONNECTIONFAILED_PANEL", new WidgetArgs()
{
{ "orderManager", orderManager },
{ "onAbort", null },
{ "onRetry", null }
});
});
disconnected = true;
}
};
}
}
}

View File

@@ -1,6 +1,8 @@
Container@INGAME_ROOT: Container@INGAME_ROOT:
Logic:CncIngameChromeLogic Logic:CncIngameChromeLogic
Children: Children:
LogicTicker@DISCONNECT_WATCHER:
Logic:DisconnectWatcherLogic
Timer@GAME_TIMER: Timer@GAME_TIMER:
X: WINDOW_RIGHT/2 X: WINDOW_RIGHT/2
Y: 0 Y: 0

View File

@@ -1,6 +1,8 @@
Container@INGAME_ROOT: Container@INGAME_ROOT:
Logic:IngameChromeLogic Logic:IngameChromeLogic
Children: Children:
LogicTicker@DISCONNECT_WATCHER:
Logic:DisconnectWatcherLogic
WorldInteractionController@INTERACTION_CONTROLLER: WorldInteractionController@INTERACTION_CONTROLLER:
X:0 X:0
Y:0 Y:0

View File

@@ -1,6 +1,8 @@
Container@INGAME_ROOT: Container@INGAME_ROOT:
Logic:IngameChromeLogic Logic:IngameChromeLogic
Children: Children:
LogicTicker@DISCONNECT_WATCHER:
Logic:DisconnectWatcherLogic
WorldInteractionController@INTERACTION_CONTROLLER: WorldInteractionController@INTERACTION_CONTROLLER:
X:0 X:0
Y:0 Y:0