diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 186e73ee4c..d5807f6e18 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -562,6 +562,12 @@ namespace osu.Game.Screens.Play updateSampleDisabledState(); } + /// + /// Seek to a specific time in gameplay. + /// + /// The destination time to seek to. + public void Seek(double time) => GameplayClockContainer.Seek(time); + /// /// Restart gameplay via a parent . /// This can be called from a child screen in order to trigger the restart process. diff --git a/osu.Game/Screens/Play/SongProgress.cs b/osu.Game/Screens/Play/SongProgress.cs index dc349ddcc6..f95e6520cc 100644 --- a/osu.Game/Screens/Play/SongProgress.cs +++ b/osu.Game/Screens/Play/SongProgress.cs @@ -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));