mirror of
https://github.com/osukey/osukey.git
synced 2025-06-05 12:57:39 +09:00
Use existing ScoreRank for rank filter
This commit is contained in:
parent
4f6081c7f3
commit
5c2c5f2000
@ -8,6 +8,7 @@ using osu.Game.Extensions;
|
|||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
using osu.Game.Overlays.BeatmapListing;
|
using osu.Game.Overlays.BeatmapListing;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
|
using osu.Game.Scoring;
|
||||||
|
|
||||||
namespace osu.Game.Online.API.Requests
|
namespace osu.Game.Online.API.Requests
|
||||||
{
|
{
|
||||||
@ -27,7 +28,7 @@ namespace osu.Game.Online.API.Requests
|
|||||||
|
|
||||||
public SearchPlayed Played { get; }
|
public SearchPlayed Played { get; }
|
||||||
|
|
||||||
public IReadOnlyCollection<SearchRank> Ranks { get; }
|
public IReadOnlyCollection<ScoreRank> Ranks { get; }
|
||||||
|
|
||||||
private readonly string query;
|
private readonly string query;
|
||||||
private readonly RulesetInfo ruleset;
|
private readonly RulesetInfo ruleset;
|
||||||
@ -45,7 +46,7 @@ namespace osu.Game.Online.API.Requests
|
|||||||
SearchGenre genre = SearchGenre.Any,
|
SearchGenre genre = SearchGenre.Any,
|
||||||
SearchLanguage language = SearchLanguage.Any,
|
SearchLanguage language = SearchLanguage.Any,
|
||||||
IReadOnlyCollection<SearchExtra> extra = null,
|
IReadOnlyCollection<SearchExtra> extra = null,
|
||||||
IReadOnlyCollection<SearchRank> ranks = null,
|
IReadOnlyCollection<ScoreRank> ranks = null,
|
||||||
SearchPlayed played = SearchPlayed.Any)
|
SearchPlayed played = SearchPlayed.Any)
|
||||||
{
|
{
|
||||||
this.query = string.IsNullOrEmpty(query) ? string.Empty : System.Uri.EscapeDataString(query);
|
this.query = string.IsNullOrEmpty(query) ? string.Empty : System.Uri.EscapeDataString(query);
|
||||||
|
@ -13,6 +13,7 @@ using osu.Game.Graphics.Containers;
|
|||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
|
using osu.Game.Scoring;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.BeatmapListing
|
namespace osu.Game.Overlays.BeatmapListing
|
||||||
{
|
{
|
||||||
@ -30,7 +31,7 @@ namespace osu.Game.Overlays.BeatmapListing
|
|||||||
|
|
||||||
public BindableList<SearchExtra> Extra => extraFilter.Current;
|
public BindableList<SearchExtra> Extra => extraFilter.Current;
|
||||||
|
|
||||||
public BindableList<SearchRank> Ranks => ranksFilter.Current;
|
public BindableList<ScoreRank> Ranks => ranksFilter.Current;
|
||||||
|
|
||||||
public Bindable<SearchPlayed> Played => playedFilter.Current;
|
public Bindable<SearchPlayed> Played => playedFilter.Current;
|
||||||
|
|
||||||
@ -55,7 +56,7 @@ namespace osu.Game.Overlays.BeatmapListing
|
|||||||
private readonly BeatmapSearchFilterRow<SearchGenre> genreFilter;
|
private readonly BeatmapSearchFilterRow<SearchGenre> genreFilter;
|
||||||
private readonly BeatmapSearchFilterRow<SearchLanguage> languageFilter;
|
private readonly BeatmapSearchFilterRow<SearchLanguage> languageFilter;
|
||||||
private readonly BeatmapSearchMultipleSelectionFilterRow<SearchExtra> extraFilter;
|
private readonly BeatmapSearchMultipleSelectionFilterRow<SearchExtra> extraFilter;
|
||||||
private readonly BeatmapSearchMultipleSelectionFilterRow<SearchRank> ranksFilter;
|
private readonly BeatmapSearchScoreFilterRow ranksFilter;
|
||||||
private readonly BeatmapSearchFilterRow<SearchPlayed> playedFilter;
|
private readonly BeatmapSearchFilterRow<SearchPlayed> playedFilter;
|
||||||
|
|
||||||
private readonly Box background;
|
private readonly Box background;
|
||||||
@ -115,7 +116,7 @@ namespace osu.Game.Overlays.BeatmapListing
|
|||||||
genreFilter = new BeatmapSearchFilterRow<SearchGenre>(@"Genre"),
|
genreFilter = new BeatmapSearchFilterRow<SearchGenre>(@"Genre"),
|
||||||
languageFilter = new BeatmapSearchFilterRow<SearchLanguage>(@"Language"),
|
languageFilter = new BeatmapSearchFilterRow<SearchLanguage>(@"Language"),
|
||||||
extraFilter = new BeatmapSearchMultipleSelectionFilterRow<SearchExtra>(@"Extra"),
|
extraFilter = new BeatmapSearchMultipleSelectionFilterRow<SearchExtra>(@"Extra"),
|
||||||
ranksFilter = new BeatmapSearchMultipleSelectionFilterRow<SearchRank>(@"Rank Achieved"),
|
ranksFilter = new BeatmapSearchScoreFilterRow(),
|
||||||
playedFilter = new BeatmapSearchFilterRow<SearchPlayed>(@"Played")
|
playedFilter = new BeatmapSearchFilterRow<SearchPlayed>(@"Played")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,9 +24,11 @@ namespace osu.Game.Overlays.BeatmapListing
|
|||||||
Current.BindTo(filter.Current);
|
Current.BindTo(filter.Current);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override Drawable CreateFilter() => filter = new MultipleSelectionFilter();
|
protected override Drawable CreateFilter() => filter = CreateMultipleSelectionFilter();
|
||||||
|
|
||||||
private class MultipleSelectionFilter : FillFlowContainer<MultipleSelectionFilterTabItem>
|
protected virtual MultipleSelectionFilter CreateMultipleSelectionFilter() => new MultipleSelectionFilter();
|
||||||
|
|
||||||
|
protected class MultipleSelectionFilter : FillFlowContainer<MultipleSelectionFilterTabItem>
|
||||||
{
|
{
|
||||||
public readonly BindableList<T> Current = new BindableList<T>();
|
public readonly BindableList<T> Current = new BindableList<T>();
|
||||||
|
|
||||||
@ -38,12 +40,16 @@ namespace osu.Game.Overlays.BeatmapListing
|
|||||||
Height = 15;
|
Height = 15;
|
||||||
Spacing = new Vector2(10, 0);
|
Spacing = new Vector2(10, 0);
|
||||||
|
|
||||||
((T[])Enum.GetValues(typeof(T))).ForEach(i => Add(new MultipleSelectionFilterTabItem(i)));
|
GetValues().ForEach(i => Add(CreateTabItem(i)));
|
||||||
|
|
||||||
foreach (var item in Children)
|
foreach (var item in Children)
|
||||||
item.Active.BindValueChanged(active => updateBindable(item.Value, active.NewValue));
|
item.Active.BindValueChanged(active => updateBindable(item.Value, active.NewValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected virtual T[] GetValues() => (T[])Enum.GetValues(typeof(T));
|
||||||
|
|
||||||
|
protected virtual MultipleSelectionFilterTabItem CreateTabItem(T value) => new MultipleSelectionFilterTabItem(value);
|
||||||
|
|
||||||
private void updateBindable(T value, bool active)
|
private void updateBindable(T value, bool active)
|
||||||
{
|
{
|
||||||
if (active)
|
if (active)
|
||||||
@ -53,7 +59,7 @@ namespace osu.Game.Overlays.BeatmapListing
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class MultipleSelectionFilterTabItem : FilterTabItem<T>
|
protected class MultipleSelectionFilterTabItem : FilterTabItem<T>
|
||||||
{
|
{
|
||||||
public MultipleSelectionFilterTabItem(T value)
|
public MultipleSelectionFilterTabItem(T value)
|
||||||
: base(value)
|
: base(value)
|
||||||
|
@ -0,0 +1,48 @@
|
|||||||
|
// 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.Linq;
|
||||||
|
using osu.Game.Scoring;
|
||||||
|
|
||||||
|
namespace osu.Game.Overlays.BeatmapListing
|
||||||
|
{
|
||||||
|
public class BeatmapSearchScoreFilterRow : BeatmapSearchMultipleSelectionFilterRow<ScoreRank>
|
||||||
|
{
|
||||||
|
public BeatmapSearchScoreFilterRow()
|
||||||
|
: base(@"Rank Achieved")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override MultipleSelectionFilter CreateMultipleSelectionFilter() => new RankFilter();
|
||||||
|
|
||||||
|
private class RankFilter : MultipleSelectionFilter
|
||||||
|
{
|
||||||
|
protected override MultipleSelectionFilterTabItem CreateTabItem(ScoreRank value) => new RankItem(value);
|
||||||
|
|
||||||
|
protected override ScoreRank[] GetValues() => base.GetValues().Reverse().ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
private class RankItem : MultipleSelectionFilterTabItem
|
||||||
|
{
|
||||||
|
public RankItem(ScoreRank value)
|
||||||
|
: base(value)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override string CreateText(ScoreRank value)
|
||||||
|
{
|
||||||
|
switch (value)
|
||||||
|
{
|
||||||
|
case ScoreRank.XH:
|
||||||
|
return @"Silver SS";
|
||||||
|
|
||||||
|
case ScoreRank.SH:
|
||||||
|
return @"Silver S";
|
||||||
|
|
||||||
|
default:
|
||||||
|
return base.CreateText(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -32,7 +32,7 @@ namespace osu.Game.Overlays.BeatmapListing
|
|||||||
text = new OsuSpriteText
|
text = new OsuSpriteText
|
||||||
{
|
{
|
||||||
Font = OsuFont.GetFont(size: 13, weight: FontWeight.Regular),
|
Font = OsuFont.GetFont(size: 13, weight: FontWeight.Regular),
|
||||||
Text = (value as Enum)?.GetDescription() ?? value.ToString()
|
Text = CreateText(value)
|
||||||
},
|
},
|
||||||
new HoverClickSounds()
|
new HoverClickSounds()
|
||||||
});
|
});
|
||||||
@ -63,6 +63,8 @@ namespace osu.Game.Overlays.BeatmapListing
|
|||||||
|
|
||||||
protected override void OnDeactivated() => updateState();
|
protected override void OnDeactivated() => updateState();
|
||||||
|
|
||||||
|
protected virtual string CreateText(T value) => (value as Enum)?.GetDescription() ?? value.ToString();
|
||||||
|
|
||||||
private void updateState()
|
private void updateState()
|
||||||
{
|
{
|
||||||
text.FadeColour(IsHovered ? colourProvider.Light1 : getStateColour(), 200, Easing.OutQuint);
|
text.FadeColour(IsHovered ? colourProvider.Light1 : getStateColour(), 200, Easing.OutQuint);
|
||||||
|
@ -1,24 +0,0 @@
|
|||||||
// 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