Open sorting table automatically

This commit is contained in:
Tyfon
2024-06-10 00:43:05 -07:00
parent ae765c2c7b
commit 8882369b34
2 changed files with 36 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
using Aki.Reflection.Patching;
using Comfort.Common;
using EFT.UI;
using HarmonyLib;
using System.Linq;
using System.Reflection;
namespace UIFixes
{
public class OpenSortingTablePatch : ModulePatch
{
private static readonly EItemUiContextType[] AllowedScreens = [EItemUiContextType.InventoryScreen, EItemUiContextType.ScavengerInventoryScreen];
protected override MethodBase GetTargetMethod()
{
return AccessTools.Method(typeof(ItemUiContext), nameof(ItemUiContext.QuickMoveToSortingTable));
}
[PatchPrefix]
public static void Prefix(ItemUiContext __instance)
{
if (!AllowedScreens.Contains(__instance.ContextType) || Plugin.InRaid())
{
return;
}
SortingTableClass sortingTable = __instance.R().InventoryController.Inventory.SortingTable;
if (sortingTable != null && !sortingTable.IsVisible)
{
Singleton<CommonUI>.Instance.InventoryScreen.method_6();
}
}
}
}

View File

@@ -47,6 +47,7 @@ namespace UIFixes
new LoadMagPresetsPatch().Enable();
KeepWindowsOnScreenPatches.Enable();
new ContextMenuShortcutPatch().Enable();
new OpenSortingTablePatch().Enable();
}
public static bool InRaid()