mirror of
https://github.com/osukey/osukey.git
synced 2025-08-08 00:53:56 +09:00
Merge pull request #9108 from peppy/editor-scrolling-playfield-support
Simplify scrolling ruleset editor implementation by adding base position support
This commit is contained in:
@ -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 };
|
||||||
|
@ -8,6 +8,7 @@ using osu.Framework.Input.Events;
|
|||||||
using osu.Game.Rulesets.Edit;
|
using osu.Game.Rulesets.Edit;
|
||||||
using osu.Game.Rulesets.Mania.Edit.Blueprints.Components;
|
using osu.Game.Rulesets.Mania.Edit.Blueprints.Components;
|
||||||
using osu.Game.Rulesets.Mania.Objects;
|
using osu.Game.Rulesets.Mania.Objects;
|
||||||
|
using osu.Game.Rulesets.UI.Scrolling;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osuTK.Input;
|
using osuTK.Input;
|
||||||
|
|
||||||
@ -22,6 +23,9 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private IManiaHitObjectComposer composer { get; set; }
|
private IManiaHitObjectComposer composer { get; set; }
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private IScrollingInfo scrollingInfo { get; set; }
|
||||||
|
|
||||||
public HoldNotePlacementBlueprint()
|
public HoldNotePlacementBlueprint()
|
||||||
: base(new HoldNote())
|
: base(new HoldNote())
|
||||||
{
|
{
|
||||||
@ -43,6 +47,19 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
|||||||
{
|
{
|
||||||
headPiece.Y = Parent.ToLocalSpace(Column.ScreenSpacePositionAtTime(HitObject.StartTime)).Y;
|
headPiece.Y = Parent.ToLocalSpace(Column.ScreenSpacePositionAtTime(HitObject.StartTime)).Y;
|
||||||
tailPiece.Y = Parent.ToLocalSpace(Column.ScreenSpacePositionAtTime(HitObject.EndTime)).Y;
|
tailPiece.Y = Parent.ToLocalSpace(Column.ScreenSpacePositionAtTime(HitObject.EndTime)).Y;
|
||||||
|
|
||||||
|
switch (scrollingInfo.Direction.Value)
|
||||||
|
{
|
||||||
|
case ScrollingDirection.Down:
|
||||||
|
headPiece.Y -= headPiece.DrawHeight / 2;
|
||||||
|
tailPiece.Y -= tailPiece.DrawHeight / 2;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ScrollingDirection.Up:
|
||||||
|
headPiece.Y += headPiece.DrawHeight / 2;
|
||||||
|
tailPiece.Y += tailPiece.DrawHeight / 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var topPosition = new Vector2(headPiece.DrawPosition.X, Math.Min(headPiece.DrawPosition.Y, tailPiece.DrawPosition.Y));
|
var topPosition = new Vector2(headPiece.DrawPosition.X, Math.Min(headPiece.DrawPosition.Y, tailPiece.DrawPosition.Y));
|
||||||
@ -78,9 +95,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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ using osuTK;
|
|||||||
|
|
||||||
namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
||||||
{
|
{
|
||||||
public class ManiaSelectionBlueprint : OverlaySelectionBlueprint
|
public abstract class ManiaSelectionBlueprint : OverlaySelectionBlueprint
|
||||||
{
|
{
|
||||||
public new DrawableManiaHitObject DrawableObject => (DrawableManiaHitObject)base.DrawableObject;
|
public new DrawableManiaHitObject DrawableObject => (DrawableManiaHitObject)base.DrawableObject;
|
||||||
|
|
||||||
@ -21,7 +21,7 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private IManiaHitObjectComposer composer { get; set; }
|
private IManiaHitObjectComposer composer { get; set; }
|
||||||
|
|
||||||
public ManiaSelectionBlueprint(DrawableHitObject drawableObject)
|
protected ManiaSelectionBlueprint(DrawableHitObject drawableObject)
|
||||||
: base(drawableObject)
|
: base(drawableObject)
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.None;
|
RelativeSizeAxes = Axes.None;
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Input;
|
using osu.Framework.Input;
|
||||||
|
using osu.Game.Rulesets.Mania.Objects.Drawables.Pieces;
|
||||||
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.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
@ -53,24 +54,31 @@ namespace osu.Game.Rulesets.Mania.Edit
|
|||||||
|
|
||||||
public IScrollingInfo ScrollingInfo => drawableRuleset.ScrollingInfo;
|
public IScrollingInfo ScrollingInfo => drawableRuleset.ScrollingInfo;
|
||||||
|
|
||||||
|
protected override Playfield PlayfieldAtScreenSpacePosition(Vector2 screenSpacePosition) =>
|
||||||
|
Playfield.GetColumnByPosition(screenSpacePosition);
|
||||||
|
|
||||||
public override SnapResult SnapScreenSpacePositionToValidTime(Vector2 screenSpacePosition)
|
public override SnapResult SnapScreenSpacePositionToValidTime(Vector2 screenSpacePosition)
|
||||||
{
|
{
|
||||||
var column = Playfield.GetColumnByPosition(screenSpacePosition);
|
var result = base.SnapScreenSpacePositionToValidTime(screenSpacePosition);
|
||||||
|
|
||||||
if (column == null)
|
switch (ScrollingInfo.Direction.Value)
|
||||||
return new SnapResult(screenSpacePosition, null);
|
{
|
||||||
|
case ScrollingDirection.Down:
|
||||||
|
result.ScreenSpacePosition -= new Vector2(0, getNoteHeight() / 2);
|
||||||
|
break;
|
||||||
|
|
||||||
double targetTime = column.TimeAtScreenSpacePosition(screenSpacePosition);
|
case ScrollingDirection.Up:
|
||||||
|
result.ScreenSpacePosition += new Vector2(0, getNoteHeight() / 2);
|
||||||
// apply beat snapping
|
break;
|
||||||
targetTime = BeatSnapProvider.SnapTime(targetTime);
|
|
||||||
|
|
||||||
// convert back to screen space
|
|
||||||
screenSpacePosition = column.ScreenSpacePositionAtTime(targetTime);
|
|
||||||
|
|
||||||
return new ManiaSnapResult(screenSpacePosition, targetTime, column);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private float getNoteHeight() =>
|
||||||
|
Playfield.GetColumn(0).ToScreenSpace(new Vector2(DefaultNotePiece.NOTE_HEIGHT)).Y -
|
||||||
|
Playfield.GetColumn(0).ToScreenSpace(Vector2.Zero).Y;
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
drawableRuleset = new DrawableManiaEditRuleset(ruleset, beatmap, mods);
|
drawableRuleset = new DrawableManiaEditRuleset(ruleset, beatmap, mods);
|
||||||
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -17,7 +17,6 @@ using osu.Game.Rulesets.UI.Scrolling;
|
|||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osu.Game.Rulesets.Mania.Beatmaps;
|
using osu.Game.Rulesets.Mania.Beatmaps;
|
||||||
using osu.Game.Rulesets.Mania.Objects.Drawables.Pieces;
|
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Mania.UI
|
namespace osu.Game.Rulesets.Mania.UI
|
||||||
{
|
{
|
||||||
@ -143,54 +142,5 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos)
|
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
|
// 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));
|
=> DrawRectangle.Inflate(new Vector2(Stage.COLUMN_SPACING / 2, 0)).Contains(ToLocalSpace(screenSpacePos));
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Given a time, return the screen space position within this column.
|
|
||||||
/// </summary>
|
|
||||||
public Vector2 ScreenSpacePositionAtTime(double time)
|
|
||||||
{
|
|
||||||
var pos = ScrollingInfo.Algorithm.PositionAt(time, Time.Current, ScrollingInfo.TimeRange.Value, HitObjectContainer.DrawHeight);
|
|
||||||
|
|
||||||
switch (ScrollingInfo.Direction.Value)
|
|
||||||
{
|
|
||||||
case 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.
|
|
||||||
pos = HitObjectContainer.DrawHeight - pos;
|
|
||||||
|
|
||||||
// Blueprints are centred on the mouse position, such that the hitobject position is anchored at the top or bottom of the blueprint depending on the scroll direction.
|
|
||||||
pos -= DefaultNotePiece.NOTE_HEIGHT / 2;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ScrollingDirection.Up:
|
|
||||||
pos += DefaultNotePiece.NOTE_HEIGHT / 2;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return HitObjectContainer.ToScreenSpace(new Vector2(HitObjectContainer.DrawWidth / 2, pos));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Given a position in screen space, return the time within this column.
|
|
||||||
/// </summary>
|
|
||||||
public double TimeAtScreenSpacePosition(Vector2 screenSpacePosition)
|
|
||||||
{
|
|
||||||
// convert to local space of column so we can snap and fetch correct location.
|
|
||||||
Vector2 localPosition = HitObjectContainer.ToLocalSpace(screenSpacePosition);
|
|
||||||
|
|
||||||
switch (ScrollingInfo.Direction.Value)
|
|
||||||
{
|
|
||||||
case ScrollingDirection.Down:
|
|
||||||
// as above
|
|
||||||
localPosition.Y = HitObjectContainer.DrawHeight - localPosition.Y;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// offset for the fact that blueprints are centered, as above.
|
|
||||||
localPosition.Y -= DefaultNotePiece.NOTE_HEIGHT / 2;
|
|
||||||
|
|
||||||
return ScrollingInfo.Algorithm.TimeAt(localPosition.Y, Time.Current, ScrollingInfo.TimeRange.Value, HitObjectContainer.DrawHeight);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
@ -205,7 +206,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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ using osu.Framework.Graphics;
|
|||||||
using osu.Framework.Layout;
|
using osu.Framework.Layout;
|
||||||
using osu.Game.Rulesets.Objects.Drawables;
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
using osu.Game.Rulesets.Objects.Types;
|
using osu.Game.Rulesets.Objects.Types;
|
||||||
|
using osuTK;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.UI.Scrolling
|
namespace osu.Game.Rulesets.UI.Scrolling
|
||||||
{
|
{
|
||||||
@ -78,6 +79,98 @@ namespace osu.Game.Rulesets.UI.Scrolling
|
|||||||
hitObjectInitialStateCache.Clear();
|
hitObjectInitialStateCache.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Given a position in screen space, return the time within this column.
|
||||||
|
/// </summary>
|
||||||
|
public double TimeAtScreenSpacePosition(Vector2 screenSpacePosition)
|
||||||
|
{
|
||||||
|
// convert to local space of column so we can snap and fetch correct location.
|
||||||
|
Vector2 localPosition = ToLocalSpace(screenSpacePosition);
|
||||||
|
|
||||||
|
float position = 0;
|
||||||
|
|
||||||
|
switch (scrollingInfo.Direction.Value)
|
||||||
|
{
|
||||||
|
case ScrollingDirection.Up:
|
||||||
|
case ScrollingDirection.Down:
|
||||||
|
position = localPosition.Y;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ScrollingDirection.Right:
|
||||||
|
case ScrollingDirection.Left:
|
||||||
|
position = localPosition.X;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
flipPositionIfRequired(ref position);
|
||||||
|
|
||||||
|
return scrollingInfo.Algorithm.TimeAt(position, Time.Current, scrollingInfo.TimeRange.Value, getLength());
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Given a time, return the screen space position within this column.
|
||||||
|
/// </summary>
|
||||||
|
public Vector2 ScreenSpacePositionAtTime(double time)
|
||||||
|
{
|
||||||
|
var pos = scrollingInfo.Algorithm.PositionAt(time, Time.Current, scrollingInfo.TimeRange.Value, getLength());
|
||||||
|
|
||||||
|
flipPositionIfRequired(ref pos);
|
||||||
|
|
||||||
|
switch (scrollingInfo.Direction.Value)
|
||||||
|
{
|
||||||
|
case ScrollingDirection.Up:
|
||||||
|
case ScrollingDirection.Down:
|
||||||
|
return ToScreenSpace(new Vector2(getBreadth() / 2, pos));
|
||||||
|
|
||||||
|
default:
|
||||||
|
return ToScreenSpace(new Vector2(pos, getBreadth() / 2));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private float getLength()
|
||||||
|
{
|
||||||
|
switch (scrollingInfo.Direction.Value)
|
||||||
|
{
|
||||||
|
case ScrollingDirection.Left:
|
||||||
|
case ScrollingDirection.Right:
|
||||||
|
return DrawWidth;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return DrawHeight;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private float getBreadth()
|
||||||
|
{
|
||||||
|
switch (scrollingInfo.Direction.Value)
|
||||||
|
{
|
||||||
|
case ScrollingDirection.Up:
|
||||||
|
case ScrollingDirection.Down:
|
||||||
|
return DrawWidth;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return DrawHeight;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void flipPositionIfRequired(ref float position)
|
||||||
|
{
|
||||||
|
// 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.
|
||||||
|
|
||||||
|
switch (scrollingInfo.Direction.Value)
|
||||||
|
{
|
||||||
|
case ScrollingDirection.Down:
|
||||||
|
position = DrawHeight - position;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ScrollingDirection.Right:
|
||||||
|
position = DrawWidth - position;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void onDefaultsApplied(DrawableHitObject drawableObject)
|
private void onDefaultsApplied(DrawableHitObject drawableObject)
|
||||||
{
|
{
|
||||||
// The cache may not exist if the hitobject state hasn't been computed yet (e.g. if the hitobject was added + defaults applied in the same frame).
|
// The cache may not exist if the hitobject state hasn't been computed yet (e.g. if the hitobject was added + defaults applied in the same frame).
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Game.Rulesets.Objects.Drawables;
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
|
using osuTK;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.UI.Scrolling
|
namespace osu.Game.Rulesets.UI.Scrolling
|
||||||
{
|
{
|
||||||
@ -23,6 +24,18 @@ namespace osu.Game.Rulesets.UI.Scrolling
|
|||||||
Direction.BindTo(ScrollingInfo.Direction);
|
Direction.BindTo(ScrollingInfo.Direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Given a position in screen space, return the time within this column.
|
||||||
|
/// </summary>
|
||||||
|
public virtual double TimeAtScreenSpacePosition(Vector2 screenSpacePosition) =>
|
||||||
|
((ScrollingHitObjectContainer)HitObjectContainer).TimeAtScreenSpacePosition(screenSpacePosition);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Given a time, return the screen space position within this column.
|
||||||
|
/// </summary>
|
||||||
|
public virtual Vector2 ScreenSpacePositionAtTime(double time)
|
||||||
|
=> ((ScrollingHitObjectContainer)HitObjectContainer).ScreenSpacePositionAtTime(time);
|
||||||
|
|
||||||
protected sealed override HitObjectContainer CreateHitObjectContainer() => new ScrollingHitObjectContainer();
|
protected sealed override HitObjectContainer CreateHitObjectContainer() => new ScrollingHitObjectContainer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user