mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 21:07:33 +08:00
commit
52b66fdc16
@ -437,6 +437,53 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
AddAssert("Selection was random", () => eagerSelectedIDs.Count > 1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestFilteringByUserStarDifficulty()
|
||||
{
|
||||
BeatmapSetInfo set = null;
|
||||
|
||||
loadBeatmaps(new List<BeatmapSetInfo>());
|
||||
|
||||
AddStep("add mixed difficulty set", () =>
|
||||
{
|
||||
set = createTestBeatmapSet(1);
|
||||
set.Beatmaps.Clear();
|
||||
|
||||
for (int i = 1; i <= 15; i++)
|
||||
{
|
||||
set.Beatmaps.Add(new BeatmapInfo
|
||||
{
|
||||
Version = $"Stars: {i}",
|
||||
StarDifficulty = i,
|
||||
});
|
||||
}
|
||||
|
||||
carousel.UpdateBeatmapSet(set);
|
||||
});
|
||||
|
||||
AddStep("select added set", () => carousel.SelectBeatmap(set.Beatmaps[0], false));
|
||||
|
||||
AddStep("filter [5..]", () => carousel.Filter(new FilterCriteria { UserStarDifficulty = { Min = 5 } }));
|
||||
AddUntilStep("Wait for debounce", () => !carousel.PendingFilterTask);
|
||||
checkVisibleItemCount(true, 11);
|
||||
|
||||
AddStep("filter to [0..7]", () => carousel.Filter(new FilterCriteria { UserStarDifficulty = { Max = 7 } }));
|
||||
AddUntilStep("Wait for debounce", () => !carousel.PendingFilterTask);
|
||||
checkVisibleItemCount(true, 7);
|
||||
|
||||
AddStep("filter to [5..7]", () => carousel.Filter(new FilterCriteria { UserStarDifficulty = { Min = 5, Max = 7 } }));
|
||||
AddUntilStep("Wait for debounce", () => !carousel.PendingFilterTask);
|
||||
checkVisibleItemCount(true, 3);
|
||||
|
||||
AddStep("filter [2..2]", () => carousel.Filter(new FilterCriteria { UserStarDifficulty = { Min = 2, Max = 2 } }));
|
||||
AddUntilStep("Wait for debounce", () => !carousel.PendingFilterTask);
|
||||
checkVisibleItemCount(true, 1);
|
||||
|
||||
AddStep("filter to [0..]", () => carousel.Filter(new FilterCriteria { UserStarDifficulty = { Min = 0 } }));
|
||||
AddUntilStep("Wait for debounce", () => !carousel.PendingFilterTask);
|
||||
checkVisibleItemCount(true, 15);
|
||||
}
|
||||
|
||||
private void loadBeatmaps(List<BeatmapSetInfo> beatmapSets = null)
|
||||
{
|
||||
createCarousel();
|
||||
|
@ -24,7 +24,7 @@ namespace osu.Game.Configuration
|
||||
|
||||
Set(OsuSetting.ShowConvertedBeatmaps, true);
|
||||
Set(OsuSetting.DisplayStarsMinimum, 0.0, 0, 10, 0.1);
|
||||
Set(OsuSetting.DisplayStarsMaximum, 10.0, 0, 10, 0.1);
|
||||
Set(OsuSetting.DisplayStarsMaximum, 10.1, 0, 10.1, 0.1);
|
||||
|
||||
Set(OsuSetting.SongSelectGroupingMode, GroupMode.All);
|
||||
Set(OsuSetting.SongSelectSortingMode, SortMode.Title);
|
||||
|
@ -1,7 +1,9 @@
|
||||
// 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 osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
@ -10,11 +12,20 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay
|
||||
{
|
||||
public class SongSelectSettings : SettingsSubsection
|
||||
{
|
||||
private Bindable<double> minStars;
|
||||
private Bindable<double> maxStars;
|
||||
|
||||
protected override string Header => "Song Select";
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuConfigManager config)
|
||||
{
|
||||
minStars = config.GetBindable<double>(OsuSetting.DisplayStarsMinimum);
|
||||
maxStars = config.GetBindable<double>(OsuSetting.DisplayStarsMaximum);
|
||||
|
||||
minStars.ValueChanged += min => maxStars.Value = Math.Max(min.NewValue, maxStars.Value);
|
||||
maxStars.ValueChanged += max => minStars.Value = Math.Min(max.NewValue, minStars.Value);
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new SettingsCheckbox
|
||||
@ -27,19 +38,19 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay
|
||||
LabelText = "Show converted beatmaps",
|
||||
Bindable = config.GetBindable<bool>(OsuSetting.ShowConvertedBeatmaps),
|
||||
},
|
||||
new SettingsSlider<double, StarSlider>
|
||||
new SettingsSlider<double, StarsSlider>
|
||||
{
|
||||
LabelText = "Display beatmaps from",
|
||||
Bindable = config.GetBindable<double>(OsuSetting.DisplayStarsMinimum),
|
||||
KeyboardStep = 0.1f,
|
||||
Keywords = new[] { "star", "difficulty" }
|
||||
Keywords = new[] { "minimum", "maximum", "star", "difficulty" }
|
||||
},
|
||||
new SettingsSlider<double, StarSlider>
|
||||
new SettingsSlider<double, MaximumStarsSlider>
|
||||
{
|
||||
LabelText = "up to",
|
||||
Bindable = config.GetBindable<double>(OsuSetting.DisplayStarsMaximum),
|
||||
KeyboardStep = 0.1f,
|
||||
Keywords = new[] { "star", "difficulty" }
|
||||
Keywords = new[] { "minimum", "maximum", "star", "difficulty" }
|
||||
},
|
||||
new SettingsEnumDropdown<RandomSelectAlgorithm>
|
||||
{
|
||||
@ -49,7 +60,12 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay
|
||||
};
|
||||
}
|
||||
|
||||
private class StarSlider : OsuSliderBar<double>
|
||||
private class MaximumStarsSlider : StarsSlider
|
||||
{
|
||||
public override string TooltipText => Current.IsDefault ? "no limit" : base.TooltipText;
|
||||
}
|
||||
|
||||
private class StarsSlider : OsuSliderBar<double>
|
||||
{
|
||||
public override string TooltipText => Current.Value.ToString(@"0.## stars");
|
||||
}
|
||||
|
@ -44,6 +44,8 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
match &= !criteria.Artist.HasFilter || criteria.Artist.Matches(Beatmap.Metadata.Artist) ||
|
||||
criteria.Artist.Matches(Beatmap.Metadata.ArtistUnicode);
|
||||
|
||||
match &= !criteria.UserStarDifficulty.HasFilter || criteria.UserStarDifficulty.IsInRange(Beatmap.StarDifficulty);
|
||||
|
||||
if (match)
|
||||
{
|
||||
var terms = new List<string>();
|
||||
|
@ -42,9 +42,15 @@ namespace osu.Game.Screens.Select
|
||||
Group = groupMode.Value,
|
||||
Sort = sortMode.Value,
|
||||
AllowConvertedBeatmaps = showConverted.Value,
|
||||
Ruleset = ruleset.Value
|
||||
Ruleset = ruleset.Value,
|
||||
};
|
||||
|
||||
if (!minimumStars.IsDefault)
|
||||
criteria.UserStarDifficulty.Min = minimumStars.Value;
|
||||
|
||||
if (!maximumStars.IsDefault)
|
||||
criteria.UserStarDifficulty.Max = maximumStars.Value;
|
||||
|
||||
FilterQueryParser.ApplyQueries(criteria, query);
|
||||
return criteria;
|
||||
}
|
||||
@ -142,7 +148,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;
|
||||
|
||||
@ -151,9 +159,15 @@ namespace osu.Game.Screens.Select
|
||||
{
|
||||
sortTabs.AccentColour = colours.GreenLight;
|
||||
|
||||
showConverted = config.GetBindable<bool>(OsuSetting.ShowConvertedBeatmaps);
|
||||
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());
|
||||
|
||||
|
@ -26,6 +26,12 @@ namespace osu.Game.Screens.Select
|
||||
public OptionalTextFilter Creator;
|
||||
public OptionalTextFilter Artist;
|
||||
|
||||
public OptionalRange<double> UserStarDifficulty = new OptionalRange<double>
|
||||
{
|
||||
IsLowerInclusive = true,
|
||||
IsUpperInclusive = true
|
||||
};
|
||||
|
||||
public string[] SearchTerms = Array.Empty<string>();
|
||||
|
||||
public RulesetInfo Ruleset;
|
||||
|
Loading…
Reference in New Issue
Block a user