mirror of
https://github.com/osukey/osukey.git
synced 2025-08-03 14:46:38 +09:00
Implement Language filter
This commit is contained in:
@ -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
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user