1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 22:47:24 +08:00

Test CatchSkinColour transformation on colour retrieval implicitly

This commit is contained in:
Salman Ahmed 2020-04-05 00:13:23 +03:00
parent 55d076d6f3
commit b100230538

View File

@ -106,44 +106,23 @@ namespace osu.Game.Rulesets.Catch.Tests
private bool checkLegacyFruitHyperDashColour(DrawableFruit fruit, Color4 expectedColour) => private bool checkLegacyFruitHyperDashColour(DrawableFruit fruit, Color4 expectedColour) =>
fruit.ChildrenOfType<SkinnableDrawable>().First().Drawable.ChildrenOfType<Sprite>().Any(c => c.Colour == expectedColour); fruit.ChildrenOfType<SkinnableDrawable>().First().Drawable.ChildrenOfType<Sprite>().Any(c => c.Colour == expectedColour);
private class TestSkin : ISkin private class TestSkin : LegacySkin
{ {
public static Color4 CustomHyperDashColour { get; } = Color4.Goldenrod; public static Color4 CustomHyperDashColour { get; } = Color4.Goldenrod;
public static Color4 CustomHyperDashFruitColour { get; } = Color4.Cyan; public static Color4 CustomHyperDashFruitColour { get; } = Color4.Cyan;
public static Color4 CustomHyperDashAfterColour { get; } = Color4.Lime; public static Color4 CustomHyperDashAfterColour { get; } = Color4.Lime;
private readonly bool customCatcherColour;
private readonly bool customAfterColour;
private readonly bool customFruitColour;
public TestSkin(bool customCatcherColour, bool customAfterColour, bool customFruitColour) public TestSkin(bool customCatcherColour, bool customAfterColour, bool customFruitColour)
: base(new SkinInfo(), null, null, string.Empty)
{ {
this.customCatcherColour = customCatcherColour; if (customCatcherColour)
this.customAfterColour = customAfterColour; Configuration.CustomColours[CatchSkinColour.HyperDash.ToString()] = CustomHyperDashColour;
this.customFruitColour = customFruitColour;
}
public Drawable GetDrawableComponent(ISkinComponent component) => null; if (customAfterColour)
Configuration.CustomColours[CatchSkinColour.HyperDashAfterImage.ToString()] = CustomHyperDashAfterColour;
public Texture GetTexture(string componentName) => null; if (customFruitColour)
Configuration.CustomColours[CatchSkinColour.HyperDashFruit.ToString()] = CustomHyperDashFruitColour;
public SampleChannel GetSample(ISampleInfo sampleInfo) => null;
public IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup)
{
if (lookup is CatchSkinColour config)
{
if (config == CatchSkinColour.HyperDash && customCatcherColour)
return SkinUtils.As<TValue>(new Bindable<Color4>(CustomHyperDashColour));
if (config == CatchSkinColour.HyperDashFruit && customFruitColour)
return SkinUtils.As<TValue>(new Bindable<Color4>(CustomHyperDashFruitColour));
if (config == CatchSkinColour.HyperDashAfterImage && customAfterColour)
return SkinUtils.As<TValue>(new Bindable<Color4>(CustomHyperDashAfterColour));
}
return null;
} }
} }
} }