Make a RulesetDatabase.

This commit is contained in:
Dean Herbert
2017-04-17 17:43:48 +09:00
parent 83b083ce64
commit a4e2f34ee7
38 changed files with 298 additions and 201 deletions

View File

@ -7,7 +7,6 @@ using System.Linq;
using osu.Framework.Platform;
using osu.Game.IO.Legacy;
using osu.Game.IPC;
using osu.Game.Modes;
using osu.Game.Modes.Scoring;
using SharpCompress.Compressors.LZMA;
using SQLite.Net;
@ -17,17 +16,20 @@ namespace osu.Game.Database
public class ScoreDatabase : Database
{
private readonly Storage storage;
private readonly BeatmapDatabase beatmaps;
private readonly RulesetDatabase rulesets;
private const string replay_folder = @"replays";
// ReSharper disable once NotAccessedField.Local (we should keep a reference to this so it is not finalised)
private ScoreIPCChannel ipc;
public ScoreDatabase(Storage storage, SQLiteConnection connection, IIpcHost importHost = null, BeatmapDatabase beatmaps = null) : base(storage, connection)
public ScoreDatabase(Storage storage, SQLiteConnection connection, IIpcHost importHost = null, BeatmapDatabase beatmaps = null, RulesetDatabase rulesets = null) : base(storage, connection)
{
this.storage = storage;
this.beatmaps = beatmaps;
this.rulesets = rulesets;
if (importHost != null)
ipc = new ScoreIPCChannel(importHost, this);
@ -40,7 +42,7 @@ namespace osu.Game.Database
using (Stream s = storage.GetStream(Path.Combine(replay_folder, replayFilename)))
using (SerializationReader sr = new SerializationReader(s))
{
var ruleset = RulesetCollection.GetRuleset(sr.ReadByte());
var ruleset = rulesets.GetRuleset(sr.ReadByte()).CreateInstance();
score = ruleset.CreateScoreProcessor().CreateScore();
/* score.Pass = true;*/
@ -116,5 +118,7 @@ namespace osu.Game.Database
public override void Reset()
{
}
protected override Type[] ValidTypes => new[] { typeof(Score) };
}
}