mirror of
https://github.com/osukey/osukey.git
synced 2025-08-06 16:13:57 +09:00
Merge branch 'master' into blueprint-container-sorting
This commit is contained in:
@ -52,7 +52,7 @@ namespace osu.Game.Rulesets.Catch.Difficulty
|
|||||||
|
|
||||||
// In 2B beatmaps, it is possible that a normal Fruit is placed in the middle of a JuiceStream.
|
// In 2B beatmaps, it is possible that a normal Fruit is placed in the middle of a JuiceStream.
|
||||||
foreach (var hitObject in beatmap.HitObjects
|
foreach (var hitObject in beatmap.HitObjects
|
||||||
.SelectMany(obj => obj is JuiceStream stream ? stream.NestedHitObjects : new[] { obj })
|
.SelectMany(obj => obj is JuiceStream stream ? stream.NestedHitObjects.AsEnumerable() : new[] { obj })
|
||||||
.Cast<CatchHitObject>()
|
.Cast<CatchHitObject>()
|
||||||
.OrderBy(x => x.StartTime))
|
.OrderBy(x => x.StartTime))
|
||||||
{
|
{
|
||||||
|
@ -149,7 +149,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
|
|||||||
{
|
{
|
||||||
lowerBound ??= RandomStart;
|
lowerBound ??= RandomStart;
|
||||||
upperBound ??= TotalColumns;
|
upperBound ??= TotalColumns;
|
||||||
nextColumn ??= (_ => GetRandomColumn(lowerBound, upperBound));
|
nextColumn ??= _ => GetRandomColumn(lowerBound, upperBound);
|
||||||
|
|
||||||
// Check for the initial column
|
// Check for the initial column
|
||||||
if (isValid(initialColumn))
|
if (isValid(initialColumn))
|
||||||
@ -176,7 +176,19 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
|
|||||||
|
|
||||||
return initialColumn;
|
return initialColumn;
|
||||||
|
|
||||||
bool isValid(int column) => validation?.Invoke(column) != false && !patterns.Any(p => p.ColumnHasObject(column));
|
bool isValid(int column)
|
||||||
|
{
|
||||||
|
if (validation?.Invoke(column) == false)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
foreach (var p in patterns)
|
||||||
|
{
|
||||||
|
if (p.ColumnHasObject(column))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -12,46 +12,68 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
internal class Pattern
|
internal class Pattern
|
||||||
{
|
{
|
||||||
private readonly List<ManiaHitObject> hitObjects = new List<ManiaHitObject>();
|
private List<ManiaHitObject> hitObjects;
|
||||||
|
private HashSet<int> containedColumns;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// All the hit objects contained in this pattern.
|
/// All the hit objects contained in this pattern.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IEnumerable<ManiaHitObject> HitObjects => hitObjects;
|
public IEnumerable<ManiaHitObject> HitObjects => hitObjects ?? Enumerable.Empty<ManiaHitObject>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Check whether a column of this patterns contains a hit object.
|
/// Check whether a column of this patterns contains a hit object.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="column">The column index.</param>
|
/// <param name="column">The column index.</param>
|
||||||
/// <returns>Whether the column with index <paramref name="column"/> contains a hit object.</returns>
|
/// <returns>Whether the column with index <paramref name="column"/> contains a hit object.</returns>
|
||||||
public bool ColumnHasObject(int column) => hitObjects.Exists(h => h.Column == column);
|
public bool ColumnHasObject(int column) => containedColumns?.Contains(column) == true;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Amount of columns taken up by hit objects in this pattern.
|
/// Amount of columns taken up by hit objects in this pattern.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int ColumnWithObjects => HitObjects.GroupBy(h => h.Column).Count();
|
public int ColumnWithObjects => containedColumns?.Count ?? 0;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Adds a hit object to this pattern.
|
/// Adds a hit object to this pattern.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="hitObject">The hit object to add.</param>
|
/// <param name="hitObject">The hit object to add.</param>
|
||||||
public void Add(ManiaHitObject hitObject) => hitObjects.Add(hitObject);
|
public void Add(ManiaHitObject hitObject)
|
||||||
|
{
|
||||||
|
prepareStorage();
|
||||||
|
|
||||||
|
hitObjects.Add(hitObject);
|
||||||
|
containedColumns.Add(hitObject.Column);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Copies hit object from another pattern to this one.
|
/// Copies hit object from another pattern to this one.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="other">The other pattern.</param>
|
/// <param name="other">The other pattern.</param>
|
||||||
public void Add(Pattern other) => hitObjects.AddRange(other.HitObjects);
|
public void Add(Pattern other)
|
||||||
|
{
|
||||||
|
prepareStorage();
|
||||||
|
|
||||||
|
if (other.hitObjects != null)
|
||||||
|
{
|
||||||
|
hitObjects.AddRange(other.hitObjects);
|
||||||
|
|
||||||
|
foreach (var h in other.hitObjects)
|
||||||
|
containedColumns.Add(h.Column);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Clears this pattern, removing all hit objects.
|
/// Clears this pattern, removing all hit objects.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Clear() => hitObjects.Clear();
|
public void Clear()
|
||||||
|
{
|
||||||
|
hitObjects?.Clear();
|
||||||
|
containedColumns?.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
private void prepareStorage()
|
||||||
/// Removes a hit object from this pattern.
|
{
|
||||||
/// </summary>
|
hitObjects ??= new List<ManiaHitObject>();
|
||||||
/// <param name="hitObject">The hit object to remove.</param>
|
containedColumns ??= new HashSet<int>();
|
||||||
public bool Remove(ManiaHitObject hitObject) => hitObjects.Remove(hitObject);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,14 +20,14 @@ using osuTK.Input;
|
|||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Editing
|
namespace osu.Game.Tests.Visual.Editing
|
||||||
{
|
{
|
||||||
public class TestSceneEditorSelection : EditorTestScene
|
public class TestSceneComposerSelection : EditorTestScene
|
||||||
{
|
{
|
||||||
protected override Ruleset CreateEditorRuleset() => new OsuRuleset();
|
protected override Ruleset CreateEditorRuleset() => new OsuRuleset();
|
||||||
|
|
||||||
protected override IBeatmap CreateBeatmap(RulesetInfo ruleset) => new TestBeatmap(ruleset, false);
|
protected override IBeatmap CreateBeatmap(RulesetInfo ruleset) => new TestBeatmap(ruleset, false);
|
||||||
|
|
||||||
private EditorBlueprintContainer blueprintContainer
|
private ComposeBlueprintContainer blueprintContainer
|
||||||
=> Editor.ChildrenOfType<EditorBlueprintContainer>().First();
|
=> Editor.ChildrenOfType<ComposeBlueprintContainer>().First();
|
||||||
|
|
||||||
private void moveMouseToObject(Func<HitObject> targetFunc)
|
private void moveMouseToObject(Func<HitObject> targetFunc)
|
||||||
{
|
{
|
231
osu.Game.Tests/Visual/Editing/TestSceneTimelineSelection.cs
Normal file
231
osu.Game.Tests/Visual/Editing/TestSceneTimelineSelection.cs
Normal file
@ -0,0 +1,231 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using osu.Framework.Testing;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Rulesets;
|
||||||
|
using osu.Game.Rulesets.Objects;
|
||||||
|
using osu.Game.Rulesets.Osu;
|
||||||
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
|
using osu.Game.Screens.Edit.Compose.Components.Timeline;
|
||||||
|
using osu.Game.Tests.Beatmaps;
|
||||||
|
using osuTK;
|
||||||
|
using osuTK.Input;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Visual.Editing
|
||||||
|
{
|
||||||
|
public class TestSceneTimelineSelection : EditorTestScene
|
||||||
|
{
|
||||||
|
protected override Ruleset CreateEditorRuleset() => new OsuRuleset();
|
||||||
|
|
||||||
|
protected override IBeatmap CreateBeatmap(RulesetInfo ruleset) => new TestBeatmap(ruleset, false);
|
||||||
|
|
||||||
|
private TimelineBlueprintContainer blueprintContainer
|
||||||
|
=> Editor.ChildrenOfType<TimelineBlueprintContainer>().First();
|
||||||
|
|
||||||
|
private void moveMouseToObject(Func<HitObject> targetFunc)
|
||||||
|
{
|
||||||
|
AddStep("move mouse to object", () =>
|
||||||
|
{
|
||||||
|
var pos = blueprintContainer.SelectionBlueprints
|
||||||
|
.First(s => s.Item == targetFunc())
|
||||||
|
.ChildrenOfType<TimelineHitObjectBlueprint>()
|
||||||
|
.First().ScreenSpaceDrawQuad.Centre;
|
||||||
|
|
||||||
|
InputManager.MoveMouseTo(pos);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestNudgeSelection()
|
||||||
|
{
|
||||||
|
HitCircle[] addedObjects = null;
|
||||||
|
|
||||||
|
AddStep("add hitobjects", () => EditorBeatmap.AddRange(addedObjects = new[]
|
||||||
|
{
|
||||||
|
new HitCircle { StartTime = 100 },
|
||||||
|
new HitCircle { StartTime = 200, Position = new Vector2(100) },
|
||||||
|
new HitCircle { StartTime = 300, Position = new Vector2(200) },
|
||||||
|
new HitCircle { StartTime = 400, Position = new Vector2(300) },
|
||||||
|
}));
|
||||||
|
|
||||||
|
AddStep("select objects", () => EditorBeatmap.SelectedHitObjects.AddRange(addedObjects));
|
||||||
|
|
||||||
|
AddStep("nudge forwards", () => InputManager.Key(Key.K));
|
||||||
|
AddAssert("objects moved forwards in time", () => addedObjects[0].StartTime > 100);
|
||||||
|
|
||||||
|
AddStep("nudge backwards", () => InputManager.Key(Key.J));
|
||||||
|
AddAssert("objects reverted to original position", () => addedObjects[0].StartTime == 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestBasicSelect()
|
||||||
|
{
|
||||||
|
var addedObject = new HitCircle { StartTime = 100 };
|
||||||
|
AddStep("add hitobject", () => EditorBeatmap.Add(addedObject));
|
||||||
|
|
||||||
|
moveMouseToObject(() => addedObject);
|
||||||
|
AddStep("left click", () => InputManager.Click(MouseButton.Left));
|
||||||
|
|
||||||
|
AddAssert("hitobject selected", () => EditorBeatmap.SelectedHitObjects.Single() == addedObject);
|
||||||
|
|
||||||
|
var addedObject2 = new HitCircle
|
||||||
|
{
|
||||||
|
StartTime = 200,
|
||||||
|
Position = new Vector2(100),
|
||||||
|
};
|
||||||
|
|
||||||
|
AddStep("add one more hitobject", () => EditorBeatmap.Add(addedObject2));
|
||||||
|
AddAssert("selection unchanged", () => EditorBeatmap.SelectedHitObjects.Single() == addedObject);
|
||||||
|
|
||||||
|
moveMouseToObject(() => addedObject2);
|
||||||
|
AddStep("left click", () => InputManager.Click(MouseButton.Left));
|
||||||
|
AddAssert("hitobject selected", () => EditorBeatmap.SelectedHitObjects.Single() == addedObject2);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestMultiSelect()
|
||||||
|
{
|
||||||
|
var addedObjects = new[]
|
||||||
|
{
|
||||||
|
new HitCircle { StartTime = 100 },
|
||||||
|
new HitCircle { StartTime = 200, Position = new Vector2(100) },
|
||||||
|
new HitCircle { StartTime = 300, Position = new Vector2(200) },
|
||||||
|
new HitCircle { StartTime = 400, Position = new Vector2(300) },
|
||||||
|
};
|
||||||
|
|
||||||
|
AddStep("add hitobjects", () => EditorBeatmap.AddRange(addedObjects));
|
||||||
|
|
||||||
|
moveMouseToObject(() => addedObjects[0]);
|
||||||
|
AddStep("click first", () => InputManager.Click(MouseButton.Left));
|
||||||
|
|
||||||
|
AddAssert("hitobject selected", () => EditorBeatmap.SelectedHitObjects.Single() == addedObjects[0]);
|
||||||
|
|
||||||
|
AddStep("hold control", () => InputManager.PressKey(Key.ControlLeft));
|
||||||
|
|
||||||
|
moveMouseToObject(() => addedObjects[1]);
|
||||||
|
AddStep("click second", () => InputManager.Click(MouseButton.Left));
|
||||||
|
AddAssert("2 hitobjects selected", () => EditorBeatmap.SelectedHitObjects.Count == 2 && EditorBeatmap.SelectedHitObjects.Contains(addedObjects[1]));
|
||||||
|
|
||||||
|
moveMouseToObject(() => addedObjects[2]);
|
||||||
|
AddStep("click third", () => InputManager.Click(MouseButton.Left));
|
||||||
|
AddAssert("3 hitobjects selected", () => EditorBeatmap.SelectedHitObjects.Count == 3 && EditorBeatmap.SelectedHitObjects.Contains(addedObjects[2]));
|
||||||
|
|
||||||
|
moveMouseToObject(() => addedObjects[1]);
|
||||||
|
AddStep("click second", () => InputManager.Click(MouseButton.Left));
|
||||||
|
AddAssert("2 hitobjects selected", () => EditorBeatmap.SelectedHitObjects.Count == 2 && !EditorBeatmap.SelectedHitObjects.Contains(addedObjects[1]));
|
||||||
|
|
||||||
|
AddStep("release control", () => InputManager.ReleaseKey(Key.ControlLeft));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestBasicDeselect()
|
||||||
|
{
|
||||||
|
var addedObject = new HitCircle { StartTime = 100 };
|
||||||
|
AddStep("add hitobject", () => EditorBeatmap.Add(addedObject));
|
||||||
|
|
||||||
|
moveMouseToObject(() => addedObject);
|
||||||
|
AddStep("left click", () => InputManager.Click(MouseButton.Left));
|
||||||
|
|
||||||
|
AddAssert("hitobject selected", () => EditorBeatmap.SelectedHitObjects.Single() == addedObject);
|
||||||
|
|
||||||
|
AddStep("click away", () =>
|
||||||
|
{
|
||||||
|
InputManager.MoveMouseTo(Editor.ChildrenOfType<TimelineArea>().Single().ScreenSpaceDrawQuad.TopLeft + Vector2.One);
|
||||||
|
InputManager.Click(MouseButton.Left);
|
||||||
|
});
|
||||||
|
|
||||||
|
AddAssert("selection lost", () => EditorBeatmap.SelectedHitObjects.Count == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestQuickDelete()
|
||||||
|
{
|
||||||
|
var addedObject = new HitCircle
|
||||||
|
{
|
||||||
|
StartTime = 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
AddStep("add hitobject", () => EditorBeatmap.Add(addedObject));
|
||||||
|
|
||||||
|
moveMouseToObject(() => addedObject);
|
||||||
|
|
||||||
|
AddStep("hold shift", () => InputManager.PressKey(Key.ShiftLeft));
|
||||||
|
AddStep("right click", () => InputManager.Click(MouseButton.Right));
|
||||||
|
AddStep("release shift", () => InputManager.ReleaseKey(Key.ShiftLeft));
|
||||||
|
|
||||||
|
AddAssert("no hitobjects in beatmap", () => EditorBeatmap.HitObjects.Count == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestRangeSelect()
|
||||||
|
{
|
||||||
|
var addedObjects = new[]
|
||||||
|
{
|
||||||
|
new HitCircle { StartTime = 100 },
|
||||||
|
new HitCircle { StartTime = 200, Position = new Vector2(100) },
|
||||||
|
new HitCircle { StartTime = 300, Position = new Vector2(200) },
|
||||||
|
new HitCircle { StartTime = 400, Position = new Vector2(300) },
|
||||||
|
new HitCircle { StartTime = 500, Position = new Vector2(400) },
|
||||||
|
};
|
||||||
|
|
||||||
|
AddStep("add hitobjects", () => EditorBeatmap.AddRange(addedObjects));
|
||||||
|
|
||||||
|
moveMouseToObject(() => addedObjects[1]);
|
||||||
|
AddStep("click second", () => InputManager.Click(MouseButton.Left));
|
||||||
|
|
||||||
|
AddAssert("hitobject selected", () => EditorBeatmap.SelectedHitObjects.Single() == addedObjects[1]);
|
||||||
|
|
||||||
|
AddStep("hold shift", () => InputManager.PressKey(Key.ShiftLeft));
|
||||||
|
|
||||||
|
moveMouseToObject(() => addedObjects[3]);
|
||||||
|
AddStep("click fourth", () => InputManager.Click(MouseButton.Left));
|
||||||
|
assertSelectionIs(addedObjects.Skip(1).Take(3));
|
||||||
|
|
||||||
|
moveMouseToObject(() => addedObjects[0]);
|
||||||
|
AddStep("click first", () => InputManager.Click(MouseButton.Left));
|
||||||
|
assertSelectionIs(addedObjects.Take(2));
|
||||||
|
|
||||||
|
AddStep("clear selection", () => EditorBeatmap.SelectedHitObjects.Clear());
|
||||||
|
AddStep("release shift", () => InputManager.ReleaseKey(Key.ShiftLeft));
|
||||||
|
|
||||||
|
moveMouseToObject(() => addedObjects[0]);
|
||||||
|
AddStep("click first", () => InputManager.Click(MouseButton.Left));
|
||||||
|
assertSelectionIs(addedObjects.Take(1));
|
||||||
|
|
||||||
|
AddStep("hold ctrl", () => InputManager.PressKey(Key.ControlLeft));
|
||||||
|
moveMouseToObject(() => addedObjects[2]);
|
||||||
|
AddStep("click third", () => InputManager.Click(MouseButton.Left));
|
||||||
|
assertSelectionIs(new[] { addedObjects[0], addedObjects[2] });
|
||||||
|
|
||||||
|
AddStep("hold shift", () => InputManager.PressKey(Key.ShiftLeft));
|
||||||
|
moveMouseToObject(() => addedObjects[4]);
|
||||||
|
AddStep("click fifth", () => InputManager.Click(MouseButton.Left));
|
||||||
|
assertSelectionIs(addedObjects.Except(new[] { addedObjects[1] }));
|
||||||
|
|
||||||
|
moveMouseToObject(() => addedObjects[0]);
|
||||||
|
AddStep("click first", () => InputManager.Click(MouseButton.Left));
|
||||||
|
assertSelectionIs(addedObjects);
|
||||||
|
|
||||||
|
AddStep("clear selection", () => EditorBeatmap.SelectedHitObjects.Clear());
|
||||||
|
moveMouseToObject(() => addedObjects[0]);
|
||||||
|
AddStep("click first", () => InputManager.Click(MouseButton.Left));
|
||||||
|
assertSelectionIs(addedObjects.Take(1));
|
||||||
|
|
||||||
|
moveMouseToObject(() => addedObjects[1]);
|
||||||
|
AddStep("click first", () => InputManager.Click(MouseButton.Left));
|
||||||
|
assertSelectionIs(addedObjects.Take(2));
|
||||||
|
|
||||||
|
moveMouseToObject(() => addedObjects[2]);
|
||||||
|
AddStep("click first", () => InputManager.Click(MouseButton.Left));
|
||||||
|
assertSelectionIs(addedObjects.Take(3));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void assertSelectionIs(IEnumerable<HitObject> hitObjects)
|
||||||
|
=> AddAssert("correct hitobjects selected", () => EditorBeatmap.SelectedHitObjects.OrderBy(h => h.StartTime).SequenceEqual(hitObjects));
|
||||||
|
}
|
||||||
|
}
|
@ -3,11 +3,12 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Framework.Extensions.ListExtensions;
|
||||||
|
using osu.Framework.Lists;
|
||||||
using osu.Game.Audio;
|
using osu.Game.Audio;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Beatmaps.ControlPoints;
|
using osu.Game.Beatmaps.ControlPoints;
|
||||||
@ -83,7 +84,7 @@ namespace osu.Game.Rulesets.Objects
|
|||||||
private readonly List<HitObject> nestedHitObjects = new List<HitObject>();
|
private readonly List<HitObject> nestedHitObjects = new List<HitObject>();
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public IReadOnlyList<HitObject> NestedHitObjects => nestedHitObjects;
|
public SlimReadOnlyListWrapper<HitObject> NestedHitObjects => nestedHitObjects.AsSlimReadOnly();
|
||||||
|
|
||||||
public HitObject()
|
public HitObject()
|
||||||
{
|
{
|
||||||
@ -91,7 +92,7 @@ namespace osu.Game.Rulesets.Objects
|
|||||||
{
|
{
|
||||||
double offset = time.NewValue - time.OldValue;
|
double offset = time.NewValue - time.OldValue;
|
||||||
|
|
||||||
foreach (var nested in NestedHitObjects)
|
foreach (var nested in nestedHitObjects)
|
||||||
nested.StartTime += offset;
|
nested.StartTime += offset;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -122,11 +123,14 @@ namespace osu.Game.Rulesets.Objects
|
|||||||
|
|
||||||
if (this is IHasComboInformation hasCombo)
|
if (this is IHasComboInformation hasCombo)
|
||||||
{
|
{
|
||||||
foreach (var n in NestedHitObjects.OfType<IHasComboInformation>())
|
foreach (HitObject hitObject in nestedHitObjects)
|
||||||
{
|
{
|
||||||
n.ComboIndexBindable.BindTo(hasCombo.ComboIndexBindable);
|
if (hitObject is IHasComboInformation n)
|
||||||
n.ComboIndexWithOffsetsBindable.BindTo(hasCombo.ComboIndexWithOffsetsBindable);
|
{
|
||||||
n.IndexInCurrentComboBindable.BindTo(hasCombo.IndexInCurrentComboBindable);
|
n.ComboIndexBindable.BindTo(hasCombo.ComboIndexBindable);
|
||||||
|
n.ComboIndexWithOffsetsBindable.BindTo(hasCombo.ComboIndexWithOffsetsBindable);
|
||||||
|
n.IndexInCurrentComboBindable.BindTo(hasCombo.IndexInCurrentComboBindable);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,7 +191,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
/// <param name="blueprint">The blueprint.</param>
|
/// <param name="blueprint">The blueprint.</param>
|
||||||
/// <param name="e">The mouse event responsible for selection.</param>
|
/// <param name="e">The mouse event responsible for selection.</param>
|
||||||
/// <returns>Whether a selection was performed.</returns>
|
/// <returns>Whether a selection was performed.</returns>
|
||||||
internal bool MouseDownSelectionRequested(SelectionBlueprint<T> blueprint, MouseButtonEvent e)
|
internal virtual bool MouseDownSelectionRequested(SelectionBlueprint<T> blueprint, MouseButtonEvent e)
|
||||||
{
|
{
|
||||||
if (e.ShiftPressed && e.Button == MouseButton.Right)
|
if (e.ShiftPressed && e.Button == MouseButton.Right)
|
||||||
{
|
{
|
||||||
|
@ -1,13 +1,19 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using JetBrains.Annotations;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Input.Bindings;
|
using osu.Framework.Input.Bindings;
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
using osu.Game.Input.Bindings;
|
using osu.Game.Input.Bindings;
|
||||||
|
using osu.Game.Rulesets.Edit;
|
||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
using osuTK.Input;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||||
{
|
{
|
||||||
@ -62,5 +68,62 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|||||||
EditorBeatmap.Update(h);
|
EditorBeatmap.Update(h);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The "pivot" object, used in range selection mode.
|
||||||
|
/// When in range selection, the range to select is determined by the pivot object
|
||||||
|
/// (last existing object interacted with prior to holding down Shift)
|
||||||
|
/// and by the object clicked last when Shift was pressed.
|
||||||
|
/// </summary>
|
||||||
|
[CanBeNull]
|
||||||
|
private HitObject pivot;
|
||||||
|
|
||||||
|
internal override bool MouseDownSelectionRequested(SelectionBlueprint<HitObject> blueprint, MouseButtonEvent e)
|
||||||
|
{
|
||||||
|
if (e.ShiftPressed && e.Button == MouseButton.Left && SelectedItems.Any())
|
||||||
|
{
|
||||||
|
handleRangeSelection(blueprint, e.ControlPressed);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool result = base.MouseDownSelectionRequested(blueprint, e);
|
||||||
|
// ensure that the object wasn't removed by the base implementation before making it the new pivot.
|
||||||
|
if (EditorBeatmap.HitObjects.Contains(blueprint.Item))
|
||||||
|
pivot = blueprint.Item;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Handles a request for range selection (triggered when Shift is held down).
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="blueprint">The blueprint which was clicked in range selection mode.</param>
|
||||||
|
/// <param name="cumulative">
|
||||||
|
/// Whether the selection should be cumulative.
|
||||||
|
/// In cumulative mode, consecutive range selections will shift the pivot (which usually stays fixed for the duration of a range selection)
|
||||||
|
/// and will never deselect an object that was previously selected.
|
||||||
|
/// </param>
|
||||||
|
private void handleRangeSelection(SelectionBlueprint<HitObject> blueprint, bool cumulative)
|
||||||
|
{
|
||||||
|
var clickedObject = blueprint.Item;
|
||||||
|
|
||||||
|
Debug.Assert(pivot != null);
|
||||||
|
|
||||||
|
double rangeStart = Math.Min(clickedObject.StartTime, pivot.StartTime);
|
||||||
|
double rangeEnd = Math.Max(clickedObject.GetEndTime(), pivot.GetEndTime());
|
||||||
|
|
||||||
|
var newSelection = new HashSet<HitObject>(EditorBeatmap.HitObjects.Where(obj => isInRange(obj, rangeStart, rangeEnd)));
|
||||||
|
|
||||||
|
if (cumulative)
|
||||||
|
{
|
||||||
|
pivot = clickedObject;
|
||||||
|
newSelection.UnionWith(EditorBeatmap.SelectedHitObjects);
|
||||||
|
}
|
||||||
|
|
||||||
|
EditorBeatmap.SelectedHitObjects.Clear();
|
||||||
|
EditorBeatmap.SelectedHitObjects.AddRange(newSelection);
|
||||||
|
|
||||||
|
bool isInRange(HitObject hitObject, double start, double end)
|
||||||
|
=> hitObject.StartTime >= start && hitObject.GetEndTime() <= end;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user