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,13 +1,15 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using Content.Client.Clickable;
using Content.Client.ContextMenu.UI;
using Content.Client.Interactable;
using Content.Client.Interactable.Components;
using Content.Client.State;
using Content.Shared;
using Content.Shared.CCVar;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.Input;
using Robust.Client.Player;
using Robust.Client.State;
@@ -38,6 +40,7 @@ namespace Content.Client.Viewport
[Dependency] protected readonly IUserInterfaceManager UserInterfaceManager = default!;
[Dependency] protected readonly IConfigurationManager ConfigurationManager = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IEyeManager _eyeManager = default!;
private IEventBus _eventBus => _entityManager.EventBus;
@@ -62,6 +65,9 @@ namespace Content.Client.Viewport
_outlineEnabled = message.Enabled;
}
/// <summary>
/// Highlight the currently hovered entity.
/// </summary>
public override void FrameUpdate(FrameEventArgs e)
{
base.FrameUpdate(e);
@@ -71,6 +77,13 @@ namespace Content.Client.Viewport
if (localPlayer == null)
return;
// TODO InteractionOutlineComponent
// BUG: The logic that gets the renderScale here assumes that the entity is only visible in a single
// viewport. The entity will be highlighted in ALL viewport where it is visible, regardless of which
// viewport is being used to hover over it. If these Viewports have very different render scales, this may
// lead to extremely thick outlines in the other viewports. Fixing this probably requires changing how the
// hover outline works, so that it only highlights the entity in a single viewport.
IEntity? entityToClick = null;
var renderScale = 1;
if (UserInterfaceManager.CurrentlyHovered is IViewportControl vp)
@@ -83,6 +96,15 @@ namespace Content.Client.Viewport
renderScale = svp.CurrentRenderScale;
}
}
else if (UserInterfaceManager.CurrentlyHovered is EntityMenuElement element)
{
entityToClick = element.Entity;
// TODO InteractionOutlineComponent
// Currently we just take the renderscale from the main viewport. In the future, when the bug mentioned
// above is fixed, the viewport should probably be the one that was clicked on to open the entity menu
// in the first place.
renderScale = _eyeManager.MainViewport.GetRenderScale();
}
var inRange = false;
if (localPlayer.ControlledEntity != null && entityToClick != null)