Merge branch 'note-placement' into inter-column-movements

# Conflicts:
#	osu.Game.Rulesets.Mania/Edit/ManiaHitObjectComposer.cs
This commit is contained in:
smoogipoo
2018-11-26 11:47:22 +09:00
7 changed files with 49 additions and 36 deletions

View File

@ -4,16 +4,16 @@
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Input.Events;
using osu.Framework.Threading;
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Mania.Objects;
using osu.Game.Rulesets.Mania.Objects.Drawables.Pieces;
using osu.Game.Rulesets.Mania.UI;
using osu.Game.Rulesets.UI.Scrolling;
using OpenTK;
using osuTK;
namespace osu.Game.Rulesets.Mania.Edit.Blueprints
{
public class ManiaPlacementBlueprint<T> : PlacementBlueprint
public abstract class ManiaPlacementBlueprint<T> : PlacementBlueprint
where T : ManiaHitObject
{
protected new T HitObject => (T)base.HitObject;
@ -23,13 +23,18 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
/// </summary>
protected Vector2 SnappedMousePosition { get; private set; }
/// <summary>
/// The width of the closest column to the current mouse position.
/// </summary>
protected float SnappedWidth { get; private set; }
[Resolved]
private IManiaHitObjectComposer composer { get; set; }
[Resolved]
private IScrollingInfo scrollingInfo { get; set; }
public ManiaPlacementBlueprint(T hitObject)
protected ManiaPlacementBlueprint(T hitObject)
: base(hitObject)
{
RelativeSizeAxes = Axes.None;
@ -37,27 +42,20 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
protected override bool OnMouseMove(MouseMoveEvent e)
{
updateSnappedPosition(e);
return true;
}
Column column = ColumnAt(e.ScreenSpaceMousePosition);
private ScheduledDelegate scheduledSnappedPositionUpdate;
private void updateSnappedPosition(MouseMoveEvent e)
{
scheduledSnappedPositionUpdate?.Cancel();
scheduledSnappedPositionUpdate = Schedule(() =>
if (column == null)
SnappedMousePosition = e.MousePosition;
else
{
Column column = ColumnAt(e.ScreenSpaceMousePosition);
if (column == null)
SnappedMousePosition = e.MousePosition;
else
{
// Snap to the column
var parentPos = Parent.ToLocalSpace(column.ToScreenSpace(new Vector2(column.DrawWidth / 2, 0)));
SnappedMousePosition = new Vector2(parentPos.X, e.MousePosition.Y);
}
});
SnappedWidth = column.DrawWidth;
// Snap to the column
var parentPos = Parent.ToLocalSpace(column.ToScreenSpace(new Vector2(column.DrawWidth / 2, 0)));
SnappedMousePosition = new Vector2(parentPos.X, e.MousePosition.Y);
}
return true;
}
protected double TimeAt(Vector2 screenSpacePosition)
@ -88,10 +86,10 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
switch (scrollingInfo.Direction.Value)
{
case ScrollingDirection.Up:
position.Y -= DrawHeight / 2;
position.Y -= NotePiece.NOTE_HEIGHT / 2;
break;
case ScrollingDirection.Down:
position.Y += DrawHeight / 2;
position.Y += NotePiece.NOTE_HEIGHT / 2;
break;
}

View File

@ -17,7 +17,6 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
Origin = Anchor.Centre;
AutoSizeAxes = Axes.Y;
Width = 45;
InternalChild = new EditNotePiece { RelativeSizeAxes = Axes.X };
}
@ -26,6 +25,7 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
{
base.Update();
Width = SnappedWidth;
Position = SnappedMousePosition;
}