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

Hook up seeking flow

This commit is contained in:
Dean Herbert 2021-05-17 18:41:56 +09:00
parent 0c433cda86
commit b80768b44a
2 changed files with 17 additions and 14 deletions

View File

@ -562,6 +562,12 @@ namespace osu.Game.Screens.Play
updateSampleDisabledState();
}
/// <summary>
/// Seek to a specific time in gameplay.
/// </summary>
/// <param name="time">The destination time to seek to.</param>
public void Seek(double time) => GameplayClockContainer.Seek(time);
/// <summary>
/// Restart gameplay via a parent <see cref="PlayerLoader"/>.
/// <remarks>This can be called from a child screen in order to trigger the restart process.</remarks>

View File

@ -66,7 +66,13 @@ namespace osu.Game.Screens.Play
}
}
public IClock ReferenceClock;
[Resolved(canBeNull: true)]
private Player player { get; set; }
[Resolved(canBeNull: true)]
private GameplayClock gameplayClock { get; set; }
private IClock referenceClock;
public SongProgress()
{
@ -99,24 +105,13 @@ namespace osu.Game.Screens.Play
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
OnSeek = seek,
OnSeek = time => player?.Seek(time),
},
}
},
};
}
private void seek(double time)
{
if (gameplayClock == null)
return;
// TODO: implement
}
[Resolved(canBeNull: true)]
private GameplayClock gameplayClock { get; set; }
[BackgroundDependencyLoader(true)]
private void load(OsuColour colours, OsuConfigManager config, DrawableRuleset drawableRuleset)
{
@ -125,6 +120,8 @@ namespace osu.Game.Screens.Play
if (drawableRuleset != null)
{
AllowSeeking.BindTo(drawableRuleset.HasReplayLoaded);
referenceClock = drawableRuleset.FrameStableClock;
Objects = drawableRuleset.Objects;
}
@ -159,7 +156,7 @@ namespace osu.Game.Screens.Play
return;
double gameplayTime = gameplayClock?.CurrentTime ?? Time.Current;
double frameStableTime = ReferenceClock?.CurrentTime ?? gameplayTime;
double frameStableTime = referenceClock?.CurrentTime ?? gameplayTime;
double progress = Math.Min(1, (frameStableTime - firstHitTime) / (lastHitTime - firstHitTime));