diff --git a/osu.Game/Overlays/Music/PlaylistList.cs b/osu.Game/Overlays/Music/PlaylistList.cs index ca46bdea95..e961b1d69b 100644 --- a/osu.Game/Overlays/Music/PlaylistList.cs +++ b/osu.Game/Overlays/Music/PlaylistList.cs @@ -73,6 +73,17 @@ namespace osu.Game.Overlays.Music }; } + public void AddBeatmapSet(BeatmapSetInfo beatmapSet) + { + items.Add(new PlaylistItem(beatmapSet) { OnSelect = itemSelected }); + } + + public void RemoveBeatmapSet(BeatmapSetInfo beatmapSet) + { + PlaylistItem itemToRemove = items.Children.FirstOrDefault(item => item.BeatmapSetInfo == beatmapSet); + if (itemToRemove != null) items.Remove(itemToRemove); + } + private class ItemSearchContainer : FillFlowContainer, IHasFilterableChildren { public string[] FilterTerms => new string[] { }; diff --git a/osu.Game/Overlays/Music/PlaylistOverlay.cs b/osu.Game/Overlays/Music/PlaylistOverlay.cs index 1e4c3c5ff6..3e93a80872 100644 --- a/osu.Game/Overlays/Music/PlaylistOverlay.cs +++ b/osu.Game/Overlays/Music/PlaylistOverlay.cs @@ -80,6 +80,9 @@ namespace osu.Game.Overlays.Music list.BeatmapSets = BeatmapSets = beatmaps.GetAllWithChildren(b => !b.DeletePending).ToList(); + beatmaps.BeatmapSetAdded += onBeatmapSetAdded; + beatmaps.BeatmapSetRemoved += onBeatmapSetRemoved; + beatmapBacking.BindTo(game.Beatmap); filter.Search.OnCommit = (sender, newText) => @@ -89,6 +92,17 @@ namespace osu.Game.Overlays.Music }; } + protected override void Dispose(bool isDisposing) + { + if (beatmaps != null) + { + beatmaps.BeatmapSetAdded -= onBeatmapSetAdded; + beatmaps.BeatmapSetRemoved -= onBeatmapSetRemoved; + } + + base.Dispose(isDisposing); + } + protected override void LoadComplete() { base.LoadComplete(); @@ -124,6 +138,10 @@ namespace osu.Game.Overlays.Music playSpecified(set.Beatmaps[0]); } + private void onBeatmapSetAdded(BeatmapSetInfo s) => list.AddBeatmapSet(s); + + private void onBeatmapSetRemoved(BeatmapSetInfo s) => list.RemoveBeatmapSet(s); + public void PlayPrevious() { var currentID = beatmapBacking.Value?.BeatmapSetInfo.ID ?? -1;