1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 23:12:56 +08:00

Improve the way text search works at song select

This commit is contained in:
Dean Herbert 2018-12-15 16:34:48 +09:00
parent 0b5f3c00bf
commit 3892454ecc
2 changed files with 20 additions and 4 deletions

View File

@ -26,10 +26,10 @@ namespace osu.Game.Screens.Select.Carousel
bool match = criteria.Ruleset == null || Beatmap.RulesetID == criteria.Ruleset.ID || Beatmap.RulesetID == 0 && criteria.Ruleset.ID > 0 && criteria.AllowConvertedBeatmaps;
if (!string.IsNullOrEmpty(criteria.SearchText))
foreach (var criteriaTerm in criteria.SearchTerms)
match &=
Beatmap.Metadata.SearchableTerms.Any(term => term.IndexOf(criteria.SearchText, StringComparison.InvariantCultureIgnoreCase) >= 0) ||
Beatmap.Version.IndexOf(criteria.SearchText, StringComparison.InvariantCultureIgnoreCase) >= 0;
Beatmap.Metadata.SearchableTerms.Any(term => term.IndexOf(criteriaTerm, StringComparison.InvariantCultureIgnoreCase) >= 0) ||
Beatmap.Version.IndexOf(criteriaTerm, StringComparison.InvariantCultureIgnoreCase) >= 0;
Filtered.Value = !match;
}

View File

@ -1,6 +1,8 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Linq;
using osu.Game.Rulesets;
using osu.Game.Screens.Select.Filter;
@ -10,8 +12,22 @@ namespace osu.Game.Screens.Select
{
public GroupMode Group;
public SortMode Sort;
public string SearchText;
public string[] SearchTerms = Array.Empty<string>();
public RulesetInfo Ruleset;
public bool AllowConvertedBeatmaps;
private string searchText;
public string SearchText
{
get { return searchText; }
set
{
searchText = value;
SearchTerms = searchText.Split(',', ' ', '!').Where(s => !string.IsNullOrEmpty(s)).ToArray();
}
}
}
}