Fix put-tools-back bug breaking stuff; deselect on unpack

This commit is contained in:
Tyfon
2024-07-02 18:40:04 -07:00
parent 212c19b658
commit c1e497d482
4 changed files with 21 additions and 11 deletions

View File

@@ -318,7 +318,14 @@ namespace UIFixes
var taskSerializer = itemUiContext.gameObject.AddComponent<ItemContextTaskSerializer>();
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<ItemContextTaskSerializer>();
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();
}

View File

@@ -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)
{

View File

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

View File

@@ -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<Item> 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);