[F] Notes shift after set speed

This commit is contained in:
Clansty
2024-10-16 18:41:07 +08:00
parent 953083a0bf
commit 5bcbffcdf0
2 changed files with 39 additions and 8 deletions

View File

@@ -7,6 +7,7 @@ using AquaMai.Helpers;
using HarmonyLib; using HarmonyLib;
using Manager; using Manager;
using Monitor; using Monitor;
using Monitor.Game;
using Process; using Process;
using UnityEngine; using UnityEngine;
@@ -19,6 +20,7 @@ public class PractiseMode
public static float speed = 1; public static float speed = 1;
private static CriAtomExPlayer player; private static CriAtomExPlayer player;
private static MovieMaterialMai2 movie; private static MovieMaterialMai2 movie;
private static GameCtrl gameCtrl;
public static void SetRepeatEnd(double time) public static void SetRepeatEnd(double time)
{ {
@@ -50,6 +52,7 @@ public class PractiseMode
player.UpdateAll(); player.UpdateAll();
movie.player.SetSpeed(speed); movie.player.SetSpeed(speed);
gameCtrl?.ResetOptionSpeed();
} }
private static IEnumerator SetSpeedCoroutineInner() private static IEnumerator SetSpeedCoroutineInner()
@@ -101,7 +104,13 @@ public class PractiseMode
repeatEnd = -1; repeatEnd = -1;
speed = 1; speed = 1;
ui = null; ui = null;
SetSpeed(); }
[HarmonyPatch(typeof(GameCtrl), "Initialize")]
[HarmonyPostfix]
public static void GameCtrlPostInitialize(GameCtrl __instance)
{
gameCtrl = __instance;
} }
# if DEBUG # if DEBUG
@@ -134,18 +143,39 @@ public class PractiseMode
} }
} }
[HarmonyPatch(typeof(NotesManager), "UpdateTimer")] private static float startGap = -1f;
[HarmonyPatch(typeof(NotesManager), "StartPlay")]
[HarmonyPostfix] [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; startGap = msecStartGap;
if (____isPlaying && ____stopwatch != null) }
[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; return false;
____curMSec = (float)num + ____msecStartGap;
} }
[HarmonyPatch(typeof(SoundCtrl), "Initialize")] [HarmonyPatch(typeof(SoundCtrl), "Initialize")]

View File

@@ -103,6 +103,7 @@ public class PractiseModeUI : MonoBehaviour
DebugFeature.Pause = !DebugFeature.Pause; DebugFeature.Pause = !DebugFeature.Pause;
if (!DebugFeature.Pause) if (!DebugFeature.Pause)
{ {
DebugFeature.Seek(0);
PractiseMode.SetSpeedCoroutine(); PractiseMode.SetSpeedCoroutine();
} }
} }