remove recreated items from reordered list

This commit is contained in:
Tyfon
2024-07-10 12:01:15 -07:00
parent 2247b7bea6
commit 395108eda8
2 changed files with 135 additions and 110 deletions

View File

@@ -1,4 +1,5 @@
using EFT.UI.DragAndDrop;
using EFT.InventoryLogic;
using EFT.UI.DragAndDrop;
using HarmonyLib;
using SPT.Reflection.Patching;
using System;
@@ -9,6 +10,16 @@ using UnityEngine;
namespace UIFixes
{
public static class ReorderGridsPatches
{
private static readonly HashSet<string> ReorderedItems = [];
public static void Enable()
{
new ReorderGridsPatch().Enable();
new ItemCreationPatch().Enable();
}
/* There are 3 cases to handle in TemplatedGridsView.Show
* 1. An item is shown for the first time
* - It renders on its own, and the UI is correct
@@ -20,7 +31,6 @@ namespace UIFixes
*/
public class ReorderGridsPatch : ModulePatch
{
private static readonly HashSet<string> ReorderedItems = [];
private static readonly Dictionary<string, int[]> GridMaps = [];
protected override MethodBase GetTargetMethod()
@@ -162,4 +172,19 @@ namespace UIFixes
public class SortedMarker : MonoBehaviour { }
}
public class ItemCreationPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
return AccessTools.Constructor(typeof(Item), [typeof(string), typeof(ItemTemplate)]);
}
[PatchPostfix]
public static void Postfix(string id)
{
ReorderedItems.Remove(id);
}
}
}
}

View File

@@ -58,7 +58,7 @@ namespace UIFixes
new PutToolsBackPatch().Enable();
new RebindGrenadesPatch().Enable();
AimToggleHoldPatches.Enable();
new ReorderGridsPatch().Enable();
ReorderGridsPatches.Enable();
NoRandomGrenadesPatch.Init();
GPCoinPatches.Enable();
}