2020-01-30 18:21:24 +08:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using osu.Framework.Bindables;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Game.Beatmaps;
|
2021-11-15 13:34:50 +08:00
|
|
|
|
using osu.Game.Extensions;
|
2020-01-30 18:21:24 +08:00
|
|
|
|
using osu.Game.Graphics.Containers;
|
|
|
|
|
using osuTK;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Music
|
|
|
|
|
{
|
2020-02-14 14:36:16 +08:00
|
|
|
|
public class Playlist : OsuRearrangeableListContainer<BeatmapSetInfo>
|
2020-01-30 18:21:24 +08:00
|
|
|
|
{
|
|
|
|
|
public Action<BeatmapSetInfo> RequestSelection;
|
|
|
|
|
|
|
|
|
|
public readonly Bindable<BeatmapSetInfo> SelectedSet = new Bindable<BeatmapSetInfo>();
|
|
|
|
|
|
|
|
|
|
public new MarginPadding Padding
|
|
|
|
|
{
|
|
|
|
|
get => base.Padding;
|
|
|
|
|
set => base.Padding = value;
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-11 15:46:11 +08:00
|
|
|
|
public void Filter(FilterCriteria criteria)
|
|
|
|
|
{
|
|
|
|
|
var items = (SearchContainer<RearrangeableListItem<BeatmapSetInfo>>)ListContainer;
|
|
|
|
|
|
|
|
|
|
foreach (var item in items.OfType<PlaylistItem>())
|
2021-11-15 13:34:50 +08:00
|
|
|
|
item.InSelectedCollection = criteria.Collection?.Beatmaps.Any(b => b.MatchesOnlineID(item.Model)) ?? true;
|
2020-09-11 15:46:11 +08:00
|
|
|
|
|
|
|
|
|
items.SearchTerm = criteria.SearchText;
|
|
|
|
|
}
|
2020-01-30 18:21:24 +08:00
|
|
|
|
|
2020-01-30 18:23:53 +08:00
|
|
|
|
public BeatmapSetInfo FirstVisibleSet => Items.FirstOrDefault(i => ((PlaylistItem)ItemMap[i]).MatchingFilter);
|
2020-01-30 18:21:24 +08:00
|
|
|
|
|
2020-02-14 14:36:16 +08:00
|
|
|
|
protected override OsuRearrangeableListItem<BeatmapSetInfo> CreateOsuDrawable(BeatmapSetInfo item) => new PlaylistItem(item)
|
2020-01-30 18:21:24 +08:00
|
|
|
|
{
|
|
|
|
|
SelectedSet = { BindTarget = SelectedSet },
|
|
|
|
|
RequestSelection = set => RequestSelection?.Invoke(set)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
protected override FillFlowContainer<RearrangeableListItem<BeatmapSetInfo>> CreateListFillFlowContainer() => new SearchContainer<RearrangeableListItem<BeatmapSetInfo>>
|
|
|
|
|
{
|
|
|
|
|
Spacing = new Vector2(0, 3),
|
|
|
|
|
LayoutDuration = 200,
|
|
|
|
|
LayoutEasing = Easing.OutQuint,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|