TaskSerializer handle being disabled/deactivated mid-operation

This commit is contained in:
Tyfon
2024-07-02 00:45:58 -07:00
parent 214062b1f2
commit 799fc6fa94
3 changed files with 10 additions and 5 deletions

View File

@@ -33,7 +33,6 @@ namespace UIFixes
// Grab the selection objects from ragfair as templates
RagfairNewOfferItemView ragfairNewOfferItemView = ItemViewFactory.CreateFromPool<RagfairNewOfferItemView>("ragfair_layout");
if (SelectedMarkTemplate == null)
{
SelectedMarkTemplate = UnityEngine.Object.Instantiate(ragfairNewOfferItemView.R().SelectedMark, null, false);
@@ -271,6 +270,7 @@ namespace UIFixes
taskSerializer.Initialize(
SortedItemContexts().Where(ic => InteractionAvailable(ic, EItemInfoButton.Equip, itemUiContext)),
itemContext => itemUiContext.QuickEquip(itemContext.Item));
itemUiContext.Tooltip?.Close();
}
}
@@ -283,6 +283,7 @@ namespace UIFixes
taskSerializer.Initialize(
SortedItemContexts().Where(ic => InteractionAvailable(ic, EItemInfoButton.Unequip, itemUiContext)),
itemContext => itemUiContext.Uninstall(itemContext.GClass2813_0));
itemUiContext.Tooltip?.Close();
}
}

View File

@@ -1,7 +1,6 @@
using Aki.Reflection.Patching;
using EFT.UI.DragAndDrop;
using HarmonyLib;
using System.Collections.Generic;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
@@ -75,9 +74,9 @@ namespace UIFixes
// This won't block the first action from swapping, but will prevent follow up swaps
SwapPatches.BlockSwaps = true;
__result.ContinueWith(_ =>
{
InPatch = false;
__result.ContinueWith(_ =>
{
InPatch = false;
SwapPatches.BlockSwaps = false;
});

View File

@@ -31,6 +31,11 @@ namespace UIFixes
Complete();
}
public void OnDisable()
{
Cancel();
}
public void LateUpdate()
{
if (currentTask.IsCanceled)