mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 16:29:58 +09:00
Merge branch 'editor-position-snap' into mania-distance-snap-grid
This commit is contained in:
@ -83,48 +83,17 @@ namespace osu.Game.Rulesets.Mania.Edit
|
||||
if (column == null)
|
||||
return new SnapResult(screenSpacePosition, null);
|
||||
|
||||
var hoc = column.HitObjectContainer;
|
||||
|
||||
// convert to local space of column so we can snap and fetch correct location.
|
||||
Vector2 localPosition = hoc.ToLocalSpace(screenSpacePosition);
|
||||
|
||||
var scrollInfo = drawableRuleset.ScrollingInfo;
|
||||
|
||||
if (scrollInfo.Direction.Value == ScrollingDirection.Down)
|
||||
{
|
||||
// We're dealing with screen coordinates in which the position decreases towards the centre of the screen resulting in an increase in start time.
|
||||
// The scrolling algorithm instead assumes a top anchor meaning an increase in time corresponds to an increase in position,
|
||||
// so when scrolling downwards the coordinates need to be flipped.
|
||||
localPosition.Y = hoc.DrawHeight - localPosition.Y;
|
||||
}
|
||||
|
||||
double targetTime = scrollInfo.Algorithm.TimeAt(localPosition.Y, EditorClock.CurrentTime, scrollInfo.TimeRange.Value, hoc.DrawHeight);
|
||||
double targetTime = column.TimeAtScreenSpacePosition(screenSpacePosition);
|
||||
|
||||
// apply beat snapping
|
||||
targetTime = BeatSnapProvider.SnapTime(targetTime);
|
||||
|
||||
// convert back to screen space
|
||||
screenSpacePosition = ScreenSpacePositionAtTime(targetTime, column);
|
||||
screenSpacePosition = column.ScreenSpacePositionAtTime(targetTime);
|
||||
|
||||
return new ManiaSnapResult(screenSpacePosition, targetTime, column);
|
||||
}
|
||||
|
||||
public Vector2 ScreenSpacePositionAtTime(double time, Column column = null)
|
||||
{
|
||||
var hoc = (column ?? Playfield.GetColumn(0)).HitObjectContainer;
|
||||
var scrollInfo = drawableRuleset.ScrollingInfo;
|
||||
|
||||
var pos = scrollInfo.Algorithm.PositionAt(time, EditorClock.CurrentTime, scrollInfo.TimeRange.Value, hoc.DrawHeight);
|
||||
|
||||
if (scrollInfo.Direction.Value == ScrollingDirection.Down)
|
||||
{
|
||||
// as explained above
|
||||
pos = hoc.DrawHeight - pos;
|
||||
}
|
||||
|
||||
return hoc.ToScreenSpace(new Vector2(hoc.DrawWidth / 2, pos));
|
||||
}
|
||||
|
||||
protected override DrawableRuleset<ManiaHitObject> CreateDrawableRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod> mods = null)
|
||||
{
|
||||
drawableRuleset = new DrawableManiaEditRuleset(ruleset, beatmap, mods);
|
||||
|
Reference in New Issue
Block a user