mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 06:57:39 +08:00
Merge pull request #1820 from peppy/fix-play-song-select-tests
Fix song select dummy beatmap once and for all
This commit is contained in:
commit
b80a393bac
@ -51,11 +51,12 @@ namespace osu.Game.Tests.Visual
|
||||
private class TestSongSelect : PlaySongSelect
|
||||
{
|
||||
public WorkingBeatmap CurrentBeatmap => Beatmap.Value;
|
||||
public WorkingBeatmap CurrentBeatmapDetailsBeatmap => BeatmapDetails.Beatmap;
|
||||
public new BeatmapCarousel Carousel => base.Carousel;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(BeatmapManager baseManager)
|
||||
private void load(OsuGameBase game)
|
||||
{
|
||||
TestSongSelect songSelect = null;
|
||||
|
||||
@ -69,12 +70,16 @@ namespace osu.Game.Tests.Visual
|
||||
dependencies.Cache(rulesets = new RulesetStore(contextFactory));
|
||||
dependencies.Cache(manager = new BeatmapManager(storage, contextFactory, rulesets, null)
|
||||
{
|
||||
DefaultBeatmap = defaultBeatmap = baseManager.GetWorkingBeatmap(null)
|
||||
DefaultBeatmap = defaultBeatmap = game.Beatmap.Default
|
||||
});
|
||||
|
||||
void loadNewSongSelect(bool deleteMaps = false) => AddStep("reload song select", () =>
|
||||
{
|
||||
if (deleteMaps) manager.DeleteAll();
|
||||
if (deleteMaps)
|
||||
{
|
||||
manager.DeleteAll();
|
||||
game.Beatmap.SetDefault();
|
||||
}
|
||||
|
||||
if (songSelect != null)
|
||||
{
|
||||
@ -91,6 +96,8 @@ namespace osu.Game.Tests.Visual
|
||||
|
||||
AddAssert("dummy selected", () => songSelect.CurrentBeatmap == defaultBeatmap);
|
||||
|
||||
AddAssert("dummy shown on wedge", () => songSelect.CurrentBeatmapDetailsBeatmap == defaultBeatmap);
|
||||
|
||||
AddStep("import test maps", () =>
|
||||
{
|
||||
for (int i = 0; i < 100; i += 10)
|
||||
|
@ -229,11 +229,15 @@ namespace osu.Game.Screens.Select
|
||||
}
|
||||
}
|
||||
|
||||
public void SelectNextRandom()
|
||||
/// <summary>
|
||||
/// Select the next beatmap in the random sequence.
|
||||
/// </summary>
|
||||
/// <returns>True if a selection could be made, else False.</returns>
|
||||
public bool SelectNextRandom()
|
||||
{
|
||||
var visible = beatmapSets.Where(s => !s.Filtered).ToList();
|
||||
if (!visible.Any())
|
||||
return;
|
||||
return false;
|
||||
|
||||
if (selectedBeatmap != null)
|
||||
{
|
||||
@ -263,6 +267,7 @@ namespace osu.Game.Screens.Select
|
||||
set = visible.ElementAt(RNG.Next(visible.Count));
|
||||
|
||||
select(set.Beatmaps.Skip(RNG.Next(set.Beatmaps.Count())).FirstOrDefault());
|
||||
return true;
|
||||
}
|
||||
|
||||
public void SelectPreviousRandom()
|
||||
|
@ -23,7 +23,7 @@ namespace osu.Game.Screens.Select
|
||||
{
|
||||
private OsuScreen player;
|
||||
private readonly ModSelectOverlay modSelect;
|
||||
private readonly BeatmapDetailArea beatmapDetails;
|
||||
protected readonly BeatmapDetailArea BeatmapDetails;
|
||||
private bool removeAutoModOnResume;
|
||||
|
||||
public PlaySongSelect()
|
||||
@ -35,13 +35,13 @@ namespace osu.Game.Screens.Select
|
||||
Anchor = Anchor.BottomCentre,
|
||||
});
|
||||
|
||||
LeftContent.Add(beatmapDetails = new BeatmapDetailArea
|
||||
LeftContent.Add(BeatmapDetails = new BeatmapDetailArea
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Padding = new MarginPadding { Top = 10, Right = 5 },
|
||||
});
|
||||
|
||||
beatmapDetails.Leaderboard.ScoreSelected += s => Push(new Results(s));
|
||||
BeatmapDetails.Leaderboard.ScoreSelected += s => Push(new Results(s));
|
||||
}
|
||||
|
||||
private SampleChannel sampleConfirm;
|
||||
@ -78,7 +78,7 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
beatmap.Mods.BindTo(modSelect.SelectedMods);
|
||||
|
||||
beatmapDetails.Beatmap = beatmap;
|
||||
BeatmapDetails.Beatmap = beatmap;
|
||||
|
||||
if (beatmap.Track != null)
|
||||
beatmap.Track.Looping = true;
|
||||
|
@ -449,9 +449,16 @@ namespace osu.Game.Screens.Select
|
||||
private void carouselBeatmapsLoaded()
|
||||
{
|
||||
if (!Beatmap.IsDefault && Beatmap.Value.BeatmapSetInfo?.DeletePending == false)
|
||||
{
|
||||
Carousel.SelectBeatmap(Beatmap.Value.BeatmapInfo);
|
||||
}
|
||||
else if (Carousel.SelectedBeatmapSet == null)
|
||||
Carousel.SelectNextRandom();
|
||||
{
|
||||
if (!Carousel.SelectNextRandom())
|
||||
// in the case random selection failed, we want to trigger selectionChanged
|
||||
// to show the dummy beatmap (we have nothing else to display).
|
||||
carouselSelectionChanged(null);
|
||||
}
|
||||
}
|
||||
|
||||
private void delete(BeatmapSetInfo beatmap)
|
||||
|
Loading…
Reference in New Issue
Block a user