1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 10:33:30 +08:00

Propagate mania column in SnapResult

This commit is contained in:
Dean Herbert 2020-05-20 19:09:04 +09:00
parent 82d6549161
commit 62092e3f5b
2 changed files with 17 additions and 10 deletions

View File

@ -33,9 +33,6 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
/// </summary>
protected float SnappedWidth { get; private set; }
[Resolved]
private IManiaHitObjectComposer composer { get; set; }
[Resolved]
private IScrollingInfo scrollingInfo { get; set; }
@ -61,7 +58,7 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
public override void UpdatePosition(SnapResult result)
{
if (!PlacementActive)
Column = ColumnAt(result.ScreenSpacePosition);
Column = (result as ManiaSnapResult)?.Column;
if (Column == null) return;
@ -85,9 +82,6 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
return hitObjectToMousePosition(Column.HitObjectContainer.ToSpaceOfOtherDrawable(new Vector2(0, pos), Parent)).Y;
}
protected Column ColumnAt(Vector2 screenSpacePosition)
=> composer.ColumnAt(screenSpacePosition);
/// <summary>
/// Converts a mouse position to a hitobject position.
/// </summary>

View File

@ -46,11 +46,13 @@ namespace osu.Game.Rulesets.Mania.Edit
public override SnapResult SnapScreenSpacePositionToValidTime(Vector2 screenSpacePosition)
{
var hoc = ColumnAt(screenSpacePosition)?.HitObjectContainer;
var column = ColumnAt(screenSpacePosition);
if (hoc == null)
if (column == null)
return new SnapResult(screenSpacePosition, null);
var hoc = column.HitObjectContainer;
Vector2 localPosition = hoc.ToLocalSpace(screenSpacePosition);
if (drawableRuleset.ScrollingInfo.Direction.Value == ScrollingDirection.Down)
@ -73,7 +75,7 @@ namespace osu.Game.Rulesets.Mania.Edit
hoc.DrawHeight))
).Y;
return new SnapResult(screenSpacePosition, BeatSnapProvider.SnapTime(targetTime));
return new ManiaSnapResult(screenSpacePosition, BeatSnapProvider.SnapTime(targetTime), column);
}
protected override DrawableRuleset<ManiaHitObject> CreateDrawableRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod> mods = null)
@ -94,4 +96,15 @@ namespace osu.Game.Rulesets.Mania.Edit
new HoldNoteCompositionTool()
};
}
public class ManiaSnapResult : SnapResult
{
public readonly Column Column;
public ManiaSnapResult(Vector2 screenSpacePosition, double time, Column column)
: base(screenSpacePosition, time)
{
Column = column;
}
}
}