examine keybind; unlock cursor
This commit is contained in:
@@ -18,6 +18,7 @@ global using DiscardResult = GClass2799;
|
||||
global using ItemSorter = GClass2772;
|
||||
global using ItemWithLocation = GClass2521;
|
||||
global using SearchableGrid = GClass2516;
|
||||
global using CursorManager = GClass3034;
|
||||
|
||||
// State machine states
|
||||
global using FirearmReadyState = EFT.Player.FirearmController.GClass1619;
|
||||
|
||||
@@ -75,12 +75,12 @@ public static class ContextMenuShortcutPatches
|
||||
|
||||
if (Settings.UseAllKeyBind.Value.IsDown())
|
||||
{
|
||||
TryInteraction(__instance, itemContext, EItemInfoButton.UseAll, EItemInfoButton.Use);
|
||||
TryInteraction(__instance, itemContext, EItemInfoButton.UseAll, [EItemInfoButton.Use]);
|
||||
}
|
||||
|
||||
if (Settings.UnloadKeyBind.Value.IsDown())
|
||||
{
|
||||
TryInteraction(__instance, itemContext, EItemInfoButton.Unload, EItemInfoButton.UnloadAmmo);
|
||||
TryInteraction(__instance, itemContext, EItemInfoButton.Unload, [EItemInfoButton.UnloadAmmo]);
|
||||
}
|
||||
|
||||
if (Settings.UnpackKeyBind.Value.IsDown())
|
||||
@@ -103,15 +103,27 @@ public static class ContextMenuShortcutPatches
|
||||
MoveToFromSortingTable(itemContext, __instance);
|
||||
}
|
||||
|
||||
if (Settings.ExamineKeyBind.Value.IsDown())
|
||||
{
|
||||
TryInteraction(__instance, itemContext, EItemInfoButton.Examine,
|
||||
[EItemInfoButton.Fold, EItemInfoButton.Unfold, EItemInfoButton.TurnOn, EItemInfoButton.TurnOff, EItemInfoButton.CheckMagazine]);
|
||||
}
|
||||
|
||||
Interactions = null;
|
||||
}
|
||||
|
||||
private static void TryInteraction(ItemUiContext itemUiContext, ItemContextAbstractClass itemContext, EItemInfoButton interaction, EItemInfoButton? fallbackInteraction = null)
|
||||
private static void TryInteraction(ItemUiContext itemUiContext, ItemContextAbstractClass itemContext, EItemInfoButton interaction, EItemInfoButton[] fallbackInteractions = null)
|
||||
{
|
||||
Interactions ??= itemUiContext.GetItemContextInteractions(itemContext, null);
|
||||
if (!Interactions.ExecuteInteraction(interaction) && fallbackInteraction.HasValue)
|
||||
if (!Interactions.ExecuteInteraction(interaction) && fallbackInteractions != null)
|
||||
{
|
||||
Interactions.ExecuteInteraction(fallbackInteraction.Value);
|
||||
foreach (var fallbackInteraction in fallbackInteractions)
|
||||
{
|
||||
if (Interactions.ExecuteInteraction(fallbackInteraction))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
33
Patches/UnlockCursorPatch.cs
Normal file
33
Patches/UnlockCursorPatch.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using HarmonyLib;
|
||||
using SPT.Reflection.Patching;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UIFixes;
|
||||
|
||||
public class UnlockCursorPatch : ModulePatch
|
||||
{
|
||||
private static readonly FullScreenMode[] WindowedModes = [FullScreenMode.Windowed, FullScreenMode.MaximizedWindow, FullScreenMode.FullScreenWindow];
|
||||
|
||||
protected override MethodBase GetTargetMethod()
|
||||
{
|
||||
return AccessTools.Method(typeof(CursorManager), nameof(CursorManager.SetCursorLockMode));
|
||||
}
|
||||
|
||||
[PatchPrefix]
|
||||
public static bool Prefix(bool cursorVisible, FullScreenMode fullscreenMode, Action ___action_0)
|
||||
{
|
||||
Cursor.lockState = cursorVisible ?
|
||||
Settings.UnlockCursor.Value && WindowedModes.Contains(fullscreenMode) ? CursorLockMode.None : CursorLockMode.Confined :
|
||||
CursorLockMode.Locked;
|
||||
|
||||
if (___action_0 != null)
|
||||
{
|
||||
___action_0();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -67,6 +67,7 @@ public class Plugin : BaseUnityPlugin
|
||||
SortPatches.Enable();
|
||||
ReloadInPlacePatches.Enable();
|
||||
BarterOfferPatches.Enable();
|
||||
new UnlockCursorPatch().Enable();
|
||||
}
|
||||
|
||||
public static bool InRaid()
|
||||
|
||||
20
Settings.cs
20
Settings.cs
@@ -48,6 +48,7 @@ internal class Settings
|
||||
private const string FleaMarketSection = "6. Flea Market";
|
||||
|
||||
// General
|
||||
public static ConfigEntry<bool> UnlockCursor { get; set; }
|
||||
public static ConfigEntry<WeaponPresetConfirmationOption> ShowPresetConfirmations { get; set; }
|
||||
public static ConfigEntry<TransferConfirmationOption> ShowTransferConfirmations { get; set; }
|
||||
public static ConfigEntry<bool> KeepMessagesOpen { get; set; }
|
||||
@@ -63,6 +64,7 @@ internal class Settings
|
||||
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> ExamineKeyBind { get; set; }
|
||||
public static ConfigEntry<KeyboardShortcut> TopUpKeyBind { get; set; }
|
||||
public static ConfigEntry<KeyboardShortcut> UseKeyBind { get; set; }
|
||||
public static ConfigEntry<KeyboardShortcut> UseAllKeyBind { get; set; }
|
||||
@@ -133,6 +135,15 @@ internal class Settings
|
||||
var configEntries = new List<ConfigEntryBase>();
|
||||
|
||||
// General
|
||||
configEntries.Add(UnlockCursor = config.Bind(
|
||||
GeneralSection,
|
||||
"Unlock Cursor",
|
||||
true,
|
||||
new ConfigDescription(
|
||||
"Unlock cursor in Windowed, Maximized Windowed, and FullScreen Windowed modes. Note that you must alt-tab out of the game and back in for this to take affect.",
|
||||
null,
|
||||
new ConfigurationManagerAttributes { })));
|
||||
|
||||
configEntries.Add(ShowPresetConfirmations = config.Bind(
|
||||
GeneralSection,
|
||||
"Show Weapon Preset Confirmation Dialog",
|
||||
@@ -269,6 +280,15 @@ internal class Settings
|
||||
null,
|
||||
new ConfigurationManagerAttributes { })));
|
||||
|
||||
configEntries.Add(ExamineKeyBind = config.Bind(
|
||||
InputSection,
|
||||
"Examine/Interact Shortcut",
|
||||
new KeyboardShortcut(KeyCode.None),
|
||||
new ConfigDescription(
|
||||
"Keybind to examine an item, fold it, unfold it, turn it on, turn it off, or check a magazine",
|
||||
null,
|
||||
new ConfigurationManagerAttributes { })));
|
||||
|
||||
configEntries.Add(TopUpKeyBind = config.Bind(
|
||||
InputSection,
|
||||
"Top Up Ammo Shortcut",
|
||||
|
||||
Reference in New Issue
Block a user