mirror of
https://github.com/osukey/osukey.git
synced 2025-08-08 00:53:56 +09:00
Add basic range-based invalidation
This commit is contained in:
@ -552,13 +552,16 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
private (int first, int last) displayedRange;
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
|
|
||||||
|
bool revalidateItems = !itemsCache.IsValid;
|
||||||
|
|
||||||
//todo: this should only refresh items, not everything here
|
//todo: this should only refresh items, not everything here
|
||||||
if (!itemsCache.IsValid)
|
if (revalidateItems)
|
||||||
{
|
|
||||||
updateItems();
|
updateItems();
|
||||||
|
|
||||||
// Remove all items that should no longer be on-screen
|
// Remove all items that should no longer be on-screen
|
||||||
@ -570,52 +573,23 @@ namespace osu.Game.Screens.Select
|
|||||||
int lastIndex = yPositions.BinarySearch(visibleBottomBound);
|
int lastIndex = yPositions.BinarySearch(visibleBottomBound);
|
||||||
if (lastIndex < 0) lastIndex = ~lastIndex;
|
if (lastIndex < 0) lastIndex = ~lastIndex;
|
||||||
|
|
||||||
scrollableContent.Clear();
|
if (revalidateItems || firstIndex != displayedRange.first || lastIndex != displayedRange.last)
|
||||||
|
{
|
||||||
|
displayedRange = (firstIndex, lastIndex);
|
||||||
|
|
||||||
// Add those items within the previously found index range that should be displayed.
|
// Add those items within the previously found index range that should be displayed.
|
||||||
for (int i = firstIndex; i < lastIndex; ++i)
|
for (int i = firstIndex; i < lastIndex; ++i)
|
||||||
{
|
{
|
||||||
DrawableCarouselItem item = visibleItems[i].CreateDrawableRepresentation();
|
var panel = scrollableContent.FirstOrDefault(c => c.Item == visibleItems[i]);
|
||||||
|
|
||||||
item.Y = yPositions[i];
|
if (panel == null)
|
||||||
item.Depth = i;
|
|
||||||
|
|
||||||
scrollableContent.Add(item);
|
|
||||||
|
|
||||||
// if (!item.Item.Visible)
|
|
||||||
// {
|
|
||||||
// if (!item.IsPresent)
|
|
||||||
// notVisibleCount++;
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// Only add if we're not already part of the content.
|
|
||||||
/*
|
|
||||||
if (!scrollableContent.Contains(item))
|
|
||||||
{
|
{
|
||||||
// Makes sure headers are always _below_ items,
|
panel = visibleItems[i].CreateDrawableRepresentation();
|
||||||
// and depth flows downward.
|
scrollableContent.Add(panel);
|
||||||
item.Depth = depth;
|
|
||||||
|
|
||||||
switch (item.LoadState)
|
|
||||||
{
|
|
||||||
case LoadState.NotLoaded:
|
|
||||||
LoadComponentAsync(item);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case LoadState.Loading:
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
scrollableContent.Add(item);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
panel.Y = yPositions[i];
|
||||||
{
|
scrollableContent.ChangeChildDepth(panel, i);
|
||||||
scrollableContent.ChangeChildDepth(item, depth);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user