block partial merges, keep ammo from merging on gridview accept
This commit is contained in:
@@ -61,7 +61,7 @@ namespace UIFixes
|
|||||||
|
|
||||||
if (itemView.IsSelectable() && !SelectedItemViews.ContainsKey(itemView) && !SecondaryItemViews.ContainsKey(itemView))
|
if (itemView.IsSelectable() && !SelectedItemViews.ContainsKey(itemView) && !SecondaryItemViews.ContainsKey(itemView))
|
||||||
{
|
{
|
||||||
ItemContextClass itemContext = new(itemView.ItemContext, itemView.ItemRotation);
|
ItemContextClass itemContext = new MultiSelectItemContext(itemView.ItemContext, itemView.ItemRotation);
|
||||||
itemContext.GClass2813_0.OnDisposed += RugPull;
|
itemContext.GClass2813_0.OnDisposed += RugPull;
|
||||||
itemContext.OnDisposed += RugPull;
|
itemContext.OnDisposed += RugPull;
|
||||||
|
|
||||||
@@ -194,6 +194,12 @@ namespace UIFixes
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class MultiSelectItemContext(ItemContextAbstractClass itemContext, ItemRotation rotation) : ItemContextClass(itemContext, rotation)
|
||||||
|
{
|
||||||
|
public override bool MergeAvailable => false;
|
||||||
|
public override bool SplitAvailable => false;
|
||||||
|
}
|
||||||
|
|
||||||
public static class MultiSelectExtensions
|
public static class MultiSelectExtensions
|
||||||
{
|
{
|
||||||
public static bool IsSelectable(this ItemView itemView)
|
public static bool IsSelectable(this ItemView itemView)
|
||||||
|
|||||||
@@ -24,8 +24,11 @@ namespace UIFixes
|
|||||||
private static readonly List<Image> Previews = [];
|
private static readonly List<Image> Previews = [];
|
||||||
|
|
||||||
// Point that various QuickFindPlace overrides should start at
|
// Point that various QuickFindPlace overrides should start at
|
||||||
public static GClass2769 FindOrigin = null;
|
private static GClass2769 FindOrigin = null;
|
||||||
public static bool FindVerticalFirst = false;
|
private static bool FindVerticalFirst = false;
|
||||||
|
|
||||||
|
// Prevents QuickFind from attempting a merge
|
||||||
|
private static bool DisableMerge = false;
|
||||||
|
|
||||||
public static void Enable()
|
public static void Enable()
|
||||||
{
|
{
|
||||||
@@ -58,6 +61,7 @@ namespace UIFixes
|
|||||||
new FindSpotKeepRotationPatch().Enable();
|
new FindSpotKeepRotationPatch().Enable();
|
||||||
new FindLocationForItemPatch().Enable();
|
new FindLocationForItemPatch().Enable();
|
||||||
new FindPlaceToPutPatch().Enable();
|
new FindPlaceToPutPatch().Enable();
|
||||||
|
new AdjustQuickFindFlagsPatch().Enable();
|
||||||
}
|
}
|
||||||
|
|
||||||
public class InitializeCommonUIPatch : ModulePatch
|
public class InitializeCommonUIPatch : ModulePatch
|
||||||
@@ -259,6 +263,8 @@ namespace UIFixes
|
|||||||
operation = default;
|
operation = default;
|
||||||
__result = false;
|
__result = false;
|
||||||
|
|
||||||
|
HidePreviews();
|
||||||
|
|
||||||
if (__instance.Grid == null || wrappedInstance.NonInteractable)
|
if (__instance.Grid == null || wrappedInstance.NonInteractable)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@@ -289,8 +295,8 @@ namespace UIFixes
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
HidePreviews();
|
|
||||||
Item targetItem = __instance.method_8(targetItemContext);
|
Item targetItem = __instance.method_8(targetItemContext);
|
||||||
|
DisableMerge = targetItem == null;
|
||||||
bool showHighlights = targetItem == null;
|
bool showHighlights = targetItem == null;
|
||||||
|
|
||||||
Stack<GStruct413> operations = new();
|
Stack<GStruct413> operations = new();
|
||||||
@@ -329,6 +335,8 @@ namespace UIFixes
|
|||||||
targetItem ??= __instance.Grid.ParentItem;
|
targetItem ??= __instance.Grid.ParentItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DisableMerge = false;
|
||||||
|
|
||||||
if (!__result)
|
if (!__result)
|
||||||
{
|
{
|
||||||
HidePreviews();
|
HidePreviews();
|
||||||
@@ -376,6 +384,7 @@ namespace UIFixes
|
|||||||
}
|
}
|
||||||
|
|
||||||
InPatch = true;
|
InPatch = true;
|
||||||
|
DisableMerge = targetItemContext == null;
|
||||||
|
|
||||||
LocationInGrid hoveredLocation = __instance.CalculateItemLocation(itemContext);
|
LocationInGrid hoveredLocation = __instance.CalculateItemLocation(itemContext);
|
||||||
GClass2769 hoveredAddress = new(__instance.Grid, hoveredLocation);
|
GClass2769 hoveredAddress = new(__instance.Grid, hoveredLocation);
|
||||||
@@ -396,6 +405,7 @@ namespace UIFixes
|
|||||||
InPatch = false;
|
InPatch = false;
|
||||||
FindOrigin = null;
|
FindOrigin = null;
|
||||||
FindVerticalFirst = false;
|
FindVerticalFirst = false;
|
||||||
|
DisableMerge = false;
|
||||||
GridViewPickTargetPatch.FallbackResult = null;
|
GridViewPickTargetPatch.FallbackResult = null;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -403,6 +413,35 @@ namespace UIFixes
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class AdjustQuickFindFlagsPatch : ModulePatch
|
||||||
|
{
|
||||||
|
// For reasons (???), BSG doesn't even define the second bit of this flags enum
|
||||||
|
private static InteractionsHandlerClass.EMoveItemOrder PartialMerge = (InteractionsHandlerClass.EMoveItemOrder)2;
|
||||||
|
|
||||||
|
protected override MethodBase GetTargetMethod()
|
||||||
|
{
|
||||||
|
return AccessTools.Method(typeof(InteractionsHandlerClass), nameof(InteractionsHandlerClass.QuickFindAppropriatePlace));
|
||||||
|
}
|
||||||
|
|
||||||
|
[PatchPrefix]
|
||||||
|
public static void Prefix(ref InteractionsHandlerClass.EMoveItemOrder order)
|
||||||
|
{
|
||||||
|
if (!MultiSelect.Active)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Multiselect always disables "Transfer", which is a partial merge
|
||||||
|
// It leaves things behind and that's not intuitive when multi-selecting
|
||||||
|
order &= ~PartialMerge;
|
||||||
|
|
||||||
|
if (DisableMerge)
|
||||||
|
{
|
||||||
|
order &= ~InteractionsHandlerClass.EMoveItemOrder.TryMerge;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class SelectMovedItemViewPatch : ModulePatch
|
public class SelectMovedItemViewPatch : ModulePatch
|
||||||
{
|
{
|
||||||
protected override MethodBase GetTargetMethod()
|
protected override MethodBase GetTargetMethod()
|
||||||
@@ -525,9 +564,14 @@ namespace UIFixes
|
|||||||
private static IEnumerable<ItemContextClass> SortSelectedContexts(
|
private static IEnumerable<ItemContextClass> SortSelectedContexts(
|
||||||
IEnumerable<ItemContextClass> selectedContexts, ItemContextClass itemContext, bool prepend = true)
|
IEnumerable<ItemContextClass> selectedContexts, ItemContextClass itemContext, bool prepend = true)
|
||||||
{
|
{
|
||||||
|
static int gridOrder(LocationInGrid loc, StashGridClass grid) => grid.GridWidth.Value * loc.y + loc.x;
|
||||||
|
|
||||||
var result = selectedContexts
|
var result = selectedContexts
|
||||||
.Where(ic => ic.Item != itemContext.Item)
|
.Where(ic => ic.Item != itemContext.Item)
|
||||||
.OrderByDescending(ic => itemContext.ItemAddress is GClass2769 originalDraggedAddress && ic.ItemAddress is GClass2769 selectedGridAddress && selectedGridAddress.Grid == originalDraggedAddress.Grid);
|
.OrderByDescending(ic => ic.ItemAddress is GClass2769)
|
||||||
|
.ThenByDescending(ic => itemContext.ItemAddress is GClass2769 originalDraggedAddress && ic.ItemAddress is GClass2769 selectedGridAddress && selectedGridAddress.Grid == originalDraggedAddress.Grid)
|
||||||
|
.ThenByDescending(ic => ic.ItemAddress is GClass2769 selectedGridAddress ? selectedGridAddress.Grid : null)
|
||||||
|
.ThenBy(ic => ic.ItemAddress is GClass2769 selectedGridAddress ? gridOrder(selectedGridAddress.LocationInGrid, selectedGridAddress.Grid) : 0);
|
||||||
|
|
||||||
return prepend ? result.Prepend(itemContext) : result;
|
return prepend ? result.Prepend(itemContext) : result;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user