filter beatmaps by star range

This commit is contained in:
Unknown
2018-10-10 16:46:02 +02:00
parent 7137c01352
commit 11dad7bf74
4 changed files with 81 additions and 16 deletions

View File

@ -26,6 +26,12 @@ namespace osu.Game.Screens.Select.Carousel
bool match = criteria.Ruleset == null || Beatmap.RulesetID == criteria.Ruleset.ID || Beatmap.RulesetID == 0 && criteria.Ruleset.ID > 0 && criteria.AllowConvertedBeatmaps;
if(criteria.DisplayStarsMinimum.HasValue)
match &= Beatmap.StarDifficulty >= criteria.DisplayStarsMinimum;
if (criteria.DisplayStarsMaximum.HasValue)
match &= Beatmap.StarDifficulty <= criteria.DisplayStarsMaximum;
if (!string.IsNullOrEmpty(criteria.SearchText))
match &=
Beatmap.Metadata.SearchableTerms.Any(term => term.IndexOf(criteria.SearchText, StringComparison.InvariantCultureIgnoreCase) >= 0) ||

View File

@ -32,14 +32,13 @@ namespace osu.Game.Screens.Select
public SortMode Sort
{
get { return sort; }
get => sort;
set
{
if (sort != value)
{
sort = value;
FilterChanged?.Invoke(CreateCriteria());
}
if (sort == value) return;
sort = value;
FilterChanged?.Invoke(CreateCriteria());
}
}
@ -47,14 +46,13 @@ namespace osu.Game.Screens.Select
public GroupMode Group
{
get { return group; }
get => group;
set
{
if (group != value)
{
group = value;
FilterChanged?.Invoke(CreateCriteria());
}
if (group == value) return;
group = value;
FilterChanged?.Invoke(CreateCriteria());
}
}
@ -64,7 +62,9 @@ namespace osu.Game.Screens.Select
Sort = sort,
SearchText = searchTextBox.Text,
AllowConvertedBeatmaps = showConverted,
Ruleset = ruleset.Value
Ruleset = ruleset.Value,
DisplayStarsMinimum = minimumStars,
DisplayStarsMaximum = maximumStars,
};
public Action Exit;
@ -168,7 +168,9 @@ namespace osu.Game.Screens.Select
private readonly IBindable<RulesetInfo> ruleset = new Bindable<RulesetInfo>();
private Bindable<bool> showConverted;
private readonly Bindable<bool> showConverted = new Bindable<bool>();
private readonly Bindable<double> minimumStars = new Bindable<double>();
private readonly Bindable<double> maximumStars = new Bindable<double>();
public readonly Box Background;
@ -177,8 +179,14 @@ namespace osu.Game.Screens.Select
{
sortTabs.AccentColour = colours.GreenLight;
showConverted = config.GetBindable<bool>(OsuSetting.ShowConvertedBeatmaps);
showConverted.ValueChanged += val => updateCriteria();
config.BindWith(OsuSetting.ShowConvertedBeatmaps, showConverted);
showConverted.ValueChanged += _ => updateCriteria();
config.BindWith(OsuSetting.DisplayStarsMinimum, minimumStars);
minimumStars.ValueChanged += _ => updateCriteria();
config.BindWith(OsuSetting.DisplayStarsMaximum, maximumStars);
maximumStars.ValueChanged += _ => updateCriteria();
ruleset.BindTo(parentRuleset);
ruleset.BindValueChanged(_ => updateCriteria(), true);

View File

@ -13,5 +13,7 @@ namespace osu.Game.Screens.Select
public string SearchText;
public RulesetInfo Ruleset;
public bool AllowConvertedBeatmaps;
public double? DisplayStarsMinimum;
public double? DisplayStarsMaximum;
}
}