Skip to content

Commit

Permalink
[F] Notes shift after set speed
Browse files Browse the repository at this point in the history
  • Loading branch information
clansty committed Oct 16, 2024
1 parent 953083a commit 5bcbffc
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 8 deletions.
46 changes: 38 additions & 8 deletions AquaMai/Utils/PractiseMode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using HarmonyLib;
using Manager;
using Monitor;
using Monitor.Game;
using Process;
using UnityEngine;

Expand All @@ -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)
{
Expand Down Expand Up @@ -50,6 +52,7 @@ public static void SetSpeed()
player.UpdateAll();

movie.player.SetSpeed(speed);
gameCtrl?.ResetOptionSpeed();
}

private static IEnumerator SetSpeedCoroutineInner()
Expand Down Expand Up @@ -101,7 +104,13 @@ public static void GameProcessPostStart()
repeatEnd = -1;
speed = 1;
ui = null;
SetSpeed();
}

[HarmonyPatch(typeof(GameCtrl), "Initialize")]
[HarmonyPostfix]
public static void GameCtrlPostInitialize(GameCtrl __instance)
{
gameCtrl = __instance;
}

# if DEBUG
Expand Down Expand Up @@ -134,18 +143,39 @@ public static void GameProcessPostUpdate(GameProcess __instance, GameMonitor[] _
}
}

[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)
{
startGap = msecStartGap;
}

[HarmonyPatch(typeof(NotesManager), "UpdateTimer")]
[HarmonyPrefix]
public static bool NotesManagerPostUpdateTimer(bool ____isPlaying, Stopwatch ____stopwatch, ref float ____curMSec, ref float ____curMSecPre, float ____msecStartGap)
{
var num = 0d;
if (____isPlaying && ____stopwatch != null)
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")]
Expand Down
1 change: 1 addition & 0 deletions AquaMai/Utils/PractiseModeUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ public void Update()
DebugFeature.Pause = !DebugFeature.Pause;
if (!DebugFeature.Pause)
{
DebugFeature.Seek(0);
PractiseMode.SetSpeedCoroutine();
}
}
Expand Down

0 comments on commit 5bcbffc

Please sign in to comment.