From cdd3c81bdca41e4b1ea99a4bbca6d548e06b124d Mon Sep 17 00:00:00 2001 From: Clansty Date: Tue, 20 Aug 2024 00:36:24 +0800 Subject: [PATCH] [+] Prevent accidental touch of the Test button --- .github/workflows/aquamai.yaml | 2 +- AquaMai/AquaMai.csproj | 1 + AquaMai/AquaMai.toml | 2 ++ AquaMai/Config.cs | 1 + AquaMai/UX/TestProof.cs | 47 ++++++++++++++++++++++++++++++++++ 5 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 AquaMai/UX/TestProof.cs diff --git a/.github/workflows/aquamai.yaml b/.github/workflows/aquamai.yaml index d1b89ad1..7ca08861 100644 --- a/.github/workflows/aquamai.yaml +++ b/.github/workflows/aquamai.yaml @@ -45,7 +45,7 @@ jobs: $Uri = "https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendDocument" $Form = @{ chat_id = "-1002231087502" - caption = "${{ github.event.commits[0].message }} `n`n For ${{ matrix.target }}" + caption = "${{ github.event.commits[0].message }} `n`nFor ${{ matrix.target }}" document = Get-Item AquaMai\Output\AquaMai.dll } Invoke-RestMethod -Uri $uri -Form $Form -Method Post diff --git a/AquaMai/AquaMai.csproj b/AquaMai/AquaMai.csproj index b3b0fbbc..8f982aa2 100644 --- a/AquaMai/AquaMai.csproj +++ b/AquaMai/AquaMai.csproj @@ -303,6 +303,7 @@ + diff --git a/AquaMai/AquaMai.toml b/AquaMai/AquaMai.toml index b81e560e..cc213ef9 100644 --- a/AquaMai/AquaMai.toml +++ b/AquaMai/AquaMai.toml @@ -44,6 +44,8 @@ ExecOnEntry="" ExtendTimer=true # Save immediate after playing a song ImmediateSave=true +# Prevent accidental touch of the Test button +TestProof=false [Performance] # Disable some useless delays to speed up the game boot process diff --git a/AquaMai/Config.cs b/AquaMai/Config.cs index 8b2be814..3a4c9605 100644 --- a/AquaMai/Config.cs +++ b/AquaMai/Config.cs @@ -31,6 +31,7 @@ namespace AquaMai public bool SkipEventInfo { get; set; } public bool ImmediateSave { get; set; } public bool LoadLocalBga { get; set; } + public bool TestProof { get; set; } public string CustomVersionString { get; set; } public string ExecOnIdle { get; set; } public string ExecOnEntry { get; set; } diff --git a/AquaMai/UX/TestProof.cs b/AquaMai/UX/TestProof.cs new file mode 100644 index 00000000..4ca24487 --- /dev/null +++ b/AquaMai/UX/TestProof.cs @@ -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")) + { + __result = false; + if (InputManager.GetSystemInputPush(button)) + { + _keyPressFrames++; + } + + if (_keyPressFrames == 60) + { + __result = true; + } + + MelonLogger.Msg(_keyPressFrames); + } + + return false; + } +}