2019-07-08 13:55:05 +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.
|
|
|
|
|
2019-07-08 21:37:39 +08:00
|
|
|
using System;
|
2019-07-08 13:55:05 +08:00
|
|
|
using osu.Framework.Allocation;
|
2019-07-08 14:40:10 +08:00
|
|
|
using osu.Game.Scoring;
|
2019-07-08 13:55:05 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Screens.Play
|
|
|
|
{
|
|
|
|
public class ReplayPlayerLoader : PlayerLoader
|
|
|
|
{
|
2019-07-08 16:37:20 +08:00
|
|
|
private readonly ScoreInfo scoreInfo;
|
2019-07-08 13:55:05 +08:00
|
|
|
|
2019-07-08 15:13:03 +08:00
|
|
|
public ReplayPlayerLoader(Score score)
|
2019-07-08 14:40:10 +08:00
|
|
|
: base(() => new ReplayPlayer(score))
|
2019-07-08 13:55:05 +08:00
|
|
|
{
|
2019-07-08 21:37:39 +08:00
|
|
|
if (score.Replay == null)
|
|
|
|
throw new ArgumentNullException(nameof(score.Replay), $"{nameof(score)} must have a non-null {nameof(score.Replay)}.");
|
|
|
|
|
2019-07-08 16:37:20 +08:00
|
|
|
scoreInfo = score.ScoreInfo;
|
2019-07-08 13:55:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
|
|
|
{
|
2019-07-08 16:57:29 +08:00
|
|
|
var dependencies = base.CreateChildDependencies(parent);
|
2019-07-08 14:40:10 +08:00
|
|
|
|
2019-07-08 21:37:39 +08:00
|
|
|
// these will be reverted thanks to PlayerLoader's lease.
|
2019-07-08 16:37:20 +08:00
|
|
|
Mods.Value = scoreInfo.Mods;
|
|
|
|
Ruleset.Value = scoreInfo.Ruleset;
|
2019-07-08 13:55:05 +08:00
|
|
|
|
2019-07-08 14:40:10 +08:00
|
|
|
return dependencies;
|
2019-07-08 13:55:05 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|