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