Кнопки удаления и телепорта в панели гридов
This commit is contained in:
parent
7709d7a6a8
commit
d63632c81c
5 changed files with 46 additions and 2 deletions
|
|
@ -1,6 +1,7 @@
|
|||
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.XAML;
|
||||
|
|
@ -14,6 +15,7 @@ public sealed partial class ObjectsTab : Control
|
|||
{
|
||||
[Dependency] private readonly IEntityManager _entityManager = default!;
|
||||
[Dependency] private readonly IGameTiming _timing = default!;
|
||||
[Dependency] private readonly IClientConsoleHost _console = default!;
|
||||
|
||||
private readonly List<ObjectsTabEntry> _objects = new();
|
||||
private readonly List<ObjectsTabSelection> _selections = new();
|
||||
|
|
@ -27,6 +29,9 @@ public sealed partial class ObjectsTab : Control
|
|||
private readonly TimeSpan _updateFrequency = TimeSpan.FromSeconds(2);
|
||||
private TimeSpan _nextUpdate;
|
||||
|
||||
private Action<NetEntity>? TeleportToObjAction { get; set; }
|
||||
private Action<NetEntity>? DeleteObjAction { get; set; }
|
||||
|
||||
public ObjectsTab()
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
|
|
@ -57,6 +62,19 @@ public sealed partial class ObjectsTab : Control
|
|||
|
||||
// Initialize the next update time
|
||||
_nextUpdate = TimeSpan.Zero;
|
||||
|
||||
TeleportToObjAction += TeleportToObj;
|
||||
DeleteObjAction += DeleteObj;
|
||||
}
|
||||
|
||||
private void TeleportToObj(NetEntity nent)
|
||||
{
|
||||
_console.ExecuteCommand($"tpto {nent}");
|
||||
}
|
||||
|
||||
private void DeleteObj(NetEntity nent)
|
||||
{
|
||||
_console.ExecuteCommand($"delete {nent}");
|
||||
}
|
||||
|
||||
protected override void FrameUpdate(FrameEventArgs args)
|
||||
|
|
@ -129,7 +147,7 @@ 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(info.Name, info.Entity, new StyleBoxFlat { BackgroundColor = backgroundColor }, TeleportToObjAction, DeleteObjAction);
|
||||
button.ToolTip = $"{info.Name}, {info.Entity}";
|
||||
|
||||
button.OnKeyBindDown += args => OnEntryKeyBindDown?.Invoke(args, data);
|
||||
|
|
|
|||
|
|
@ -13,5 +13,17 @@
|
|||
SizeFlagsStretchRatio="3"
|
||||
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>
|
||||
|
|
|
|||
|
|
@ -10,12 +10,16 @@ public sealed partial class ObjectsTabEntry : PanelContainer
|
|||
{
|
||||
public NetEntity AssocEntity;
|
||||
|
||||
public ObjectsTabEntry(string name, NetEntity nent, StyleBox styleBox)
|
||||
public ObjectsTabEntry(string name, NetEntity nent, StyleBox styleBox, Action<NetEntity>? teleportToObj, Action<NetEntity>? deleteObj)
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
|
||||
AssocEntity = nent;
|
||||
EIDLabel.Text = nent.ToString();
|
||||
NameLabel.Text = name;
|
||||
BackgroundColorPanel.PanelOverride = styleBox;
|
||||
|
||||
TeleportButton.OnPressed += _ => teleportToObj?.Invoke(nent);
|
||||
DeleteButton.OnPressed += _ => deleteObj?.Invoke(nent);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,5 +17,11 @@
|
|||
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>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,4 @@
|
|||
object-tab-entity-id = ID сущности
|
||||
object-tab-object-name = Имя обьекта
|
||||
object-tab-entity-teleport = Телепорт
|
||||
object-tab-entity-delete = Удалить
|
||||
Loading…
Add table
Reference in a new issue