mirror of
https://github.com/ppy/osu.git
synced 2025-02-15 17:33:02 +08:00
Remove need for ManiaSnapResult
This commit is contained in:
parent
2c16619ecd
commit
e7442ec3a2
@ -48,7 +48,7 @@ namespace osu.Game.Rulesets.Mania.Tests
|
|||||||
var time = column.TimeAtScreenSpacePosition(InputManager.CurrentState.Mouse.Position);
|
var time = column.TimeAtScreenSpacePosition(InputManager.CurrentState.Mouse.Position);
|
||||||
var pos = column.ScreenSpacePositionAtTime(time);
|
var pos = column.ScreenSpacePositionAtTime(time);
|
||||||
|
|
||||||
return new ManiaSnapResult(pos, time, column);
|
return new SnapResult(pos, time, column);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override Container CreateHitObjectContainer() => new ScrollingTestContainer(ScrollingDirection.Down) { RelativeSizeAxes = Axes.Both };
|
protected override Container CreateHitObjectContainer() => new ScrollingTestContainer(ScrollingDirection.Down) { RelativeSizeAxes = Axes.Both };
|
||||||
|
@ -78,9 +78,9 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (result is ManiaSnapResult maniaResult)
|
if (result.Playfield != null)
|
||||||
{
|
{
|
||||||
headPiece.Width = tailPiece.Width = maniaResult.Column.DrawWidth;
|
headPiece.Width = tailPiece.Width = result.Playfield.DrawWidth;
|
||||||
headPiece.X = tailPiece.X = ToLocalSpace(result.ScreenSpacePosition).X;
|
headPiece.X = tailPiece.X = ToLocalSpace(result.ScreenSpacePosition).X;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
|||||||
base.UpdatePosition(result);
|
base.UpdatePosition(result);
|
||||||
|
|
||||||
if (!PlacementActive)
|
if (!PlacementActive)
|
||||||
Column = (result as ManiaSnapResult)?.Column;
|
Column = result.Playfield as Column;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,9 +26,9 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
|||||||
{
|
{
|
||||||
base.UpdatePosition(result);
|
base.UpdatePosition(result);
|
||||||
|
|
||||||
if (result is ManiaSnapResult maniaResult)
|
if (result.Playfield != null)
|
||||||
{
|
{
|
||||||
piece.Width = maniaResult.Column.DrawWidth;
|
piece.Width = result.Playfield.DrawWidth;
|
||||||
piece.Position = ToLocalSpace(result.ScreenSpacePosition);
|
piece.Position = ToLocalSpace(result.ScreenSpacePosition);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,23 +53,8 @@ namespace osu.Game.Rulesets.Mania.Edit
|
|||||||
|
|
||||||
public IScrollingInfo ScrollingInfo => drawableRuleset.ScrollingInfo;
|
public IScrollingInfo ScrollingInfo => drawableRuleset.ScrollingInfo;
|
||||||
|
|
||||||
public override SnapResult SnapScreenSpacePositionToValidTime(Vector2 screenSpacePosition)
|
protected override Playfield PlayfieldAtScreenSpacePosition(Vector2 screenSpacePosition) =>
|
||||||
{
|
Playfield.GetColumnByPosition(screenSpacePosition);
|
||||||
var column = Playfield.GetColumnByPosition(screenSpacePosition);
|
|
||||||
|
|
||||||
if (column == null)
|
|
||||||
return new SnapResult(screenSpacePosition, null);
|
|
||||||
|
|
||||||
double targetTime = column.TimeAtScreenSpacePosition(screenSpacePosition);
|
|
||||||
|
|
||||||
// apply beat snapping
|
|
||||||
targetTime = BeatSnapProvider.SnapTime(targetTime);
|
|
||||||
|
|
||||||
// convert back to screen space
|
|
||||||
screenSpacePosition = column.ScreenSpacePositionAtTime(targetTime);
|
|
||||||
|
|
||||||
return new ManiaSnapResult(screenSpacePosition, targetTime, column);
|
|
||||||
}
|
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
|
@ -1,20 +0,0 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
|
||||||
|
|
||||||
using osu.Game.Rulesets.Edit;
|
|
||||||
using osu.Game.Rulesets.Mania.UI;
|
|
||||||
using osuTK;
|
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Mania.Edit
|
|
||||||
{
|
|
||||||
public class ManiaSnapResult : SnapResult
|
|
||||||
{
|
|
||||||
public readonly Column Column;
|
|
||||||
|
|
||||||
public ManiaSnapResult(Vector2 screenSpacePosition, double time, Column column)
|
|
||||||
: base(screenSpacePosition, time)
|
|
||||||
{
|
|
||||||
Column = column;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -78,7 +78,7 @@ namespace osu.Game.Rulesets.Osu.Edit
|
|||||||
|
|
||||||
(Vector2 pos, double time) = distanceSnapGrid.GetSnappedPosition(distanceSnapGrid.ToLocalSpace(screenSpacePosition));
|
(Vector2 pos, double time) = distanceSnapGrid.GetSnappedPosition(distanceSnapGrid.ToLocalSpace(screenSpacePosition));
|
||||||
|
|
||||||
return new SnapResult(distanceSnapGrid.ToScreenSpace(pos), time);
|
return new SnapResult(distanceSnapGrid.ToScreenSpace(pos), time, PlayfieldAtScreenSpacePosition(screenSpacePosition));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateDistanceSnapGrid()
|
private void updateDistanceSnapGrid()
|
||||||
|
@ -19,6 +19,7 @@ using osu.Game.Rulesets.Mods;
|
|||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
using osu.Game.Rulesets.Objects.Drawables;
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
using osu.Game.Rulesets.UI;
|
using osu.Game.Rulesets.UI;
|
||||||
|
using osu.Game.Rulesets.UI.Scrolling;
|
||||||
using osu.Game.Screens.Edit;
|
using osu.Game.Screens.Edit;
|
||||||
using osu.Game.Screens.Edit.Components.RadioButtons;
|
using osu.Game.Screens.Edit.Components.RadioButtons;
|
||||||
using osu.Game.Screens.Edit.Compose;
|
using osu.Game.Screens.Edit.Compose;
|
||||||
@ -224,7 +225,26 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
|
|
||||||
public void Delete(HitObject hitObject) => EditorBeatmap.Remove(hitObject);
|
public void Delete(HitObject hitObject) => EditorBeatmap.Remove(hitObject);
|
||||||
|
|
||||||
public override SnapResult SnapScreenSpacePositionToValidTime(Vector2 screenSpacePosition) => new SnapResult(screenSpacePosition, null);
|
protected virtual Playfield PlayfieldAtScreenSpacePosition(Vector2 screenSpacePosition) => drawableRulesetWrapper.Playfield;
|
||||||
|
|
||||||
|
public override SnapResult SnapScreenSpacePositionToValidTime(Vector2 screenSpacePosition)
|
||||||
|
{
|
||||||
|
var playfield = PlayfieldAtScreenSpacePosition(screenSpacePosition);
|
||||||
|
double? targetTime = null;
|
||||||
|
|
||||||
|
if (playfield is ScrollingPlayfield scrollingPlayfield)
|
||||||
|
{
|
||||||
|
targetTime = scrollingPlayfield.TimeAtScreenSpacePosition(screenSpacePosition);
|
||||||
|
|
||||||
|
// apply beat snapping
|
||||||
|
targetTime = BeatSnapProvider.SnapTime(targetTime.Value);
|
||||||
|
|
||||||
|
// convert back to screen space
|
||||||
|
screenSpacePosition = scrollingPlayfield.ScreenSpacePositionAtTime(targetTime.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new SnapResult(screenSpacePosition, targetTime, playfield);
|
||||||
|
}
|
||||||
|
|
||||||
public override float GetBeatSnapDistanceAt(double referenceTime)
|
public override float GetBeatSnapDistanceAt(double referenceTime)
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using osu.Game.Rulesets.UI;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Edit
|
namespace osu.Game.Rulesets.Edit
|
||||||
@ -20,10 +21,13 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public double? Time;
|
public double? Time;
|
||||||
|
|
||||||
public SnapResult(Vector2 screenSpacePosition, double? time)
|
public readonly Playfield Playfield;
|
||||||
|
|
||||||
|
public SnapResult(Vector2 screenSpacePosition, double? time, Playfield playfield = null)
|
||||||
{
|
{
|
||||||
ScreenSpacePosition = screenSpacePosition;
|
ScreenSpacePosition = screenSpacePosition;
|
||||||
Time = time;
|
Time = time;
|
||||||
|
Playfield = playfield;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user