mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 20:32:55 +08:00
Change single slider scaling to a method that works
This commit is contained in:
parent
3d471d239f
commit
e67ab3cca7
@ -197,19 +197,19 @@ namespace osu.Game.Rulesets.Osu.Edit
|
|||||||
Quad sliderQuad = getSurroundingQuad(slider.Path.ControlPoints.Select(p => p.Position.Value));
|
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);
|
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)
|
foreach (var point in slider.Path.ControlPoints)
|
||||||
point.Position.Value *= pathRelativeDeltaScale;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user