]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Add keybinds for openening a specified component in VV (#41348)
authorslarticodefast <161409025+slarticodefast@users.noreply.github.com>
Wed, 12 Nov 2025 23:10:48 +0000 (00:10 +0100)
committerGitHub <noreply@github.com>
Wed, 12 Nov 2025 23:10:48 +0000 (23:10 +0000)
* quick inspect

* Update Content.Client/Commands/QuickInspectCommand.cs

Co-authored-by: Kyle Tyo <36606155+VerinSenpai@users.noreply.github.com>
* documentation!!!

---------

Co-authored-by: Kyle Tyo <36606155+VerinSenpai@users.noreply.github.com>
Content.Client/Commands/QuickInspectCommand.cs [new file with mode: 0644]
Content.Client/Gameplay/GameplayStateBase.cs
Content.Client/Input/ContentContexts.cs
Content.Client/Options/UI/Tabs/KeyRebindTab.xaml.cs
Content.Shared/CCVar/CCVars.Debug.cs [new file with mode: 0644]
Content.Shared/Input/ContentKeyFunctions.cs
Resources/Locale/en-US/commands/quick-inspect-command.ftl [new file with mode: 0644]
Resources/Locale/en-US/escape-menu/ui/options-menu.ftl
Resources/clientCommandPerms.yml
Resources/keybinds.yml

diff --git a/Content.Client/Commands/QuickInspectCommand.cs b/Content.Client/Commands/QuickInspectCommand.cs
new file mode 100644 (file)
index 0000000..dc3aae6
--- /dev/null
@@ -0,0 +1,52 @@
+using System.Linq;
+using Content.Shared.CCVar;
+using Content.Shared.Input;
+using Robust.Client.Input;
+using Robust.Shared.Configuration;
+using Robust.Shared.Console;
+
+namespace Content.Client.Commands;
+
+/// <summary>
+/// Sets the a <see cref="CCVars.DebugQuickInspect"/> CVar to the name of a component, which allows the client to quickly open a VV window for that component
+/// by using the Alt+C or Alt+B hotkeys.
+/// </summary>
+public sealed class QuickInspectCommand : LocalizedEntityCommands
+{
+    [Dependency] private readonly IConfigurationManager _configurationManager = default!;
+    [Dependency] private readonly IInputManager _inputManager = default!;
+
+    public override string Command => "quickinspect";
+
+    public override void Execute(IConsoleShell shell, string argStr, string[] args)
+    {
+        if (args.Length != 1)
+        {
+            shell.WriteLine(Loc.GetString("shell-wrong-arguments-number"));
+            return;
+        }
+
+        _configurationManager.SetCVar(CCVars.DebugQuickInspect, args[0]);
+
+        var serverKey = _inputManager.GetKeyFunctionButtonString(ContentKeyFunctions.InspectServerComponent);
+        var clientKey = _inputManager.GetKeyFunctionButtonString(ContentKeyFunctions.InspectClientComponent);
+        shell.WriteLine(Loc.GetString($"cmd-quickinspect-success", ("component", args[0]), ("serverKeybind", serverKey), ("clientKeybind", clientKey)));
+    }
+
+    public override CompletionResult GetCompletion(IConsoleShell shell, string[] args)
+    {
+        if (args.Length == 1)
+        {
+            // Not ideal since it only shows client-side components, but you can still type in any name you want.
+            // If you know how to get server component names on the client then please fix this.
+            var options = EntityManager.ComponentFactory.AllRegisteredTypes
+                .Select(p => new CompletionOption(
+                    EntityManager.ComponentFactory.GetComponentName(p)
+                ));
+
+            return CompletionResult.FromOptions(options);
+        }
+
+        return CompletionResult.Empty;
+    }
+}
index 69e6e0b58be531ab743ae00744f497be7a324c3c..c2b10fd01afd64b8f151f9a9dbefd5c9ae23b5ff 100644 (file)
@@ -3,6 +3,7 @@ using System.Numerics;
 using Content.Client.Clickable;
 using Content.Client.UserInterface;
 using Content.Client.Viewport;
+using Content.Shared.CCVar;
 using Content.Shared.Input;
 using Robust.Client.ComponentTrees;
 using Robust.Client.GameObjects;
@@ -13,6 +14,7 @@ using Robust.Client.State;
 using Robust.Client.UserInterface;
 using Robust.Client.UserInterface.Controls;
 using Robust.Client.UserInterface.CustomControls;
+using Robust.Shared.Configuration;
 using Robust.Shared.Console;
 using Robust.Shared.Graphics;
 using Robust.Shared.Input;
@@ -40,6 +42,7 @@ namespace Content.Client.Gameplay
         [Dependency] private readonly IEntityManager _entityManager = default!;
         [Dependency] private readonly IViewVariablesManager _vvm = default!;
         [Dependency] private readonly IConsoleHost _conHost = default!;
+        [Dependency] private readonly IConfigurationManager _configurationManager = default!;
 
         private ClickableEntityComparer _comparer = default!;
 
@@ -83,6 +86,8 @@ namespace Content.Client.Gameplay
             _comparer = new ClickableEntityComparer();
             CommandBinds.Builder
                 .Bind(ContentKeyFunctions.InspectEntity, new PointerInputCmdHandler(HandleInspect, outsidePrediction: true))
+                .Bind(ContentKeyFunctions.InspectServerComponent, new PointerInputCmdHandler(HandleInspectServerComponent, outsidePrediction: true))
+                .Bind(ContentKeyFunctions.InspectClientComponent, new PointerInputCmdHandler(HandleInspectClientComponent, outsidePrediction: true))
                 .Register<GameplayStateBase>();
         }
 
@@ -99,6 +104,21 @@ namespace Content.Client.Gameplay
             return true;
         }
 
+        private bool HandleInspectServerComponent(ICommonSession? session, EntityCoordinates coords, EntityUid uid)
+        {
+            var component = _configurationManager.GetCVar(CCVars.DebugQuickInspect);
+            if (_entityManager.TryGetNetEntity(uid, out var net))
+                _conHost.ExecuteCommand($"vv /entity/{net.Value.Id}/{component}");
+            return true;
+        }
+
+        private bool HandleInspectClientComponent(ICommonSession? session, EntityCoordinates coords, EntityUid uid)
+        {
+            var component = _configurationManager.GetCVar(CCVars.DebugQuickInspect);
+            _conHost.ExecuteCommand($"vv /c/entity/{uid}/{component}");
+            return true;
+        }
+
         public EntityUid? GetClickedEntity(MapCoordinates coordinates)
         {
             return GetClickedEntity(coordinates, _eyeManager.CurrentEye);
index 47f0cda2f6d98e0f0729f8424ed0f0475c7be260..01e7dc367c33486f8d2b0b77e5ad00b6270d2bcc 100644 (file)
@@ -38,6 +38,8 @@ namespace Content.Client.Input
             common.AddFunction(ContentKeyFunctions.ZoomIn);
             common.AddFunction(ContentKeyFunctions.ResetZoom);
             common.AddFunction(ContentKeyFunctions.InspectEntity);
+            common.AddFunction(ContentKeyFunctions.InspectServerComponent);
+            common.AddFunction(ContentKeyFunctions.InspectClientComponent);
             common.AddFunction(ContentKeyFunctions.ToggleRoundEndSummaryWindow);
 
             // Not in engine, because engine cannot check for sanbox/admin status before starting placement.
index f92f66df31842943abbcfe54bb0bd1aeb7ee8f17..40d1836c08a850040d2198353739f72910b5d508 100644 (file)
@@ -268,6 +268,8 @@ namespace Content.Client.Options.UI.Tabs
             AddButton(EngineKeyFunctions.ShowDebugMonitors);
             AddButton(EngineKeyFunctions.HideUI);
             AddButton(ContentKeyFunctions.InspectEntity);
+            AddButton(ContentKeyFunctions.InspectServerComponent);
+            AddButton(ContentKeyFunctions.InspectClientComponent);
 
             AddHeader("ui-options-header-text-cursor");
             AddButton(EngineKeyFunctions.TextCursorLeft);
diff --git a/Content.Shared/CCVar/CCVars.Debug.cs b/Content.Shared/CCVar/CCVars.Debug.cs
new file mode 100644 (file)
index 0000000..a95acc4
--- /dev/null
@@ -0,0 +1,13 @@
+using Robust.Shared.Configuration;
+
+namespace Content.Shared.CCVar;
+
+public sealed partial class CCVars
+{
+    /// <summary>
+    /// Component to be inspected using the "Quick Inspect Component" keybind.
+    /// Set by the "quickinspect" command.
+    /// </summary>
+    public static readonly CVarDef<string> DebugQuickInspect =
+        CVarDef.Create("debug.quick_inspect", "", CVar.CLIENTONLY | CVar.ARCHIVE);
+}
index 50ea218b0073c76f725632e37b13c37fd4f751c1..63f631032272ca3c849d6bd225aa63030c8f2679 100644 (file)
@@ -123,7 +123,8 @@ namespace Content.Shared.Input
         public static readonly BoundKeyFunction EditorCopyObject = "EditorCopyObject";
         public static readonly BoundKeyFunction EditorFlipObject = "EditorFlipObject";
         public static readonly BoundKeyFunction InspectEntity = "InspectEntity";
-
+        public static readonly BoundKeyFunction InspectServerComponent = "InspectServerComponent";
+        public static readonly BoundKeyFunction InspectClientComponent = "InspectClientComponent";
         public static readonly BoundKeyFunction MappingUnselect = "MappingUnselect";
         public static readonly BoundKeyFunction SaveMap = "SaveMap";
         public static readonly BoundKeyFunction MappingEnablePick = "MappingEnablePick";
diff --git a/Resources/Locale/en-US/commands/quick-inspect-command.ftl b/Resources/Locale/en-US/commands/quick-inspect-command.ftl
new file mode 100644 (file)
index 0000000..e057fd9
--- /dev/null
@@ -0,0 +1,5 @@
+cmd-quickinspect-desc = Sets a component name to be opened for a hovered entity via the "Inspect Server/Client Component" keybind.
+cmd-quickinspect-help = Usage: {$command} <component name>
+cmd-quickinspect-success = Component set to: {$component}.
+    Press {$serverKeybind} to open a VV window for the server.
+    Press {$clientKeybind} to open a VV window for the client.
index 98ee2543c15e31012d3b8ec42b2e612516da9196..a263e5222984e69a4d39eda9b20dd44d94487ffb 100644 (file)
@@ -227,6 +227,11 @@ ui-options-function-editor-copy-object = Copy
 ui-options-function-show-debug-console = Open Console
 ui-options-function-show-debug-monitors = Show Debug Monitors
 ui-options-function-inspect-entity = Inspect Entity
+ui-options-function-inspect-entity-tooltip = Open a ViewVariables window for the entity your mouse is currently hovering over.
+ui-options-function-inspect-server-component = Inspect Server Component
+ui-options-function-inspect-server-component-tooltip = Open a ViewVariables window with the server component set by the "quickinspect" command for the entity your mouse is currently hovering over.
+ui-options-function-inspect-client-component = Inspect Client Component
+ui-options-function-inspect-client-component-tooltip = Open a ViewVariables window with the client component set by the "quickinspect" command for the entity your mouse is currently hovering over.
 ui-options-function-hide-ui = Hide UI
 
 ui-options-function-hotbar1 = Hotbar slot 1
index d83fdcc3533ee9a9884c824eb0f1a1995fc12924..a177bc5fe1cc9864614b6cb23b30876ebc1c7a04 100644 (file)
@@ -74,6 +74,7 @@
     - fullstatereset
     - dumpentities
     - showaccessreaders
+    - quickinspect
 
 - Flags: MAPPING
   Commands:
index 870c8e14355afafe01ca0586ed8a0d69f428b214..aa7b2918e1cdb5d1d632ff4a01ecdfda0c77941c 100644 (file)
@@ -281,6 +281,14 @@ binds:
   type: State
   key: v
   mod1: Alt
+- function: InspectServerComponent
+  type: State
+  key: b
+  mod1: Alt
+- function: InspectClientComponent
+  type: State
+  key: c
+  mod1: Alt
 - function: MouseMiddle
   type: State
   key: MouseMiddle