Viewport improvements (#3765)
This commit is contained in:
committed by
GitHub
parent
8e2fc49357
commit
147a54c642
62
Content.Client/UserInterface/LauncherConnectingGui.xaml.cs
Normal file
62
Content.Client/UserInterface/LauncherConnectingGui.xaml.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
using Content.Client.State;
|
||||
using Content.Client.UserInterface.Stylesheets;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Network;
|
||||
|
||||
namespace Content.Client.UserInterface
|
||||
{
|
||||
[GenerateTypedNameReferences]
|
||||
public sealed partial class LauncherConnectingGui : Control
|
||||
{
|
||||
private readonly LauncherConnecting _state;
|
||||
|
||||
public LauncherConnectingGui(LauncherConnecting state)
|
||||
{
|
||||
_state = state;
|
||||
|
||||
RobustXamlLoader.Load(this);
|
||||
|
||||
LayoutContainer.SetAnchorPreset(this, LayoutContainer.LayoutPreset.Wide);
|
||||
|
||||
Stylesheet = IoCManager.Resolve<IStylesheetManager>().SheetSpace;
|
||||
|
||||
ReconnectButton.OnPressed += _ => _state.RetryConnect();
|
||||
RetryButton.OnPressed += _ => _state.RetryConnect();
|
||||
ExitButton.OnPressed += _ => _state.Exit();
|
||||
|
||||
var addr = state.Address;
|
||||
if (addr != null)
|
||||
ConnectingAddress.Text = addr;
|
||||
|
||||
state.PageChanged += OnPageChanged;
|
||||
state.ConnectFailReasonChanged += ConnectFailReasonChanged;
|
||||
state.ConnectionStateChanged += ConnectionStateChanged;
|
||||
|
||||
ConnectionStateChanged(state.ConnectionState);
|
||||
}
|
||||
|
||||
private void ConnectFailReasonChanged(string? reason)
|
||||
{
|
||||
ConnectFailReason.Text = reason == null
|
||||
? null
|
||||
: Loc.GetString("connecting-fail-reason", ("reason", reason));
|
||||
}
|
||||
|
||||
private void OnPageChanged(LauncherConnecting.Page page)
|
||||
{
|
||||
ConnectingStatus.Visible = page == LauncherConnecting.Page.Connecting;
|
||||
ConnectFail.Visible = page == LauncherConnecting.Page.ConnectFailed;
|
||||
Disconnected.Visible = page == LauncherConnecting.Page.Disconnected;
|
||||
}
|
||||
|
||||
private void ConnectionStateChanged(ClientConnectionState state)
|
||||
{
|
||||
ConnectStatus.Text = Loc.GetString($"connecting-state-{state}");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user