From 83dbba3cbfb3a02297ae8bc801a11bf2028f3cb6 Mon Sep 17 00:00:00 2001
From: Dean Herbert <pe@ppy.sh>
Date: Tue, 5 Jan 2021 18:41:45 +0900
Subject: [PATCH 1/3] Fix carousel beatmap set panels applying transforms to
 difficulties while they are loading

---
 .../Carousel/DrawableCarouselBeatmapSet.cs    | 31 +++++++++++++------
 1 file changed, 21 insertions(+), 10 deletions(-)

diff --git a/osu.Game/Screens/Select/Carousel/DrawableCarouselBeatmapSet.cs b/osu.Game/Screens/Select/Carousel/DrawableCarouselBeatmapSet.cs
index b3c5d458d6..17fa66447d 100644
--- a/osu.Game/Screens/Select/Carousel/DrawableCarouselBeatmapSet.cs
+++ b/osu.Game/Screens/Select/Carousel/DrawableCarouselBeatmapSet.cs
@@ -5,6 +5,7 @@ using System;
 using System.Collections.Generic;
 using System.Diagnostics;
 using System.Linq;
+using System.Threading.Tasks;
 using osu.Framework.Allocation;
 using osu.Framework.Graphics;
 using osu.Framework.Graphics.Containers;
@@ -40,6 +41,8 @@ namespace osu.Game.Screens.Select.Carousel
 
         private BeatmapSetInfo beatmapSet;
 
+        private Task beatmapsLoadTask;
+
         [Resolved]
         private BeatmapManager manager { get; set; }
 
@@ -85,7 +88,9 @@ namespace osu.Game.Screens.Select.Carousel
             base.UpdateItem();
 
             Content.Clear();
+
             beatmapContainer = null;
+            beatmapsLoadTask = null;
 
             if (Item == null)
                 return;
@@ -122,11 +127,7 @@ namespace osu.Game.Screens.Select.Carousel
 
             MovementContainer.MoveToX(0, 500, Easing.OutExpo);
 
-            if (beatmapContainer != null)
-            {
-                foreach (var beatmap in beatmapContainer)
-                    beatmap.MoveToY(0, 800, Easing.OutQuint);
-            }
+            updateBeatmapYPositions();
         }
 
         protected override void Selected()
@@ -163,7 +164,7 @@ namespace osu.Game.Screens.Select.Carousel
                     ChildrenEnumerable = visibleBeatmaps.Select(c => c.CreateDrawableRepresentation())
                 };
 
-                LoadComponentAsync(beatmapContainer, loaded =>
+                beatmapsLoadTask = LoadComponentAsync(beatmapContainer, loaded =>
                 {
                     // make sure the pooled target hasn't changed.
                     if (beatmapContainer != loaded)
@@ -173,16 +174,26 @@ namespace osu.Game.Screens.Select.Carousel
                     updateBeatmapYPositions();
                 });
             }
+        }
 
-            void updateBeatmapYPositions()
+        private void updateBeatmapYPositions()
+        {
+            if (beatmapsLoadTask == null || !beatmapsLoadTask.IsCompleted)
+                return;
+
+            float yPos = DrawableCarouselBeatmap.CAROUSEL_BEATMAP_SPACING;
+
+            bool isSelected = Item.State.Value == CarouselItemState.Selected;
+
+            foreach (var panel in beatmapContainer.Children)
             {
-                float yPos = DrawableCarouselBeatmap.CAROUSEL_BEATMAP_SPACING;
-
-                foreach (var panel in beatmapContainer.Children)
+                if (isSelected)
                 {
                     panel.MoveToY(yPos, 800, Easing.OutQuint);
                     yPos += panel.Item.TotalHeight;
                 }
+                else
+                    panel.MoveToY(0, 800, Easing.OutQuint);
             }
         }
 

From 99701a6d9b22e2fbc4864556a14f9f44311b5236 Mon Sep 17 00:00:00 2001
From: Dean Herbert <pe@ppy.sh>
Date: Wed, 6 Jan 2021 21:06:33 +0900
Subject: [PATCH 2/3] Add null check on beatmapContainer for safety

---
 osu.Game/Screens/Select/Carousel/DrawableCarouselBeatmapSet.cs | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/osu.Game/Screens/Select/Carousel/DrawableCarouselBeatmapSet.cs b/osu.Game/Screens/Select/Carousel/DrawableCarouselBeatmapSet.cs
index 17fa66447d..c0415384c8 100644
--- a/osu.Game/Screens/Select/Carousel/DrawableCarouselBeatmapSet.cs
+++ b/osu.Game/Screens/Select/Carousel/DrawableCarouselBeatmapSet.cs
@@ -178,6 +178,9 @@ namespace osu.Game.Screens.Select.Carousel
 
         private void updateBeatmapYPositions()
         {
+            if (beatmapContainer == null)
+                return;
+
             if (beatmapsLoadTask == null || !beatmapsLoadTask.IsCompleted)
                 return;
 

From 43b9fde45731fdbd5da77f119eaedc5e0afa0f24 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= <dach.bartlomiej@gmail.com>
Date: Wed, 6 Jan 2021 13:15:15 +0100
Subject: [PATCH 3/3] Add some nullability annotations for good measure

---
 osu.Game/Screens/Select/Carousel/DrawableCarouselBeatmapSet.cs | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/osu.Game/Screens/Select/Carousel/DrawableCarouselBeatmapSet.cs b/osu.Game/Screens/Select/Carousel/DrawableCarouselBeatmapSet.cs
index c0415384c8..d7e901b71e 100644
--- a/osu.Game/Screens/Select/Carousel/DrawableCarouselBeatmapSet.cs
+++ b/osu.Game/Screens/Select/Carousel/DrawableCarouselBeatmapSet.cs
@@ -6,6 +6,7 @@ using System.Collections.Generic;
 using System.Diagnostics;
 using System.Linq;
 using System.Threading.Tasks;
+using JetBrains.Annotations;
 using osu.Framework.Allocation;
 using osu.Framework.Graphics;
 using osu.Framework.Graphics.Containers;
@@ -37,10 +38,12 @@ namespace osu.Game.Screens.Select.Carousel
 
         public IEnumerable<DrawableCarouselItem> DrawableBeatmaps => beatmapContainer?.Children ?? Enumerable.Empty<DrawableCarouselItem>();
 
+        [CanBeNull]
         private Container<DrawableCarouselItem> beatmapContainer;
 
         private BeatmapSetInfo beatmapSet;
 
+        [CanBeNull]
         private Task beatmapsLoadTask;
 
         [Resolved]