advanced setting for shift-click multiselect; handle no-op moves better

This commit is contained in:
Tyfon
2024-07-01 02:08:07 -07:00
parent 7fc6ce0798
commit a3ae04b32a
2 changed files with 44 additions and 17 deletions

View File

@@ -24,6 +24,7 @@ using GridFindExtensions = GClass2503;
using BaseItemInfoInteractions = GClass3021;
using GenericItemContext = GClass2817;
using Stackable = GClass2735;
using NoOpMove = GClass2779;
using DestroyError = GClass3320;
using NoRoomError = GClass3292;
using GridModificationsUnavailableError = StashGridClass.GClass3291;
@@ -47,6 +48,8 @@ namespace UIFixes
private static bool DisableMerge = false;
private static bool IgnoreItemParent = false;
private static readonly Color ValidMoveColor = new(0.06f, 0.38f, 0.06f, 0.57f);
public static void Enable()
{
// Initialization
@@ -168,7 +171,7 @@ namespace UIFixes
bool shiftDown = Input.GetKey(KeyCode.LeftShift) && !Input.GetKey(KeyCode.RightShift);
bool altDown = Input.GetKey(KeyCode.LeftAlt) && !Input.GetKey(KeyCode.RightAlt);
if (__instance is GridItemView gridItemView && eventData.button == PointerEventData.InputButton.Left && shiftDown && !ctrlDown && !altDown)
if (Settings.EnableMultiClick.Value && __instance is GridItemView gridItemView && eventData.button == PointerEventData.InputButton.Left && shiftDown && !ctrlDown && !altDown)
{
MultiSelect.Toggle(gridItemView);
return;
@@ -561,6 +564,12 @@ namespace UIFixes
FindOrigin = null;
FindVerticalFirst = false;
// Moving item to the same place, not a problem. Use a no-op move
if (operation.Error is MoveSameSpaceError)
{
operation = new(new NoOpMove());
}
if (__result = operation.Succeeded)
{
operations.Push(operation);
@@ -569,16 +578,6 @@ namespace UIFixes
ShowPreview(__instance, selectedItemContext, operation);
}
}
else if (operation.Error is MoveSameSpaceError)
{
// Moving item to the same place, cool, not a problem
__result = true;
operation = default;
if (isGridPlacement && selectedItemContext.Item.Parent is GridItemAddress gridAddress)
{
ShowPreview(__instance, selectedItemContext, gridAddress, R.GridView.ValidMoveColor);
}
}
else
{
if (operation.Error is NoRoomError noRoomError)
@@ -1266,7 +1265,16 @@ namespace UIFixes
private static void ShowPreview(GridView gridView, ItemContextClass itemContext, ItemOperation operation)
{
if (operation.Value is not MoveOperation moveOperation || moveOperation.To is not GridItemAddress gridAddress)
GridItemAddress gridAddress = null;
if (operation.Value is MoveOperation moveOperation)
{
gridAddress = moveOperation.To as GridItemAddress;
}
else if (operation.Value is NoOpMove noopMove)
{
gridAddress = itemContext.ItemAddress as GridItemAddress;
}
else
{
return;
}
@@ -1282,7 +1290,7 @@ namespace UIFixes
return;
}
Color backgroundColor = gridView.GetHighlightColor(itemContext, operation, null);
Color backgroundColor = operation.Value is NoOpMove ? ValidMoveColor : gridView.GetHighlightColor(itemContext, operation, null);
ShowPreview(gridView, itemContext, gridAddress, backgroundColor);
}

View File

@@ -67,7 +67,8 @@ namespace UIFixes
// Inventory
public static ConfigEntry<bool> EnableMultiSelect { get; set; }
public static ConfigEntry<bool> EnableMultiSelectInRaid { get; set; }
public static ConfigEntry<bool> EnableMultiSelectInRaid { get; set; } // Advanced
public static ConfigEntry<bool> EnableMultiClick { get; set; } // Advanced
public static ConfigEntry<KeyboardShortcut> SelectionBoxKey { get; set; }
public static ConfigEntry<MultiSelectStrategy> MultiSelectStrat { get; set; }
public static ConfigEntry<bool> ShowMultiSelectDebug { get; set; } // Advanced
@@ -317,6 +318,15 @@ namespace UIFixes
null,
new ConfigurationManagerAttributes { IsAdvanced = true })));
configEntries.Add(EnableMultiClick = config.Bind(
InventorySection,
"Enable Multiselect with Shift-Click",
true,
new ConfigDescription(
"Add items to the selection by shift-clicking them. If you disable this, the only way to multiselect is with the selection box",
null,
new ConfigurationManagerAttributes { IsAdvanced = true })));
configEntries.Add(SelectionBoxKey = config.Bind(
InventorySection,
"Selection Box Key",
@@ -574,10 +584,12 @@ namespace UIFixes
RecalcOrder(configEntries);
MakeExclusive(EnableMultiSelect, AutoOpenSortingTable);
MakeDependent(EnableMultiSelect, EnableMultiSelectInRaid);
MakeDependent(EnableMultiSelect, ShowMultiSelectDebug, false);
MakeDependent(EnableMultiSelect, EnableMultiClick);
MakeExclusive(EnableMultiClick, AutoOpenSortingTable, false);
}
private static void RecalcOrder(List<ConfigEntryBase> configEntries)
@@ -595,7 +607,7 @@ namespace UIFixes
}
}
private static void MakeExclusive(ConfigEntry<bool> priorityConfig, ConfigEntry<bool> secondaryConfig)
private static void MakeExclusive(ConfigEntry<bool> priorityConfig, ConfigEntry<bool> secondaryConfig, bool allowSecondaryToDisablePrimary = true)
{
if (priorityConfig.Value)
{
@@ -614,7 +626,14 @@ namespace UIFixes
{
if (secondaryConfig.Value)
{
priorityConfig.Value = false;
if (allowSecondaryToDisablePrimary)
{
priorityConfig.Value = false;
}
else if (priorityConfig.Value)
{
secondaryConfig.Value = false;
}
}
};
}