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