Improve drag box selection logic

`AllowDeselectionDuringDrag` is remove.
Instead, selected hit objects are not automatically deselected
when clock is seeked to a later time (the hit object is dead).
Update drag box selection even if mouse is not moved
(in case clock is running or scroll wheel is used).
This commit is contained in:
ekrctb
2022-10-11 14:11:45 +09:00
parent cb21126623
commit 1a24762f9b
2 changed files with 31 additions and 12 deletions

View File

@ -39,6 +39,8 @@ namespace osu.Game.Screens.Edit.Compose.Components
private PlacementBlueprint currentPlacement;
private InputManager inputManager;
private DragEvent lastDragEvent;
/// <remarks>
/// Positional input must be received outside the container's bounds,
/// in order to handle composer blueprints which are partially offscreen.
@ -83,8 +85,6 @@ namespace osu.Game.Screens.Edit.Compose.Components
}
}
protected override bool AllowDeselectionDuringDrag => !EditorClock.IsRunning;
protected override void TransferBlueprintFor(HitObject hitObject, DrawableHitObject drawableObject)
{
base.TransferBlueprintFor(hitObject, drawableObject);
@ -120,6 +120,18 @@ namespace osu.Game.Screens.Edit.Compose.Components
return false;
}
protected override void OnDrag(DragEvent e)
{
base.OnDrag(e);
lastDragEvent = e;
}
protected override void OnDragEnd(DragEndEvent e)
{
base.OnDragEnd(e);
lastDragEvent = null;
}
/// <summary>
/// Move the current selection spatially by the specified delta, in gamefield coordinates (ie. the same coordinates as the blueprints).
/// </summary>
@ -236,6 +248,10 @@ namespace osu.Game.Screens.Edit.Compose.Components
{
base.Update();
// trigger every frame so drags continue to update selection while seeking time.
if (lastDragEvent != null)
OnDrag(lastDragEvent);
if (currentPlacement != null)
{
switch (currentPlacement.PlacementActive)