ObjectsTabEntry.xaml.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using Content.Client.Administration.Managers;
  2. using Robust.Client.AutoGenerated;
  3. using Robust.Client.Graphics;
  4. using Robust.Client.UserInterface.Controls;
  5. using Robust.Client.UserInterface.XAML;
  6. namespace Content.Client.Administration.UI.Tabs.ObjectsTab;
  7. [GenerateTypedNameReferences]
  8. public sealed partial class ObjectsTabEntry : PanelContainer
  9. {
  10. public NetEntity AssocEntity;
  11. public Action<NetEntity>? OnTeleport;
  12. public Action<NetEntity>? OnDelete;
  13. private readonly Dictionary<Button, ConfirmationData> _confirmations = new();
  14. public ObjectsTabEntry(IClientAdminManager manager, string name, NetEntity nent, StyleBox styleBox)
  15. {
  16. RobustXamlLoader.Load(this);
  17. AssocEntity = nent;
  18. EIDLabel.Text = nent.ToString();
  19. NameLabel.Text = name;
  20. BackgroundColorPanel.PanelOverride = styleBox;
  21. TeleportButton.Disabled = !manager.CanCommand("tpto");
  22. DeleteButton.Disabled = !manager.CanCommand("delete");
  23. TeleportButton.OnPressed += _ => OnTeleport?.Invoke(nent);
  24. DeleteButton.OnPressed += _ =>
  25. {
  26. if (!AdminUIHelpers.TryConfirm(DeleteButton, _confirmations))
  27. {
  28. return;
  29. }
  30. OnDelete?.Invoke(nent);
  31. };
  32. }
  33. }