Move import logic to shared implementation

This commit is contained in:
Dean Herbert
2018-02-14 20:26:49 +09:00
parent af61a524b5
commit e0d28564d0
16 changed files with 340 additions and 209 deletions

View File

@ -111,14 +111,23 @@ namespace osu.Desktop
{
var filePaths = new [] { e.FileName };
if (filePaths.All(f => Path.GetExtension(f) == @".osz"))
Task.Factory.StartNew(() => BeatmapManager.Import(filePaths), TaskCreationOptions.LongRunning);
else if (filePaths.All(f => Path.GetExtension(f) == @".osr"))
Task.Run(() =>
{
var score = ScoreStore.ReadReplayFile(filePaths.First());
Schedule(() => LoadScore(score));
});
var firstExtension = Path.GetExtension(filePaths.First());
if (filePaths.Any(f => Path.GetExtension(f) != firstExtension)) return;
switch (firstExtension)
{
case ".osz":
Task.Factory.StartNew(() => BeatmapManager.Import(filePaths), TaskCreationOptions.LongRunning);
return;
case ".osr":
Task.Run(() =>
{
var score = ScoreStore.ReadReplayFile(filePaths.First());
Schedule(() => LoadScore(score));
});
return;
}
}
private static readonly string[] allowed_extensions = { @".osz", @".osr" };