2019-12-21 09:26:58 +00: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-12-21 09:53:05 +00:00
|
|
|
using System;
|
2019-12-21 09:26:58 +00:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
using NUnit.Framework;
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Audio;
|
|
|
|
using osu.Framework.IO.Stores;
|
2019-12-25 06:01:05 +00:00
|
|
|
using osu.Framework.Testing;
|
2019-12-21 09:26:58 +00:00
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
using osu.Game.Rulesets.Osu.Objects;
|
|
|
|
using osu.Game.Screens.Play;
|
|
|
|
using osu.Game.Skinning;
|
|
|
|
using osu.Game.Tests.Visual;
|
|
|
|
using osuTK;
|
|
|
|
using osuTK.Graphics;
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.Tests
|
|
|
|
{
|
2020-01-31 05:56:42 +00:00
|
|
|
public class TestSceneLegacyBeatmapSkin : ScreenTestScene
|
2019-12-21 09:26:58 +00:00
|
|
|
{
|
|
|
|
[Resolved]
|
|
|
|
private AudioManager audio { get; set; }
|
|
|
|
|
2019-12-25 06:05:08 +00:00
|
|
|
[TestCase(true)]
|
|
|
|
[TestCase(false)]
|
|
|
|
public void TestBeatmapComboColours(bool customSkinColoursPresent)
|
2019-12-21 09:26:58 +00:00
|
|
|
{
|
|
|
|
ExposedPlayer player = null;
|
|
|
|
|
2019-12-25 06:05:08 +00:00
|
|
|
AddStep("load coloured beatmap", () => player = loadBeatmap(customSkinColoursPresent, true));
|
2019-12-21 09:26:58 +00:00
|
|
|
AddUntilStep("wait for player", () => player.IsLoaded);
|
|
|
|
|
2019-12-25 06:01:05 +00:00
|
|
|
AddAssert("is beatmap skin colours", () => player.UsableComboColours.SequenceEqual(TestBeatmapSkin.Colours));
|
2019-12-21 09:26:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
2019-12-25 06:05:08 +00:00
|
|
|
public void TestBeatmapNoComboColours()
|
2019-12-21 09:26:58 +00:00
|
|
|
{
|
|
|
|
ExposedPlayer player = null;
|
|
|
|
|
|
|
|
AddStep("load no-colour beatmap", () => player = loadBeatmap(false, false));
|
|
|
|
AddUntilStep("wait for player", () => player.IsLoaded);
|
|
|
|
|
2019-12-25 06:01:05 +00:00
|
|
|
AddAssert("is default user skin colours", () => player.UsableComboColours.SequenceEqual(SkinConfiguration.DefaultComboColours));
|
2019-12-21 09:26:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
2019-12-25 06:05:08 +00:00
|
|
|
public void TestBeatmapNoComboColoursSkinOverride()
|
2019-12-21 09:26:58 +00:00
|
|
|
{
|
|
|
|
ExposedPlayer player = null;
|
|
|
|
|
2019-12-25 06:01:05 +00:00
|
|
|
AddStep("load custom-skin colour", () => player = loadBeatmap(true, false));
|
2019-12-21 09:26:58 +00:00
|
|
|
AddUntilStep("wait for player", () => player.IsLoaded);
|
|
|
|
|
2019-12-25 06:01:05 +00:00
|
|
|
AddAssert("is custom user skin colours", () => player.UsableComboColours.SequenceEqual(TestSkin.Colours));
|
2019-12-21 09:26:58 +00:00
|
|
|
}
|
|
|
|
|
2019-12-21 09:53:05 +00:00
|
|
|
private ExposedPlayer loadBeatmap(bool userHasCustomColours, bool beatmapHasColours)
|
2019-12-21 09:26:58 +00:00
|
|
|
{
|
|
|
|
ExposedPlayer player;
|
|
|
|
|
2019-12-21 09:53:05 +00:00
|
|
|
Beatmap.Value = new CustomSkinWorkingBeatmap(audio, beatmapHasColours);
|
2020-01-31 05:56:42 +00:00
|
|
|
|
|
|
|
LoadScreen(player = new ExposedPlayer(userHasCustomColours));
|
2019-12-21 09:26:58 +00:00
|
|
|
|
|
|
|
return player;
|
|
|
|
}
|
|
|
|
|
|
|
|
private class ExposedPlayer : Player
|
|
|
|
{
|
2019-12-21 09:53:05 +00:00
|
|
|
private readonly bool userHasCustomColours;
|
|
|
|
|
|
|
|
public ExposedPlayer(bool userHasCustomColours)
|
2019-12-21 09:26:58 +00:00
|
|
|
: base(false, false)
|
|
|
|
{
|
2019-12-21 09:53:05 +00:00
|
|
|
this.userHasCustomColours = userHasCustomColours;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
|
|
|
{
|
|
|
|
var dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
|
|
|
dependencies.CacheAs<ISkinSource>(new TestSkin(userHasCustomColours));
|
|
|
|
return dependencies;
|
2019-12-21 09:26:58 +00:00
|
|
|
}
|
|
|
|
|
2019-12-25 06:01:05 +00:00
|
|
|
public IReadOnlyList<Color4> UsableComboColours =>
|
|
|
|
GameplayClockContainer.ChildrenOfType<BeatmapSkinProvidingContainer>()
|
|
|
|
.First()
|
2020-02-07 05:58:07 +00:00
|
|
|
.GetConfig<GlobalSkinColours, IReadOnlyList<Color4>>(GlobalSkinColours.ComboColours)?.Value;
|
2019-12-21 09:26:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private class CustomSkinWorkingBeatmap : ClockBackedTestWorkingBeatmap
|
|
|
|
{
|
|
|
|
private readonly bool hasColours;
|
|
|
|
|
|
|
|
public CustomSkinWorkingBeatmap(AudioManager audio, bool hasColours)
|
|
|
|
: base(new Beatmap
|
|
|
|
{
|
|
|
|
BeatmapInfo =
|
|
|
|
{
|
|
|
|
BeatmapSet = new BeatmapSetInfo(),
|
|
|
|
Ruleset = new OsuRuleset().RulesetInfo,
|
|
|
|
},
|
|
|
|
HitObjects = { new HitCircle { Position = new Vector2(256, 192) } }
|
|
|
|
}, null, null, audio)
|
|
|
|
{
|
|
|
|
this.hasColours = hasColours;
|
|
|
|
}
|
|
|
|
|
2020-08-31 16:29:46 +00:00
|
|
|
protected override ISkin GetSkin() => new TestBeatmapSkin(BeatmapInfo, hasColours);
|
2019-12-21 09:26:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private class TestBeatmapSkin : LegacyBeatmapSkin
|
|
|
|
{
|
|
|
|
public static Color4[] Colours { get; } =
|
|
|
|
{
|
|
|
|
new Color4(50, 100, 150, 255),
|
|
|
|
new Color4(40, 80, 120, 255),
|
|
|
|
};
|
|
|
|
|
|
|
|
public TestBeatmapSkin(BeatmapInfo beatmap, bool hasColours)
|
|
|
|
: base(beatmap, new ResourceStore<byte[]>(), null)
|
|
|
|
{
|
|
|
|
if (hasColours)
|
|
|
|
Configuration.AddComboColours(Colours);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-21 09:53:05 +00:00
|
|
|
private class TestSkin : LegacySkin, ISkinSource
|
2019-12-21 09:26:58 +00:00
|
|
|
{
|
|
|
|
public static Color4[] Colours { get; } =
|
|
|
|
{
|
2019-12-25 05:55:13 +00:00
|
|
|
new Color4(150, 100, 50, 255),
|
2019-12-21 09:26:58 +00:00
|
|
|
new Color4(20, 20, 20, 255),
|
|
|
|
};
|
|
|
|
|
|
|
|
public TestSkin(bool hasCustomColours)
|
|
|
|
: base(new SkinInfo(), null, null, string.Empty)
|
|
|
|
{
|
|
|
|
if (hasCustomColours)
|
|
|
|
Configuration.AddComboColours(Colours);
|
|
|
|
}
|
2019-12-21 09:53:05 +00:00
|
|
|
|
|
|
|
public event Action SourceChanged
|
|
|
|
{
|
|
|
|
add { }
|
|
|
|
remove { }
|
|
|
|
}
|
2019-12-21 09:26:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|