1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 20:22:55 +08:00

Move ScreenSpacePositionAtTime to inside Column implementation

This commit is contained in:
Dean Herbert 2020-05-21 13:33:02 +09:00
parent 922b793a5a
commit 5ad7842b91
7 changed files with 18 additions and 28 deletions

View File

@ -49,8 +49,6 @@ namespace osu.Game.Rulesets.Mania.Tests
public Column ColumnAt(Vector2 screenSpacePosition) => column;
public Vector2 ScreenSpacePositionAtTime(double time, Column column = null) => Vector2.Zero;
public int TotalColumns => 1;
}
}

View File

@ -33,8 +33,6 @@ namespace osu.Game.Rulesets.Mania.Tests
public Column ColumnAt(Vector2 screenSpacePosition) => column;
public Vector2 ScreenSpacePositionAtTime(double time, Column column = null) => Vector2.Zero;
public int TotalColumns => 1;
}
}

View File

@ -8,7 +8,6 @@ using osu.Framework.Input.Events;
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Mania.Edit.Blueprints.Components;
using osu.Game.Rulesets.Mania.Objects;
using osu.Game.Rulesets.UI.Scrolling;
using osuTK;
using osuTK.Input;
@ -42,8 +41,8 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
if (Column != null)
{
headPiece.Y = Parent.ToLocalSpace(composer.ScreenSpacePositionAtTime(HitObject.StartTime, Column)).Y;
tailPiece.Y = Parent.ToLocalSpace(composer.ScreenSpacePositionAtTime(HitObject.EndTime, Column)).Y;
headPiece.Y = Parent.ToLocalSpace(Column.ScreenSpacePositionAtTime(HitObject.StartTime, Column)).Y;
tailPiece.Y = Parent.ToLocalSpace(Column.ScreenSpacePositionAtTime(HitObject.EndTime, Column)).Y;
}
var topPosition = new Vector2(headPiece.DrawPosition.X, Math.Min(headPiece.DrawPosition.Y, tailPiece.DrawPosition.Y));

View File

@ -10,8 +10,6 @@ namespace osu.Game.Rulesets.Mania.Edit
{
Column ColumnAt(Vector2 screenSpacePosition);
Vector2 ScreenSpacePositionAtTime(double time, Column column = null);
int TotalColumns { get; }
}
}

View File

@ -72,27 +72,11 @@ namespace osu.Game.Rulesets.Mania.Edit
targetTime = BeatSnapProvider.SnapTime(targetTime);
// convert back to screen space
screenSpacePosition = ScreenSpacePositionAtTime(targetTime, column);
screenSpacePosition = column.ScreenSpacePositionAtTime(targetTime, column);
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);

View File

@ -140,5 +140,18 @@ namespace osu.Game.Rulesets.Mania.UI
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos)
// This probably shouldn't exist as is, but the columns in the stage are separated by a 1px border
=> DrawRectangle.Inflate(new Vector2(Stage.COLUMN_SPACING / 2, 0)).Contains(ToLocalSpace(screenSpacePos));
public Vector2 ScreenSpacePositionAtTime(double time, Column column = null)
{
var pos = ScrollingInfo.Algorithm.PositionAt(time, Time.Current, ScrollingInfo.TimeRange.Value, HitObjectContainer.DrawHeight);
if (ScrollingInfo.Direction.Value == ScrollingDirection.Down)
{
// as explained above
pos = HitObjectContainer.DrawHeight - pos;
}
return HitObjectContainer.ToScreenSpace(new Vector2(HitObjectContainer.DrawWidth / 2, pos));
}
}
}

View File

@ -15,12 +15,12 @@ namespace osu.Game.Rulesets.UI.Scrolling
protected readonly IBindable<ScrollingDirection> Direction = new Bindable<ScrollingDirection>();
[Resolved]
private IScrollingInfo scrollingInfo { get; set; }
protected IScrollingInfo ScrollingInfo { get; private set; }
[BackgroundDependencyLoader]
private void load()
{
Direction.BindTo(scrollingInfo.Direction);
Direction.BindTo(ScrollingInfo.Direction);
}
protected sealed override HitObjectContainer CreateHitObjectContainer() => new ScrollingHitObjectContainer();