Redial Button II - Now with magic! (#8237)
* Redial Button II - Now with magic! * 15-second timer before redial is allowed
This commit is contained in:
@@ -129,6 +129,7 @@ namespace Content.Client.Entry
|
|||||||
IoCManager.Resolve<RulesManager>().Initialize();
|
IoCManager.Resolve<RulesManager>().Initialize();
|
||||||
IoCManager.Resolve<ViewportManager>().Initialize();
|
IoCManager.Resolve<ViewportManager>().Initialize();
|
||||||
IoCManager.Resolve<GhostKickManager>().Initialize();
|
IoCManager.Resolve<GhostKickManager>().Initialize();
|
||||||
|
IoCManager.Resolve<ExtendedDisconnectInformationManager>().Initialize();
|
||||||
|
|
||||||
IoCManager.InjectDependencies(this);
|
IoCManager.InjectDependencies(this);
|
||||||
|
|
||||||
@@ -138,6 +139,7 @@ namespace Content.Client.Entry
|
|||||||
{
|
{
|
||||||
IoCManager.Resolve<IMapManager>().CreateNewMapEntity(MapId.Nullspace);
|
IoCManager.Resolve<IMapManager>().CreateNewMapEntity(MapId.Nullspace);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ using Content.Client.GhostKick;
|
|||||||
using Content.Client.HUD;
|
using Content.Client.HUD;
|
||||||
using Content.Client.Info;
|
using Content.Client.Info;
|
||||||
using Content.Client.Items.Managers;
|
using Content.Client.Items.Managers;
|
||||||
|
using Content.Client.Launcher;
|
||||||
using Content.Client.Module;
|
using Content.Client.Module;
|
||||||
using Content.Client.Parallax.Managers;
|
using Content.Client.Parallax.Managers;
|
||||||
using Content.Client.Preferences;
|
using Content.Client.Preferences;
|
||||||
@@ -45,6 +46,7 @@ namespace Content.Client.IoC
|
|||||||
IoCManager.Register<IGamePrototypeLoadManager, GamePrototypeLoadManager>();
|
IoCManager.Register<IGamePrototypeLoadManager, GamePrototypeLoadManager>();
|
||||||
IoCManager.Register<NetworkResourceManager>();
|
IoCManager.Register<NetworkResourceManager>();
|
||||||
IoCManager.Register<GhostKickManager>();
|
IoCManager.Register<GhostKickManager>();
|
||||||
|
IoCManager.Register<ExtendedDisconnectInformationManager>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
using System;
|
||||||
|
using Robust.Client;
|
||||||
|
using Robust.Client.UserInterface;
|
||||||
|
using Robust.Shared.IoC;
|
||||||
|
using Robust.Shared.Log;
|
||||||
|
using Robust.Shared.Network;
|
||||||
|
|
||||||
|
namespace Content.Client.Launcher;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// So apparently the way that disconnect information is shipped around is really indirect.
|
||||||
|
/// But honestly, given that content might have additional flags (i.e. hide disconnect button for bans)?
|
||||||
|
/// This is responsible for collecting any extended disconnect information.
|
||||||
|
/// </summary>
|
||||||
|
public sealed class ExtendedDisconnectInformationManager
|
||||||
|
{
|
||||||
|
[Dependency] private readonly IClientNetManager _clientNetManager = default!;
|
||||||
|
|
||||||
|
private NetDisconnectedArgs? _lastNetDisconnectedArgs = null;
|
||||||
|
|
||||||
|
public NetDisconnectedArgs? LastNetDisconnectedArgs
|
||||||
|
{
|
||||||
|
get => _lastNetDisconnectedArgs;
|
||||||
|
private set
|
||||||
|
{
|
||||||
|
_lastNetDisconnectedArgs = value;
|
||||||
|
LastNetDisconnectedArgsChanged?.Invoke(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// BE CAREFUL!
|
||||||
|
// This may fire at an arbitrary time before or after whatever code that needs it.
|
||||||
|
public event Action<NetDisconnectedArgs?>? LastNetDisconnectedArgsChanged;
|
||||||
|
|
||||||
|
public void Initialize()
|
||||||
|
{
|
||||||
|
_clientNetManager.Disconnect += OnNetDisconnect;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnNetDisconnect(object? sender, NetDisconnectedArgs args)
|
||||||
|
{
|
||||||
|
LastNetDisconnectedArgs = args;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -2,6 +2,7 @@ using System;
|
|||||||
using Robust.Client;
|
using Robust.Client;
|
||||||
using Robust.Client.UserInterface;
|
using Robust.Client.UserInterface;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
|
using Robust.Shared.Log;
|
||||||
using Robust.Shared.Network;
|
using Robust.Shared.Network;
|
||||||
|
|
||||||
namespace Content.Client.Launcher
|
namespace Content.Client.Launcher
|
||||||
@@ -70,6 +71,12 @@ namespace Content.Client.Launcher
|
|||||||
|
|
||||||
private void OnConnectFailed(object? _, NetConnectFailArgs args)
|
private void OnConnectFailed(object? _, NetConnectFailArgs args)
|
||||||
{
|
{
|
||||||
|
if (args.RedialFlag)
|
||||||
|
{
|
||||||
|
// We've just *attempted* to connect and we've been told we need to redial, so do it.
|
||||||
|
// Result deliberately discarded.
|
||||||
|
Redial();
|
||||||
|
}
|
||||||
ConnectFailReason = args.Reason;
|
ConnectFailReason = args.Reason;
|
||||||
CurrentPage = Page.ConnectFailed;
|
CurrentPage = Page.ConnectFailed;
|
||||||
}
|
}
|
||||||
@@ -88,6 +95,27 @@ namespace Content.Client.Launcher
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool Redial()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (_gameController.LaunchState.Ss14Address != null)
|
||||||
|
{
|
||||||
|
_gameController.Redial(_gameController.LaunchState.Ss14Address);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Logger.InfoS("launcher-ui", $"Redial not possible, no Ss14Address");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.ErrorS("launcher-ui", $"Redial exception: {ex}");
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public void Exit()
|
public void Exit()
|
||||||
{
|
{
|
||||||
_gameController.Shutdown("Exit button pressed");
|
_gameController.Shutdown("Exit button pressed");
|
||||||
|
|||||||
@@ -33,6 +33,10 @@
|
|||||||
<Button Name="ReconnectButton" Text="{Loc 'connecting-reconnect'}"
|
<Button Name="ReconnectButton" Text="{Loc 'connecting-reconnect'}"
|
||||||
HorizontalAlignment="Center"
|
HorizontalAlignment="Center"
|
||||||
VerticalExpand="True" VerticalAlignment="Bottom" />
|
VerticalExpand="True" VerticalAlignment="Bottom" />
|
||||||
|
<Button Name="RedialButton" Text="{Loc 'connecting-redial'}"
|
||||||
|
Disabled="True"
|
||||||
|
HorizontalAlignment="Center"
|
||||||
|
VerticalExpand="True" VerticalAlignment="Bottom" />
|
||||||
</BoxContainer>
|
</BoxContainer>
|
||||||
</Control>
|
</Control>
|
||||||
<Label Name="ConnectingAddress" StyleClasses="LabelSubText" HorizontalAlignment="Center" />
|
<Label Name="ConnectingAddress" StyleClasses="LabelSubText" HorizontalAlignment="Center" />
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using Robust.Client.UserInterface;
|
|||||||
using Robust.Client.UserInterface.Controls;
|
using Robust.Client.UserInterface.Controls;
|
||||||
using Robust.Client.UserInterface.XAML;
|
using Robust.Client.UserInterface.XAML;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
|
using Robust.Shared.Timing;
|
||||||
using Robust.Shared.Localization;
|
using Robust.Shared.Localization;
|
||||||
using Robust.Shared.Network;
|
using Robust.Shared.Network;
|
||||||
|
|
||||||
@@ -12,7 +13,9 @@ namespace Content.Client.Launcher
|
|||||||
[GenerateTypedNameReferences]
|
[GenerateTypedNameReferences]
|
||||||
public sealed partial class LauncherConnectingGui : Control
|
public sealed partial class LauncherConnectingGui : Control
|
||||||
{
|
{
|
||||||
|
private const float RedialWaitTimeSeconds = 15f;
|
||||||
private readonly LauncherConnecting _state;
|
private readonly LauncherConnecting _state;
|
||||||
|
private float _redialWaitTime = RedialWaitTimeSeconds;
|
||||||
|
|
||||||
public LauncherConnectingGui(LauncherConnecting state)
|
public LauncherConnectingGui(LauncherConnecting state)
|
||||||
{
|
{
|
||||||
@@ -25,6 +28,12 @@ namespace Content.Client.Launcher
|
|||||||
Stylesheet = IoCManager.Resolve<IStylesheetManager>().SheetSpace;
|
Stylesheet = IoCManager.Resolve<IStylesheetManager>().SheetSpace;
|
||||||
|
|
||||||
ReconnectButton.OnPressed += _ => _state.RetryConnect();
|
ReconnectButton.OnPressed += _ => _state.RetryConnect();
|
||||||
|
// Redial shouldn't fail, but if it does, try a reconnect (maybe we're being run from debug)
|
||||||
|
RedialButton.OnPressed += _ =>
|
||||||
|
{
|
||||||
|
if (!_state.Redial())
|
||||||
|
_state.RetryConnect();
|
||||||
|
};
|
||||||
RetryButton.OnPressed += _ => _state.RetryConnect();
|
RetryButton.OnPressed += _ => _state.RetryConnect();
|
||||||
ExitButton.OnPressed += _ => _state.Exit();
|
ExitButton.OnPressed += _ => _state.Exit();
|
||||||
|
|
||||||
@@ -37,6 +46,11 @@ namespace Content.Client.Launcher
|
|||||||
state.ConnectionStateChanged += ConnectionStateChanged;
|
state.ConnectionStateChanged += ConnectionStateChanged;
|
||||||
|
|
||||||
ConnectionStateChanged(state.ConnectionState);
|
ConnectionStateChanged(state.ConnectionState);
|
||||||
|
|
||||||
|
// Redial flag setup
|
||||||
|
var edim = IoCManager.Resolve<ExtendedDisconnectInformationManager>();
|
||||||
|
edim.LastNetDisconnectedArgsChanged += LastNetDisconnectedArgsChanged;
|
||||||
|
LastNetDisconnectedArgsChanged(edim.LastNetDisconnectedArgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ConnectFailReasonChanged(string? reason)
|
private void ConnectFailReasonChanged(string? reason)
|
||||||
@@ -46,6 +60,29 @@ namespace Content.Client.Launcher
|
|||||||
: Loc.GetString("connecting-fail-reason", ("reason", reason));
|
: Loc.GetString("connecting-fail-reason", ("reason", reason));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void LastNetDisconnectedArgsChanged(NetDisconnectedArgs? args)
|
||||||
|
{
|
||||||
|
var redialFlag = args?.RedialFlag ?? false;
|
||||||
|
RedialButton.Visible = redialFlag;
|
||||||
|
ReconnectButton.Visible = !redialFlag;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void FrameUpdate(FrameEventArgs args)
|
||||||
|
{
|
||||||
|
base.FrameUpdate(args);
|
||||||
|
_redialWaitTime -= args.DeltaSeconds;
|
||||||
|
if (_redialWaitTime <= 0)
|
||||||
|
{
|
||||||
|
RedialButton.Disabled = false;
|
||||||
|
RedialButton.Text = Loc.GetString("connecting-redial");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
RedialButton.Disabled = true;
|
||||||
|
RedialButton.Text = Loc.GetString("connecting-redial-wait", ("time", _redialWaitTime));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void OnPageChanged(LauncherConnecting.Page page)
|
private void OnPageChanged(LauncherConnecting.Page page)
|
||||||
{
|
{
|
||||||
ConnectingStatus.Visible = page == LauncherConnecting.Page.Connecting;
|
ConnectingStatus.Visible = page == LauncherConnecting.Page.Connecting;
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ connecting-title = Space Station 14
|
|||||||
connecting-exit = Exit
|
connecting-exit = Exit
|
||||||
connecting-retry = Retry
|
connecting-retry = Retry
|
||||||
connecting-reconnect = Reconnect
|
connecting-reconnect = Reconnect
|
||||||
|
connecting-redial = Relaunch
|
||||||
|
connecting-redial-wait = Please wait: { TOSTRING($time, "G3") }
|
||||||
connecting-in-progress = Connecting to server...
|
connecting-in-progress = Connecting to server...
|
||||||
connecting-disconnected = Disconnected from server:
|
connecting-disconnected = Disconnected from server:
|
||||||
connecting-tip = Don't die!
|
connecting-tip = Don't die!
|
||||||
|
|||||||
Reference in New Issue
Block a user