Skip to content

Commit

Permalink
Merge pull request #17930 from peppy/fix-song-select-music-control
Browse files Browse the repository at this point in the history
Fix nested song select in first-run dialog fiddling with global audio
  • Loading branch information
peppy authored Apr 24, 2022
2 parents 21665f6 + d92c905 commit 0746238
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
7 changes: 6 additions & 1 deletion osu.Game/Overlays/FirstRunSetup/ScreenUIScale.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ private void load(OsuConfigManager config)
new Drawable[]
{
new SampleScreenContainer(new PinnedMainMenu()),
new SampleScreenContainer(new PlaySongSelect()),
new SampleScreenContainer(new NestedSongSelect()),
},
// TODO: add more screens here in the future (gameplay / results)
// requires a bit more consideration to isolate their behaviour from the "parent" game.
Expand Down Expand Up @@ -95,6 +95,11 @@ protected override void Update()
}
}

private class NestedSongSelect : PlaySongSelect
{
protected override bool ControlGlobalMusic => false;
}

private class PinnedMainMenu : MainMenu
{
public override void OnEntering(ScreenTransitionEvent e)
Expand Down
23 changes: 19 additions & 4 deletions osu.Game/Screens/Select/SongSelect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ public abstract class SongSelect : ScreenWithBeatmapBackground, IKeyBindingHandl

public FilterControl FilterControl { get; private set; }

/// <summary>
/// Whether this song select instance should take control of the global track,
/// applying looping and preview offsets.
/// </summary>
protected virtual bool ControlGlobalMusic => true;

protected virtual bool ShowFooter => true;

protected virtual bool DisplayStableImportPrompt => legacyImportManager?.SupportsImportFromStable == true;
Expand Down Expand Up @@ -604,15 +610,18 @@ public override void OnResuming(ScreenTransitionEvent e)
BeatmapDetails.Refresh();

beginLooping();
music.ResetTrackAdjustments();

if (Beatmap != null && !Beatmap.Value.BeatmapSetInfo.DeletePending)
{
updateComponentFromBeatmap(Beatmap.Value);

// restart playback on returning to song select, regardless.
// not sure this should be a permanent thing (we may want to leave a user pause paused even on returning)
music.Play(requestedByUser: true);
if (ControlGlobalMusic)
{
// restart playback on returning to song select, regardless.
// not sure this should be a permanent thing (we may want to leave a user pause paused even on returning)
music.ResetTrackAdjustments();
music.Play(requestedByUser: true);
}
}

this.FadeIn(250);
Expand Down Expand Up @@ -663,6 +672,9 @@ public override bool OnExiting(ScreenExitEvent e)

private void beginLooping()
{
if (!ControlGlobalMusic)
return;

Debug.Assert(!isHandlingLooping);

isHandlingLooping = true;
Expand Down Expand Up @@ -733,6 +745,9 @@ private void updateComponentFromBeatmap(WorkingBeatmap beatmap)
/// </summary>
private void ensurePlayingSelected()
{
if (!ControlGlobalMusic)
return;

ITrack track = music.CurrentTrack;

bool isNewTrack = !lastTrack.TryGetTarget(out var last) || last != track;
Expand Down

0 comments on commit 0746238

Please sign in to comment.