Keep quantity focused after purchase

This commit is contained in:
Tyfon
2024-05-31 16:20:59 -07:00
parent a9c60d33e7
commit 6da8800d97
2 changed files with 27 additions and 0 deletions

View File

@@ -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();
}
}
}

View File

@@ -41,6 +41,7 @@ namespace UIFixes
TradingAutoSwitchPatches.Enable();
AddOfferRememberAutoselectPatches.Enable();
KeepMessagesOpenPatches.Enable();
new FocusTradeQuantityPatch().Enable();
}
public static bool InRaid()