Fix add offer window

This commit is contained in:
Tyfon
2024-07-07 16:29:35 -07:00
parent 1ed8b9d7f4
commit 9530cb9f18

View File

@@ -59,8 +59,11 @@ namespace UIFixes
[PatchPrefix]
public static void Prefix(AddOfferWindow __instance, TaskCompletionSource ___taskCompletionSource_0, ref TaskCompletionSource __state)
{
if (Settings.KeepAddOfferOpen.Value)
if (!Settings.KeepAddOfferOpen.Value)
{
return;
}
__state = ___taskCompletionSource_0;
// Close the window if you're gonna hit max offers
@@ -70,13 +73,19 @@ namespace UIFixes
BlockClose = true;
}
}
}
[PatchPostfix]
public static void Postfix(RequirementView[] ____requirementViews, TaskCompletionSource ___taskCompletionSource_0, ref TaskCompletionSource __state)
{
bool isAddingOffer = __state != ___taskCompletionSource_0; // If the taskCompletionSource member was changed, then it's adding an offer :S
if (Settings.KeepAddOfferOpen.Value && isAddingOffer)
BlockClose = false;
if (!Settings.KeepAddOfferOpen.Value)
{
return;
}
// If the taskCompletionSource member was changed, then it's adding an offer :S
if (__state != ___taskCompletionSource_0)
{
AddOfferTasks.Add(__state.Task); // This is the task completion source passed into the add offer call
@@ -86,8 +95,6 @@ namespace UIFixes
requirementView.ResetRequirementInformation();
}
}
BlockClose = false;
}
}
@@ -101,7 +108,12 @@ namespace UIFixes
[PatchPrefix]
public static bool Prefix()
{
if (!BlockClose && AddOfferTasks.All(t => t.IsCompleted))
if (!Settings.KeepAddOfferOpen.Value)
{
return true;
}
if (!BlockClose && CompletionSource != null && AddOfferTasks.All(t => t.IsCompleted))
{
CompletionSource.Complete();
CompletionSource = null;