Fix right clicking entries in the admin objects tab (#11866)
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
using Content.Client.Administration.Managers;
|
using Content.Client.Administration.Managers;
|
||||||
using Content.Client.Administration.UI;
|
using Content.Client.Administration.UI;
|
||||||
|
using Content.Client.Administration.UI.Tabs.ObjectsTab;
|
||||||
using Content.Client.Administration.UI.Tabs.PlayerTab;
|
using Content.Client.Administration.UI.Tabs.PlayerTab;
|
||||||
using Content.Client.Gameplay;
|
using Content.Client.Gameplay;
|
||||||
using Content.Client.UserInterface.Controls;
|
using Content.Client.UserInterface.Controls;
|
||||||
@@ -34,15 +35,16 @@ public sealed class AdminUIController : UIController, IOnStateEntered<GameplaySt
|
|||||||
public void OnStateEntered(GameplayState state)
|
public void OnStateEntered(GameplayState state)
|
||||||
{
|
{
|
||||||
DebugTools.Assert(_window == null);
|
DebugTools.Assert(_window == null);
|
||||||
|
|
||||||
_window = UIManager.CreateWindow<AdminMenuWindow>();
|
_window = UIManager.CreateWindow<AdminMenuWindow>();
|
||||||
_adminButton = UIManager.GetActiveUIWidget<MenuBar.Widgets.GameTopMenuBar>().AdminButton;
|
_adminButton = UIManager.GetActiveUIWidget<MenuBar.Widgets.GameTopMenuBar>().AdminButton;
|
||||||
LayoutContainer.SetAnchorPreset(_window, LayoutContainer.LayoutPreset.Center);
|
LayoutContainer.SetAnchorPreset(_window, LayoutContainer.LayoutPreset.Center);
|
||||||
|
|
||||||
_window.PlayerTabControl.OnEntryPressed += PlayerTabEntryPressed;
|
_window.PlayerTabControl.OnEntryPressed += PlayerTabEntryPressed;
|
||||||
_window.OnOpen += () => _adminButton.Pressed = true;
|
_window.ObjectsTabControl.OnEntryPressed += ObjectsTabEntryPressed;
|
||||||
_window.OnClose += () => _adminButton.Pressed = false;
|
_window.OnOpen += OnWindowOpen;
|
||||||
|
_window.OnClose += OnWindowClosed;
|
||||||
_admin.AdminStatusUpdated += AdminStatusUpdated;
|
_admin.AdminStatusUpdated += AdminStatusUpdated;
|
||||||
|
|
||||||
_adminButton.OnPressed += AdminButtonPressed;
|
_adminButton.OnPressed += AdminButtonPressed;
|
||||||
|
|
||||||
_input.SetInputCommand(ContentKeyFunctions.OpenAdminMenu,
|
_input.SetInputCommand(ContentKeyFunctions.OpenAdminMenu,
|
||||||
@@ -51,10 +53,27 @@ public sealed class AdminUIController : UIController, IOnStateEntered<GameplaySt
|
|||||||
AdminStatusUpdated();
|
AdminStatusUpdated();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnWindowOpen()
|
||||||
|
{
|
||||||
|
if (_adminButton != null)
|
||||||
|
_adminButton.Pressed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnWindowClosed()
|
||||||
|
{
|
||||||
|
if (_adminButton != null)
|
||||||
|
_adminButton.Pressed = false;
|
||||||
|
}
|
||||||
|
|
||||||
public void OnStateExited(GameplayState state)
|
public void OnStateExited(GameplayState state)
|
||||||
{
|
{
|
||||||
if (_window != null)
|
if (_window != null)
|
||||||
{
|
{
|
||||||
|
_window.PlayerTabControl.OnEntryPressed -= PlayerTabEntryPressed;
|
||||||
|
_window.ObjectsTabControl.OnEntryPressed -= ObjectsTabEntryPressed;
|
||||||
|
_window.OnOpen -= OnWindowOpen;
|
||||||
|
_window.OnClose -= OnWindowClosed;
|
||||||
|
|
||||||
_window.Dispose();
|
_window.Dispose();
|
||||||
_window = null;
|
_window = null;
|
||||||
}
|
}
|
||||||
@@ -111,4 +130,22 @@ public sealed class AdminUIController : UIController, IOnStateEntered<GameplaySt
|
|||||||
|
|
||||||
args.Event.Handle();
|
args.Event.Handle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ObjectsTabEntryPressed(ButtonEventArgs args)
|
||||||
|
{
|
||||||
|
if (args.Button is not ObjectsTabEntry button)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var uid = button.AssocEntity;
|
||||||
|
var function = args.Event.Function;
|
||||||
|
|
||||||
|
if (function == EngineKeyFunctions.UIClick)
|
||||||
|
_conHost.ExecuteCommand($"vv {uid}");
|
||||||
|
else if (function == EngineKeyFunctions.UseSecondary)
|
||||||
|
_verbs.VerbMenu.OpenVerbMenu(uid, true);
|
||||||
|
else
|
||||||
|
return;
|
||||||
|
|
||||||
|
args.Event.Handle();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user