Skip to content

Commit

Permalink
[+] keep note speed when changed speed
Browse files Browse the repository at this point in the history
  • Loading branch information
clansty committed Oct 16, 2024
1 parent 6857ae5 commit 903da87
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
20 changes: 19 additions & 1 deletion AquaMai/Utils/PractiseMode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using AquaMai.Fix;
using AquaMai.Helpers;
using HarmonyLib;
Expand All @@ -20,7 +21,8 @@ public class PractiseMode
public static float speed = 1;
private static CriAtomExPlayer player;
private static MovieMaterialMai2 movie;
private static GameCtrl gameCtrl;
public static GameCtrl gameCtrl;
public static bool keepNoteSpeed = false;

public static void SetRepeatEnd(double time)
{
Expand Down Expand Up @@ -116,6 +118,22 @@ public static double CurrentPlayMsec

public static PractiseModeUI ui;

[HarmonyPatch]
public class PatchNoteSpeed
{
public static IEnumerable<MethodBase> TargetMethods()
{
yield return AccessTools.Method(typeof(GameManager), "GetNoteSpeed");
yield return AccessTools.Method(typeof(GameManager), "GetTouchSpeed");
}

public static void Postfix(ref float __result)
{
if (!keepNoteSpeed) return;
__result /= speed;
}
}

[HarmonyPatch(typeof(GameProcess), "OnStart")]
[HarmonyPostfix]
public static void GameProcessPostStart()
Expand Down
9 changes: 7 additions & 2 deletions AquaMai/Utils/PractiseModeUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ public void OnGUI()
GUI.Button(GetButtonRect(2, 2), Locale.SpeedUp);
GUI.Button(GetButtonRect(1, 3), Locale.SpeedReset);

GUI.Label(GetButtonRect(0, 3), TimeSpan.FromMilliseconds(PractiseMode.CurrentPlayMsec).ToString(@"mm\:ss\.fff"));
GUI.Label(GetButtonRect(2, 3), TimeSpan.FromMilliseconds(NotesManager.Instance().getPlayFinalMsec()).ToString(@"mm\:ss\.fff"));
GUI.Label(GetButtonRect(0, 3), $"{TimeSpan.FromMilliseconds(PractiseMode.CurrentPlayMsec):mm\\:ss\\.fff}\n{TimeSpan.FromMilliseconds(NotesManager.Instance().getPlayFinalMsec()):mm\\:ss\\.fff}");
GUI.Button(GetButtonRect(2, 3), $"保持流速\n{(PractiseMode.keepNoteSpeed ? "ON" : "OFF")}");
}

public void Update()
Expand Down Expand Up @@ -131,6 +131,11 @@ public void Update()
{
PractiseMode.SpeedReset();
}
else if (InputManager.GetTouchPanelAreaDown(InputManager.TouchPanelArea.E4))
{
PractiseMode.keepNoteSpeed = !PractiseMode.keepNoteSpeed;
PractiseMode.gameCtrl?.ResetOptionSpeed();
}
else if (
InputManager.GetTouchPanelAreaDown(InputManager.TouchPanelArea.A1) ||
InputManager.GetTouchPanelAreaDown(InputManager.TouchPanelArea.A2) ||
Expand Down

0 comments on commit 903da87

Please sign in to comment.