diff --git a/DrawMultiSelect.cs b/DrawMultiSelect.cs index c801fc7..b193aee 100644 --- a/DrawMultiSelect.cs +++ b/DrawMultiSelect.cs @@ -55,7 +55,7 @@ namespace UIFixes } // checking ItemUiContext is a quick and easy way to know the mouse is over an item - if (Input.GetKeyDown(KeyCode.Mouse0) && ItemUiContext.Instance.R().ItemContext == null) + if (Settings.SelectionBoxKey.Value.IsDown() && ItemUiContext.Instance.R().ItemContext == null) { PointerEventData eventData = new(EventSystem.current) { @@ -138,7 +138,7 @@ namespace UIFixes } } - if (drawing && !Input.GetKey(KeyCode.Mouse0)) + if (drawing && !Settings.SelectionBoxKey.Value.IsPressed()) { drawing = false; if (secondary) diff --git a/Patches/ContextMenuPatches.cs b/Patches/ContextMenuPatches.cs index eee8350..85b1c73 100644 --- a/Patches/ContextMenuPatches.cs +++ b/Patches/ContextMenuPatches.cs @@ -121,7 +121,7 @@ namespace UIFixes ____text.text += " (x" + count + ")"; } } - else if (caption == EItemInfoButton.UnloadAmmo.ToString())) + else if (caption == EItemInfoButton.UnloadAmmo.ToString()) { int count = MultiSelect.InteractionCount(EItemInfoButton.UnloadAmmo, ItemUiContext.Instance); if (count > 0) diff --git a/Patches/ContextMenuShortcutPatches.cs b/Patches/ContextMenuShortcutPatches.cs index 2d66ddc..a54f31e 100644 --- a/Patches/ContextMenuShortcutPatches.cs +++ b/Patches/ContextMenuShortcutPatches.cs @@ -4,6 +4,7 @@ using EFT.UI; using EFT.UI.DragAndDrop; using HarmonyLib; using System.Reflection; +using TMPro; using UnityEngine.EventSystems; namespace UIFixes @@ -28,7 +29,7 @@ namespace UIFixes { // Need an item context to operate on, and ignore these keypresses if there's a focused textbox somewhere ItemContextAbstractClass itemContext = __instance.R().ItemContext; - if (itemContext == null || EventSystem.current.currentSelectedGameObject != null) + if (itemContext == null || EventSystem.current.currentSelectedGameObject?.GetComponent() != null) { return; } @@ -37,25 +38,21 @@ namespace UIFixes if (Settings.InspectKeyBind.Value.IsDown()) { interactions.ExecuteInteraction(EItemInfoButton.Inspect); - return; } if (Settings.OpenKeyBind.Value.IsDown()) { interactions.ExecuteInteraction(EItemInfoButton.Open); - return; } if (Settings.TopUpKeyBind.Value.IsDown()) { interactions.ExecuteInteraction(EItemInfoButton.TopUp); - return; } if (Settings.UseKeyBind.Value.IsDown()) { interactions.ExecuteInteraction(EItemInfoButton.Use); - return; } if (Settings.UseAllKeyBind.Value.IsDown()) @@ -64,8 +61,6 @@ namespace UIFixes { interactions.ExecuteInteraction(EItemInfoButton.Use); } - - return; } if (Settings.UnloadKeyBind.Value.IsDown()) @@ -74,26 +69,21 @@ namespace UIFixes { interactions.ExecuteInteraction(EItemInfoButton.UnloadAmmo); } - - return; } if (Settings.UnpackKeyBind.Value.IsDown()) { interactions.ExecuteInteraction(EItemInfoButton.Unpack); - return; } if (Settings.FilterByKeyBind.Value.IsDown()) { interactions.ExecuteInteraction(EItemInfoButton.FilterSearch); - return; } if (Settings.LinkedSearchKeyBind.Value.IsDown()) { interactions.ExecuteInteraction(EItemInfoButton.LinkedSearch); - return; } } } diff --git a/Settings.cs b/Settings.cs index bfda310..1883654 100644 --- a/Settings.cs +++ b/Settings.cs @@ -66,6 +66,7 @@ namespace UIFixes // Inventory public static ConfigEntry EnableMultiSelect { get; set; } + public static ConfigEntry SelectionBoxKey { get; set; } public static ConfigEntry MultiSelectStrat { get; set; } public static ConfigEntry ShowMultiSelectDebug { get; set; } // Advanced public static ConfigEntry SwapItems { get; set; } @@ -304,6 +305,15 @@ namespace UIFixes null, new ConfigurationManagerAttributes { }))); + configEntries.Add(SelectionBoxKey = config.Bind( + InventorySection, + "Selection Box Key", + new KeyboardShortcut(KeyCode.Mouse0), + new ConfigDescription( + "Mouse button or keyboard key to hold while dragging to create a selection box. Press Reset to use Mouse0 (left mouse button)", + null, + new ConfigurationManagerAttributes { }))); + configEntries.Add(MultiSelectStrat = config.Bind( InventorySection, "Multiselect Item Placement",