diff --git a/Patches/FocusTradeQuantityPatch.cs b/Patches/FocusTradeQuantityPatch.cs new file mode 100644 index 0000000..54f9778 --- /dev/null +++ b/Patches/FocusTradeQuantityPatch.cs @@ -0,0 +1,26 @@ +using Aki.Reflection.Patching; +using EFT.UI; +using HarmonyLib; +using System.Reflection; +using TMPro; + +namespace UIFixes +{ + public class FocusTradeQuantityPatch : ModulePatch + { + protected override MethodBase GetTargetMethod() + { + return AccessTools.Method(typeof(BarterSchemePanel), nameof(BarterSchemePanel.method_10)); + } + + // Gets called on the TransactionChanged event. + // The reason quantity isn't focused on the 2nd+ purchase is that BSG calls ActivateInputField() and Select() before the transaction is finished + // During the transaction, the whole canvas group is not interactable, and these methods don't work on non-interactable fields + [PatchPostfix] + public static void Postfix(TMP_InputField ____quantity) + { + ____quantity.ActivateInputField(); + ____quantity.Select(); + } + } +} diff --git a/Plugin.cs b/Plugin.cs index f179c89..3dfa222 100644 --- a/Plugin.cs +++ b/Plugin.cs @@ -41,6 +41,7 @@ namespace UIFixes TradingAutoSwitchPatches.Enable(); AddOfferRememberAutoselectPatches.Enable(); KeepMessagesOpenPatches.Enable(); + new FocusTradeQuantityPatch().Enable(); } public static bool InRaid()