using System.Linq;
using Content.Client.Administration.Systems;
using Content.Client.UserInterface.Controls;
-using Content.Client.Verbs;
using Content.Client.Verbs.UI;
using Content.Shared.Administration;
-using Content.Shared.Input;
using Robust.Client.AutoGenerated;
using Robust.Client.Graphics;
using Robust.Client.UserInterface;
RobustXamlLoader.Load(this);
// Fill the Option data
PlayerListContainer.ItemPressed += PlayerListItemPressed;
+ PlayerListContainer.ItemKeyBindDown += PlayerListItemKeyBindDown;
PlayerListContainer.GenerateItem += GenerateButton;
PopulateList(_adminSystem.PlayerList);
FilterLineEdit.OnTextChanged += _ => FilterList();
{
if (args == null || data is not PlayerListData {Info: var selectedPlayer})
return;
- if (args.Event.Function == EngineKeyFunctions.UIClick)
- {
- OnSelectionChanged?.Invoke(selectedPlayer);
- // update label text. Only required if there is some override (e.g. unread bwoink count).
- if (OverrideText != null && args.Button.Children.FirstOrDefault()?.Children?.FirstOrDefault() is Label label)
- label.Text = GetText(selectedPlayer);
- }
- else if (args.Event.Function == EngineKeyFunctions.UseSecondary && selectedPlayer.NetEntity != null)
- {
- _uiManager.GetUIController<VerbMenuUIController>().OpenVerbMenu(selectedPlayer.NetEntity.Value, true);
- }
+ if (args.Event.Function != EngineKeyFunctions.UIClick)
+ return;
+
+ OnSelectionChanged?.Invoke(selectedPlayer);
+
+ // update label text. Only required if there is some override (e.g. unread bwoink count).
+ if (OverrideText != null && args.Button.Children.FirstOrDefault()?.Children?.FirstOrDefault() is Label label)
+ label.Text = GetText(selectedPlayer);
+ }
+
+ private void PlayerListItemKeyBindDown(GUIBoundKeyEventArgs? args, ListData? data)
+ {
+ if (args == null || data is not PlayerListData { Info: var selectedPlayer })
+ return;
+
+ if (args.Function != EngineKeyFunctions.UIRightClick || selectedPlayer.NetEntity == null)
+ return;
+
+ _uiManager.GetUIController<VerbMenuUIController>().OpenVerbMenu(selectedPlayer.NetEntity.Value, true);
+ args.Handle();
}
public void StopFiltering()
using Content.Client.Station;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface;
-using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Map.Components;
private readonly List<ObjectsTabEntry> _objects = new();
private List<ObjectsTabSelection> _selections = new();
- public event Action<BaseButton.ButtonEventArgs>? OnEntryPressed;
+ public event Action<ObjectsTabEntry, GUIBoundKeyEventArgs>? OnEntryKeyBindDown;
public ObjectsTab()
{
var ctrl = new ObjectsTabEntry(name, entity);
_objects.Add(ctrl);
ObjectList.AddChild(ctrl);
- ctrl.OnPressed += args => OnEntryPressed?.Invoke(args);
+ ctrl.OnKeyBindDown += args => OnEntryKeyBindDown?.Invoke(ctrl, args);
}
}
private bool _ascending = true;
private bool _showDisconnected;
- public event Action<ButtonEventArgs>? OnEntryPressed;
+ public event Action<PlayerTabEntry, GUIBoundKeyEventArgs>? OnEntryKeyBindDown;
public PlayerTab()
{
player.Connected,
player.PlaytimeString);
entry.PlayerEntity = player.NetEntity;
- entry.OnPressed += args => OnEntryPressed?.Invoke(args);
+ entry.OnKeyBindDown += args => OnEntryKeyBindDown?.Invoke(entry, args);
entry.ToolTip = Loc.GetString("player-tab-entry-tooltip");
PlayerList.AddChild(entry);
public bool Toggle { get; set; }
public Action<ListData, ListContainerButton>? GenerateItem;
public Action<BaseButton.ButtonEventArgs?, ListData?>? ItemPressed;
+ public Action<GUIBoundKeyEventArgs, ListData?>? ItemKeyBindDown;
public IReadOnlyList<ListData> Data => _data;
private const int DefaultSeparation = 3;
ItemPressed?.Invoke(args, button.Data);
}
+ private void OnItemKeyBindDown(ListContainerButton button, GUIBoundKeyEventArgs args)
+ {
+ ItemKeyBindDown?.Invoke(args, button.Data);
+ }
+
[Pure]
private Vector2 GetScrollValue()
{
{
button = new ListContainerButton(data);
button.OnPressed += OnItemPressed;
+ button.OnKeyBindDown += args => OnItemKeyBindDown(button, args);
button.ToggleMode = Toggle;
button.Group = _buttonGroup;
using JetBrains.Annotations;
using Robust.Client.Console;
using Robust.Client.Input;
+using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controllers;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.Input;
if (_panicBunker != null)
_window.PanicBunkerControl.UpdateStatus(_panicBunker);
- _window.PlayerTabControl.OnEntryPressed += PlayerTabEntryPressed;
- _window.ObjectsTabControl.OnEntryPressed += ObjectsTabEntryPressed;
+ _window.PlayerTabControl.OnEntryKeyBindDown += PlayerTabEntryKeyBindDown;
+ _window.ObjectsTabControl.OnEntryKeyBindDown += ObjectsTabEntryKeyBindDown;
_window.OnOpen += OnWindowOpen;
_window.OnClose += OnWindowClosed;
_window.OnDisposed += OnWindowDisposed;
if (_window == null)
return;
- _window.PlayerTabControl.OnEntryPressed -= PlayerTabEntryPressed;
- _window.ObjectsTabControl.OnEntryPressed -= ObjectsTabEntryPressed;
+ _window.PlayerTabControl.OnEntryKeyBindDown -= PlayerTabEntryKeyBindDown;
+ _window.ObjectsTabControl.OnEntryKeyBindDown -= ObjectsTabEntryKeyBindDown;
_window.OnOpen -= OnWindowOpen;
_window.OnClose -= OnWindowClosed;
_window.OnDisposed -= OnWindowDisposed;
}
}
- private void PlayerTabEntryPressed(ButtonEventArgs args)
+ private void PlayerTabEntryKeyBindDown(PlayerTabEntry entry, GUIBoundKeyEventArgs args)
{
- if (args.Button is not PlayerTabEntry button
- || button.PlayerEntity == null)
+ if (entry.PlayerEntity == null)
return;
- var entity = button.PlayerEntity.Value;
- var function = args.Event.Function;
+ var entity = entry.PlayerEntity.Value;
+ var function = args.Function;
if (function == EngineKeyFunctions.UIClick)
_conHost.ExecuteCommand($"vv {entity}");
- else if (function == EngineKeyFunctions.UseSecondary)
+ else if (function == EngineKeyFunctions.UIRightClick)
_verb.OpenVerbMenu(entity, true);
else
return;
- args.Event.Handle();
+ args.Handle();
}
- private void ObjectsTabEntryPressed(ButtonEventArgs args)
+ private void ObjectsTabEntryKeyBindDown(ObjectsTabEntry entry, GUIBoundKeyEventArgs args)
{
- if (args.Button is not ObjectsTabEntry button)
- return;
-
- var uid = button.AssocEntity;
- var function = args.Event.Function;
+ var uid = entry.AssocEntity;
+ var function = args.Function;
if (function == EngineKeyFunctions.UIClick)
_conHost.ExecuteCommand($"vv {uid}");
else
return;
- args.Event.Handle();
+ args.Handle();
}
}