Add keybinds for openening a specified component in VV (#41348)
* 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>
This commit is contained in:
52
Content.Client/Commands/QuickInspectCommand.cs
Normal file
52
Content.Client/Commands/QuickInspectCommand.cs
Normal file
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@ using System.Numerics;
|
|||||||
using Content.Client.Clickable;
|
using Content.Client.Clickable;
|
||||||
using Content.Client.UserInterface;
|
using Content.Client.UserInterface;
|
||||||
using Content.Client.Viewport;
|
using Content.Client.Viewport;
|
||||||
|
using Content.Shared.CCVar;
|
||||||
using Content.Shared.Input;
|
using Content.Shared.Input;
|
||||||
using Robust.Client.ComponentTrees;
|
using Robust.Client.ComponentTrees;
|
||||||
using Robust.Client.GameObjects;
|
using Robust.Client.GameObjects;
|
||||||
@@ -13,6 +14,7 @@ using Robust.Client.State;
|
|||||||
using Robust.Client.UserInterface;
|
using Robust.Client.UserInterface;
|
||||||
using Robust.Client.UserInterface.Controls;
|
using Robust.Client.UserInterface.Controls;
|
||||||
using Robust.Client.UserInterface.CustomControls;
|
using Robust.Client.UserInterface.CustomControls;
|
||||||
|
using Robust.Shared.Configuration;
|
||||||
using Robust.Shared.Console;
|
using Robust.Shared.Console;
|
||||||
using Robust.Shared.Graphics;
|
using Robust.Shared.Graphics;
|
||||||
using Robust.Shared.Input;
|
using Robust.Shared.Input;
|
||||||
@@ -40,6 +42,7 @@ namespace Content.Client.Gameplay
|
|||||||
[Dependency] private readonly IEntityManager _entityManager = default!;
|
[Dependency] private readonly IEntityManager _entityManager = default!;
|
||||||
[Dependency] private readonly IViewVariablesManager _vvm = default!;
|
[Dependency] private readonly IViewVariablesManager _vvm = default!;
|
||||||
[Dependency] private readonly IConsoleHost _conHost = default!;
|
[Dependency] private readonly IConsoleHost _conHost = default!;
|
||||||
|
[Dependency] private readonly IConfigurationManager _configurationManager = default!;
|
||||||
|
|
||||||
private ClickableEntityComparer _comparer = default!;
|
private ClickableEntityComparer _comparer = default!;
|
||||||
|
|
||||||
@@ -83,6 +86,8 @@ namespace Content.Client.Gameplay
|
|||||||
_comparer = new ClickableEntityComparer();
|
_comparer = new ClickableEntityComparer();
|
||||||
CommandBinds.Builder
|
CommandBinds.Builder
|
||||||
.Bind(ContentKeyFunctions.InspectEntity, new PointerInputCmdHandler(HandleInspect, outsidePrediction: true))
|
.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>();
|
.Register<GameplayStateBase>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,6 +104,21 @@ namespace Content.Client.Gameplay
|
|||||||
return true;
|
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)
|
public EntityUid? GetClickedEntity(MapCoordinates coordinates)
|
||||||
{
|
{
|
||||||
return GetClickedEntity(coordinates, _eyeManager.CurrentEye);
|
return GetClickedEntity(coordinates, _eyeManager.CurrentEye);
|
||||||
|
|||||||
@@ -38,6 +38,8 @@ namespace Content.Client.Input
|
|||||||
common.AddFunction(ContentKeyFunctions.ZoomIn);
|
common.AddFunction(ContentKeyFunctions.ZoomIn);
|
||||||
common.AddFunction(ContentKeyFunctions.ResetZoom);
|
common.AddFunction(ContentKeyFunctions.ResetZoom);
|
||||||
common.AddFunction(ContentKeyFunctions.InspectEntity);
|
common.AddFunction(ContentKeyFunctions.InspectEntity);
|
||||||
|
common.AddFunction(ContentKeyFunctions.InspectServerComponent);
|
||||||
|
common.AddFunction(ContentKeyFunctions.InspectClientComponent);
|
||||||
common.AddFunction(ContentKeyFunctions.ToggleRoundEndSummaryWindow);
|
common.AddFunction(ContentKeyFunctions.ToggleRoundEndSummaryWindow);
|
||||||
|
|
||||||
// Not in engine, because engine cannot check for sanbox/admin status before starting placement.
|
// Not in engine, because engine cannot check for sanbox/admin status before starting placement.
|
||||||
|
|||||||
@@ -268,6 +268,8 @@ namespace Content.Client.Options.UI.Tabs
|
|||||||
AddButton(EngineKeyFunctions.ShowDebugMonitors);
|
AddButton(EngineKeyFunctions.ShowDebugMonitors);
|
||||||
AddButton(EngineKeyFunctions.HideUI);
|
AddButton(EngineKeyFunctions.HideUI);
|
||||||
AddButton(ContentKeyFunctions.InspectEntity);
|
AddButton(ContentKeyFunctions.InspectEntity);
|
||||||
|
AddButton(ContentKeyFunctions.InspectServerComponent);
|
||||||
|
AddButton(ContentKeyFunctions.InspectClientComponent);
|
||||||
|
|
||||||
AddHeader("ui-options-header-text-cursor");
|
AddHeader("ui-options-header-text-cursor");
|
||||||
AddButton(EngineKeyFunctions.TextCursorLeft);
|
AddButton(EngineKeyFunctions.TextCursorLeft);
|
||||||
|
|||||||
13
Content.Shared/CCVar/CCVars.Debug.cs
Normal file
13
Content.Shared/CCVar/CCVars.Debug.cs
Normal file
@@ -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);
|
||||||
|
}
|
||||||
@@ -123,7 +123,8 @@ namespace Content.Shared.Input
|
|||||||
public static readonly BoundKeyFunction EditorCopyObject = "EditorCopyObject";
|
public static readonly BoundKeyFunction EditorCopyObject = "EditorCopyObject";
|
||||||
public static readonly BoundKeyFunction EditorFlipObject = "EditorFlipObject";
|
public static readonly BoundKeyFunction EditorFlipObject = "EditorFlipObject";
|
||||||
public static readonly BoundKeyFunction InspectEntity = "InspectEntity";
|
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 MappingUnselect = "MappingUnselect";
|
||||||
public static readonly BoundKeyFunction SaveMap = "SaveMap";
|
public static readonly BoundKeyFunction SaveMap = "SaveMap";
|
||||||
public static readonly BoundKeyFunction MappingEnablePick = "MappingEnablePick";
|
public static readonly BoundKeyFunction MappingEnablePick = "MappingEnablePick";
|
||||||
|
|||||||
@@ -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.
|
||||||
@@ -227,6 +227,11 @@ ui-options-function-editor-copy-object = Copy
|
|||||||
ui-options-function-show-debug-console = Open Console
|
ui-options-function-show-debug-console = Open Console
|
||||||
ui-options-function-show-debug-monitors = Show Debug Monitors
|
ui-options-function-show-debug-monitors = Show Debug Monitors
|
||||||
ui-options-function-inspect-entity = Inspect Entity
|
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-hide-ui = Hide UI
|
||||||
|
|
||||||
ui-options-function-hotbar1 = Hotbar slot 1
|
ui-options-function-hotbar1 = Hotbar slot 1
|
||||||
|
|||||||
@@ -74,6 +74,7 @@
|
|||||||
- fullstatereset
|
- fullstatereset
|
||||||
- dumpentities
|
- dumpentities
|
||||||
- showaccessreaders
|
- showaccessreaders
|
||||||
|
- quickinspect
|
||||||
|
|
||||||
- Flags: MAPPING
|
- Flags: MAPPING
|
||||||
Commands:
|
Commands:
|
||||||
|
|||||||
@@ -281,6 +281,14 @@ binds:
|
|||||||
type: State
|
type: State
|
||||||
key: v
|
key: v
|
||||||
mod1: Alt
|
mod1: Alt
|
||||||
|
- function: InspectServerComponent
|
||||||
|
type: State
|
||||||
|
key: b
|
||||||
|
mod1: Alt
|
||||||
|
- function: InspectClientComponent
|
||||||
|
type: State
|
||||||
|
key: c
|
||||||
|
mod1: Alt
|
||||||
- function: MouseMiddle
|
- function: MouseMiddle
|
||||||
type: State
|
type: State
|
||||||
key: MouseMiddle
|
key: MouseMiddle
|
||||||
|
|||||||
Reference in New Issue
Block a user