diff --git a/osu.Game/Screens/Select/CarouselContainer.cs b/osu.Game/Screens/Select/CarouselContainer.cs index f9cc18264a..530b5ea65b 100644 --- a/osu.Game/Screens/Select/CarouselContainer.cs +++ b/osu.Game/Screens/Select/CarouselContainer.cs @@ -22,8 +22,7 @@ namespace osu.Game.Screens.Select public BeatmapGroup SelectedGroup { get; private set; } public BeatmapPanel SelectedPanel { get; private set; } - - private Cached yPositionsCached = new Cached(); + private List yPositions = new List(); public CarouselContainer() @@ -45,7 +44,7 @@ namespace osu.Game.Screens.Select foreach (BeatmapPanel panel in group.BeatmapPanels) panels.Add(panel); - yPositionsCached.Invalidate(); + computeYPositions(); } private void movePanel(Panel panel, bool advance, ref float currentY) @@ -57,7 +56,11 @@ namespace osu.Game.Screens.Select currentY += panel.DrawHeight + 5; } - private void computeYPositions() + /// + /// Computes the target Y positions for every panel in the carousel. + /// + /// The Y position of the currently selected panel. + private float computeYPositions() { yPositions.Clear(); @@ -92,7 +95,7 @@ namespace osu.Game.Screens.Select currentY += DrawHeight / 2; scrollableContent.Height = currentY; - ScrollTo(selectedY); + return selectedY; } public void SelectBeatmap(BeatmapInfo beatmap) @@ -121,15 +124,8 @@ namespace osu.Game.Screens.Select panel.State = PanelSelectedState.Selected; SelectedPanel = panel; - yPositionsCached.Invalidate(); - } - - protected override void UpdateLayout() - { - base.UpdateLayout(); - - if (!yPositionsCached.EnsureValid()) - yPositionsCached.Refresh(computeYPositions); + float selectedY = computeYPositions(); + ScrollTo(selectedY); } private static float offsetX(Panel panel, float dist, float halfHeight)