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.
|
|
|
|
|
2022-06-17 07:37:17 +00:00
|
|
|
#nullable disable
|
|
|
|
|
2020-03-26 02:30:59 +00:00
|
|
|
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 partial 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]
|
2021-07-28 10:02:24 +00:00
|
|
|
public void TestCustomAfterImageColour()
|
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
|
|
|
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]
|
2021-07-28 10:02:24 +00:00
|
|
|
public void TestCustomAfterImageColourPriority()
|
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
|
|
|
}
|
|
|
|
|
2021-07-28 10:02:24 +00:00
|
|
|
private void checkHyperDashCatcherColour(ISkin skin, Color4 expectedCatcherColour, Color4? expectedAfterImageColour = null)
|
2020-03-26 06:19:00 +00:00
|
|
|
{
|
2020-04-22 02:12:51 +00:00
|
|
|
CatcherTrailDisplay trails = null;
|
2021-07-26 08:46:56 +00:00
|
|
|
Catcher catcher = 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
|
|
|
{
|
2021-07-27 09:59:55 +00:00
|
|
|
CatcherArea catcherArea;
|
2021-07-19 11:11:49 +00:00
|
|
|
Child = setupSkinHierarchy(new Container
|
2020-04-04 15:07:29 +00:00
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
2021-07-27 09:59:55 +00:00
|
|
|
Child = catcherArea = new CatcherArea
|
2021-07-19 11:11:49 +00:00
|
|
|
{
|
2021-07-27 09:59:55 +00:00
|
|
|
Catcher = catcher = new Catcher(new DroppedObjectContainer())
|
2021-07-19 11:11:49 +00:00
|
|
|
{
|
|
|
|
Scale = new Vector2(4)
|
2021-07-27 09:59:55 +00:00
|
|
|
}
|
2021-07-19 11:11:49 +00:00
|
|
|
}
|
2020-04-21 02:58:56 +00:00
|
|
|
}, skin);
|
2021-07-28 09:13:43 +00:00
|
|
|
trails = catcherArea.ChildrenOfType<CatcherTrailDisplay>().Single();
|
2020-10-19 11:00:17 +00:00
|
|
|
});
|
2020-04-21 02:58:56 +00:00
|
|
|
|
2021-07-26 08:46:56 +00:00
|
|
|
AddStep("start hyper-dash", () =>
|
2020-10-19 11:00:17 +00:00
|
|
|
{
|
2021-07-19 11:11:49 +00:00
|
|
|
catcher.SetHyperDashState(2);
|
2020-03-26 06:19:00 +00:00
|
|
|
});
|
|
|
|
|
2021-07-19 11:11:49 +00:00
|
|
|
AddUntilStep("catcher colour is correct", () => catcher.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);
|
2021-07-28 10:02:24 +00:00
|
|
|
AddAssert("catcher after-image colours are correct", () => trails.HyperDashAfterImageColour == (expectedAfterImageColour ?? 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
|
|
|
{
|
2021-07-19 11:11:49 +00:00
|
|
|
catcher.SetHyperDashState();
|
|
|
|
catcher.FinishTransforms();
|
2020-03-26 02:40:38 +00:00
|
|
|
});
|
|
|
|
|
2021-07-19 11:11:49 +00:00
|
|
|
AddAssert("catcher colour returned to white", () => catcher.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
|
|
|
{
|
2021-11-29 08:15:26 +00:00
|
|
|
var legacySkinProvider = new SkinProvidingContainer(skins.GetSkin(DefaultLegacySkin.CreateInfo()));
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|