diff --git a/Patches/AutofillQuestItemsPatch.cs b/Patches/AutofillQuestItemsPatch.cs new file mode 100644 index 0000000..2f36a28 --- /dev/null +++ b/Patches/AutofillQuestItemsPatch.cs @@ -0,0 +1,24 @@ +using Aki.Reflection.Patching; +using EFT.UI; +using HarmonyLib; +using System.Reflection; + +namespace UIFixes +{ + public class AutofillQuestItemsPatch : ModulePatch + { + protected override MethodBase GetTargetMethod() + { + return AccessTools.DeclaredMethod(typeof(HandoverQuestItemsWindow), nameof(HandoverQuestItemsWindow.Show)); + } + + [PatchPostfix] + public static void Postfix(HandoverQuestItemsWindow __instance) + { + if (Settings.AutofillQuestTurnIns.Value) + { + __instance.AutoSelectButtonPressedHandler(); + } + } + } +} diff --git a/Patches/FocusFleaOfferNumberPatches.cs b/Patches/FocusFleaOfferNumberPatches.cs index 84bf0d5..a7a7a18 100644 --- a/Patches/FocusFleaOfferNumberPatches.cs +++ b/Patches/FocusFleaOfferNumberPatches.cs @@ -20,10 +20,7 @@ namespace UIFixes { protected override MethodBase GetTargetMethod() { - // The parent has a Show() so need to be specific - return AccessTools.GetDeclaredMethods(typeof(HandoverRagfairMoneyWindow)).First( - m => m.Name == nameof(HandoverRagfairMoneyWindow.Show) && - m.GetParameters()[0].ParameterType == typeof(Inventory)); + return AccessTools.DeclaredMethod(typeof(HandoverRagfairMoneyWindow), nameof(HandoverRagfairMoneyWindow.Show)); } [PatchPostfix] @@ -39,10 +36,7 @@ namespace UIFixes { protected override MethodBase GetTargetMethod() { - // The parent has a Show() so need to be specific - return AccessTools.GetDeclaredMethods(typeof(HandoverExchangeableItemsWindow)).First( - m => m.Name == nameof(HandoverExchangeableItemsWindow.Show) && - m.GetParameters()[0].ParameterType == typeof(EExchangeableWindowType)); + return AccessTools.DeclaredMethod(typeof(HandoverExchangeableItemsWindow), nameof(HandoverExchangeableItemsWindow.Show)); } [PatchPostfix] diff --git a/Patches/ScrollPatches.cs b/Patches/ScrollPatches.cs index fed6787..6c7f6c2 100644 --- a/Patches/ScrollPatches.cs +++ b/Patches/ScrollPatches.cs @@ -227,7 +227,7 @@ namespace UIFixes { protected override MethodBase GetTargetMethod() { - return AccessTools.Method(typeof(ScrollRectNoDrag), nameof(ScrollRectNoDrag.OnScroll)); //type.GetMethod("OnScroll"); + return AccessTools.Method(typeof(ScrollRectNoDrag), nameof(ScrollRectNoDrag.OnScroll)); } [PatchPrefix] diff --git a/Plugin.cs b/Plugin.cs index 496ca13..8bff0b8 100644 --- a/Plugin.cs +++ b/Plugin.cs @@ -36,6 +36,7 @@ namespace UIFixes KeepOfferWindowOpenPatches.Enable(); AddOfferClickablePricesPatches.Enable(); new AssortUnlocksPatch().Enable(); + new AutofillQuestItemsPatch().Enable(); } public static bool InRaid() diff --git a/Settings.cs b/Settings.cs index 1bbde90..be05e48 100644 --- a/Settings.cs +++ b/Settings.cs @@ -31,6 +31,7 @@ namespace UIFixes // General public static ConfigEntry ShowPresetConfirmations { get; set; } public static ConfigEntry ShowTransferConfirmations { get; set; } + public static ConfigEntry AutofillQuestTurnIns { get; set; } // Input public static ConfigEntry UseHomeEnd { get; set; } @@ -87,6 +88,15 @@ namespace UIFixes null, new ConfigurationManagerAttributes { }))); + configEntries.Add(AutofillQuestTurnIns = config.Bind( + GeneralSection, + "Autofill Quest Item Turn-ins", + true, + new ConfigDescription( + "Auto-select matching items when turning in quest items. Like pushing the AUTO button for you.", + null, + new ConfigurationManagerAttributes { }))); + // Input configEntries.Add(UseHomeEnd = config.Bind( InputSection,