]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Copy button for ban/disconnect reason (#30760)
authorRepo <47093363+Titian3@users.noreply.github.com>
Tue, 20 Aug 2024 21:31:09 +0000 (09:31 +1200)
committerGitHub <noreply@github.com>
Tue, 20 Aug 2024 21:31:09 +0000 (23:31 +0200)
* 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
Content.Client/Launcher/LauncherConnectingGui.xaml
Content.Client/Launcher/LauncherConnectingGui.xaml.cs
Resources/Locale/en-US/launcher/launcher-connecting.ftl

index 29b241ae5df35e0e2924540c8dabc6e4cfc0ff78..33d31cc52d85f3fbdea268801ea96b6149bac6ec 100644 (file)
@@ -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);
 
index 3734fa5b3adc56bee2f7352f9e9bee154dcc7bf4..2cb349d4e77bdc209411bd3751f38ffd42d7f442 100644 (file)
                 <Control VerticalExpand="True" Margin="0 0 0 8">
                     <BoxContainer Orientation="Vertical" Name="ConnectingStatus">
                         <Label Text="{Loc 'connecting-in-progress'}" Align="Center" />
-                        <!-- Who the fuck named these cont- oh wait I did -->
                         <Label Name="ConnectStatus" StyleClasses="LabelSubText" Align="Center" />
                     </BoxContainer>
-                    <BoxContainer Orientation="Vertical" Name="ConnectFail" Visible="False">
+                    <BoxContainer Orientation="Vertical" Name="ConnectFail" Visible="False" SeparationOverride="10">
                         <RichTextLabel Name="ConnectFailReason" VerticalAlignment="Stretch"/>
-                        <Button Name="RetryButton" Text="{Loc 'connecting-retry'}"
-                                HorizontalAlignment="Center"
-                                VerticalExpand="True" VerticalAlignment="Bottom" />
+                        <BoxContainer Orientation="Horizontal" Align="Center">
+                            <Button Name="RetryButton"
+                                    Text="{Loc 'connecting-retry'}"
+                                    HorizontalAlignment="Center"
+                                    VerticalAlignment="Bottom"
+                                    StyleClasses="OpenRight"/>
+                            <Button Name="CopyButton"
+                                    Text="{Loc 'connecting-copy'}"
+                                    HorizontalAlignment="Center"
+                                    VerticalAlignment="Bottom"
+                                    StyleClasses="OpenLeft"/>
+                        </BoxContainer>
                     </BoxContainer>
-                    <BoxContainer Orientation="Vertical" Name="Disconnected">
+                    <BoxContainer Orientation="Vertical" Name="Disconnected" Visible="False" SeparationOverride="10">
                         <Label Text="{Loc 'connecting-disconnected'}" Align="Center" />
                         <Label Name="DisconnectReason" Align="Center" />
-                        <Button Name="ReconnectButton" Text="{Loc 'connecting-reconnect'}"
-                                HorizontalAlignment="Center"
-                                VerticalExpand="True" VerticalAlignment="Bottom" />
+                        <BoxContainer Orientation="Horizontal" Align="Center" VerticalAlignment="Bottom">
+                            <Button Name="ReconnectButton"
+                                    Text="{Loc 'connecting-reconnect'}"
+                                    HorizontalAlignment="Center"
+                                    VerticalAlignment="Bottom"
+                                    StyleClasses="OpenRight"/>
+                            <Button Name="CopyButtonDisconnected"
+                                    Text="{Loc 'connecting-copy'}"
+                                    HorizontalAlignment="Center"
+                                    VerticalAlignment="Bottom"
+                                    StyleClasses="OpenLeft"/>
+                        </BoxContainer>
                     </BoxContainer>
                 </Control>
                 <Label Name="ConnectingAddress" StyleClasses="LabelSubText" HorizontalAlignment="Center" />
index 5015b710eb48a11f74d8303e30f67b24bef2cf89..cf89f98095e69916fea93e1adec73c2aa3378621 100644 (file)
@@ -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<IStylesheetManager>().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
index f9dff0c46a65d1d763668910f91b6eb57a21bada..b2d144b249811ee656bc1e6541f773579af7a2b9 100644 (file)
@@ -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...