mirror of
https://github.com/ppy/osu.git
synced 2025-01-15 15:12:57 +08:00
Implement Genre filter
This commit is contained in:
parent
5a0b93bdb2
commit
6b2ae67eaf
@ -5,6 +5,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
|
using osu.Game.Online.API.Requests;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Online
|
namespace osu.Game.Tests.Visual.Online
|
||||||
{
|
{
|
||||||
@ -30,6 +31,12 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
AddStep("Show Rem tag", () => overlay.ShowTag("Rem"));
|
AddStep("Show Rem tag", () => overlay.ShowTag("Rem"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestShowGenre()
|
||||||
|
{
|
||||||
|
AddStep("Show Anime genre", () => overlay.ShowGenre(BeatmapSearchGenre.Anime));
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestShow()
|
public void TestShow()
|
||||||
{
|
{
|
||||||
|
@ -16,15 +16,17 @@ namespace osu.Game.Online.API.Requests
|
|||||||
private readonly BeatmapSearchCategory searchCategory;
|
private readonly BeatmapSearchCategory searchCategory;
|
||||||
private readonly DirectSortCriteria sortCriteria;
|
private readonly DirectSortCriteria sortCriteria;
|
||||||
private readonly SortDirection direction;
|
private readonly SortDirection direction;
|
||||||
|
private readonly BeatmapSearchGenre genre;
|
||||||
private string directionString => direction == SortDirection.Descending ? @"desc" : @"asc";
|
private string directionString => direction == SortDirection.Descending ? @"desc" : @"asc";
|
||||||
|
|
||||||
public SearchBeatmapSetsRequest(string query, RulesetInfo ruleset, BeatmapSearchCategory searchCategory = BeatmapSearchCategory.Any, DirectSortCriteria sortCriteria = DirectSortCriteria.Ranked, SortDirection direction = SortDirection.Descending)
|
public SearchBeatmapSetsRequest(string query, RulesetInfo ruleset, BeatmapSearchCategory searchCategory = BeatmapSearchCategory.Any, DirectSortCriteria sortCriteria = DirectSortCriteria.Ranked, SortDirection direction = SortDirection.Descending, BeatmapSearchGenre genre = BeatmapSearchGenre.Any)
|
||||||
{
|
{
|
||||||
this.query = string.IsNullOrEmpty(query) ? string.Empty : System.Uri.EscapeDataString(query);
|
this.query = string.IsNullOrEmpty(query) ? string.Empty : System.Uri.EscapeDataString(query);
|
||||||
this.ruleset = ruleset;
|
this.ruleset = ruleset;
|
||||||
this.searchCategory = searchCategory;
|
this.searchCategory = searchCategory;
|
||||||
this.sortCriteria = sortCriteria;
|
this.sortCriteria = sortCriteria;
|
||||||
this.direction = direction;
|
this.direction = direction;
|
||||||
|
this.genre = genre;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override WebRequest CreateWebRequest()
|
protected override WebRequest CreateWebRequest()
|
||||||
@ -36,6 +38,10 @@ namespace osu.Game.Online.API.Requests
|
|||||||
req.AddParameter("m", ruleset.ID.Value.ToString());
|
req.AddParameter("m", ruleset.ID.Value.ToString());
|
||||||
|
|
||||||
req.AddParameter("s", searchCategory.ToString().ToLowerInvariant());
|
req.AddParameter("s", searchCategory.ToString().ToLowerInvariant());
|
||||||
|
|
||||||
|
if (genre != BeatmapSearchGenre.Any)
|
||||||
|
req.AddParameter("g", ((int)genre).ToString());
|
||||||
|
|
||||||
req.AddParameter("sort", $"{sortCriteria.ToString().ToLowerInvariant()}_{directionString}");
|
req.AddParameter("sort", $"{sortCriteria.ToString().ToLowerInvariant()}_{directionString}");
|
||||||
|
|
||||||
return req;
|
return req;
|
||||||
@ -62,4 +68,22 @@ namespace osu.Game.Online.API.Requests
|
|||||||
[Description("My Maps")]
|
[Description("My Maps")]
|
||||||
Mine,
|
Mine,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum BeatmapSearchGenre
|
||||||
|
{
|
||||||
|
Any,
|
||||||
|
Unspecified,
|
||||||
|
|
||||||
|
[Description("Video Game")]
|
||||||
|
Game,
|
||||||
|
Anime,
|
||||||
|
Rock,
|
||||||
|
Pop,
|
||||||
|
Other,
|
||||||
|
Novelty,
|
||||||
|
|
||||||
|
[Description("Hip Hop")]
|
||||||
|
Hiphop = 9,
|
||||||
|
Electronic
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,8 @@ namespace osu.Game.Overlays.BeatmapListing
|
|||||||
|
|
||||||
public Bindable<BeatmapSearchCategory> Category => categoryFilter.Current;
|
public Bindable<BeatmapSearchCategory> Category => categoryFilter.Current;
|
||||||
|
|
||||||
|
public Bindable<BeatmapSearchGenre> Genre => genreFilter.Current;
|
||||||
|
|
||||||
public BeatmapSetInfo BeatmapSet
|
public BeatmapSetInfo BeatmapSet
|
||||||
{
|
{
|
||||||
set
|
set
|
||||||
@ -43,6 +45,7 @@ namespace osu.Game.Overlays.BeatmapListing
|
|||||||
private readonly BeatmapSearchTextBox textBox;
|
private readonly BeatmapSearchTextBox textBox;
|
||||||
private readonly BeatmapSearchRulesetFilterRow modeFilter;
|
private readonly BeatmapSearchRulesetFilterRow modeFilter;
|
||||||
private readonly BeatmapSearchFilterRow<BeatmapSearchCategory> categoryFilter;
|
private readonly BeatmapSearchFilterRow<BeatmapSearchCategory> categoryFilter;
|
||||||
|
private readonly BeatmapSearchSmallFilterRow<BeatmapSearchGenre> genreFilter;
|
||||||
|
|
||||||
private readonly Box background;
|
private readonly Box background;
|
||||||
private readonly UpdateableBeatmapSetCover beatmapCover;
|
private readonly UpdateableBeatmapSetCover beatmapCover;
|
||||||
@ -98,6 +101,7 @@ namespace osu.Game.Overlays.BeatmapListing
|
|||||||
{
|
{
|
||||||
modeFilter = new BeatmapSearchRulesetFilterRow(),
|
modeFilter = new BeatmapSearchRulesetFilterRow(),
|
||||||
categoryFilter = new BeatmapSearchFilterRow<BeatmapSearchCategory>(@"Categories"),
|
categoryFilter = new BeatmapSearchFilterRow<BeatmapSearchCategory>(@"Categories"),
|
||||||
|
genreFilter = new BeatmapSearchSmallFilterRow<BeatmapSearchGenre>(@"Genre"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -154,6 +154,7 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
searchSection.Ruleset.BindValueChanged(_ => queueUpdateSearch());
|
searchSection.Ruleset.BindValueChanged(_ => queueUpdateSearch());
|
||||||
searchSection.Category.BindValueChanged(_ => queueUpdateSearch());
|
searchSection.Category.BindValueChanged(_ => queueUpdateSearch());
|
||||||
|
searchSection.Genre.BindValueChanged(_ => queueUpdateSearch());
|
||||||
sortCriteria.BindValueChanged(_ => queueUpdateSearch());
|
sortCriteria.BindValueChanged(_ => queueUpdateSearch());
|
||||||
sortDirection.BindValueChanged(_ => queueUpdateSearch());
|
sortDirection.BindValueChanged(_ => queueUpdateSearch());
|
||||||
}
|
}
|
||||||
@ -171,11 +172,25 @@ namespace osu.Game.Overlays
|
|||||||
Show();
|
Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ShowGenre(BeatmapSearchGenre genre)
|
||||||
|
{
|
||||||
|
var currentGenre = searchSection.Genre.Value;
|
||||||
|
|
||||||
|
if (currentGenre != genre)
|
||||||
|
{
|
||||||
|
setDefaultSearchValues();
|
||||||
|
searchSection.Genre.Value = genre;
|
||||||
|
}
|
||||||
|
|
||||||
|
Show();
|
||||||
|
}
|
||||||
|
|
||||||
private void setDefaultSearchValues()
|
private void setDefaultSearchValues()
|
||||||
{
|
{
|
||||||
searchSection.Query.Value = string.Empty;
|
searchSection.Query.Value = string.Empty;
|
||||||
searchSection.Ruleset.Value = new RulesetInfo { Name = @"Any" };
|
searchSection.Ruleset.Value = new RulesetInfo { Name = @"Any" };
|
||||||
searchSection.Category.Value = BeatmapSearchCategory.Leaderboard;
|
searchSection.Category.Value = BeatmapSearchCategory.Leaderboard;
|
||||||
|
searchSection.Genre.Value = BeatmapSearchGenre.Any;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ScheduledDelegate queryChangedDebounce;
|
private ScheduledDelegate queryChangedDebounce;
|
||||||
@ -208,7 +223,8 @@ namespace osu.Game.Overlays
|
|||||||
searchSection.Ruleset.Value,
|
searchSection.Ruleset.Value,
|
||||||
searchSection.Category.Value,
|
searchSection.Category.Value,
|
||||||
sortControl.Current.Value,
|
sortControl.Current.Value,
|
||||||
sortControl.SortDirection.Value);
|
sortControl.SortDirection.Value,
|
||||||
|
searchSection.Genre.Value);
|
||||||
|
|
||||||
getSetsRequest.Success += response => Schedule(() => recreatePanels(response));
|
getSetsRequest.Success += response => Schedule(() => recreatePanels(response));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user