]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Teleport and delete buttons in objects tab. (#28914)
authorVigers Ray <60344369+VigersRay@users.noreply.github.com>
Thu, 8 Aug 2024 11:00:08 +0000 (14:00 +0300)
committerGitHub <noreply@github.com>
Thu, 8 Aug 2024 11:00:08 +0000 (21:00 +1000)
* Тыкнул и нету ЦК

* review

---------

Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
Content.Client/Administration/UI/Tabs/ObjectsTab/ObjectsTab.xaml.cs
Content.Client/Administration/UI/Tabs/ObjectsTab/ObjectsTabEntry.xaml
Content.Client/Administration/UI/Tabs/ObjectsTab/ObjectsTabEntry.xaml.cs
Content.Client/Administration/UI/Tabs/ObjectsTab/ObjectsTabHeader.xaml
Resources/Locale/en-US/administration/ui/tabs/object-tab.ftl

index 7082617c944c4858129aa9d0a1075c095620e7c1..4b50771b0fe468d50a5715380fe4d9ce07dcae61 100644 (file)
@@ -1,19 +1,21 @@
+using Content.Client.Administration.Managers;
 using Content.Client.Station;
 using Content.Client.UserInterface.Controls;
 using Robust.Client.AutoGenerated;
+using Robust.Client.Console;
 using Robust.Client.Graphics;
 using Robust.Client.UserInterface;
-using Robust.Client.UserInterface.Controls;
 using Robust.Client.UserInterface.XAML;
 using Robust.Shared.Map.Components;
-using Robust.Shared.Timing;
 
 namespace Content.Client.Administration.UI.Tabs.ObjectsTab;
 
 [GenerateTypedNameReferences]
 public sealed partial class ObjectsTab : Control
 {
+    [Dependency] private readonly IClientAdminManager _admin = default!;
     [Dependency] private readonly IEntityManager _entityManager = default!;
+    [Dependency] private readonly IClientConsoleHost _console = default!;
 
     private readonly Color _altColor = Color.FromHex("#292B38");
     private readonly Color _defaultColor = Color.FromHex("#2F2F3B");
@@ -49,10 +51,20 @@ public sealed partial class ObjectsTab : Control
         RefreshListButton.OnPressed += _ => RefreshObjectList();
 
         var defaultSelection = ObjectsTabSelection.Grids;
-        ObjectTypeOptions.SelectId((int) defaultSelection);
+        ObjectTypeOptions.SelectId((int)defaultSelection);
         RefreshObjectList(defaultSelection);
     }
 
+    private void TeleportTo(NetEntity nent)
+    {
+        _console.ExecuteCommand($"tpto {nent}");
+    }
+
+    private void Delete(NetEntity nent)
+    {
+        _console.ExecuteCommand($"delete {nent}");
+    }
+
     public void RefreshObjectList()
     {
         RefreshObjectList(_selections[ObjectTypeOptions.SelectedId]);
@@ -116,9 +128,9 @@ public sealed partial class ObjectsTab : Control
         if (data is not ObjectsListData { Info: var info, BackgroundColor: var backgroundColor })
             return;
 
-        var entry = new ObjectsTabEntry(info.Name,
-            info.Entity,
-            new StyleBoxFlat { BackgroundColor = backgroundColor });
+        var entry = new ObjectsTabEntry(_admin, info.Name, info.Entity, new StyleBoxFlat { BackgroundColor = backgroundColor });
+        entry.OnTeleport += TeleportTo;
+        entry.OnDelete += Delete;
         button.ToolTip = $"{info.Name}, {info.Entity}";
 
         button.AddChild(entry);
index 83c4cc5697f71fb45fb0eab108b09a2569d81afe..c561125a30c7d28fdb4a0e1ad7791a03b0e1f997 100644 (file)
@@ -5,13 +5,25 @@
                   HorizontalExpand="True"
                   SeparationOverride="4">
         <Label Name="NameLabel"
-               SizeFlagsStretchRatio="3"
+               SizeFlagsStretchRatio="5"
                HorizontalExpand="True"
                ClipText="True"/>
         <customControls:VSeparator/>
         <Label Name="EIDLabel"
+               SizeFlagsStretchRatio="5"
+               HorizontalExpand="True"
+               ClipText="True"/>
+        <customControls:VSeparator/>
+        <Button Name="TeleportButton"
+                Text="{Loc object-tab-entity-teleport}"
                SizeFlagsStretchRatio="3"
                HorizontalExpand="True"
                ClipText="True"/>
+        <customControls:VSeparator/>
+        <Button Name="DeleteButton"
+                Text="{Loc object-tab-entity-delete}"
+                SizeFlagsStretchRatio="3"
+                HorizontalExpand="True"
+                ClipText="True"/>
     </BoxContainer>
 </PanelContainer>
index aab06c6ccd0f468e54c1c143afe56352bf437480..29774bb587e4f3d02f8718d1499a591cf97c0a2f 100644 (file)
@@ -1,4 +1,5 @@
-using Robust.Client.AutoGenerated;
+using Content.Client.Administration.Managers;
+using Robust.Client.AutoGenerated;
 using Robust.Client.Graphics;
 using Robust.Client.UserInterface.Controls;
 using Robust.Client.UserInterface.XAML;
@@ -10,12 +11,22 @@ public sealed partial class ObjectsTabEntry : PanelContainer
 {
     public NetEntity AssocEntity;
 
-    public ObjectsTabEntry(string name, NetEntity nent, StyleBox styleBox)
+    public Action<NetEntity>? OnTeleport;
+    public Action<NetEntity>? OnDelete;
+
+    public ObjectsTabEntry(IClientAdminManager manager, string name, NetEntity nent, StyleBox styleBox)
     {
         RobustXamlLoader.Load(this);
+
         AssocEntity = nent;
         EIDLabel.Text = nent.ToString();
         NameLabel.Text = name;
         BackgroundColorPanel.PanelOverride = styleBox;
+
+        TeleportButton.Disabled = !manager.CanCommand("tpto");
+        DeleteButton.Disabled = !manager.CanCommand("delete");
+
+        TeleportButton.OnPressed += _ => OnTeleport?.Invoke(nent);
+        DeleteButton.OnPressed += _ => OnDelete?.Invoke(nent);
     }
 }
index 71a1f5c7bc6431a12e3bc0fca04f67df4c1c958a..2cc7d76180e09e12054b8c8d160dd5c36f682fd4 100644 (file)
@@ -5,17 +5,23 @@
                   HorizontalExpand="True"
                   SeparationOverride="4">
         <Label Name="ObjectNameLabel"
-               SizeFlagsStretchRatio="3"
+               SizeFlagsStretchRatio="5"
                HorizontalExpand="True"
                ClipText="True"
                Text="{Loc object-tab-object-name}"
                MouseFilter="Pass"/>
         <cc:VSeparator/>
         <Label Name="EntityIDLabel"
-               SizeFlagsStretchRatio="3"
+               SizeFlagsStretchRatio="5"
                HorizontalExpand="True"
                ClipText="True"
                Text="{Loc object-tab-entity-id}"
                MouseFilter="Pass"/>
+        <Label Name="EntityTeleportLabel"
+               SizeFlagsStretchRatio="3"
+               HorizontalExpand="True"/>
+        <Label Name="EntityDeleteLabel"
+               SizeFlagsStretchRatio="3"
+               HorizontalExpand="True"/>
     </BoxContainer>
 </Control>
index da84ea4f163c1b62c1cd39fc83a6841d9f22746f..3f49a4ad9cfb0a45358914810c2d0afb0bf77841 100644 (file)
@@ -8,3 +8,6 @@ object-tab-object-type-grids = Grids
 object-tab-object-type-maps = Maps
 object-tab-object-type-stations = Stations
 object-tab-refresh-button = Refresh
+
+object-tab-entity-teleport = Teleport
+object-tab-entity-delete = Delete