mirror of
https://github.com/osukey/osukey.git
synced 2025-06-27 22:27:57 +09:00
Remove excessive selection updating
This commit is contained in:
parent
05c0df53dc
commit
e59a00ac6e
@ -209,7 +209,33 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
AddAssert("start not requested", () => !startRequested);
|
AddAssert("start not requested", () => !startRequested);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void importForRuleset(int id) => AddStep($"import test map for ruleset {id}", () => manager.Import(createTestBeatmapSet(getImportId(), rulesets.AvailableRulesets.Where(r => r.ID == id).ToArray())));
|
[Test]
|
||||||
|
public void TestAddNewBeatmap()
|
||||||
|
{
|
||||||
|
const int test_count = 10;
|
||||||
|
int beatmapChangedCount = 0;
|
||||||
|
createSongSelect();
|
||||||
|
AddStep("Setup counter", () =>
|
||||||
|
{
|
||||||
|
beatmapChangedCount = 0;
|
||||||
|
songSelect.Carousel.BeatmapSetsChanged += () => beatmapChangedCount++;
|
||||||
|
});
|
||||||
|
AddRepeatStep($"Create beatmaps {test_count} times", () =>
|
||||||
|
{
|
||||||
|
manager.Import(createTestBeatmapSet(getImportId(), rulesets.AvailableRulesets.Where(r => r.ID == 0).ToArray()));
|
||||||
|
|
||||||
|
Scheduler.AddDelayed(() =>
|
||||||
|
{
|
||||||
|
// Wait for debounce
|
||||||
|
songSelect.Carousel.SelectNextRandom();
|
||||||
|
}, 400);
|
||||||
|
}, test_count);
|
||||||
|
|
||||||
|
AddAssert($"Beatmap changed {test_count} times", () => beatmapChangedCount == test_count);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void importForRuleset(int id) => AddStep($"import test map for ruleset {id}",
|
||||||
|
() => manager.Import(createTestBeatmapSet(getImportId(), rulesets.AvailableRulesets.Where(r => r.ID == id).ToArray())));
|
||||||
|
|
||||||
private static int importId;
|
private static int importId;
|
||||||
private int getImportId() => ++importId;
|
private int getImportId() => ++importId;
|
||||||
|
@ -597,11 +597,17 @@ namespace osu.Game.Screens.Select
|
|||||||
{
|
{
|
||||||
bindBindables();
|
bindBindables();
|
||||||
|
|
||||||
|
// As a selection was already obtained, do not attempt to update the selected beatmap.
|
||||||
|
if (Carousel.SelectedBeatmapSet != null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Attempt to select the current beatmap on the carousel, if it is valid to be selected.
|
||||||
if (!Beatmap.IsDefault && Beatmap.Value.BeatmapSetInfo?.DeletePending == false && Beatmap.Value.BeatmapSetInfo?.Protected == false
|
if (!Beatmap.IsDefault && Beatmap.Value.BeatmapSetInfo?.DeletePending == false && Beatmap.Value.BeatmapSetInfo?.Protected == false
|
||||||
&& Carousel.SelectBeatmap(Beatmap.Value.BeatmapInfo, false))
|
&& Carousel.SelectBeatmap(Beatmap.Value.BeatmapInfo, false))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (Carousel.SelectedBeatmapSet == null && !Carousel.SelectNextRandom())
|
// If the current active beatmap could not be selected, select a new random beatmap.
|
||||||
|
if (!Carousel.SelectNextRandom())
|
||||||
{
|
{
|
||||||
// in the case random selection failed, we want to trigger selectionChanged
|
// in the case random selection failed, we want to trigger selectionChanged
|
||||||
// to show the dummy beatmap (we have nothing else to display).
|
// to show the dummy beatmap (we have nothing else to display).
|
||||||
|
Loading…
x
Reference in New Issue
Block a user