1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-19 13:02:54 +08:00

Merge pull request #9563 from EVAST9919/rankings-spotlights-filter

Add filtering by friends to spotlights in RankingsOverlay
This commit is contained in:
Dan Balasescu 2020-07-15 16:41:44 +09:00 committed by GitHub
commit ed38b589bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 70 additions and 35 deletions

View File

@ -15,6 +15,7 @@ using osu.Game.Rulesets.Catch;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osu.Game.Overlays; using osu.Game.Overlays;
using osu.Game.Overlays.Rankings;
namespace osu.Game.Tests.Visual.Online namespace osu.Game.Tests.Visual.Online
{ {
@ -105,7 +106,7 @@ namespace osu.Game.Tests.Visual.Online
{ {
onLoadStarted(); onLoadStarted();
request = new GetSpotlightRankingsRequest(ruleset, spotlight); request = new GetSpotlightRankingsRequest(ruleset, spotlight, RankingsSortCriteria.All);
((GetSpotlightRankingsRequest)request).Success += rankings => Schedule(() => ((GetSpotlightRankingsRequest)request).Success += rankings => Schedule(() =>
{ {
var table = new ScoresTable(1, rankings.Users); var table = new ScoresTable(1, rankings.Users);

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using osu.Framework.IO.Network; using osu.Framework.IO.Network;
using osu.Game.Overlays.Rankings;
using osu.Game.Rulesets; using osu.Game.Rulesets;
namespace osu.Game.Online.API.Requests namespace osu.Game.Online.API.Requests
@ -9,11 +10,13 @@ namespace osu.Game.Online.API.Requests
public class GetSpotlightRankingsRequest : GetRankingsRequest<GetSpotlightRankingsResponse> public class GetSpotlightRankingsRequest : GetRankingsRequest<GetSpotlightRankingsResponse>
{ {
private readonly int spotlight; private readonly int spotlight;
private readonly RankingsSortCriteria sort;
public GetSpotlightRankingsRequest(RulesetInfo ruleset, int spotlight) public GetSpotlightRankingsRequest(RulesetInfo ruleset, int spotlight, RankingsSortCriteria sort)
: base(ruleset, 1) : base(ruleset, 1)
{ {
this.spotlight = spotlight; this.spotlight = spotlight;
this.sort = sort;
} }
protected override WebRequest CreateWebRequest() protected override WebRequest CreateWebRequest()
@ -21,6 +24,7 @@ namespace osu.Game.Online.API.Requests
var req = base.CreateWebRequest(); var req = base.CreateWebRequest();
req.AddParameter("spotlight", spotlight.ToString()); req.AddParameter("spotlight", spotlight.ToString());
req.AddParameter("filter", sort.ToString().ToLower());
return req; return req;
} }

View File

@ -22,10 +22,8 @@ namespace osu.Game.Overlays.Rankings
{ {
private const int duration = 300; private const int duration = 300;
private readonly Box background;
private readonly SpotlightsDropdown dropdown;
private readonly BindableWithCurrent<APISpotlight> current = new BindableWithCurrent<APISpotlight>(); private readonly BindableWithCurrent<APISpotlight> current = new BindableWithCurrent<APISpotlight>();
public readonly Bindable<RankingsSortCriteria> Sort = new Bindable<RankingsSortCriteria>();
public Bindable<APISpotlight> Current public Bindable<APISpotlight> Current
{ {
@ -41,19 +39,22 @@ namespace osu.Game.Overlays.Rankings
protected override bool StartHidden => true; protected override bool StartHidden => true;
private readonly Box background;
private readonly Container content;
private readonly SpotlightsDropdown dropdown;
private readonly InfoColumn startDateColumn; private readonly InfoColumn startDateColumn;
private readonly InfoColumn endDateColumn; private readonly InfoColumn endDateColumn;
private readonly InfoColumn mapCountColumn; private readonly InfoColumn mapCountColumn;
private readonly InfoColumn participantsColumn; private readonly InfoColumn participantsColumn;
private readonly Container content;
public SpotlightSelector() public SpotlightSelector()
{ {
RelativeSizeAxes = Axes.X; RelativeSizeAxes = Axes.X;
Height = 100; AutoSizeAxes = Axes.Y;
Add(content = new Container Add(content = new Container
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Children = new Drawable[] Children = new Drawable[]
{ {
background = new Box background = new Box
@ -62,25 +63,40 @@ namespace osu.Game.Overlays.Rankings
}, },
new Container new Container
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.X,
Padding = new MarginPadding { Horizontal = UserProfileOverlay.CONTENT_X_MARGIN, Vertical = 10 }, AutoSizeAxes = Axes.Y,
Padding = new MarginPadding { Horizontal = UserProfileOverlay.CONTENT_X_MARGIN },
Child = new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
Children = new Drawable[] Children = new Drawable[]
{ {
dropdown = new SpotlightsDropdown new Container
{ {
Anchor = Anchor.TopCentre, Margin = new MarginPadding { Vertical = 20 },
Origin = Anchor.TopCentre,
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
Current = Current, Height = 40,
Depth = -float.MaxValue Depth = -float.MaxValue,
Child = dropdown = new SpotlightsDropdown
{
RelativeSizeAxes = Axes.X,
Current = Current
}
}, },
new Container
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Children = new Drawable[]
{
new FillFlowContainer new FillFlowContainer
{ {
Anchor = Anchor.BottomRight,
Origin = Anchor.BottomRight,
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal, Direction = FillDirection.Horizontal,
Spacing = new Vector2(15, 0), Spacing = new Vector2(10, 0),
Margin = new MarginPadding { Bottom = 5 },
Children = new Drawable[] Children = new Drawable[]
{ {
startDateColumn = new InfoColumn(@"Start Date"), startDateColumn = new InfoColumn(@"Start Date"),
@ -88,6 +104,15 @@ namespace osu.Game.Overlays.Rankings
mapCountColumn = new InfoColumn(@"Map Count"), mapCountColumn = new InfoColumn(@"Map Count"),
participantsColumn = new InfoColumn(@"Participants") participantsColumn = new InfoColumn(@"Participants")
} }
},
new RankingsSortTabControl
{
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
Current = Sort
}
}
}
} }
} }
} }
@ -128,12 +153,13 @@ namespace osu.Game.Overlays.Rankings
{ {
AutoSizeAxes = Axes.Both; AutoSizeAxes = Axes.Both;
Direction = FillDirection.Vertical; Direction = FillDirection.Vertical;
Margin = new MarginPadding { Vertical = 10 };
Children = new Drawable[] Children = new Drawable[]
{ {
new OsuSpriteText new OsuSpriteText
{ {
Text = name, Text = name,
Font = OsuFont.GetFont(size: 10), Font = OsuFont.GetFont(size: 10, weight: FontWeight.Regular),
}, },
new Container new Container
{ {
@ -143,7 +169,7 @@ namespace osu.Game.Overlays.Rankings
{ {
Anchor = Anchor.BottomLeft, Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft, Origin = Anchor.BottomLeft,
Font = OsuFont.GetFont(size: 18, weight: FontWeight.Light), Font = OsuFont.GetFont(size: 20, weight: FontWeight.Light),
} }
} }
}; };

View File

@ -24,6 +24,7 @@ namespace osu.Game.Overlays.Rankings
public readonly Bindable<RulesetInfo> Ruleset = new Bindable<RulesetInfo>(); public readonly Bindable<RulesetInfo> Ruleset = new Bindable<RulesetInfo>();
private readonly Bindable<APISpotlight> selectedSpotlight = new Bindable<APISpotlight>(); private readonly Bindable<APISpotlight> selectedSpotlight = new Bindable<APISpotlight>();
private readonly Bindable<RankingsSortCriteria> sort = new Bindable<RankingsSortCriteria>();
[Resolved] [Resolved]
private IAPIProvider api { get; set; } private IAPIProvider api { get; set; }
@ -72,6 +73,8 @@ namespace osu.Game.Overlays.Rankings
} }
} }
}; };
sort.BindTo(selector.Sort);
} }
protected override void LoadComplete() protected override void LoadComplete()
@ -80,7 +83,8 @@ namespace osu.Game.Overlays.Rankings
selector.Show(); selector.Show();
selectedSpotlight.BindValueChanged(onSpotlightChanged); selectedSpotlight.BindValueChanged(_ => onSpotlightChanged());
sort.BindValueChanged(_ => onSpotlightChanged());
Ruleset.BindValueChanged(onRulesetChanged); Ruleset.BindValueChanged(onRulesetChanged);
getSpotlights(); getSpotlights();
@ -101,14 +105,14 @@ namespace osu.Game.Overlays.Rankings
selectedSpotlight.TriggerChange(); selectedSpotlight.TriggerChange();
} }
private void onSpotlightChanged(ValueChangedEvent<APISpotlight> spotlight) private void onSpotlightChanged()
{ {
loading.Show(); loading.Show();
cancellationToken?.Cancel(); cancellationToken?.Cancel();
getRankingsRequest?.Cancel(); getRankingsRequest?.Cancel();
getRankingsRequest = new GetSpotlightRankingsRequest(Ruleset.Value, spotlight.NewValue.Id); getRankingsRequest = new GetSpotlightRankingsRequest(Ruleset.Value, selectedSpotlight.Value.Id, sort.Value);
getRankingsRequest.Success += onSuccess; getRankingsRequest.Success += onSuccess;
api.Queue(getRankingsRequest); api.Queue(getRankingsRequest);
} }