1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 08:55:35 +08:00

Fix ordering of display/input of HitObjectMasks

This commit is contained in:
smoogipoo 2018-03-30 16:23:17 +09:00
parent 53541a5c8d
commit 69a7ddbf1e
2 changed files with 22 additions and 4 deletions

View File

@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Rulesets.Edit;
@ -49,5 +50,19 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Layers
private void onMaskSelected(HitObjectMask mask) => MaskSelected?.Invoke(mask);
private void onMaskDeselected(HitObjectMask mask) => MaskDeselected?.Invoke(mask);
protected override int Compare(Drawable x, Drawable y)
{
if (!(x is HitObjectMask xMask) || !(y is HitObjectMask yMask))
return base.Compare(x, y);
return Compare(xMask, yMask);
}
public 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);
return i == 0 ? CompareReverseChildID(x, y) : i;
}
}
}

View File

@ -8,6 +8,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Input;
using osu.Framework.Lists;
using osu.Game.Graphics;
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Edit.Types;
@ -24,7 +25,7 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Layers
private readonly MaskContainer maskContainer;
private readonly List<HitObjectMask> selectedMasks = new List<HitObjectMask>();
private readonly SortedList<HitObjectMask> selectedMasks;
private IEnumerable<HitObjectMask> selectableMasks => maskContainer.AliveMasks;
private Drawable outline;
@ -33,6 +34,8 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Layers
{
this.maskContainer = maskContainer;
selectedMasks = new SortedList<HitObjectMask>(maskContainer.Compare);
RelativeSizeAxes = Axes.Both;
AlwaysPresent = true;
Alpha = 0;
@ -61,7 +64,7 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Layers
#region User Input Handling
// Only handle input on selectable or selected masks
public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => selectableMasks.Concat(selectedMasks).Any(m => m.ReceiveMouseInputAt(screenSpacePos));
public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => selectableMasks.Reverse().Concat(selectedMasks).Any(m => m.ReceiveMouseInputAt(screenSpacePos));
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
{
@ -69,7 +72,7 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Layers
return true;
DeselectAll();
selectableMasks.First(m => m.ReceiveMouseInputAt(state.Mouse.NativeState.Position)).Select();
selectableMasks.Reverse().First(m => m.ReceiveMouseInputAt(state.Mouse.NativeState.Position)).Select();
UpdateVisibility();
return true;
@ -80,7 +83,7 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Layers
if (selectedMasks.Count == 1)
return true;
var toSelect = selectedMasks.First(m => m.ReceiveMouseInputAt(state.Mouse.NativeState.Position));
var toSelect = selectedMasks.Reverse().First(m => m.ReceiveMouseInputAt(state.Mouse.NativeState.Position));
DeselectAll();
toSelect.Select();