diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneAutoplay.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneAutoplay.cs index e198a8504b..e47c782bca 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneAutoplay.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneAutoplay.cs @@ -63,7 +63,7 @@ namespace osu.Game.Tests.Visual.Gameplay private void seekToBreak(int breakIndex) { AddStep($"seek to break {breakIndex}", () => Player.GameplayClockContainer.Seek(destBreak().StartTime)); - AddUntilStep("wait for seek to complete", () => Player.HUDOverlay.Progress.ReferenceClock.CurrentTime >= destBreak().StartTime); + AddUntilStep("wait for seek to complete", () => Player.DrawableRuleset.FrameStableClock.CurrentTime >= destBreak().StartTime); BreakPeriod destBreak() => Beatmap.Value.Beatmap.Breaks.ElementAt(breakIndex); } diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 7d3afe3043..186e73ee4c 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -358,11 +358,6 @@ namespace osu.Game.Screens.Play AlwaysVisible = { BindTarget = DrawableRuleset.HasReplayLoaded }, IsCounting = false }, - RequestSeek = time => - { - GameplayClockContainer.Seek(time); - GameplayClockContainer.Start(); - }, Anchor = Anchor.Centre, Origin = Anchor.Centre }, diff --git a/osu.Game/Screens/Play/SongProgress.cs b/osu.Game/Screens/Play/SongProgress.cs index 4a0787bfae..dc349ddcc6 100644 --- a/osu.Game/Screens/Play/SongProgress.cs +++ b/osu.Game/Screens/Play/SongProgress.cs @@ -14,10 +14,11 @@ using osu.Framework.Timing; using osu.Game.Configuration; using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.UI; +using osu.Game.Skinning; namespace osu.Game.Screens.Play { - public class SongProgress : OverlayContainer + public class SongProgress : OverlayContainer, ISkinnableDrawable { private const int info_height = 20; private const int bottom_bar_height = 5; @@ -39,9 +40,6 @@ namespace osu.Game.Screens.Play public readonly Bindable ShowGraph = new Bindable(); - //TODO: this isn't always correct (consider mania where a non-last object may last for longer than the last in the list). - private double lastHitTime => objects.Last().GetEndTime() + 1; - public override bool HandleNonPositionalInput => AllowSeeking.Value; public override bool HandlePositionalInput => AllowSeeking.Value; @@ -49,6 +47,9 @@ namespace osu.Game.Screens.Play private double firstHitTime => objects.First().StartTime; + //TODO: this isn't always correct (consider mania where a non-last object may last for longer than the last in the list). + private double lastHitTime => objects.Last().GetEndTime() + 1; + private IEnumerable objects; public IEnumerable Objects @@ -67,10 +68,12 @@ namespace osu.Game.Screens.Play public IClock ReferenceClock; - private IClock gameplayClock; - public SongProgress() { + RelativeSizeAxes = Axes.X; + Anchor = Anchor.BottomRight; + Origin = Anchor.BottomRight; + Children = new Drawable[] { new SongProgressDisplay @@ -96,20 +99,34 @@ namespace osu.Game.Screens.Play { Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, - OnSeek = time => RequestSeek?.Invoke(time), + OnSeek = seek, }, } }, }; } + 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, GameplayClock clock, OsuConfigManager config) + private void load(OsuColour colours, OsuConfigManager config, DrawableRuleset drawableRuleset) { base.LoadComplete(); - if (clock != null) - gameplayClock = clock; + if (drawableRuleset != null) + { + AllowSeeking.BindTo(drawableRuleset.HasReplayLoaded); + Objects = drawableRuleset.Objects; + } config.BindWith(OsuSetting.ShowProgressGraph, ShowGraph); @@ -124,11 +141,6 @@ namespace osu.Game.Screens.Play ShowGraph.BindValueChanged(_ => updateGraphVisibility(), true); } - public void BindDrawableRuleset(DrawableRuleset drawableRuleset) - { - AllowSeeking.BindTo(drawableRuleset.HasReplayLoaded); - } - protected override void PopIn() { this.FadeIn(500, Easing.OutQuint); diff --git a/osu.Game/Skinning/DefaultSkin.cs b/osu.Game/Skinning/DefaultSkin.cs index 9b4e32531a..d13ddcf22b 100644 --- a/osu.Game/Skinning/DefaultSkin.cs +++ b/osu.Game/Skinning/DefaultSkin.cs @@ -12,6 +12,7 @@ using osu.Framework.Graphics.Textures; using osu.Game.Audio; using osu.Game.Extensions; using osu.Game.IO; +using osu.Game.Screens.Play; using osu.Game.Screens.Play.HUD; using osuTK; using osuTK.Graphics; @@ -86,6 +87,7 @@ namespace osu.Game.Skinning GetDrawableComponent(new HUDSkinComponent(HUDSkinComponents.ScoreCounter)), GetDrawableComponent(new HUDSkinComponent(HUDSkinComponents.AccuracyCounter)), GetDrawableComponent(new HUDSkinComponent(HUDSkinComponents.HealthDisplay)), + GetDrawableComponent(new HUDSkinComponent(HUDSkinComponents.SongProgress)), } }; @@ -109,6 +111,9 @@ namespace osu.Game.Skinning case HUDSkinComponents.HealthDisplay: return new DefaultHealthDisplay(); + + case HUDSkinComponents.SongProgress: + return new SongProgress(); } break; diff --git a/osu.Game/Skinning/HUDSkinComponents.cs b/osu.Game/Skinning/HUDSkinComponents.cs index a345e060e5..2e6c3a9937 100644 --- a/osu.Game/Skinning/HUDSkinComponents.cs +++ b/osu.Game/Skinning/HUDSkinComponents.cs @@ -9,5 +9,6 @@ namespace osu.Game.Skinning ScoreCounter, AccuracyCounter, HealthDisplay, + SongProgress, } } diff --git a/osu.Game/Skinning/LegacySkin.cs b/osu.Game/Skinning/LegacySkin.cs index a6f8f45c0f..6c8d6ee45a 100644 --- a/osu.Game/Skinning/LegacySkin.cs +++ b/osu.Game/Skinning/LegacySkin.cs @@ -17,6 +17,7 @@ using osu.Game.Audio; using osu.Game.Beatmaps.Formats; using osu.Game.IO; using osu.Game.Rulesets.Scoring; +using osu.Game.Screens.Play; using osu.Game.Screens.Play.HUD; using osuTK.Graphics; @@ -350,6 +351,7 @@ namespace osu.Game.Skinning GetDrawableComponent(new HUDSkinComponent(HUDSkinComponents.ScoreCounter)) ?? new DefaultScoreCounter(), GetDrawableComponent(new HUDSkinComponent(HUDSkinComponents.AccuracyCounter)) ?? new DefaultAccuracyCounter(), GetDrawableComponent(new HUDSkinComponent(HUDSkinComponents.HealthDisplay)) ?? new DefaultHealthDisplay(), + GetDrawableComponent(new HUDSkinComponent(HUDSkinComponents.SongProgress)) ?? new SongProgress(), } };