Refactor Context Menus and make them use XAML & stylesheets (#4768)

* XAML verb menu

* fix ghost FOV

* spacing

* rename missed "ContextMenu"->"EntityMenu" instances

* move visibility checks to verb system

* update comment

* Remove CanSeeContainerCheck

* use ScrollContainer measure option

* MaxWidth / texxt line wrapping

* verb category default

Now when you click on a verb category, it should default to running the first member of that category.

This makes it much more convenient to eject/insert when there is only a single option

* only apply style to first verb category entry

* Use new visibility flags

* FoV -> Fov

* Revert "only apply style to first verb category entry"

This reverts commit 9a6a17dba600e3ae0421caed59fcab145c260c99.

* make all entity menu visibility checks clientside

* Fix empty unbuckle category

* fix merge
This commit is contained in:
Leon Friedrich
2021-10-28 18:21:19 +13:00
committed by GitHub
parent 224952110e
commit 49296e33a0
36 changed files with 1421 additions and 1535 deletions

View File

@@ -1,19 +1,18 @@
using Content.Shared;
using Content.Client.ContextMenu.UI;
using Content.Shared.CCVar;
using Robust.Shared.Configuration;
using Robust.Shared.Console;
using Robust.Shared.IoC;
using ContextMenuView = Content.Client.ContextMenu.UI.ContextMenuView;
namespace Content.Client.Commands
{
public class GroupingContextMenuCommand : IConsoleCommand
public class GroupingEntityMenuCommand : IConsoleCommand
{
public string Command => "contextmenug";
public string Command => "entitymenug";
public string Description => "Sets the contextmenu-groupingtype.";
public string Description => "Sets the entity menu grouping type.";
public string Help => ($"Usage: contextmenug <0:{ContextMenuView.GroupingTypesCount}>");
public string Help => $"Usage: entitymenug <0:{EntityMenuPresenter.GroupingTypesCount}>";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (args.Length != 1)
@@ -28,14 +27,14 @@ namespace Content.Client.Commands
return;
}
if (id < 0 ||id > ContextMenuView.GroupingTypesCount - 1)
if (id < 0 ||id > EntityMenuPresenter.GroupingTypesCount - 1)
{
shell.WriteLine($"{args[0]} is not a valid integer.");
return;
}
var configurationManager = IoCManager.Resolve<IConfigurationManager>();
var cvar = CCVars.ContextMenuGroupingType;
var cvar = CCVars.EntityMenuGroupingType;
configurationManager.SetCVar(cvar, id);
shell.WriteLine($"Context Menu Grouping set to type: {configurationManager.GetCVar(cvar)}");

View File

@@ -0,0 +1,54 @@
using Content.Client.Verbs;
using JetBrains.Annotations;
using Robust.Shared.Console;
using Robust.Shared.GameObjects;
namespace Content.Client.Commands
{
[UsedImplicitly]
internal sealed class SetMenuVisibilityCommand : IConsoleCommand
{
public const string CommandName = "menuvis";
public string Command => CommandName;
public string Description => "Set restrictions about what entities to show on the entity context menu.";
public string Help => $"Usage: {Command} [NoFoV] [InContainer] [Invisible] [All]";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (!TryParseArguments(shell, args, out var visibility))
return;
EntitySystem.Get<VerbSystem>().Visibility = visibility;
}
private bool TryParseArguments(IConsoleShell shell, string[] args, out MenuVisibility visibility)
{
visibility = MenuVisibility.Default;
foreach (var arg in args)
{
switch (arg.ToLower())
{
case "nofov":
visibility |= MenuVisibility.NoFov;
break;
case "incontainer":
visibility |= MenuVisibility.InContainer;
break;
case "invisible":
visibility |= MenuVisibility.Invisible;
break;
case "all":
visibility |= MenuVisibility.All;
break;
default:
shell.WriteLine($"Unknown visibility argument '{arg}'. Only 'NoFov', 'InContainer', 'Invisible' or 'All' are valid. Provide no arguments to set to default.");
return false;
}
}
return true;
}
}
}