mirror of
https://github.com/ppy/osu.git
synced 2024-11-12 08:27:26 +08:00
47 lines
1.2 KiB
C#
47 lines
1.2 KiB
C#
|
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
|||
|
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|||
|
|
|||
|
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;
|
|||
|
|
|||
|
public BeatmapImporter(BasicGameHost host, BeatmapDatabase beatmaps = null)
|
|||
|
{
|
|||
|
this.beatmaps = beatmaps;
|
|||
|
|
|||
|
channel = new IpcChannel<BeatmapImportMessage>(host);
|
|||
|
channel.MessageReceived += messageReceived;
|
|||
|
}
|
|||
|
|
|||
|
public async Task Import(string path)
|
|||
|
{
|
|||
|
if (beatmaps != null)
|
|||
|
beatmaps.Import(path);
|
|||
|
else
|
|||
|
{
|
|||
|
await channel.SendMessage(new BeatmapImportMessage { Path = path });
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void messageReceived(BeatmapImportMessage msg)
|
|||
|
{
|
|||
|
Debug.Assert(beatmaps != null);
|
|||
|
|
|||
|
Import(msg.Path);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public class BeatmapImportMessage
|
|||
|
{
|
|||
|
public string Path;
|
|||
|
}
|
|||
|
}
|