diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index f38eecef81..692e7189a3 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -184,6 +184,8 @@ namespace osu.Game LocalConfig.BindWith(OsuSetting.VolumeInactive, userInactiveVolume); IsActive.BindValueChanged(active => updateActiveState(active.NewValue), true); + + Beatmap.BindValueChanged(beatmapChanged, true); } private ExternalLinkOpener externalLinkOpener; @@ -284,6 +286,23 @@ namespace osu.Game }, $"watch {databasedScoreInfo}", bypassScreenAllowChecks: true); } + #region Beatmap jukebox progression + + private void beatmapChanged(ValueChangedEvent beatmap) + { + var nextBeatmap = beatmap.NewValue; + if (nextBeatmap?.Track != null) + nextBeatmap.Track.Completed += currentTrackCompleted; + } + + private void currentTrackCompleted() + { + if (!Beatmap.Value.Track.Looping && !Beatmap.Disabled) + musicController.NextTrack(); + } + + #endregion + private ScheduledDelegate performFromMainMenuTask; /// @@ -446,7 +465,7 @@ namespace osu.Game Origin = Anchor.TopRight, }, rightFloatingOverlayContent.Add, true); - loadComponentSingleFile(new MusicController + loadComponentSingleFile(musicController = new MusicController { GetToolbarHeight = () => ToolbarOffset, Anchor = Anchor.TopRight, @@ -719,8 +738,11 @@ namespace osu.Game private Container topMostOverlayContent; private FrameworkConfigManager frameworkConfig; + private ScalingContainer screenContainer; + private MusicController musicController; + protected override bool OnExiting() { if (screenStack.CurrentScreen is Loader) diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index 8b9bac877b..36937def2b 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -70,9 +70,6 @@ namespace osu.Game.Overlays { Width = 400; Margin = new MarginPadding(10); - - // required to let MusicController handle beatmap cycling. - AlwaysPresent = true; } [BackgroundDependencyLoader] @@ -349,18 +346,11 @@ namespace osu.Game.Overlays direction = last > next ? TransformDirection.Prev : TransformDirection.Next; } - - //current.Track.Completed -= currentTrackCompleted; } - current = beatmap.NewValue; - - if (current != null) - current.Track.Completed += currentTrackCompleted; - progressBar.CurrentTime = 0; - updateDisplay(current, direction); + updateDisplay(current = beatmap.NewValue, direction); updateAudioAdjustments(); queuedDirection = null; @@ -378,12 +368,6 @@ namespace osu.Game.Overlays mod.ApplyToClock(track); } - private void currentTrackCompleted() => Schedule(() => - { - if (!current.Track.Looping && !beatmap.Disabled && beatmapSets.Any()) - next(); - }); - private ScheduledDelegate pendingBeatmapSwitch; private void updateDisplay(WorkingBeatmap beatmap, TransformDirection direction) @@ -447,10 +431,6 @@ namespace osu.Game.Overlays { base.PopOut(); - // This is here mostly as a performance fix. - // If the playlist is not hidden it will update children even when the music controller is hidden (due to AlwaysPresent). - playlist.Hide(); - this.FadeOut(transition_length, Easing.OutQuint); dragContainer.ScaleTo(0.9f, transition_length, Easing.OutQuint); } @@ -548,5 +528,10 @@ namespace osu.Game.Overlays return base.OnDragEnd(e); } } + + /// + /// Play the next random or playlist track. + /// + public void NextTrack() => next(); } }