diff --git a/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs b/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs index 5563c0170d..50d6918faa 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs @@ -41,7 +41,6 @@ namespace osu.Desktop.VisualTests.Tests objects.Add(new HitObject { StartTime = i }); progress.Objects = objects; - progress.Progress = RNG.NextDouble(); } } } diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 1e3555f798..666c3e41a4 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -125,6 +125,7 @@ namespace osu.Game.Screens.Play hudOverlay.BindHitRenderer(HitRenderer); hudOverlay.Progress.Objects = HitRenderer.Objects; + hudOverlay.Progress.AudioClock = interpolatedSourceClock; //bind HitRenderer to ScoreProcessor and ourselves (for a pass situation) HitRenderer.OnAllJudged += onCompletion; @@ -175,13 +176,6 @@ namespace osu.Game.Screens.Play }; } - protected override void Update() - { - base.Update(); - - hudOverlay.Progress.Progress = Beatmap.Track.CurrentTime / Beatmap.Track.Length; - } - private void initializeSkipButton() { const double skip_required_cutoff = 3000; diff --git a/osu.Game/Screens/Play/SongProgress.cs b/osu.Game/Screens/Play/SongProgress.cs index 4efd05ccb7..52f3b9e1ae 100644 --- a/osu.Game/Screens/Play/SongProgress.cs +++ b/osu.Game/Screens/Play/SongProgress.cs @@ -10,12 +10,13 @@ using System.Collections.Generic; using osu.Game.Graphics; using osu.Framework.Allocation; using System.Linq; +using osu.Framework.Timing; using osu.Game.Modes.Objects; using osu.Game.Modes.Objects.Types; namespace osu.Game.Screens.Play { - public class SongProgress : OverlayContainer + public class SongProgress : OverlayContainer { private const int progress_height = 5; @@ -30,27 +31,21 @@ namespace osu.Game.Screens.Play public Action OnSeek; - private double progress; - public double Progress - { - get { return progress; } - set - { - progress = value; - updateProgress(); - } - } + public IClock AudioClock; + + private double lastHitTime => ((objects.Last() as IHasEndTime)?.EndTime ?? objects.Last().StartTime) + 1; + + private IEnumerable objects; public IEnumerable Objects { set { - var objects = value; + objects = value; const int granularity = 200; - var lastHit = ((objects.Last() as IHasEndTime)?.EndTime ?? objects.Last().StartTime) + 1; - var interval = lastHit / granularity; + var interval = lastHitTime / granularity; var values = new int[granularity]; @@ -108,12 +103,6 @@ namespace osu.Game.Screens.Play State = Visibility.Visible; } - private void updateProgress() - { - bar.UpdatePosition((float)progress); - graph.Progress = (int)(graph.ColumnCount * progress); - } - private bool barVisible; public void ToggleBar() @@ -143,7 +132,11 @@ namespace osu.Game.Screens.Play { base.Update(); - updateProgress(); + double progress = (AudioClock?.CurrentTime ?? Time.Current) / lastHitTime; + + bar.UpdatePosition((float)progress); + graph.Progress = (int)(graph.ColumnCount * progress); + } } }