unpack all; lateupdate taskserializer; create inner context as necessary
This commit is contained in:
@@ -237,14 +237,30 @@ namespace UIFixes
|
|||||||
|
|
||||||
private static bool InteractionAvailable(ItemContextClass itemContext, EItemInfoButton interaction, ItemUiContext itemUiContext)
|
private static bool InteractionAvailable(ItemContextClass itemContext, EItemInfoButton interaction, ItemUiContext itemUiContext)
|
||||||
{
|
{
|
||||||
|
// Since itemContext is for "drag", no context actions are allowed. Get the underlying "inventory" context
|
||||||
ItemContextAbstractClass innerContext = itemContext.GClass2813_0;
|
ItemContextAbstractClass innerContext = itemContext.GClass2813_0;
|
||||||
if (innerContext == null)
|
if (innerContext == null)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool createdContext = false;
|
||||||
|
if (innerContext.Item != itemContext.Item)
|
||||||
|
{
|
||||||
|
// Actual context went away and we're looking at inventory/stash context
|
||||||
|
innerContext = innerContext.CreateChild(itemContext.Item);
|
||||||
|
createdContext = true;
|
||||||
|
}
|
||||||
|
|
||||||
var contextInteractions = itemUiContext.GetItemContextInteractions(innerContext, null);
|
var contextInteractions = itemUiContext.GetItemContextInteractions(innerContext, null);
|
||||||
return contextInteractions.IsInteractionAvailable(interaction);
|
bool result = contextInteractions.IsInteractionAvailable(interaction);
|
||||||
|
|
||||||
|
if (createdContext)
|
||||||
|
{
|
||||||
|
innerContext.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void EquipAll(ItemUiContext itemUiContext, bool allOrNothing)
|
public static void EquipAll(ItemUiContext itemUiContext, bool allOrNothing)
|
||||||
@@ -298,6 +314,19 @@ namespace UIFixes
|
|||||||
UnloadSerializer = null;
|
UnloadSerializer = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void UnpackAll(ItemUiContext itemUiContext, bool allOrNothing)
|
||||||
|
{
|
||||||
|
if (!allOrNothing || InteractionCount(EItemInfoButton.Unpack, itemUiContext) == Count)
|
||||||
|
{
|
||||||
|
var taskSerializer = itemUiContext.gameObject.AddComponent<ItemContextTaskSerializer>();
|
||||||
|
taskSerializer.Initialize(
|
||||||
|
SortedItemContexts().Where(ic => InteractionAvailable(ic, EItemInfoButton.Unpack, itemUiContext)),
|
||||||
|
itemContext => itemUiContext.UnpackItem(itemContext.Item));
|
||||||
|
|
||||||
|
itemUiContext.Tooltip?.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static void ShowSelection(GridItemView itemView)
|
private static void ShowSelection(GridItemView itemView)
|
||||||
{
|
{
|
||||||
GameObject selectedMark = itemView.transform.Find("SelectedMark")?.gameObject;
|
GameObject selectedMark = itemView.transform.Find("SelectedMark")?.gameObject;
|
||||||
|
|||||||
@@ -129,6 +129,15 @@ namespace UIFixes
|
|||||||
____text.text += " (x" + count + ")";
|
____text.text += " (x" + count + ")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (caption == EItemInfoButton.Unpack.ToString())
|
||||||
|
{
|
||||||
|
int count = MultiSelect.InteractionCount(EItemInfoButton.Unpack, ItemUiContext.Instance);
|
||||||
|
if (count > 0)
|
||||||
|
{
|
||||||
|
____text.text += " (x" + count + ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -314,6 +314,9 @@ namespace UIFixes
|
|||||||
case EItemInfoButton.UnloadAmmo:
|
case EItemInfoButton.UnloadAmmo:
|
||||||
MultiSelect.UnloadAmmoAll(___itemUiContext_1, false);
|
MultiSelect.UnloadAmmoAll(___itemUiContext_1, false);
|
||||||
return false;
|
return false;
|
||||||
|
case EItemInfoButton.Unpack:
|
||||||
|
MultiSelect.UnpackAll(___itemUiContext_1, false);
|
||||||
|
return false;
|
||||||
default:
|
default:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
@@ -21,7 +20,7 @@ namespace UIFixes
|
|||||||
currentTask = Task.CompletedTask;
|
currentTask = Task.CompletedTask;
|
||||||
totalTask = new TaskCompletionSource();
|
totalTask = new TaskCompletionSource();
|
||||||
|
|
||||||
Update();
|
LateUpdate();
|
||||||
|
|
||||||
return totalTask.Task;
|
return totalTask.Task;
|
||||||
}
|
}
|
||||||
@@ -29,9 +28,10 @@ namespace UIFixes
|
|||||||
public void Cancel()
|
public void Cancel()
|
||||||
{
|
{
|
||||||
totalTask.TrySetCanceled();
|
totalTask.TrySetCanceled();
|
||||||
|
Complete();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Update()
|
public void LateUpdate()
|
||||||
{
|
{
|
||||||
if (currentTask.IsCanceled)
|
if (currentTask.IsCanceled)
|
||||||
{
|
{
|
||||||
@@ -56,7 +56,7 @@ namespace UIFixes
|
|||||||
|
|
||||||
private void Complete()
|
private void Complete()
|
||||||
{
|
{
|
||||||
totalTask.Complete();
|
totalTask.TryComplete();
|
||||||
func = null;
|
func = null;
|
||||||
Destroy(this);
|
Destroy(this);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user