1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 15:07:44 +08:00

Use alternative method for checking panel readiness to eliminate bool flag

This commit is contained in:
Bartłomiej Dach 2022-08-17 21:52:55 +02:00
parent 3109066e34
commit 3d14b14cfe
No known key found for this signature in database
GPG Key ID: BCECCD4FA41F6497

View File

@ -66,8 +66,8 @@ namespace osu.Game.Overlays.Mods
private IModHotkeyHandler hotkeyHandler = null!;
private Task? latestLoadTask;
private bool itemsLoaded;
internal bool ItemsLoaded => latestLoadTask?.IsCompleted == true && itemsLoaded;
private ICollection<ModPanel>? latestLoadedPanels;
internal bool ItemsLoaded => latestLoadTask?.IsCompleted == true && latestLoadedPanels?.All(panel => panel.Parent != null) == true;
public override bool IsPresent => base.IsPresent || Scheduler.HasPendingTasks;
@ -133,14 +133,13 @@ namespace osu.Game.Overlays.Mods
{
cancellationTokenSource?.Cancel();
var panels = availableMods.Select(mod => CreateModPanel(mod).With(panel => panel.Shear = Vector2.Zero));
var panels = availableMods.Select(mod => CreateModPanel(mod).With(panel => panel.Shear = Vector2.Zero)).ToArray();
latestLoadedPanels = panels;
itemsLoaded = false;
latestLoadTask = LoadComponentsAsync(panels, loaded =>
{
ItemsFlow.ChildrenEnumerable = loaded;
updateState();
itemsLoaded = true;
}, (cancellationTokenSource = new CancellationTokenSource()).Token);
}