Increase dragging dead zone (#7416)

This commit is contained in:
Leon Friedrich
2022-04-09 09:17:52 +12:00
committed by GitHub
parent 7900abb888
commit bec0b63dc1
4 changed files with 25 additions and 7 deletions

View File

@@ -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<EntityUid>(OnBeginDrag, OnContinueDrag, OnEndDrag);
_cfgMan.OnValueChanged(CCVars.DragDropDeadZone, SetDeadZone, true);
_dropTargetInRangeShader = _prototypeManager.Index<ShaderPrototype>(ShaderDropTargetInRange).Instance();
_dropTargetOutOfRangeShader = _prototypeManager.Index<ShaderPrototype>(ShaderDropTargetOutOfRange).Instance();
@@ -84,8 +88,14 @@ namespace Content.Client.DragDrop
.Register<DragDropSystem>();
}
private void SetDeadZone(float deadZone)
{
_dragDropHelper.Deadzone = deadZone;
}
public override void Shutdown()
{
_cfgMan.UnsubValueChanged(CCVars.DragDropDeadZone, SetDeadZone);
_dragDropHelper.EndDrag();
CommandBinds.Unregister<DragDropSystem>();
base.Shutdown();