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:
parent
9a7fe4056a
commit
cc4c5f72d8
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user