Add keybind for purchase dialog ALL button

This commit is contained in:
Tyfon
2024-06-02 16:06:21 -07:00
parent 05d0339b62
commit 8f90965fe3
2 changed files with 39 additions and 2 deletions

View File

@@ -2,9 +2,12 @@
using EFT.InventoryLogic; using EFT.InventoryLogic;
using EFT.UI.Ragfair; using EFT.UI.Ragfair;
using HarmonyLib; using HarmonyLib;
using System;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using TMPro; using TMPro;
using UnityEngine;
using UnityEngine.UI;
namespace UIFixes namespace UIFixes
{ {
@@ -24,8 +27,11 @@ namespace UIFixes
} }
[PatchPostfix] [PatchPostfix]
public static void Postfix(TMP_InputField ____inputField) public static void Postfix(HandoverRagfairMoneyWindow __instance, TMP_InputField ____inputField)
{ {
AllButtonKeybind allKeybind = __instance.GetOrAddComponent<AllButtonKeybind>();
allKeybind.Init(__instance.method_9);
____inputField.contentType = TMP_InputField.ContentType.IntegerNumber; ____inputField.contentType = TMP_InputField.ContentType.IntegerNumber;
____inputField.ActivateInputField(); ____inputField.ActivateInputField();
____inputField.Select(); ____inputField.Select();
@@ -40,12 +46,33 @@ namespace UIFixes
} }
[PatchPostfix] [PatchPostfix]
public static void Postfix(TMP_InputField ____inputField) public static void Postfix(HandoverExchangeableItemsWindow __instance, TMP_InputField ____inputField)
{ {
AllButtonKeybind allKeybind = __instance.GetOrAddComponent<AllButtonKeybind>();
allKeybind.Init(__instance.method_16);
____inputField.contentType = TMP_InputField.ContentType.IntegerNumber; ____inputField.contentType = TMP_InputField.ContentType.IntegerNumber;
____inputField.ActivateInputField(); ____inputField.ActivateInputField();
____inputField.Select(); ____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();
}
}
}
} }
} }

View File

@@ -68,6 +68,7 @@ namespace UIFixes
public static ConfigEntry<bool> ShowRequiredQuest { get; set; } public static ConfigEntry<bool> ShowRequiredQuest { get; set; }
public static ConfigEntry<bool> AutoExpandCategories { get; set; } public static ConfigEntry<bool> AutoExpandCategories { get; set; }
public static ConfigEntry<bool> KeepAddOfferOpen { get; set; } public static ConfigEntry<bool> KeepAddOfferOpen { get; set; }
public static ConfigEntry<KeyboardShortcut> PurchaseAllKeybind { get; set; }
public static ConfigEntry<bool> KeepAddOfferOpenIgnoreMaxOffers { get; set; } // Advanced public static ConfigEntry<bool> KeepAddOfferOpenIgnoreMaxOffers { get; set; } // Advanced
public static ConfigEntry<bool> RememberAutoselectSimilar { get; set; } // Advanced public static ConfigEntry<bool> RememberAutoselectSimilar { get; set; } // Advanced
@@ -333,6 +334,15 @@ namespace UIFixes
null, null,
new ConfigurationManagerAttributes { }))); 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( configEntries.Add(KeepAddOfferOpenIgnoreMaxOffers = config.Bind(
FleaMarketSection, FleaMarketSection,
"Keep Add Offer Window Open: Ignore Max Offers", "Keep Add Offer Window Open: Ignore Max Offers",