mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 10:33:30 +08:00
Add score importer
This commit is contained in:
parent
0dd23c46b0
commit
a5df01ff47
@ -28,7 +28,7 @@ namespace osu.Game.Beatmaps
|
||||
DateTimeOffset? LastUpdated { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The status of this beatmap set.
|
||||
/// The "ranked" status of this beatmap set.
|
||||
/// </summary>
|
||||
BeatmapOnlineStatus Status { get; }
|
||||
|
||||
|
64
osu.Game/Stores/ScoreImporter.cs
Normal file
64
osu.Game/Stores/ScoreImporter.cs
Normal file
@ -0,0 +1,64 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.IO.Archives;
|
||||
using osu.Game.Models;
|
||||
using osu.Game.Scoring.Legacy;
|
||||
using Realms;
|
||||
|
||||
#nullable enable
|
||||
|
||||
namespace osu.Game.Stores
|
||||
{
|
||||
/// <summary>
|
||||
/// Handles the storage and retrieval of Scores/WorkingScores.
|
||||
/// </summary>
|
||||
[ExcludeFromDynamicCompile]
|
||||
public class ScoreImporter : RealmArchiveModelImporter<RealmScore>
|
||||
{
|
||||
private readonly RealmRulesetStore rulesets;
|
||||
private readonly BeatmapManager beatmaps;
|
||||
|
||||
public override IEnumerable<string> HandledExtensions => new[] { ".osr" };
|
||||
|
||||
protected override string[] HashableFileTypes => new[] { ".osr" };
|
||||
|
||||
public ScoreImporter(RealmRulesetStore rulesets, RealmContextFactory contextFactory, Storage storage, BeatmapManager beatmaps)
|
||||
: base(storage, contextFactory)
|
||||
{
|
||||
this.rulesets = rulesets;
|
||||
this.beatmaps = beatmaps;
|
||||
}
|
||||
|
||||
protected override RealmScore? CreateModel(ArchiveReader archive)
|
||||
{
|
||||
using (var stream = archive.GetStream(archive.Filenames.First(f => f.EndsWith(".osr", StringComparison.OrdinalIgnoreCase))))
|
||||
{
|
||||
try
|
||||
{
|
||||
// TODO: make work.
|
||||
// return new DatabasedLegacyScoreDecoder(rulesets, beatmaps).Parse(stream).ScoreInfo;
|
||||
return new RealmScore();
|
||||
}
|
||||
catch (LegacyScoreDecoder.BeatmapNotFoundException e)
|
||||
{
|
||||
Logger.Log(e.Message, LoggingTarget.Information, LogLevel.Error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override Task Populate(RealmScore model, ArchiveReader? archive, Realm realm, CancellationToken cancellationToken = default)
|
||||
=> Task.CompletedTask;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user