From 4e79a6dfe27fd38259711cdddce5db4baeef9410 Mon Sep 17 00:00:00 2001 From: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com> Date: Sat, 12 Nov 2022 06:45:36 +1300 Subject: [PATCH] Add vv /c/enthover (#12545) --- Content.Client/Gameplay/GameplayStateBase.cs | 30 ++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/Content.Client/Gameplay/GameplayStateBase.cs b/Content.Client/Gameplay/GameplayStateBase.cs index f0d76fe1b1..cb65ece0fc 100644 --- a/Content.Client/Gameplay/GameplayStateBase.cs +++ b/Content.Client/Gameplay/GameplayStateBase.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Linq; using Content.Client.Clickable; +using Content.Client.ContextMenu.UI; using Robust.Client.GameObjects; using Robust.Client.Input; using Robust.Client.Player; @@ -28,17 +29,46 @@ namespace Content.Client.Gameplay [Dependency] private readonly IMapManager _mapManager = default!; [Dependency] protected readonly IUserInterfaceManager UserInterfaceManager = default!; [Dependency] private readonly IEntityManager _entityManager = default!; + [Dependency] private readonly IViewVariablesManager _vvm = default!; private ClickableEntityComparer _comparer = default!; + private (ViewVariablesPath? path, string[] segments) ResolveVVHoverObject(string path) + { + // VVs the currently hovered entity. For a nifty vv keybinding you can use: + // + // /bind v command "vv /c/enthover" + // /svbind + // + // Though you probably want to include a modifier like alt, as otherwise this would open VV even when typing + // a message into chat containing the letter v. + + var segments = path.Split('/'); + + EntityUid? uid = null; + if (UserInterfaceManager.CurrentlyHovered is IViewportControl vp && _inputManager.MouseScreenPosition.IsValid) + uid = GetEntityUnderPosition(vp.ScreenToMap(_inputManager.MouseScreenPosition.Position)); + else if (UserInterfaceManager.CurrentlyHovered is EntityMenuElement element) + uid = element.Entity; + + return (uid != null ? new ViewVariablesInstancePath(uid) : null, segments); + } + + private IEnumerable? ListVVHoverPaths(string[] segments) + { + return null; + } + protected override void Startup() { + _vvm.RegisterDomain("enthover", ResolveVVHoverObject, ListVVHoverPaths); _inputManager.KeyBindStateChanged += OnKeyBindStateChanged; _comparer = new ClickableEntityComparer(_entityManager); } protected override void Shutdown() { + _vvm.UnregisterDomain("enthover"); _inputManager.KeyBindStateChanged -= OnKeyBindStateChanged; }