mirror of
https://github.com/osukey/osukey.git
synced 2025-08-03 06:36:31 +09:00
Crentalise all import logic
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using osu.Framework.Platform;
|
||||
@ -14,7 +15,7 @@ using SharpCompress.Compressors.LZMA;
|
||||
|
||||
namespace osu.Game.Rulesets.Scoring
|
||||
{
|
||||
public class ScoreStore : DatabaseBackedStore
|
||||
public class ScoreStore : DatabaseBackedStore, ICanAcceptFiles
|
||||
{
|
||||
private readonly Storage storage;
|
||||
|
||||
@ -23,6 +24,8 @@ namespace osu.Game.Rulesets.Scoring
|
||||
|
||||
private const string replay_folder = @"replays";
|
||||
|
||||
public event Action<Score> ScoreImported;
|
||||
|
||||
// ReSharper disable once NotAccessedField.Local (we should keep a reference to this so it is not finalised)
|
||||
private ScoreIPCChannel ipc;
|
||||
|
||||
@ -36,6 +39,18 @@ namespace osu.Game.Rulesets.Scoring
|
||||
ipc = new ScoreIPCChannel(importHost, this);
|
||||
}
|
||||
|
||||
public string[] HandledExtensions => new[] { ".osr" };
|
||||
|
||||
public void Import(params string[] paths)
|
||||
{
|
||||
foreach (var path in paths)
|
||||
{
|
||||
var score = ReadReplayFile(path);
|
||||
if (score != null)
|
||||
ScoreImported?.Invoke(score);
|
||||
}
|
||||
}
|
||||
|
||||
public Score ReadReplayFile(string replayFilename)
|
||||
{
|
||||
Score score;
|
||||
@ -159,5 +174,6 @@ namespace osu.Game.Rulesets.Scoring
|
||||
|
||||
return new Replay { Frames = frames };
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user