]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
add confirmation to the delete button in objects tab (#30946)
authorMilon <plmilonpl@gmail.com>
Sat, 17 Aug 2024 16:05:17 +0000 (18:05 +0200)
committerGitHub <noreply@github.com>
Sat, 17 Aug 2024 16:05:17 +0000 (12:05 -0400)
ui shitcode

Content.Client/Administration/UI/Tabs/ObjectsTab/ObjectsTabEntry.xaml.cs

index 29774bb587e4f3d02f8718d1499a591cf97c0a2f..ee5d3701f589807aff39430c65ed1706975b00b4 100644 (file)
@@ -1,4 +1,4 @@
-using Content.Client.Administration.Managers;
+using Content.Client.Administration.Managers;
 using Robust.Client.AutoGenerated;
 using Robust.Client.Graphics;
 using Robust.Client.UserInterface.Controls;
@@ -13,6 +13,7 @@ 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)
     {
@@ -27,6 +28,13 @@ public sealed partial class ObjectsTabEntry : PanelContainer
         DeleteButton.Disabled = !manager.CanCommand("delete");
 
         TeleportButton.OnPressed += _ => OnTeleport?.Invoke(nent);
-        DeleteButton.OnPressed += _ => OnDelete?.Invoke(nent);
+        DeleteButton.OnPressed += _ =>
+        {
+            if (!AdminUIHelpers.TryConfirm(DeleteButton, _confirmations))
+            {
+                return;
+            }
+            OnDelete?.Invoke(nent);
+        };
     }
 }