multiselect + sort table polish, sort table keybinds

This commit is contained in:
Tyfon
2024-07-22 13:54:45 -07:00
parent 41699a422f
commit 0a656a2c4b
7 changed files with 190 additions and 54 deletions

View File

@@ -1,11 +1,11 @@
using EFT.InventoryLogic;
using Comfort.Common;
using EFT.InventoryLogic;
using EFT.UI;
using EFT.UI.DragAndDrop;
using HarmonyLib;
using SPT.Reflection.Patching;
using System.Reflection;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
namespace UIFixes;
@@ -98,6 +98,11 @@ public static class ContextMenuShortcutPatches
TryInteraction(__instance, itemContext, EItemInfoButton.LinkedSearch);
}
if (Settings.SortingTableKeyBind.Value.IsDown())
{
MoveToFromSortingTable(itemContext, __instance);
}
Interactions = null;
}
@@ -109,6 +114,36 @@ public static class ContextMenuShortcutPatches
Interactions.ExecuteInteraction(fallbackInteraction.Value);
}
}
private static void MoveToFromSortingTable(ItemContextAbstractClass itemContext, ItemUiContext itemUiContext)
{
Item item = itemContext.Item;
if (item.Owner is not InventoryControllerClass controller)
{
return;
}
SortingTableClass sortingTable = controller.Inventory.SortingTable;
bool isInSortingTable = sortingTable != null && item.Parent.Container.ParentItem == sortingTable;
var operation = isInSortingTable ? itemUiContext.QuickFindAppropriatePlace(itemContext, controller, false, true, true) : itemUiContext.QuickMoveToSortingTable(item, true);
if (operation.Succeeded && controller.CanExecute(operation.Value))
{
if (operation.Value is IDestroyResult destroyResult && destroyResult.ItemsDestroyRequired)
{
NotificationManagerClass.DisplayWarningNotification(new DestroyError(item, destroyResult.ItemsToDestroy).GetLocalizedDescription());
return;
}
controller.RunNetworkTransaction(operation.Value, null);
if (itemUiContext.Tooltip != null)
{
itemUiContext.Tooltip.Close();
}
Singleton<GUISounds>.Instance.PlayItemSound(item.ItemSound, EInventorySoundType.pickup, false);
}
}
}
// HideoutItemViews don't register themselves with ItemUiContext for some reason