From a9d14eadacea77e5b479adb7396367f45c31132a Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 14 Feb 2018 17:53:04 +0900 Subject: [PATCH] Add clearSelection method --- .../Edit/Layers/Selection/SelectionLayer.cs | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/osu.Game/Rulesets/Edit/Layers/Selection/SelectionLayer.cs b/osu.Game/Rulesets/Edit/Layers/Selection/SelectionLayer.cs index e1fc0d179a..a335108a0f 100644 --- a/osu.Game/Rulesets/Edit/Layers/Selection/SelectionLayer.cs +++ b/osu.Game/Rulesets/Edit/Layers/Selection/SelectionLayer.cs @@ -27,12 +27,11 @@ namespace osu.Game.Rulesets.Edit.Layers.Selection private SelectionBox selectionBox; private CaptureBox captureBox; - private readonly List capturedHitObjects = new List(); + private readonly List selectedHitObjects = new List(); protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) { - capturedHitObjects.Clear(); - captureBox?.Hide(); + clearSelection(); return true; } @@ -71,6 +70,15 @@ namespace osu.Game.Rulesets.Edit.Layers.Selection return true; } + /// + /// Deselects all selected s. + /// + private void clearSelection() + { + selectedHitObjects.Clear(); + captureBox?.Hide(); + } + /// /// Captures all hitobjects that are present within the area of a . /// @@ -78,7 +86,7 @@ namespace osu.Game.Rulesets.Edit.Layers.Selection private void captureQuad(Quad screenSpaceQuad) { foreach (var obj in playfield.HitObjects.Objects.Where(h => h.IsAlive && h.IsPresent && screenSpaceQuad.Contains(h.SelectionPoint))) - capturedHitObjects.Add(obj); + selectedHitObjects.Add(obj); } /// @@ -91,12 +99,12 @@ namespace osu.Game.Rulesets.Edit.Layers.Selection if (captured == null) return; - capturedHitObjects.Add(captured); + selectedHitObjects.Add(captured); } private void finishCapture(bool fromDrag) { - if (capturedHitObjects.Count == 0) + if (selectedHitObjects.Count == 0) return; // Due to https://github.com/ppy/osu-framework/issues/1382, we may get here through both @@ -104,9 +112,9 @@ namespace osu.Game.Rulesets.Edit.Layers.Selection captureBox?.Hide(); if (fromDrag) - AddInternal(captureBox = new DragCaptureBox(this, capturedHitObjects.ToList(), selectionBox.Position, selectionBox.Size)); + AddInternal(captureBox = new DragCaptureBox(this, selectedHitObjects.ToList(), selectionBox.Position, selectionBox.Size)); else - AddInternal(captureBox = new InstantCaptureBox(this, capturedHitObjects.ToList())); + AddInternal(captureBox = new InstantCaptureBox(this, selectedHitObjects.ToList())); } } }