1
0

GroupingEntityMenuCommand.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using Content.Client.ContextMenu.UI;
  2. using Content.Shared.CCVar;
  3. using Robust.Shared.Configuration;
  4. using Robust.Shared.Console;
  5. namespace Content.Client.Commands;
  6. public sealed class GroupingEntityMenuCommand : LocalizedCommands
  7. {
  8. [Dependency] private readonly IConfigurationManager _configurationManager = default!;
  9. public override string Command => "entitymenug";
  10. public override string Help => LocalizationManager.GetString($"cmd-{Command}-help", ("command", Command), ("groupingTypesCount", EntityMenuUIController.GroupingTypesCount));
  11. public override void Execute(IConsoleShell shell, string argStr, string[] args)
  12. {
  13. if (args.Length != 1)
  14. {
  15. shell.WriteLine(Help);
  16. return;
  17. }
  18. if (!int.TryParse(args[0], out var id))
  19. {
  20. shell.WriteError(LocalizationManager.GetString($"cmd-{Command}-error", ("arg", args[0])));
  21. return;
  22. }
  23. if (id < 0 || id > EntityMenuUIController.GroupingTypesCount - 1)
  24. {
  25. shell.WriteError(LocalizationManager.GetString($"cmd-{Command}-error", ("arg", args[0])));
  26. return;
  27. }
  28. var cvar = CCVars.EntityMenuGroupingType;
  29. _configurationManager.SetCVar(cvar, id);
  30. shell.WriteLine(LocalizationManager.GetString($"cmd-{Command}-notify", ("cvar", _configurationManager.GetCVar(cvar))));
  31. }
  32. }