mirror of
https://github.com/osukey/osukey.git
synced 2025-05-09 23:57:18 +09:00
Snap placement blueprint to columns
This commit is contained in:
parent
3d8ef97e81
commit
25101ecd2c
@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Input.Events;
|
||||||
|
using osu.Framework.Threading;
|
||||||
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.UI;
|
using osu.Game.Rulesets.Mania.UI;
|
||||||
@ -16,6 +18,11 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
|||||||
{
|
{
|
||||||
protected new T HitObject => (T)base.HitObject;
|
protected new T HitObject => (T)base.HitObject;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The current mouse position, snapped to the closest column.
|
||||||
|
/// </summary>
|
||||||
|
protected Vector2 SnappedMousePosition { get; private set; }
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private IManiaHitObjectComposer composer { get; set; }
|
private IManiaHitObjectComposer composer { get; set; }
|
||||||
|
|
||||||
@ -28,6 +35,31 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
|||||||
RelativeSizeAxes = Axes.None;
|
RelativeSizeAxes = Axes.None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override bool OnMouseMove(MouseMoveEvent e)
|
||||||
|
{
|
||||||
|
updateSnappedPosition(e);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ScheduledDelegate scheduledSnappedPositionUpdate;
|
||||||
|
|
||||||
|
private void updateSnappedPosition(MouseMoveEvent e)
|
||||||
|
{
|
||||||
|
scheduledSnappedPositionUpdate?.Cancel();
|
||||||
|
scheduledSnappedPositionUpdate = Schedule(() =>
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
protected double TimeAt(Vector2 screenSpacePosition)
|
protected double TimeAt(Vector2 screenSpacePosition)
|
||||||
{
|
{
|
||||||
var column = ColumnAt(screenSpacePosition);
|
var column = ColumnAt(screenSpacePosition);
|
||||||
|
@ -22,10 +22,11 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
|||||||
InternalChild = new EditNotePiece { RelativeSizeAxes = Axes.X };
|
InternalChild = new EditNotePiece { RelativeSizeAxes = Axes.X };
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnMouseMove(MouseMoveEvent e)
|
protected override void Update()
|
||||||
{
|
{
|
||||||
Position = e.MousePosition;
|
base.Update();
|
||||||
return true;
|
|
||||||
|
Position = SnappedMousePosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnClick(ClickEvent e)
|
protected override bool OnClick(ClickEvent e)
|
||||||
|
@ -13,6 +13,7 @@ using osu.Framework.Input.Bindings;
|
|||||||
using osu.Game.Rulesets.Judgements;
|
using osu.Game.Rulesets.Judgements;
|
||||||
using osu.Game.Rulesets.Mania.UI.Components;
|
using osu.Game.Rulesets.Mania.UI.Components;
|
||||||
using osu.Game.Rulesets.UI.Scrolling;
|
using osu.Game.Rulesets.UI.Scrolling;
|
||||||
|
using OpenTK;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Mania.UI
|
namespace osu.Game.Rulesets.Mania.UI
|
||||||
{
|
{
|
||||||
@ -172,5 +173,9 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
}
|
}
|
||||||
|
|
||||||
public bool OnReleased(ManiaAction action) => false;
|
public bool OnReleased(ManiaAction action) => false;
|
||||||
|
|
||||||
|
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
|
||||||
|
=> DrawRectangle.Inflate(new Vector2(1, 0)).Contains(ToLocalSpace(screenSpacePos));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user