1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 09:02:58 +08:00

Apply nullability to new test scene

This commit is contained in:
Dean Herbert 2022-10-31 15:46:57 +09:00
parent 94dd4045f1
commit e38ba5e4c6

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using NUnit.Framework; using NUnit.Framework;
@ -22,8 +20,9 @@ namespace osu.Game.Tests.Visual.Gameplay
private readonly SmoothPath controlPointDrawablePath; private readonly SmoothPath controlPointDrawablePath;
private readonly SmoothPath convertedDrawablePath; private readonly SmoothPath convertedDrawablePath;
private readonly SmoothPath convertedControlPointDrawablePath; private readonly SmoothPath convertedControlPointDrawablePath;
private SliderPath path;
private SliderPath convertedPath; private SliderPath path = null!;
private SliderPath convertedPath = null!;
public TestSceneBezierConverter() public TestSceneBezierConverter()
{ {
@ -58,16 +57,20 @@ namespace osu.Game.Tests.Visual.Gameplay
Position = new Vector2(100, 300) Position = new Vector2(100, 300)
} }
}; };
resetPath();
} }
[SetUp] [SetUp]
public void Setup() => Schedule(() => public void Setup() => Schedule(resetPath);
private void resetPath()
{ {
path = new SliderPath(); path = new SliderPath();
convertedPath = new SliderPath(); convertedPath = new SliderPath();
path.Version.ValueChanged += getConvertedControlPoints; path.Version.ValueChanged += getConvertedControlPoints;
}); }
private void getConvertedControlPoints(ValueChangedEvent<int> obj) private void getConvertedControlPoints(ValueChangedEvent<int> obj)
{ {
@ -79,26 +82,30 @@ namespace osu.Game.Tests.Visual.Gameplay
{ {
base.Update(); base.Update();
if (path != null) List<Vector2> vertices = new List<Vector2>();
{
List<Vector2> vertices = new List<Vector2>();
path.GetPathToProgress(vertices, 0, 1);
drawablePath.Vertices = vertices; path.GetPathToProgress(vertices, 0, 1);
controlPointDrawablePath.Vertices = path.ControlPoints.Select(o => o.Position).ToList();
if (controlPointDrawablePath.Vertices.Count > 0) drawablePath.Vertices = vertices;
controlPointDrawablePath.Position = drawablePath.PositionInBoundingBox(drawablePath.Vertices[0]) - controlPointDrawablePath.PositionInBoundingBox(controlPointDrawablePath.Vertices[0]); controlPointDrawablePath.Vertices = path.ControlPoints.Select(o => o.Position).ToList();
if (controlPointDrawablePath.Vertices.Count > 0)
{
controlPointDrawablePath.Position =
drawablePath.PositionInBoundingBox(drawablePath.Vertices[0]) - controlPointDrawablePath.PositionInBoundingBox(controlPointDrawablePath.Vertices[0]);
} }
if (convertedPath != null) vertices.Clear();
{
List<Vector2> vertices = new List<Vector2>();
convertedPath.GetPathToProgress(vertices, 0, 1);
convertedDrawablePath.Vertices = vertices; convertedPath.GetPathToProgress(vertices, 0, 1);
convertedControlPointDrawablePath.Vertices = convertedPath.ControlPoints.Select(o => o.Position).ToList();
if (convertedControlPointDrawablePath.Vertices.Count > 0) convertedDrawablePath.Vertices = vertices;
convertedControlPointDrawablePath.Position = convertedDrawablePath.PositionInBoundingBox(convertedDrawablePath.Vertices[0]) - convertedControlPointDrawablePath.PositionInBoundingBox(convertedControlPointDrawablePath.Vertices[0]); convertedControlPointDrawablePath.Vertices = convertedPath.ControlPoints.Select(o => o.Position).ToList();
if (convertedControlPointDrawablePath.Vertices.Count > 0)
{
convertedControlPointDrawablePath.Position = convertedDrawablePath.PositionInBoundingBox(convertedDrawablePath.Vertices[0])
- convertedControlPointDrawablePath.PositionInBoundingBox(convertedControlPointDrawablePath.Vertices[0]);
} }
} }