diff --git a/MultiSelect.cs b/MultiSelect.cs index 0f0a7e4..9beebda 100644 --- a/MultiSelect.cs +++ b/MultiSelect.cs @@ -239,11 +239,8 @@ namespace UIFixes { if (!allOrNothing || InteractionCount(EItemInfoButton.Equip, itemUiContext) == Count) { - foreach (ItemContextClass selectedItemContext in SortedItemContexts()) - { - itemUiContext.QuickEquip(selectedItemContext.Item).HandleExceptions(); - } - + var taskSerializer = itemUiContext.GetOrAddComponent(); + taskSerializer.Initialize(SortedItemContexts(), itemContext => itemUiContext.QuickEquip(itemContext.Item)); itemUiContext.Tooltip?.Close(); } } @@ -252,11 +249,8 @@ namespace UIFixes { if (!allOrNothing || InteractionCount(EItemInfoButton.Unequip, itemUiContext) == Count) { - foreach (ItemContextClass selectedItemContext in SortedItemContexts()) - { - itemUiContext.Uninstall(selectedItemContext.GClass2813_0).HandleExceptions(); - } - + var taskSerializer = itemUiContext.GetOrAddComponent(); + taskSerializer.Initialize(SortedItemContexts(), itemContext => itemUiContext.Uninstall(itemContext.GClass2813_0)); itemUiContext.Tooltip?.Close(); } } @@ -265,11 +259,8 @@ namespace UIFixes { if (!allOrNothing || InteractionCount(EItemInfoButton.UnloadAmmo, itemUiContext) == Count) { - foreach (ItemContextClass selectedItemContext in SortedItemContexts()) - { - itemUiContext.UnloadAmmo(selectedItemContext.Item).HandleExceptions(); - } - + var taskSerializer = itemUiContext.GetOrAddComponent(); + taskSerializer.Initialize(SortedItemContexts(), itemContext => itemUiContext.UnloadAmmo(itemContext.Item)); itemUiContext.Tooltip?.Close(); } } @@ -328,6 +319,9 @@ namespace UIFixes } } + // Specific type of TaskSerializer because Unity can't understand generics + public class ItemContextTaskSerializer : TaskSerializer { } + public static class MultiSelectExtensions { public static bool IsSelectable(this ItemView itemView) diff --git a/Patches/ContextMenuPatches.cs b/Patches/ContextMenuPatches.cs index 85b1c73..eee8350 100644 --- a/Patches/ContextMenuPatches.cs +++ b/Patches/ContextMenuPatches.cs @@ -121,7 +121,7 @@ namespace UIFixes ____text.text += " (x" + count + ")"; } } - else if (caption == EItemInfoButton.UnloadAmmo.ToString()) + else if (caption == EItemInfoButton.UnloadAmmo.ToString())) { int count = MultiSelect.InteractionCount(EItemInfoButton.UnloadAmmo, ItemUiContext.Instance); if (count > 0) diff --git a/Patches/MultiSelectPatches.cs b/Patches/MultiSelectPatches.cs index 4eda6cd..4b505f2 100644 --- a/Patches/MultiSelectPatches.cs +++ b/Patches/MultiSelectPatches.cs @@ -34,9 +34,6 @@ namespace UIFixes private static bool DisableMerge = false; private static bool IgnoreItemParent = false; - // Specific type of TaskSerializer because Unity can't understand generics - public class ItemContextTaskSerializer : TaskSerializer { } - public static void Enable() { // Initialization