mirror of
https://github.com/ppy/osu.git
synced 2025-01-15 00:02:54 +08:00
Implement Language filter
This commit is contained in:
parent
6b2ae67eaf
commit
063a53017e
@ -37,6 +37,12 @@ namespace osu.Game.Tests.Visual.Online
|
||||
AddStep("Show Anime genre", () => overlay.ShowGenre(BeatmapSearchGenre.Anime));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestShowLanguage()
|
||||
{
|
||||
AddStep("Show Japanese language", () => overlay.ShowLanguage(BeatmapSearchLanguage.Japanese));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestShow()
|
||||
{
|
||||
|
@ -17,9 +17,10 @@ namespace osu.Game.Online.API.Requests
|
||||
private readonly DirectSortCriteria sortCriteria;
|
||||
private readonly SortDirection direction;
|
||||
private readonly BeatmapSearchGenre genre;
|
||||
private readonly BeatmapSearchLanguage language;
|
||||
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, BeatmapSearchGenre genre = BeatmapSearchGenre.Any)
|
||||
public SearchBeatmapSetsRequest(string query, RulesetInfo ruleset, BeatmapSearchCategory searchCategory = BeatmapSearchCategory.Any, DirectSortCriteria sortCriteria = DirectSortCriteria.Ranked, SortDirection direction = SortDirection.Descending, BeatmapSearchGenre genre = BeatmapSearchGenre.Any, BeatmapSearchLanguage language = BeatmapSearchLanguage.Any)
|
||||
{
|
||||
this.query = string.IsNullOrEmpty(query) ? string.Empty : System.Uri.EscapeDataString(query);
|
||||
this.ruleset = ruleset;
|
||||
@ -27,6 +28,7 @@ namespace osu.Game.Online.API.Requests
|
||||
this.sortCriteria = sortCriteria;
|
||||
this.direction = direction;
|
||||
this.genre = genre;
|
||||
this.language = language;
|
||||
}
|
||||
|
||||
protected override WebRequest CreateWebRequest()
|
||||
@ -42,6 +44,9 @@ namespace osu.Game.Online.API.Requests
|
||||
if (genre != BeatmapSearchGenre.Any)
|
||||
req.AddParameter("g", ((int)genre).ToString());
|
||||
|
||||
if (language != BeatmapSearchLanguage.Any)
|
||||
req.AddParameter("l", ((int)language).ToString());
|
||||
|
||||
req.AddParameter("sort", $"{sortCriteria.ToString().ToLowerInvariant()}_{directionString}");
|
||||
|
||||
return req;
|
||||
@ -86,4 +91,20 @@ namespace osu.Game.Online.API.Requests
|
||||
Hiphop = 9,
|
||||
Electronic
|
||||
}
|
||||
|
||||
public enum BeatmapSearchLanguage
|
||||
{
|
||||
Any,
|
||||
English = 2,
|
||||
Chilnese = 4,
|
||||
French = 7,
|
||||
German,
|
||||
Italian = 11,
|
||||
Japanese = 3,
|
||||
Korean = 6,
|
||||
Spanish = 10,
|
||||
Swedish = 9,
|
||||
Instrumantal = 5,
|
||||
Other = 1
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +27,8 @@ namespace osu.Game.Overlays.BeatmapListing
|
||||
|
||||
public Bindable<BeatmapSearchGenre> Genre => genreFilter.Current;
|
||||
|
||||
public Bindable<BeatmapSearchLanguage> Language => languageFilter.Current;
|
||||
|
||||
public BeatmapSetInfo BeatmapSet
|
||||
{
|
||||
set
|
||||
@ -46,6 +48,7 @@ namespace osu.Game.Overlays.BeatmapListing
|
||||
private readonly BeatmapSearchRulesetFilterRow modeFilter;
|
||||
private readonly BeatmapSearchFilterRow<BeatmapSearchCategory> categoryFilter;
|
||||
private readonly BeatmapSearchSmallFilterRow<BeatmapSearchGenre> genreFilter;
|
||||
private readonly BeatmapSearchSmallFilterRow<BeatmapSearchLanguage> languageFilter;
|
||||
|
||||
private readonly Box background;
|
||||
private readonly UpdateableBeatmapSetCover beatmapCover;
|
||||
@ -102,6 +105,7 @@ namespace osu.Game.Overlays.BeatmapListing
|
||||
modeFilter = new BeatmapSearchRulesetFilterRow(),
|
||||
categoryFilter = new BeatmapSearchFilterRow<BeatmapSearchCategory>(@"Categories"),
|
||||
genreFilter = new BeatmapSearchSmallFilterRow<BeatmapSearchGenre>(@"Genre"),
|
||||
languageFilter = new BeatmapSearchSmallFilterRow<BeatmapSearchLanguage>(@"Language"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -155,6 +155,7 @@ namespace osu.Game.Overlays
|
||||
searchSection.Ruleset.BindValueChanged(_ => queueUpdateSearch());
|
||||
searchSection.Category.BindValueChanged(_ => queueUpdateSearch());
|
||||
searchSection.Genre.BindValueChanged(_ => queueUpdateSearch());
|
||||
searchSection.Language.BindValueChanged(_ => queueUpdateSearch());
|
||||
sortCriteria.BindValueChanged(_ => queueUpdateSearch());
|
||||
sortDirection.BindValueChanged(_ => queueUpdateSearch());
|
||||
}
|
||||
@ -185,12 +186,26 @@ namespace osu.Game.Overlays
|
||||
Show();
|
||||
}
|
||||
|
||||
public void ShowLanguage(BeatmapSearchLanguage language)
|
||||
{
|
||||
var currentLanguage = searchSection.Language.Value;
|
||||
|
||||
if (currentLanguage != language)
|
||||
{
|
||||
setDefaultSearchValues();
|
||||
searchSection.Language.Value = language;
|
||||
}
|
||||
|
||||
Show();
|
||||
}
|
||||
|
||||
private void setDefaultSearchValues()
|
||||
{
|
||||
searchSection.Query.Value = string.Empty;
|
||||
searchSection.Ruleset.Value = new RulesetInfo { Name = @"Any" };
|
||||
searchSection.Category.Value = BeatmapSearchCategory.Leaderboard;
|
||||
searchSection.Genre.Value = BeatmapSearchGenre.Any;
|
||||
searchSection.Language.Value = BeatmapSearchLanguage.Any;
|
||||
}
|
||||
|
||||
private ScheduledDelegate queryChangedDebounce;
|
||||
@ -224,7 +239,8 @@ namespace osu.Game.Overlays
|
||||
searchSection.Category.Value,
|
||||
sortControl.Current.Value,
|
||||
sortControl.SortDirection.Value,
|
||||
searchSection.Genre.Value);
|
||||
searchSection.Genre.Value,
|
||||
searchSection.Language.Value);
|
||||
|
||||
getSetsRequest.Success += response => Schedule(() => recreatePanels(response));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user