1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 09:07:52 +08:00

Fix test failure due to relying on implementation detail

This commit is contained in:
Bartłomiej Dach 2023-06-19 18:42:30 +02:00
parent 84fc6e92db
commit 9bcd86d66d
No known key found for this signature in database

View File

@ -185,7 +185,18 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
AddAssert("Ensure cursor is on a grid line", () =>
{
return grid.ChildrenOfType<CircularProgress>().Any(p => Precision.AlmostEquals(p.ScreenSpaceDrawQuad.TopRight.X, grid.ToScreenSpace(cursor.LastSnappedPosition).X));
return grid.ChildrenOfType<CircularProgress>().Any(ring =>
{
// the grid rings are actually slightly _larger_ than the snapping radii.
// this is done such that the snapping radius falls right in the middle of each grid ring thickness-wise,
// but it does however complicate the following calculations slightly.
// we want to calculate the coordinates of the rightmost point on the grid line, which is in the exact middle of the ring thickness-wise.
// for the X component, we take the entire width of the ring, minus one half of the inner radius (since we want the middle of the line on the right side).
// for the Y component, we just take 0.5f.
var rightMiddleOfGridLine = ring.ToScreenSpace(ring.DrawSize * new Vector2(1 - ring.InnerRadius / 2, 0.5f));
return Precision.AlmostEquals(rightMiddleOfGridLine.X, grid.ToScreenSpace(cursor.LastSnappedPosition).X);
});
});
}