Fixed issue with the station map UI (#22848)

Fixed issue with dragging the nav map in the station map UI
This commit is contained in:
chromiumboy
2023-12-22 01:15:51 -06:00
committed by GitHub
parent cb6884e5bb
commit 09c48c710b

View File

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