mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 02:22:56 +08:00
Request sorting, fix VS Code's "refactoring"
This commit is contained in:
parent
3ed740676f
commit
f7f4f5e155
@ -5,6 +5,8 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Overlays.Direct;
|
||||
|
||||
namespace osu.Game.Online.API.Requests
|
||||
{
|
||||
@ -12,14 +14,21 @@ namespace osu.Game.Online.API.Requests
|
||||
{
|
||||
private readonly string query;
|
||||
private readonly RankStatus rankStatus;
|
||||
private readonly DirectSortCriteria sortCriteria;
|
||||
private readonly SortDirection direction;
|
||||
private string directionString => direction == SortDirection.Descending ? @"desc" : @"asc";
|
||||
|
||||
public GetBeatmapSetsRequest(string query, RankStatus rankStatus = RankStatus.Any)
|
||||
public GetBeatmapSetsRequest(string query, RankStatus rankStatus = RankStatus.Any, DirectSortCriteria sortCriteria = DirectSortCriteria.Ranked, SortDirection direction = SortDirection.Descending)
|
||||
{
|
||||
this.query = System.Uri.EscapeDataString(query);
|
||||
this.rankStatus = rankStatus;
|
||||
this.sortCriteria = sortCriteria;
|
||||
this.direction = direction;
|
||||
|
||||
System.Console.WriteLine(Target);
|
||||
}
|
||||
|
||||
protected override string Target => $@"beatmapsets/search?q={query}&s={(int)rankStatus}";
|
||||
protected override string Target => $@"beatmapsets/search?q={query}&s={(int)rankStatus}&sort={sortCriteria.ToString().ToLower()}_{directionString}";
|
||||
}
|
||||
|
||||
public class GetBeatmapSetsResponse : BeatmapMetadata
|
||||
|
@ -18,7 +18,7 @@ namespace osu.Game.Overlays.Direct
|
||||
private FillFlowContainer<RulesetToggleButton> modeButtons;
|
||||
|
||||
protected override Color4 BackgroundColour => OsuColour.FromHex(@"384552");
|
||||
protected override DirectSortCriteria DefaultTab => DirectSortCriteria.Title;
|
||||
protected override DirectSortCriteria DefaultTab => DirectSortCriteria.Ranked;
|
||||
protected override Drawable CreateSupplementaryControls()
|
||||
{
|
||||
modeButtons = new FillFlowContainer<RulesetToggleButton>
|
||||
|
@ -16,9 +16,9 @@ using osu.Game.Overlays.Direct;
|
||||
using osu.Game.Overlays.SearchableList;
|
||||
using OpenTK.Graphics;
|
||||
|
||||
namespace osu.Game.Overlaysi
|
||||
namespace osu.Game.Overlays
|
||||
{
|
||||
public class DirectOverlay : SearchableListOverlay<DirectTab, DirectSortCritera, RankStatus>
|
||||
public class DirectOverlay : SearchableListOverlay<DirectTab, DirectSortCriteria, RankStatus>
|
||||
{
|
||||
private const float panel_padding = 10f;
|
||||
|
||||
@ -29,12 +29,12 @@ namespace osu.Game.Overlaysi
|
||||
private readonly OsuSpriteText resultCountsText;
|
||||
private readonly FillFlowContainer<DirectPanel> panels;
|
||||
|
||||
protected override Color4 BackgroundColour => OsuColour.FromHexi(@"485e74");
|
||||
protected override Color4 BackgroundColour => OsuColour.FromHex(@"485e74");
|
||||
protected override Color4 TrianglesColourLight => OsuColour.FromHex(@"465b71");
|
||||
protected override Color4 TrianglesColourDark => OsuColour.FromHex(@"3f5265");
|
||||
|
||||
protected override SearchableListHeader<DirectTab> CreateHeader() => new Header();
|
||||
protected override SearchableListFilterControl<DirectSortCritera, RankStatus> CreateFilterControl() => new FilterControl();
|
||||
protected override SearchableListFilterControl<DirectSortCriteria, RankStatus> CreateFilterControl() => new FilterControl();
|
||||
|
||||
private IEnumerable<BeatmapSetInfo> beatmapSets;
|
||||
public IEnumerable<BeatmapSetInfo> BeatmapSets
|
||||
@ -117,6 +117,7 @@ namespace osu.Game.Overlaysi
|
||||
Header.Tabs.Current.ValueChanged += tab => { if (tab != DirectTab.Search) Filter.Search.Text = string.Empty; };
|
||||
Filter.Search.Current.ValueChanged += text => { if (text != string.Empty) Header.Tabs.Current.Value = DirectTab.Search; };
|
||||
Filter.Search.OnCommit = (sender, text) => updateSets();
|
||||
Filter.Tabs.Current.ValueChanged += sortCriteria => updateSets();
|
||||
Filter.DisplayStyleControl.DisplayStyle.ValueChanged += recreatePanels;
|
||||
Filter.DisplayStyleControl.Dropdown.Current.ValueChanged += rankStatus => updateSets();
|
||||
|
||||
@ -162,7 +163,7 @@ namespace osu.Game.Overlaysi
|
||||
|
||||
if (api == null || Filter.Search.Text == string.Empty) return;
|
||||
|
||||
getSetsRequest = new GetBeatmapSetsRequest(Filter.Search.Text, Filter.DisplayStyleControl.Dropdown.Current.Value);
|
||||
getSetsRequest = new GetBeatmapSetsRequest(Filter.Search.Text, Filter.DisplayStyleControl.Dropdown.Current.Value, Filter.Tabs.Current.Value); //todo: sort direction
|
||||
getSetsRequest.Success += r => BeatmapSets = r?.Select(response => response.ToSetInfo(rulesets));
|
||||
api.Queue(getSetsRequest);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user