diff --git a/osu.Game/Screens/Play/HUD/ArgonSongProgress.cs b/osu.Game/Screens/Play/HUD/ArgonSongProgress.cs index a0e74dd6cd..7db3f9fd3c 100644 --- a/osu.Game/Screens/Play/HUD/ArgonSongProgress.cs +++ b/osu.Game/Screens/Play/HUD/ArgonSongProgress.cs @@ -114,7 +114,6 @@ namespace osu.Game.Screens.Play.HUD protected override void UpdateProgress(double progress, bool isIntro) { - bar.CurrentTime = GameplayClock.CurrentTime; bar.Progress = isIntro ? 0 : progress; } } diff --git a/osu.Game/Screens/Play/HUD/ArgonSongProgressBar.cs b/osu.Game/Screens/Play/HUD/ArgonSongProgressBar.cs index 42f638c386..7a7870a775 100644 --- a/osu.Game/Screens/Play/HUD/ArgonSongProgressBar.cs +++ b/osu.Game/Screens/Play/HUD/ArgonSongProgressBar.cs @@ -48,6 +48,7 @@ namespace osu.Game.Screens.Play.HUD RelativeSizeAxes = Axes.Both, Alpha = 0, Colour = OsuColour.Gray(0.2f), + Depth = float.MaxValue, }, audioBar = new RoundedBar { @@ -102,14 +103,14 @@ namespace osu.Game.Screens.Play.HUD base.Update(); playfieldBar.Length = (float)Interpolation.Lerp(playfieldBar.Length, Progress, Math.Clamp(Time.Elapsed / 40, 0, 1)); - audioBar.Length = (float)Interpolation.Lerp(audioBar.Length, NormalizedValue, Math.Clamp(Time.Elapsed / 40, 0, 1)); + audioBar.Length = (float)Interpolation.Lerp(audioBar.Length, AudioProgress, Math.Clamp(Time.Elapsed / 40, 0, 1)); - if (trackTime > CurrentTime) + if (trackTime > AudioTime) ChangeInternalChildDepth(audioBar, -1); else - ChangeInternalChildDepth(audioBar, 0); + ChangeInternalChildDepth(audioBar, 1); - float timeDelta = (float)Math.Abs(CurrentTime - trackTime); + float timeDelta = (float)Math.Abs(AudioTime - trackTime); const float colour_transition_threshold = 20000; diff --git a/osu.Game/Screens/Play/HUD/DefaultSongProgress.cs b/osu.Game/Screens/Play/HUD/DefaultSongProgress.cs index be310df3a9..f01c11855c 100644 --- a/osu.Game/Screens/Play/HUD/DefaultSongProgress.cs +++ b/osu.Game/Screens/Play/HUD/DefaultSongProgress.cs @@ -98,7 +98,6 @@ namespace osu.Game.Screens.Play.HUD protected override void UpdateProgress(double progress, bool isIntro) { - bar.CurrentTime = GameplayClock.CurrentTime; graph.Progress = isIntro ? 0 : (int)(graph.ColumnCount * progress); } diff --git a/osu.Game/Screens/Play/HUD/DefaultSongProgressBar.cs b/osu.Game/Screens/Play/HUD/DefaultSongProgressBar.cs index 222d6c17bf..05c8c6c46b 100644 --- a/osu.Game/Screens/Play/HUD/DefaultSongProgressBar.cs +++ b/osu.Game/Screens/Play/HUD/DefaultSongProgressBar.cs @@ -98,7 +98,7 @@ namespace osu.Game.Screens.Play.HUD base.Update(); handleBase.Height = Height - handleContainer.Height; - float newX = (float)Interpolation.Lerp(handleBase.X, NormalizedValue * DrawWidth, Math.Clamp(Time.Elapsed / 40, 0, 1)); + float newX = (float)Interpolation.Lerp(handleBase.X, AudioProgress * DrawWidth, Math.Clamp(Time.Elapsed / 40, 0, 1)); fill.Width = newX; handleBase.X = newX; diff --git a/osu.Game/Screens/Play/HUD/SongProgress.cs b/osu.Game/Screens/Play/HUD/SongProgress.cs index 962752ba5a..296306ec89 100644 --- a/osu.Game/Screens/Play/HUD/SongProgress.cs +++ b/osu.Game/Screens/Play/HUD/SongProgress.cs @@ -71,7 +71,13 @@ namespace osu.Game.Screens.Play.HUD protected double LastHitTime { get; private set; } + /// + /// Called every update frame with current progress information. + /// + /// Current (visual) progress through the beatmap (0..1). + /// If true, progress is (0..1) through the intro. protected abstract void UpdateProgress(double progress, bool isIntro); + protected virtual void UpdateObjects(IEnumerable objects) { } [BackgroundDependencyLoader] diff --git a/osu.Game/Screens/Play/HUD/SongProgressBar.cs b/osu.Game/Screens/Play/HUD/SongProgressBar.cs index 140621986c..ea2e5b2891 100644 --- a/osu.Game/Screens/Play/HUD/SongProgressBar.cs +++ b/osu.Game/Screens/Play/HUD/SongProgressBar.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using System; +using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics.Containers; using osu.Framework.Input.Events; @@ -12,6 +13,20 @@ namespace osu.Game.Screens.Play.HUD { public abstract partial class SongProgressBar : CompositeDrawable { + /// + /// The current seek position of the audio, on a (0..1) range. + /// This is generally the seek target, which will eventually match the gameplay clock when it catches up. + /// + protected double AudioProgress => length == 0 ? 1 : AudioTime / length; + + /// + /// The current (non-frame-stable) audio time. + /// + protected double AudioTime => Math.Clamp(GameplayClock.CurrentTime - StartTime, 0.0, length); + + [Resolved] + protected IGameplayClock GameplayClock { get; private set; } = null!; + /// /// Action which is invoked when a seek is requested, with the proposed millisecond value for the seek operation. /// @@ -32,12 +47,8 @@ namespace osu.Game.Screens.Play.HUD public double EndTime { get; set; } = 1.0; - public double CurrentTime { get; set; } - private double length => EndTime - StartTime; - protected double NormalizedValue => length == 0 ? 1 : Math.Clamp(CurrentTime - StartTime, 0.0, length) / length; - private bool handleClick; protected override bool OnMouseDown(MouseDownEvent e)