Increase dragging dead zone (#7416)
This commit is contained in:
@@ -210,7 +210,8 @@ namespace Content.Client.Actions.UI
|
|||||||
_slots[i] = slot;
|
_slots[i] = slot;
|
||||||
}
|
}
|
||||||
|
|
||||||
DragDropHelper = new DragDropHelper<ActionSlot>(OnBeginActionDrag, OnContinueActionDrag, OnEndActionDrag, DragDeadZone);
|
DragDropHelper = new DragDropHelper<ActionSlot>(OnBeginActionDrag, OnContinueActionDrag, OnEndActionDrag);
|
||||||
|
DragDropHelper.Deadzone = DragDeadZone;
|
||||||
|
|
||||||
MinSize = (10, 400);
|
MinSize = (10, 400);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,14 +21,12 @@ namespace Content.Client.DragDrop
|
|||||||
/// <typeparam name="T">thing being dragged and dropped</typeparam>
|
/// <typeparam name="T">thing being dragged and dropped</typeparam>
|
||||||
public sealed class DragDropHelper<T>
|
public sealed class DragDropHelper<T>
|
||||||
{
|
{
|
||||||
private const float DefaultDragDeadzone = 2f;
|
|
||||||
|
|
||||||
private readonly IInputManager _inputManager;
|
private readonly IInputManager _inputManager;
|
||||||
|
|
||||||
private readonly OnBeginDrag _onBeginDrag;
|
private readonly OnBeginDrag _onBeginDrag;
|
||||||
private readonly OnEndDrag _onEndDrag;
|
private readonly OnEndDrag _onEndDrag;
|
||||||
private readonly OnContinueDrag _onContinueDrag;
|
private readonly OnContinueDrag _onContinueDrag;
|
||||||
private readonly float _deadzone;
|
public float Deadzone = 2f;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Convenience method, current mouse screen position as provided by inputmanager.
|
/// Convenience method, current mouse screen position as provided by inputmanager.
|
||||||
@@ -67,9 +65,8 @@ namespace Content.Client.DragDrop
|
|||||||
/// <param name="deadzone">drag will be triggered when mouse leaves
|
/// <param name="deadzone">drag will be triggered when mouse leaves
|
||||||
/// this deadzone around the mousedown position</param>
|
/// this deadzone around the mousedown position</param>
|
||||||
public DragDropHelper(OnBeginDrag onBeginDrag, OnContinueDrag onContinueDrag,
|
public DragDropHelper(OnBeginDrag onBeginDrag, OnContinueDrag onContinueDrag,
|
||||||
OnEndDrag onEndDrag, float deadzone = DefaultDragDeadzone)
|
OnEndDrag onEndDrag)
|
||||||
{
|
{
|
||||||
_deadzone = deadzone;
|
|
||||||
_inputManager = IoCManager.Resolve<IInputManager>();
|
_inputManager = IoCManager.Resolve<IInputManager>();
|
||||||
_onBeginDrag = onBeginDrag;
|
_onBeginDrag = onBeginDrag;
|
||||||
_onEndDrag = onEndDrag;
|
_onEndDrag = onEndDrag;
|
||||||
@@ -128,7 +125,7 @@ namespace Content.Client.DragDrop
|
|||||||
case DragState.MouseDown:
|
case DragState.MouseDown:
|
||||||
{
|
{
|
||||||
var screenPos = _inputManager.MouseScreenPosition;
|
var screenPos = _inputManager.MouseScreenPosition;
|
||||||
if ((_mouseDownScreenPos.Position - screenPos.Position).Length > _deadzone)
|
if ((_mouseDownScreenPos.Position - screenPos.Position).Length > Deadzone)
|
||||||
{
|
{
|
||||||
StartDragging();
|
StartDragging();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using Content.Client.Outline;
|
using Content.Client.Outline;
|
||||||
using Content.Client.Viewport;
|
using Content.Client.Viewport;
|
||||||
using Content.Shared.ActionBlocker;
|
using Content.Shared.ActionBlocker;
|
||||||
|
using Content.Shared.CCVar;
|
||||||
using Content.Shared.DragDrop;
|
using Content.Shared.DragDrop;
|
||||||
using Content.Shared.Interaction;
|
using Content.Shared.Interaction;
|
||||||
using Content.Shared.Interaction.Events;
|
using Content.Shared.Interaction.Events;
|
||||||
@@ -11,6 +12,7 @@ using Robust.Client.Graphics;
|
|||||||
using Robust.Client.Input;
|
using Robust.Client.Input;
|
||||||
using Robust.Client.Player;
|
using Robust.Client.Player;
|
||||||
using Robust.Client.State;
|
using Robust.Client.State;
|
||||||
|
using Robust.Shared.Configuration;
|
||||||
using Robust.Shared.Input;
|
using Robust.Shared.Input;
|
||||||
using Robust.Shared.Input.Binding;
|
using Robust.Shared.Input.Binding;
|
||||||
using Robust.Shared.Prototypes;
|
using Robust.Shared.Prototypes;
|
||||||
@@ -30,6 +32,7 @@ namespace Content.Client.DragDrop
|
|||||||
[Dependency] private readonly IEyeManager _eyeManager = default!;
|
[Dependency] private readonly IEyeManager _eyeManager = default!;
|
||||||
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
||||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||||
|
[Dependency] private readonly IConfigurationManager _cfgMan = default!;
|
||||||
[Dependency] private readonly InteractionOutlineSystem _outline = default!;
|
[Dependency] private readonly InteractionOutlineSystem _outline = default!;
|
||||||
[Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
|
[Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
|
||||||
[Dependency] private readonly InputSystem _inputSystem = default!;
|
[Dependency] private readonly InputSystem _inputSystem = default!;
|
||||||
@@ -75,6 +78,7 @@ namespace Content.Client.DragDrop
|
|||||||
UpdatesOutsidePrediction = true;
|
UpdatesOutsidePrediction = true;
|
||||||
|
|
||||||
_dragDropHelper = new DragDropHelper<EntityUid>(OnBeginDrag, OnContinueDrag, OnEndDrag);
|
_dragDropHelper = new DragDropHelper<EntityUid>(OnBeginDrag, OnContinueDrag, OnEndDrag);
|
||||||
|
_cfgMan.OnValueChanged(CCVars.DragDropDeadZone, SetDeadZone, true);
|
||||||
|
|
||||||
_dropTargetInRangeShader = _prototypeManager.Index<ShaderPrototype>(ShaderDropTargetInRange).Instance();
|
_dropTargetInRangeShader = _prototypeManager.Index<ShaderPrototype>(ShaderDropTargetInRange).Instance();
|
||||||
_dropTargetOutOfRangeShader = _prototypeManager.Index<ShaderPrototype>(ShaderDropTargetOutOfRange).Instance();
|
_dropTargetOutOfRangeShader = _prototypeManager.Index<ShaderPrototype>(ShaderDropTargetOutOfRange).Instance();
|
||||||
@@ -84,8 +88,14 @@ namespace Content.Client.DragDrop
|
|||||||
.Register<DragDropSystem>();
|
.Register<DragDropSystem>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SetDeadZone(float deadZone)
|
||||||
|
{
|
||||||
|
_dragDropHelper.Deadzone = deadZone;
|
||||||
|
}
|
||||||
|
|
||||||
public override void Shutdown()
|
public override void Shutdown()
|
||||||
{
|
{
|
||||||
|
_cfgMan.UnsubValueChanged(CCVars.DragDropDeadZone, SetDeadZone);
|
||||||
_dragDropHelper.EndDrag();
|
_dragDropHelper.EndDrag();
|
||||||
CommandBinds.Unregister<DragDropSystem>();
|
CommandBinds.Unregister<DragDropSystem>();
|
||||||
base.Shutdown();
|
base.Shutdown();
|
||||||
|
|||||||
@@ -869,5 +869,15 @@ namespace Content.Shared.CCVar
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly CVarDef<int> ResourceUploadingStoreDeletionDays =
|
public static readonly CVarDef<int> ResourceUploadingStoreDeletionDays =
|
||||||
CVarDef.Create("netres.store_deletion_days", 30, CVar.SERVER | CVar.SERVERONLY);
|
CVarDef.Create("netres.store_deletion_days", 30, CVar.SERVER | CVar.SERVERONLY);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Controls
|
||||||
|
*/
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Deadzone for drag-drop interactions.
|
||||||
|
/// </summary>
|
||||||
|
public static readonly CVarDef<float> DragDropDeadZone =
|
||||||
|
CVarDef.Create("control.drag_dead_zone", 12f, CVar.CLIENTONLY | CVar.ARCHIVE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user