2021-01-15 04:30:24 +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.
|
|
|
|
|
|
|
|
using System.Linq;
|
|
|
|
using NUnit.Framework;
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Audio;
|
|
|
|
using osu.Framework.Testing;
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
using osu.Game.Configuration;
|
|
|
|
using osu.Game.Rulesets.Catch.Objects;
|
|
|
|
using osu.Game.Rulesets.Catch.Skinning;
|
|
|
|
using osu.Game.Skinning;
|
2021-01-16 04:46:46 +00:00
|
|
|
using osu.Game.Tests.Beatmaps;
|
2021-01-15 04:30:24 +00:00
|
|
|
using osuTK.Graphics;
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Catch.Tests
|
|
|
|
{
|
2021-01-16 04:46:46 +00:00
|
|
|
public class TestSceneLegacyBeatmapSkin : LegacyBeatmapSkinColourTest
|
2021-01-15 04:30:24 +00:00
|
|
|
{
|
|
|
|
[Resolved]
|
|
|
|
private AudioManager audio { get; set; }
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(OsuConfigManager config)
|
|
|
|
{
|
2021-01-16 04:46:46 +00:00
|
|
|
config.BindWith(OsuSetting.BeatmapSkins, BeatmapSkins);
|
|
|
|
config.BindWith(OsuSetting.BeatmapColours, BeatmapColours);
|
2021-01-15 04:30:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[TestCase(true, true)]
|
|
|
|
[TestCase(true, false)]
|
|
|
|
[TestCase(false, true)]
|
|
|
|
[TestCase(false, false)]
|
2021-01-16 04:46:46 +00:00
|
|
|
public override void TestBeatmapComboColours(bool userHasCustomColours, bool useBeatmapSkin)
|
2021-01-15 04:30:24 +00:00
|
|
|
{
|
2021-01-16 04:46:46 +00:00
|
|
|
TestBeatmap = new CatchCustomSkinWorkingBeatmap(audio, true);
|
|
|
|
base.TestBeatmapComboColours(userHasCustomColours, useBeatmapSkin);
|
|
|
|
AddAssert("is beatmap skin colours", () => TestPlayer.UsableComboColours.SequenceEqual(TestBeatmapSkin.Colours));
|
2021-01-15 04:30:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[TestCase(true)]
|
|
|
|
[TestCase(false)]
|
2021-01-16 04:46:46 +00:00
|
|
|
public override void TestBeatmapComboColoursOverride(bool useBeatmapSkin)
|
2021-01-15 04:30:24 +00:00
|
|
|
{
|
2021-01-16 04:46:46 +00:00
|
|
|
TestBeatmap = new CatchCustomSkinWorkingBeatmap(audio, true);
|
|
|
|
base.TestBeatmapComboColoursOverride(useBeatmapSkin);
|
|
|
|
AddAssert("is user custom skin colours", () => TestPlayer.UsableComboColours.SequenceEqual(TestSkin.Colours));
|
2021-01-15 04:30:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[TestCase(true)]
|
|
|
|
[TestCase(false)]
|
2021-01-16 04:46:46 +00:00
|
|
|
public override void TestBeatmapComboColoursOverrideWithDefaultColours(bool useBeatmapSkin)
|
2021-01-15 04:30:24 +00:00
|
|
|
{
|
2021-01-16 04:46:46 +00:00
|
|
|
TestBeatmap = new CatchCustomSkinWorkingBeatmap(audio, true);
|
|
|
|
base.TestBeatmapComboColoursOverrideWithDefaultColours(useBeatmapSkin);
|
|
|
|
AddAssert("is default user skin colours", () => TestPlayer.UsableComboColours.SequenceEqual(SkinConfiguration.DefaultComboColours));
|
2021-01-15 04:30:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[TestCase(true, true)]
|
|
|
|
[TestCase(false, true)]
|
|
|
|
[TestCase(true, false)]
|
|
|
|
[TestCase(false, false)]
|
2021-01-16 04:46:46 +00:00
|
|
|
public override void TestBeatmapNoComboColours(bool useBeatmapSkin, bool useBeatmapColour)
|
2021-01-15 04:30:24 +00:00
|
|
|
{
|
2021-01-16 04:46:46 +00:00
|
|
|
TestBeatmap = new CatchCustomSkinWorkingBeatmap(audio, false);
|
|
|
|
base.TestBeatmapNoComboColours(useBeatmapSkin, useBeatmapColour);
|
|
|
|
AddAssert("is default user skin colours", () => TestPlayer.UsableComboColours.SequenceEqual(SkinConfiguration.DefaultComboColours));
|
2021-01-15 04:30:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[TestCase(true, true)]
|
|
|
|
[TestCase(false, true)]
|
|
|
|
[TestCase(true, false)]
|
|
|
|
[TestCase(false, false)]
|
2021-01-16 04:46:46 +00:00
|
|
|
public override void TestBeatmapNoComboColoursSkinOverride(bool useBeatmapSkin, bool useBeatmapColour)
|
2021-01-15 04:30:24 +00:00
|
|
|
{
|
2021-01-16 04:46:46 +00:00
|
|
|
TestBeatmap = new CatchCustomSkinWorkingBeatmap(audio, false);
|
|
|
|
base.TestBeatmapNoComboColoursSkinOverride(useBeatmapSkin, useBeatmapColour);
|
|
|
|
AddAssert("is custom user skin colours", () => TestPlayer.UsableComboColours.SequenceEqual(TestSkin.Colours));
|
2021-01-15 04:30:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[TestCase(true)]
|
|
|
|
[TestCase(false)]
|
|
|
|
public void TestBeatmapHyperDashColours(bool useBeatmapSkin)
|
|
|
|
{
|
2021-01-16 04:46:46 +00:00
|
|
|
TestBeatmap = new CatchCustomSkinWorkingBeatmap(audio, true);
|
|
|
|
ConfigureTest(useBeatmapSkin, true, true);
|
2021-01-16 07:09:35 +00:00
|
|
|
AddAssert("is custom hyper dash colours", () => ((CatchExposedPlayer)TestPlayer).UsableHyperDashColour == TestBeatmapSkin.HYPER_DASH_COLOUR);
|
|
|
|
AddAssert("is custom hyper dash after image colours", () => ((CatchExposedPlayer)TestPlayer).UsableHyperDashAfterImageColour == TestBeatmapSkin.HYPER_DASH_AFTER_IMAGE_COLOUR);
|
|
|
|
AddAssert("is custom hyper dash fruit colours", () => ((CatchExposedPlayer)TestPlayer).UsableHyperDashFruitColour == TestBeatmapSkin.HYPER_DASH_FRUIT_COLOUR);
|
2021-01-15 04:30:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[TestCase(true)]
|
|
|
|
[TestCase(false)]
|
|
|
|
public void TestBeatmapHyperDashColoursOverride(bool useBeatmapSkin)
|
|
|
|
{
|
2021-01-16 04:46:46 +00:00
|
|
|
TestBeatmap = new CatchCustomSkinWorkingBeatmap(audio, true);
|
|
|
|
ConfigureTest(useBeatmapSkin, false, true);
|
2021-01-16 07:09:35 +00:00
|
|
|
AddAssert("is custom hyper dash colours", () => ((CatchExposedPlayer)TestPlayer).UsableHyperDashColour == TestSkin.HYPER_DASH_COLOUR);
|
|
|
|
AddAssert("is custom hyper dash after image colours", () => ((CatchExposedPlayer)TestPlayer).UsableHyperDashAfterImageColour == TestSkin.HYPER_DASH_AFTER_IMAGE_COLOUR);
|
|
|
|
AddAssert("is custom hyper dash fruit colours", () => ((CatchExposedPlayer)TestPlayer).UsableHyperDashFruitColour == TestSkin.HYPER_DASH_FRUIT_COLOUR);
|
2021-01-15 04:30:24 +00:00
|
|
|
}
|
|
|
|
|
2021-01-16 04:46:46 +00:00
|
|
|
protected override ExposedPlayer CreateTestPlayer(bool userHasCustomColours) => new CatchExposedPlayer(userHasCustomColours);
|
2021-01-15 04:30:24 +00:00
|
|
|
|
2021-01-16 04:46:46 +00:00
|
|
|
private class CatchExposedPlayer : ExposedPlayer
|
2021-01-15 04:30:24 +00:00
|
|
|
{
|
2021-01-16 04:46:46 +00:00
|
|
|
public CatchExposedPlayer(bool userHasCustomColours)
|
|
|
|
: base(userHasCustomColours)
|
2021-01-15 04:30:24 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public Color4 UsableHyperDashColour =>
|
|
|
|
GameplayClockContainer.ChildrenOfType<BeatmapSkinProvidingContainer>()
|
|
|
|
.First()
|
|
|
|
.GetConfig<SkinCustomColourLookup, Color4>(new SkinCustomColourLookup(CatchSkinColour.HyperDash))?
|
|
|
|
.Value ?? Color4.Red;
|
|
|
|
|
|
|
|
public Color4 UsableHyperDashAfterImageColour =>
|
|
|
|
GameplayClockContainer.ChildrenOfType<BeatmapSkinProvidingContainer>()
|
|
|
|
.First()
|
|
|
|
.GetConfig<SkinCustomColourLookup, Color4>(new SkinCustomColourLookup(CatchSkinColour.HyperDashAfterImage))?
|
|
|
|
.Value ?? Color4.Red;
|
|
|
|
|
|
|
|
public Color4 UsableHyperDashFruitColour =>
|
|
|
|
GameplayClockContainer.ChildrenOfType<BeatmapSkinProvidingContainer>()
|
|
|
|
.First()
|
|
|
|
.GetConfig<SkinCustomColourLookup, Color4>(new SkinCustomColourLookup(CatchSkinColour.HyperDashFruit))?
|
|
|
|
.Value ?? Color4.Red;
|
|
|
|
}
|
|
|
|
|
2021-01-16 04:46:46 +00:00
|
|
|
private class CatchCustomSkinWorkingBeatmap : CustomSkinWorkingBeatmap
|
2021-01-15 04:30:24 +00:00
|
|
|
{
|
2021-01-16 04:46:46 +00:00
|
|
|
public CatchCustomSkinWorkingBeatmap(AudioManager audio, bool hasColours)
|
2021-01-16 07:09:35 +00:00
|
|
|
: base(createBeatmap(), audio, hasColours)
|
2021-01-15 04:30:24 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-01-16 07:09:35 +00:00
|
|
|
private static IBeatmap createBeatmap() =>
|
|
|
|
new Beatmap
|
2021-01-15 04:30:24 +00:00
|
|
|
{
|
|
|
|
BeatmapInfo =
|
|
|
|
{
|
2021-01-16 07:09:35 +00:00
|
|
|
BeatmapSet = new BeatmapSetInfo(),
|
|
|
|
Ruleset = new CatchRuleset().RulesetInfo
|
|
|
|
},
|
|
|
|
HitObjects = { new Fruit { StartTime = 1816, X = 56, NewCombo = true } }
|
2021-01-15 04:30:24 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|