ActionsCommands.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using Content.Client.Actions;
  2. using Content.Shared.Administration;
  3. using Robust.Shared.Console;
  4. namespace Content.Client.Commands;
  5. // Disabled until sandoxing issues are resolved. In the meantime, if you want to create an acttions preset, just disable
  6. // sandboxing and uncomment this code (and the SaveActionAssignments() function).
  7. /*
  8. [AnyCommand]
  9. public sealed class SaveActionsCommand : IConsoleCommand
  10. {
  11. public string Command => "saveacts";
  12. public string Description => "Saves the current action toolbar assignments to a file";
  13. public string Help => $"Usage: {Command} <user resource path>";
  14. public void Execute(IConsoleShell shell, string argStr, string[] args)
  15. {
  16. if (args.Length != 1)
  17. {
  18. shell.WriteLine(Help);
  19. return;
  20. }
  21. try
  22. {
  23. EntitySystem.Get<ActionsSystem>().SaveActionAssignments(args[0]);
  24. }
  25. catch
  26. {
  27. shell.WriteLine("Failed to save action assignments");
  28. }
  29. }
  30. }
  31. */
  32. [AnyCommand]
  33. public sealed class LoadActionsCommand : LocalizedCommands
  34. {
  35. [Dependency] private readonly IEntitySystemManager _entitySystemManager = default!;
  36. public override string Command => "loadacts";
  37. public override string Help => LocalizationManager.GetString($"cmd-{Command}-help", ("command", Command));
  38. public override void Execute(IConsoleShell shell, string argStr, string[] args)
  39. {
  40. if (args.Length != 1)
  41. {
  42. shell.WriteLine(Help);
  43. return;
  44. }
  45. try
  46. {
  47. _entitySystemManager.GetEntitySystem<ActionsSystem>().LoadActionAssignments(args[0], true);
  48. }
  49. catch
  50. {
  51. shell.WriteError(LocalizationManager.GetString($"cmd-{Command}-error"));
  52. }
  53. }
  54. }