mirror of
https://github.com/ppy/osu.git
synced 2025-03-15 22:19:31 +08:00
Implement filtering by rank achieved
This commit is contained in:
parent
1710b396e7
commit
008d1d697c
@ -29,6 +29,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
OsuSpriteText genre;
|
||||
OsuSpriteText language;
|
||||
OsuSpriteText extra;
|
||||
OsuSpriteText ranks;
|
||||
OsuSpriteText played;
|
||||
|
||||
Add(control = new BeatmapListingSearchControl
|
||||
@ -50,6 +51,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
genre = new OsuSpriteText(),
|
||||
language = new OsuSpriteText(),
|
||||
extra = new OsuSpriteText(),
|
||||
ranks = new OsuSpriteText(),
|
||||
played = new OsuSpriteText()
|
||||
}
|
||||
});
|
||||
@ -60,6 +62,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
control.Genre.BindValueChanged(g => genre.Text = $"Genre: {g.NewValue}", true);
|
||||
control.Language.BindValueChanged(l => language.Text = $"Language: {l.NewValue}", true);
|
||||
control.Extra.BindValueChanged(e => extra.Text = $"Extra: {(e.NewValue == null ? "" : string.Join(".", e.NewValue.Select(i => i.ToString().ToLowerInvariant())))}", true);
|
||||
control.Ranks.BindValueChanged(r => ranks.Text = $"Ranks: {(r.NewValue == null ? "" : string.Join(".", r.NewValue.Select(i => i.ToString())))}", true);
|
||||
control.Played.BindValueChanged(p => played.Text = $"Played: {p.NewValue}", true);
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,8 @@ namespace osu.Game.Online.API.Requests
|
||||
|
||||
public SearchPlayed Played { get; }
|
||||
|
||||
public List<SearchRank> Ranks { get; }
|
||||
|
||||
private readonly string query;
|
||||
private readonly RulesetInfo ruleset;
|
||||
private readonly Cursor cursor;
|
||||
@ -43,6 +45,7 @@ namespace osu.Game.Online.API.Requests
|
||||
SearchGenre genre = SearchGenre.Any,
|
||||
SearchLanguage language = SearchLanguage.Any,
|
||||
List<SearchExtra> extra = null,
|
||||
List<SearchRank> ranks = null,
|
||||
SearchPlayed played = SearchPlayed.Any)
|
||||
{
|
||||
this.query = string.IsNullOrEmpty(query) ? string.Empty : System.Uri.EscapeDataString(query);
|
||||
@ -55,6 +58,7 @@ namespace osu.Game.Online.API.Requests
|
||||
Genre = genre;
|
||||
Language = language;
|
||||
Extra = extra;
|
||||
Ranks = ranks;
|
||||
Played = played;
|
||||
}
|
||||
|
||||
@ -79,6 +83,9 @@ namespace osu.Game.Online.API.Requests
|
||||
if (Extra != null && Extra.Any())
|
||||
req.AddParameter("e", string.Join(".", Extra.Select(e => e.ToString().ToLowerInvariant())));
|
||||
|
||||
if (Ranks != null && Ranks.Any())
|
||||
req.AddParameter("r", string.Join(".", Ranks.Select(r => r.ToString())));
|
||||
|
||||
if (Played != SearchPlayed.Any)
|
||||
req.AddParameter("played", Played.ToString().ToLowerInvariant());
|
||||
|
||||
|
@ -131,6 +131,7 @@ namespace osu.Game.Overlays.BeatmapListing
|
||||
searchControl.Genre.BindValueChanged(_ => queueUpdateSearch());
|
||||
searchControl.Language.BindValueChanged(_ => queueUpdateSearch());
|
||||
searchControl.Extra.BindValueChanged(_ => queueUpdateSearch());
|
||||
searchControl.Ranks.BindValueChanged(_ => queueUpdateSearch());
|
||||
searchControl.Played.BindValueChanged(_ => queueUpdateSearch());
|
||||
|
||||
sortCriteria.BindValueChanged(_ => queueUpdateSearch());
|
||||
@ -183,6 +184,7 @@ namespace osu.Game.Overlays.BeatmapListing
|
||||
searchControl.Genre.Value,
|
||||
searchControl.Language.Value,
|
||||
searchControl.Extra.Value,
|
||||
searchControl.Ranks.Value,
|
||||
searchControl.Played.Value);
|
||||
|
||||
getSetsRequest.Success += response =>
|
||||
|
@ -31,6 +31,8 @@ namespace osu.Game.Overlays.BeatmapListing
|
||||
|
||||
public Bindable<List<SearchExtra>> Extra => extraFilter.Current;
|
||||
|
||||
public Bindable<List<SearchRank>> Ranks => ranksFilter.Current;
|
||||
|
||||
public Bindable<SearchPlayed> Played => playedFilter.Current;
|
||||
|
||||
public BeatmapSetInfo BeatmapSet
|
||||
@ -54,6 +56,7 @@ namespace osu.Game.Overlays.BeatmapListing
|
||||
private readonly BeatmapSearchFilterRow<SearchGenre> genreFilter;
|
||||
private readonly BeatmapSearchFilterRow<SearchLanguage> languageFilter;
|
||||
private readonly BeatmapSearchExtraFilterRow extraFilter;
|
||||
private readonly BeatmapSearchRankFilterRow ranksFilter;
|
||||
private readonly BeatmapSearchFilterRow<SearchPlayed> playedFilter;
|
||||
|
||||
private readonly Box background;
|
||||
@ -113,6 +116,7 @@ namespace osu.Game.Overlays.BeatmapListing
|
||||
genreFilter = new BeatmapSearchFilterRow<SearchGenre>(@"Genre"),
|
||||
languageFilter = new BeatmapSearchFilterRow<SearchLanguage>(@"Language"),
|
||||
extraFilter = new BeatmapSearchExtraFilterRow(),
|
||||
ranksFilter = new BeatmapSearchRankFilterRow(),
|
||||
playedFilter = new BeatmapSearchFilterRow<SearchPlayed>(@"Played")
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ namespace osu.Game.Overlays.BeatmapListing
|
||||
|
||||
private class ExtraFilter : MultipleSelectionFilter
|
||||
{
|
||||
protected override MultipleSelectionFilterTabItem[] CreateItems() => new[]
|
||||
protected override MultipleSelectionFilterTabItem[] CreateItems() => new MultipleSelectionFilterTabItem[]
|
||||
{
|
||||
new ExtraFilterTabItem(SearchExtra.Video),
|
||||
new ExtraFilterTabItem(SearchExtra.Storyboard)
|
||||
|
@ -14,7 +14,7 @@ namespace osu.Game.Overlays.BeatmapListing
|
||||
{
|
||||
public abstract class BeatmapSearchMultipleSelectionFilterRow<T> : BeatmapSearchFilterRow<List<T>>
|
||||
{
|
||||
public BeatmapSearchMultipleSelectionFilterRow(string headerName)
|
||||
protected BeatmapSearchMultipleSelectionFilterRow(string headerName)
|
||||
: base(headerName)
|
||||
{
|
||||
}
|
||||
@ -33,7 +33,7 @@ namespace osu.Game.Overlays.BeatmapListing
|
||||
set => current.Current = value;
|
||||
}
|
||||
|
||||
public MultipleSelectionFilter()
|
||||
protected MultipleSelectionFilter()
|
||||
{
|
||||
Anchor = Anchor.BottomLeft;
|
||||
Origin = Anchor.BottomLeft;
|
||||
|
@ -0,0 +1,35 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using osu.Framework.Extensions;
|
||||
|
||||
namespace osu.Game.Overlays.BeatmapListing
|
||||
{
|
||||
public class BeatmapSearchRankFilterRow : BeatmapSearchMultipleSelectionFilterRow<SearchRank>
|
||||
{
|
||||
public BeatmapSearchRankFilterRow()
|
||||
: base("Rank Achieved")
|
||||
{
|
||||
}
|
||||
|
||||
protected override MultipleSelectionFilter CreateMultipleSelectionFilter() => new RankFilter();
|
||||
|
||||
private class RankFilter : MultipleSelectionFilter
|
||||
{
|
||||
protected override MultipleSelectionFilterTabItem[] CreateItems()
|
||||
=> ((SearchRank[])Enum.GetValues(typeof(SearchRank))).Select(v => new RankFilterTabItem(v)).ToArray<MultipleSelectionFilterTabItem>();
|
||||
}
|
||||
|
||||
private class RankFilterTabItem : MultipleSelectionFilterTabItem
|
||||
{
|
||||
public RankFilterTabItem(SearchRank value)
|
||||
: base(value)
|
||||
{
|
||||
}
|
||||
|
||||
protected override string CreateText(SearchRank value) => $@"{value.GetDescription() ?? value.ToString()}";
|
||||
}
|
||||
}
|
||||
}
|
@ -16,8 +16,6 @@ namespace osu.Game.Overlays.BeatmapListing
|
||||
{
|
||||
public class FilterTabItem<T> : TabItem<T>
|
||||
{
|
||||
protected virtual float TextSize => 13;
|
||||
|
||||
[Resolved]
|
||||
private OverlayColourProvider colourProvider { get; set; }
|
||||
|
||||
@ -33,7 +31,7 @@ namespace osu.Game.Overlays.BeatmapListing
|
||||
{
|
||||
text = new OsuSpriteText
|
||||
{
|
||||
Font = OsuFont.GetFont(size: TextSize, weight: FontWeight.Regular),
|
||||
Font = OsuFont.GetFont(size: 13, weight: FontWeight.Regular),
|
||||
Text = CreateText(value)
|
||||
},
|
||||
new HoverClickSounds()
|
||||
@ -67,7 +65,11 @@ namespace osu.Game.Overlays.BeatmapListing
|
||||
|
||||
protected override void OnDeactivated() => updateState();
|
||||
|
||||
private void updateState() => text.FadeColour(Active.Value ? Color4.White : getStateColour(), 200, Easing.OutQuint);
|
||||
private void updateState()
|
||||
{
|
||||
text.FadeColour(Active.Value ? Color4.White : getStateColour(), 200, Easing.OutQuint);
|
||||
text.Font = text.Font.With(weight: Active.Value ? FontWeight.SemiBold : FontWeight.Regular);
|
||||
}
|
||||
|
||||
private Color4 getStateColour() => IsHovered ? colourProvider.Light1 : colourProvider.Light3;
|
||||
}
|
||||
|
24
osu.Game/Overlays/BeatmapListing/SearchRank.cs
Normal file
24
osu.Game/Overlays/BeatmapListing/SearchRank.cs
Normal file
@ -0,0 +1,24 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace osu.Game.Overlays.BeatmapListing
|
||||
{
|
||||
public enum SearchRank
|
||||
{
|
||||
[Description(@"Silver SS")]
|
||||
XH,
|
||||
|
||||
[Description(@"SS")]
|
||||
X,
|
||||
|
||||
[Description(@"Silver S")]
|
||||
SH,
|
||||
S,
|
||||
A,
|
||||
B,
|
||||
C,
|
||||
D
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user