Add context menu to AdminMenu PlayerTab entries (#5904)
* XAML PlayerTab entries * Move command execution to PlayerTab * Move command logic to the AdminSystem * Clean up * Add examine and context menu keybind handling to PlayerTab * Fix remote admin verbs * Remove examine for now * Add server verbs * Fix requests of verb by non-admins * Clean up AdminSystem.Menu
This commit is contained in:
@@ -3,6 +3,7 @@ using Content.Client.Administration.Managers;
|
||||
using Content.Client.Administration.UI;
|
||||
using Content.Client.Administration.UI.Tabs.PlayerTab;
|
||||
using Content.Client.HUD;
|
||||
using Content.Client.Verbs;
|
||||
using Content.Shared.Input;
|
||||
using Robust.Client.Console;
|
||||
using Robust.Client.Graphics;
|
||||
@@ -11,6 +12,7 @@ using Robust.Client.ResourceManagement;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Input;
|
||||
using Robust.Shared.Input.Binding;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Network;
|
||||
@@ -30,6 +32,8 @@ namespace Content.Client.Administration
|
||||
[Dependency] private readonly IEntityLookup _entityLookup = default!;
|
||||
[Dependency] private readonly IClientConsoleHost _clientConsoleHost = default!;
|
||||
|
||||
[Dependency] private readonly VerbSystem _verbSystem = default!;
|
||||
|
||||
private AdminMenuWindow? _window;
|
||||
private readonly List<BaseWindow> _commandWindows = new();
|
||||
|
||||
@@ -142,7 +146,17 @@ namespace Content.Client.Administration
|
||||
|| button.PlayerUid == null)
|
||||
return;
|
||||
|
||||
_clientConsoleHost.ExecuteCommand($"vv {button.PlayerUid}");
|
||||
var uid = button.PlayerUid.Value;
|
||||
var function = args.Event.Function;
|
||||
|
||||
if (function == EngineKeyFunctions.UIClick)
|
||||
_clientConsoleHost.ExecuteCommand($"vv {uid}");
|
||||
else if (function == ContentKeyFunctions.OpenContextMenu)
|
||||
_verbSystem.VerbMenu.OpenVerbMenu(uid, true);
|
||||
else
|
||||
return;
|
||||
|
||||
args.Event.Handle();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Content.Client.Administration.UI.CustomControls;
|
||||
using Content.Shared.Administration;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<ContainerButton xmlns="https://spacestation14.io"
|
||||
xmlns:customControls="clr-namespace:Content.Client.Administration.UI.CustomControls">
|
||||
xmlns:customControls="clr-namespace:Content.Client.Administration.UI.CustomControls"
|
||||
EnableAllKeybinds="True">
|
||||
<PanelContainer Name="BackgroundColorPanel"/>
|
||||
<BoxContainer Orientation="Horizontal"
|
||||
HorizontalExpand="True"
|
||||
|
||||
@@ -41,7 +41,9 @@ namespace Content.Client.Verbs.UI
|
||||
/// <summary>
|
||||
/// Open a verb menu and fill it work verbs applicable to the given target entity.
|
||||
/// </summary>
|
||||
public void OpenVerbMenu(EntityUid target)
|
||||
/// <param name="target">Entity to get verbs on.</param>
|
||||
/// <param name="force">Used to force showing all verbs (mostly for admins).</param>
|
||||
public void OpenVerbMenu(EntityUid target, bool force = false)
|
||||
{
|
||||
if (_playerManager.LocalPlayer?.ControlledEntity is not {Valid: true} user)
|
||||
return;
|
||||
@@ -49,7 +51,7 @@ namespace Content.Client.Verbs.UI
|
||||
Close();
|
||||
|
||||
CurrentTarget = target;
|
||||
CurrentVerbs = _verbSystem.GetVerbs(target, user, VerbType.All);
|
||||
CurrentVerbs = _verbSystem.GetVerbs(target, user, VerbType.All, force);
|
||||
|
||||
if (!target.IsClientSide())
|
||||
{
|
||||
|
||||
@@ -180,14 +180,15 @@ namespace Content.Client.Verbs
|
||||
/// Ask the server to send back a list of server-side verbs, and for now return an incomplete list of verbs
|
||||
/// (only those defined locally).
|
||||
/// </summary>
|
||||
public Dictionary<VerbType, SortedSet<Verb>> GetVerbs(EntityUid target, EntityUid user, VerbType verbTypes)
|
||||
public Dictionary<VerbType, SortedSet<Verb>> GetVerbs(EntityUid target, EntityUid user, VerbType verbTypes,
|
||||
bool force = false)
|
||||
{
|
||||
if (!target.IsClientSide())
|
||||
{
|
||||
RaiseNetworkEvent(new RequestServerVerbsEvent(target, verbTypes));
|
||||
RaiseNetworkEvent(new RequestServerVerbsEvent(target, verbTypes, adminRequest: force));
|
||||
}
|
||||
|
||||
return GetLocalVerbs(target, user, verbTypes);
|
||||
return GetLocalVerbs(target, user, verbTypes, force);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user