]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix right click not showing the context menu in AHelps, players tab and objects tab...
authorDrSmugleaf <DrSmugleaf@users.noreply.github.com>
Thu, 21 Dec 2023 06:32:52 +0000 (22:32 -0800)
committerGitHub <noreply@github.com>
Thu, 21 Dec 2023 06:32:52 +0000 (23:32 -0700)
* Fix right clicks in AHelp window

* Fix player tab right click

* Fix objects tab right click

Content.Client/Administration/UI/CustomControls/PlayerListControl.xaml.cs
Content.Client/Administration/UI/Tabs/ObjectsTab/ObjectsTab.xaml.cs
Content.Client/Administration/UI/Tabs/PlayerTab/PlayerTab.xaml.cs
Content.Client/UserInterface/Controls/ListContainer.cs
Content.Client/UserInterface/Systems/Admin/AdminUIController.cs

index 050262cc991d6346c868f928037e372ef464e93b..41c3ac76f980484dcf8c69ebe9bb1726f545a435 100644 (file)
@@ -1,10 +1,8 @@
 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;
@@ -39,6 +37,7 @@ namespace Content.Client.Administration.UI.CustomControls
             RobustXamlLoader.Load(this);
             // Fill the Option data
             PlayerListContainer.ItemPressed += PlayerListItemPressed;
+            PlayerListContainer.ItemKeyBindDown += PlayerListItemKeyBindDown;
             PlayerListContainer.GenerateItem += GenerateButton;
             PopulateList(_adminSystem.PlayerList);
             FilterLineEdit.OnTextChanged += _ => FilterList();
@@ -50,18 +49,27 @@ namespace Content.Client.Administration.UI.CustomControls
         {
             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()
index 3f5df2cf006bd2977b8ed687ad0cbd4cdc8c0e92..dcb184b3083302d3edf354b8352e478498cc2e22 100644 (file)
@@ -1,7 +1,6 @@
 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;
 
@@ -15,7 +14,7 @@ public sealed partial class ObjectsTab : Control
     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()
     {
@@ -82,7 +81,7 @@ public sealed partial class ObjectsTab : Control
             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);
         }
     }
 
index 1190a4c329c50006b7e5a4c427b42d33faa9aa59..33a1d2361f28393a8e291e83f1ae562098aeaebf 100644 (file)
@@ -28,7 +28,7 @@ namespace Content.Client.Administration.UI.Tabs.PlayerTab
         private bool _ascending = true;
         private bool _showDisconnected;
 
-        public event Action<ButtonEventArgs>? OnEntryPressed;
+        public event Action<PlayerTabEntry, GUIBoundKeyEventArgs>? OnEntryKeyBindDown;
 
         public PlayerTab()
         {
@@ -123,7 +123,7 @@ namespace Content.Client.Administration.UI.Tabs.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);
 
index c66ef33d3f879e59e2261d0fe6284418def7fda0..05ae0a4bb1555da13fa6498fd729a9d85edd720b 100644 (file)
@@ -23,6 +23,7 @@ public sealed class ListContainer : Control
     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;
@@ -135,6 +136,11 @@ public sealed class ListContainer : Control
         ItemPressed?.Invoke(args, button.Data);
     }
 
+    private void OnItemKeyBindDown(ListContainerButton button, GUIBoundKeyEventArgs args)
+    {
+        ItemKeyBindDown?.Invoke(args, button.Data);
+    }
+
     [Pure]
     private Vector2 GetScrollValue()
     {
@@ -256,6 +262,7 @@ public sealed class ListContainer : Control
                     {
                         button = new ListContainerButton(data);
                         button.OnPressed += OnItemPressed;
+                        button.OnKeyBindDown += args => OnItemKeyBindDown(button, args);
                         button.ToggleMode = Toggle;
                         button.Group = _buttonGroup;
 
index acb79cf3012dbe6edf8e082b6033de1d695fe487..a7ece3714da588210dbdac20e81314056fa73591 100644 (file)
@@ -13,6 +13,7 @@ using Content.Shared.Input;
 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;
@@ -97,8 +98,8 @@ public sealed class AdminUIController : UIController, IOnStateEntered<GameplaySt
         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;
@@ -144,8 +145,8 @@ public sealed class AdminUIController : UIController, IOnStateEntered<GameplaySt
         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;
@@ -175,32 +176,28 @@ public sealed class AdminUIController : UIController, IOnStateEntered<GameplaySt
         }
     }
 
-    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}");
@@ -209,6 +206,6 @@ public sealed class AdminUIController : UIController, IOnStateEntered<GameplaySt
         else
             return;
 
-        args.Event.Handle();
+        args.Handle();
     }
 }