diff --git a/Multiselect/MultiSelect.cs b/Multiselect/MultiSelect.cs index b5680f7..ac55efa 100644 --- a/Multiselect/MultiSelect.cs +++ b/Multiselect/MultiSelect.cs @@ -318,7 +318,14 @@ namespace UIFixes var taskSerializer = itemUiContext.gameObject.AddComponent(); taskSerializer.Initialize( SortedItemContexts().Where(ic => InteractionAvailable(ic, EItemInfoButton.UnloadAmmo, itemUiContext)), - itemContext => itemUiContext.UnloadAmmo(itemContext.Item)); + itemContext => + { + if (itemContext.Item is AmmoBox) + { + Deselect(itemContext); + } + return itemUiContext.UnloadAmmo(itemContext.Item); + }); LoadUnloadSerializer = taskSerializer; itemUiContext.Tooltip?.Close(); @@ -343,7 +350,11 @@ namespace UIFixes var taskSerializer = itemUiContext.gameObject.AddComponent(); taskSerializer.Initialize( SortedItemContexts().Where(ic => InteractionAvailable(ic, EItemInfoButton.Unpack, itemUiContext)), - itemContext => itemUiContext.UnpackItem(itemContext.Item)); + itemContext => + { + Deselect(itemContext); + return itemUiContext.UnpackItem(itemContext.Item); + }); itemUiContext.Tooltip?.Close(); } diff --git a/Patches/LoadMultipleMagazinesPatches.cs b/Patches/LoadMultipleMagazinesPatches.cs index 068a705..93bd4c0 100644 --- a/Patches/LoadMultipleMagazinesPatches.cs +++ b/Patches/LoadMultipleMagazinesPatches.cs @@ -30,7 +30,7 @@ namespace UIFixes } [PatchPrefix] - public static void Prefix(MagazineClass magazine) + public static void Prefix() { if (MultiSelect.Active) { @@ -57,7 +57,7 @@ namespace UIFixes } [PatchPrefix] - public static void Prefix(ref ItemFilter[] filters, Item item) + public static void Prefix(ref ItemFilter[] filters) { if (CombinedFilters == null) { @@ -96,7 +96,7 @@ namespace UIFixes } [PatchPrefix] - public static void Prefix(MagazineClass magazine) + public static void Prefix() { if (MultiSelect.Active) { diff --git a/Patches/MultiSelectPatches.cs b/Patches/MultiSelectPatches.cs index 0d58637..788fc16 100644 --- a/Patches/MultiSelectPatches.cs +++ b/Patches/MultiSelectPatches.cs @@ -718,9 +718,6 @@ namespace UIFixes public class AdjustQuickFindFlagsPatch : ModulePatch { - // For reasons (???), BSG doesn't even define the second bit of this flags enum - private static readonly InteractionsHandlerClass.EMoveItemOrder PartialMerge = (InteractionsHandlerClass.EMoveItemOrder)2; - protected override MethodBase GetTargetMethod() { return AccessTools.Method(typeof(InteractionsHandlerClass), nameof(InteractionsHandlerClass.QuickFindAppropriatePlace)); diff --git a/Patches/PutToolsBackPatch.cs b/Patches/PutToolsBackPatch.cs index 2605b61..8476c9e 100644 --- a/Patches/PutToolsBackPatch.cs +++ b/Patches/PutToolsBackPatch.cs @@ -2,6 +2,7 @@ using EFT; using EFT.InventoryLogic; using HarmonyLib; +using System; using System.Collections.Generic; using System.Linq; using System.Reflection; @@ -25,8 +26,9 @@ namespace UIFixes StashClass stash = inventory.Stash; if (inventory != null && stash != null) { - var handledContainers = new ContainerCollection[] { inventory.Stash, inventory.Equipment, inventory.QuestRaidItems, inventory.QuestStashItems, inventory.SortingTable }; - var unhandledItems = newItems.Where(i => !handledContainers.Select(c => c.Id).Contains(i.parentId)).ToArray(); + // Handled items are either in these top level containers or are nested inside each other (mods, attachments, etc) + var handledContainerIds = newItems.Select(i => i._id).Concat([inventory.Stash.Id, inventory.Equipment.Id, inventory.QuestRaidItems.Id, inventory.QuestStashItems.Id, inventory.SortingTable.Id]); + var unhandledItems = newItems.Where(i => !String.IsNullOrEmpty(i.parentId) && !handledContainerIds.Contains(i.parentId)); if (!unhandledItems.Any()) { @@ -38,7 +40,7 @@ namespace UIFixes List stashItems = stash.GetNotMergedItems().ToList(); - ItemFactory.GStruct134 tree = ___gclass1486_0.FlatItemsToTree(unhandledItems, true, null); + ItemFactory.GStruct134 tree = ___gclass1486_0.FlatItemsToTree(unhandledItems.ToArray(), true, null); foreach (Item item in tree.Items.Values.Where(i => i.CurrentAddress == null)) { GClass1189 newItem = unhandledItems.First(i => i._id == item.Id);