diff --git a/ContextMenus/RepairInteractions.cs b/ContextMenus/RepairInteractions.cs
index dfe3af9..ffe84f2 100644
--- a/ContextMenus/RepairInteractions.cs
+++ b/ContextMenus/RepairInteractions.cs
@@ -41,7 +41,7 @@ namespace UIFixes
{
text = string.Format("{0}", repairer.LocalizedName);
}
- else if (repairer is GClass802 repairKit)
+ else if (repairer is GClass803 repairKit)
{
float pointsLeft = repairKit.GetRepairPoints();
double amount = repairStrategy.GetRepairPrice(repairAmount, repairKit);
@@ -96,7 +96,7 @@ namespace UIFixes
float repairAmount = GetClampedRepairAmount(repairStrategy);
- if (repairer is GClass802 repairKit)
+ if (repairer is GClass803 repairKit)
{
float pointsLeft = repairKit.GetRepairPoints();
double amount = repairStrategy.GetRepairPrice(repairAmount, repairKit);
diff --git a/Multiselect/MultiGrid.cs b/Multiselect/MultiGrid.cs
index ecaf233..096c3bc 100644
--- a/Multiselect/MultiGrid.cs
+++ b/Multiselect/MultiGrid.cs
@@ -5,8 +5,6 @@ using System.Collections.Generic;
using System.Linq;
using UnityEngine;
-using GridItemAddress = GClass2769;
-
namespace UIFixes
{
public static class MultiGrid
@@ -14,7 +12,7 @@ namespace UIFixes
private static readonly Dictionary- > GridOffsets = [];
private static readonly Dictionary
- >> GridsByLocation = [];
- public static LocationInGrid GetGridLocation(GridItemAddress realAddress)
+ public static LocationInGrid GetGridLocation(ItemAddressClass realAddress)
{
if (!IsMultiGrid(realAddress))
{
@@ -25,7 +23,7 @@ namespace UIFixes
return new LocationInGrid(realAddress.LocationInGrid.x + gridOffset.x, realAddress.LocationInGrid.y + gridOffset.y, realAddress.LocationInGrid.r);
}
- public static GridItemAddress GetRealAddress(StashGridClass originGrid, LocationInGrid multigridLocation)
+ public static ItemAddressClass GetRealAddress(StashGridClass originGrid, LocationInGrid multigridLocation)
{
if (!IsMultiGrid(originGrid.ParentItem))
{
@@ -33,7 +31,7 @@ namespace UIFixes
multigridLocation.x = Math.Max(0, Math.Min(originGrid.GridWidth.Value, multigridLocation.x));
multigridLocation.y = Math.Max(0, Math.Min(originGrid.GridHeight.Value, multigridLocation.y));
- return new GridItemAddress(originGrid, multigridLocation);
+ return new ItemAddressClass(originGrid, multigridLocation);
}
var gridsByLocation = GridsByLocation[originGrid.ParentItem];
@@ -54,7 +52,7 @@ namespace UIFixes
Vector2Int offsets = GridOffsets[originGrid.ParentItem][grid];
LocationInGrid location = new(x - offsets.x, y - offsets.y, multigridLocation.r);
- return new GridItemAddress(grid, location);
+ return new ItemAddressClass(grid, location);
}
public static void Cache(GridView initialGridView)
@@ -108,25 +106,9 @@ namespace UIFixes
GridOffsets.Add(parent, gridOffsets);
GridsByLocation.Add(parent, gridsByLocation);
-
- // Best effort attempt at cleanup
- IItemOwner owner = parent.Owner;
- if (owner != null)
- {
- void onRemoveItem(GEventArgs3 eventArgs)
- {
- if (GridOffsets.ContainsKey(eventArgs.Item))
- {
- GridOffsets.Remove(eventArgs.Item);
- GridsByLocation.Remove(eventArgs.Item);
- owner.RemoveItemEvent -= onRemoveItem;
- }
- };
- owner.RemoveItemEvent += onRemoveItem;
- }
}
- private static bool IsMultiGrid(GridItemAddress itemAddress)
+ private static bool IsMultiGrid(ItemAddressClass itemAddress)
{
return IsMultiGrid(itemAddress.Container.ParentItem);
}
diff --git a/Multiselect/MultiSelect.cs b/Multiselect/MultiSelect.cs
index ac55efa..6bfc3ab 100644
--- a/Multiselect/MultiSelect.cs
+++ b/Multiselect/MultiSelect.cs
@@ -7,8 +7,6 @@ using System.Threading.Tasks;
using TMPro;
using UnityEngine;
-using GridItemAddress = GClass2769;
-
namespace UIFixes
{
public class MultiSelect
@@ -202,9 +200,9 @@ namespace UIFixes
var result = ItemContexts
.Where(ic => first == null || ic.Item != first.Item)
- .OrderByDescending(ic => ic.ItemAddress is GridItemAddress)
+ .OrderByDescending(ic => ic.ItemAddress is ItemAddressClass)
.ThenByDescending(ic => first != null && first.ItemAddress.Container.ParentItem == ic.ItemAddress.Container.ParentItem)
- .ThenBy(ic => ic.ItemAddress is GridItemAddress selectedGridAddress ? gridOrder(MultiGrid.GetGridLocation(selectedGridAddress)) : 0);
+ .ThenBy(ic => ic.ItemAddress is ItemAddressClass selectedGridAddress ? gridOrder(MultiGrid.GetGridLocation(selectedGridAddress)) : 0);
return first != null && prepend ? result.Prepend(first) : result;
}
@@ -238,7 +236,7 @@ namespace UIFixes
private static bool InteractionAvailable(ItemContextClass itemContext, EItemInfoButton interaction, ItemUiContext itemUiContext)
{
// Since itemContext is for "drag", no context actions are allowed. Get the underlying "inventory" context
- ItemContextAbstractClass innerContext = itemContext.GClass2813_0;
+ ItemContextAbstractClass innerContext = itemContext.ItemContextAbstractClass;
if (innerContext == null)
{
return false;
@@ -283,7 +281,7 @@ namespace UIFixes
var taskSerializer = itemUiContext.gameObject.AddComponent();
taskSerializer.Initialize(
SortedItemContexts().Where(ic => InteractionAvailable(ic, EItemInfoButton.Unequip, itemUiContext)),
- itemContext => itemUiContext.Uninstall(itemContext.GClass2813_0));
+ itemContext => itemUiContext.Uninstall(itemContext.ItemContextAbstractClass));
itemUiContext.Tooltip?.Close();
}
@@ -291,19 +289,23 @@ namespace UIFixes
public static Task LoadAmmoAll(ItemUiContext itemUiContext, string ammoTemplateId, bool allOrNothing)
{
- StopLoading();
+ StopLoading(true);
if (!allOrNothing || InteractionCount(EItemInfoButton.LoadAmmo, itemUiContext) == Count)
{
- // Call Initialize() before setting UnloadSerializer so that the initial synchronous call to StopProcesses()->StopUnloading() doesn't immediately cancel this
- var taskSerializer = itemUiContext.gameObject.AddComponent();
- Task result = taskSerializer.Initialize(
- SortedItemContexts().Where(ic => ic.Item is MagazineClass && InteractionAvailable(ic, EItemInfoButton.LoadAmmo, itemUiContext)),
- itemContext => itemUiContext.LoadAmmoByType(itemContext.Item as MagazineClass, ammoTemplateId, itemContext.UpdateView));
+ LoadUnloadSerializer = itemUiContext.gameObject.AddComponent();
+ Task result = LoadUnloadSerializer.Initialize(
+ SortedItemContexts()
+ .Where(ic => ic.Item is MagazineClass && InteractionAvailable(ic, EItemInfoButton.LoadAmmo, itemUiContext))
+ .SelectMany(ic => ic.RepeatUntilFull()),
+ itemContext =>
+ {
+ IgnoreStopLoading = true;
+ return itemUiContext.LoadAmmoByType(itemContext.Item as MagazineClass, ammoTemplateId, itemContext.UpdateView);
+ });
- LoadUnloadSerializer = taskSerializer;
itemUiContext.Tooltip?.Close();
- return result;
+ return result.ContinueWith(t => LoadUnloadSerializer = null);
}
return Task.CompletedTask;
@@ -311,12 +313,11 @@ namespace UIFixes
public static void UnloadAmmoAll(ItemUiContext itemUiContext, bool allOrNothing)
{
- StopLoading();
+ StopLoading(true);
if (!allOrNothing || InteractionCount(EItemInfoButton.UnloadAmmo, itemUiContext) == Count)
{
- // Call Initialize() before setting UnloadSerializer so that the initial synchronous call to StopProcesses()->StopUnloading() doesn't immediately cancel this
- var taskSerializer = itemUiContext.gameObject.AddComponent();
- taskSerializer.Initialize(
+ LoadUnloadSerializer = itemUiContext.gameObject.AddComponent();
+ LoadUnloadSerializer.Initialize(
SortedItemContexts().Where(ic => InteractionAvailable(ic, EItemInfoButton.UnloadAmmo, itemUiContext)),
itemContext =>
{
@@ -324,23 +325,33 @@ namespace UIFixes
{
Deselect(itemContext);
}
- return itemUiContext.UnloadAmmo(itemContext.Item);
- });
- LoadUnloadSerializer = taskSerializer;
+ IgnoreStopLoading = true;
+ return itemUiContext.UnloadAmmo(itemContext.Item);
+ }).ContinueWith(t => LoadUnloadSerializer = null);
+
itemUiContext.Tooltip?.Close();
}
}
- public static void StopLoading()
+ private static bool IgnoreStopLoading = false;
+
+ public static void StopLoading(bool force = false)
{
if (LoadUnloadSerializer == null)
{
return;
}
- LoadUnloadSerializer.Cancel();
- LoadUnloadSerializer = null;
+ if (!IgnoreStopLoading || force)
+ {
+ LoadUnloadSerializer.Cancel();
+ LoadUnloadSerializer = null;
+ }
+ else
+ {
+ IgnoreStopLoading = false;
+ }
}
public static void UnpackAll(ItemUiContext itemUiContext, bool allOrNothing)
@@ -402,21 +413,21 @@ namespace UIFixes
public MultiSelectItemContext(ItemContextAbstractClass itemContext, ItemRotation rotation) : base(itemContext, rotation)
{
// Adjust event handlers
- if (GClass2813_0 != null)
+ if (ItemContextAbstractClass != null)
{
// Listen for underlying context being disposed, it might mean the item is gone (merged, destroyed, etc)
- GClass2813_0.OnDisposed += OnParentDispose;
+ ItemContextAbstractClass.OnDisposed += OnParentDispose;
// This serves no purpose and causes stack overflows
- GClass2813_0.OnCloseWindow -= CloseDependentWindows;
+ ItemContextAbstractClass.OnCloseWindow -= CloseDependentWindows;
}
}
public override void Dispose()
{
base.Dispose();
- if (GClass2813_0 != null)
+ if (ItemContextAbstractClass != null)
{
- GClass2813_0.OnDisposed -= OnParentDispose;
+ ItemContextAbstractClass.OnDisposed -= OnParentDispose;
}
}
@@ -433,9 +444,9 @@ namespace UIFixes
// ItemContextClass (drag) defaults to None, but we want what the underlying item allows
public override bool CanQuickMoveTo(ETargetContainer targetContainer)
{
- if (GClass2813_0 != null)
+ if (ItemContextAbstractClass != null)
{
- return GClass2813_0.CanQuickMoveTo(targetContainer);
+ return ItemContextAbstractClass.CanQuickMoveTo(targetContainer);
}
return base.CanQuickMoveTo(targetContainer);
@@ -481,6 +492,18 @@ namespace UIFixes
}
}
+ public static IEnumerable RepeatUntilFull(this ItemContextClass itemContext)
+ {
+ if (itemContext.Item is MagazineClass magazine)
+ {
+ int ammoCount = -1;
+ while (magazine.Count > ammoCount && magazine.Count < magazine.MaxCount)
+ {
+ ammoCount = magazine.Count;
+ yield return itemContext;
+ }
+ }
+ }
}
}
diff --git a/Patches/AddOfferClickablePricesPatches.cs b/Patches/AddOfferClickablePricesPatches.cs
index dc4b1d6..daa2bcd 100644
--- a/Patches/AddOfferClickablePricesPatches.cs
+++ b/Patches/AddOfferClickablePricesPatches.cs
@@ -1,7 +1,7 @@
-using Aki.Reflection.Patching;
-using EFT.UI.Ragfair;
+using EFT.UI.Ragfair;
using HarmonyLib;
using JetBrains.Annotations;
+using SPT.Reflection.Patching;
using System.Linq;
using System.Reflection;
using TMPro;
diff --git a/Patches/AddOfferRememberAutoselectPatches.cs b/Patches/AddOfferRememberAutoselectPatches.cs
index 12b7e11..60a2e3e 100644
--- a/Patches/AddOfferRememberAutoselectPatches.cs
+++ b/Patches/AddOfferRememberAutoselectPatches.cs
@@ -1,7 +1,7 @@
-using Aki.Reflection.Patching;
-using EFT.UI;
+using EFT.UI;
using EFT.UI.Ragfair;
using HarmonyLib;
+using SPT.Reflection.Patching;
using System.Reflection;
using UnityEngine;
@@ -29,7 +29,7 @@ namespace UIFixes
{
protected override MethodBase GetTargetMethod()
{
- return AccessTools.Method(typeof(AddOfferWindow), nameof(AddOfferWindow.method_8));
+ return AccessTools.Method(typeof(AddOfferWindow), nameof(AddOfferWindow.method_7));
}
[PatchPostfix]
diff --git a/Patches/AssortUnlocksPatch.cs b/Patches/AssortUnlocksPatch.cs
index b467a13..f42ad1e 100644
--- a/Patches/AssortUnlocksPatch.cs
+++ b/Patches/AssortUnlocksPatch.cs
@@ -1,12 +1,13 @@
-using Aki.Common.Http;
-using Aki.Reflection.Patching;
-using EFT.UI;
+using EFT.UI;
using EFT.UI.Ragfair;
using HarmonyLib;
using Newtonsoft.Json;
+using SPT.Common.Http;
+using SPT.Reflection.Patching;
using System;
using System.Collections.Generic;
using System.Reflection;
+using System.Threading.Tasks;
namespace UIFixes
{
@@ -32,20 +33,24 @@ namespace UIFixes
{
Loading = true;
- string response = RequestHandler.GetJson("/uifixes/assortUnlocks");
- if (!String.IsNullOrEmpty(response))
+ Task response = RequestHandler.GetJsonAsync("/uifixes/assortUnlocks");
+ response.ContinueWith(task =>
{
- try
+ string json = task.Result;
+ if (!String.IsNullOrEmpty(json))
{
- AssortUnlocks = JsonConvert.DeserializeObject>(response);
+ try
+ {
+ AssortUnlocks = JsonConvert.DeserializeObject>(json);
+ }
+ catch (Exception ex)
+ {
+ Logger.LogError(ex);
+ }
}
- catch (Exception ex)
- {
- Logger.LogError(ex);
- }
- }
- Loading = false;
+ Loading = false;
+ });
}
if (__instance.Offer_0.Locked)
diff --git a/Patches/AutofillQuestItemsPatch.cs b/Patches/AutofillQuestItemsPatch.cs
index 3f9db85..2a3306b 100644
--- a/Patches/AutofillQuestItemsPatch.cs
+++ b/Patches/AutofillQuestItemsPatch.cs
@@ -1,6 +1,6 @@
-using Aki.Reflection.Patching;
-using EFT.UI;
+using EFT.UI;
using HarmonyLib;
+using SPT.Reflection.Patching;
using System.Reflection;
using UnityEngine;
diff --git a/Patches/ConfirmationDialogKeysPatches.cs b/Patches/ConfirmationDialogKeysPatches.cs
index aa8e9d4..e320391 100644
--- a/Patches/ConfirmationDialogKeysPatches.cs
+++ b/Patches/ConfirmationDialogKeysPatches.cs
@@ -1,7 +1,6 @@
-using Aki.Reflection.Patching;
-using EFT.InputSystem;
-using EFT.UI;
+using EFT.UI;
using HarmonyLib;
+using SPT.Reflection.Patching;
using System.Reflection;
using UnityEngine;
using UnityEngine.UI;
diff --git a/Patches/ContextMenuPatches.cs b/Patches/ContextMenuPatches.cs
index 5ff21d1..86fa881 100644
--- a/Patches/ContextMenuPatches.cs
+++ b/Patches/ContextMenuPatches.cs
@@ -1,9 +1,9 @@
-using Aki.Reflection.Patching;
-using Aki.Reflection.Utils;
-using Comfort.Common;
+using Comfort.Common;
using EFT.InventoryLogic;
using EFT.UI;
using HarmonyLib;
+using SPT.Reflection.Patching;
+using SPT.Reflection.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -49,9 +49,9 @@ namespace UIFixes
public static void Enable()
{
// The context menus in the inventory and the trading screen inventory are *completely different code*
- InventoryRootInteractionsType = PatchConstants.EftTypes.Single(t => t.GetField("HIDEOUT_WEAPON_MODIFICATION_REQUIRED") != null); // GClass3023
+ InventoryRootInteractionsType = PatchConstants.EftTypes.Single(t => t.GetField("HIDEOUT_WEAPON_MODIFICATION_REQUIRED") != null); // GClass3045
- // GClass3032 - this is nuts to find, have to inspect a static enum array
+ // GClass3054 - this is nuts to find, have to inspect a static enum array
TradingRootInteractionsType = PatchConstants.EftTypes.Single(t =>
{
var enumerableField = t.GetField("ienumerable_2", BindingFlags.NonPublic | BindingFlags.Static);
@@ -414,7 +414,7 @@ namespace UIFixes
if (selectedItem is BulletClass)
{
- __result = new MagazineBuildClass.Class3135(selectedItem);
+ __result = new MagazineBuildClass.Class3183(selectedItem);
return false;
}
diff --git a/Patches/ContextMenuShortcutPatches.cs b/Patches/ContextMenuShortcutPatches.cs
index 102d584..4b00092 100644
--- a/Patches/ContextMenuShortcutPatches.cs
+++ b/Patches/ContextMenuShortcutPatches.cs
@@ -1,8 +1,8 @@
-using Aki.Reflection.Patching;
-using EFT.InventoryLogic;
+using EFT.InventoryLogic;
using EFT.UI;
using EFT.UI.DragAndDrop;
using HarmonyLib;
+using SPT.Reflection.Patching;
using System.Reflection;
using TMPro;
using UnityEngine.EventSystems;
@@ -143,9 +143,9 @@ namespace UIFixes
}
[PatchPostfix]
- public static void Postfix(ItemUiContext ___itemUiContext_0, ItemContextAbstractClass ___gclass2813_0)
+ public static void Postfix(ItemUiContext ___itemUiContext_0, ItemContextAbstractClass ___itemContextAbstractClass)
{
- ___itemUiContext_0.RegisterCurrentItemContext(___gclass2813_0);
+ ___itemUiContext_0.RegisterCurrentItemContext(___itemContextAbstractClass);
}
}
@@ -157,9 +157,9 @@ namespace UIFixes
}
[PatchPostfix]
- public static void Postfix(ItemUiContext ___itemUiContext_0, ItemContextAbstractClass ___gclass2813_0)
+ public static void Postfix(ItemUiContext ___itemUiContext_0, ItemContextAbstractClass ___itemContextAbstractClass)
{
- ___itemUiContext_0.UnregisterCurrentItemContext(___gclass2813_0);
+ ___itemUiContext_0.UnregisterCurrentItemContext(___itemContextAbstractClass);
}
}
diff --git a/Patches/FixFleaPatches.cs b/Patches/FixFleaPatches.cs
index 1c76278..8837479 100644
--- a/Patches/FixFleaPatches.cs
+++ b/Patches/FixFleaPatches.cs
@@ -1,6 +1,6 @@
-using Aki.Reflection.Patching;
-using EFT.UI.Ragfair;
+using EFT.UI.Ragfair;
using HarmonyLib;
+using SPT.Reflection.Patching;
using System.Reflection;
using TMPro;
using UnityEngine;
diff --git a/Patches/FixMailRecieveAllPatch.cs b/Patches/FixMailRecieveAllPatch.cs
index 23dab60..7b6392d 100644
--- a/Patches/FixMailRecieveAllPatch.cs
+++ b/Patches/FixMailRecieveAllPatch.cs
@@ -1,6 +1,6 @@
-using Aki.Reflection.Patching;
using EFT.UI.Chat;
using HarmonyLib;
+using SPT.Reflection.Patching;
using System.Reflection;
namespace UIFixes
diff --git a/Patches/FixTooltipPatches.cs b/Patches/FixTooltipPatches.cs
index 6aeff33..72eac2c 100644
--- a/Patches/FixTooltipPatches.cs
+++ b/Patches/FixTooltipPatches.cs
@@ -1,7 +1,7 @@
-using Aki.Reflection.Patching;
-using EFT.UI;
+using EFT.UI;
using EFT.UI.DragAndDrop;
using HarmonyLib;
+using SPT.Reflection.Patching;
using System.Reflection;
using TMPro;
using UnityEngine;
diff --git a/Patches/FixTraderControllerSimulateFalsePatch.cs b/Patches/FixTraderControllerSimulateFalsePatch.cs
index a5f63ff..06ef2ea 100644
--- a/Patches/FixTraderControllerSimulateFalsePatch.cs
+++ b/Patches/FixTraderControllerSimulateFalsePatch.cs
@@ -1,7 +1,7 @@
-using Aki.Reflection.Patching;
-using Diz.LanguageExtensions;
+using Diz.LanguageExtensions;
using EFT.InventoryLogic;
using HarmonyLib;
+using SPT.Reflection.Patching;
using System.Reflection;
namespace UIFixes
@@ -13,18 +13,18 @@ namespace UIFixes
return AccessTools.Method(typeof(TraderControllerClass), nameof(TraderControllerClass.ExecutePossibleAction), [typeof(ItemContextAbstractClass), typeof(Item), typeof(bool), typeof(bool)]);
}
- // Recreatign this function to add the comment section, so calling this with simulate = false doesn't break everything
+ // Recreating this function to add the comment section, so calling this with simulate = false doesn't break everything
[PatchPrefix]
[HarmonyPriority(Priority.Last)]
public static bool Prefix(TraderControllerClass __instance, ItemContextAbstractClass itemContext, Item targetItem, bool partialTransferOnly, bool simulate, ref GStruct413 __result)
{
- TraderControllerClass.Struct754 opStruct;
+ TraderControllerClass.Struct775 opStruct;
opStruct.targetItem = targetItem;
- opStruct.gclass2758_0 = __instance;
+ opStruct.traderControllerClass = __instance;
opStruct.simulate = simulate;
opStruct.item = itemContext.Item;
- Error error = new GClass3293(opStruct.item);
+ Error error = new GClass3317(opStruct.item);
bool mergeAvailable = itemContext.MergeAvailable;
bool splitAvailable = itemContext.SplitAvailable;
partialTransferOnly &= splitAvailable;
@@ -45,7 +45,7 @@ namespace UIFixes
}
}
- if (opStruct.targetItem is GInterface306 applicable)
+ if (opStruct.targetItem is GInterface321 applicable)
{
var operation = __instance.method_23(applicable, ref error, ref opStruct);
if (operation.Succeeded)
diff --git a/Patches/FixUnloadLastBulletPatch.cs b/Patches/FixUnloadLastBulletPatch.cs
index 1581c0e..c52dad3 100644
--- a/Patches/FixUnloadLastBulletPatch.cs
+++ b/Patches/FixUnloadLastBulletPatch.cs
@@ -1,6 +1,6 @@
-using Aki.Reflection.Patching;
-using EFT.InventoryLogic;
+using EFT.InventoryLogic;
using HarmonyLib;
+using SPT.Reflection.Patching;
using System.Collections.Generic;
using System.Reflection;
diff --git a/Patches/FleaPrevSearchPatches.cs b/Patches/FleaPrevSearchPatches.cs
index 2b0ca8a..bcc7a7e 100644
--- a/Patches/FleaPrevSearchPatches.cs
+++ b/Patches/FleaPrevSearchPatches.cs
@@ -1,8 +1,8 @@
-using Aki.Reflection.Patching;
-using EFT.UI;
+using EFT.UI;
using EFT.UI.Ragfair;
using EFT.UI.Utilities.LightScroller;
using HarmonyLib;
+using SPT.Reflection.Patching;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -197,7 +197,7 @@ namespace UIFixes
private void ApplyFullFilter(FilterRule filterRule)
{
// Order impacts the order the filters show in the UI
- var searches = new List();
+ var searches = new List();
// This part was tricky to figure out. Adding OR removing any of these ID filters will clear the others, so you can only do one of them.
// When going to a state with no id filter, you MUST remove something (or all to be safe)
@@ -322,7 +322,7 @@ namespace UIFixes
{
protected override MethodBase GetTargetMethod()
{
- return AccessTools.Method(typeof(RagfairScreen), nameof(RagfairScreen.method_7));
+ return AccessTools.Method(typeof(RagfairScreen), nameof(RagfairScreen.method_9));
}
[PatchPostfix]
diff --git a/Patches/FocusFleaOfferNumberPatches.cs b/Patches/FocusFleaOfferNumberPatches.cs
index 08ea964..5293875 100644
--- a/Patches/FocusFleaOfferNumberPatches.cs
+++ b/Patches/FocusFleaOfferNumberPatches.cs
@@ -1,13 +1,10 @@
-using Aki.Reflection.Patching;
-using EFT.InventoryLogic;
-using EFT.UI.Ragfair;
+using EFT.UI.Ragfair;
using HarmonyLib;
+using SPT.Reflection.Patching;
using System;
-using System.Linq;
using System.Reflection;
using TMPro;
using UnityEngine;
-using UnityEngine.UI;
namespace UIFixes
{
diff --git a/Patches/FocusTradeQuantityPatch.cs b/Patches/FocusTradeQuantityPatch.cs
index 54f9778..94a00f4 100644
--- a/Patches/FocusTradeQuantityPatch.cs
+++ b/Patches/FocusTradeQuantityPatch.cs
@@ -1,6 +1,6 @@
-using Aki.Reflection.Patching;
-using EFT.UI;
+using EFT.UI;
using HarmonyLib;
+using SPT.Reflection.Patching;
using System.Reflection;
using TMPro;
diff --git a/Patches/GridWindowButtonsPatch.cs b/Patches/GridWindowButtonsPatch.cs
index 356cb0c..9642751 100644
--- a/Patches/GridWindowButtonsPatch.cs
+++ b/Patches/GridWindowButtonsPatch.cs
@@ -1,7 +1,7 @@
-using Aki.Reflection.Patching;
-using EFT.InventoryLogic;
+using EFT.InventoryLogic;
using EFT.UI;
using HarmonyLib;
+using SPT.Reflection.Patching;
using System.Reflection;
using UnityEngine;
using UnityEngine.UI;
diff --git a/Patches/HideoutLevelPatches.cs b/Patches/HideoutLevelPatches.cs
index 3fa51db..4d9ac73 100644
--- a/Patches/HideoutLevelPatches.cs
+++ b/Patches/HideoutLevelPatches.cs
@@ -1,6 +1,6 @@
-using Aki.Reflection.Patching;
-using EFT.Hideout;
+using EFT.Hideout;
using HarmonyLib;
+using SPT.Reflection.Patching;
using System.Reflection;
namespace UIFixes
diff --git a/Patches/HideoutSearchPatches.cs b/Patches/HideoutSearchPatches.cs
index ed91fa4..d918a80 100644
--- a/Patches/HideoutSearchPatches.cs
+++ b/Patches/HideoutSearchPatches.cs
@@ -1,4 +1,4 @@
-using Aki.Reflection.Patching;
+using SPT.Reflection.Patching;
using EFT.Hideout;
using EFT.UI;
using HarmonyLib;
@@ -34,7 +34,7 @@ namespace UIFixes
{
protected override MethodBase GetTargetMethod()
{
- return AccessTools.Method(R.ProductionPanelShowSubclass.Type, "method_6");
+ return AccessTools.Method(R.ProductionPanelShowSubclass.Type, "method_2");
}
[PatchPostfix]
@@ -96,7 +96,7 @@ namespace UIFixes
public static void Postfix(ProductionPanel __instance, ValidationInputField ____searchInputField)
{
// Force it to render immediately, at full height, even if the search filtering would reduce the number of children
- if (__instance.method_4().Count() > 2)
+ if (__instance.method_9().Count() > 2)
{
AreaScreenSubstrate areaScreenSubstrate = __instance.GetComponentInParent();
LayoutElement layoutElement = areaScreenSubstrate.R().ContentLayout;
@@ -109,21 +109,21 @@ namespace UIFixes
}
}
- // method_4 gets the sorted list of products. If there's a search term, prioritize the matching items so they load first
+ // method_9 gets the sorted list of products. If there's a search term, prioritize the matching items so they load first
public class FastHideoutSearchPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
- return AccessTools.Method(typeof(ProductionPanel), nameof(ProductionPanel.method_4));
+ return AccessTools.Method(typeof(ProductionPanel), nameof(ProductionPanel.method_9));
}
- // Copied directly from method_4. Working with GClasses directly here, because this would be a nightmare with reflection
+ // Copied directly from method_9. Working with GClasses directly here, because this would be a nightmare with reflection
[PatchPrefix]
- public static bool Prefix(ref IEnumerable __result, ProductionPanel __instance, GClass1922[] ___gclass1922_0, ValidationInputField ____searchInputField)
+ public static bool Prefix(ref IEnumerable __result, ProductionPanel __instance, ProductionBuildAbstractClass[] ___gclass1938_0, ValidationInputField ____searchInputField)
{
- __result = ___gclass1922_0.OfType().Where(scheme => !scheme.locked)
+ __result = ___gclass1938_0.OfType().Where(scheme => !scheme.locked)
.OrderBy(scheme => scheme.endProduct.LocalizedName().Contains(____searchInputField.text) ? 0 : 1) // search-matching items first
- .ThenBy(__instance.method_10)
+ .ThenBy(__instance.method_18)
.ThenBy(scheme => scheme.FavoriteIndex)
.ThenBy(scheme => scheme.Level);
@@ -131,18 +131,18 @@ namespace UIFixes
}
}
- // method_9 activates/deactivates the product game objects based on the search. Need to resort the list due to above patch
+ // method_14 activates/deactivates the product game objects based on the search. Need to resort the list due to above patch
public class FixHideoutSearchAgainPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
- return AccessTools.Method(typeof(ProductionPanel), nameof(ProductionPanel.method_9));
+ return AccessTools.Method(typeof(ProductionPanel), nameof(ProductionPanel.method_14));
}
[PatchPrefix]
public static void Prefix(ProductionPanel __instance)
{
- __instance.method_8(); // update sort order
+ __instance.method_13(); // update sort order
}
}
diff --git a/Patches/InspectWindowResizePatches.cs b/Patches/InspectWindowResizePatches.cs
index 5342c60..273b59d 100644
--- a/Patches/InspectWindowResizePatches.cs
+++ b/Patches/InspectWindowResizePatches.cs
@@ -1,8 +1,8 @@
-using Aki.Reflection.Patching;
-using EFT.InputSystem;
+using EFT.InputSystem;
using EFT.InventoryLogic;
using EFT.UI;
using HarmonyLib;
+using SPT.Reflection.Patching;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
diff --git a/Patches/InspectWindowStatsPatches.cs b/Patches/InspectWindowStatsPatches.cs
index e9995b8..fcc1e3e 100644
--- a/Patches/InspectWindowStatsPatches.cs
+++ b/Patches/InspectWindowStatsPatches.cs
@@ -1,7 +1,7 @@
-using Aki.Reflection.Patching;
-using EFT.InventoryLogic;
+using EFT.InventoryLogic;
using EFT.UI;
using HarmonyLib;
+using SPT.Reflection.Patching;
using System;
using System.Collections.Generic;
using System.Globalization;
@@ -304,7 +304,7 @@ namespace UIFixes
// Bar width is currently set to durability/100, and that 100 is pretty much hardcoded by the client
// Just clamp the bar to keep it from overflowing
[PatchPostfix]
- public static void Postfix(DurabilityPanel __instance, Image ___Current)
+ public static void Postfix(Image ___Current)
{
___Current.rectTransform.anchorMax = new Vector2(
Mathf.Min(___Current.rectTransform.anchorMax.x, 1f),
diff --git a/Patches/KeepMessagesOpenPatches.cs b/Patches/KeepMessagesOpenPatches.cs
index c32dfe3..ec2f546 100644
--- a/Patches/KeepMessagesOpenPatches.cs
+++ b/Patches/KeepMessagesOpenPatches.cs
@@ -1,8 +1,8 @@
-using Aki.Reflection.Patching;
-using EFT.UI;
+using EFT.UI;
using EFT.UI.Chat;
using EFT.UI.Screens;
using HarmonyLib;
+using SPT.Reflection.Patching;
using System.Reflection;
namespace UIFixes
diff --git a/Patches/KeepOfferWindowOpenPatches.cs b/Patches/KeepOfferWindowOpenPatches.cs
index 016b4e7..0ae8ab0 100644
--- a/Patches/KeepOfferWindowOpenPatches.cs
+++ b/Patches/KeepOfferWindowOpenPatches.cs
@@ -1,7 +1,9 @@
-using Aki.Reflection.Patching;
-using EFT.InventoryLogic;
-using EFT.UI.Ragfair;
+using EFT.UI.Ragfair;
using HarmonyLib;
+using SPT.Reflection.Patching;
+using System;
+using System.Collections.Generic;
+using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
@@ -11,13 +13,42 @@ namespace UIFixes
{
private static bool BlockClose = false;
+ private static TaskCompletionSource CompletionSource;
+ private static readonly List AddOfferTasks = [];
+ private static AddOfferWindow Window;
+
public static void Enable()
{
+ new GetTaskCompletionSourcePatch().Enable();
new PlaceOfferClickPatch().Enable();
new ClosePatch().Enable();
new ManageTaskPatch().Enable();
}
+ public class GetTaskCompletionSourcePatch : ModulePatch
+ {
+ protected override MethodBase GetTargetMethod()
+ {
+ return AccessTools.DeclaredMethod(typeof(AddOfferWindow), nameof(AddOfferWindow.Show));
+ }
+
+ [PatchPostfix]
+ public static void Postfix(AddOfferWindow __instance, ref Task __result)
+ {
+ if (!Settings.KeepAddOfferOpen.Value)
+ {
+ return;
+ }
+
+ Window = __instance;
+ AddOfferTasks.Clear();
+
+ // Use a different task to mark when everything is actually done
+ CompletionSource = new TaskCompletionSource();
+ __result = CompletionSource.Task;
+ }
+ }
+
public class PlaceOfferClickPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
@@ -26,10 +57,12 @@ namespace UIFixes
}
[PatchPrefix]
- public static void Prefix(AddOfferWindow __instance)
+ public static void Prefix(AddOfferWindow __instance, TaskCompletionSource ___taskCompletionSource_0, ref TaskCompletionSource __state)
{
if (Settings.KeepAddOfferOpen.Value)
{
+ __state = ___taskCompletionSource_0;
+
// Close the window if you're gonna hit max offers
var ragfair = __instance.R().Ragfair;
if (Settings.KeepAddOfferOpenIgnoreMaxOffers.Value || ragfair.MyOffersCount + 1 < ragfair.GetMaxOffersCount(ragfair.MyRating))
@@ -40,10 +73,13 @@ namespace UIFixes
}
[PatchPostfix]
- public static void Postfix(RequirementView[] ____requirementViews, bool ___bool_2)
+ public static void Postfix(RequirementView[] ____requirementViews, TaskCompletionSource ___taskCompletionSource_0, ref TaskCompletionSource __state)
{
- if (Settings.KeepAddOfferOpen.Value && ___bool_2)
+ bool isAddingOffer = __state != ___taskCompletionSource_0; // If the taskCompletionSource member was changed, then it's adding an offer :S
+ if (Settings.KeepAddOfferOpen.Value && isAddingOffer)
{
+ AddOfferTasks.Add(__state.Task); // This is the task completion source passed into the add offer call
+
// clear old prices
foreach (var requirementView in ____requirementViews)
{
@@ -59,12 +95,20 @@ namespace UIFixes
{
protected override MethodBase GetTargetMethod()
{
- return AccessTools.Method(typeof(AddOfferWindow), nameof(AddOfferWindow.Close));
+ return AccessTools.Method(typeof(AddOfferWindow), nameof(Window.Close));
}
[PatchPrefix]
public static bool Prefix()
{
+ if (!BlockClose && AddOfferTasks.All(t => t.IsCompleted))
+ {
+ CompletionSource.Complete();
+ CompletionSource = null;
+ AddOfferTasks.Clear();
+ Window = null;
+ }
+
return !BlockClose;
}
}
@@ -75,21 +119,25 @@ namespace UIFixes
{
protected override MethodBase GetTargetMethod()
{
- return AccessTools.Method(typeof(AddOfferWindow), nameof(AddOfferWindow.method_16));
+ Type type = typeof(AddOfferWindow).GetNestedTypes().Single(t => t.GetField("completionSource") != null); // AddOfferWindow.Class3068
+ return AccessTools.Method(type, "method_0");
}
[PatchPrefix]
- public static bool Prefix(AddOfferWindow __instance, TaskCompletionSource