--- /dev/null
+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;
+ }
+}
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;
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;
[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!;
_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>();
}
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);
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.
AddButton(EngineKeyFunctions.ShowDebugMonitors);
AddButton(EngineKeyFunctions.HideUI);
AddButton(ContentKeyFunctions.InspectEntity);
+ AddButton(ContentKeyFunctions.InspectServerComponent);
+ AddButton(ContentKeyFunctions.InspectClientComponent);
AddHeader("ui-options-header-text-cursor");
AddButton(EngineKeyFunctions.TextCursorLeft);
--- /dev/null
+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);
+}
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";
--- /dev/null
+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.
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
- fullstatereset
- dumpentities
- showaccessreaders
+ - quickinspect
- Flags: MAPPING
Commands:
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