limit nonstandard dragging
This commit is contained in:
44
Patches/LimitDragPatches.cs
Normal file
44
Patches/LimitDragPatches.cs
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
using System;
|
||||||
|
using System.Reflection;
|
||||||
|
using EFT.UI;
|
||||||
|
using HarmonyLib;
|
||||||
|
using SPT.Reflection.Patching;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.EventSystems;
|
||||||
|
|
||||||
|
namespace UIFixes;
|
||||||
|
|
||||||
|
public static class LimitDragPatches
|
||||||
|
{
|
||||||
|
public static void Enable()
|
||||||
|
{
|
||||||
|
new OnDragEventPatch(typeof(DragTrigger), nameof(DragTrigger.OnDrag)).Enable();
|
||||||
|
new OnDragEventPatch(typeof(DragTrigger), nameof(DragTrigger.OnBeginDrag)).Enable();
|
||||||
|
new OnDragEventPatch(typeof(DragTrigger), nameof(DragTrigger.OnEndDrag)).Enable();
|
||||||
|
|
||||||
|
new OnDragEventPatch(typeof(UIDragComponent), "UnityEngine.EventSystems.IDragHandler.OnDrag").Enable();
|
||||||
|
new OnDragEventPatch(typeof(UIDragComponent), "UnityEngine.EventSystems.IBeginDragHandler.OnBeginDrag").Enable();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class OnDragEventPatch(Type type, string methodName) : ModulePatch
|
||||||
|
{
|
||||||
|
private readonly string methodName = methodName;
|
||||||
|
private readonly Type type = type;
|
||||||
|
|
||||||
|
protected override MethodBase GetTargetMethod()
|
||||||
|
{
|
||||||
|
return AccessTools.Method(type, methodName);
|
||||||
|
}
|
||||||
|
|
||||||
|
[PatchPrefix]
|
||||||
|
public static bool Prefix(PointerEventData eventData)
|
||||||
|
{
|
||||||
|
if (!Settings.LimitNonstandardDrags.Value)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return eventData.button == PointerEventData.InputButton.Left && !Input.GetKey(KeyCode.LeftShift) && !Input.GetKey(KeyCode.RightShift);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -68,6 +68,7 @@ public class Plugin : BaseUnityPlugin
|
|||||||
ReloadInPlacePatches.Enable();
|
ReloadInPlacePatches.Enable();
|
||||||
BarterOfferPatches.Enable();
|
BarterOfferPatches.Enable();
|
||||||
new UnlockCursorPatch().Enable();
|
new UnlockCursorPatch().Enable();
|
||||||
|
LimitDragPatches.Enable();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool InRaid()
|
public static bool InRaid()
|
||||||
|
14
Settings.cs
14
Settings.cs
@@ -70,6 +70,8 @@ internal class Settings
|
|||||||
public static ConfigEntry<bool> UseHomeEnd { get; set; }
|
public static ConfigEntry<bool> UseHomeEnd { get; set; }
|
||||||
public static ConfigEntry<bool> RebindPageUpDown { get; set; }
|
public static ConfigEntry<bool> RebindPageUpDown { get; set; }
|
||||||
public static ConfigEntry<int> MouseScrollMulti { get; set; }
|
public static ConfigEntry<int> MouseScrollMulti { get; set; }
|
||||||
|
public static ConfigEntry<bool> UseRaidMouseScrollMulti { get; set; } // Advanced
|
||||||
|
public static ConfigEntry<int> MouseScrollMultiInRaid { get; set; } // Advanced
|
||||||
public static ConfigEntry<KeyboardShortcut> InspectKeyBind { get; set; }
|
public static ConfigEntry<KeyboardShortcut> InspectKeyBind { get; set; }
|
||||||
public static ConfigEntry<KeyboardShortcut> OpenKeyBind { get; set; }
|
public static ConfigEntry<KeyboardShortcut> OpenKeyBind { get; set; }
|
||||||
public static ConfigEntry<KeyboardShortcut> ExamineKeyBind { get; set; }
|
public static ConfigEntry<KeyboardShortcut> ExamineKeyBind { get; set; }
|
||||||
@@ -81,8 +83,7 @@ internal class Settings
|
|||||||
public static ConfigEntry<KeyboardShortcut> FilterByKeyBind { get; set; }
|
public static ConfigEntry<KeyboardShortcut> FilterByKeyBind { get; set; }
|
||||||
public static ConfigEntry<KeyboardShortcut> LinkedSearchKeyBind { get; set; }
|
public static ConfigEntry<KeyboardShortcut> LinkedSearchKeyBind { get; set; }
|
||||||
public static ConfigEntry<KeyboardShortcut> SortingTableKeyBind { get; set; }
|
public static ConfigEntry<KeyboardShortcut> SortingTableKeyBind { get; set; }
|
||||||
public static ConfigEntry<bool> UseRaidMouseScrollMulti { get; set; } // Advanced
|
public static ConfigEntry<bool> LimitNonstandardDrags { get; set; } // Advanced
|
||||||
public static ConfigEntry<int> MouseScrollMultiInRaid { get; set; } // Advanced
|
|
||||||
public static ConfigEntry<bool> ItemContextBlocksTextInputs { get; set; } // Advanced
|
public static ConfigEntry<bool> ItemContextBlocksTextInputs { get; set; } // Advanced
|
||||||
|
|
||||||
// Inventory
|
// Inventory
|
||||||
@@ -372,6 +373,15 @@ internal class Settings
|
|||||||
null,
|
null,
|
||||||
new ConfigurationManagerAttributes { })));
|
new ConfigurationManagerAttributes { })));
|
||||||
|
|
||||||
|
configEntries.Add(LimitNonstandardDrags = config.Bind(
|
||||||
|
InputSection,
|
||||||
|
"Limit Nonstandard Drags",
|
||||||
|
true,
|
||||||
|
new ConfigDescription(
|
||||||
|
"Constrain dragging to the left mouse, when shift is not down",
|
||||||
|
null,
|
||||||
|
new ConfigurationManagerAttributes { IsAdvanced = true })));
|
||||||
|
|
||||||
configEntries.Add(ItemContextBlocksTextInputs = config.Bind(
|
configEntries.Add(ItemContextBlocksTextInputs = config.Bind(
|
||||||
InputSection,
|
InputSection,
|
||||||
"Block Text Inputs on Item Mouseover",
|
"Block Text Inputs on Item Mouseover",
|
||||||
|
Reference in New Issue
Block a user