mirror of
https://github.com/ppy/osu.git
synced 2026-05-25 02:29:54 +08:00
Merge pull request #33302 from peppy/song-select-v2-fix-loading-overlay
SongSelectV2: Fix carousel loading state looking out of place
This commit is contained in:
@@ -375,6 +375,8 @@ namespace osu.Game.Tests.Visual.SongSelectV2
|
||||
|
||||
public partial class TestBeatmapCarousel : BeatmapCarousel
|
||||
{
|
||||
public int FilterDelay = 0;
|
||||
|
||||
public IEnumerable<BeatmapInfo> PostFilterBeatmaps = null!;
|
||||
|
||||
public BeatmapInfo? SelectedBeatmapInfo => CurrentSelection as BeatmapInfo;
|
||||
@@ -383,15 +385,15 @@ namespace osu.Game.Tests.Visual.SongSelectV2
|
||||
public new BeatmapSetInfo? ExpandedBeatmapSet => base.ExpandedBeatmapSet;
|
||||
public new GroupDefinition? ExpandedGroup => base.ExpandedGroup;
|
||||
|
||||
protected override Task<IEnumerable<CarouselItem>> FilterAsync(bool clearExistingPanels = false)
|
||||
protected override async Task<IEnumerable<CarouselItem>> FilterAsync(bool clearExistingPanels = false)
|
||||
{
|
||||
var filterAsync = base.FilterAsync(clearExistingPanels);
|
||||
filterAsync.ContinueWith(result =>
|
||||
{
|
||||
if (result.IsCompletedSuccessfully)
|
||||
PostFilterBeatmaps = result.GetResultSafely().Select(i => i.Model).OfType<BeatmapInfo>();
|
||||
});
|
||||
return filterAsync;
|
||||
var items = await base.FilterAsync(clearExistingPanels);
|
||||
|
||||
if (FilterDelay != 0)
|
||||
await Task.Delay(FilterDelay);
|
||||
|
||||
PostFilterBeatmaps = items.Select(i => i.Model).OfType<BeatmapInfo>();
|
||||
return items;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,6 +48,14 @@ namespace osu.Game.Tests.Visual.SongSelectV2
|
||||
RemoveAllBeatmaps();
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Explicit]
|
||||
public void TestLoadingDisplay()
|
||||
{
|
||||
AddStep("induce slow filtering", () => Carousel.FilterDelay = 2000);
|
||||
SortAndGroupBy(SortMode.Artist, GroupMode.NoGrouping);
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Explicit]
|
||||
public void TestAddRemoveRepeatedOps()
|
||||
|
||||
@@ -18,6 +18,7 @@ using osu.Framework.Utils;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Carousel;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Screens.Select;
|
||||
@@ -78,7 +79,7 @@ namespace osu.Game.Screens.SelectV2
|
||||
grouping = new BeatmapCarouselFilterGrouping(() => Criteria),
|
||||
};
|
||||
|
||||
AddInternal(loading = new LoadingLayer(dimBackground: true));
|
||||
AddInternal(loading = new LoadingLayer());
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
@@ -451,13 +452,18 @@ namespace osu.Game.Screens.SelectV2
|
||||
|
||||
Criteria = criteria;
|
||||
|
||||
loadingDebounce ??= Scheduler.AddDelayed(() => loading.Show(), 250);
|
||||
loadingDebounce ??= Scheduler.AddDelayed(() =>
|
||||
{
|
||||
Scroll.FadeColour(OsuColour.Gray(0.5f), 1000, Easing.OutQuint);
|
||||
loading.Show();
|
||||
}, 250);
|
||||
|
||||
FilterAsync(resetDisplay).ContinueWith(_ => Schedule(() =>
|
||||
{
|
||||
loadingDebounce?.Cancel();
|
||||
loadingDebounce = null;
|
||||
|
||||
Scroll.FadeColour(OsuColour.Gray(1f), 500, Easing.OutQuint);
|
||||
loading.Hide();
|
||||
}));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user