mirror of
https://github.com/ppy/osu.git
synced 2024-11-13 18:07:25 +08:00
Attempt to fix multiple selection movements
This commit is contained in:
parent
b88dd44252
commit
cebc0fc046
@ -10,6 +10,7 @@ using osu.Framework.Allocation;
|
|||||||
using osu.Game.Rulesets.Mania.UI;
|
using osu.Game.Rulesets.Mania.UI;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
using osu.Game.Rulesets.UI;
|
using osu.Game.Rulesets.UI;
|
||||||
|
using osu.Game.Rulesets.UI.Scrolling;
|
||||||
using osu.Game.Screens.Edit.Compose.Components;
|
using osu.Game.Screens.Edit.Compose.Components;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
|
||||||
@ -37,7 +38,32 @@ namespace osu.Game.Rulesets.Mania.Edit
|
|||||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
||||||
=> dependencies = new DependencyContainer(base.CreateChildDependencies(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)
|
protected override DrawableRuleset<ManiaHitObject> CreateDrawableRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod> mods = null)
|
||||||
{
|
{
|
||||||
|
@ -56,20 +56,6 @@ namespace osu.Game.Rulesets.Mania.Edit
|
|||||||
// since the scrolling hitobject container requires at least one update frame to update the position.
|
// 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.
|
// However the position needs to be valid for future movement events to calculate the correct deltas.
|
||||||
hitObject.Y += delta;
|
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,6 +87,22 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
return found;
|
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>
|
/// <summary>
|
||||||
/// Retrieves the total amount of columns across all stages in this playfield.
|
/// Retrieves the total amount of columns across all stages in this playfield.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -401,18 +401,16 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
|
|
||||||
HitObject draggedObject = movementBlueprint.HitObject;
|
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 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))))
|
if (!selectionHandler.HandleMovement(new MoveSelectionEvent(movementBlueprint, ToScreenSpace(snappedPosition))))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Todo: Temp
|
|
||||||
(_, double snappedTime) = snapProvider.GetSnappedPosition(ToLocalSpace(snappedPosition), draggedObject.StartTime);
|
|
||||||
|
|
||||||
// Apply the start time at the newly snapped-to position
|
// Apply the start time at the newly snapped-to position
|
||||||
double offset = snappedTime - draggedObject.StartTime;
|
double offset = snappedTime - draggedObject.StartTime;
|
||||||
foreach (HitObject obj in selectionHandler.SelectedHitObjects)
|
foreach (HitObject obj in selectionHandler.SelectedHitObjects)
|
||||||
|
Loading…
Reference in New Issue
Block a user