diff --git a/Patches/FixTogglesPatches.cs b/Patches/FixTogglesPatches.cs new file mode 100644 index 0000000..c82130b --- /dev/null +++ b/Patches/FixTogglesPatches.cs @@ -0,0 +1,72 @@ +using Aki.Reflection.Patching; +using EFT.UI.Ragfair; +using HarmonyLib; +using System.Reflection; +using UnityEngine; +using UnityEngine.EventSystems; +using UnityEngine.UI; + +namespace UIFixes +{ + // This fix is anal AF + public class FixTogglesPatches + { + public static void Enable() + { + new DoNotToggleOnMouseOverPatch().Enable(); + new ToggleOnOpenPatch().Enable(); + new ToggleOnClosePatch().Enable(); + } + + public class DoNotToggleOnMouseOverPatch : ModulePatch + { + protected override MethodBase GetTargetMethod() + { + return AccessTools.Method(typeof(CategoryView), nameof(CategoryView.PointerEnterHandler)); + } + + [PatchPostfix] + public static void Postfix(PointerEventData eventData, Image ____toggleImage, Sprite ____closeSprite, bool ___bool_3) + { + if (!___bool_3) + { + ____toggleImage.sprite = ____closeSprite; + } + } + } + + public class ToggleOnOpenPatch : ModulePatch + { + protected override MethodBase GetTargetMethod() + { + return AccessTools.Method(typeof(CategoryView), nameof(CategoryView.OpenCategory)); + } + + [PatchPostfix] + public static void Postfix(Image ____toggleImage, Sprite ____openSprite, bool ___bool_3) + { + if (___bool_3) + { + ____toggleImage.sprite = ____openSprite; + } + } + } + + public class ToggleOnClosePatch : ModulePatch + { + protected override MethodBase GetTargetMethod() + { + return AccessTools.Method(typeof(CategoryView), nameof(CategoryView.OpenCategory)); + } + + [PatchPostfix] + public static void Postfix(Image ____toggleImage, Sprite ____closeSprite, bool ___bool_3) + { + if (!___bool_3) + { + ____toggleImage.sprite = ____closeSprite; + } + } + } + } +}