mirror of
https://github.com/ppy/osu.git
synced 2025-01-27 00:23:01 +08:00
Move remaining positioning logic local to hold note blueprint
This commit is contained in:
parent
2f78866dfb
commit
26fb779f4d
@ -2,11 +2,13 @@
|
|||||||
// 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 System;
|
using System;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Input.Events;
|
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;
|
||||||
|
|
||||||
@ -37,8 +39,8 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
|||||||
|
|
||||||
if (Column != null)
|
if (Column != null)
|
||||||
{
|
{
|
||||||
headPiece.Y = PositionAt(HitObject.StartTime);
|
headPiece.Y = positionAt(HitObject.StartTime);
|
||||||
tailPiece.Y = PositionAt(HitObject.EndTime);
|
tailPiece.Y = positionAt(HitObject.EndTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
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));
|
||||||
@ -84,5 +86,21 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
|||||||
originalStartTime = HitObject.StartTime = startTime;
|
originalStartTime = HitObject.StartTime = startTime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private IScrollingInfo scrollingInfo { get; set; }
|
||||||
|
|
||||||
|
private float positionAt(double time)
|
||||||
|
{
|
||||||
|
var pos = scrollingInfo.Algorithm.PositionAt(time,
|
||||||
|
EditorClock.CurrentTime,
|
||||||
|
scrollingInfo.TimeRange.Value,
|
||||||
|
Column.HitObjectContainer.DrawHeight);
|
||||||
|
|
||||||
|
if (scrollingInfo.Direction.Value == ScrollingDirection.Down)
|
||||||
|
pos = Column.HitObjectContainer.DrawHeight - pos;
|
||||||
|
|
||||||
|
return Column.HitObjectContainer.ToSpaceOfOtherDrawable(new Vector2(0, pos), Parent).Y;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,12 @@
|
|||||||
// 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.Framework.Allocation;
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Input;
|
using osu.Framework.Input;
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
using osu.Game.Rulesets.Edit;
|
using osu.Game.Rulesets.Edit;
|
||||||
using osu.Game.Rulesets.Mania.Objects;
|
using osu.Game.Rulesets.Mania.Objects;
|
||||||
using osu.Game.Rulesets.Mania.Objects.Drawables.Pieces;
|
|
||||||
using osu.Game.Rulesets.Mania.UI;
|
using osu.Game.Rulesets.Mania.UI;
|
||||||
using osu.Game.Rulesets.UI.Scrolling;
|
|
||||||
using osuTK;
|
|
||||||
using osuTK.Input;
|
using osuTK.Input;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
||||||
@ -23,9 +19,6 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
|||||||
|
|
||||||
protected Column Column;
|
protected Column Column;
|
||||||
|
|
||||||
[Resolved]
|
|
||||||
private IScrollingInfo scrollingInfo { get; set; }
|
|
||||||
|
|
||||||
protected ManiaPlacementBlueprint(T hitObject)
|
protected ManiaPlacementBlueprint(T hitObject)
|
||||||
: base(hitObject)
|
: base(hitObject)
|
||||||
{
|
{
|
||||||
@ -50,39 +43,5 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
|||||||
if (!PlacementActive)
|
if (!PlacementActive)
|
||||||
Column = (result as ManiaSnapResult)?.Column;
|
Column = (result as ManiaSnapResult)?.Column;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected float PositionAt(double time)
|
|
||||||
{
|
|
||||||
var pos = scrollingInfo.Algorithm.PositionAt(time,
|
|
||||||
EditorClock.CurrentTime,
|
|
||||||
scrollingInfo.TimeRange.Value,
|
|
||||||
Column.HitObjectContainer.DrawHeight);
|
|
||||||
|
|
||||||
if (scrollingInfo.Direction.Value == ScrollingDirection.Down)
|
|
||||||
pos = Column.HitObjectContainer.DrawHeight - pos;
|
|
||||||
|
|
||||||
return hitObjectToMousePosition(Column.HitObjectContainer.ToSpaceOfOtherDrawable(new Vector2(0, pos), Parent)).Y;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Converts a hitobject position to a mouse position.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="hitObjectPosition">The hitobject position.</param>
|
|
||||||
/// <returns>The resulting mouse position, anchored at the centre of the hitobject.</returns>
|
|
||||||
private Vector2 hitObjectToMousePosition(Vector2 hitObjectPosition)
|
|
||||||
{
|
|
||||||
switch (scrollingInfo.Direction.Value)
|
|
||||||
{
|
|
||||||
case ScrollingDirection.Up:
|
|
||||||
hitObjectPosition.Y += DefaultNotePiece.NOTE_HEIGHT / 2;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ScrollingDirection.Down:
|
|
||||||
hitObjectPosition.Y -= DefaultNotePiece.NOTE_HEIGHT / 2;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return hitObjectPosition;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user