From b41ee53dbdb636bf694f7edcd1040c2dcbdd8c0c Mon Sep 17 00:00:00 2001 From: beck-thompson <107373427+beck-thompson@users.noreply.github.com> Date: Wed, 16 Apr 2025 18:02:41 -0700 Subject: [PATCH] Cleanup various admin buttons (#36312) cleanup --- .../Administration/UI/AdminUIHelpers.cs | 59 ------------------- .../UI/Bwoink/BwoinkControl.xaml | 7 ++- .../UI/Bwoink/BwoinkControl.xaml.cs | 11 ---- .../UI/Notes/AdminNotesLinePopup.xaml | 5 +- .../UI/Tabs/AdminTab/PlayerActionsWindow.xaml | 5 +- .../Tabs/AdminTab/PlayerActionsWindow.xaml.cs | 10 ---- .../Tabs/ObjectsTab/ObjectsTabEntry.xaml.cs | 10 +--- 7 files changed, 11 insertions(+), 96 deletions(-) delete mode 100644 Content.Client/Administration/UI/AdminUIHelpers.cs diff --git a/Content.Client/Administration/UI/AdminUIHelpers.cs b/Content.Client/Administration/UI/AdminUIHelpers.cs deleted file mode 100644 index 89ab33e931..0000000000 --- a/Content.Client/Administration/UI/AdminUIHelpers.cs +++ /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 confirmations) - { - if (confirmations.Remove(button, out var data)) - { - ResetButton(button, data); - return true; - } - - return false; - } - - public static void RemoveAllConfirms(Dictionary confirmations) - { - foreach (var (button, confirmation) in confirmations) - { - ResetButton(button, confirmation); - } - - confirmations.Clear(); - } - - public static bool TryConfirm(Button button, Dictionary 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); diff --git a/Content.Client/Administration/UI/Bwoink/BwoinkControl.xaml b/Content.Client/Administration/UI/Bwoink/BwoinkControl.xaml index d53101f68e..2c27fdd2ce 100644 --- a/Content.Client/Administration/UI/Bwoink/BwoinkControl.xaml +++ b/Content.Client/Administration/UI/Bwoink/BwoinkControl.xaml @@ -1,6 +1,7 @@  + xmlns:cc="clr-namespace:Content.Client.Administration.UI.CustomControls" + xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"> @@ -18,9 +19,9 @@