1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 12:33:01 +08:00

Move logic to keep selection in bounds into it's own method

This commit is contained in:
Leon Gebler 2021-02-20 21:48:31 +01:00
parent 9a7fe4056a
commit cc4c5f72d8

View File

@ -211,26 +211,35 @@ namespace osu.Game.Rulesets.Osu.Edit
{
var hitObjects = selectedMovableObjects;
Quad quad = getSurroundingQuad(hitObjects);
Vector2 newTopLeft = quad.TopLeft + delta;
if (newTopLeft.X < 0)
delta.X -= newTopLeft.X;
if (newTopLeft.Y < 0)
delta.Y -= newTopLeft.Y;
Vector2 newBottomRight = quad.BottomRight + delta;
if (newBottomRight.X > DrawWidth)
delta.X -= newBottomRight.X - DrawWidth;
if (newBottomRight.Y > DrawHeight)
delta.Y -= newBottomRight.Y - DrawHeight;
foreach (var h in hitObjects)
h.Position += delta;
moveSelectionInBounds();
return true;
}
private void moveSelectionInBounds()
{
var hitObjects = selectedMovableObjects;
Quad quad = getSurroundingQuad(hitObjects);
Vector2 delta = new Vector2(0);
if (quad.TopLeft.X < 0)
delta.X -= quad.TopLeft.X;
if (quad.TopLeft.Y < 0)
delta.Y -= quad.TopLeft.Y;
if (quad.BottomRight.X > DrawWidth)
delta.X -= quad.BottomRight.X - DrawWidth;
if (quad.BottomRight.Y > DrawHeight)
delta.Y -= quad.BottomRight.Y - DrawHeight;
foreach (var h in hitObjects)
h.Position += delta;
}
/// <summary>
/// Returns a gamefield-space quad surrounding the provided hit objects.
/// </summary>