mirror of
https://github.com/ppy/osu.git
synced 2025-02-15 19:45:43 +08:00
Remove async load (now using loadComponentSingleFile)
This commit is contained in:
parent
0360f7d845
commit
2d7e85f622
@ -40,11 +40,6 @@ namespace osu.Game.Collections
|
|||||||
|
|
||||||
public bool SupportsImportFromStable => RuntimeInfo.IsDesktop;
|
public bool SupportsImportFromStable => RuntimeInfo.IsDesktop;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Whether the user's database has finished loading.
|
|
||||||
/// </summary>
|
|
||||||
public bool DatabaseLoaded { get; private set; }
|
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private GameHost host { get; set; }
|
private GameHost host { get; set; }
|
||||||
|
|
||||||
@ -62,7 +57,12 @@ namespace osu.Game.Collections
|
|||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
Collections.CollectionChanged += collectionsChanged;
|
Collections.CollectionChanged += collectionsChanged;
|
||||||
loadDatabase();
|
|
||||||
|
if (storage.Exists(database_name))
|
||||||
|
{
|
||||||
|
using (var stream = storage.GetStream(database_name))
|
||||||
|
importCollections(readCollections(stream));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void collectionsChanged(object sender, NotifyCollectionChangedEventArgs e)
|
private void collectionsChanged(object sender, NotifyCollectionChangedEventArgs e)
|
||||||
@ -91,17 +91,6 @@ namespace osu.Game.Collections
|
|||||||
backgroundSave();
|
backgroundSave();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadDatabase() => Task.Run(async () =>
|
|
||||||
{
|
|
||||||
if (storage.Exists(database_name))
|
|
||||||
{
|
|
||||||
using (var stream = storage.GetStream(database_name))
|
|
||||||
await import(stream);
|
|
||||||
}
|
|
||||||
|
|
||||||
DatabaseLoaded = true;
|
|
||||||
});
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Set an endpoint for notifications to be posted to.
|
/// Set an endpoint for notifications to be posted to.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -149,14 +138,6 @@ namespace osu.Game.Collections
|
|||||||
|
|
||||||
PostNotification?.Invoke(notification);
|
PostNotification?.Invoke(notification);
|
||||||
|
|
||||||
await import(stream, notification);
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task import(Stream stream, ProgressNotification notification = null) => await Task.Run(async () =>
|
|
||||||
{
|
|
||||||
if (notification != null)
|
|
||||||
notification.Progress = 0;
|
|
||||||
|
|
||||||
var collection = readCollections(stream, notification);
|
var collection = readCollections(stream, notification);
|
||||||
bool importCompleted = false;
|
bool importCompleted = false;
|
||||||
|
|
||||||
@ -169,12 +150,9 @@ namespace osu.Game.Collections
|
|||||||
while (!IsDisposed && !importCompleted)
|
while (!IsDisposed && !importCompleted)
|
||||||
await Task.Delay(10);
|
await Task.Delay(10);
|
||||||
|
|
||||||
if (notification != null)
|
|
||||||
{
|
|
||||||
notification.CompletionText = $"Imported {collection.Count} collections";
|
notification.CompletionText = $"Imported {collection.Count} collections";
|
||||||
notification.State = ProgressNotificationState.Completed;
|
notification.State = ProgressNotificationState.Completed;
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
private void importCollections(List<BeatmapCollection> newCollections)
|
private void importCollections(List<BeatmapCollection> newCollections)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user