1
0

ToolshedVisualizeWindow.xaml.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using System.Numerics;
  2. using Robust.Client.AutoGenerated;
  3. using Robust.Client.Console;
  4. using Robust.Client.UserInterface.Controls;
  5. using Robust.Client.UserInterface.CustomControls;
  6. using Robust.Client.UserInterface.XAML;
  7. namespace Content.Client.Bql;
  8. [GenerateTypedNameReferences]
  9. internal sealed partial class ToolshedVisualizeWindow : DefaultWindow
  10. {
  11. private readonly IClientConsoleHost _console;
  12. private readonly ILocalizationManager _loc;
  13. public ToolshedVisualizeWindow(IClientConsoleHost console, ILocalizationManager loc)
  14. {
  15. _console = console;
  16. _loc = loc;
  17. RobustXamlLoader.Load(this);
  18. }
  19. protected override Vector2 ContentsMinimumSize => new(500, 700);
  20. public void Update((string name, NetEntity entity)[] entities)
  21. {
  22. StatusLabel.Text = _loc.GetString("ui-bql-results-status", ("count", entities.Length));
  23. ItemList.RemoveAllChildren();
  24. foreach (var (name, entity) in entities)
  25. {
  26. var nameLabel = new Label { Text = name, HorizontalExpand = true };
  27. var tpButton = new Button { Text = _loc.GetString("ui-bql-results-tp") };
  28. tpButton.OnPressed += _ => _console.ExecuteCommand($"tpto {entity}");
  29. tpButton.ToolTip = _loc.GetString("ui-bql-results-tp-tooltip");
  30. var vvButton = new Button { Text = _loc.GetString("ui-bql-results-vv") };
  31. vvButton.ToolTip = _loc.GetString("ui-bql-results-vv-tooltip");
  32. vvButton.OnPressed += _ => _console.ExecuteCommand($"vv {entity}");
  33. ItemList.AddChild(new BoxContainer
  34. {
  35. Orientation = BoxContainer.LayoutOrientation.Horizontal,
  36. Children = { nameLabel, tpButton, vvButton }
  37. });
  38. }
  39. }
  40. }