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

Add new beatmap search filter row "General"

This commit is contained in:
Max Hübner 2021-03-25 23:20:10 +01:00
parent 452e5c7cc3
commit aa2c1ee85e
4 changed files with 33 additions and 0 deletions

View File

@ -15,6 +15,9 @@ namespace osu.Game.Online.API.Requests
{
public class SearchBeatmapSetsRequest : APIRequest<SearchBeatmapSetsResponse>
{
[CanBeNull]
public IReadOnlyCollection<SearchGeneral> General { get; }
public SearchCategory SearchCategory { get; }
public SortCriteria SortCriteria { get; }
@ -45,6 +48,7 @@ namespace osu.Game.Online.API.Requests
string query,
RulesetInfo ruleset,
Cursor cursor = null,
IReadOnlyCollection<SearchGeneral> general = null,
SearchCategory searchCategory = SearchCategory.Any,
SortCriteria sortCriteria = SortCriteria.Ranked,
SortDirection sortDirection = SortDirection.Descending,
@ -59,6 +63,7 @@ namespace osu.Game.Online.API.Requests
this.ruleset = ruleset;
this.cursor = cursor;
General = general;
SearchCategory = searchCategory;
SortCriteria = sortCriteria;
SortDirection = sortDirection;
@ -75,6 +80,9 @@ namespace osu.Game.Online.API.Requests
var req = base.CreateWebRequest();
req.AddParameter("q", query);
if (General != null && General.Any())
req.AddParameter("c", string.Join('.', General.Select(e => e.ToString().ToLowerInvariant())));
if (ruleset.ID.HasValue)
req.AddParameter("m", ruleset.ID.Value.ToString());

View File

@ -134,6 +134,7 @@ namespace osu.Game.Overlays.BeatmapListing
queueUpdateSearch(true);
});
searchControl.General.CollectionChanged += (_, __) => queueUpdateSearch();
searchControl.Ruleset.BindValueChanged(_ => queueUpdateSearch());
searchControl.Category.BindValueChanged(_ => queueUpdateSearch());
searchControl.Genre.BindValueChanged(_ => queueUpdateSearch());
@ -187,6 +188,7 @@ namespace osu.Game.Overlays.BeatmapListing
searchControl.Query.Value,
searchControl.Ruleset.Value,
lastResponse?.Cursor,
searchControl.General,
searchControl.Category.Value,
sortControl.Current.Value,
sortControl.SortDirection.Value,

View File

@ -29,6 +29,8 @@ namespace osu.Game.Overlays.BeatmapListing
public Bindable<string> Query => textBox.Current;
public BindableList<SearchGeneral> General => generalFilter.Current;
public Bindable<RulesetInfo> Ruleset => modeFilter.Current;
public Bindable<SearchCategory> Category => categoryFilter.Current;
@ -61,6 +63,7 @@ namespace osu.Game.Overlays.BeatmapListing
}
private readonly BeatmapSearchTextBox textBox;
private readonly BeatmapSearchMultipleSelectionFilterRow<SearchGeneral> generalFilter;
private readonly BeatmapSearchRulesetFilterRow modeFilter;
private readonly BeatmapSearchFilterRow<SearchCategory> categoryFilter;
private readonly BeatmapSearchFilterRow<SearchGenre> genreFilter;
@ -123,6 +126,7 @@ namespace osu.Game.Overlays.BeatmapListing
Padding = new MarginPadding { Horizontal = 10 },
Children = new Drawable[]
{
generalFilter = new BeatmapSearchMultipleSelectionFilterRow<SearchGeneral>(@"General"),
modeFilter = new BeatmapSearchRulesetFilterRow(),
categoryFilter = new BeatmapSearchFilterRow<SearchCategory>(@"Categories"),
genreFilter = new BeatmapSearchFilterRow<SearchGenre>(@"Genre"),

View File

@ -0,0 +1,19 @@
// 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.ComponentModel;
namespace osu.Game.Overlays.BeatmapListing
{
public enum SearchGeneral
{
[Description("Recommended difficulty")]
Recommended,
[Description("Include converted beatmaps")]
Converts,
[Description("Subscribed mappers")]
Follows
}
}