mirror of
https://github.com/osukey/osukey.git
synced 2025-08-08 09:03:50 +09:00
Merge pull request #9350 from peppy/fix-editor-drag-selection-while-playing
Fix editor drag selection not continuing to select unless the mouse is moved
This commit is contained in:
@ -13,6 +13,7 @@ using osu.Framework.Graphics.Primitives;
|
|||||||
using osu.Framework.Input;
|
using osu.Framework.Input;
|
||||||
using osu.Framework.Input.Bindings;
|
using osu.Framework.Input.Bindings;
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Rulesets.Edit;
|
using osu.Game.Rulesets.Edit;
|
||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
using osu.Game.Rulesets.Objects.Drawables;
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
@ -324,10 +325,22 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
{
|
{
|
||||||
foreach (var blueprint in SelectionBlueprints)
|
foreach (var blueprint in SelectionBlueprints)
|
||||||
{
|
{
|
||||||
if (blueprint.IsAlive && blueprint.IsPresent && rect.Contains(blueprint.ScreenSpaceSelectionPoint))
|
// only run when utmost necessary to avoid unnecessary rect computations.
|
||||||
|
bool isValidForSelection() => blueprint.IsAlive && blueprint.IsPresent && rect.Contains(blueprint.ScreenSpaceSelectionPoint);
|
||||||
|
|
||||||
|
switch (blueprint.State)
|
||||||
|
{
|
||||||
|
case SelectionState.NotSelected:
|
||||||
|
if (isValidForSelection())
|
||||||
blueprint.Select();
|
blueprint.Select();
|
||||||
else
|
break;
|
||||||
|
|
||||||
|
case SelectionState.Selected:
|
||||||
|
// if the editor is playing, we generally don't want to deselect objects even if outside the selection area.
|
||||||
|
if (!editorClock.IsRunning && !isValidForSelection())
|
||||||
blueprint.Deselect();
|
blueprint.Deselect();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,6 +53,8 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private RectangleF? dragRectangle;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handle a forwarded mouse event.
|
/// Handle a forwarded mouse event.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -66,15 +68,14 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
var dragQuad = new Quad(dragStartPosition.X, dragStartPosition.Y, dragPosition.X - dragStartPosition.X, dragPosition.Y - dragStartPosition.Y);
|
var dragQuad = new Quad(dragStartPosition.X, dragStartPosition.Y, dragPosition.X - dragStartPosition.X, dragPosition.Y - dragStartPosition.Y);
|
||||||
|
|
||||||
// We use AABBFloat instead of RectangleF since it handles negative sizes for us
|
// We use AABBFloat instead of RectangleF since it handles negative sizes for us
|
||||||
var dragRectangle = dragQuad.AABBFloat;
|
var rec = dragQuad.AABBFloat;
|
||||||
|
dragRectangle = rec;
|
||||||
|
|
||||||
var topLeft = ToLocalSpace(dragRectangle.TopLeft);
|
var topLeft = ToLocalSpace(rec.TopLeft);
|
||||||
var bottomRight = ToLocalSpace(dragRectangle.BottomRight);
|
var bottomRight = ToLocalSpace(rec.BottomRight);
|
||||||
|
|
||||||
Box.Position = topLeft;
|
Box.Position = topLeft;
|
||||||
Box.Size = bottomRight - topLeft;
|
Box.Size = bottomRight - topLeft;
|
||||||
|
|
||||||
PerformSelection?.Invoke(dragRectangle);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,7 +94,19 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Hide() => State = Visibility.Hidden;
|
protected override void Update()
|
||||||
|
{
|
||||||
|
base.Update();
|
||||||
|
|
||||||
|
if (dragRectangle != null)
|
||||||
|
PerformSelection?.Invoke(dragRectangle.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Hide()
|
||||||
|
{
|
||||||
|
State = Visibility.Hidden;
|
||||||
|
dragRectangle = null;
|
||||||
|
}
|
||||||
|
|
||||||
public override void Show() => State = Visibility.Visible;
|
public override void Show() => State = Visibility.Visible;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user