Option to keep AddOffer window open
This commit is contained in:
81
Patches/KeepOfferWindowOpenPatches.cs
Normal file
81
Patches/KeepOfferWindowOpenPatches.cs
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
using Aki.Reflection.Patching;
|
||||||
|
using EFT.UI.Ragfair;
|
||||||
|
using HarmonyLib;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace UIFixes
|
||||||
|
{
|
||||||
|
public static class KeepOfferWindowOpenPatches
|
||||||
|
{
|
||||||
|
private static bool BlockClose = false;
|
||||||
|
|
||||||
|
public static void Enable()
|
||||||
|
{
|
||||||
|
new PlaceOfferClickPatch().Enable();
|
||||||
|
new ClosePatch().Enable();
|
||||||
|
new ManageTaskPatch().Enable();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class PlaceOfferClickPatch : ModulePatch
|
||||||
|
{
|
||||||
|
protected override MethodBase GetTargetMethod()
|
||||||
|
{
|
||||||
|
return AccessTools.Method(typeof(AddOfferWindow), nameof(AddOfferWindow.method_1));
|
||||||
|
}
|
||||||
|
|
||||||
|
[PatchPrefix]
|
||||||
|
public static void Prefix()
|
||||||
|
{
|
||||||
|
BlockClose = Settings.KeepAddOfferOpen.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
[PatchPostfix]
|
||||||
|
public static void Postfix()
|
||||||
|
{
|
||||||
|
BlockClose = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ClosePatch : ModulePatch
|
||||||
|
{
|
||||||
|
protected override MethodBase GetTargetMethod()
|
||||||
|
{
|
||||||
|
return AccessTools.Method(typeof(AddOfferWindow), nameof(AddOfferWindow.Close));
|
||||||
|
}
|
||||||
|
|
||||||
|
[PatchPrefix]
|
||||||
|
public static bool Prefix()
|
||||||
|
{
|
||||||
|
return !BlockClose;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// The window has a task completion source that completes when closing window or upon successful offer placement (which assumes window closes too)
|
||||||
|
// Replace implementation to ensure it only completes when window is closed, or placement is successful AND window has since closed
|
||||||
|
public class ManageTaskPatch : ModulePatch
|
||||||
|
{
|
||||||
|
protected override MethodBase GetTargetMethod()
|
||||||
|
{
|
||||||
|
return AccessTools.Method(typeof(AddOfferWindow), nameof(AddOfferWindow.method_16));
|
||||||
|
}
|
||||||
|
|
||||||
|
[PatchPrefix]
|
||||||
|
public static bool Prefix(AddOfferWindow __instance, TaskCompletionSource<object> ___taskCompletionSource_0, ref bool ___bool_2)
|
||||||
|
{
|
||||||
|
if (!Settings.KeepAddOfferOpen.Value)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
___bool_2 = false;
|
||||||
|
if (!__instance.gameObject.activeInHierarchy)
|
||||||
|
{
|
||||||
|
___taskCompletionSource_0.SetResult(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -30,6 +30,7 @@ namespace UIFixes
|
|||||||
new MoveTaskbarPatch().Enable();
|
new MoveTaskbarPatch().Enable();
|
||||||
FixFleaPatches.Enable();
|
FixFleaPatches.Enable();
|
||||||
FleaPrevSearchPatches.Enable();
|
FleaPrevSearchPatches.Enable();
|
||||||
|
KeepOfferWindowOpenPatches.Enable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
10
Settings.cs
10
Settings.cs
@@ -59,6 +59,7 @@ namespace UIFixes
|
|||||||
public static ConfigEntry<bool> EnableFleaHistory { get; set; }
|
public static ConfigEntry<bool> EnableFleaHistory { get; set; }
|
||||||
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; }
|
||||||
|
|
||||||
// Advanced
|
// Advanced
|
||||||
public static ConfigEntry<bool> StyleItemPanel { get; set; }
|
public static ConfigEntry<bool> StyleItemPanel { get; set; }
|
||||||
@@ -244,6 +245,15 @@ namespace UIFixes
|
|||||||
null,
|
null,
|
||||||
new ConfigurationManagerAttributes { })));
|
new ConfigurationManagerAttributes { })));
|
||||||
|
|
||||||
|
configEntries.Add(KeepAddOfferOpen = config.Bind(
|
||||||
|
FleaMarketSection,
|
||||||
|
"Keep Add Offer Window Open",
|
||||||
|
false,
|
||||||
|
new ConfigDescription(
|
||||||
|
"Don't close the Add Offer window after you place an offer",
|
||||||
|
null,
|
||||||
|
new ConfigurationManagerAttributes { })));
|
||||||
|
|
||||||
// Advanced
|
// Advanced
|
||||||
configEntries.Add(StyleItemPanel = config.Bind(
|
configEntries.Add(StyleItemPanel = config.Bind(
|
||||||
AdvancedSection,
|
AdvancedSection,
|
||||||
|
|||||||
Reference in New Issue
Block a user