1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 09:02:55 +08:00

Merge pull request #10139 from peppy/editor-fix-multiple-selection

Fix editor selected hitobjects containing the selection up to five times
This commit is contained in:
Dan Balasescu 2020-09-14 17:19:56 +09:00 committed by GitHub
commit 5712d3f0aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 3 deletions

View File

@ -27,6 +27,17 @@ namespace osu.Game.Tests.Visual.Editing
AddStep("get beatmap", () => editorBeatmap = Editor.ChildrenOfType<EditorBeatmap>().Single());
}
[Test]
public void TestSelectedObjects()
{
HitCircle obj = null;
AddStep("add hitobject", () => editorBeatmap.Add(obj = new HitCircle { StartTime = 1000 }));
AddStep("select hitobject", () => editorBeatmap.SelectedHitObjects.Add(obj));
AddAssert("confirm 1 selected", () => editorBeatmap.SelectedHitObjects.Count == 1);
AddStep("deselect hitobject", () => editorBeatmap.SelectedHitObjects.Remove(obj));
AddAssert("confirm 0 selected", () => editorBeatmap.SelectedHitObjects.Count == 0);
}
[Test]
public void TestUndoFromInitialState()
{

View File

@ -367,14 +367,12 @@ namespace osu.Game.Screens.Edit.Compose.Components
{
selectionHandler.HandleSelected(blueprint);
SelectionBlueprints.ChangeChildDepth(blueprint, 1);
beatmap.SelectedHitObjects.Add(blueprint.HitObject);
}
private void onBlueprintDeselected(SelectionBlueprint blueprint)
{
selectionHandler.HandleDeselected(blueprint);
SelectionBlueprints.ChangeChildDepth(blueprint, 0);
beatmap.SelectedHitObjects.Remove(blueprint.HitObject);
}
#endregion

View File

@ -146,7 +146,10 @@ namespace osu.Game.Screens.Edit.Compose.Components
internal void HandleSelected(SelectionBlueprint blueprint)
{
selectedBlueprints.Add(blueprint);
EditorBeatmap.SelectedHitObjects.Add(blueprint.HitObject);
// there are potentially multiple SelectionHandlers active, but we only want to add hitobjects to the selected list once.
if (!EditorBeatmap.SelectedHitObjects.Contains(blueprint.HitObject))
EditorBeatmap.SelectedHitObjects.Add(blueprint.HitObject);
UpdateVisibility();
}
@ -158,6 +161,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
internal void HandleDeselected(SelectionBlueprint blueprint)
{
selectedBlueprints.Remove(blueprint);
EditorBeatmap.SelectedHitObjects.Remove(blueprint.HitObject);
UpdateVisibility();