mirror of
https://github.com/ppy/osu
synced 2024-12-26 08:53:10 +00:00
Make beatmap importing async.
This commit is contained in:
parent
65a24dfe5d
commit
5ff4028c29
@ -56,7 +56,7 @@ namespace osu.Desktop
|
|||||||
// this method will only be executed if e.Effect in dragEnter gets set to something other that None.
|
// this method will only be executed if e.Effect in dragEnter gets set to something other that None.
|
||||||
var dropData = e.Data.GetData(DataFormats.FileDrop) as object[];
|
var dropData = e.Data.GetData(DataFormats.FileDrop) as object[];
|
||||||
var filePaths = dropData.Select(f => f.ToString()).ToArray();
|
var filePaths = dropData.Select(f => f.ToString()).ToArray();
|
||||||
ImportBeatmaps(filePaths);
|
ImportBeatmapsAsync(filePaths);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void dragEnter(DragEventArgs e)
|
private void dragEnter(DragEventArgs e)
|
||||||
|
@ -25,6 +25,7 @@ using OpenTK;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Graphics.Primitives;
|
using osu.Framework.Graphics.Primitives;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using osu.Game.Overlays.Notifications;
|
using osu.Game.Overlays.Notifications;
|
||||||
|
|
||||||
namespace osu.Game
|
namespace osu.Game
|
||||||
@ -81,7 +82,7 @@ namespace osu.Game
|
|||||||
if (args?.Length > 0)
|
if (args?.Length > 0)
|
||||||
{
|
{
|
||||||
var paths = args.Where(a => !a.StartsWith(@"-"));
|
var paths = args.Where(a => !a.StartsWith(@"-"));
|
||||||
ImportBeatmaps(paths);
|
ImportBeatmapsAsync(paths);
|
||||||
}
|
}
|
||||||
|
|
||||||
Dependencies.Cache(this);
|
Dependencies.Cache(this);
|
||||||
@ -89,9 +90,9 @@ namespace osu.Game
|
|||||||
PlayMode = LocalConfig.GetBindable<PlayMode>(OsuConfig.PlayMode);
|
PlayMode = LocalConfig.GetBindable<PlayMode>(OsuConfig.PlayMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ImportBeatmaps(IEnumerable<string> paths)
|
protected async void ImportBeatmapsAsync(IEnumerable<string> paths)
|
||||||
{
|
{
|
||||||
Schedule(delegate { Dependencies.Get<BeatmapDatabase>().Import(paths); });
|
await Task.Run(() => BeatmapDatabase.Import(paths));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
|
@ -23,6 +23,8 @@ namespace osu.Game
|
|||||||
{
|
{
|
||||||
protected OsuConfigManager LocalConfig;
|
protected OsuConfigManager LocalConfig;
|
||||||
|
|
||||||
|
protected BeatmapDatabase BeatmapDatabase;
|
||||||
|
|
||||||
protected override string MainResourceFile => @"osu.Game.Resources.dll";
|
protected override string MainResourceFile => @"osu.Game.Resources.dll";
|
||||||
|
|
||||||
public APIAccess API;
|
public APIAccess API;
|
||||||
@ -40,7 +42,7 @@ namespace osu.Game
|
|||||||
{
|
{
|
||||||
Dependencies.Cache(this);
|
Dependencies.Cache(this);
|
||||||
Dependencies.Cache(LocalConfig);
|
Dependencies.Cache(LocalConfig);
|
||||||
Dependencies.Cache(new BeatmapDatabase(Host.Storage, Host));
|
Dependencies.Cache(BeatmapDatabase = new BeatmapDatabase(Host.Storage, Host));
|
||||||
Dependencies.Cache(new OsuColour());
|
Dependencies.Cache(new OsuColour());
|
||||||
|
|
||||||
//this completely overrides the framework default. will need to change once we make a proper FontStore.
|
//this completely overrides the framework default. will need to change once we make a proper FontStore.
|
||||||
|
Loading…
Reference in New Issue
Block a user