AdminbusTab.xaml.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. using Content.Client.Administration.Managers;
  2. using Content.Client.UserInterface.Systems.DecalPlacer;
  3. using Content.Shared.Administration;
  4. using Robust.Client.AutoGenerated;
  5. using Robust.Client.Upload.Commands;
  6. using Robust.Client.UserInterface;
  7. using Robust.Client.UserInterface.Controllers.Implementations;
  8. using Robust.Client.UserInterface.Controls;
  9. using Robust.Client.UserInterface.XAML;
  10. namespace Content.Client.Administration.UI.Tabs.AdminbusTab
  11. {
  12. [GenerateTypedNameReferences]
  13. public sealed partial class AdminbusTab : Control
  14. {
  15. private readonly EntitySpawningUIController _entitySpawningController;
  16. private readonly TileSpawningUIController _tileSpawningController;
  17. private readonly DecalPlacerUIController _decalPlacerController;
  18. public AdminbusTab()
  19. {
  20. RobustXamlLoader.Load(this);
  21. IoCManager.InjectDependencies(this);
  22. _entitySpawningController = UserInterfaceManager.GetUIController<EntitySpawningUIController>();
  23. _tileSpawningController = UserInterfaceManager.GetUIController<TileSpawningUIController>();
  24. _decalPlacerController = UserInterfaceManager.GetUIController<DecalPlacerUIController>();
  25. var adminManager = IoCManager.Resolve<IClientAdminManager>();
  26. adminManager.AdminStatusUpdated += OnStatusUpdate;
  27. // For the SpawnEntitiesButton and SpawnTilesButton we need to do the press manually
  28. // TODO: This will probably need some command check at some point
  29. SpawnEntitiesButton.OnPressed += SpawnEntitiesButtonOnPressed;
  30. SpawnTilesButton.OnPressed += SpawnTilesButtonOnOnPressed;
  31. SpawnDecalsButton.OnPressed += SpawnDecalsButtonOnPressed;
  32. LoadGamePrototypeButton.OnPressed += LoadGamePrototypeButtonOnPressed;
  33. LoadGamePrototypeButton.Disabled = !adminManager.CanCommand("loadprototype");
  34. LoadBlueprintsButton.Disabled = !adminManager.CanCommand("loadgrid");
  35. }
  36. private void OnStatusUpdate()
  37. {
  38. var adminManager = IoCManager.Resolve<IClientAdminManager>();
  39. LoadGamePrototypeButton.Disabled = !adminManager.CanCommand("loadprototype");
  40. LoadBlueprintsButton.Disabled = !adminManager.CanCommand("loadgrid");
  41. }
  42. private void LoadGamePrototypeButtonOnPressed(BaseButton.ButtonEventArgs obj)
  43. {
  44. LoadPrototypeCommand.LoadPrototype();
  45. }
  46. private void SpawnEntitiesButtonOnPressed(BaseButton.ButtonEventArgs obj)
  47. {
  48. _entitySpawningController.ToggleWindow();
  49. }
  50. private void SpawnTilesButtonOnOnPressed(BaseButton.ButtonEventArgs obj)
  51. {
  52. _tileSpawningController.ToggleWindow();
  53. }
  54. private void SpawnDecalsButtonOnPressed(BaseButton.ButtonEventArgs obj)
  55. {
  56. _decalPlacerController.ToggleWindow();
  57. }
  58. }
  59. }