mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 16:12:57 +08:00
Expose selected objects from SelectionLayer
This commit is contained in:
parent
eeb3440ffa
commit
66b19b6c97
@ -12,6 +12,7 @@ using osu.Game.Graphics;
|
||||
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
|
||||
/// </summary>
|
||||
public class DragSelector : CompositeDrawable
|
||||
{
|
||||
public readonly Bindable<SelectionInfo> Selection = new Bindable<SelectionInfo>();
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="DrawableHitObject"/>s that can be selected through a drag-selection.
|
||||
/// </summary>
|
||||
@ -103,7 +106,6 @@ namespace osu.Game.Rulesets.Edit.Layers.Selection
|
||||
}
|
||||
|
||||
private readonly List<DrawableHitObject> capturedHitObjects = new List<DrawableHitObject>();
|
||||
public IReadOnlyList<DrawableHitObject> CapturedHitObjects => capturedHitObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Processes hitobjects to determine which ones are captured by the drag selection.
|
||||
@ -128,7 +130,7 @@ namespace osu.Game.Rulesets.Edit.Layers.Selection
|
||||
/// </summary>
|
||||
public void FinishCapture()
|
||||
{
|
||||
if (CapturedHitObjects.Count == 0)
|
||||
if (capturedHitObjects.Count == 0)
|
||||
{
|
||||
Hide();
|
||||
return;
|
||||
@ -158,6 +160,12 @@ namespace osu.Game.Rulesets.Edit.Layers.Selection
|
||||
// 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 @@ namespace osu.Game.Rulesets.Edit.Layers.Selection
|
||||
{
|
||||
isActive = false;
|
||||
this.FadeOut(400, Easing.OutQuint).Expire();
|
||||
|
||||
Selection.Value = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
19
osu.Game/Rulesets/Edit/Layers/Selection/SelectionInfo.cs
Normal file
19
osu.Game/Rulesets/Edit/Layers/Selection/SelectionInfo.cs
Normal file
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// The objects that are captured by the selection.
|
||||
/// </summary>
|
||||
public IEnumerable<DrawableHitObject> Objects;
|
||||
|
||||
/// <summary>
|
||||
/// The screen space quad of the selection box surrounding <see cref="Objects"/>.
|
||||
/// </summary>
|
||||
public Quad SelectionQuad;
|
||||
}
|
||||
}
|
@ -1,15 +1,21 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// 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<SelectionInfo> Selection = new Bindable<SelectionInfo>();
|
||||
|
||||
private readonly Playfield playfield;
|
||||
|
||||
public SelectionLayer(Playfield playfield)
|
||||
@ -25,11 +31,14 @@ namespace osu.Game.Rulesets.Edit.Layers.Selection
|
||||
{
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
@ -314,6 +314,7 @@
|
||||
<Compile Include="Rulesets\Edit\Layers\Selection\DragSelector.cs" />
|
||||
<Compile Include="Rulesets\Edit\Layers\Selection\Marker.cs" />
|
||||
<Compile Include="Rulesets\Edit\Layers\Selection\MarkerContainer.cs" />
|
||||
<Compile Include="Rulesets\Edit\Layers\Selection\SelectionInfo.cs" />
|
||||
<Compile Include="Rulesets\Edit\Layers\Selection\SelectionLayer.cs" />
|
||||
<Compile Include="Screens\Edit\Components\BottomBarContainer.cs" />
|
||||
<Compile Include="Screens\Edit\Components\PlaybackControl.cs" />
|
||||
|
Loading…
Reference in New Issue
Block a user