diff --git a/osu.Game/Rulesets/Edit/Layers/Selection/DragSelector.cs b/osu.Game/Rulesets/Edit/Layers/Selection/DragSelector.cs index b83ed2e270..2201a661b7 100644 --- a/osu.Game/Rulesets/Edit/Layers/Selection/DragSelector.cs +++ b/osu.Game/Rulesets/Edit/Layers/Selection/DragSelector.cs @@ -12,6 +12,7 @@ using osu.Game.Rulesets.Objects.Drawables; using OpenTK; using OpenTK.Graphics; +using osu.Framework.Configuration; namespace osu.Game.Rulesets.Edit.Layers.Selection { @@ -20,6 +21,8 @@ namespace osu.Game.Rulesets.Edit.Layers.Selection /// public class DragSelector : CompositeDrawable { + public readonly Bindable Selection = new Bindable(); + /// /// The s that can be selected through a drag-selection. /// @@ -103,7 +106,6 @@ private void updateDragRectangle(RectangleF rectangle) } private readonly List capturedHitObjects = new List(); - public IReadOnlyList CapturedHitObjects => capturedHitObjects; /// /// Processes hitobjects to determine which ones are captured by the drag selection. @@ -128,7 +130,7 @@ public void BeginCapture() /// public void FinishCapture() { - if (CapturedHitObjects.Count == 0) + if (capturedHitObjects.Count == 0) { Hide(); return; @@ -158,6 +160,12 @@ public void FinishCapture() // Transform into markers to let the user modify the drag selection further. background.Delay(50).FadeOut(200); markers.FadeIn(200); + + Selection.Value = new SelectionInfo + { + Objects = capturedHitObjects, + SelectionQuad = Parent.ToScreenSpace(dragRectangle) + }; } private bool isActive = true; @@ -167,6 +175,8 @@ public override void Hide() { isActive = false; this.FadeOut(400, Easing.OutQuint).Expire(); + + Selection.Value = null; } } } diff --git a/osu.Game/Rulesets/Edit/Layers/Selection/SelectionInfo.cs b/osu.Game/Rulesets/Edit/Layers/Selection/SelectionInfo.cs new file mode 100644 index 0000000000..402bec1706 --- /dev/null +++ b/osu.Game/Rulesets/Edit/Layers/Selection/SelectionInfo.cs @@ -0,0 +1,19 @@ +using System.Collections.Generic; +using osu.Framework.Graphics.Primitives; +using osu.Game.Rulesets.Objects.Drawables; + +namespace osu.Game.Rulesets.Edit.Layers.Selection +{ + public class SelectionInfo + { + /// + /// The objects that are captured by the selection. + /// + public IEnumerable Objects; + + /// + /// The screen space quad of the selection box surrounding . + /// + public Quad SelectionQuad; + } +} diff --git a/osu.Game/Rulesets/Edit/Layers/Selection/SelectionLayer.cs b/osu.Game/Rulesets/Edit/Layers/Selection/SelectionLayer.cs index a38be68461..af8eac847e 100644 --- a/osu.Game/Rulesets/Edit/Layers/Selection/SelectionLayer.cs +++ b/osu.Game/Rulesets/Edit/Layers/Selection/SelectionLayer.cs @@ -1,15 +1,21 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; +using System.Collections.Generic; +using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Input; +using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.UI; namespace osu.Game.Rulesets.Edit.Layers.Selection { public class SelectionLayer : CompositeDrawable { + public readonly Bindable Selection = new Bindable(); + private readonly Playfield playfield; public SelectionLayer(Playfield playfield) @@ -25,11 +31,14 @@ protected override bool OnDragStart(InputState state) { // Hide the previous drag box - we won't be working with it any longer selector?.Hide(); + AddInternal(selector = new DragSelector(ToLocalSpace(state.Mouse.NativeState.Position)) { - CapturableObjects = playfield.HitObjects.Objects + CapturableObjects = playfield.HitObjects.Objects, }); + Selection.BindTo(selector.Selection); + return true; } diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 207dae1b54..63cf0ae0f5 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -314,6 +314,7 @@ +