diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneBeatSyncedContainer.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneBeatSyncedContainer.cs index ede89c6096..1881f6d718 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneBeatSyncedContainer.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneBeatSyncedContainer.cs @@ -258,24 +258,7 @@ namespace osu.Game.Tests.Visual.UserInterface }; } - protected override void LoadComplete() - { - base.LoadComplete(); - - Beatmap.BindValueChanged(_ => - { - timingPointCount.Value = 0; - currentTimingPoint.Value = 0; - beatCount.Value = 0; - currentBeat.Value = 0; - beatsPerMinute.Value = 0; - adjustedBeatLength.Value = 0; - timeUntilNextBeat.Value = 0; - timeSinceLastBeat.Value = 0; - }, true); - } - - private List timingPoints => Beatmap.Value.Beatmap.ControlPointInfo.TimingPoints.ToList(); + private List timingPoints => Beatmap.ControlPointInfo.TimingPoints.ToList(); private TimingControlPoint getNextTimingPoint(TimingControlPoint current) { diff --git a/osu.Game/Graphics/Containers/BeatSyncedContainer.cs b/osu.Game/Graphics/Containers/BeatSyncedContainer.cs index 2024d18570..48936f7aa9 100644 --- a/osu.Game/Graphics/Containers/BeatSyncedContainer.cs +++ b/osu.Game/Graphics/Containers/BeatSyncedContainer.cs @@ -10,6 +10,7 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Timing; using osu.Game.Beatmaps; using osu.Game.Beatmaps.ControlPoints; +using osu.Game.Screens.Edit; using osu.Game.Screens.Play; namespace osu.Game.Graphics.Containers @@ -79,20 +80,31 @@ namespace osu.Game.Graphics.Containers } [Resolved] - protected IBindable Beatmap { get; private set; } + private IBindable beatmap { get; set; } [Resolved(canBeNull: true)] protected GameplayClock GameplayClock { get; private set; } + [Resolved(canBeNull: true)] + protected EditorBeatmap EditorBeatmap { get; private set; } + + [Resolved(canBeNull: true)] + protected EditorClock EditorClock { get; private set; } + + protected IBeatmap Beatmap => EditorBeatmap ?? beatmap?.Value.Beatmap; + protected IClock BeatSyncClock { get { + if (EditorClock != null) + return EditorClock; + if (GameplayClock != null) return GameplayClock; - if (Beatmap.Value.TrackLoaded) - return Beatmap.Value.Track; + if (beatmap.Value.TrackLoaded) + return beatmap.Value.Track; return null; } @@ -101,7 +113,6 @@ namespace osu.Game.Graphics.Containers protected override void Update() { ITrack track = null; - IBeatmap beatmap = null; TimingControlPoint timingPoint; EffectControlPoint effectPoint; @@ -113,10 +124,9 @@ namespace osu.Game.Graphics.Containers double currentTrackTime = clock.CurrentTime + EarlyActivationMilliseconds; - if (Beatmap.Value.TrackLoaded && Beatmap.Value.BeatmapLoaded) + if (this.beatmap.Value.TrackLoaded && this.beatmap.Value.BeatmapLoaded) { - track = Beatmap.Value.Track; - beatmap = Beatmap.Value.Beatmap; + track = this.beatmap.Value.Track; } IsBeatSyncedWithTrack = beatmap != null && clock.IsRunning && track?.Length > 0; @@ -125,8 +135,8 @@ namespace osu.Game.Graphics.Containers { Debug.Assert(beatmap != null); - timingPoint = beatmap.ControlPointInfo.TimingPointAt(currentTrackTime); - effectPoint = beatmap.ControlPointInfo.EffectPointAt(currentTrackTime); + timingPoint = Beatmap.ControlPointInfo.TimingPointAt(currentTrackTime); + effectPoint = Beatmap.ControlPointInfo.EffectPointAt(currentTrackTime); } else {