mirror of
https://github.com/osukey/osukey.git
synced 2025-08-05 07:33:55 +09:00
Basic inter-column selection movement
This commit is contained in:
@ -2,11 +2,15 @@
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Game.Rulesets.Edit;
|
||||
using osu.Game.Rulesets.Mania.Objects;
|
||||
using osu.Game.Rulesets.Mania.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Mania.UI;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Rulesets.UI.Scrolling;
|
||||
using OpenTK;
|
||||
@ -20,6 +24,9 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
||||
[Resolved]
|
||||
private IScrollingInfo scrollingInfo { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private IManiaHitObjectComposer composer { get; set; }
|
||||
|
||||
public ManiaSelectionBlueprint(DrawableHitObject hitObject)
|
||||
: base(hitObject)
|
||||
{
|
||||
@ -41,6 +48,8 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
||||
|
||||
public override void AdjustPosition(DragEvent dragEvent, IEnumerable<DrawableHitObject> selectedObjects)
|
||||
{
|
||||
var maniaObject = (ManiaHitObject)HitObject.HitObject;
|
||||
|
||||
var objectParent = HitObject.Parent;
|
||||
|
||||
// Using the hitobject position is required since AdjustPosition can be invoked multiple times per frame
|
||||
@ -60,6 +69,34 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
||||
EditorClock.CurrentTime,
|
||||
scrollingInfo.TimeRange.Value,
|
||||
objectParent.DrawHeight);
|
||||
|
||||
var lastColumn = ColumnAt(dragEvent.ScreenSpaceLastMousePosition);
|
||||
var currentColumn = ColumnAt(dragEvent.ScreenSpaceMousePosition);
|
||||
if (lastColumn != null && currentColumn != null)
|
||||
{
|
||||
int columnDelta = currentColumn.Index - lastColumn.Index;
|
||||
|
||||
if (columnDelta != 0)
|
||||
{
|
||||
int minColumn = int.MaxValue;
|
||||
int maxColumn = int.MinValue;
|
||||
|
||||
foreach (var obj in selectedObjects.OfType<DrawableManiaHitObject>())
|
||||
{
|
||||
if (obj.HitObject.Column < minColumn)
|
||||
minColumn = obj.HitObject.Column;
|
||||
if (obj.HitObject.Column > maxColumn)
|
||||
maxColumn = obj.HitObject.Column;
|
||||
}
|
||||
|
||||
columnDelta = MathHelper.Clamp(columnDelta, -minColumn, composer.TotalColumns - 1 - maxColumn);
|
||||
}
|
||||
|
||||
Schedule(() => maniaObject.Column += columnDelta);
|
||||
}
|
||||
}
|
||||
|
||||
protected Column ColumnAt(Vector2 screenSpacePosition) => composer.ColumnAt(screenSpacePosition);
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user