Reduce complexity of selection restore

This commit is contained in:
Dean Herbert 2023-08-25 00:52:54 +09:00
parent 9e94f38091
commit 89eeff515b

View File

@ -134,8 +134,7 @@ namespace osu.Game.Screens.Select
if (selectedBeatmapSet != null && !originalBeatmapSetsDetached.Contains(selectedBeatmapSet.BeatmapSet))
selectedBeatmapSet = null;
var selectedSetBefore = selectedBeatmapSet;
var selectedBeatmapBefore = selectedBeatmap;
var selectedBeatmapBefore = selectedBeatmap?.BeatmapInfo;
CarouselRoot newRoot = new CarouselRoot(this);
@ -170,9 +169,9 @@ namespace osu.Game.Screens.Select
signalBeatmapsLoaded();
// Restore selection
if (selectedBeatmapBefore != null && selectedSetBefore != null && newRoot.BeatmapSetsByID.TryGetValue(selectedSetBefore.BeatmapSet.ID, out var newSelectionCandidates))
if (selectedBeatmapBefore != null && newRoot.BeatmapSetsByID.TryGetValue(selectedBeatmapBefore.BeatmapSet!.ID, out var newSelectionCandidates))
{
CarouselBeatmap? found = newSelectionCandidates.SelectMany(s => s.Beatmaps).SingleOrDefault(b => b.BeatmapInfo.ID == selectedBeatmapBefore.BeatmapInfo.ID);
CarouselBeatmap? found = newSelectionCandidates.SelectMany(s => s.Beatmaps).SingleOrDefault(b => b.BeatmapInfo.ID == selectedBeatmapBefore.ID);
if (found != null)
found.State.Value = CarouselItemState.Selected;