From 903da8732de63ddbaf69fb86b07e48862c52293a Mon Sep 17 00:00:00 2001 From: Clansty Date: Wed, 16 Oct 2024 19:23:32 +0800 Subject: [PATCH] [+] keep note speed when changed speed --- AquaMai/Utils/PractiseMode.cs | 20 +++++++++++++++++++- AquaMai/Utils/PractiseModeUI.cs | 9 +++++++-- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/AquaMai/Utils/PractiseMode.cs b/AquaMai/Utils/PractiseMode.cs index ac92981c..8070d108 100644 --- a/AquaMai/Utils/PractiseMode.cs +++ b/AquaMai/Utils/PractiseMode.cs @@ -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; @@ -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) { @@ -116,6 +118,22 @@ public static double CurrentPlayMsec public static PractiseModeUI ui; + [HarmonyPatch] + public class PatchNoteSpeed + { + public static IEnumerable 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() diff --git a/AquaMai/Utils/PractiseModeUI.cs b/AquaMai/Utils/PractiseModeUI.cs index 2e107828..b83b6971 100644 --- a/AquaMai/Utils/PractiseModeUI.cs +++ b/AquaMai/Utils/PractiseModeUI.cs @@ -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() @@ -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) ||