deselect items that go into mags, allow partial moves when all items are the same and stackable
This commit is contained in:
@@ -213,25 +213,19 @@ namespace UIFixes
|
||||
|
||||
public static int InteractionCount(EItemInfoButton interaction, ItemUiContext itemUiContext)
|
||||
{
|
||||
int count = 0;
|
||||
foreach (ItemContextClass selectedItemContext in SortedItemContexts())
|
||||
return ItemContexts.Count(ic => InteractionAvailable(ic, interaction, itemUiContext));
|
||||
}
|
||||
|
||||
private static bool InteractionAvailable(ItemContextClass itemContext, EItemInfoButton interaction, ItemUiContext itemUiContext)
|
||||
{
|
||||
ItemContextAbstractClass innerContext = selectedItemContext.GClass2813_0;
|
||||
ItemContextAbstractClass innerContext = itemContext.GClass2813_0;
|
||||
if (innerContext == null)
|
||||
{
|
||||
continue;
|
||||
return false;
|
||||
}
|
||||
|
||||
var contextInteractions = itemUiContext.GetItemContextInteractions(innerContext, null);
|
||||
if (!contextInteractions.IsInteractionAvailable(interaction))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
++count;
|
||||
}
|
||||
|
||||
return count;
|
||||
return contextInteractions.IsInteractionAvailable(interaction);
|
||||
}
|
||||
|
||||
public static void EquipAll(ItemUiContext itemUiContext, bool allOrNothing)
|
||||
@@ -239,7 +233,9 @@ namespace UIFixes
|
||||
if (!allOrNothing || InteractionCount(EItemInfoButton.Equip, itemUiContext) == Count)
|
||||
{
|
||||
var taskSerializer = itemUiContext.gameObject.AddComponent<ItemContextTaskSerializer>();
|
||||
taskSerializer.Initialize(SortedItemContexts(), itemContext => itemUiContext.QuickEquip(itemContext.Item));
|
||||
taskSerializer.Initialize(
|
||||
SortedItemContexts().Where(ic => InteractionAvailable(ic, EItemInfoButton.Equip, itemUiContext)),
|
||||
itemContext => itemUiContext.QuickEquip(itemContext.Item));
|
||||
itemUiContext.Tooltip?.Close();
|
||||
}
|
||||
}
|
||||
@@ -249,7 +245,9 @@ namespace UIFixes
|
||||
if (!allOrNothing || InteractionCount(EItemInfoButton.Unequip, itemUiContext) == Count)
|
||||
{
|
||||
var taskSerializer = itemUiContext.gameObject.AddComponent<ItemContextTaskSerializer>();
|
||||
taskSerializer.Initialize(SortedItemContexts(), itemContext => itemUiContext.Uninstall(itemContext.GClass2813_0));
|
||||
taskSerializer.Initialize(
|
||||
SortedItemContexts().Where(ic => InteractionAvailable(ic, EItemInfoButton.Unequip, itemUiContext)),
|
||||
itemContext => itemUiContext.Uninstall(itemContext.GClass2813_0));
|
||||
itemUiContext.Tooltip?.Close();
|
||||
}
|
||||
}
|
||||
@@ -261,7 +259,9 @@ namespace UIFixes
|
||||
{
|
||||
// Call Initialize() before setting UnloadSerializer so that the initial synchronous call to StopProcesses()->StopUnloading() doesn't immediately cancel this
|
||||
var taskSerializer = itemUiContext.gameObject.AddComponent<ItemContextTaskSerializer>();
|
||||
taskSerializer.Initialize(SortedItemContexts(), itemContext => itemUiContext.UnloadAmmo(itemContext.Item));
|
||||
taskSerializer.Initialize(
|
||||
SortedItemContexts().Where(ic => InteractionAvailable(ic, EItemInfoButton.UnloadAmmo, itemUiContext)),
|
||||
itemContext => itemUiContext.UnloadAmmo(itemContext.Item));
|
||||
|
||||
UnloadSerializer = taskSerializer;
|
||||
itemUiContext.Tooltip?.Close();
|
||||
@@ -341,9 +341,9 @@ namespace UIFixes
|
||||
|
||||
private void OnParentDispose()
|
||||
{
|
||||
if (Item.CurrentAddress == null)
|
||||
if (Item.CurrentAddress == null || Item.CurrentAddress.Container.ParentItem is MagazineClass)
|
||||
{
|
||||
// This item is gone!
|
||||
// This item was entirely merged away, or went into a magazine
|
||||
MultiSelect.Deselect(this);
|
||||
}
|
||||
}
|
||||
|
@@ -19,7 +19,7 @@ namespace UIFixes
|
||||
public static void Postfix(GridWindow __instance)
|
||||
{
|
||||
var wrappedInstance = __instance.R();
|
||||
if (Settings.AddContainerButtons.Value && wrappedInstance.LootItem.Int32_0 > 2) // Greater than 2 cells wide
|
||||
if (Settings.AddContainerButtons.Value && wrappedInstance.LootItem.Int32_0 > 3) // Greater than 3 cells wide
|
||||
{
|
||||
Transform closeButton = __instance.transform.Find("Caption Panel/Close Button");
|
||||
Image sortBackground = __instance.transform.Find("Caption Panel/Sort Button")?.GetComponent<Image>();
|
||||
|
@@ -478,6 +478,9 @@ namespace UIFixes
|
||||
DisableMerge = targetItem == null;
|
||||
bool isGridPlacement = targetItem == null;
|
||||
|
||||
// If everything selected is the same type and is a stackable type, allow partial success
|
||||
bool allowPartialSuccess = targetItem != null && itemContext.Item is GClass2735 && MultiSelect.ItemContexts.All(ic => ic.Item.TemplateId == itemContext.Item.TemplateId);
|
||||
|
||||
Stack<GStruct413> operations = new();
|
||||
foreach (ItemContextClass selectedItemContext in MultiSelect.SortedItemContexts(itemContext))
|
||||
{
|
||||
@@ -583,6 +586,11 @@ namespace UIFixes
|
||||
|
||||
DisableMerge = false;
|
||||
|
||||
if (allowPartialSuccess && operations.Any())
|
||||
{
|
||||
__result = true;
|
||||
}
|
||||
|
||||
if (!__result)
|
||||
{
|
||||
HidePreviews();
|
||||
|
Reference in New Issue
Block a user