Show an error dialog if disconnected from the server.
This commit is contained in:
@@ -485,6 +485,7 @@
|
||||
<Compile Include="ShroudRenderer.cs" />
|
||||
<Compile Include="Render\WithCrateBody.cs" />
|
||||
<Compile Include="Buildings\Demolishable.cs" />
|
||||
<Compile Include="Widgets\Logic\DisconnectWatcherLogic.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">
|
||||
|
||||
@@ -88,7 +88,10 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
var abortButton = panel.Get<ButtonWidget>("ABORT_BUTTON");
|
||||
var retryButton = panel.Get<ButtonWidget>("RETRY_BUTTON");
|
||||
|
||||
abortButton.Visible = onAbort != null;
|
||||
abortButton.OnClick = () => { Ui.CloseWindow(); onAbort(); };
|
||||
|
||||
retryButton.Visible = onRetry != null;
|
||||
retryButton.OnClick = () =>
|
||||
{
|
||||
var password = passwordField != null && passwordField.IsVisible() ? passwordField.Text : orderManager.Password;
|
||||
|
||||
41
OpenRA.Mods.RA/Widgets/Logic/DisconnectWatcherLogic.cs
Normal file
41
OpenRA.Mods.RA/Widgets/Logic/DisconnectWatcherLogic.cs
Normal 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;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
Container@INGAME_ROOT:
|
||||
Logic:CncIngameChromeLogic
|
||||
Children:
|
||||
LogicTicker@DISCONNECT_WATCHER:
|
||||
Logic:DisconnectWatcherLogic
|
||||
Timer@GAME_TIMER:
|
||||
X: WINDOW_RIGHT/2
|
||||
Y: 0
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
Container@INGAME_ROOT:
|
||||
Logic:IngameChromeLogic
|
||||
Children:
|
||||
LogicTicker@DISCONNECT_WATCHER:
|
||||
Logic:DisconnectWatcherLogic
|
||||
WorldInteractionController@INTERACTION_CONTROLLER:
|
||||
X:0
|
||||
Y:0
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
Container@INGAME_ROOT:
|
||||
Logic:IngameChromeLogic
|
||||
Children:
|
||||
LogicTicker@DISCONNECT_WATCHER:
|
||||
Logic:DisconnectWatcherLogic
|
||||
WorldInteractionController@INTERACTION_CONTROLLER:
|
||||
X:0
|
||||
Y:0
|
||||
|
||||
Reference in New Issue
Block a user