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;
|
||||||
using Content.Client.Administration.UI.Tabs.PlayerTab;
|
using Content.Client.Administration.UI.Tabs.PlayerTab;
|
||||||
using Content.Client.HUD;
|
using Content.Client.HUD;
|
||||||
|
using Content.Client.Verbs;
|
||||||
using Content.Shared.Input;
|
using Content.Shared.Input;
|
||||||
using Robust.Client.Console;
|
using Robust.Client.Console;
|
||||||
using Robust.Client.Graphics;
|
using Robust.Client.Graphics;
|
||||||
@@ -11,6 +12,7 @@ using Robust.Client.ResourceManagement;
|
|||||||
using Robust.Client.UserInterface.Controls;
|
using Robust.Client.UserInterface.Controls;
|
||||||
using Robust.Client.UserInterface.CustomControls;
|
using Robust.Client.UserInterface.CustomControls;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
|
using Robust.Shared.Input;
|
||||||
using Robust.Shared.Input.Binding;
|
using Robust.Shared.Input.Binding;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Network;
|
using Robust.Shared.Network;
|
||||||
@@ -30,6 +32,8 @@ namespace Content.Client.Administration
|
|||||||
[Dependency] private readonly IEntityLookup _entityLookup = default!;
|
[Dependency] private readonly IEntityLookup _entityLookup = default!;
|
||||||
[Dependency] private readonly IClientConsoleHost _clientConsoleHost = default!;
|
[Dependency] private readonly IClientConsoleHost _clientConsoleHost = default!;
|
||||||
|
|
||||||
|
[Dependency] private readonly VerbSystem _verbSystem = default!;
|
||||||
|
|
||||||
private AdminMenuWindow? _window;
|
private AdminMenuWindow? _window;
|
||||||
private readonly List<BaseWindow> _commandWindows = new();
|
private readonly List<BaseWindow> _commandWindows = new();
|
||||||
|
|
||||||
@@ -142,7 +146,17 @@ namespace Content.Client.Administration
|
|||||||
|| button.PlayerUid == null)
|
|| button.PlayerUid == null)
|
||||||
return;
|
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 System.Collections.Generic;
|
||||||
using Content.Client.Administration.UI.CustomControls;
|
using Content.Client.Administration.UI.CustomControls;
|
||||||
using Content.Shared.Administration;
|
using Content.Shared.Administration;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<ContainerButton xmlns="https://spacestation14.io"
|
<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"/>
|
<PanelContainer Name="BackgroundColorPanel"/>
|
||||||
<BoxContainer Orientation="Horizontal"
|
<BoxContainer Orientation="Horizontal"
|
||||||
HorizontalExpand="True"
|
HorizontalExpand="True"
|
||||||
|
|||||||
@@ -41,7 +41,9 @@ namespace Content.Client.Verbs.UI
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Open a verb menu and fill it work verbs applicable to the given target entity.
|
/// Open a verb menu and fill it work verbs applicable to the given target entity.
|
||||||
/// </summary>
|
/// </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)
|
if (_playerManager.LocalPlayer?.ControlledEntity is not {Valid: true} user)
|
||||||
return;
|
return;
|
||||||
@@ -49,7 +51,7 @@ namespace Content.Client.Verbs.UI
|
|||||||
Close();
|
Close();
|
||||||
|
|
||||||
CurrentTarget = target;
|
CurrentTarget = target;
|
||||||
CurrentVerbs = _verbSystem.GetVerbs(target, user, VerbType.All);
|
CurrentVerbs = _verbSystem.GetVerbs(target, user, VerbType.All, force);
|
||||||
|
|
||||||
if (!target.IsClientSide())
|
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
|
/// 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).
|
/// (only those defined locally).
|
||||||
/// </summary>
|
/// </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())
|
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>
|
/// <summary>
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
|
using Content.Server.Administration.Managers;
|
||||||
using Content.Server.Popups;
|
using Content.Server.Popups;
|
||||||
|
using Content.Shared.Administration;
|
||||||
using Content.Shared.Administration.Logs;
|
using Content.Shared.Administration.Logs;
|
||||||
using Content.Shared.Database;
|
using Content.Shared.Database;
|
||||||
using Content.Shared.Hands.Components;
|
using Content.Shared.Hands.Components;
|
||||||
@@ -15,6 +17,7 @@ namespace Content.Server.Verbs
|
|||||||
{
|
{
|
||||||
[Dependency] private readonly SharedAdminLogSystem _logSystem = default!;
|
[Dependency] private readonly SharedAdminLogSystem _logSystem = default!;
|
||||||
[Dependency] private readonly PopupSystem _popupSystem = default!;
|
[Dependency] private readonly PopupSystem _popupSystem = default!;
|
||||||
|
[Dependency] private readonly IAdminManager _adminMgr = default!;
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
@@ -43,7 +46,11 @@ namespace Content.Server.Verbs
|
|||||||
// this, and some verbs (e.g. view variables) won't even care about whether an entity is accessible through
|
// this, and some verbs (e.g. view variables) won't even care about whether an entity is accessible through
|
||||||
// the entity menu or not.
|
// the entity menu or not.
|
||||||
|
|
||||||
var response = new VerbsResponseEvent(args.EntityUid, GetLocalVerbs(args.EntityUid, attached, args.Type));
|
var force = args.AdminRequest && eventArgs.SenderSession is IPlayerSession playerSession &&
|
||||||
|
_adminMgr.HasAdminFlag(playerSession, AdminFlags.Admin);
|
||||||
|
|
||||||
|
var response =
|
||||||
|
new VerbsResponseEvent(args.EntityUid, GetLocalVerbs(args.EntityUid, attached, args.Type, force));
|
||||||
RaiseNetworkEvent(response, player.ConnectedClient);
|
RaiseNetworkEvent(response, player.ConnectedClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ namespace Content.Shared.Verbs
|
|||||||
bool canAccess = false;
|
bool canAccess = false;
|
||||||
if (force || target == user)
|
if (force || target == user)
|
||||||
canAccess = true;
|
canAccess = true;
|
||||||
else if (_interactionSystem.InRangeUnobstructed(user, target, ignoreInsideBlocker: true))
|
else if (EntityManager.EntityExists(target) && _interactionSystem.InRangeUnobstructed(user, target, ignoreInsideBlocker: true))
|
||||||
{
|
{
|
||||||
if (user.IsInSameOrParentContainer(target))
|
if (user.IsInSameOrParentContainer(target))
|
||||||
canAccess = true;
|
canAccess = true;
|
||||||
|
|||||||
@@ -21,12 +21,14 @@ namespace Content.Shared.Verbs
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly EntityUid? SlotOwner;
|
public readonly EntityUid? SlotOwner;
|
||||||
|
|
||||||
|
public readonly bool AdminRequest;
|
||||||
|
|
||||||
public RequestServerVerbsEvent(EntityUid entityUid, VerbType type, EntityUid? slotOwner = null)
|
public RequestServerVerbsEvent(EntityUid entityUid, VerbType type, EntityUid? slotOwner = null, bool adminRequest = false)
|
||||||
{
|
{
|
||||||
EntityUid = entityUid;
|
EntityUid = entityUid;
|
||||||
Type = type;
|
Type = type;
|
||||||
SlotOwner = slotOwner;
|
SlotOwner = slotOwner;
|
||||||
|
AdminRequest = adminRequest;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user