2020-03-26 02:30:59 +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.
|
|
|
|
|
|
|
|
using System.Linq;
|
|
|
|
using NUnit.Framework;
|
2020-03-30 06:29:00 +00:00
|
|
|
using osu.Framework.Allocation;
|
2020-03-26 02:30:59 +00:00
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
|
|
|
using osu.Framework.Testing;
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
using osu.Game.Beatmaps.ControlPoints;
|
|
|
|
using osu.Game.Rulesets.Catch.Objects;
|
|
|
|
using osu.Game.Rulesets.Catch.Objects.Drawables;
|
|
|
|
using osu.Game.Rulesets.Catch.Skinning;
|
2020-12-07 03:35:24 +00:00
|
|
|
using osu.Game.Rulesets.Catch.Skinning.Legacy;
|
2020-03-26 02:30:59 +00:00
|
|
|
using osu.Game.Rulesets.Catch.UI;
|
|
|
|
using osu.Game.Skinning;
|
|
|
|
using osu.Game.Tests.Visual;
|
|
|
|
using osuTK;
|
|
|
|
using osuTK.Graphics;
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Catch.Tests
|
|
|
|
{
|
|
|
|
public class TestSceneHyperDashColouring : OsuTestScene
|
|
|
|
{
|
2020-03-30 06:29:00 +00:00
|
|
|
[Resolved]
|
|
|
|
private SkinManager skins { get; set; }
|
|
|
|
|
2020-03-26 06:19:00 +00:00
|
|
|
[Test]
|
2020-04-21 02:58:56 +00:00
|
|
|
public void TestDefaultCatcherColour()
|
2020-03-26 06:19:00 +00:00
|
|
|
{
|
2020-04-21 02:58:56 +00:00
|
|
|
var skin = new TestSkin();
|
2020-03-26 06:19:00 +00:00
|
|
|
|
2020-04-21 02:58:56 +00:00
|
|
|
checkHyperDashCatcherColour(skin, Catcher.DEFAULT_HYPER_DASH_COLOUR);
|
|
|
|
}
|
2020-03-26 06:19:00 +00:00
|
|
|
|
2020-04-21 02:58:56 +00:00
|
|
|
[Test]
|
|
|
|
public void TestCustomCatcherColour()
|
|
|
|
{
|
|
|
|
var skin = new TestSkin
|
2020-03-26 06:19:00 +00:00
|
|
|
{
|
2020-04-21 02:58:56 +00:00
|
|
|
HyperDashColour = Color4.Goldenrod
|
|
|
|
};
|
2020-03-26 06:19:00 +00:00
|
|
|
|
2020-04-21 02:58:56 +00:00
|
|
|
checkHyperDashCatcherColour(skin, skin.HyperDashColour);
|
|
|
|
}
|
2020-03-26 06:19:00 +00:00
|
|
|
|
2020-04-21 02:58:56 +00:00
|
|
|
[Test]
|
|
|
|
public void TestCustomEndGlowColour()
|
|
|
|
{
|
|
|
|
var skin = new TestSkin
|
2020-03-26 06:19:00 +00:00
|
|
|
{
|
2020-04-21 02:58:56 +00:00
|
|
|
HyperDashAfterImageColour = Color4.Lime
|
|
|
|
};
|
2020-03-26 06:19:00 +00:00
|
|
|
|
2020-04-21 02:58:56 +00:00
|
|
|
checkHyperDashCatcherColour(skin, Catcher.DEFAULT_HYPER_DASH_COLOUR, skin.HyperDashAfterImageColour);
|
2020-03-26 06:19:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
2020-04-21 02:58:56 +00:00
|
|
|
public void TestCustomEndGlowColourPriority()
|
2020-03-26 06:19:00 +00:00
|
|
|
{
|
2020-04-21 02:58:56 +00:00
|
|
|
var skin = new TestSkin
|
2020-03-26 06:19:00 +00:00
|
|
|
{
|
2020-04-21 02:58:56 +00:00
|
|
|
HyperDashColour = Color4.Goldenrod,
|
|
|
|
HyperDashAfterImageColour = Color4.Lime
|
|
|
|
};
|
2020-03-26 06:19:00 +00:00
|
|
|
|
2020-04-21 02:58:56 +00:00
|
|
|
checkHyperDashCatcherColour(skin, skin.HyperDashColour, skin.HyperDashAfterImageColour);
|
|
|
|
}
|
2020-03-26 06:19:00 +00:00
|
|
|
|
2020-04-04 21:02:33 +00:00
|
|
|
[Test]
|
2020-04-19 10:41:00 +00:00
|
|
|
public void TestDefaultFruitColour()
|
2020-03-26 02:40:38 +00:00
|
|
|
{
|
2020-04-19 10:41:00 +00:00
|
|
|
var skin = new TestSkin();
|
2020-03-26 02:40:38 +00:00
|
|
|
|
2020-04-19 10:41:00 +00:00
|
|
|
checkHyperDashFruitColour(skin, Catcher.DEFAULT_HYPER_DASH_COLOUR);
|
|
|
|
}
|
2020-03-26 06:19:00 +00:00
|
|
|
|
2020-04-19 10:41:00 +00:00
|
|
|
[Test]
|
|
|
|
public void TestCustomFruitColour()
|
|
|
|
{
|
|
|
|
var skin = new TestSkin
|
2020-03-26 06:19:00 +00:00
|
|
|
{
|
2020-04-19 10:41:00 +00:00
|
|
|
HyperDashFruitColour = Color4.Cyan
|
|
|
|
};
|
2020-03-26 06:19:00 +00:00
|
|
|
|
2020-04-19 10:41:00 +00:00
|
|
|
checkHyperDashFruitColour(skin, skin.HyperDashFruitColour);
|
2020-03-26 06:19:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
2020-04-19 10:41:00 +00:00
|
|
|
public void TestCustomFruitColourPriority()
|
2020-03-26 06:19:00 +00:00
|
|
|
{
|
2020-04-19 10:41:00 +00:00
|
|
|
var skin = new TestSkin
|
2020-03-26 06:19:00 +00:00
|
|
|
{
|
2020-04-19 10:41:00 +00:00
|
|
|
HyperDashColour = Color4.Goldenrod,
|
|
|
|
HyperDashFruitColour = Color4.Cyan
|
|
|
|
};
|
2020-03-26 06:19:00 +00:00
|
|
|
|
2020-04-19 10:41:00 +00:00
|
|
|
checkHyperDashFruitColour(skin, skin.HyperDashFruitColour);
|
2020-03-26 06:19:00 +00:00
|
|
|
}
|
|
|
|
|
2020-04-04 21:02:33 +00:00
|
|
|
[Test]
|
2020-04-19 10:41:00 +00:00
|
|
|
public void TestFruitColourFallback()
|
2020-03-26 06:19:00 +00:00
|
|
|
{
|
2020-04-19 10:41:00 +00:00
|
|
|
var skin = new TestSkin
|
2020-03-26 06:19:00 +00:00
|
|
|
{
|
2020-04-19 10:41:00 +00:00
|
|
|
HyperDashColour = Color4.Goldenrod
|
|
|
|
};
|
2020-03-26 06:19:00 +00:00
|
|
|
|
2020-04-19 10:41:00 +00:00
|
|
|
checkHyperDashFruitColour(skin, skin.HyperDashColour);
|
2020-03-26 06:19:00 +00:00
|
|
|
}
|
|
|
|
|
2020-04-21 02:58:56 +00:00
|
|
|
private void checkHyperDashCatcherColour(ISkin skin, Color4 expectedCatcherColour, Color4? expectedEndGlowColour = null)
|
2020-03-26 06:19:00 +00:00
|
|
|
{
|
|
|
|
CatcherArea catcherArea = null;
|
2020-04-22 02:12:51 +00:00
|
|
|
CatcherTrailDisplay trails = null;
|
2020-03-26 06:19:00 +00:00
|
|
|
|
2020-04-21 02:58:56 +00:00
|
|
|
AddStep("create hyper-dashing catcher", () =>
|
2020-03-26 06:19:00 +00:00
|
|
|
{
|
2020-12-09 01:35:01 +00:00
|
|
|
Child = setupSkinHierarchy(catcherArea = new CatcherArea(new Container<CaughtObject>())
|
2020-04-04 15:07:29 +00:00
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
Scale = new Vector2(4f),
|
2020-04-21 02:58:56 +00:00
|
|
|
}, skin);
|
2020-10-19 11:00:17 +00:00
|
|
|
});
|
2020-04-21 02:58:56 +00:00
|
|
|
|
2020-10-19 11:00:17 +00:00
|
|
|
AddStep("get trails container", () =>
|
|
|
|
{
|
2020-04-22 02:12:51 +00:00
|
|
|
trails = catcherArea.OfType<CatcherTrailDisplay>().Single();
|
2020-04-21 02:58:56 +00:00
|
|
|
catcherArea.MovableCatcher.SetHyperDashState(2);
|
2020-03-26 06:19:00 +00:00
|
|
|
});
|
|
|
|
|
2020-05-06 21:25:25 +00:00
|
|
|
AddUntilStep("catcher colour is correct", () => catcherArea.MovableCatcher.Colour == expectedCatcherColour);
|
2020-03-26 06:19:00 +00:00
|
|
|
|
2020-04-22 02:12:51 +00:00
|
|
|
AddAssert("catcher trails colours are correct", () => trails.HyperDashTrailsColour == expectedCatcherColour);
|
|
|
|
AddAssert("catcher end-glow colours are correct", () => trails.EndGlowSpritesColour == (expectedEndGlowColour ?? expectedCatcherColour));
|
2020-03-26 02:40:38 +00:00
|
|
|
|
2020-04-21 02:58:56 +00:00
|
|
|
AddStep("finish hyper-dashing", () =>
|
2020-03-26 02:40:38 +00:00
|
|
|
{
|
2020-04-21 02:58:56 +00:00
|
|
|
catcherArea.MovableCatcher.SetHyperDashState(1);
|
|
|
|
catcherArea.MovableCatcher.FinishTransforms();
|
2020-03-26 02:40:38 +00:00
|
|
|
});
|
|
|
|
|
2020-04-21 02:58:56 +00:00
|
|
|
AddAssert("catcher colour returned to white", () => catcherArea.MovableCatcher.Colour == Color4.White);
|
2020-03-26 02:40:38 +00:00
|
|
|
}
|
|
|
|
|
2020-04-19 10:41:00 +00:00
|
|
|
private void checkHyperDashFruitColour(ISkin skin, Color4 expectedColour)
|
2020-03-26 02:40:38 +00:00
|
|
|
{
|
|
|
|
DrawableFruit drawableFruit = null;
|
|
|
|
|
2020-04-19 10:41:00 +00:00
|
|
|
AddStep("create hyper-dash fruit", () =>
|
2020-03-26 02:40:38 +00:00
|
|
|
{
|
2020-03-30 06:29:00 +00:00
|
|
|
var fruit = new Fruit { HyperDashTarget = new Banana() };
|
2020-03-26 02:40:38 +00:00
|
|
|
fruit.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
|
|
|
|
|
2020-03-30 06:29:00 +00:00
|
|
|
Child = setupSkinHierarchy(drawableFruit = new DrawableFruit(fruit)
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
Scale = new Vector2(4f),
|
2020-04-19 10:41:00 +00:00
|
|
|
}, skin);
|
2020-03-26 02:40:38 +00:00
|
|
|
});
|
|
|
|
|
2020-04-19 10:41:00 +00:00
|
|
|
AddAssert("hyper-dash colour is correct", () => checkLegacyFruitHyperDashColour(drawableFruit, expectedColour));
|
2020-03-26 02:40:38 +00:00
|
|
|
}
|
|
|
|
|
2020-04-19 10:41:00 +00:00
|
|
|
private Drawable setupSkinHierarchy(Drawable child, ISkin skin)
|
2020-03-26 02:40:38 +00:00
|
|
|
{
|
2020-04-04 21:02:33 +00:00
|
|
|
var legacySkinProvider = new SkinProvidingContainer(skins.GetSkin(DefaultLegacySkin.Info));
|
2020-04-19 10:41:00 +00:00
|
|
|
var testSkinProvider = new SkinProvidingContainer(skin);
|
2020-04-04 21:02:33 +00:00
|
|
|
var legacySkinTransformer = new SkinProvidingContainer(new CatchLegacySkinTransformer(testSkinProvider));
|
2020-03-30 06:29:00 +00:00
|
|
|
|
2020-04-04 21:02:33 +00:00
|
|
|
return legacySkinProvider
|
|
|
|
.WithChild(testSkinProvider
|
|
|
|
.WithChild(legacySkinTransformer
|
|
|
|
.WithChild(child)));
|
2020-03-26 02:30:59 +00:00
|
|
|
}
|
|
|
|
|
2020-03-30 06:29:00 +00:00
|
|
|
private bool checkLegacyFruitHyperDashColour(DrawableFruit fruit, Color4 expectedColour) =>
|
|
|
|
fruit.ChildrenOfType<SkinnableDrawable>().First().Drawable.ChildrenOfType<Sprite>().Any(c => c.Colour == expectedColour);
|
2020-03-26 02:30:59 +00:00
|
|
|
|
2020-04-04 21:13:23 +00:00
|
|
|
private class TestSkin : LegacySkin
|
2020-03-26 02:30:59 +00:00
|
|
|
{
|
2020-04-19 10:41:00 +00:00
|
|
|
public Color4 HyperDashColour
|
2020-03-26 02:30:59 +00:00
|
|
|
{
|
2020-04-19 10:41:00 +00:00
|
|
|
get => Configuration.CustomColours[CatchSkinColour.HyperDash.ToString()];
|
|
|
|
set => Configuration.CustomColours[CatchSkinColour.HyperDash.ToString()] = value;
|
2020-03-26 02:30:59 +00:00
|
|
|
}
|
|
|
|
|
2020-04-19 10:41:00 +00:00
|
|
|
public Color4 HyperDashAfterImageColour
|
2020-03-26 02:30:59 +00:00
|
|
|
{
|
2020-04-19 10:41:00 +00:00
|
|
|
get => Configuration.CustomColours[CatchSkinColour.HyperDashAfterImage.ToString()];
|
|
|
|
set => Configuration.CustomColours[CatchSkinColour.HyperDashAfterImage.ToString()] = value;
|
|
|
|
}
|
2020-03-26 02:30:59 +00:00
|
|
|
|
2020-04-19 10:41:00 +00:00
|
|
|
public Color4 HyperDashFruitColour
|
|
|
|
{
|
|
|
|
get => Configuration.CustomColours[CatchSkinColour.HyperDashFruit.ToString()];
|
|
|
|
set => Configuration.CustomColours[CatchSkinColour.HyperDashFruit.ToString()] = value;
|
|
|
|
}
|
2020-03-26 02:30:59 +00:00
|
|
|
|
2020-04-19 10:41:00 +00:00
|
|
|
public TestSkin()
|
|
|
|
: base(new SkinInfo(), null, null, string.Empty)
|
|
|
|
{
|
2020-03-26 02:30:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|