mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 16:59:53 +09:00
Add the ability to search for local beatmaps via online IDs
Closes #10470.
This commit is contained in:
@ -58,6 +58,14 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
|
|
||||||
foreach (var criteriaTerm in criteria.SearchTerms)
|
foreach (var criteriaTerm in criteria.SearchTerms)
|
||||||
match &= terms.Any(term => term.IndexOf(criteriaTerm, StringComparison.InvariantCultureIgnoreCase) >= 0);
|
match &= terms.Any(term => term.IndexOf(criteriaTerm, StringComparison.InvariantCultureIgnoreCase) >= 0);
|
||||||
|
|
||||||
|
// if a match wasn't found via text matching of terms, do a second catch-all check matching against online IDs.
|
||||||
|
// this should be done after text matching so we can prioritise matching numbers in metadata.
|
||||||
|
if (!match && criteria.SearchNumber.HasValue)
|
||||||
|
{
|
||||||
|
match = (Beatmap.OnlineBeatmapID == criteria.SearchNumber.Value) ||
|
||||||
|
(Beatmap.BeatmapSet?.OnlineBeatmapSetID == criteria.SearchNumber.Value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (match)
|
if (match)
|
||||||
|
@ -43,6 +43,11 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
private string searchText;
|
private string searchText;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// <see cref="SearchText"/> as a number (if it can be parsed as one).
|
||||||
|
/// </summary>
|
||||||
|
public int? SearchNumber { get; private set; }
|
||||||
|
|
||||||
public string SearchText
|
public string SearchText
|
||||||
{
|
{
|
||||||
get => searchText;
|
get => searchText;
|
||||||
@ -50,6 +55,11 @@ namespace osu.Game.Screens.Select
|
|||||||
{
|
{
|
||||||
searchText = value;
|
searchText = value;
|
||||||
SearchTerms = searchText.Split(new[] { ',', ' ', '!' }, StringSplitOptions.RemoveEmptyEntries).ToArray();
|
SearchTerms = searchText.Split(new[] { ',', ' ', '!' }, StringSplitOptions.RemoveEmptyEntries).ToArray();
|
||||||
|
|
||||||
|
SearchNumber = null;
|
||||||
|
|
||||||
|
if (SearchTerms.Length == 1 && int.TryParse(SearchTerms[0], out int parsed))
|
||||||
|
SearchNumber = parsed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user