Add context menu keybinds
This commit is contained in:
@@ -48,21 +48,21 @@ namespace UIFixes
|
||||
{
|
||||
protected override MethodBase GetTargetMethod()
|
||||
{
|
||||
return AccessTools.Method(typeof(ItemUiContext), nameof(ItemUiContext.TranslateCommand));
|
||||
return AccessTools.Method(typeof(ItemUiContext), nameof(ItemUiContext.Update));
|
||||
}
|
||||
|
||||
[PatchPrefix]
|
||||
public static bool Prefix(ECommand command, ref InputNode.ETranslateResult __result, SplitDialog ___splitDialog_0)
|
||||
[PatchPostfix]
|
||||
public static void Postfix(SplitDialog ___splitDialog_0)
|
||||
{
|
||||
// It's wild to me that they implement UI keyboard shortcuts via the in-raid movement keybinds
|
||||
if (___splitDialog_0 != null && ___splitDialog_0.gameObject.activeSelf && command == ECommand.Jump)
|
||||
if (___splitDialog_0 == null || !___splitDialog_0.gameObject.activeSelf)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.Space))
|
||||
{
|
||||
___splitDialog_0.Accept();
|
||||
__result = InputNode.ETranslateResult.Block;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
56
Patches/ContextMenuShortcutPatch.cs
Normal file
56
Patches/ContextMenuShortcutPatch.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using Aki.Reflection.Patching;
|
||||
using EFT.InventoryLogic;
|
||||
using EFT.UI;
|
||||
using HarmonyLib;
|
||||
using System.Reflection;
|
||||
|
||||
namespace UIFixes
|
||||
{
|
||||
public class ContextMenuShortcutPatch : ModulePatch
|
||||
{
|
||||
protected override MethodBase GetTargetMethod()
|
||||
{
|
||||
return AccessTools.Method(typeof(ItemUiContext), nameof(ItemUiContext.Update));
|
||||
}
|
||||
|
||||
[PatchPostfix]
|
||||
public static void Postfix(ItemUiContext __instance)
|
||||
{
|
||||
ItemContextAbstractClass itemContext = __instance.R().ItemContext;
|
||||
if (itemContext == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (Settings.InspectKeyBind.Value.IsDown())
|
||||
{
|
||||
__instance.GetItemContextInteractions(itemContext, null).ExecuteInteraction(EItemInfoButton.Inspect);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Settings.OpenKeyBind.Value.IsDown())
|
||||
{
|
||||
__instance.GetItemContextInteractions(itemContext, null).ExecuteInteraction(EItemInfoButton.Open);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Settings.TopUpKeyBind.Value.IsDown())
|
||||
{
|
||||
__instance.GetItemContextInteractions(itemContext, null).ExecuteInteraction(EItemInfoButton.TopUp);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Settings.FilterByKeyBind.Value.IsDown())
|
||||
{
|
||||
__instance.GetItemContextInteractions(itemContext, null).ExecuteInteraction(EItemInfoButton.FilterSearch);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Settings.LinkedSearchKeyBind.Value.IsDown())
|
||||
{
|
||||
__instance.GetItemContextInteractions(itemContext, null).ExecuteInteraction(EItemInfoButton.LinkedSearch);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -46,6 +46,7 @@ namespace UIFixes
|
||||
new GridWindowButtonsPatch().Enable();
|
||||
new LoadMagPresetsPatch().Enable();
|
||||
KeepWindowsOnScreenPatches.Enable();
|
||||
new ContextMenuShortcutPatch().Enable();
|
||||
}
|
||||
|
||||
public static bool InRaid()
|
||||
|
3
R.cs
3
R.cs
@@ -503,16 +503,19 @@ namespace UIFixes
|
||||
public static Type Type { get; private set; }
|
||||
private static FieldInfo InventoryControllerField;
|
||||
private static FieldInfo GridWindowTemplateField;
|
||||
private static PropertyInfo ItemContextProperty;
|
||||
|
||||
public static void InitTypes()
|
||||
{
|
||||
Type = typeof(EFT.UI.ItemUiContext);
|
||||
InventoryControllerField = AccessTools.GetDeclaredFields(Type).Single(t => t.FieldType == typeof(InventoryControllerClass));
|
||||
GridWindowTemplateField = AccessTools.Field(Type, "_gridWindowTemplate");
|
||||
ItemContextProperty = AccessTools.GetDeclaredProperties(Type).Single(p => p.PropertyType == typeof(ItemContextAbstractClass));
|
||||
}
|
||||
|
||||
public InventoryControllerClass InventoryController { get { return (InventoryControllerClass)InventoryControllerField.GetValue(Value); } }
|
||||
public EFT.UI.GridWindow GridWindowTemplate { get { return (EFT.UI.GridWindow)GridWindowTemplateField.GetValue(Value); } }
|
||||
public ItemContextAbstractClass ItemContext { get { return (ItemContextAbstractClass)ItemContextProperty.GetValue(Value); } }
|
||||
}
|
||||
|
||||
public static class Money
|
||||
|
51
Settings.cs
51
Settings.cs
@@ -41,6 +41,12 @@ namespace UIFixes
|
||||
public static ConfigEntry<bool> UseHomeEnd { get; set; }
|
||||
public static ConfigEntry<bool> RebindPageUpDown { get; set; }
|
||||
public static ConfigEntry<int> MouseScrollMulti { get; set; }
|
||||
|
||||
public static ConfigEntry<KeyboardShortcut> InspectKeyBind { get; set; }
|
||||
public static ConfigEntry<KeyboardShortcut> OpenKeyBind { get; set; }
|
||||
public static ConfigEntry<KeyboardShortcut> TopUpKeyBind { get; set; }
|
||||
public static ConfigEntry<KeyboardShortcut> FilterByKeyBind { get; set; }
|
||||
public static ConfigEntry<KeyboardShortcut> LinkedSearchKeyBind { get; set; }
|
||||
public static ConfigEntry<bool> UseRaidMouseScrollMulti { get; set; } // Advanced
|
||||
public static ConfigEntry<int> MouseScrollMultiInRaid { get; set; } // Advanced
|
||||
|
||||
@@ -161,6 +167,51 @@ namespace UIFixes
|
||||
new AcceptableValueRange<int>(1, 10),
|
||||
new ConfigurationManagerAttributes { })));
|
||||
|
||||
configEntries.Add(InspectKeyBind = config.Bind(
|
||||
InputSection,
|
||||
"Inspect Shortcut",
|
||||
new KeyboardShortcut(KeyCode.I),
|
||||
new ConfigDescription(
|
||||
"Keybind to inspect an item",
|
||||
null,
|
||||
new ConfigurationManagerAttributes { })));
|
||||
|
||||
configEntries.Add(OpenKeyBind = config.Bind(
|
||||
InputSection,
|
||||
"Open Shortcut",
|
||||
new KeyboardShortcut(KeyCode.O),
|
||||
new ConfigDescription(
|
||||
"Keybind to open a container",
|
||||
null,
|
||||
new ConfigurationManagerAttributes { })));
|
||||
|
||||
configEntries.Add(TopUpKeyBind = config.Bind(
|
||||
InputSection,
|
||||
"Top Up Ammo Shortcut",
|
||||
new KeyboardShortcut(KeyCode.T),
|
||||
new ConfigDescription(
|
||||
"Keybind to top up an ammo stack",
|
||||
null,
|
||||
new ConfigurationManagerAttributes { })));
|
||||
|
||||
configEntries.Add(FilterByKeyBind = config.Bind(
|
||||
InputSection,
|
||||
"Filter by Item Shortcut",
|
||||
new KeyboardShortcut(KeyCode.F),
|
||||
new ConfigDescription(
|
||||
"Keybind to search flea market for this item",
|
||||
null,
|
||||
new ConfigurationManagerAttributes { })));
|
||||
|
||||
configEntries.Add(LinkedSearchKeyBind = config.Bind(
|
||||
InputSection,
|
||||
"Linked Search Shortcut",
|
||||
new KeyboardShortcut(KeyCode.L),
|
||||
new ConfigDescription(
|
||||
"Keybind to search flea market for items linked to this item",
|
||||
null,
|
||||
new ConfigurationManagerAttributes { })));
|
||||
|
||||
configEntries.Add(UseRaidMouseScrollMulti = config.Bind(
|
||||
InputSection,
|
||||
"Use Different Scrolling Speed in Raid",
|
||||
|
Reference in New Issue
Block a user