2019-12-21 17:26:58 +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.
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
#nullable disable
|
|
|
|
|
2021-05-05 14:22:19 +08:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
2019-12-21 17:26:58 +08:00
|
|
|
using System.Linq;
|
|
|
|
using NUnit.Framework;
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Audio;
|
|
|
|
using osu.Game.Beatmaps;
|
2021-01-13 13:09:22 +08:00
|
|
|
using osu.Game.Configuration;
|
2021-07-22 21:15:23 +08:00
|
|
|
using osu.Game.Rulesets.Objects;
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
2019-12-21 17:26:58 +08:00
|
|
|
using osu.Game.Rulesets.Osu.Objects;
|
|
|
|
using osu.Game.Skinning;
|
2021-01-16 12:46:46 +08:00
|
|
|
using osu.Game.Tests.Beatmaps;
|
2019-12-21 17:26:58 +08:00
|
|
|
using osuTK;
|
2021-05-05 14:22:19 +08:00
|
|
|
using osuTK.Graphics;
|
2019-12-21 17:26:58 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.Tests
|
|
|
|
{
|
2022-11-24 13:32:20 +08:00
|
|
|
public partial class TestSceneLegacyBeatmapSkin : LegacyBeatmapSkinColourTest
|
2019-12-21 17:26:58 +08:00
|
|
|
{
|
|
|
|
[Resolved]
|
|
|
|
private AudioManager audio { get; set; }
|
|
|
|
|
2021-01-13 13:09:22 +08:00
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(OsuConfigManager config)
|
|
|
|
{
|
2021-01-16 12:46:46 +08:00
|
|
|
config.BindWith(OsuSetting.BeatmapSkins, BeatmapSkins);
|
|
|
|
config.BindWith(OsuSetting.BeatmapColours, BeatmapColours);
|
2022-11-02 17:14:20 +08:00
|
|
|
|
|
|
|
config.SetValue(OsuSetting.ComboColourNormalisationAmount, 0f);
|
2021-01-13 13:09:22 +08:00
|
|
|
}
|
|
|
|
|
2021-01-14 05:05:46 +08:00
|
|
|
[TestCase(true, true)]
|
|
|
|
[TestCase(true, false)]
|
|
|
|
[TestCase(false, true)]
|
|
|
|
[TestCase(false, false)]
|
2021-05-31 19:00:47 +08:00
|
|
|
public void TestBeatmapComboColours(bool userHasCustomColours, bool useBeatmapSkin)
|
2019-12-21 17:26:58 +08:00
|
|
|
{
|
2021-05-31 18:57:31 +08:00
|
|
|
PrepareBeatmap(() => new OsuCustomSkinWorkingBeatmap(audio, true));
|
2021-05-31 19:00:47 +08:00
|
|
|
ConfigureTest(useBeatmapSkin, true, userHasCustomColours);
|
2021-01-16 12:46:46 +08:00
|
|
|
AddAssert("is beatmap skin colours", () => TestPlayer.UsableComboColours.SequenceEqual(TestBeatmapSkin.Colours));
|
2019-12-21 17:26:58 +08:00
|
|
|
}
|
|
|
|
|
2021-01-14 05:05:46 +08:00
|
|
|
[TestCase(true)]
|
|
|
|
[TestCase(false)]
|
2021-05-31 19:00:47 +08:00
|
|
|
public void TestBeatmapComboColoursOverride(bool useBeatmapSkin)
|
2021-01-13 13:09:22 +08:00
|
|
|
{
|
2021-05-31 18:57:31 +08:00
|
|
|
PrepareBeatmap(() => new OsuCustomSkinWorkingBeatmap(audio, true));
|
2021-05-31 19:00:47 +08:00
|
|
|
ConfigureTest(useBeatmapSkin, false, true);
|
2021-01-16 12:46:46 +08:00
|
|
|
AddAssert("is user custom skin colours", () => TestPlayer.UsableComboColours.SequenceEqual(TestSkin.Colours));
|
2021-01-13 13:09:22 +08:00
|
|
|
}
|
|
|
|
|
2021-01-14 05:05:46 +08:00
|
|
|
[TestCase(true)]
|
|
|
|
[TestCase(false)]
|
2021-05-31 19:00:47 +08:00
|
|
|
public void TestBeatmapComboColoursOverrideWithDefaultColours(bool useBeatmapSkin)
|
2019-12-21 17:26:58 +08:00
|
|
|
{
|
2021-05-31 18:57:31 +08:00
|
|
|
PrepareBeatmap(() => new OsuCustomSkinWorkingBeatmap(audio, true));
|
2021-05-31 19:00:47 +08:00
|
|
|
ConfigureTest(useBeatmapSkin, false, false);
|
2021-01-16 12:46:46 +08:00
|
|
|
AddAssert("is default user skin colours", () => TestPlayer.UsableComboColours.SequenceEqual(SkinConfiguration.DefaultComboColours));
|
2021-01-13 13:09:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
[TestCase(true, true)]
|
|
|
|
[TestCase(false, true)]
|
|
|
|
[TestCase(true, false)]
|
|
|
|
[TestCase(false, false)]
|
2021-05-31 19:00:47 +08:00
|
|
|
public void TestBeatmapNoComboColours(bool useBeatmapSkin, bool useBeatmapColour)
|
2021-01-13 13:09:22 +08:00
|
|
|
{
|
2021-05-31 18:57:31 +08:00
|
|
|
PrepareBeatmap(() => new OsuCustomSkinWorkingBeatmap(audio, false));
|
2021-05-31 19:00:47 +08:00
|
|
|
ConfigureTest(useBeatmapSkin, useBeatmapColour, false);
|
2021-01-16 12:46:46 +08:00
|
|
|
AddAssert("is default user skin colours", () => TestPlayer.UsableComboColours.SequenceEqual(SkinConfiguration.DefaultComboColours));
|
2019-12-21 17:26:58 +08:00
|
|
|
}
|
|
|
|
|
2021-01-13 13:09:22 +08:00
|
|
|
[TestCase(true, true)]
|
|
|
|
[TestCase(false, true)]
|
|
|
|
[TestCase(true, false)]
|
|
|
|
[TestCase(false, false)]
|
2021-05-31 19:00:47 +08:00
|
|
|
public void TestBeatmapNoComboColoursSkinOverride(bool useBeatmapSkin, bool useBeatmapColour)
|
2019-12-21 17:26:58 +08:00
|
|
|
{
|
2021-05-31 18:57:31 +08:00
|
|
|
PrepareBeatmap(() => new OsuCustomSkinWorkingBeatmap(audio, false));
|
2021-05-31 19:00:47 +08:00
|
|
|
ConfigureTest(useBeatmapSkin, useBeatmapColour, true);
|
2021-01-16 12:46:46 +08:00
|
|
|
AddAssert("is custom user skin colours", () => TestPlayer.UsableComboColours.SequenceEqual(TestSkin.Colours));
|
2019-12-21 17:26:58 +08:00
|
|
|
}
|
2021-01-13 13:09:22 +08:00
|
|
|
|
2021-05-05 14:22:19 +08:00
|
|
|
[TestCase(true, true)]
|
|
|
|
[TestCase(true, false)]
|
|
|
|
[TestCase(false, true)]
|
|
|
|
[TestCase(false, false)]
|
2021-07-20 19:35:21 +08:00
|
|
|
public void TestComboOffsetWithBeatmapColours(bool userHasCustomColours, bool useBeatmapSkin)
|
2021-05-05 14:22:19 +08:00
|
|
|
{
|
2021-07-20 15:28:24 +08:00
|
|
|
PrepareBeatmap(() => new OsuCustomSkinWorkingBeatmap(audio, true, getHitCirclesWithLegacyOffsets()));
|
|
|
|
ConfigureTest(useBeatmapSkin, true, userHasCustomColours);
|
2021-07-20 19:35:21 +08:00
|
|
|
assertCorrectObjectComboColours("is beatmap skin colours with combo offsets applied",
|
2021-05-05 14:22:19 +08:00
|
|
|
TestBeatmapSkin.Colours,
|
2021-07-20 19:15:43 +08:00
|
|
|
(i, obj) => i + 1 + obj.ComboOffset);
|
2021-05-05 14:22:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
[TestCase(true)]
|
|
|
|
[TestCase(false)]
|
2021-07-20 19:35:21 +08:00
|
|
|
public void TestComboOffsetWithIgnoredBeatmapColours(bool useBeatmapSkin)
|
2021-05-05 14:22:19 +08:00
|
|
|
{
|
2021-07-20 15:28:24 +08:00
|
|
|
PrepareBeatmap(() => new OsuCustomSkinWorkingBeatmap(audio, true, getHitCirclesWithLegacyOffsets()));
|
|
|
|
ConfigureTest(useBeatmapSkin, false, true);
|
2021-07-20 19:35:21 +08:00
|
|
|
assertCorrectObjectComboColours("is user skin colours without combo offsets applied",
|
2021-05-05 14:22:19 +08:00
|
|
|
TestSkin.Colours,
|
|
|
|
(i, _) => i + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void assertCorrectObjectComboColours(string description, Color4[] expectedColours, Func<int, OsuHitObject, int> nextExpectedComboIndex)
|
|
|
|
{
|
|
|
|
AddUntilStep("wait for objects to become alive", () =>
|
|
|
|
TestPlayer.DrawableRuleset.Playfield.AllHitObjects.Count() == TestPlayer.DrawableRuleset.Objects.Count());
|
|
|
|
|
|
|
|
AddAssert(description, () =>
|
|
|
|
{
|
|
|
|
int index = 0;
|
|
|
|
|
2021-07-22 21:15:23 +08:00
|
|
|
return TestPlayer.DrawableRuleset.Playfield.AllHitObjects.All(d =>
|
2021-05-05 14:22:19 +08:00
|
|
|
{
|
2021-07-22 21:15:23 +08:00
|
|
|
index = nextExpectedComboIndex(index, (OsuHitObject)d.HitObject);
|
|
|
|
return checkComboColour(d, expectedColours[index % expectedColours.Length]);
|
|
|
|
});
|
2021-05-05 14:22:19 +08:00
|
|
|
});
|
2021-07-22 21:15:23 +08:00
|
|
|
|
|
|
|
static bool checkComboColour(DrawableHitObject drawableHitObject, Color4 expectedColour)
|
|
|
|
{
|
|
|
|
return drawableHitObject.AccentColour.Value == expectedColour &&
|
|
|
|
drawableHitObject.NestedHitObjects.All(n => checkComboColour(n, expectedColour));
|
|
|
|
}
|
2021-05-05 14:22:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
private static IEnumerable<OsuHitObject> getHitCirclesWithLegacyOffsets()
|
|
|
|
{
|
|
|
|
var hitObjects = new List<OsuHitObject>();
|
|
|
|
|
2021-07-22 21:15:23 +08:00
|
|
|
for (int i = 0; i < 10; i++)
|
2021-05-05 14:22:19 +08:00
|
|
|
{
|
2021-07-22 21:15:23 +08:00
|
|
|
var hitObject = i % 2 == 0
|
|
|
|
? (OsuHitObject)new HitCircle()
|
2021-07-22 21:42:00 +08:00
|
|
|
: new Slider
|
2021-07-22 21:15:23 +08:00
|
|
|
{
|
|
|
|
Path = new SliderPath(new[]
|
|
|
|
{
|
|
|
|
new PathControlPoint(new Vector2(0, 0)),
|
|
|
|
new PathControlPoint(new Vector2(100, 0)),
|
|
|
|
})
|
|
|
|
};
|
|
|
|
|
|
|
|
hitObject.StartTime = i;
|
|
|
|
hitObject.Position = new Vector2(256, 192);
|
|
|
|
hitObject.NewCombo = true;
|
|
|
|
hitObject.ComboOffset = i;
|
|
|
|
|
|
|
|
hitObjects.Add(hitObject);
|
2021-05-05 14:22:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return hitObjects;
|
|
|
|
}
|
|
|
|
|
2021-01-16 12:46:46 +08:00
|
|
|
private class OsuCustomSkinWorkingBeatmap : CustomSkinWorkingBeatmap
|
2019-12-21 17:26:58 +08:00
|
|
|
{
|
2021-05-05 14:22:19 +08:00
|
|
|
public OsuCustomSkinWorkingBeatmap(AudioManager audio, bool hasColours, IEnumerable<OsuHitObject> hitObjects = null)
|
|
|
|
: base(createBeatmap(hitObjects), audio, hasColours)
|
2021-01-16 12:46:46 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-05-05 14:22:19 +08:00
|
|
|
private static IBeatmap createBeatmap(IEnumerable<OsuHitObject> hitObjects)
|
|
|
|
{
|
|
|
|
var beatmap = new Beatmap
|
2019-12-21 17:26:58 +08:00
|
|
|
{
|
|
|
|
BeatmapInfo =
|
|
|
|
{
|
|
|
|
BeatmapSet = new BeatmapSetInfo(),
|
|
|
|
Ruleset = new OsuRuleset().RulesetInfo,
|
|
|
|
},
|
2021-01-16 12:46:46 +08:00
|
|
|
};
|
2021-05-05 14:22:19 +08:00
|
|
|
|
|
|
|
beatmap.HitObjects.AddRange(hitObjects ?? new[]
|
|
|
|
{
|
|
|
|
new HitCircle { Position = new Vector2(256, 192) }
|
|
|
|
});
|
|
|
|
|
|
|
|
return beatmap;
|
|
|
|
}
|
2019-12-21 17:26:58 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|