Fix verb menu not loading (#13454)
This commit is contained in:
@@ -108,7 +108,6 @@ namespace Content.Client.ContextMenu.UI
|
|||||||
CancelOpen?.Cancel();
|
CancelOpen?.Cancel();
|
||||||
CancelOpen = new();
|
CancelOpen = new();
|
||||||
Timer.Spawn(HoverDelay, () => OpenSubMenu(element), CancelOpen.Token);
|
Timer.Spawn(HoverDelay, () => OpenSubMenu(element), CancelOpen.Token);
|
||||||
OnContextMouseEntered?.Invoke(element);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -170,7 +169,7 @@ namespace Content.Client.ContextMenu.UI
|
|||||||
// open pop-up adjacent to the parent element. We want the sub-menu elements to align with this element
|
// open pop-up adjacent to the parent element. We want the sub-menu elements to align with this element
|
||||||
// which depends on the panel container style margins.
|
// which depends on the panel container style margins.
|
||||||
var altPos = element.GlobalPosition;
|
var altPos = element.GlobalPosition;
|
||||||
var pos = altPos + (element.Width + 2*ContextMenuElement.ElementMargin, - 2*ContextMenuElement.ElementMargin);
|
var pos = altPos + (element.Width + 2 * ContextMenuElement.ElementMargin, -2 * ContextMenuElement.ElementMargin);
|
||||||
element.SubMenu.Open(UIBox2.FromDimensions(pos, (1, 1)), altPos);
|
element.SubMenu.Open(UIBox2.FromDimensions(pos, (1, 1)), altPos);
|
||||||
|
|
||||||
// draw on top of other menus
|
// draw on top of other menus
|
||||||
|
|||||||
@@ -64,7 +64,6 @@ namespace Content.Client.ContextMenu.UI
|
|||||||
{
|
{
|
||||||
_updating = true;
|
_updating = true;
|
||||||
_cfg.OnValueChanged(CCVars.EntityMenuGroupingType, OnGroupingChanged, true);
|
_cfg.OnValueChanged(CCVars.EntityMenuGroupingType, OnGroupingChanged, true);
|
||||||
_context.OnContextMouseEntered += OnMouseEntered;
|
|
||||||
_context.OnContextKeyEvent += OnKeyBindDown;
|
_context.OnContextKeyEvent += OnKeyBindDown;
|
||||||
|
|
||||||
CommandBinds.Builder
|
CommandBinds.Builder
|
||||||
@@ -77,7 +76,6 @@ namespace Content.Client.ContextMenu.UI
|
|||||||
_updating = false;
|
_updating = false;
|
||||||
Elements.Clear();
|
Elements.Clear();
|
||||||
_cfg.UnsubValueChanged(CCVars.EntityMenuGroupingType, OnGroupingChanged);
|
_cfg.UnsubValueChanged(CCVars.EntityMenuGroupingType, OnGroupingChanged);
|
||||||
_context.OnContextMouseEntered -= OnMouseEntered;
|
|
||||||
_context.OnContextKeyEvent -= OnKeyBindDown;
|
_context.OnContextKeyEvent -= OnKeyBindDown;
|
||||||
CommandBinds.Unregister<EntityMenuUIController>();
|
CommandBinds.Unregister<EntityMenuUIController>();
|
||||||
}
|
}
|
||||||
@@ -101,25 +99,6 @@ namespace Content.Client.ContextMenu.UI
|
|||||||
_context.RootMenu.Open(box);
|
_context.RootMenu.Open(box);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnMouseEntered(ContextMenuElement element)
|
|
||||||
{
|
|
||||||
if (element is not EntityMenuElement entityElement)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// get an entity associated with this element
|
|
||||||
var entity = entityElement.Entity;
|
|
||||||
|
|
||||||
// if there is none, this is a group, so don't open verbs
|
|
||||||
if (entity == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Deleted() automatically checks for null & existence.
|
|
||||||
if (_entityManager.Deleted(entity))
|
|
||||||
return;
|
|
||||||
|
|
||||||
_verb.OpenVerbMenu(entity.Value, popup: element.SubMenu);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnKeyBindDown(ContextMenuElement element, GUIBoundKeyEventArgs args)
|
public void OnKeyBindDown(ContextMenuElement element, GUIBoundKeyEventArgs args)
|
||||||
{
|
{
|
||||||
if (element is not EntityMenuElement entityElement)
|
if (element is not EntityMenuElement entityElement)
|
||||||
@@ -241,6 +220,9 @@ namespace Content.Client.ContextMenu.UI
|
|||||||
{
|
{
|
||||||
var element = new EntityMenuElement(entity);
|
var element = new EntityMenuElement(entity);
|
||||||
element.SubMenu = new ContextMenuPopup(_context, element);
|
element.SubMenu = new ContextMenuPopup(_context, element);
|
||||||
|
element.SubMenu.OnPopupOpen += () => _verb.OpenVerbMenu(entity, popup: element.SubMenu);
|
||||||
|
element.SubMenu.OnPopupHide += element.SubMenu.MenuBody.DisposeAllChildren;
|
||||||
|
|
||||||
_context.AddElement(_context.RootMenu, element);
|
_context.AddElement(_context.RootMenu, element);
|
||||||
Elements.TryAdd(entity, element);
|
Elements.TryAdd(entity, element);
|
||||||
}
|
}
|
||||||
@@ -258,6 +240,8 @@ namespace Content.Client.ContextMenu.UI
|
|||||||
// this group only has a single entity, add a simple menu element
|
// this group only has a single entity, add a simple menu element
|
||||||
var element = new EntityMenuElement(group[0]);
|
var element = new EntityMenuElement(group[0]);
|
||||||
element.SubMenu = new ContextMenuPopup(_context, element);
|
element.SubMenu = new ContextMenuPopup(_context, element);
|
||||||
|
element.SubMenu.OnPopupOpen += () => _verb.OpenVerbMenu(group[0], popup: element.SubMenu);
|
||||||
|
element.SubMenu.OnPopupHide += element.SubMenu.MenuBody.DisposeAllChildren;
|
||||||
_context.AddElement(_context.RootMenu, element);
|
_context.AddElement(_context.RootMenu, element);
|
||||||
Elements.TryAdd(group[0], element);
|
Elements.TryAdd(group[0], element);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user