Skip to content

Commit

Permalink
displayedCarouselItems -> carouselItems
Browse files Browse the repository at this point in the history
  • Loading branch information
peppy committed Jan 23, 2025
1 parent d526835 commit ded1d9f
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions osu.Game/Screens/SelectV2/Carousel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public abstract partial class Carousel<T> : CompositeDrawable
/// <summary>
/// The number of carousel items currently in rotation for display.
/// </summary>
public int DisplayableItems => displayedCarouselItems?.Count ?? 0;
public int DisplayableItems => carouselItems?.Count ?? 0;

/// <summary>
/// The number of items currently actualised into drawables.
Expand Down Expand Up @@ -171,7 +171,7 @@ protected Carousel()

#region Filtering and display preparation

private List<CarouselItem>? displayedCarouselItems;
private List<CarouselItem>? carouselItems;

private Task filterTask = Task.CompletedTask;
private CancellationTokenSource cancellationSource = new CancellationTokenSource();
Expand Down Expand Up @@ -222,7 +222,7 @@ await Task.Run(async () =>
return;

log("Items ready for display");
displayedCarouselItems = items.ToList();
carouselItems = items.ToList();
displayedRange = null;

updateSelection();
Expand Down Expand Up @@ -253,9 +253,9 @@ private void updateSelection()
{
currentSelectionCarouselItem = null;

if (displayedCarouselItems == null) return;
if (carouselItems == null) return;

foreach (var item in displayedCarouselItems)
foreach (var item in carouselItems)
{
bool isSelected = item.Model == currentSelection;

Expand Down Expand Up @@ -306,7 +306,7 @@ protected override void Update()
{
base.Update();

if (displayedCarouselItems == null)
if (carouselItems == null)
return;

var range = getDisplayRange();
Expand Down Expand Up @@ -356,15 +356,15 @@ private static float offsetX(float dist, float halfHeight)

private DisplayRange getDisplayRange()
{
Debug.Assert(displayedCarouselItems != null);
Debug.Assert(carouselItems != null);

// Find index range of all items that should be on-screen
carouselBoundsItem.CarouselYPosition = visibleUpperBound - DistanceOffscreenToPreload;
int firstIndex = displayedCarouselItems.BinarySearch(carouselBoundsItem);
int firstIndex = carouselItems.BinarySearch(carouselBoundsItem);
if (firstIndex < 0) firstIndex = ~firstIndex;

carouselBoundsItem.CarouselYPosition = visibleBottomBound + DistanceOffscreenToPreload;
int lastIndex = displayedCarouselItems.BinarySearch(carouselBoundsItem);
int lastIndex = carouselItems.BinarySearch(carouselBoundsItem);
if (lastIndex < 0) lastIndex = ~lastIndex;

firstIndex = Math.Max(0, firstIndex - 1);
Expand All @@ -375,11 +375,11 @@ private DisplayRange getDisplayRange()

private void updateDisplayedRange(DisplayRange range)
{
Debug.Assert(displayedCarouselItems != null);
Debug.Assert(carouselItems != null);

List<CarouselItem> toDisplay = range.Last - range.First == 0
? new List<CarouselItem>()
: displayedCarouselItems.GetRange(range.First, range.Last - range.First + 1);
: carouselItems.GetRange(range.First, range.Last - range.First + 1);

// Iterate over all panels which are already displayed and figure which need to be displayed / removed.
foreach (var panel in scroll.Panels)
Expand Down Expand Up @@ -415,9 +415,9 @@ private void updateDisplayedRange(DisplayRange range)

// Update the total height of all items (to make the scroll container scrollable through the full height even though
// most items are not displayed / loaded).
if (displayedCarouselItems.Count > 0)
if (carouselItems.Count > 0)
{
var lastItem = displayedCarouselItems[^1];
var lastItem = carouselItems[^1];
scroll.SetLayoutHeight((float)(lastItem.CarouselYPosition + lastItem.DrawHeight + visibleHalfHeight));
}
else
Expand Down

0 comments on commit ded1d9f

Please sign in to comment.