From 35eb3afc4a8c75217d6a5a86f5b5cee6a92f4891 Mon Sep 17 00:00:00 2001 From: Tyfon <29051038+tyfon7@users.noreply.github.com> Date: Sat, 20 Apr 2024 03:00:27 -0700 Subject: [PATCH] Hide disabled interactions, and rev version! --- .gitignore | 1 + Patches/DisabledActionsPatch.cs | 37 +++++++++++++++++++++++++++++++++ Patches/WeaponBindingPatch.cs | 10 +++------ Plugin.cs | 1 + Settings.cs | 2 ++ UIFixes.csproj | 2 +- 6 files changed, 45 insertions(+), 8 deletions(-) create mode 100644 Patches/DisabledActionsPatch.cs diff --git a/.gitignore b/.gitignore index 168b63f..97ea84d 100644 --- a/.gitignore +++ b/.gitignore @@ -31,6 +31,7 @@ bld/ [Oo]bj/ [Ll]og/ [Ll]ogs/ +dist/ # Visual Studio 2015/2017 cache/options directory .vs/ diff --git a/Patches/DisabledActionsPatch.cs b/Patches/DisabledActionsPatch.cs new file mode 100644 index 0000000..356ca0d --- /dev/null +++ b/Patches/DisabledActionsPatch.cs @@ -0,0 +1,37 @@ +using Aki.Reflection.Patching; +using HarmonyLib; +using System; +using System.Linq; +using System.Reflection; + +namespace UIFixes +{ + public class DisabledActionsPatch : ModulePatch + { + protected override MethodBase GetTargetMethod() + { + Type type = typeof(GetActionsClass); + return AccessTools.GetDeclaredMethods(type).FirstOrDefault(x => + { + var parameters = x.GetParameters(); + return x.Name == "GetAvailableActions" && parameters[0].Name == "owner"; + }); + } + + [PatchPostfix] + private static void Postfix(ref ActionsReturnClass __result) + { + if (Settings.RemoveDisabledActions.Value && __result != null) + { + for (int i = __result.Actions.Count - 1; i >= 0; i--) + { + if (__result.Actions[i].Disabled) + { + Logger.LogInfo(__result.Actions[i].Name); + __result.Actions.RemoveAt(i); + } + } + } + } + } +} diff --git a/Patches/WeaponBindingPatch.cs b/Patches/WeaponBindingPatch.cs index 7646cb9..768c1e8 100644 --- a/Patches/WeaponBindingPatch.cs +++ b/Patches/WeaponBindingPatch.cs @@ -1,14 +1,10 @@ using Aki.Reflection.Patching; +using Aki.Reflection.Utils; +using EFT.InputSystem; using EFT.InventoryLogic; -using EFT.UI.WeaponModding; using System; -using System.Collections.Generic; using System.Linq; using System.Reflection; -using System.Text; -using System.Threading.Tasks; -using EFT.InputSystem; -using Aki.Reflection.Utils; namespace UIFixes { @@ -25,7 +21,7 @@ namespace UIFixes } [PatchPostfix] - private static void Postfix(object __instance, EBoundItem boundItem, ref string __result) + private static void Postfix(object /*GClass960*/ __instance, EBoundItem boundItem, ref string __result) { switch(boundItem) { diff --git a/Plugin.cs b/Plugin.cs index 41a5abd..869c3fc 100644 --- a/Plugin.cs +++ b/Plugin.cs @@ -15,6 +15,7 @@ namespace UIFixes ScrollPatches.Enable(); WeaponZoomPatch.Enable(); new WeaponBindingPatch().Enable(); + new DisabledActionsPatch().Enable(); } } } diff --git a/Settings.cs b/Settings.cs index 85d5a23..24b43e3 100644 --- a/Settings.cs +++ b/Settings.cs @@ -9,6 +9,7 @@ namespace UIFixes public static ConfigEntry TransferConfirmOnClose { get; set; } public static ConfigEntry UseHomeEnd { get; set; } public static ConfigEntry RebindPageUpDown { get; set; } + public static ConfigEntry RemoveDisabledActions { get; set; } public static void Init(ConfigFile config) { @@ -17,6 +18,7 @@ namespace UIFixes TransferConfirmOnClose = config.Bind("Transfer Items", "Confirm untransfered items", false, "Whether to pointlessly confirm that you're leaving the item transfer with literally no consequences"); UseHomeEnd = config.Bind("Keybinds", "Add support for Home and End", true, "Home and End will scroll to the top and bottom of lists"); RebindPageUpDown = config.Bind("Keybinds", "Use normal PageUp and PageDown (requires restart)", true, "Changes PageUp and PageDown to simply page up and down, not scroll all the way to top and bottom"); + RemoveDisabledActions = config.Bind("In Raid", "Hide unimplemented actions", false, "Hides actions you can't actually do, like \"Bang and Clear\", etc from locked doors and other interactable objects"); } } } diff --git a/UIFixes.csproj b/UIFixes.csproj index 81b8b48..502ea00 100644 --- a/UIFixes.csproj +++ b/UIFixes.csproj @@ -4,7 +4,7 @@ net471 Tyfon.UIFixes SPT UI Fixes - 1.0.0 + 1.1.0 true latest