1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-15 08:52:56 +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 void toggleAutoplay() private double previousAutoTime = 0;
{
if (DrawableRuleset.ReplayScore == null) public void SetupAutoplay()
{ {
var autoplay = Ruleset.Value.CreateInstance().GetAutoplayMod(); var autoplay = Ruleset.Value.CreateInstance().GetAutoplayMod();
if (autoplay == null) if (autoplay == null)
return; return;
var score = autoplay.CreateScoreFromReplayData(GameplayState.Beatmap, [autoplay]); // 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. // 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); score.Replay.Frames.RemoveAll(f => f.Time <= GameplayClockContainer.CurrentTime);
DrawableRuleset.SetReplayScore(score); DrawableRuleset.SetReplayScore(score);
// Without this schedule, the `GlobalCursorDisplay.Update()` machinery will fade the gameplay cursor out, but we still want it to show. // Without this schedule, the `GlobalCursorDisplay.Update()` machinery will fade the gameplay cursor out, but we still want it to show.
Schedule(() => DrawableRuleset.Cursor?.Show()); Schedule(() => DrawableRuleset.Cursor?.Show());
} }
private void toggleAutoplay()
{
if (DrawableRuleset.ReplayScore == null)
{
SetupAutoplay();
}
else else
DrawableRuleset.SetReplayScore(null); 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() private void toggleQuickPause()
{ {
if (GameplayClockContainer.IsPaused.Value) if (GameplayClockContainer.IsPaused.Value)