OCD patch to fix toggle behavior
This commit is contained in:
72
Patches/FixTogglesPatches.cs
Normal file
72
Patches/FixTogglesPatches.cs
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user