mirror of
https://github.com/ppy/osu.git
synced 2025-02-22 06:02:54 +08:00
Merge pull request #12090 from bdach/overlapping-object-selection
Fix selection blueprint misbehaving with overlapping objects
This commit is contained in:
commit
e630c1be50
@ -4,6 +4,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using JetBrains.Annotations;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
@ -28,6 +29,8 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
|
|||||||
protected SliderBodyPiece BodyPiece { get; private set; }
|
protected SliderBodyPiece BodyPiece { get; private set; }
|
||||||
protected SliderCircleSelectionBlueprint HeadBlueprint { get; private set; }
|
protected SliderCircleSelectionBlueprint HeadBlueprint { get; private set; }
|
||||||
protected SliderCircleSelectionBlueprint TailBlueprint { get; private set; }
|
protected SliderCircleSelectionBlueprint TailBlueprint { get; private set; }
|
||||||
|
|
||||||
|
[CanBeNull]
|
||||||
protected PathControlPointVisualiser ControlPointVisualiser { get; private set; }
|
protected PathControlPointVisualiser ControlPointVisualiser { get; private set; }
|
||||||
|
|
||||||
private readonly DrawableSlider slider;
|
private readonly DrawableSlider slider;
|
||||||
@ -114,6 +117,8 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
|
|||||||
|
|
||||||
// throw away frame buffers on deselection.
|
// throw away frame buffers on deselection.
|
||||||
ControlPointVisualiser?.Expire();
|
ControlPointVisualiser?.Expire();
|
||||||
|
ControlPointVisualiser = null;
|
||||||
|
|
||||||
BodyPiece.RecyclePath();
|
BodyPiece.RecyclePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
70
osu.Game.Tests/Visual/Editing/TestSceneBlueprintSelection.cs
Normal file
70
osu.Game.Tests/Visual/Editing/TestSceneBlueprintSelection.cs
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System.Linq;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using osu.Framework.Testing;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Rulesets;
|
||||||
|
using osu.Game.Rulesets.Objects;
|
||||||
|
using osu.Game.Rulesets.Osu;
|
||||||
|
using osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components;
|
||||||
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
|
using osu.Game.Screens.Edit.Compose.Components;
|
||||||
|
using osu.Game.Tests.Beatmaps;
|
||||||
|
using osuTK;
|
||||||
|
using osuTK.Input;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Visual.Editing
|
||||||
|
{
|
||||||
|
public class TestSceneBlueprintSelection : EditorTestScene
|
||||||
|
{
|
||||||
|
protected override Ruleset CreateEditorRuleset() => new OsuRuleset();
|
||||||
|
|
||||||
|
protected override IBeatmap CreateBeatmap(RulesetInfo ruleset) => new TestBeatmap(ruleset, false);
|
||||||
|
|
||||||
|
private BlueprintContainer blueprintContainer
|
||||||
|
=> Editor.ChildrenOfType<BlueprintContainer>().First();
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestSelectedObjectHasPriorityWhenOverlapping()
|
||||||
|
{
|
||||||
|
var firstSlider = new Slider
|
||||||
|
{
|
||||||
|
Path = new SliderPath(new[]
|
||||||
|
{
|
||||||
|
new PathControlPoint(new Vector2()),
|
||||||
|
new PathControlPoint(new Vector2(150, -50)),
|
||||||
|
new PathControlPoint(new Vector2(300, 0))
|
||||||
|
}),
|
||||||
|
Position = new Vector2(0, 100)
|
||||||
|
};
|
||||||
|
var secondSlider = new Slider
|
||||||
|
{
|
||||||
|
Path = new SliderPath(new[]
|
||||||
|
{
|
||||||
|
new PathControlPoint(new Vector2()),
|
||||||
|
new PathControlPoint(new Vector2(-50, 50)),
|
||||||
|
new PathControlPoint(new Vector2(-100, 100))
|
||||||
|
}),
|
||||||
|
Position = new Vector2(200, 0)
|
||||||
|
};
|
||||||
|
|
||||||
|
AddStep("add overlapping sliders", () =>
|
||||||
|
{
|
||||||
|
EditorBeatmap.Add(firstSlider);
|
||||||
|
EditorBeatmap.Add(secondSlider);
|
||||||
|
});
|
||||||
|
AddStep("select first slider", () => EditorBeatmap.SelectedHitObjects.Add(firstSlider));
|
||||||
|
|
||||||
|
AddStep("move mouse to common point", () =>
|
||||||
|
{
|
||||||
|
var pos = blueprintContainer.ChildrenOfType<PathControlPointPiece>().ElementAt(1).ScreenSpaceDrawQuad.Centre;
|
||||||
|
InputManager.MoveMouseTo(pos);
|
||||||
|
});
|
||||||
|
AddStep("right click", () => InputManager.Click(MouseButton.Right));
|
||||||
|
|
||||||
|
AddAssert("selection is unchanged", () => EditorBeatmap.SelectedHitObjects.Single() == firstSlider);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -338,7 +338,8 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
private bool beginClickSelection(MouseButtonEvent e)
|
private bool beginClickSelection(MouseButtonEvent e)
|
||||||
{
|
{
|
||||||
// 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).
|
||||||
foreach (SelectionBlueprint blueprint in SelectionBlueprints.AliveChildren.Reverse())
|
// Priority is given to already-selected blueprints.
|
||||||
|
foreach (SelectionBlueprint blueprint in SelectionBlueprints.AliveChildren.Reverse().OrderByDescending(b => b.IsSelected))
|
||||||
{
|
{
|
||||||
if (!blueprint.IsHovered) continue;
|
if (!blueprint.IsHovered) continue;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user