mirror of
https://github.com/osukey/osukey.git
synced 2025-06-28 22:58:10 +09: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;
|
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)
|
foreach (var h in hitObjects)
|
||||||
h.Position += delta;
|
h.Position += delta;
|
||||||
|
|
||||||
|
moveSelectionInBounds();
|
||||||
|
|
||||||
return true;
|
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>
|
/// <summary>
|
||||||
/// Returns a gamefield-space quad surrounding the provided hit objects.
|
/// Returns a gamefield-space quad surrounding the provided hit objects.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user