1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 12:57:36 +08:00

Move selection fallback logic out of BeatmapCarousel to SongSelect

This commit is contained in:
Dean Herbert 2020-03-12 15:52:03 +09:00
parent 5537b279de
commit ca9cfbe51d
2 changed files with 30 additions and 24 deletions

View File

@ -225,25 +225,21 @@ namespace osu.Game.Screens.Select
continue;
if (!bypassFilters && item.Filtered.Value)
// The beatmap exists in this set but is filtered, so look for the first unfiltered map in the set
item = set.Beatmaps.FirstOrDefault(b => !b.Filtered.Value);
return false;
if (item != null)
select(item);
// if we got here and the set is filtered, it means we were bypassing filters.
// in this case, reapplying the filter is necessary to ensure the panel is in the correct place
// (since it is forcefully being included in the carousel).
if (set.Filtered.Value)
{
select(item);
Debug.Assert(bypassFilters);
// if we got here and the set is filtered, it means we were bypassing filters.
// in this case, reapplying the filter is necessary to ensure the panel is in the correct place
// (since it is forcefully being included in the carousel).
if (set.Filtered.Value)
{
Debug.Assert(bypassFilters);
applyActiveCriteria(false);
}
return true;
applyActiveCriteria(false);
}
return true;
}
return false;

View File

@ -380,6 +380,8 @@ namespace osu.Game.Screens.Select
{
if (e.NewValue is DummyWorkingBeatmap || !this.IsCurrentScreen()) return;
Logger.Log($"working beatmap updated to {e.NewValue}");
if (!Carousel.SelectBeatmap(e.NewValue.BeatmapInfo, false))
{
// A selection may not have been possible with filters applied.
@ -446,8 +448,10 @@ namespace osu.Game.Screens.Select
if (transferRulesetValue())
{
// if the ruleset changed, the rest of the selection update will happen via updateSelectedRuleset.
Mods.Value = Array.Empty<Mod>();
// required to return once in order to have the carousel in a good state.
// if the ruleset changed, the rest of the selection update will happen via updateSelectedRuleset.
return;
}
@ -472,7 +476,7 @@ namespace osu.Game.Screens.Select
if (this.IsCurrentScreen())
ensurePlayingSelected();
UpdateBeatmap(Beatmap.Value);
updateComponentFromBeatmap(Beatmap.Value);
}
}
@ -547,7 +551,7 @@ namespace osu.Game.Screens.Select
if (Beatmap != null && !Beatmap.Value.BeatmapSetInfo.DeletePending)
{
UpdateBeatmap(Beatmap.Value);
updateComponentFromBeatmap(Beatmap.Value);
// restart playback on returning to song select, regardless.
music?.Play();
@ -610,10 +614,8 @@ namespace osu.Game.Screens.Select
/// This is a debounced call (unlike directly binding to WorkingBeatmap.ValueChanged).
/// </summary>
/// <param name="beatmap">The working beatmap.</param>
protected virtual void UpdateBeatmap(WorkingBeatmap beatmap)
private void updateComponentFromBeatmap(WorkingBeatmap beatmap)
{
Logger.Log($"working beatmap updated to {beatmap}");
if (Background is BackgroundScreenBeatmap backgroundModeBeatmap)
{
backgroundModeBeatmap.Beatmap = beatmap;
@ -658,9 +660,17 @@ namespace osu.Game.Screens.Select
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
&& Carousel.SelectBeatmap(Beatmap.Value.BeatmapInfo, false))
return;
if (!Beatmap.IsDefault && Beatmap.Value.BeatmapSetInfo?.DeletePending == false && Beatmap.Value.BeatmapSetInfo?.Protected == false)
{
if (Carousel.SelectBeatmap(Beatmap.Value.BeatmapInfo, false))
return;
// prefer not changing ruleset at this point, so look for another difficulty in the currently playing beatmap
var found = Beatmap.Value.BeatmapSetInfo.Beatmaps.FirstOrDefault(b => b.Ruleset.Equals(decoupledRuleset.Value));
if (found != null && Carousel.SelectBeatmap(found, false))
return;
}
// If the current active beatmap could not be selected, select a new random beatmap.
if (!Carousel.SelectNextRandom())