mirror of
https://github.com/ppy/osu.git
synced 2025-01-06 09:03:01 +08:00
Further simplified beatmap colouring tests.
This commit is contained in:
parent
112967c1e8
commit
a3535f4b79
@ -1,22 +1,17 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Audio;
|
using osu.Framework.Audio;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Beatmaps.ControlPoints;
|
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Rulesets.Catch.Objects;
|
using osu.Game.Rulesets.Catch.Objects;
|
||||||
using osu.Game.Rulesets.Catch.Skinning;
|
using osu.Game.Rulesets.Catch.Skinning;
|
||||||
using osu.Game.Rulesets.Catch.UI;
|
|
||||||
using osu.Game.Rulesets.Objects;
|
|
||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
using osu.Game.Tests.Beatmaps;
|
using osu.Game.Tests.Beatmaps;
|
||||||
using osuTK;
|
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Catch.Tests
|
namespace osu.Game.Rulesets.Catch.Tests
|
||||||
@ -90,9 +85,9 @@ namespace osu.Game.Rulesets.Catch.Tests
|
|||||||
{
|
{
|
||||||
TestBeatmap = new CatchCustomSkinWorkingBeatmap(audio, true);
|
TestBeatmap = new CatchCustomSkinWorkingBeatmap(audio, true);
|
||||||
ConfigureTest(useBeatmapSkin, true, true);
|
ConfigureTest(useBeatmapSkin, true, true);
|
||||||
AddAssert("is custom hyper dash colours", () => ((CatchExposedPlayer)TestPlayer).UsableHyperDashColour == CatchTestBeatmapSkin.HYPER_DASH_COLOUR);
|
AddAssert("is custom hyper dash colours", () => ((CatchExposedPlayer)TestPlayer).UsableHyperDashColour == TestBeatmapSkin.HYPER_DASH_COLOUR);
|
||||||
AddAssert("is custom hyper dash after image colours", () => ((CatchExposedPlayer)TestPlayer).UsableHyperDashAfterImageColour == CatchTestBeatmapSkin.HYPER_DASH_AFTER_IMAGE_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 == CatchTestBeatmapSkin.HYPER_DASH_FRUIT_COLOUR);
|
AddAssert("is custom hyper dash fruit colours", () => ((CatchExposedPlayer)TestPlayer).UsableHyperDashFruitColour == TestBeatmapSkin.HYPER_DASH_FRUIT_COLOUR);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestCase(true)]
|
[TestCase(true)]
|
||||||
@ -101,9 +96,9 @@ namespace osu.Game.Rulesets.Catch.Tests
|
|||||||
{
|
{
|
||||||
TestBeatmap = new CatchCustomSkinWorkingBeatmap(audio, true);
|
TestBeatmap = new CatchCustomSkinWorkingBeatmap(audio, true);
|
||||||
ConfigureTest(useBeatmapSkin, false, true);
|
ConfigureTest(useBeatmapSkin, false, true);
|
||||||
AddAssert("is custom hyper dash colours", () => ((CatchExposedPlayer)TestPlayer).UsableHyperDashColour == CatchTestSkin.HYPER_DASH_COLOUR);
|
AddAssert("is custom hyper dash colours", () => ((CatchExposedPlayer)TestPlayer).UsableHyperDashColour == TestSkin.HYPER_DASH_COLOUR);
|
||||||
AddAssert("is custom hyper dash after image colours", () => ((CatchExposedPlayer)TestPlayer).UsableHyperDashAfterImageColour == CatchTestSkin.HYPER_DASH_AFTER_IMAGE_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 == CatchTestSkin.HYPER_DASH_FRUIT_COLOUR);
|
AddAssert("is custom hyper dash fruit colours", () => ((CatchExposedPlayer)TestPlayer).UsableHyperDashFruitColour == TestSkin.HYPER_DASH_FRUIT_COLOUR);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override ExposedPlayer CreateTestPlayer(bool userHasCustomColours) => new CatchExposedPlayer(userHasCustomColours);
|
protected override ExposedPlayer CreateTestPlayer(bool userHasCustomColours) => new CatchExposedPlayer(userHasCustomColours);
|
||||||
@ -115,13 +110,6 @@ namespace osu.Game.Rulesets.Catch.Tests
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
|
||||||
{
|
|
||||||
var dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
|
||||||
dependencies.CacheAs<ISkinSource>(new CatchTestSkin(UserHasCustomColours));
|
|
||||||
return dependencies;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Color4 UsableHyperDashColour =>
|
public Color4 UsableHyperDashColour =>
|
||||||
GameplayClockContainer.ChildrenOfType<BeatmapSkinProvidingContainer>()
|
GameplayClockContainer.ChildrenOfType<BeatmapSkinProvidingContainer>()
|
||||||
.First()
|
.First()
|
||||||
@ -141,129 +129,23 @@ namespace osu.Game.Rulesets.Catch.Tests
|
|||||||
.Value ?? Color4.Red;
|
.Value ?? Color4.Red;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class TestJuiceStream : JuiceStream
|
|
||||||
{
|
|
||||||
public TestJuiceStream(float x)
|
|
||||||
{
|
|
||||||
X = x;
|
|
||||||
|
|
||||||
Path = new SliderPath(new[]
|
|
||||||
{
|
|
||||||
new PathControlPoint(Vector2.Zero),
|
|
||||||
new PathControlPoint(new Vector2(30, 0)),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class CatchCustomSkinWorkingBeatmap : CustomSkinWorkingBeatmap
|
private class CatchCustomSkinWorkingBeatmap : CustomSkinWorkingBeatmap
|
||||||
{
|
{
|
||||||
public CatchCustomSkinWorkingBeatmap(AudioManager audio, bool hasColours)
|
public CatchCustomSkinWorkingBeatmap(AudioManager audio, bool hasColours)
|
||||||
: base(createBeatmap(new CatchRuleset().RulesetInfo), audio, hasColours)
|
: base(createBeatmap(), audio, hasColours)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override ISkin GetSkin() => new CatchTestBeatmapSkin(BeatmapInfo, HasColours);
|
private static IBeatmap createBeatmap() =>
|
||||||
|
new Beatmap
|
||||||
private static IBeatmap createBeatmap(RulesetInfo ruleset)
|
|
||||||
{
|
|
||||||
var beatmap = new Beatmap
|
|
||||||
{
|
{
|
||||||
BeatmapInfo =
|
BeatmapInfo =
|
||||||
{
|
{
|
||||||
Ruleset = ruleset,
|
BeatmapSet = new BeatmapSetInfo(),
|
||||||
BaseDifficulty = new BeatmapDifficulty { CircleSize = 3.6f }
|
Ruleset = new CatchRuleset().RulesetInfo
|
||||||
}
|
},
|
||||||
|
HitObjects = { new Fruit { StartTime = 1816, X = 56, NewCombo = true } }
|
||||||
};
|
};
|
||||||
|
|
||||||
beatmap.ControlPointInfo.Add(0, new TimingControlPoint());
|
|
||||||
|
|
||||||
// Should produce a hyper-dash (edge case test)
|
|
||||||
beatmap.HitObjects.Add(new Fruit { StartTime = 1816, X = 56, NewCombo = true });
|
|
||||||
beatmap.HitObjects.Add(new Fruit { StartTime = 2008, X = 308, NewCombo = true });
|
|
||||||
|
|
||||||
double startTime = 3000;
|
|
||||||
|
|
||||||
const float left_x = 0.02f * CatchPlayfield.WIDTH;
|
|
||||||
const float right_x = 0.98f * CatchPlayfield.WIDTH;
|
|
||||||
|
|
||||||
createObjects(() => new Fruit { X = left_x });
|
|
||||||
createObjects(() => new TestJuiceStream(right_x), 1);
|
|
||||||
createObjects(() => new TestJuiceStream(left_x), 1);
|
|
||||||
createObjects(() => new Fruit { X = right_x });
|
|
||||||
createObjects(() => new Fruit { X = left_x });
|
|
||||||
createObjects(() => new Fruit { X = right_x });
|
|
||||||
createObjects(() => new TestJuiceStream(left_x), 1);
|
|
||||||
|
|
||||||
beatmap.ControlPointInfo.Add(startTime, new TimingControlPoint
|
|
||||||
{
|
|
||||||
BeatLength = 50
|
|
||||||
});
|
|
||||||
|
|
||||||
createObjects(() => new TestJuiceStream(left_x)
|
|
||||||
{
|
|
||||||
Path = new SliderPath(new[]
|
|
||||||
{
|
|
||||||
new PathControlPoint(Vector2.Zero),
|
|
||||||
new PathControlPoint(new Vector2(512, 0))
|
|
||||||
})
|
|
||||||
}, 1);
|
|
||||||
|
|
||||||
return beatmap;
|
|
||||||
|
|
||||||
void createObjects(Func<CatchHitObject> createObject, int count = 3)
|
|
||||||
{
|
|
||||||
const float spacing = 140;
|
|
||||||
|
|
||||||
for (int i = 0; i < count; i++)
|
|
||||||
{
|
|
||||||
var hitObject = createObject();
|
|
||||||
hitObject.StartTime = startTime + i * spacing;
|
|
||||||
beatmap.HitObjects.Add(hitObject);
|
|
||||||
}
|
|
||||||
|
|
||||||
startTime += 700;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class CatchTestBeatmapSkin : TestBeatmapSkin
|
|
||||||
{
|
|
||||||
public static readonly Color4 HYPER_DASH_COLOUR = Color4.DarkBlue;
|
|
||||||
|
|
||||||
public static readonly Color4 HYPER_DASH_AFTER_IMAGE_COLOUR = Color4.DarkCyan;
|
|
||||||
|
|
||||||
public static readonly Color4 HYPER_DASH_FRUIT_COLOUR = Color4.DarkGoldenrod;
|
|
||||||
|
|
||||||
public CatchTestBeatmapSkin(BeatmapInfo beatmap, bool hasColours)
|
|
||||||
: base(beatmap, hasColours)
|
|
||||||
{
|
|
||||||
if (hasColours)
|
|
||||||
{
|
|
||||||
Configuration.CustomColours.Add(CatchSkinColour.HyperDash.ToString(), HYPER_DASH_COLOUR);
|
|
||||||
Configuration.CustomColours.Add(CatchSkinColour.HyperDashAfterImage.ToString(), HYPER_DASH_AFTER_IMAGE_COLOUR);
|
|
||||||
Configuration.CustomColours.Add(CatchSkinColour.HyperDashFruit.ToString(), HYPER_DASH_FRUIT_COLOUR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class CatchTestSkin : TestSkin
|
|
||||||
{
|
|
||||||
public static readonly Color4 HYPER_DASH_COLOUR = Color4.LightBlue;
|
|
||||||
|
|
||||||
public static readonly Color4 HYPER_DASH_AFTER_IMAGE_COLOUR = Color4.LightCoral;
|
|
||||||
|
|
||||||
public static readonly Color4 HYPER_DASH_FRUIT_COLOUR = Color4.LightCyan;
|
|
||||||
|
|
||||||
public CatchTestSkin(bool hasCustomColours)
|
|
||||||
: base(hasCustomColours)
|
|
||||||
{
|
|
||||||
if (hasCustomColours)
|
|
||||||
{
|
|
||||||
Configuration.CustomColours.Add(CatchSkinColour.HyperDash.ToString(), HYPER_DASH_COLOUR);
|
|
||||||
Configuration.CustomColours.Add(CatchSkinColour.HyperDashAfterImage.ToString(), HYPER_DASH_AFTER_IMAGE_COLOUR);
|
|
||||||
Configuration.CustomColours.Add(CatchSkinColour.HyperDashFruit.ToString(), HYPER_DASH_FRUIT_COLOUR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,35 +77,13 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
AddAssert("is custom user skin colours", () => TestPlayer.UsableComboColours.SequenceEqual(TestSkin.Colours));
|
AddAssert("is custom user skin colours", () => TestPlayer.UsableComboColours.SequenceEqual(TestSkin.Colours));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override ExposedPlayer CreateTestPlayer(bool userHasCustomColours) => new OsuExposedPlayer(userHasCustomColours);
|
|
||||||
|
|
||||||
private class OsuExposedPlayer : ExposedPlayer
|
|
||||||
{
|
|
||||||
public OsuExposedPlayer(bool userHasCustomColours)
|
|
||||||
: base(userHasCustomColours)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
|
||||||
{
|
|
||||||
var dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
|
||||||
dependencies.CacheAs<ISkinSource>(new OsuTestSkin(UserHasCustomColours));
|
|
||||||
return dependencies;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class OsuCustomSkinWorkingBeatmap : CustomSkinWorkingBeatmap
|
private class OsuCustomSkinWorkingBeatmap : CustomSkinWorkingBeatmap
|
||||||
{
|
{
|
||||||
private readonly bool hasColours;
|
|
||||||
|
|
||||||
public OsuCustomSkinWorkingBeatmap(AudioManager audio, bool hasColours)
|
public OsuCustomSkinWorkingBeatmap(AudioManager audio, bool hasColours)
|
||||||
: base(createBeatmap(), audio, hasColours)
|
: base(createBeatmap(), audio, hasColours)
|
||||||
{
|
{
|
||||||
this.hasColours = hasColours;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override ISkin GetSkin() => new OsuTestBeatmapSkin(BeatmapInfo, hasColours);
|
|
||||||
|
|
||||||
private static IBeatmap createBeatmap() =>
|
private static IBeatmap createBeatmap() =>
|
||||||
new Beatmap
|
new Beatmap
|
||||||
{
|
{
|
||||||
@ -117,21 +95,5 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
HitObjects = { new HitCircle { Position = new Vector2(256, 192) } }
|
HitObjects = { new HitCircle { Position = new Vector2(256, 192) } }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private class OsuTestBeatmapSkin : TestBeatmapSkin
|
|
||||||
{
|
|
||||||
public OsuTestBeatmapSkin(BeatmapInfo beatmap, bool hasColours)
|
|
||||||
: base(beatmap, hasColours)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class OsuTestSkin : TestSkin
|
|
||||||
{
|
|
||||||
public OsuTestSkin(bool hasCustomColours)
|
|
||||||
: base(hasCustomColours)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -114,11 +114,22 @@ namespace osu.Game.Tests.Beatmaps
|
|||||||
new Color4(40, 80, 120, 255),
|
new Color4(40, 80, 120, 255),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public static readonly Color4 HYPER_DASH_COLOUR = Color4.DarkBlue;
|
||||||
|
|
||||||
|
public static readonly Color4 HYPER_DASH_AFTER_IMAGE_COLOUR = Color4.DarkCyan;
|
||||||
|
|
||||||
|
public static readonly Color4 HYPER_DASH_FRUIT_COLOUR = Color4.DarkGoldenrod;
|
||||||
|
|
||||||
public TestBeatmapSkin(BeatmapInfo beatmap, bool hasColours)
|
public TestBeatmapSkin(BeatmapInfo beatmap, bool hasColours)
|
||||||
: base(beatmap, new ResourceStore<byte[]>(), null)
|
: base(beatmap, new ResourceStore<byte[]>(), null)
|
||||||
{
|
{
|
||||||
if (hasColours)
|
if (hasColours)
|
||||||
|
{
|
||||||
Configuration.AddComboColours(Colours);
|
Configuration.AddComboColours(Colours);
|
||||||
|
Configuration.CustomColours.Add("HyperDash", HYPER_DASH_COLOUR);
|
||||||
|
Configuration.CustomColours.Add("HyperDashAfterImage", HYPER_DASH_AFTER_IMAGE_COLOUR);
|
||||||
|
Configuration.CustomColours.Add("HyperDashFruit", HYPER_DASH_FRUIT_COLOUR);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,11 +141,22 @@ namespace osu.Game.Tests.Beatmaps
|
|||||||
new Color4(20, 20, 20, 255),
|
new Color4(20, 20, 20, 255),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public static readonly Color4 HYPER_DASH_COLOUR = Color4.LightBlue;
|
||||||
|
|
||||||
|
public static readonly Color4 HYPER_DASH_AFTER_IMAGE_COLOUR = Color4.LightCoral;
|
||||||
|
|
||||||
|
public static readonly Color4 HYPER_DASH_FRUIT_COLOUR = Color4.LightCyan;
|
||||||
|
|
||||||
public TestSkin(bool hasCustomColours)
|
public TestSkin(bool hasCustomColours)
|
||||||
: base(new SkinInfo(), new ResourceStore<byte[]>(), null, string.Empty)
|
: base(new SkinInfo(), new ResourceStore<byte[]>(), null, string.Empty)
|
||||||
{
|
{
|
||||||
if (hasCustomColours)
|
if (hasCustomColours)
|
||||||
|
{
|
||||||
Configuration.AddComboColours(Colours);
|
Configuration.AddComboColours(Colours);
|
||||||
|
Configuration.CustomColours.Add("HyperDash", HYPER_DASH_COLOUR);
|
||||||
|
Configuration.CustomColours.Add("HyperDashAfterImage", HYPER_DASH_AFTER_IMAGE_COLOUR);
|
||||||
|
Configuration.CustomColours.Add("HyperDashFruit", HYPER_DASH_FRUIT_COLOUR);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public event Action SourceChanged
|
public event Action SourceChanged
|
||||||
|
Loading…
Reference in New Issue
Block a user