2020-11-06 14:56:02 +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-11-16 13:40:25 +00:00
|
|
|
using System.Linq;
|
2020-11-06 14:56:02 +00:00
|
|
|
using NUnit.Framework;
|
2020-11-16 13:40:25 +00:00
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Testing;
|
2020-11-06 14:56:02 +00:00
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
using osu.Game.Beatmaps.ControlPoints;
|
|
|
|
using osu.Game.Rulesets.Objects;
|
|
|
|
using osu.Game.Rulesets.Objects.Types;
|
|
|
|
using osu.Game.Rulesets.Osu.Objects;
|
|
|
|
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
2022-10-20 00:32:33 +00:00
|
|
|
using osu.Game.Rulesets.Osu.Skinning.Legacy;
|
2020-11-16 13:40:25 +00:00
|
|
|
using osu.Game.Skinning;
|
2020-11-06 14:56:02 +00:00
|
|
|
using osu.Game.Tests.Visual;
|
|
|
|
using osuTK;
|
2020-11-16 13:40:25 +00:00
|
|
|
using osuTK.Graphics;
|
2020-11-06 14:56:02 +00:00
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.Tests
|
|
|
|
{
|
|
|
|
public partial class TestSceneSliderApplication : OsuTestScene
|
|
|
|
{
|
2020-11-16 13:40:25 +00:00
|
|
|
[Resolved]
|
|
|
|
private SkinManager skinManager { get; set; }
|
|
|
|
|
2020-11-06 14:56:02 +00:00
|
|
|
[Test]
|
|
|
|
public void TestApplyNewSlider()
|
|
|
|
{
|
|
|
|
DrawableSlider dho = null;
|
|
|
|
|
|
|
|
AddStep("create slider", () => Child = dho = new DrawableSlider(prepareObject(new Slider
|
|
|
|
{
|
|
|
|
Position = new Vector2(256, 192),
|
|
|
|
IndexInCurrentCombo = 0,
|
2020-11-06 15:40:41 +00:00
|
|
|
StartTime = Time.Current,
|
2020-11-06 14:56:02 +00:00
|
|
|
Path = new SliderPath(PathType.Linear, new[]
|
|
|
|
{
|
|
|
|
Vector2.Zero,
|
|
|
|
new Vector2(150, 100),
|
|
|
|
new Vector2(300, 0),
|
|
|
|
})
|
2020-11-06 15:40:41 +00:00
|
|
|
})));
|
2020-11-06 14:56:02 +00:00
|
|
|
|
|
|
|
AddWaitStep("wait for progression", 1);
|
|
|
|
|
|
|
|
AddStep("apply new slider", () => dho.Apply(prepareObject(new Slider
|
|
|
|
{
|
|
|
|
Position = new Vector2(256, 192),
|
|
|
|
ComboIndex = 1,
|
2020-11-06 15:40:41 +00:00
|
|
|
StartTime = dho.HitObject.StartTime,
|
2020-11-06 14:56:02 +00:00
|
|
|
Path = new SliderPath(PathType.Bezier, new[]
|
|
|
|
{
|
|
|
|
Vector2.Zero,
|
|
|
|
new Vector2(150, 100),
|
|
|
|
new Vector2(300, 0),
|
|
|
|
}),
|
|
|
|
RepeatCount = 1
|
2021-04-21 05:32:37 +00:00
|
|
|
})));
|
2020-11-06 14:56:02 +00:00
|
|
|
}
|
|
|
|
|
2020-11-16 13:40:25 +00:00
|
|
|
[Test]
|
|
|
|
public void TestBallTintChangedOnAccentChange()
|
|
|
|
{
|
|
|
|
DrawableSlider dho = null;
|
|
|
|
|
|
|
|
AddStep("create slider", () =>
|
|
|
|
{
|
2022-10-20 00:32:33 +00:00
|
|
|
var skin = skinManager.GetSkin(DefaultLegacySkin.CreateInfo());
|
|
|
|
var provider = Ruleset.Value.CreateInstance().CreateSkinTransformer(skin, Beatmap.Value.Beatmap);
|
2022-04-23 00:17:18 +00:00
|
|
|
|
|
|
|
Child = new SkinProvidingContainer(provider)
|
2020-11-16 13:40:25 +00:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Child = dho = new DrawableSlider(prepareObject(new Slider
|
|
|
|
{
|
|
|
|
Position = new Vector2(256, 192),
|
|
|
|
IndexInCurrentCombo = 0,
|
|
|
|
StartTime = Time.Current,
|
|
|
|
Path = new SliderPath(PathType.Linear, new[]
|
|
|
|
{
|
|
|
|
Vector2.Zero,
|
|
|
|
new Vector2(150, 100),
|
|
|
|
new Vector2(300, 0),
|
|
|
|
})
|
|
|
|
}))
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
AddStep("set accent white", () => dho.AccentColour.Value = Color4.White);
|
2022-10-20 00:32:33 +00:00
|
|
|
AddAssert("ball is white", () => dho.ChildrenOfType<LegacySliderBall>().Single().BallColour == Color4.White);
|
2020-11-16 13:40:25 +00:00
|
|
|
|
|
|
|
AddStep("set accent red", () => dho.AccentColour.Value = Color4.Red);
|
2022-10-20 00:32:33 +00:00
|
|
|
AddAssert("ball is red", () => dho.ChildrenOfType<LegacySliderBall>().Single().BallColour == Color4.Red);
|
2020-11-16 13:40:25 +00:00
|
|
|
}
|
|
|
|
|
2020-11-06 14:56:02 +00:00
|
|
|
private Slider prepareObject(Slider slider)
|
|
|
|
{
|
|
|
|
slider.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
|
|
|
|
return slider;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|