2019-01-24 16:43:03 +08:00
|
|
|
// 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.
|
2018-11-28 17:45:17 +08:00
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
#nullable disable
|
|
|
|
|
2018-11-28 17:45:17 +08:00
|
|
|
using System;
|
|
|
|
using System.Linq;
|
|
|
|
using osu.Framework.IO.Stores;
|
|
|
|
using osu.Game.Beatmaps;
|
2021-11-19 15:07:55 +08:00
|
|
|
using osu.Game.Extensions;
|
2021-12-14 18:47:11 +08:00
|
|
|
using osu.Game.Rulesets;
|
2018-11-28 17:45:17 +08:00
|
|
|
using osu.Game.Scoring.Legacy;
|
|
|
|
|
|
|
|
namespace osu.Game.Scoring
|
|
|
|
{
|
|
|
|
public class LegacyDatabasedScore : Score
|
|
|
|
{
|
2021-12-14 18:47:11 +08:00
|
|
|
public LegacyDatabasedScore(ScoreInfo score, RulesetStore rulesets, BeatmapManager beatmaps, IResourceStore<byte[]> store)
|
2018-11-28 17:45:17 +08:00
|
|
|
{
|
2018-11-30 14:18:52 +08:00
|
|
|
ScoreInfo = score;
|
2018-11-28 17:45:17 +08:00
|
|
|
|
2021-12-06 21:47:00 +08:00
|
|
|
string replayFilename = score.Files.FirstOrDefault(f => f.Filename.EndsWith(".osr", StringComparison.InvariantCultureIgnoreCase))?.File.GetStoragePath();
|
2020-06-15 19:31:47 +08:00
|
|
|
|
|
|
|
if (replayFilename == null)
|
|
|
|
return;
|
2018-11-28 17:45:17 +08:00
|
|
|
|
|
|
|
using (var stream = store.GetStream(replayFilename))
|
2022-08-30 17:18:46 +08:00
|
|
|
{
|
|
|
|
if (stream == null)
|
|
|
|
return;
|
|
|
|
|
2020-03-24 09:38:24 +08:00
|
|
|
Replay = new DatabasedLegacyScoreDecoder(rulesets, beatmaps).Parse(stream).Replay;
|
2022-08-30 17:18:46 +08:00
|
|
|
}
|
2018-11-28 17:45:17 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|