From 2678089e0b0610ea78afb373a36f81d54af171cc Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 18 Apr 2021 20:18:30 +0900 Subject: [PATCH 1/3] Add test case failing on selection after paste --- .../Editing/TestSceneEditorClipboard.cs | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/osu.Game.Tests/Visual/Editing/TestSceneEditorClipboard.cs b/osu.Game.Tests/Visual/Editing/TestSceneEditorClipboard.cs index 29046c82a6..01d9966736 100644 --- a/osu.Game.Tests/Visual/Editing/TestSceneEditorClipboard.cs +++ b/osu.Game.Tests/Visual/Editing/TestSceneEditorClipboard.cs @@ -3,12 +3,16 @@ using System.Linq; using NUnit.Framework; +using osu.Framework.Testing; using osu.Game.Beatmaps; using osu.Game.Rulesets; +using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Osu; using osu.Game.Rulesets.Osu.Objects; +using osu.Game.Screens.Edit.Compose.Components; +using osu.Game.Screens.Edit.Compose.Components.Timeline; using osu.Game.Tests.Beatmaps; using osuTK; @@ -110,8 +114,9 @@ namespace osu.Game.Tests.Visual.Editing AddAssert("duration matches", () => ((Spinner)EditorBeatmap.HitObjects.Single()).Duration == 5000); } - [Test] - public void TestCopyPaste() + [TestCase(false)] + [TestCase(true)] + public void TestCopyPaste(bool deselectAfterCopy) { var addedObject = new HitCircle { StartTime = 1000 }; @@ -123,11 +128,22 @@ namespace osu.Game.Tests.Visual.Editing AddStep("move forward in time", () => EditorClock.Seek(2000)); + if (deselectAfterCopy) + { + AddStep("deselect", () => EditorBeatmap.SelectedHitObjects.Clear()); + + AddUntilStep("timeline selection box is not visible", () => Editor.ChildrenOfType().First().ChildrenOfType().First().Alpha == 0); + AddUntilStep("composer selection box is not visible", () => Editor.ChildrenOfType().First().ChildrenOfType().First().Alpha == 0); + } + AddStep("paste hitobject", () => Editor.Paste()); AddAssert("are two objects", () => EditorBeatmap.HitObjects.Count == 2); AddAssert("new object selected", () => EditorBeatmap.SelectedHitObjects.Single().StartTime == 2000); + + AddUntilStep("timeline selection box is visible", () => Editor.ChildrenOfType().First().ChildrenOfType().First().Alpha > 0); + AddUntilStep("composer selection box is visible", () => Editor.ChildrenOfType().First().ChildrenOfType().First().Alpha > 0); } [Test] From e76565dbc57f874fd4143d5d8717aeeb99e5a5eb Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 18 Apr 2021 20:11:05 +0900 Subject: [PATCH 2/3] Fix selection box not displaying after pasting a selection in the editor Closes #12471. --- .../Edit/Compose/Components/SelectionHandler.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/osu.Game/Screens/Edit/Compose/Components/SelectionHandler.cs b/osu.Game/Screens/Edit/Compose/Components/SelectionHandler.cs index 389ef78ed5..40641ee41f 100644 --- a/osu.Game/Screens/Edit/Compose/Components/SelectionHandler.cs +++ b/osu.Game/Screens/Edit/Compose/Components/SelectionHandler.cs @@ -33,10 +33,14 @@ namespace osu.Game.Screens.Edit.Compose.Components /// public class SelectionHandler : CompositeDrawable, IKeyBindingHandler, IHasContextMenu { + /// + /// The currently selected blueprints. + /// Should be used when operations are dealing directly with the visible blueprints. + /// For more general selection operations, use EditorBeatmap.SelectedHitObjects instead. + /// public IEnumerable SelectedBlueprints => selectedBlueprints; - private readonly List selectedBlueprints; - public int SelectedCount => selectedBlueprints.Count; + private readonly List selectedBlueprints; private Drawable content; @@ -295,7 +299,7 @@ namespace osu.Game.Screens.Edit.Compose.Components /// private void updateVisibility() { - int count = selectedBlueprints.Count; + int count = EditorBeatmap.SelectedHitObjects.Count; selectionDetailsText.Text = count > 0 ? count.ToString() : string.Empty; From cfc76640941f5dcb41dc4e5b319b207be7e85214 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 18 Apr 2021 21:05:23 +0900 Subject: [PATCH 3/3] Use full path --- osu.Game/Screens/Edit/Compose/Components/SelectionHandler.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Edit/Compose/Components/SelectionHandler.cs b/osu.Game/Screens/Edit/Compose/Components/SelectionHandler.cs index 40641ee41f..b06e982859 100644 --- a/osu.Game/Screens/Edit/Compose/Components/SelectionHandler.cs +++ b/osu.Game/Screens/Edit/Compose/Components/SelectionHandler.cs @@ -36,7 +36,7 @@ namespace osu.Game.Screens.Edit.Compose.Components /// /// The currently selected blueprints. /// Should be used when operations are dealing directly with the visible blueprints. - /// For more general selection operations, use EditorBeatmap.SelectedHitObjects instead. + /// For more general selection operations, use instead. /// public IEnumerable SelectedBlueprints => selectedBlueprints;