Attempt to fix multiple selection movements

This commit is contained in:
smoogipoo 2020-04-27 20:35:24 +09:00
parent b88dd44252
commit cebc0fc046
4 changed files with 47 additions and 21 deletions

View File

@ -10,6 +10,7 @@
using osu.Game.Rulesets.Mania.UI;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.UI;
using osu.Game.Rulesets.UI.Scrolling;
using osu.Game.Screens.Edit.Compose.Components;
using osuTK;
@ -37,7 +38,32 @@ public ManiaHitObjectComposer(Ruleset ruleset)
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
=> dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
public int TotalColumns => ((ManiaPlayfield)drawableRuleset.Playfield).TotalColumns;
public ManiaPlayfield Playfield => ((ManiaPlayfield)drawableRuleset.Playfield);
public int TotalColumns => Playfield.TotalColumns;
public override (Vector2 position, double time) GetSnappedPosition(Vector2 position, double time)
{
var hoc = Playfield.GetColumn(0).HitObjectContainer;
position.Y -= ToLocalSpace(hoc.ScreenSpaceDrawQuad.TopLeft).Y;
float targetPosition = position.Y;
if (drawableRuleset.ScrollingInfo.Direction.Value == ScrollingDirection.Down)
{
// When scrolling downwards, the position is _negative_ when the object's start time is after the current time (e.g. in the middle of the stage).
// However all scrolling algorithms upwards scrolling, meaning that a positive (inverse) position is expected in the same scenario.
targetPosition = -targetPosition;
}
double targetTime = drawableRuleset.ScrollingInfo.Algorithm.TimeAt(targetPosition,
EditorClock.CurrentTime,
drawableRuleset.ScrollingInfo.TimeRange.Value,
hoc.DrawHeight);
return base.GetSnappedPosition(position, targetTime);
}
protected override DrawableRuleset<ManiaHitObject> CreateDrawableRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod> mods = null)
{

View File

@ -56,20 +56,6 @@ private void performDragMovement(MoveSelectionEvent moveEvent)
// since the scrolling hitobject container requires at least one update frame to update the position.
// However the position needs to be valid for future movement events to calculate the correct deltas.
hitObject.Y += delta;
float targetPosition = hitObject.Position.Y;
if (scrollingInfo.Direction.Value == ScrollingDirection.Down)
{
// When scrolling downwards, the position is _negative_ when the object's start time is after the current time (e.g. in the middle of the stage).
// However all scrolling algorithms upwards scrolling, meaning that a positive (inverse) position is expected in the same scenario.
targetPosition = -targetPosition;
}
hitObject.HitObject.StartTime = scrollingInfo.Algorithm.TimeAt(targetPosition,
editorClock.CurrentTime,
scrollingInfo.TimeRange.Value,
objectParent.DrawHeight);
}
}

View File

@ -87,6 +87,22 @@ public Column GetColumnByPosition(Vector2 screenSpacePosition)
return found;
}
public Column GetColumn(int index)
{
foreach (var stage in stages)
{
if (index >= stage.Columns.Count)
{
index -= stage.Columns.Count;
continue;
}
return stage.Columns[index];
}
throw new ArgumentOutOfRangeException(nameof(index));
}
/// <summary>
/// Retrieves the total amount of columns across all stages in this playfield.
/// </summary>

View File

@ -401,18 +401,16 @@ private bool moveCurrentSelection(DragEvent e)
HitObject draggedObject = movementBlueprint.HitObject;
// The final movement position, relative to movementBlueprintOriginalPosition
// The final movement position, relative to movementBlueprintOriginalPosition.
Vector2 movePosition = movementBlueprintOriginalPosition.Value + e.ScreenSpaceMousePosition - e.ScreenSpaceMouseDownPosition;
(Vector2 snappedPosition, _) = snapProvider.GetSnappedPosition(ToLocalSpace(movePosition), draggedObject.StartTime);
// Retrieve a snapped position.
(Vector2 snappedPosition, double snappedTime) = snapProvider.GetSnappedPosition(ToLocalSpace(movePosition), draggedObject.StartTime);
// Move the hitobjects
// Move the hitobjects.
if (!selectionHandler.HandleMovement(new MoveSelectionEvent(movementBlueprint, ToScreenSpace(snappedPosition))))
return true;
// Todo: Temp
(_, double snappedTime) = snapProvider.GetSnappedPosition(ToLocalSpace(snappedPosition), draggedObject.StartTime);
// Apply the start time at the newly snapped-to position
double offset = snappedTime - draggedObject.StartTime;
foreach (HitObject obj in selectionHandler.SelectedHitObjects)