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.
|
|
|
|
|
2022-06-17 07:37:17 +00:00
|
|
|
#nullable disable
|
|
|
|
|
2021-01-15 04:30:24 +00:00
|
|
|
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 partial 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-05-31 11:00:47 +00:00
|
|
|
public void TestBeatmapComboColours(bool userHasCustomColours, bool useBeatmapSkin)
|
2021-01-15 04:30:24 +00:00
|
|
|
{
|
2021-05-31 10:57:31 +00:00
|
|
|
PrepareBeatmap(() => new CatchCustomSkinWorkingBeatmap(audio, true));
|
2021-05-31 11:00:47 +00:00
|
|
|
ConfigureTest(useBeatmapSkin, true, userHasCustomColours);
|
2021-01-16 04:46:46 +00:00
|
|
|
AddAssert("is beatmap skin colours", () => TestPlayer.UsableComboColours.SequenceEqual(TestBeatmapSkin.Colours));
|
2021-01-15 04:30:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[TestCase(true)]
|
|
|
|
[TestCase(false)]
|
2021-05-31 11:00:47 +00:00
|
|
|
public void TestBeatmapComboColoursOverride(bool useBeatmapSkin)
|
2021-01-15 04:30:24 +00:00
|
|
|
{
|
2021-05-31 10:57:31 +00:00
|
|
|
PrepareBeatmap(() => new CatchCustomSkinWorkingBeatmap(audio, true));
|
2021-05-31 11:00:47 +00:00
|
|
|
ConfigureTest(useBeatmapSkin, false, true);
|
2021-01-16 04:46:46 +00:00
|
|
|
AddAssert("is user custom skin colours", () => TestPlayer.UsableComboColours.SequenceEqual(TestSkin.Colours));
|
2021-01-15 04:30:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[TestCase(true)]
|
|
|
|
[TestCase(false)]
|
2021-05-31 11:00:47 +00:00
|
|
|
public void TestBeatmapComboColoursOverrideWithDefaultColours(bool useBeatmapSkin)
|
2021-01-15 04:30:24 +00:00
|
|
|
{
|
2021-05-31 10:57:31 +00:00
|
|
|
PrepareBeatmap(() => new CatchCustomSkinWorkingBeatmap(audio, true));
|
2021-05-31 11:00:47 +00:00
|
|
|
ConfigureTest(useBeatmapSkin, false, false);
|
2021-01-16 04:46:46 +00:00
|
|
|
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-05-31 11:00:47 +00:00
|
|
|
public void TestBeatmapNoComboColours(bool useBeatmapSkin, bool useBeatmapColour)
|
2021-01-15 04:30:24 +00:00
|
|
|
{
|
2021-05-31 10:57:31 +00:00
|
|
|
PrepareBeatmap(() => new CatchCustomSkinWorkingBeatmap(audio, false));
|
2021-05-31 11:00:47 +00:00
|
|
|
ConfigureTest(useBeatmapSkin, useBeatmapColour, false);
|
2021-01-16 04:46:46 +00:00
|
|
|
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-05-31 11:00:47 +00:00
|
|
|
public void TestBeatmapNoComboColoursSkinOverride(bool useBeatmapSkin, bool useBeatmapColour)
|
2021-01-15 04:30:24 +00:00
|
|
|
{
|
2021-05-31 10:57:31 +00:00
|
|
|
PrepareBeatmap(() => new CatchCustomSkinWorkingBeatmap(audio, false));
|
2021-05-31 11:00:47 +00:00
|
|
|
ConfigureTest(useBeatmapSkin, useBeatmapColour, true);
|
2021-01-16 04:46:46 +00:00
|
|
|
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-05-31 10:57:31 +00:00
|
|
|
PrepareBeatmap(() => new CatchCustomSkinWorkingBeatmap(audio, true));
|
2021-01-16 04:46:46 +00:00
|
|
|
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-05-31 10:57:31 +00:00
|
|
|
PrepareBeatmap(() => new CatchCustomSkinWorkingBeatmap(audio, true));
|
2021-01-16 04:46:46 +00:00
|
|
|
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 partial 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
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|