Files
tbd-station-14/Content.Client/Commands/GroupingContextMenuCommand.cs
Daniel Castro Razo f30a4d8a52 ContextMenu (#3286)
* ContextMenu

* Updating to WPF.

* Updating to WPF.

* Margins
2021-02-26 12:42:16 +11:00

46 lines
1.5 KiB
C#

#nullable enable
using Content.Client.GameObjects.EntitySystems;
using Content.Shared;
using Robust.Shared.Configuration;
using Robust.Shared.Console;
using Robust.Shared.IoC;
using ContextMenuView = Content.Client.UserInterface.ContextMenu.ContextMenuView;
namespace Content.Client.Commands
{
public class GroupingContextMenuCommand : IConsoleCommand
{
public string Command => "contextmenug";
public string Description => "Sets the contextmenu-groupingtype.";
public string Help => ($"Usage: contextmenug <0:{ContextMenuView.GroupingTypesCount}>");
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (args.Length != 1)
{
shell.WriteLine(Help);
return;
}
if (!int.TryParse(args[0], out var id))
{
shell.WriteLine($"{args[0]} is not a valid integer.");
return;
}
if (id < 0 ||id > ContextMenuView.GroupingTypesCount - 1)
{
shell.WriteLine($"{args[0]} is not a valid integer.");
return;
}
var configurationManager = IoCManager.Resolve<IConfigurationManager>();
var cvar = CCVars.ContextMenuGroupingType;
configurationManager.SetCVar(cvar, id);
shell.WriteLine($"Context Menu Grouping set to type: {configurationManager.GetCVar(cvar)}");
}
}
}