1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-05 10:33:22 +08:00

Compare commits

...

7 Commits

Author SHA1 Message Date
Dan Balasescu
aefd2fd847
Merge pull request #8370 from peppy/fix-carousel-root-selects-from-nothing
Fix selection not occurring when switching away from empty ruleset
2020-03-23 12:39:43 +09:00
Dan Balasescu
d0c7b49376
Merge branch 'master' into fix-carousel-root-selects-from-nothing 2020-03-23 11:34:04 +09:00
smoogipoo
448e5c0deb Merge branch 'master' into fix-carousel-root-selects-from-nothing 2020-03-23 11:15:22 +09:00
smoogipoo
bf70276496 Fix test re-using the same beatmap sets 2020-03-23 11:12:36 +09:00
Dean Herbert
29009c85c0
Fix typo in comment
Co-Authored-By: Bartłomiej Dach <dach.bartlomiej@gmail.com>
2020-03-22 00:32:53 +09:00
Dean Herbert
8136ea561e Fix a couple of broken tests 2020-03-20 15:02:13 +09:00
Dean Herbert
9b60b535e5 Fix selection not occurring when switching from empty ruleset on first load 2020-03-20 15:01:26 +09:00
4 changed files with 50 additions and 9 deletions

View File

@ -278,6 +278,7 @@ namespace osu.Game.Tests.Visual.Background
private void setupUserSettings()
{
AddUntilStep("Song select is current", () => songSelect.IsCurrentScreen());
AddUntilStep("Song select has selection", () => songSelect.Carousel?.SelectedBeatmap != null);
AddStep("Set default user settings", () =>
{

View File

@ -227,6 +227,34 @@ namespace osu.Game.Tests.Visual.SongSelect
waitForSelection(set_count);
}
[Test]
public void TestSelectionEnteringFromEmptyRuleset()
{
var sets = new List<BeatmapSetInfo>();
AddStep("Create beatmaps for taiko only", () =>
{
sets.Clear();
var rulesetBeatmapSet = createTestBeatmapSet(1);
var taikoRuleset = rulesets.AvailableRulesets.ElementAt(1);
rulesetBeatmapSet.Beatmaps.ForEach(b =>
{
b.Ruleset = taikoRuleset;
b.RulesetID = 1;
});
sets.Add(rulesetBeatmapSet);
});
loadBeatmaps(sets, () => new FilterCriteria { Ruleset = rulesets.AvailableRulesets.ElementAt(0) });
AddStep("Set non-empty mode filter", () =>
carousel.Filter(new FilterCriteria { Ruleset = rulesets.AvailableRulesets.ElementAt(1) }, false));
AddAssert("Something is selected", () => carousel.SelectedBeatmap != null);
}
/// <summary>
/// Test sorting
/// </summary>
@ -399,20 +427,25 @@ namespace osu.Game.Tests.Visual.SongSelect
AddStep("filter to ruleset 0", () =>
carousel.Filter(new FilterCriteria { Ruleset = rulesets.AvailableRulesets.ElementAt(0) }, false));
AddStep("select filtered map skipping filtered", () => carousel.SelectBeatmap(testMixed.Beatmaps[1], false));
AddAssert("unfiltered beatmap not selected", () => carousel.SelectedBeatmap == null);
AddAssert("unfiltered beatmap not selected", () => carousel.SelectedBeatmap.RulesetID == 0);
AddStep("remove mixed set", () =>
{
carousel.RemoveBeatmapSet(testMixed);
testMixed = null;
});
var testSingle = createTestBeatmapSet(set_count + 2);
testSingle.Beatmaps.ForEach(b =>
BeatmapSetInfo testSingle = null;
AddStep("add single ruleset beatmapset", () =>
{
b.Ruleset = rulesets.AvailableRulesets.ElementAt(1);
b.RulesetID = b.Ruleset.ID ?? 1;
testSingle = createTestBeatmapSet(set_count + 2);
testSingle.Beatmaps.ForEach(b =>
{
b.Ruleset = rulesets.AvailableRulesets.ElementAt(1);
b.RulesetID = b.Ruleset.ID ?? 1;
});
carousel.UpdateBeatmapSet(testSingle);
});
AddStep("add single ruleset beatmapset", () => carousel.UpdateBeatmapSet(testSingle));
AddStep("select filtered map skipping filtered", () => carousel.SelectBeatmap(testSingle.Beatmaps[0], false));
checkNoSelection();
AddStep("remove single ruleset set", () => carousel.RemoveBeatmapSet(testSingle));
@ -546,7 +579,7 @@ namespace osu.Game.Tests.Visual.SongSelect
checkVisibleItemCount(true, 15);
}
private void loadBeatmaps(List<BeatmapSetInfo> beatmapSets = null)
private void loadBeatmaps(List<BeatmapSetInfo> beatmapSets = null, Func<FilterCriteria> initialCriteria = null)
{
createCarousel();
@ -561,7 +594,7 @@ namespace osu.Game.Tests.Visual.SongSelect
bool changed = false;
AddStep($"Load {(beatmapSets.Count > 0 ? beatmapSets.Count.ToString() : "some")} beatmaps", () =>
{
carousel.Filter(new FilterCriteria());
carousel.Filter(initialCriteria?.Invoke() ?? new FilterCriteria());
carousel.BeatmapSetsChanged = () => changed = true;
carousel.BeatmapSets = beatmapSets;
});

View File

@ -750,13 +750,17 @@ namespace osu.Game.Screens.Select
public CarouselRoot(BeatmapCarousel carousel)
{
// root should always remain selected. if not, PerformSelection will not be called.
State.Value = CarouselItemState.Selected;
State.ValueChanged += state => State.Value = CarouselItemState.Selected;
this.carousel = carousel;
}
protected override void PerformSelection()
{
if (LastSelected == null || LastSelected.Filtered.Value)
carousel.SelectNextRandom();
carousel?.SelectNextRandom();
else
base.PerformSelection();
}

View File

@ -150,6 +150,7 @@ namespace osu.Game.Screens.Select
},
Child = Carousel = new BeatmapCarousel
{
AllowSelection = false, // delay any selection until our bindables are ready to make a good choice.
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
RelativeSizeAxes = Axes.Both,
@ -655,6 +656,8 @@ namespace osu.Game.Screens.Select
{
bindBindables();
Carousel.AllowSelection = true;
// If a selection was already obtained, do not attempt to update the selected beatmap.
if (Carousel.SelectedBeatmapSet != null)
return;