Skip to content

Commit

Permalink
[+] Prevent accidental touch of the Test button
Browse files Browse the repository at this point in the history
  • Loading branch information
clansty committed Aug 19, 2024
1 parent eb72839 commit cdd3c81
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/aquamai.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions AquaMai/AquaMai.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@
<Compile Include="UX\SkipEventInfo.cs" />
<Compile Include="UX\SkipWarningScreen.cs" />
<Compile Include="UX\SkipToMusicSelection.cs" />
<Compile Include="UX\TestProof.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
Expand Down
2 changes: 2 additions & 0 deletions AquaMai/AquaMai.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions AquaMai/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class UXConfig
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; }
Expand Down
47 changes: 47 additions & 0 deletions AquaMai/UX/TestProof.cs
Original file line number Diff line number Diff line change
@@ -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;
}
}

0 comments on commit cdd3c81

Please sign in to comment.