[+] Prevent accidental touch of the Test button

This commit is contained in:
Clansty
2024-08-20 00:36:24 +08:00
parent eb72839e2b
commit cdd3c81bdc
5 changed files with 52 additions and 1 deletions

47
AquaMai/UX/TestProof.cs Normal file
View File

@@ -0,0 +1,47 @@
using System.Diagnostics;
using System.Linq;
using HarmonyLib;
using Manager;
using MelonLoader;
namespace AquaMai.UX;
public class TestProof
{
private static int _keyPressFrames;
[HarmonyPrefix]
[HarmonyPatch(typeof(InputManager), "GetSystemInputDown")]
public static bool GetSystemInputDown(ref bool __result, InputManager.SystemButtonSetting button, bool[] ___SystemButtonDown)
{
__result = ___SystemButtonDown[(int)button];
if (button != InputManager.SystemButtonSetting.ButtonTest)
return false;
if (!InputManager.GetSystemInputPush(button))
{
_keyPressFrames = 0;
return false;
}
var stackTrace = new StackTrace(); // get call stack
var stackFrames = stackTrace.GetFrames(); // get method calls (frames)
if (stackFrames.Any(it => it.GetMethod().Name == "DMD<Main.GameMainObject::Update>"))
{
__result = false;
if (InputManager.GetSystemInputPush(button))
{
_keyPressFrames++;
}
if (_keyPressFrames == 60)
{
__result = true;
}
MelonLogger.Msg(_keyPressFrames);
}
return false;
}
}