2019-01-24 16:43:03 +08: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.
|
2018-10-25 17:48:11 +08:00
|
|
|
|
2018-10-29 13:07:06 +08:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
2019-10-01 18:33:24 +08:00
|
|
|
using NUnit.Framework;
|
|
|
|
using osu.Framework.MathUtils;
|
2018-10-25 17:48:11 +08:00
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
using osu.Game.Beatmaps.ControlPoints;
|
2018-11-01 14:38:19 +08:00
|
|
|
using osu.Game.Rulesets.Objects;
|
2018-10-25 17:48:11 +08:00
|
|
|
using osu.Game.Rulesets.Objects.Types;
|
2019-10-01 18:33:24 +08:00
|
|
|
using osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles.Components;
|
2018-11-07 15:08:56 +08:00
|
|
|
using osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders;
|
|
|
|
using osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components;
|
2018-10-25 17:48:11 +08:00
|
|
|
using osu.Game.Rulesets.Osu.Objects;
|
|
|
|
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
|
|
|
using osu.Game.Tests.Visual;
|
2018-11-20 15:51:59 +08:00
|
|
|
using osuTK;
|
2018-10-25 17:48:11 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.Tests
|
|
|
|
{
|
2019-05-15 03:37:25 +08:00
|
|
|
public class TestSceneSliderSelectionBlueprint : SelectionBlueprintTestScene
|
2018-10-25 17:48:11 +08:00
|
|
|
{
|
2018-10-29 14:36:43 +08:00
|
|
|
public override IReadOnlyList<Type> RequiredTypes => new[]
|
2018-10-29 13:07:06 +08:00
|
|
|
{
|
2018-11-06 16:56:04 +08:00
|
|
|
typeof(SliderSelectionBlueprint),
|
|
|
|
typeof(SliderCircleSelectionBlueprint),
|
2018-10-29 13:07:06 +08:00
|
|
|
typeof(SliderBodyPiece),
|
|
|
|
typeof(SliderCircle),
|
2018-11-01 02:52:24 +08:00
|
|
|
typeof(PathControlPointVisualiser),
|
|
|
|
typeof(PathControlPointPiece)
|
2018-10-29 13:07:06 +08:00
|
|
|
};
|
|
|
|
|
2019-10-01 18:33:24 +08:00
|
|
|
private Slider slider;
|
|
|
|
private DrawableSlider drawableObject;
|
|
|
|
private TestSliderBlueprint blueprint;
|
2018-10-25 17:48:11 +08:00
|
|
|
|
2019-10-01 18:33:24 +08:00
|
|
|
[SetUp]
|
|
|
|
public void Setup() => Schedule(() =>
|
2018-10-25 17:48:11 +08:00
|
|
|
{
|
2019-10-01 18:33:24 +08:00
|
|
|
Clear();
|
|
|
|
|
|
|
|
slider = new Slider
|
2018-10-25 17:48:11 +08:00
|
|
|
{
|
|
|
|
Position = new Vector2(256, 192),
|
2018-11-01 14:38:19 +08:00
|
|
|
Path = new SliderPath(PathType.Bezier, new[]
|
2018-10-25 17:48:11 +08:00
|
|
|
{
|
|
|
|
Vector2.Zero,
|
|
|
|
new Vector2(150, 150),
|
|
|
|
new Vector2(300, 0)
|
2018-11-01 14:38:19 +08:00
|
|
|
})
|
2018-10-25 17:48:11 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
slider.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty { CircleSize = 2 });
|
|
|
|
|
|
|
|
Add(drawableObject = new DrawableSlider(slider));
|
2019-10-01 18:33:24 +08:00
|
|
|
AddBlueprint(blueprint = new TestSliderBlueprint(drawableObject));
|
|
|
|
});
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestInitialState()
|
|
|
|
{
|
|
|
|
checkPositions();
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestMoveHitObject()
|
|
|
|
{
|
|
|
|
moveHitObject();
|
|
|
|
checkPositions();
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestMoveAfterApplyingDefaults()
|
|
|
|
{
|
|
|
|
AddStep("apply defaults", () => slider.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty { CircleSize = 2 }));
|
|
|
|
moveHitObject();
|
|
|
|
checkPositions();
|
|
|
|
}
|
|
|
|
|
2019-10-21 15:15:41 +08:00
|
|
|
[Test]
|
|
|
|
public void TestStackedHitObject()
|
|
|
|
{
|
|
|
|
AddStep("set stacking", () => slider.StackHeight = 5);
|
|
|
|
checkPositions();
|
|
|
|
}
|
|
|
|
|
2019-10-01 18:33:24 +08:00
|
|
|
private void moveHitObject()
|
|
|
|
{
|
|
|
|
AddStep("move hitobject", () =>
|
|
|
|
{
|
|
|
|
slider.Position = new Vector2(300, 225);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
private void checkPositions()
|
|
|
|
{
|
2019-10-21 15:15:41 +08:00
|
|
|
AddAssert("body positioned correctly", () => blueprint.BodyPiece.Position == slider.StackedPosition);
|
2019-10-01 18:33:24 +08:00
|
|
|
|
|
|
|
AddAssert("head positioned correctly",
|
|
|
|
() => Precision.AlmostEquals(blueprint.HeadBlueprint.CirclePiece.ScreenSpaceDrawQuad.Centre, drawableObject.HeadCircle.ScreenSpaceDrawQuad.Centre));
|
|
|
|
|
|
|
|
AddAssert("tail positioned correctly",
|
|
|
|
() => Precision.AlmostEquals(blueprint.TailBlueprint.CirclePiece.ScreenSpaceDrawQuad.Centre, drawableObject.TailCircle.ScreenSpaceDrawQuad.Centre));
|
2018-10-25 17:48:11 +08:00
|
|
|
}
|
|
|
|
|
2019-10-01 18:33:24 +08:00
|
|
|
private class TestSliderBlueprint : SliderSelectionBlueprint
|
|
|
|
{
|
|
|
|
public new SliderBodyPiece BodyPiece => base.BodyPiece;
|
|
|
|
public new TestSliderCircleBlueprint HeadBlueprint => (TestSliderCircleBlueprint)base.HeadBlueprint;
|
|
|
|
public new TestSliderCircleBlueprint TailBlueprint => (TestSliderCircleBlueprint)base.TailBlueprint;
|
|
|
|
|
|
|
|
public TestSliderBlueprint(DrawableSlider slider)
|
|
|
|
: base(slider)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override SliderCircleSelectionBlueprint CreateCircleSelectionBlueprint(DrawableSlider slider, SliderPosition position) => new TestSliderCircleBlueprint(slider, position);
|
|
|
|
}
|
|
|
|
|
|
|
|
private class TestSliderCircleBlueprint : SliderCircleSelectionBlueprint
|
|
|
|
{
|
|
|
|
public new HitCirclePiece CirclePiece => base.CirclePiece;
|
|
|
|
|
|
|
|
public TestSliderCircleBlueprint(DrawableSlider slider, SliderPosition position)
|
|
|
|
: base(slider, position)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
2018-10-25 17:48:11 +08:00
|
|
|
}
|
|
|
|
}
|