mirror of
https://github.com/ppy/osu
synced 2025-01-20 21:10:49 +00:00
Remove MaskContainer dependency in MaskSelection
This commit is contained in:
parent
5c036b966b
commit
2b15555ede
@ -1 +1 @@
|
||||
Subproject commit 6852878ce30e1bfde301282563d09c7927d9106c
|
||||
Subproject commit e72c85be22b9d853df075b965cdd433eb9deccf3
|
@ -251,8 +251,7 @@ namespace osu.Game.Rulesets.Edit
|
||||
/// Creates a <see cref="MaskSelection"/> which outlines <see cref="DrawableHitObject"/>s
|
||||
/// and handles hitobject pattern adjustments.
|
||||
/// </summary>
|
||||
/// <param name="maskContainer">The <see cref="HitObjectMask"/> container.</param>
|
||||
public virtual MaskSelection CreateSelectionBox(MaskContainer maskContainer) => new MaskSelection(maskContainer);
|
||||
public virtual MaskSelection CreateMaskSelection() => new MaskSelection();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a <see cref="ScalableContainer"/> which provides a layer above or below the <see cref="Playfield"/>.
|
||||
|
@ -18,7 +18,6 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Layers
|
||||
private readonly HitObjectComposer composer;
|
||||
|
||||
private MaskContainer maskContainer;
|
||||
private MaskSelection maskSelection;
|
||||
|
||||
public HitObjectMaskLayer(Playfield playfield, HitObjectComposer composer)
|
||||
{
|
||||
@ -33,7 +32,12 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Layers
|
||||
{
|
||||
maskContainer = new MaskContainer();
|
||||
|
||||
maskSelection = composer.CreateSelectionBox(maskContainer);
|
||||
var maskSelection = composer.CreateMaskSelection();
|
||||
|
||||
maskContainer.MaskSelected += maskSelection.HandleSelected;
|
||||
maskContainer.MaskDeselected += maskSelection.HandleDeselected;
|
||||
maskContainer.MaskSelectionRequested += maskSelection.HandleSelectionRequested;
|
||||
maskSelection.DeselectAll = maskContainer.DeselectAll;
|
||||
|
||||
var dragLayer = new DragLayer(maskContainer.Select);
|
||||
dragLayer.DragEnd += () => maskSelection.UpdateVisibility();
|
||||
|
@ -87,7 +87,7 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Layers
|
||||
return Compare(xMask, yMask);
|
||||
}
|
||||
|
||||
public int Compare(HitObjectMask x, HitObjectMask y)
|
||||
public static int Compare(HitObjectMask x, HitObjectMask y)
|
||||
{
|
||||
// Put earlier hitobjects towards the end of the list, so they handle input first
|
||||
int i = y.HitObject.HitObject.StartTime.CompareTo(x.HitObject.HitObject.StartTime);
|
||||
|
@ -1,6 +1,7 @@
|
||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
@ -22,26 +23,17 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Layers
|
||||
{
|
||||
public const float BORDER_RADIUS = 2;
|
||||
|
||||
private readonly MaskContainer maskContainer;
|
||||
|
||||
private readonly SortedList<HitObjectMask> selectedMasks;
|
||||
|
||||
private Drawable outline;
|
||||
|
||||
public MaskSelection(MaskContainer maskContainer)
|
||||
public MaskSelection()
|
||||
{
|
||||
// todo: remove this
|
||||
this.maskContainer = maskContainer;
|
||||
|
||||
selectedMasks = new SortedList<HitObjectMask>(maskContainer.Compare);
|
||||
selectedMasks = new SortedList<HitObjectMask>(MaskContainer.Compare);
|
||||
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
AlwaysPresent = true;
|
||||
Alpha = 0;
|
||||
|
||||
maskContainer.MaskSelected += onSelected;
|
||||
maskContainer.MaskDeselected += onDeselected;
|
||||
maskContainer.MaskSelectionRequested += onSelectionRequested;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
@ -99,9 +91,22 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Layers
|
||||
|
||||
#region Selection Handling
|
||||
|
||||
private void onSelected(HitObjectMask mask) => selectedMasks.Add(mask);
|
||||
/// <summary>
|
||||
/// Bind an action to deselect all selected masks.
|
||||
/// </summary>
|
||||
public Action DeselectAll { private get; set; }
|
||||
|
||||
private void onDeselected(HitObjectMask mask)
|
||||
/// <summary>
|
||||
/// Handle a mask becoming selected.
|
||||
/// </summary>
|
||||
/// <param name="mask">The mask.</param>
|
||||
public void HandleSelected(HitObjectMask mask) => selectedMasks.Add(mask);
|
||||
|
||||
/// <summary>
|
||||
/// Handle a mask becoming deselected.
|
||||
/// </summary>
|
||||
/// <param name="mask">The mask.</param>
|
||||
public void HandleDeselected(HitObjectMask mask)
|
||||
{
|
||||
selectedMasks.Remove(mask);
|
||||
|
||||
@ -110,7 +115,11 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Layers
|
||||
UpdateVisibility();
|
||||
}
|
||||
|
||||
private void onSelectionRequested(HitObjectMask mask)
|
||||
/// <summary>
|
||||
/// Handle a mask requesting selection.
|
||||
/// </summary>
|
||||
/// <param name="mask">The mask.</param>
|
||||
public void HandleSelectionRequested(HitObjectMask mask)
|
||||
{
|
||||
if (GetContainingInputManager().CurrentState.Keyboard.ControlPressed)
|
||||
{
|
||||
@ -125,7 +134,8 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Layers
|
||||
if (mask.State == Visibility.Visible)
|
||||
return;
|
||||
|
||||
maskContainer.DeselectAll();
|
||||
|
||||
DeselectAll?.Invoke();
|
||||
mask.Select();
|
||||
}
|
||||
|
||||
@ -170,14 +180,5 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Layers
|
||||
outline.Size = bottomRight - topLeft;
|
||||
outline.Position = topLeft;
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
base.Dispose(isDisposing);
|
||||
|
||||
maskContainer.MaskSelected -= onSelected;
|
||||
maskContainer.MaskDeselected -= onDeselected;
|
||||
maskContainer.MaskSelectionRequested -= onSelectionRequested;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user