From bd51cf330b7e837a82d6c657414677dd4f2d2606 Mon Sep 17 00:00:00 2001 From: Vigers Ray <60344369+VigersRay@users.noreply.github.com> Date: Thu, 8 Aug 2024 14:00:08 +0300 Subject: [PATCH] Teleport and delete buttons in objects tab. (#28914) MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit * Тыкнул и нету ЦК * review --------- Co-authored-by: metalgearsloth --- .../UI/Tabs/ObjectsTab/ObjectsTab.xaml.cs | 24 ++++++++++++++----- .../UI/Tabs/ObjectsTab/ObjectsTabEntry.xaml | 14 ++++++++++- .../Tabs/ObjectsTab/ObjectsTabEntry.xaml.cs | 15 ++++++++++-- .../UI/Tabs/ObjectsTab/ObjectsTabHeader.xaml | 10 ++++++-- .../administration/ui/tabs/object-tab.ftl | 3 +++ 5 files changed, 55 insertions(+), 11 deletions(-) diff --git a/Content.Client/Administration/UI/Tabs/ObjectsTab/ObjectsTab.xaml.cs b/Content.Client/Administration/UI/Tabs/ObjectsTab/ObjectsTab.xaml.cs index 7082617c94..4b50771b0f 100644 --- a/Content.Client/Administration/UI/Tabs/ObjectsTab/ObjectsTab.xaml.cs +++ b/Content.Client/Administration/UI/Tabs/ObjectsTab/ObjectsTab.xaml.cs @@ -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); diff --git a/Content.Client/Administration/UI/Tabs/ObjectsTab/ObjectsTabEntry.xaml b/Content.Client/Administration/UI/Tabs/ObjectsTab/ObjectsTabEntry.xaml index 83c4cc5697..c561125a30 100644 --- a/Content.Client/Administration/UI/Tabs/ObjectsTab/ObjectsTabEntry.xaml +++ b/Content.Client/Administration/UI/Tabs/ObjectsTab/ObjectsTabEntry.xaml @@ -5,13 +5,25 @@ HorizontalExpand="True" SeparationOverride="4">