]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Cleanup various admin buttons (#36312)
authorbeck-thompson <107373427+beck-thompson@users.noreply.github.com>
Thu, 17 Apr 2025 01:02:41 +0000 (18:02 -0700)
committerGitHub <noreply@github.com>
Thu, 17 Apr 2025 01:02:41 +0000 (03:02 +0200)
cleanup

Content.Client/Administration/UI/AdminUIHelpers.cs [deleted file]
Content.Client/Administration/UI/Bwoink/BwoinkControl.xaml
Content.Client/Administration/UI/Bwoink/BwoinkControl.xaml.cs
Content.Client/Administration/UI/Notes/AdminNotesLinePopup.xaml
Content.Client/Administration/UI/Tabs/AdminTab/PlayerActionsWindow.xaml
Content.Client/Administration/UI/Tabs/AdminTab/PlayerActionsWindow.xaml.cs
Content.Client/Administration/UI/Tabs/ObjectsTab/ObjectsTabEntry.xaml.cs

diff --git a/Content.Client/Administration/UI/AdminUIHelpers.cs b/Content.Client/Administration/UI/AdminUIHelpers.cs
deleted file mode 100644 (file)
index 89ab33e..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-using System.Threading;
-using Content.Client.Stylesheets;
-using Robust.Client.UserInterface.Controls;
-using Timer = Robust.Shared.Timing.Timer;
-
-namespace Content.Client.Administration.UI;
-
-public static class AdminUIHelpers
-{
-    private static void ResetButton(Button button, ConfirmationData data)
-    {
-        data.Cancellation.Cancel();
-        button.ModulateSelfOverride = null;
-        button.Text = data.OriginalText;
-    }
-
-    public static bool RemoveConfirm(Button button, Dictionary<Button, ConfirmationData> confirmations)
-    {
-        if (confirmations.Remove(button, out var data))
-        {
-            ResetButton(button, data);
-            return true;
-        }
-
-        return false;
-    }
-
-    public static void RemoveAllConfirms(Dictionary<Button, ConfirmationData> confirmations)
-    {
-        foreach (var (button, confirmation) in confirmations)
-        {
-            ResetButton(button, confirmation);
-        }
-
-        confirmations.Clear();
-    }
-
-    public static bool TryConfirm(Button button, Dictionary<Button, ConfirmationData> confirmations)
-    {
-        if (RemoveConfirm(button, confirmations))
-            return true;
-
-        var data = new ConfirmationData(new CancellationTokenSource(), button.Text);
-        confirmations[button] = data;
-
-        Timer.Spawn(TimeSpan.FromSeconds(5), () =>
-        {
-            confirmations.Remove(button);
-            button.ModulateSelfOverride = null;
-            button.Text = data.OriginalText;
-        }, data.Cancellation.Token);
-
-        button.ModulateSelfOverride = StyleNano.ButtonColorCautionDefault;
-        button.Text = Loc.GetString("admin-player-actions-confirm");
-        return false;
-    }
-}
-
-public readonly record struct ConfirmationData(CancellationTokenSource Cancellation, string? OriginalText);
index d53101f68e9f673091037b5b217114b23b4d416a..2c27fdd2ce3a67075e0a93af0ddeba71fa81ecf5 100644 (file)
@@ -1,6 +1,7 @@
 <Control
     xmlns="https://spacestation14.io"
-    xmlns:cc="clr-namespace:Content.Client.Administration.UI.CustomControls">
+    xmlns:cc="clr-namespace:Content.Client.Administration.UI.CustomControls"
+    xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls">
     <PanelContainer StyleClasses="BackgroundDark">
         <SplitContainer Orientation="Vertical" ResizeMode="NotResizable">
             <SplitContainer Orientation="Horizontal" VerticalExpand="True">
@@ -18,9 +19,9 @@
                 <Control HorizontalExpand="True" />
                 <Button Visible="False" Name="Bans" Text="{Loc 'admin-player-actions-bans'}" StyleClasses="OpenRight" />
                 <Button Visible="False" Name="Notes" Text="{Loc 'admin-player-actions-notes'}" StyleClasses="OpenBoth" />
-                <Button Visible="False" Name="Kick" Text="{Loc 'admin-player-actions-kick'}" StyleClasses="OpenBoth" />
+                <controls:ConfirmButton Visible="False" Name="Kick" Text="{Loc 'admin-player-actions-kick'}" ConfirmationText="{Loc 'admin-player-actions-confirm'}" StyleClasses="OpenBoth" />
                 <Button Visible="False" Name="Ban" Text="{Loc 'admin-player-actions-ban'}" StyleClasses="OpenBoth" />
-                <Button Visible="False" Name="Respawn" Text="{Loc 'admin-player-actions-respawn'}" StyleClasses="OpenBoth" />
+                <controls:ConfirmButton Visible="False" Name="Respawn" Text="{Loc 'admin-player-actions-respawn'}" ConfirmationText="{Loc 'admin-player-actions-confirm'}" StyleClasses="OpenBoth" />
                 <Button Visible="False" Name="Follow" Text="{Loc 'admin-player-actions-follow'}" StyleClasses="OpenLeft" />
             </BoxContainer>
         </SplitContainer>
index 973f1a090b7a7b6b5ba90fb5462947ffb877dace..6ff07f6cbde093abca1a32d3239f29221494e8d6 100644 (file)
@@ -29,7 +29,6 @@ namespace Content.Client.Administration.UI.Bwoink
         public AdminAHelpUIHandler AHelpHelper = default!;
 
         private PlayerInfo? _currentPlayer;
-        private readonly Dictionary<Button, ConfirmationData> _confirmations = new();
 
         public BwoinkControl()
         {
@@ -178,11 +177,6 @@ namespace Content.Client.Administration.UI.Bwoink
 
             Kick.OnPressed += _ =>
             {
-                if (!AdminUIHelpers.TryConfirm(Kick, _confirmations))
-                {
-                    return;
-                }
-
                 // TODO: Reason field
                 if (_currentPlayer is not null)
                     _console.ExecuteCommand($"kick \"{_currentPlayer.Username}\"");
@@ -196,11 +190,6 @@ namespace Content.Client.Administration.UI.Bwoink
 
             Respawn.OnPressed += _ =>
             {
-                if (!AdminUIHelpers.TryConfirm(Respawn, _confirmations))
-                {
-                    return;
-                }
-
                 if (_currentPlayer is not null)
                     _console.ExecuteCommand($"respawn \"{_currentPlayer.Username}\"");
             };
index 4a3c0ef7acee6ca0c00e9548371120e46c320dc1..8e216b1ffe7250bd48a7a30de9cad0ec9d145f16 100644 (file)
@@ -1,5 +1,6 @@
 <Popup xmlns="https://spacestation14.io"
-       xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client">
+       xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client"
+       xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls">
     <PanelContainer>
         <PanelContainer.PanelOverride>
             <gfx:StyleBoxFlat BorderThickness="2" BorderColor="#18181B" BackgroundColor="#25252a"/>
@@ -19,7 +20,7 @@
             <BoxContainer Orientation="Horizontal">
                 <Button Name="EditButton" Text="{Loc admin-notes-edit}"/>
                 <Control HorizontalExpand="True"/>
-                <Button Name="DeleteButton" Text="{Loc admin-notes-delete}" HorizontalAlignment="Right"/>
+                <controls:ConfirmButton Name="DeleteButton" Text="{Loc admin-notes-delete}" ConfirmationText="{Loc 'admin-player-actions-confirm'}" HorizontalAlignment="Right"/>
             </BoxContainer>
         </BoxContainer>
     </PanelContainer>
index 3df57de57b30f61b17216cb4c2fb7816e7183109..10718c25a529ef92f1c2e3a3961d0bbd7ba89531 100644 (file)
@@ -1,6 +1,7 @@
 <DefaultWindow
     xmlns="https://spacestation14.io"
     xmlns:cc="clr-namespace:Content.Client.Administration.UI.CustomControls"
+    xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
     Title="{Loc admin-player-actions-window-title}" MinSize="425 272">
     <BoxContainer Orientation="Vertical">
         <BoxContainer Orientation="Horizontal">
@@ -10,9 +11,9 @@
         </BoxContainer>
         <cc:PlayerListControl Name="PlayerList" VerticalExpand="True" />
         <BoxContainer Orientation="Horizontal">
-            <Button Name="SubmitKickButton" Text="{Loc admin-player-actions-kick}" Disabled="True"/>
+            <controls:ConfirmButton Name="SubmitKickButton" Text="{Loc admin-player-actions-kick}" ConfirmationText="{Loc 'admin-player-actions-confirm'}" Disabled="True"/>
             <Button Name="SubmitAHelpButton" Text="{Loc admin-player-actions-ahelp}" Disabled="True"/>
-            <Button Name="SubmitRespawnButton" Text="{Loc admin-player-actions-respawn}" Disabled="True"/>
+            <controls:ConfirmButton Name="SubmitRespawnButton" Text="{Loc admin-player-actions-respawn}" ConfirmationText="{Loc 'admin-player-actions-confirm'}" Disabled="True"/>
         </BoxContainer>
     </BoxContainer>
 </DefaultWindow>
index 6f960aaae19fc87fda5fce3f4e9bb0888472d4a2..2216b6dfb0620b213d40f1a7ae7c060f895c0104 100644 (file)
@@ -14,7 +14,6 @@ namespace Content.Client.Administration.UI.Tabs.AdminTab
     public sealed partial class PlayerActionsWindow : DefaultWindow
     {
         private PlayerInfo? _selectedPlayer;
-        private readonly Dictionary<Button, ConfirmationData> _confirmations = new();
 
         public PlayerActionsWindow()
         {
@@ -28,9 +27,6 @@ namespace Content.Client.Administration.UI.Tabs.AdminTab
 
         private void OnListOnOnSelectionChanged(PlayerInfo? obj)
         {
-            if (_selectedPlayer != obj)
-                AdminUIHelpers.RemoveAllConfirms(_confirmations);
-
             _selectedPlayer = obj;
             var disableButtons = _selectedPlayer == null;
             SubmitKickButton.Disabled = disableButtons;
@@ -43,9 +39,6 @@ namespace Content.Client.Administration.UI.Tabs.AdminTab
             if (_selectedPlayer == null)
                 return;
 
-            if (!AdminUIHelpers.TryConfirm(SubmitKickButton, _confirmations))
-                return;
-
             IoCManager.Resolve<IClientConsoleHost>().ExecuteCommand(
                 $"kick \"{_selectedPlayer.Username}\" \"{CommandParsing.Escape(ReasonLine.Text)}\"");
         }
@@ -64,9 +57,6 @@ namespace Content.Client.Administration.UI.Tabs.AdminTab
             if (_selectedPlayer == null)
                 return;
 
-            if (!AdminUIHelpers.TryConfirm(SubmitRespawnButton, _confirmations))
-                return;
-
             IoCManager.Resolve<IClientConsoleHost>().ExecuteCommand(
                 $"respawn \"{_selectedPlayer.Username}\"");
         }
index ee5d3701f589807aff39430c65ed1706975b00b4..8e292e4d3407c0faa3a410995991da213fd17344 100644 (file)
@@ -13,7 +13,6 @@ public sealed partial class ObjectsTabEntry : PanelContainer
 
     public Action<NetEntity>? OnTeleport;
     public Action<NetEntity>? OnDelete;
-    private readonly Dictionary<Button, ConfirmationData> _confirmations = new();
 
     public ObjectsTabEntry(IClientAdminManager manager, string name, NetEntity nent, StyleBox styleBox)
     {
@@ -28,13 +27,6 @@ public sealed partial class ObjectsTabEntry : PanelContainer
         DeleteButton.Disabled = !manager.CanCommand("delete");
 
         TeleportButton.OnPressed += _ => OnTeleport?.Invoke(nent);
-        DeleteButton.OnPressed += _ =>
-        {
-            if (!AdminUIHelpers.TryConfirm(DeleteButton, _confirmations))
-            {
-                return;
-            }
-            OnDelete?.Invoke(nent);
-        };
+        DeleteButton.OnPressed += _ => OnDelete?.Invoke(nent);
     }
 }