1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-14 03:25:11 +08:00

Change single slider scaling to a method that works

This commit is contained in:
Leon Gebler 2021-03-23 16:09:44 +01:00
parent 3d471d239f
commit e67ab3cca7

View File

@ -197,19 +197,19 @@ namespace osu.Game.Rulesets.Osu.Edit
Quad sliderQuad = getSurroundingQuad(slider.Path.ControlPoints.Select(p => p.Position.Value));
Vector2 pathRelativeDeltaScale = new Vector2(1 + scale.X / sliderQuad.Width, 1 + scale.Y / sliderQuad.Height);
Quad selectionQuad = getSurroundingQuad(new OsuHitObject[] { slider });
Quad scaledQuad = new Quad(selectionQuad.TopLeft.X, selectionQuad.TopLeft.Y, selectionQuad.Width + scale.X, selectionQuad.Height + scale.Y);
(bool xInBounds, bool yInBounds) = isQuadInBounds(scaledQuad);
if (!xInBounds)
pathRelativeDeltaScale.X = 1;
if (!yInBounds)
pathRelativeDeltaScale.Y = 1;
foreach (var point in slider.Path.ControlPoints)
point.Position.Value *= pathRelativeDeltaScale;
//if sliderhead or sliderend end up outside playfield, revert scaling.
Quad scaledQuad = getSurroundingQuad(new OsuHitObject[] { slider });
(bool xInBounds, bool yInBounds) = isQuadInBounds(scaledQuad);
if (xInBounds && yInBounds)
return true;
foreach (var point in slider.Path.ControlPoints)
point.Position.Value *= new Vector2(1 / pathRelativeDeltaScale.X, 1 / pathRelativeDeltaScale.Y);
return true;
}