2017-02-07 04:59:30 +00:00
|
|
|
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
2016-10-21 09:25:22 +00:00
|
|
|
|
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using osu.Framework.Platform;
|
|
|
|
|
using osu.Game.Database;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.IPC
|
|
|
|
|
{
|
|
|
|
|
public class BeatmapImporter
|
|
|
|
|
{
|
|
|
|
|
private IpcChannel<BeatmapImportMessage> channel;
|
|
|
|
|
private BeatmapDatabase beatmaps;
|
|
|
|
|
|
2017-02-23 06:38:17 +00:00
|
|
|
|
public BeatmapImporter(GameHost host, BeatmapDatabase beatmaps = null)
|
2016-10-21 09:25:22 +00:00
|
|
|
|
{
|
|
|
|
|
this.beatmaps = beatmaps;
|
|
|
|
|
|
|
|
|
|
channel = new IpcChannel<BeatmapImportMessage>(host);
|
|
|
|
|
channel.MessageReceived += messageReceived;
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-23 21:32:10 +00:00
|
|
|
|
public async Task ImportAsync(string path)
|
2016-10-21 09:25:22 +00:00
|
|
|
|
{
|
|
|
|
|
if (beatmaps != null)
|
|
|
|
|
beatmaps.Import(path);
|
|
|
|
|
else
|
|
|
|
|
{
|
2017-02-23 21:32:10 +00:00
|
|
|
|
await channel.SendMessageAsync(new BeatmapImportMessage { Path = path });
|
2016-10-21 09:25:22 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void messageReceived(BeatmapImportMessage msg)
|
|
|
|
|
{
|
|
|
|
|
Debug.Assert(beatmaps != null);
|
|
|
|
|
|
2017-02-23 21:32:10 +00:00
|
|
|
|
ImportAsync(msg.Path);
|
2016-10-21 09:25:22 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class BeatmapImportMessage
|
|
|
|
|
{
|
|
|
|
|
public string Path;
|
|
|
|
|
}
|
|
|
|
|
}
|