1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-12 02:02:55 +08:00

make autoplay path when going backwards in replay

This commit is contained in:
TaterToes 2024-10-10 15:55:03 -04:00 committed by GitHub
parent c545269eec
commit 1d479c2e8b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -173,27 +173,53 @@ namespace osu.Game.Screens.Edit.GameplayTest
{
}
private double previousAutoTime = 0;
public void SetupAutoplay()
{
var autoplay = Ruleset.Value.CreateInstance().GetAutoplayMod();
if (autoplay == null)
return;
// stores time when autoplay starts
previousAutoTime = GameplayClockContainer.CurrentTime;
var score = autoplay.CreateScoreFromReplayData(GameplayState.Beatmap, new[] { autoplay });
// remove past frames to prevent replay frame handler from seeking back to start in an attempt to play back the entirety of the replay.
score.Replay.Frames.RemoveAll(f => f.Time <= GameplayClockContainer.CurrentTime);
DrawableRuleset.SetReplayScore(score);
// Without this schedule, the `GlobalCursorDisplay.Update()` machinery will fade the gameplay cursor out, but we still want it to show.
Schedule(() => DrawableRuleset.Cursor?.Show());
}
private void toggleAutoplay()
{
if (DrawableRuleset.ReplayScore == null)
{
var autoplay = Ruleset.Value.CreateInstance().GetAutoplayMod();
if (autoplay == null)
return;
var score = autoplay.CreateScoreFromReplayData(GameplayState.Beatmap, [autoplay]);
// remove past frames to prevent replay frame handler from seeking back to start in an attempt to play back the entirety of the replay.
score.Replay.Frames.RemoveAll(f => f.Time <= GameplayClockContainer.CurrentTime);
DrawableRuleset.SetReplayScore(score);
// Without this schedule, the `GlobalCursorDisplay.Update()` machinery will fade the gameplay cursor out, but we still want it to show.
Schedule(() => DrawableRuleset.Cursor?.Show());
SetupAutoplay();
}
else
DrawableRuleset.SetReplayScore(null);
}
protected override void Update()
{
if (DrawableRuleset.ReplayScore != null)
{
// compare currentTime with previousTime
if (GameplayClockContainer.CurrentTime != previousAutoTime)
{
if (GameplayClockContainer.CurrentTime < previousAutoTime)
{
SetupAutoplay();
}
}
}
}
private void toggleQuickPause()
{
if (GameplayClockContainer.IsPaused.Value)