mirror of
https://github.com/ppy/osu.git
synced 2024-11-14 15:17:27 +08:00
65 lines
2.2 KiB
C#
65 lines
2.2 KiB
C#
// 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;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Humanizer;
|
|
using NUnit.Framework;
|
|
using osu.Framework.Graphics;
|
|
using osu.Game.Beatmaps;
|
|
using osu.Game.Beatmaps.ControlPoints;
|
|
using osu.Game.Rulesets.Objects;
|
|
using osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components;
|
|
using osu.Game.Rulesets.Osu.Objects;
|
|
using osu.Game.Tests.Visual;
|
|
using osuTK;
|
|
|
|
namespace osu.Game.Rulesets.Osu.Tests
|
|
{
|
|
public class TestScenePathControlPointVisualiser : OsuTestScene
|
|
{
|
|
public override IReadOnlyList<Type> RequiredTypes => new[]
|
|
{
|
|
typeof(StringHumanizeExtensions),
|
|
typeof(PathControlPointPiece),
|
|
typeof(PathControlPointConnectionPiece)
|
|
};
|
|
|
|
private Slider slider;
|
|
private PathControlPointVisualiser visualiser;
|
|
|
|
[SetUp]
|
|
public void Setup() => Schedule(() =>
|
|
{
|
|
slider = new Slider();
|
|
slider.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
|
|
});
|
|
|
|
[Test]
|
|
public void TestAddOverlappingControlPoints()
|
|
{
|
|
createVisualiser(true);
|
|
|
|
addControlPointStep(new Vector2(200));
|
|
addControlPointStep(new Vector2(300));
|
|
addControlPointStep(new Vector2(300));
|
|
addControlPointStep(new Vector2(500, 300));
|
|
|
|
AddAssert("last connection displayed", () =>
|
|
{
|
|
var lastConnection = visualiser.Connections.Last(c => c.ControlPoint.Position.Value == new Vector2(300));
|
|
return lastConnection.DrawWidth > 50;
|
|
});
|
|
}
|
|
|
|
private void createVisualiser(bool allowSelection) => AddStep("create visualiser", () => Child = visualiser = new PathControlPointVisualiser(slider, allowSelection)
|
|
{
|
|
Anchor = Anchor.Centre,
|
|
Origin = Anchor.Centre
|
|
});
|
|
|
|
private void addControlPointStep(Vector2 position) => AddStep($"add control point {position}", () => slider.Path.ControlPoints.Add(new PathControlPoint(position)));
|
|
}
|
|
}
|