Create ReplayPlayerLoader for local mod caching

This commit is contained in:
David Zhao 2019-07-08 14:55:05 +09:00
parent 2432878614
commit 2747d7692b
2 changed files with 33 additions and 2 deletions

View File

@ -284,9 +284,8 @@ public void PresentScore(ScoreInfo score)
{
Ruleset.Value = databasedScoreInfo.Ruleset;
Beatmap.Value = BeatmapManager.GetWorkingBeatmap(databasedBeatmap);
Mods.Value = databasedScoreInfo.Mods;
menuScreen.Push(new PlayerLoader(() => new ReplayPlayer(databasedScore)));
menuScreen.Push(new ReplayPlayerLoader(() => new ReplayPlayer(databasedScore), databasedScoreInfo.Mods));
}, $"watch {databasedScoreInfo}", bypassScreenAllowChecks: true);
}

View File

@ -0,0 +1,32 @@
// 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 osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Game.Rulesets.Mods;
namespace osu.Game.Screens.Play
{
public class ReplayPlayerLoader : PlayerLoader
{
private readonly IReadOnlyList<Mod> mods;
public ReplayPlayerLoader(Func<Player> player, IReadOnlyList<Mod> mods)
: base(player)
{
this.mods = mods;
}
private DependencyContainer dependencies;
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
{
dependencies = new DependencyContainer(parent);
dependencies.Cache(new Bindable<IReadOnlyList<Mod>>(mods));
return base.CreateChildDependencies(dependencies);
}
}
}