diff --git a/Patches/FocusFleaOfferNumberPatches.cs b/Patches/FocusFleaOfferNumberPatches.cs index a7a7a18..08ea964 100644 --- a/Patches/FocusFleaOfferNumberPatches.cs +++ b/Patches/FocusFleaOfferNumberPatches.cs @@ -2,9 +2,12 @@ using EFT.InventoryLogic; using EFT.UI.Ragfair; using HarmonyLib; +using System; using System.Linq; using System.Reflection; using TMPro; +using UnityEngine; +using UnityEngine.UI; namespace UIFixes { @@ -24,8 +27,11 @@ namespace UIFixes } [PatchPostfix] - public static void Postfix(TMP_InputField ____inputField) + public static void Postfix(HandoverRagfairMoneyWindow __instance, TMP_InputField ____inputField) { + AllButtonKeybind allKeybind = __instance.GetOrAddComponent(); + allKeybind.Init(__instance.method_9); + ____inputField.contentType = TMP_InputField.ContentType.IntegerNumber; ____inputField.ActivateInputField(); ____inputField.Select(); @@ -40,12 +46,33 @@ namespace UIFixes } [PatchPostfix] - public static void Postfix(TMP_InputField ____inputField) + public static void Postfix(HandoverExchangeableItemsWindow __instance, TMP_InputField ____inputField) { + AllButtonKeybind allKeybind = __instance.GetOrAddComponent(); + allKeybind.Init(__instance.method_16); + ____inputField.contentType = TMP_InputField.ContentType.IntegerNumber; ____inputField.ActivateInputField(); ____inputField.Select(); } } + + public class AllButtonKeybind : MonoBehaviour + { + private Action purchaseAllAction; + + public void Init(Action purchaseAllAction) + { + this.purchaseAllAction = purchaseAllAction; + } + + public void Update() + { + if (Settings.PurchaseAllKeybind.Value.IsDown()) + { + purchaseAllAction(); + } + } + } } } diff --git a/Settings.cs b/Settings.cs index 8e4c1f0..ec5e629 100644 --- a/Settings.cs +++ b/Settings.cs @@ -68,6 +68,7 @@ namespace UIFixes public static ConfigEntry ShowRequiredQuest { get; set; } public static ConfigEntry AutoExpandCategories { get; set; } public static ConfigEntry KeepAddOfferOpen { get; set; } + public static ConfigEntry PurchaseAllKeybind { get; set; } public static ConfigEntry KeepAddOfferOpenIgnoreMaxOffers { get; set; } // Advanced public static ConfigEntry RememberAutoselectSimilar { get; set; } // Advanced @@ -333,6 +334,15 @@ namespace UIFixes null, new ConfigurationManagerAttributes { }))); + configEntries.Add(PurchaseAllKeybind = config.Bind( + InspectSection, + "Purchase Dialog ALL Shortcut", + new KeyboardShortcut(KeyCode.A), + new ConfigDescription( + "Keybind to set the quantity to all in the item purchase dialog. Equivalent to clicking the ALL button.", + null, + new ConfigurationManagerAttributes { }))); + configEntries.Add(KeepAddOfferOpenIgnoreMaxOffers = config.Bind( FleaMarketSection, "Keep Add Offer Window Open: Ignore Max Offers",