diff --git a/Multiselect/MultiSelectDebug.cs b/Multiselect/MultiSelectDebug.cs index ace5f3a..4ef678b 100644 --- a/Multiselect/MultiSelectDebug.cs +++ b/Multiselect/MultiSelectDebug.cs @@ -37,10 +37,11 @@ namespace UIFixes foreach (ItemContextClass itemContext in MultiSelect.SortedItemContexts()) { LocationInGrid location = itemContext.ItemAddress is ItemAddressClass gridAddress ? MultiGrid.GetGridLocation(gridAddress) : null; - builder.AppendFormat("x{0} {1} {2}\n", + builder.AppendFormat("x{0} {1} {2} {3}\n", itemContext.Item.StackObjectsCount, + itemContext.ItemAddress.ContainerName, location != null ? $"({location.x}, {location.y})" : "slot", - itemContext.Item.ToString()); + itemContext.Item.Name.Localized()); } if (MultiSelect.SecondaryContexts.Any()) diff --git a/Patches/MultiSelectPatches.cs b/Patches/MultiSelectPatches.cs index 896beaa..b6eebf3 100644 --- a/Patches/MultiSelectPatches.cs +++ b/Patches/MultiSelectPatches.cs @@ -681,7 +681,8 @@ namespace UIFixes FindOrigin = GetTargetGridAddress(itemContext, ic, hoveredAddress); FindVerticalFirst = ic.ItemRotation == ItemRotation.Vertical; return __instance.AcceptItem(ic, targetItemContext); - }); + }, + itemContext => __instance.Grid.ParentItem.Owner.SelectEvents(itemContext.Item).All(args => args.Status == CommandStatus.Succeed)); // Setting the fallback after initializing means it only applies after the first item is already moved GridViewPickTargetPatch.FallbackResult = __instance.Grid.ParentItem; @@ -906,7 +907,10 @@ namespace UIFixes InPatch = true; var serializer = __instance.gameObject.AddComponent(); - __result = serializer.Initialize(MultiSelect.SortedItemContexts(), itemContext => __instance.AcceptItem(itemContext, targetItemContext)); + __result = serializer.Initialize( + MultiSelect.SortedItemContexts(), + itemContext => __instance.AcceptItem(itemContext, targetItemContext), + itemContext => __instance.Slot.ParentItem.Owner.SelectEvents(itemContext.Item).All(args => args.Status == CommandStatus.Succeed)); __result.ContinueWith(_ => { InPatch = false; }); diff --git a/TaskSerializer.cs b/TaskSerializer.cs index 6ac4aa1..8a3499f 100644 --- a/TaskSerializer.cs +++ b/TaskSerializer.cs @@ -8,14 +8,16 @@ namespace UIFixes public class TaskSerializer : MonoBehaviour { private Func func; + private Func canContinue; private IEnumerator enumerator; private Task currentTask; private TaskCompletionSource totalTask; - public Task Initialize(IEnumerable items, Func func) + public Task Initialize(IEnumerable items, Func func, Func canContinue = null) { this.enumerator = items.GetEnumerator(); this.func = func; + this.canContinue = canContinue; currentTask = Task.CompletedTask; totalTask = new TaskCompletionSource(); @@ -52,6 +54,11 @@ namespace UIFixes return; } + if (canContinue != null && enumerator.Current != null && !canContinue(enumerator.Current)) + { + return; + } + if (enumerator.MoveNext()) { currentTask = func(enumerator.Current);