diff --git a/osu.Game.Tests/Visual/TestCaseEditorSelectionLayer.cs b/osu.Game.Tests/Visual/TestCaseEditorSelectionLayer.cs index 9796d1715f..50a39e6c33 100644 --- a/osu.Game.Tests/Visual/TestCaseEditorSelectionLayer.cs +++ b/osu.Game.Tests/Visual/TestCaseEditorSelectionLayer.cs @@ -21,8 +21,7 @@ namespace osu.Game.Tests.Visual { public override IReadOnlyList RequiredTypes => new[] { - typeof(HitObjectCapturer), - typeof(SelectionDragger), + typeof(SelectionBox), typeof(SelectionLayer), typeof(CaptureBox) }; diff --git a/osu.Game/Rulesets/Edit/Layers/Selection/HitObjectCapturer.cs b/osu.Game/Rulesets/Edit/Layers/Selection/HitObjectCapturer.cs deleted file mode 100644 index e141f06816..0000000000 --- a/osu.Game/Rulesets/Edit/Layers/Selection/HitObjectCapturer.cs +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (c) 2007-2018 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using System; -using System.Collections.Generic; -using System.Linq; -using osu.Framework.Graphics.Primitives; -using osu.Game.Rulesets.Objects.Drawables; -using OpenTK; - -namespace osu.Game.Rulesets.Edit.Layers.Selection -{ - public class HitObjectCapturer - { - public event Action HitObjectCaptured; - - private readonly IEnumerable capturableHitObjects; - - public HitObjectCapturer(IEnumerable capturableHitObjects) - { - this.capturableHitObjects = capturableHitObjects; - } - - /// - /// Captures all hitobjects that are present within the area of a . - /// - /// The capture . - /// If any s were captured. - public bool CaptureQuad(Quad screenSpaceQuad) - { - bool anyCaptured = false; - foreach (var obj in capturableHitObjects.Where(h => h.IsAlive && h.IsPresent && screenSpaceQuad.Contains(h.SelectionPoint))) - { - HitObjectCaptured?.Invoke(obj); - anyCaptured = true; - } - - return anyCaptured; - } - - /// - /// Captures the top-most hitobject that is present under a specific point. - /// - /// The to capture at. - /// Whether a was captured. - public bool CapturePoint(Vector2 screenSpacePoint) - { - var captured = capturableHitObjects.Reverse().Where(h => h.IsAlive && h.IsPresent).FirstOrDefault(h => h.ReceiveMouseInputAt(screenSpacePoint)); - if (captured == null) - return false; - - HitObjectCaptured?.Invoke(captured); - return true; - } - } -} diff --git a/osu.Game/Rulesets/Edit/Layers/Selection/SelectionDragger.cs b/osu.Game/Rulesets/Edit/Layers/Selection/SelectionBox.cs similarity index 89% rename from osu.Game/Rulesets/Edit/Layers/Selection/SelectionDragger.cs rename to osu.Game/Rulesets/Edit/Layers/Selection/SelectionBox.cs index 661d09d883..87c6833f01 100644 --- a/osu.Game/Rulesets/Edit/Layers/Selection/SelectionDragger.cs +++ b/osu.Game/Rulesets/Edit/Layers/Selection/SelectionBox.cs @@ -12,12 +12,12 @@ namespace osu.Game.Rulesets.Edit.Layers.Selection /// /// A box that represents a drag selection. /// - public class SelectionDragger : CompositeDrawable + public class SelectionBox : CompositeDrawable { /// - /// Creates a new . + /// Creates a new . /// - public SelectionDragger() + public SelectionBox() { InternalChildren = new Drawable[] { diff --git a/osu.Game/Rulesets/Edit/Layers/Selection/SelectionLayer.cs b/osu.Game/Rulesets/Edit/Layers/Selection/SelectionLayer.cs index a90d01646e..e7a46569f1 100644 --- a/osu.Game/Rulesets/Edit/Layers/Selection/SelectionLayer.cs +++ b/osu.Game/Rulesets/Edit/Layers/Selection/SelectionLayer.cs @@ -3,13 +3,13 @@ using System.Collections.Generic; using System.Linq; -using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; using osu.Framework.Input; using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.UI; +using OpenTK; namespace osu.Game.Rulesets.Edit.Layers.Selection { @@ -24,19 +24,11 @@ namespace osu.Game.Rulesets.Edit.Layers.Selection RelativeSizeAxes = Axes.Both; } - private SelectionDragger selectionDragger; + private SelectionBox selectionBox; private CaptureBox captureBox; - private HitObjectCapturer capturer; private readonly List capturedHitObjects = new List(); - [BackgroundDependencyLoader] - private void load() - { - capturer = new HitObjectCapturer(playfield.HitObjects.Objects); - capturer.HitObjectCaptured += h => capturedHitObjects.Add(h); - } - protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) { capturedHitObjects.Clear(); @@ -46,7 +38,7 @@ namespace osu.Game.Rulesets.Edit.Layers.Selection protected override bool OnDragStart(InputState state) { - AddInternal(selectionDragger = new SelectionDragger()); + AddInternal(selectionBox = new SelectionBox()); return true; } @@ -57,15 +49,15 @@ namespace osu.Game.Rulesets.Edit.Layers.Selection var screenSpaceDragQuad = new Quad(dragStartPosition.X, dragStartPosition.Y, dragPosition.X - dragStartPosition.X, dragPosition.Y - dragStartPosition.Y); - selectionDragger.SetDragRectangle(screenSpaceDragQuad.AABBFloat); - capturer.CaptureQuad(screenSpaceDragQuad); + selectionBox.SetDragRectangle(screenSpaceDragQuad.AABBFloat); + captureQuad(screenSpaceDragQuad); return true; } protected override bool OnDragEnd(InputState state) { - selectionDragger.Hide(); + selectionBox.Hide(); finishCapture(); return true; @@ -73,12 +65,35 @@ namespace osu.Game.Rulesets.Edit.Layers.Selection protected override bool OnClick(InputState state) { - if (capturer.CapturePoint(state.Mouse.NativeState.Position)) - finishCapture(); + capturePoint(state.Mouse.NativeState.Position); + finishCapture(); return true; } + /// + /// Captures all hitobjects that are present within the area of a . + /// + /// The capture . + 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); + } + + /// + /// Captures the top-most hitobject that is present under a specific point. + /// + /// The to capture at. + private void capturePoint(Vector2 screenSpacePoint) + { + var captured = playfield.HitObjects.Objects.Reverse().Where(h => h.IsAlive && h.IsPresent).FirstOrDefault(h => h.ReceiveMouseInputAt(screenSpacePoint)); + if (captured == null) + return; + + capturedHitObjects.Add(captured); + } + private void finishCapture() { if (capturedHitObjects.Count == 0) diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 7e884fdc24..69b5c45890 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -333,7 +333,6 @@ - @@ -354,9 +353,9 @@ - +