diff --git a/osu-framework b/osu-framework index fc93e11439..b25ed4291b 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit fc93e11439b8b391d9e01e208368d96ba85bfa26 +Subproject commit b25ed4291bb8a8a38faf404c68b3f97efc9d3413 diff --git a/osu.Game/Database/BeatmapMetadata.cs b/osu.Game/Database/BeatmapMetadata.cs index d7dbb02cf9..098c524cc3 100644 --- a/osu.Game/Database/BeatmapMetadata.cs +++ b/osu.Game/Database/BeatmapMetadata.cs @@ -22,5 +22,15 @@ namespace osu.Game.Database public int PreviewTime { get; set; } public string AudioFile { get; set; } public string BackgroundFile { get; set; } + + public string[] SearchableTerms => new[] + { + Artist, + ArtistUnicode, + Title, + TitleUnicode, + Source, + Tags + }; } } \ No newline at end of file diff --git a/osu.Game/Overlays/Music/PlaylistItem.cs b/osu.Game/Overlays/Music/PlaylistItem.cs index e103b8b14f..da31e94e22 100644 --- a/osu.Game/Overlays/Music/PlaylistItem.cs +++ b/osu.Game/Overlays/Music/PlaylistItem.cs @@ -15,7 +15,7 @@ using osu.Framework.Localisation; namespace osu.Game.Overlays.Music { - internal class PlaylistItem : Container + internal class PlaylistItem : Container, IFilterable { private const float fade_duration = 100; @@ -56,6 +56,8 @@ namespace osu.Game.Overlays.Music { BeatmapMetadata metadata = BeatmapSetInfo.Metadata; + FilterTerms = metadata.SearchableTerms; + Children = new Drawable[] { handle = new TextAwesome @@ -115,5 +117,21 @@ namespace osu.Game.Overlays.Music OnSelect?.Invoke(BeatmapSetInfo); return true; } + + public string[] FilterTerms { get; private set; } + + private bool matching = true; + + public bool MatchingCurrentFilter + { + set + { + if (matching == value) return; + + matching = value; + + FadeTo(matching ? 1 : 0, 200); + } + } } } diff --git a/osu.Game/Overlays/Music/PlaylistList.cs b/osu.Game/Overlays/Music/PlaylistList.cs index 5d95bb1b4a..418fcd41e8 100644 --- a/osu.Game/Overlays/Music/PlaylistList.cs +++ b/osu.Game/Overlays/Music/PlaylistList.cs @@ -29,6 +29,10 @@ namespace osu.Game.Overlays.Music public Action OnSelect; + private readonly SearchContainer search; + + public void Filter(string searchTerm) => search.SearchTerm = searchTerm; + public BeatmapSetInfo SelectedItem { get { return items.Children.FirstOrDefault(i => i.Selected)?.BeatmapSetInfo; } @@ -48,14 +52,36 @@ namespace osu.Game.Overlays.Music RelativeSizeAxes = Axes.Both, Children = new Drawable[] { - items = new FillFlowContainer + search = new SearchContainer { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, - }, + Children = new Drawable[] + { + items = new ItemSearchContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + }, + } + } }, }, }; } + + private class ItemSearchContainer : FillFlowContainer, IHasFilterableChildren + { + public string[] FilterTerms => new string[] { }; + public bool MatchingCurrentFilter { set { } } + + public IEnumerable FilterableChildren => Children; + + public ItemSearchContainer() + { + LayoutDuration = 200; + LayoutEasing = EasingTypes.OutQuint; + } + } } } \ No newline at end of file diff --git a/osu.Game/Overlays/Music/PlaylistOverlay.cs b/osu.Game/Overlays/Music/PlaylistOverlay.cs index a4c796e882..3865ed246f 100644 --- a/osu.Game/Overlays/Music/PlaylistOverlay.cs +++ b/osu.Game/Overlays/Music/PlaylistOverlay.cs @@ -74,7 +74,7 @@ namespace osu.Game.Overlays.Music RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, ExitRequested = () => State = Visibility.Hidden, - FilterChanged = filterChanged, + FilterChanged = search => list.Filter(search), Padding = new MarginPadding(10), }, }, @@ -86,11 +86,6 @@ namespace osu.Game.Overlays.Music beatmapBacking.BindTo(game.Beatmap); } - private void filterChanged(string newValue) - { - // TODO: implement - } - protected override void LoadComplete() { base.LoadComplete(); diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index 1736b6a82f..cf5a2fdee1 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -260,7 +260,7 @@ namespace osu.Game.Overlays } private WorkingBeatmap current; - private TransformDirection queuedDirection; + private TransformDirection queuedDirection = TransformDirection.Next; private void beatmapChanged(WorkingBeatmap beatmap) { @@ -270,6 +270,7 @@ namespace osu.Game.Overlays current = beatmapBacking.Value; updateDisplay(beatmapBacking, audioEquals ? TransformDirection.None : queuedDirection); + queuedDirection = TransformDirection.Next; } private ScheduledDelegate pendingBeatmapSwitch; diff --git a/osu.Game/Screens/Select/FilterCriteria.cs b/osu.Game/Screens/Select/FilterCriteria.cs index d49c7296ba..3634e739cf 100644 --- a/osu.Game/Screens/Select/FilterCriteria.cs +++ b/osu.Game/Screens/Select/FilterCriteria.cs @@ -27,13 +27,8 @@ namespace osu.Game.Screens.Select bool match = hasCurrentMode; - match &= string.IsNullOrEmpty(SearchText) - || (set.Metadata.Artist ?? string.Empty).IndexOf(SearchText, StringComparison.InvariantCultureIgnoreCase) != -1 - || (set.Metadata.ArtistUnicode ?? string.Empty).IndexOf(SearchText, StringComparison.InvariantCultureIgnoreCase) != -1 - || (set.Metadata.Title ?? string.Empty).IndexOf(SearchText, StringComparison.InvariantCultureIgnoreCase) != -1 - || (set.Metadata.TitleUnicode ?? string.Empty).IndexOf(SearchText, StringComparison.InvariantCultureIgnoreCase) != -1 - || (set.Metadata.Tags ?? string.Empty).IndexOf(SearchText, StringComparison.InvariantCultureIgnoreCase) != -1 - || (set.Metadata.Source ?? string.Empty).IndexOf(SearchText, StringComparison.InvariantCultureIgnoreCase) != -1; + if (!string.IsNullOrEmpty(SearchText)) + match &= set.Metadata.SearchableTerms.Any(term => term.IndexOf(SearchText, StringComparison.InvariantCultureIgnoreCase) >= 0); switch (g.State) {