]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fixed issue with the station map UI (#22848)
authorchromiumboy <50505512+chromiumboy@users.noreply.github.com>
Fri, 22 Dec 2023 07:15:51 +0000 (01:15 -0600)
committerGitHub <noreply@github.com>
Fri, 22 Dec 2023 07:15:51 +0000 (18:15 +1100)
Fixed issue with dragging the nav map in the station map UI

Content.Client/Pinpointer/UI/NavMapControl.cs

index cae5e15037d559f4d42b8e246a40b3c9832f8714..438c06f7f2ee752e0ebff283e6df658923d22bc5 100644 (file)
@@ -45,10 +45,12 @@ public partial class NavMapControl : MapGridControl
     protected float UpdateTime = 1.0f;
     protected float MaxSelectableDistance = 10f;
     protected float RecenterMinimum = 0.05f;
+    protected float MinDragDistance = 5f;
 
     // Local variables
     private Vector2 _offset;
     private bool _draggin;
+    private Vector2 _startDragPosition = default!;
     private bool _recentering = false;
     private readonly Font _font;
     private float _updateTimer = 0.25f;
@@ -168,23 +170,31 @@ public partial class NavMapControl : MapGridControl
         base.KeyBindDown(args);
 
         if (args.Function == EngineKeyFunctions.Use)
+        {
+            _startDragPosition = args.PointerLocation.Position;
             _draggin = true;
+        }
     }
 
     protected override void KeyBindUp(GUIBoundKeyEventArgs args)
     {
         base.KeyBindUp(args);
 
+        if (args.Function == EngineKeyFunctions.Use)
+            _draggin = false;
+
         if (TrackedEntitySelectedAction == null)
             return;
 
         if (args.Function == EngineKeyFunctions.Use)
         {
-            _draggin = false;
-
             if (_xform == null || _physics == null || TrackedEntities.Count == 0)
                 return;
 
+            // If the cursor has moved a significant distance, exit
+            if ((_startDragPosition - args.PointerLocation.Position).Length() > MinDragDistance)
+                return;
+
             // Get the clicked position
             var offset = _offset + _physics.LocalCenter;
             var localPosition = args.PointerLocation.Position - GlobalPixelPosition;