Allow song select to refresh the global WorkingBeatmap after an external update

This commit is contained in:
Dean Herbert
2022-06-20 19:48:46 +09:00
parent 6999933d33
commit 66a01d1ed2
4 changed files with 31 additions and 0 deletions

View File

@ -296,8 +296,24 @@ namespace osu.Game.Screens.Select
base.LoadComplete();
modSelectOverlayRegistration = OverlayManager?.RegisterBlockingOverlay(ModSelect);
beatmaps.OnInvalidated += workingBeatmapInvalidated;
}
private void workingBeatmapInvalidated(WorkingBeatmap working) => Scheduler.AddOnce(w =>
{
// The global beatmap may have already been updated (ie. by the editor).
// Only perform the actual switch if we still need to.
if (w == Beatmap.Value)
{
// Not sure if this refresh is required.
var beatmapInfo = beatmaps.QueryBeatmap(b => b.ID == w.BeatmapInfo.ID);
Beatmap.Value = beatmaps.GetWorkingBeatmap(beatmapInfo);
}
updateComponentFromBeatmap(Beatmap.Value);
}, working);
/// <summary>
/// Creates the buttons to be displayed in the footer.
/// </summary>
@ -700,6 +716,8 @@ namespace osu.Game.Screens.Select
music.TrackChanged -= ensureTrackLooping;
modSelectOverlayRegistration?.Dispose();
beatmaps.OnInvalidated -= workingBeatmapInvalidated;
}
/// <summary>