Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shuffle playback order in global playlist by default #29917

Merged
merged 5 commits into from
Oct 1, 2024
Merged

Conversation

bdach
Copy link
Collaborator

@bdach bdach commented Sep 18, 2024

RFC. Closes #18169.

Implements the given proposal of keeping the current stable order but adding a shuffle facility to the now playing overlay, and enabling it by default.

There are more changes I want to make here but I'd like this to get discussion first, because I am likely to continue putting this sort of selection logic into MusicController and I just want to confirm nobody is going to have a problem with that.

In particular this is not sharing the randomisation implementation with beatmap carousel because it doesn't generalise nicely (song select cares about the particular beatmap difficulties selected to rewind properly, while the music controller only cares about picking a beatmap set).

No automated tests because randomisation is difficult to test, I tested that this does what it's supposed to manually. That said I can try on request.

RFC. Closes ppy#18169.

Implements the given proposal of keeping the current stable order but
adding a shuffle facility to the now playing overlay, and enabling it by
default.

There are more changes I want to make here but I'd like this to get
discussion first, because I am likely to continue putting this sort of
selection logic into `MusicController` and I just want to confirm nobody
is going to have a problem with that.

In particular this is not sharing the randomisation implementation with
beatmap carousel because it doesn't generalise nicely (song select cares
about the particular *beatmap difficulties* selected to rewind properly,
while the music controller only cares about picking a *beatmap set*).
@peppy peppy self-requested a review September 27, 2024 09:33
@peppy
Copy link
Member

peppy commented Sep 27, 2024

I think this direction is fine. But I'd consider moving the icon to the left to prefer centering (the pause button should be in the centre):

diff --git a/osu.Game/Overlays/NowPlayingOverlay.cs b/osu.Game/Overlays/NowPlayingOverlay.cs
index e1e5aa9426..be0dfb474a 100644
--- a/osu.Game/Overlays/NowPlayingOverlay.cs
+++ b/osu.Game/Overlays/NowPlayingOverlay.cs
@@ -164,15 +164,16 @@ private void load()
                                                     Action = () => musicController.NextTrack(),
                                                     Icon = FontAwesome.Solid.StepForward,
                                                 },
-                                                shuffleButton = new MusicIconButton
-                                                {
-                                                    Anchor = Anchor.Centre,
-                                                    Origin = Anchor.Centre,
-                                                    Action = shuffle.Toggle,
-                                                    Icon = FontAwesome.Solid.Random,
-                                                }
                                             }
                                         },
+                                        shuffleButton = new MusicIconButton
+                                        {
+                                            Anchor = Anchor.CentreLeft,
+                                            Origin = Anchor.Centre,
+                                            Action = shuffle.Toggle,
+                                            Position = new Vector2(bottom_black_area_height / 2, 0),
+                                            Icon = FontAwesome.Solid.Random,
+                                        },
                                         playlistButton = new MusicIconButton
                                         {
                                             Origin = Anchor.Centre,

Copy link
Member

@peppy peppy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As commented.

bdach added 3 commits October 1, 2024 10:07
`SkipWhile()` in this context does not correctly ensure that
`ElementAtOrDefault(1)` is not a protected track. An explicit `Where()`
does.

Spotted accidentally when I noticed that skipping to next track can
select a protected track, but skipping to previous cannot.
@pull-request-size pull-request-size bot added size/L and removed size/M labels Oct 1, 2024
@bdach
Copy link
Collaborator Author

bdach commented Oct 1, 2024

But I'd consider moving the icon to the left to prefer centering

I figured you might say this 😅 Applied, thanks.

Incidentally I noticed a bug in next track selection that was already here in master but I fixed it here anyway (2a214f7) just to reduce noise. See commit message for explanation.

@peppy peppy merged commit f08ace7 into ppy:master Oct 1, 2024
11 of 13 checks passed
@bdach bdach deleted the shuffle branch October 1, 2024 09:34
bdach added a commit to bdach/osu that referenced this pull request Oct 8, 2024
I'm not sure why this was "fine" for as long as it apparently was,
but what `MusicController` was doing was completely incorrect and
playing with fire (accessing raw managed realm objects), which went
wrong somewhere around - admittedly -
ppy#29917, likely because that one started
*storing* these raw managed realm objects to fields, and you know what
will happen to those after you do a migration and recycle realms.

To attempt to circumvent this, (ab)use `DetachedBeatmapStore` instead.
Which does necessitate moving it to `OsuGameBase`, but it's the simplest
way out I can see. I guess the alternative would be to faff around with
`Live<T>` but it's ugly and I'm attempting to fix this relatively quick
right now.
bdach added a commit to bdach/osu that referenced this pull request Oct 8, 2024
I'm not sure why this was "fine" for as long as it apparently was,
but what `MusicController` was doing was completely incorrect and
playing with fire (accessing raw managed realm objects), which went
wrong somewhere around - admittedly -
ppy#29917, likely because that one started
*storing* these raw managed realm objects to fields, and you know what
will happen to those after you do a migration and recycle realms.

To attempt to circumvent this, (ab)use `DetachedBeatmapStore` instead.
Which does necessitate moving it to `OsuGameBase`, but it's the simplest
way out I can see. I guess the alternative would be to faff around with
`Live<T>` but it's ugly and I'm attempting to fix this relatively quick
right now.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Global playlist is no longer shuffled (since realm switch)
2 participants