mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 12:33:01 +08:00
Change editor to always perform selection of closest object
This commit is contained in:
parent
4e4dcc9846
commit
5ade093c5a
@ -381,6 +381,8 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private bool selectedBlueprintAlreadySelectedOnMouseDown;
|
private bool selectedBlueprintAlreadySelectedOnMouseDown;
|
||||||
|
|
||||||
|
protected virtual IEnumerable<SelectionBlueprint<T>> ApplySelectionOrder(IEnumerable<SelectionBlueprint<T>> blueprints) => blueprints.Reverse();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Attempts to select any hovered blueprints.
|
/// Attempts to select any hovered blueprints.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -390,15 +392,28 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
{
|
{
|
||||||
// Iterate from the top of the input stack (blueprints closest to the front of the screen first).
|
// Iterate from the top of the input stack (blueprints closest to the front of the screen first).
|
||||||
// Priority is given to already-selected blueprints.
|
// Priority is given to already-selected blueprints.
|
||||||
foreach (SelectionBlueprint<T> blueprint in SelectionBlueprints.AliveChildren.Reverse().OrderByDescending(b => b.IsSelected))
|
foreach (SelectionBlueprint<T> blueprint in SelectionBlueprints.AliveChildren.Where(b => b.IsSelected))
|
||||||
{
|
{
|
||||||
if (!blueprint.IsHovered) continue;
|
if (runForBlueprint(blueprint))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
selectedBlueprintAlreadySelectedOnMouseDown = blueprint.State == SelectionState.Selected;
|
foreach (SelectionBlueprint<T> blueprint in ApplySelectionOrder(SelectionBlueprints.AliveChildren))
|
||||||
return clickSelectionHandled = SelectionHandler.MouseDownSelectionRequested(blueprint, e);
|
{
|
||||||
|
if (runForBlueprint(blueprint))
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
bool runForBlueprint(SelectionBlueprint<T> blueprint)
|
||||||
|
{
|
||||||
|
if (!blueprint.IsHovered) return false;
|
||||||
|
|
||||||
|
selectedBlueprintAlreadySelectedOnMouseDown = blueprint.State == SelectionState.Selected;
|
||||||
|
clickSelectionHandled = SelectionHandler.MouseDownSelectionRequested(blueprint, e);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -432,13 +447,13 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
|
|
||||||
// The depth of blueprints is constantly changing (see above where selected blueprints are brought to the front).
|
// The depth of blueprints is constantly changing (see above where selected blueprints are brought to the front).
|
||||||
// For this logic, we want a stable sort order so we can correctly cycle, thus using the blueprintMap instead.
|
// For this logic, we want a stable sort order so we can correctly cycle, thus using the blueprintMap instead.
|
||||||
IEnumerable<SelectionBlueprint<T>> cyclingSelectionBlueprints = blueprintMap.Values;
|
IEnumerable<SelectionBlueprint<T>> cyclingSelectionBlueprints = ApplySelectionOrder(blueprintMap.Values);
|
||||||
|
|
||||||
// If there's already a selection, let's start from the blueprint after the selection.
|
// If there's already a selection, let's start from the blueprint after the selection.
|
||||||
cyclingSelectionBlueprints = cyclingSelectionBlueprints.SkipWhile(b => !b.IsSelected).Skip(1);
|
cyclingSelectionBlueprints = cyclingSelectionBlueprints.SkipWhile(b => !b.IsSelected).Skip(1);
|
||||||
|
|
||||||
// Add the blueprints from before the selection to the end of the enumerable to allow for cyclic selection.
|
// Add the blueprints from before the selection to the end of the enumerable to allow for cyclic selection.
|
||||||
cyclingSelectionBlueprints = cyclingSelectionBlueprints.Concat(blueprintMap.Values.TakeWhile(b => !b.IsSelected));
|
cyclingSelectionBlueprints = cyclingSelectionBlueprints.Concat(ApplySelectionOrder(blueprintMap.Values).TakeWhile(b => !b.IsSelected));
|
||||||
|
|
||||||
foreach (SelectionBlueprint<T> blueprint in cyclingSelectionBlueprints)
|
foreach (SelectionBlueprint<T> blueprint in cyclingSelectionBlueprints)
|
||||||
{
|
{
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
@ -129,6 +130,10 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override IEnumerable<SelectionBlueprint<HitObject>> ApplySelectionOrder(IEnumerable<SelectionBlueprint<HitObject>> blueprints) =>
|
||||||
|
base.ApplySelectionOrder(blueprints)
|
||||||
|
.OrderBy(b => Math.Min(Math.Abs(EditorClock.CurrentTime - b.Item.GetEndTime()), Math.Abs(EditorClock.CurrentTime - b.Item.StartTime)));
|
||||||
|
|
||||||
protected override Container<SelectionBlueprint<HitObject>> CreateSelectionBlueprintContainer() => new HitObjectOrderedSelectionContainer { RelativeSizeAxes = Axes.Both };
|
protected override Container<SelectionBlueprint<HitObject>> CreateSelectionBlueprintContainer() => new HitObjectOrderedSelectionContainer { RelativeSizeAxes = Axes.Both };
|
||||||
|
|
||||||
protected override SelectionHandler<HitObject> CreateSelectionHandler() => new EditorSelectionHandler();
|
protected override SelectionHandler<HitObject> CreateSelectionHandler() => new EditorSelectionHandler();
|
||||||
|
Loading…
Reference in New Issue
Block a user