From 5bcbffcdf0df0efa5bc7cc150600df25360e1475 Mon Sep 17 00:00:00 2001 From: Clansty Date: Wed, 16 Oct 2024 18:41:07 +0800 Subject: [PATCH] [F] Notes shift after set speed --- AquaMai/Utils/PractiseMode.cs | 46 +++++++++++++++++++++++++++------ AquaMai/Utils/PractiseModeUI.cs | 1 + 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/AquaMai/Utils/PractiseMode.cs b/AquaMai/Utils/PractiseMode.cs index 5dde577f..bcf3adfb 100644 --- a/AquaMai/Utils/PractiseMode.cs +++ b/AquaMai/Utils/PractiseMode.cs @@ -7,6 +7,7 @@ using AquaMai.Helpers; using HarmonyLib; using Manager; using Monitor; +using Monitor.Game; using Process; using UnityEngine; @@ -19,6 +20,7 @@ public class PractiseMode public static float speed = 1; private static CriAtomExPlayer player; private static MovieMaterialMai2 movie; + private static GameCtrl gameCtrl; public static void SetRepeatEnd(double time) { @@ -50,6 +52,7 @@ public class PractiseMode player.UpdateAll(); movie.player.SetSpeed(speed); + gameCtrl?.ResetOptionSpeed(); } private static IEnumerator SetSpeedCoroutineInner() @@ -101,7 +104,13 @@ public class PractiseMode repeatEnd = -1; speed = 1; ui = null; - SetSpeed(); + } + + [HarmonyPatch(typeof(GameCtrl), "Initialize")] + [HarmonyPostfix] + public static void GameCtrlPostInitialize(GameCtrl __instance) + { + gameCtrl = __instance; } # if DEBUG @@ -134,18 +143,39 @@ public class PractiseMode } } - [HarmonyPatch(typeof(NotesManager), "UpdateTimer")] + private static float startGap = -1f; + + [HarmonyPatch(typeof(NotesManager), "StartPlay")] [HarmonyPostfix] - public static void NotesManagerPostUpdateTimer(bool ____isPlaying, Stopwatch ____stopwatch, ref float ____curMSec, ref float ____curMSecPre, float ____msecStartGap) + public static void NotesManagerPostUpdateTimer(float msecStartGap) { - var num = 0d; - if (____isPlaying && ____stopwatch != null) + startGap = msecStartGap; + } + + [HarmonyPatch(typeof(NotesManager), "UpdateTimer")] + [HarmonyPrefix] + public static bool NotesManagerPostUpdateTimer(bool ____isPlaying, Stopwatch ____stopwatch, ref float ____curMSec, ref float ____curMSecPre, float ____msecStartGap) + { + if (startGap != -1f) { - num = (double)____stopwatch.ElapsedTicks / Stopwatch.Frequency * 1000.0 * speed; + ____curMSec = startGap; + ____curMSecPre = startGap; + ____stopwatch?.Reset(); + startGap = -1f; + } + else + { + ____curMSecPre = ____curMSec; + if (____isPlaying && ____stopwatch != null && !DebugFeature.Pause) + { + var num = (double)____stopwatch.ElapsedTicks / Stopwatch.Frequency * 1000.0 * speed; + ____curMSec += (float)num; + ____stopwatch.Reset(); + ____stopwatch.Start(); + } } - ____curMSecPre = ____curMSec; - ____curMSec = (float)num + ____msecStartGap; + return false; } [HarmonyPatch(typeof(SoundCtrl), "Initialize")] diff --git a/AquaMai/Utils/PractiseModeUI.cs b/AquaMai/Utils/PractiseModeUI.cs index 49ac913a..12da7c10 100644 --- a/AquaMai/Utils/PractiseModeUI.cs +++ b/AquaMai/Utils/PractiseModeUI.cs @@ -103,6 +103,7 @@ public class PractiseModeUI : MonoBehaviour DebugFeature.Pause = !DebugFeature.Pause; if (!DebugFeature.Pause) { + DebugFeature.Seek(0); PractiseMode.SetSpeedCoroutine(); } }