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

Custom playlist music order was ignored. Queue music by filter and collection. #30343

Draft
wants to merge 21 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
5c23a2c
Fixed a bug where custom playlist music order was ignored.
wezwery Oct 18, 2024
814d2ed
Return BeatmapSets visibility to private.
wezwery Oct 18, 2024
9ee8e4f
Removed nullable from IEnumerable<Live<BeatmapSetInfo>>
wezwery Oct 18, 2024
854a412
Formatting code and change equals methods.
wezwery Oct 19, 2024
aa57ca3
Add Playlist to MusicController. It seems to work.
wezwery Oct 21, 2024
7b989b5
Code formatting. Calling a method once per frame.
wezwery Oct 21, 2024
1916990
Register a realm notification for beatmaps changes. Tests seem to work.
wezwery Oct 23, 2024
a75ad5c
Added empty playlist checks to other tests in TestSceneMusicActionHan…
wezwery Oct 23, 2024
42d712b
Remove bad code. Add beatmapsets to MusicController.Playlist when Pla…
wezwery Oct 24, 2024
0fcd5e7
Adding spaces
wezwery Oct 24, 2024
d4aaa86
Get all beatmap sets when playlist is empty
wezwery Nov 1, 2024
bd467a6
Code Quality fix
wezwery Nov 1, 2024
138b516
Merge branch 'master' into music-player-queue-by-results
wezwery Nov 7, 2024
0400e8f
Update Playlist from PlaylistOverlay. Again.
wezwery Nov 11, 2024
e70fdc2
Directly add PlaylistOverlay to playlistContainer.
wezwery Nov 11, 2024
c4f95a9
Added logging to view the number of beatmap sets.
wezwery Nov 11, 2024
de0f002
Remove logging. Add beatmapsets on load. Change Clear to RemoveAll un…
wezwery Nov 15, 2024
412a254
Clear Playlist in MusicController when Realm have BeatmapSets changes.
wezwery Nov 15, 2024
f80a727
Revert changes in NowPlayingOverlay.cs
wezwery Nov 15, 2024
7c58c59
Revert changes in PlaylistOverlay.cs
wezwery Nov 15, 2024
e8197bf
Merge branch 'master' into music-player-queue-by-results
wezwery Nov 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions osu.Game/Overlays/Music/Playlist.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
// See the LICENCE file in the repository root for full licence text.

using System;
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
Expand All @@ -21,6 +23,9 @@ public partial class Playlist : OsuRearrangeableListContainer<Live<BeatmapSetInf

private FilterCriteria currentCriteria = new FilterCriteria();

[Resolved]
private MusicController musicController { get; set; } = null!;

public new MarginPadding Padding
{
get => base.Padding;
Expand All @@ -46,9 +51,21 @@ public void Filter(FilterCriteria criteria)

items.SearchTerm = criteria.SearchText;
currentCriteria = criteria;

if (currentCriteria == criteria)
updateMusicControllerPlaylist();

items.FilterCompleted += updateMusicControllerPlaylist;

void updateMusicControllerPlaylist() => Scheduler.AddOnce(() =>
{
musicController.Playlist.Clear();
musicController.Playlist.AddRange(AllVisibleSets);
});
}

public Live<BeatmapSetInfo>? FirstVisibleSet => Items.FirstOrDefault(i => ((PlaylistItem)ItemMap[i]).MatchingFilter);
public IEnumerable<Live<BeatmapSetInfo>> AllVisibleSets => Items.Where(i => ((PlaylistItem)ItemMap[i]).MatchingFilter);

protected override OsuRearrangeableListItem<Live<BeatmapSetInfo>> CreateOsuDrawable(Live<BeatmapSetInfo> item) =>
new PlaylistItem(item)
Expand Down
5 changes: 5 additions & 0 deletions osu.Game/Overlays/Music/PlaylistOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,19 @@ private void beatmapsChanged(IRealmCollection<BeatmapSetInfo> sender, ChangeSet
beatmapSets.Clear();
// must use AddRange to avoid RearrangeableList sort overhead per add op.
beatmapSets.AddRange(sender.Select(b => b.ToLive(realm)));

return;
}

foreach (int i in changes.InsertedIndices)
{
beatmapSets.Insert(i, sender[i].ToLive(realm));
}

foreach (int i in changes.DeletedIndices.OrderDescending())
{
beatmapSets.RemoveAt(i);
}
}

protected override void PopIn()
Expand Down
15 changes: 11 additions & 4 deletions osu.Game/Overlays/MusicController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ public partial class MusicController : CompositeDrawable
[Resolved]
private IBindable<IReadOnlyList<Mod>> mods { get; set; } = null!;

public readonly BindableList<Live<BeatmapSetInfo>> Playlist = new BindableList<Live<BeatmapSetInfo>>();

public DrawableTrack CurrentTrack { get; private set; } = new DrawableTrack(new TrackVirtual(1000));

[Resolved]
Expand Down Expand Up @@ -275,7 +277,6 @@ private PreviousTrackResult prev(bool allowProtectedTracks)
/// </summary>
/// <param name="onSuccess">Invoked when the operation has been performed successfully.</param>
/// <param name="allowProtectedTracks">Whether to include <see cref="BeatmapSetInfo.Protected"/> beatmap sets when navigating.</param>
/// <returns>A <see cref="ScheduledDelegate"/> of the operation.</returns>
public void NextTrack(Action? onSuccess = null, bool allowProtectedTracks = false) => Schedule(() =>
{
bool res = next(allowProtectedTracks);
Expand Down Expand Up @@ -459,9 +460,15 @@ private void restartTrack()

private TrackChangeDirection? queuedDirection;

private IEnumerable<Live<BeatmapSetInfo>> getBeatmapSets() => realm.Realm.All<BeatmapSetInfo>().Where(s => !s.DeletePending)
.AsEnumerable()
.Select(s => new RealmLive<BeatmapSetInfo>(s, realm));
private IEnumerable<Live<BeatmapSetInfo>> getBeatmapSets()
{
return Playlist.IsDefault
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is the meaning of this conditional? Why is this ever required?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is necessary because github tests fail music overlay tests when loading beatmaps. The playlist is always empty.

? realm.Realm.All<BeatmapSetInfo>()
.Where(s => !s.DeletePending)
.AsEnumerable()
.Select(s => new RealmLive<BeatmapSetInfo>(s, realm))
: Playlist.Where(s => !s.Value.DeletePending);
}

private void changeBeatmap(WorkingBeatmap newWorking)
{
Expand Down
Loading