From 93497e484fd9eb97dc353d3afdc8977037f56764 Mon Sep 17 00:00:00 2001
From: Repo <47093363+Titian3@users.noreply.github.com>
Date: Wed, 21 Aug 2024 09:31:09 +1200
Subject: [PATCH] Copy button for ban/disconnect reason (#30760)
* Copy button for connection messages on failed connections and ban hit attempts
* loc
* better sepperation layout
* consistent styling.
* Fix loc var name
* Reconnect button back.
* Move clipboard dependency out to the params.
* open buttons so they look a bit better.
---
Content.Client/Launcher/LauncherConnecting.cs | 3 +-
.../Launcher/LauncherConnectingGui.xaml | 35 ++++++++++++++-----
.../Launcher/LauncherConnectingGui.xaml.cs | 27 ++++++++++++--
.../en-US/launcher/launcher-connecting.ftl | 1 +
4 files changed, 54 insertions(+), 12 deletions(-)
diff --git a/Content.Client/Launcher/LauncherConnecting.cs b/Content.Client/Launcher/LauncherConnecting.cs
index 29b241ae5d..33d31cc52d 100644
--- a/Content.Client/Launcher/LauncherConnecting.cs
+++ b/Content.Client/Launcher/LauncherConnecting.cs
@@ -19,6 +19,7 @@ namespace Content.Client.Launcher
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IConfigurationManager _cfg = default!;
+ [Dependency] private readonly IClipboardManager _clipboard = default!;
private LauncherConnectingGui? _control;
@@ -58,7 +59,7 @@ namespace Content.Client.Launcher
protected override void Startup()
{
- _control = new LauncherConnectingGui(this, _random, _prototypeManager, _cfg);
+ _control = new LauncherConnectingGui(this, _random, _prototypeManager, _cfg, _clipboard);
_userInterfaceManager.StateRoot.AddChild(_control);
diff --git a/Content.Client/Launcher/LauncherConnectingGui.xaml b/Content.Client/Launcher/LauncherConnectingGui.xaml
index 3734fa5b3a..2cb349d4e7 100644
--- a/Content.Client/Launcher/LauncherConnectingGui.xaml
+++ b/Content.Client/Launcher/LauncherConnectingGui.xaml
@@ -18,21 +18,38 @@
-
-
+
-
+
+
+
+
-
+
-
+
+
+
+
diff --git a/Content.Client/Launcher/LauncherConnectingGui.xaml.cs b/Content.Client/Launcher/LauncherConnectingGui.xaml.cs
index 5015b710eb..cf89f98095 100644
--- a/Content.Client/Launcher/LauncherConnectingGui.xaml.cs
+++ b/Content.Client/Launcher/LauncherConnectingGui.xaml.cs
@@ -28,14 +28,16 @@ namespace Content.Client.Launcher
private readonly IRobustRandom _random;
private readonly IPrototypeManager _prototype;
private readonly IConfigurationManager _cfg;
+ private readonly IClipboardManager _clipboard;
public LauncherConnectingGui(LauncherConnecting state, IRobustRandom random,
- IPrototypeManager prototype, IConfigurationManager config)
+ IPrototypeManager prototype, IConfigurationManager config, IClipboardManager clipboard)
{
_state = state;
_random = random;
_prototype = prototype;
_cfg = config;
+ _clipboard = clipboard;
RobustXamlLoader.Load(this);
@@ -44,8 +46,11 @@ namespace Content.Client.Launcher
Stylesheet = IoCManager.Resolve().SheetSpace;
ChangeLoginTip();
- ReconnectButton.OnPressed += ReconnectButtonPressed;
RetryButton.OnPressed += ReconnectButtonPressed;
+ ReconnectButton.OnPressed += ReconnectButtonPressed;
+
+ CopyButton.OnPressed += CopyButtonPressed;
+ CopyButtonDisconnected.OnPressed += CopyButtonDisconnectedPressed;
ExitButton.OnPressed += _ => _state.Exit();
var addr = state.Address;
@@ -78,6 +83,24 @@ namespace Content.Client.Launcher
_state.RetryConnect();
}
+ private void CopyButtonPressed(BaseButton.ButtonEventArgs args)
+ {
+ CopyText(ConnectFailReason.Text);
+ }
+
+ private void CopyButtonDisconnectedPressed(BaseButton.ButtonEventArgs args)
+ {
+ CopyText(DisconnectReason.Text);
+ }
+
+ private void CopyText(string? text)
+ {
+ if (!string.IsNullOrEmpty(text))
+ {
+ _clipboard.SetText(text);
+ }
+ }
+
private void ConnectFailReasonChanged(string? reason)
{
ConnectFailReason.SetMessage(reason == null
diff --git a/Resources/Locale/en-US/launcher/launcher-connecting.ftl b/Resources/Locale/en-US/launcher/launcher-connecting.ftl
index f9dff0c46a..b2d144b249 100644
--- a/Resources/Locale/en-US/launcher/launcher-connecting.ftl
+++ b/Resources/Locale/en-US/launcher/launcher-connecting.ftl
@@ -4,6 +4,7 @@ connecting-title = Space Station 14
connecting-exit = Exit
connecting-retry = Retry
connecting-reconnect = Reconnect
+connecting-copy = Copy Message
connecting-redial = Relaunch
connecting-redial-wait = Please wait: { TOSTRING($time, "G3") }
connecting-in-progress = Connecting to server...
--
2.51.2