1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-13 13:32:54 +08:00

Update playlist when adding or removing beatmap set

This commit is contained in:
Ben Pig Chu 2017-07-22 15:26:47 +08:00
parent d344452e9b
commit 76edcb4a67
2 changed files with 29 additions and 0 deletions

View File

@ -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<PlaylistItem>, IHasFilterableChildren
{
public string[] FilterTerms => new string[] { };

View File

@ -80,6 +80,9 @@ namespace osu.Game.Overlays.Music
list.BeatmapSets = BeatmapSets = beatmaps.GetAllWithChildren<BeatmapSetInfo>(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;