1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-24 08:07:26 +08:00
osu-lazer/osu.Game/Tests/Visual/LegacySkinPlayerTestScene.cs

67 lines
2.3 KiB
C#
Raw Normal View History

2020-12-01 08:49:04 +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.
using System.Linq;
2020-12-01 08:49:04 +08:00
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Audio;
2020-12-01 08:49:04 +08:00
using osu.Framework.IO.Stores;
using osu.Framework.Testing;
using osu.Framework.Timing;
using osu.Game.Beatmaps;
2020-12-01 08:49:04 +08:00
using osu.Game.Rulesets;
using osu.Game.Skinning;
using osu.Game.Storyboards;
2020-12-01 08:49:04 +08:00
namespace osu.Game.Tests.Visual
{
[TestFixture]
public abstract class LegacySkinPlayerTestScene : PlayerTestScene
{
2021-05-15 23:02:38 +08:00
protected LegacySkin LegacySkin { get; private set; }
2020-12-01 08:49:04 +08:00
private ISkinSource legacySkinSource;
protected override TestPlayer CreatePlayer(Ruleset ruleset) => new SkinProvidingPlayer(legacySkinSource);
protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard = null)
=> new LegacySkinWorkingBeatmap(beatmap, storyboard, Clock, Audio);
2020-12-01 08:49:04 +08:00
[BackgroundDependencyLoader]
private void load(OsuGameBase game, SkinManager skins)
2020-12-01 08:49:04 +08:00
{
2021-05-15 23:02:38 +08:00
LegacySkin = new DefaultLegacySkin(new NamespacedResourceStore<byte[]>(game.Resources, "Skins/Legacy"), skins);
legacySkinSource = new SkinProvidingContainer(LegacySkin);
2020-12-01 08:49:04 +08:00
}
public override void SetUpSteps()
{
base.SetUpSteps();
// check presence of a random legacy HUD component to ensure this is using legacy skin.
AddAssert("using legacy skin", () => this.ChildrenOfType<LegacyScoreCounter>().Any());
}
2020-12-01 08:49:04 +08:00
public class SkinProvidingPlayer : TestPlayer
{
[Cached(typeof(ISkinSource))]
private readonly ISkinSource skinSource;
public SkinProvidingPlayer(ISkinSource skinSource)
{
this.skinSource = skinSource;
}
}
private class LegacySkinWorkingBeatmap : ClockBackedTestWorkingBeatmap
{
public LegacySkinWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard, IFrameBasedClock frameBasedClock, AudioManager audio)
: base(beatmap, storyboard, frameBasedClock, audio)
{
}
protected override ISkin GetSkin() => new LegacyBeatmapSkin(BeatmapInfo, null, null);
}
2020-12-01 08:49:04 +08:00
}
}