Fix add offer window
This commit is contained in:
@@ -59,8 +59,11 @@ namespace UIFixes
|
|||||||
[PatchPrefix]
|
[PatchPrefix]
|
||||||
public static void Prefix(AddOfferWindow __instance, TaskCompletionSource ___taskCompletionSource_0, ref TaskCompletionSource __state)
|
public static void Prefix(AddOfferWindow __instance, TaskCompletionSource ___taskCompletionSource_0, ref TaskCompletionSource __state)
|
||||||
{
|
{
|
||||||
if (Settings.KeepAddOfferOpen.Value)
|
if (!Settings.KeepAddOfferOpen.Value)
|
||||||
{
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
__state = ___taskCompletionSource_0;
|
__state = ___taskCompletionSource_0;
|
||||||
|
|
||||||
// Close the window if you're gonna hit max offers
|
// Close the window if you're gonna hit max offers
|
||||||
@@ -70,13 +73,19 @@ namespace UIFixes
|
|||||||
BlockClose = true;
|
BlockClose = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[PatchPostfix]
|
[PatchPostfix]
|
||||||
public static void Postfix(RequirementView[] ____requirementViews, TaskCompletionSource ___taskCompletionSource_0, ref TaskCompletionSource __state)
|
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
|
BlockClose = false;
|
||||||
if (Settings.KeepAddOfferOpen.Value && isAddingOffer)
|
|
||||||
|
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
|
AddOfferTasks.Add(__state.Task); // This is the task completion source passed into the add offer call
|
||||||
|
|
||||||
@@ -86,8 +95,6 @@ namespace UIFixes
|
|||||||
requirementView.ResetRequirementInformation();
|
requirementView.ResetRequirementInformation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockClose = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,7 +108,12 @@ namespace UIFixes
|
|||||||
[PatchPrefix]
|
[PatchPrefix]
|
||||||
public static bool Prefix()
|
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.Complete();
|
||||||
CompletionSource = null;
|
CompletionSource = null;
|
||||||
|
Reference in New Issue
Block a user