1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 11:35:35 +08:00

Merge branch 'master' into fix-collection-import-notification

This commit is contained in:
Bartłomiej Dach 2022-08-08 21:05:48 +02:00 committed by GitHub
commit e77f47e489
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 29 deletions

View File

@ -203,7 +203,7 @@ namespace osu.Game.Graphics.UserInterface
if (hasSignificantChanges)
requestDisplay();
else if (isDisplayed && Time.Current - lastDisplayRequiredTime > 2000)
else if (isDisplayed && Time.Current - lastDisplayRequiredTime > 2000 && !IsHovered)
{
mainContent.FadeTo(0, 300, Easing.OutQuint);
isDisplayed = false;

View File

@ -66,7 +66,7 @@ namespace osu.Game.Overlays.Mods
private IModHotkeyHandler hotkeyHandler = null!;
private Task? latestLoadTask;
internal bool ItemsLoaded => latestLoadTask == null;
internal bool ItemsLoaded => latestLoadTask?.IsCompleted == true;
public ModColumn(ModType modType, bool allowIncompatibleSelection)
{
@ -132,18 +132,11 @@ namespace osu.Game.Overlays.Mods
var panels = availableMods.Select(mod => CreateModPanel(mod).With(panel => panel.Shear = Vector2.Zero));
Task? loadTask;
latestLoadTask = loadTask = LoadComponentsAsync(panels, loaded =>
latestLoadTask = LoadComponentsAsync(panels, loaded =>
{
ItemsFlow.ChildrenEnumerable = loaded;
updateState();
}, (cancellationTokenSource = new CancellationTokenSource()).Token);
loadTask.ContinueWith(_ =>
{
if (loadTask == latestLoadTask)
latestLoadTask = null;
});
}
private void updateState()

View File

@ -2,7 +2,6 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
@ -50,19 +49,18 @@ namespace osu.Game.Overlays.Mods
{
presetSubscription?.Dispose();
presetSubscription = realm.RegisterForNotifications(r =>
r.All<ModPreset>()
.Filter($"{nameof(ModPreset.Ruleset)}.{nameof(RulesetInfo.ShortName)} == $0"
+ $" && {nameof(ModPreset.DeletePending)} == false", ruleset.Value.ShortName)
.OrderBy(preset => preset.Name),
(presets, _, _) => asyncLoadPanels(presets));
r.All<ModPreset>()
.Filter($"{nameof(ModPreset.Ruleset)}.{nameof(RulesetInfo.ShortName)} == $0"
+ $" && {nameof(ModPreset.DeletePending)} == false", ruleset.Value.ShortName)
.OrderBy(preset => preset.Name), asyncLoadPanels);
}
private CancellationTokenSource? cancellationTokenSource;
private Task? latestLoadTask;
internal bool ItemsLoaded => latestLoadTask == null;
internal bool ItemsLoaded => latestLoadTask?.IsCompleted == true;
private void asyncLoadPanels(IReadOnlyList<ModPreset> presets)
private void asyncLoadPanels(IRealmCollection<ModPreset> presets, ChangeSet changes, Exception error)
{
cancellationTokenSource?.Cancel();
@ -72,23 +70,14 @@ namespace osu.Game.Overlays.Mods
return;
}
var panels = presets.Select(preset => new ModPresetPanel(preset.ToLive(realm))
latestLoadTask = LoadComponentsAsync(presets.Select(p => new ModPresetPanel(p.ToLive(realm))
{
Shear = Vector2.Zero
});
Task? loadTask;
latestLoadTask = loadTask = LoadComponentsAsync(panels, loaded =>
}), loaded =>
{
ItemsFlow.RemoveAll(panel => panel is ModPresetPanel);
ItemsFlow.AddRange(loaded);
}, (cancellationTokenSource = new CancellationTokenSource()).Token);
loadTask.ContinueWith(_ =>
{
if (loadTask == latestLoadTask)
latestLoadTask = null;
});
}
protected override void Dispose(bool isDisposing)