Autofill quest items

This commit is contained in:
Tyfon
2024-05-27 14:17:54 -07:00
parent 8978922a5a
commit d8b17d19b9
5 changed files with 38 additions and 9 deletions

View File

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

View File

@@ -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]

View File

@@ -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]

View File

@@ -36,6 +36,7 @@ namespace UIFixes
KeepOfferWindowOpenPatches.Enable();
AddOfferClickablePricesPatches.Enable();
new AssortUnlocksPatch().Enable();
new AutofillQuestItemsPatch().Enable();
}
public static bool InRaid()

View File

@@ -31,6 +31,7 @@ namespace UIFixes
// General
public static ConfigEntry<WeaponPresetConfirmationOption> ShowPresetConfirmations { get; set; }
public static ConfigEntry<TransferConfirmationOption> ShowTransferConfirmations { get; set; }
public static ConfigEntry<bool> AutofillQuestTurnIns { get; set; }
// Input
public static ConfigEntry<bool> 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,