Apply some simple fixes

This commit is contained in:
smoogipoo
2018-11-19 17:59:52 +09:00
parent 4dec2d1db0
commit 52309465eb

View File

@ -4,7 +4,6 @@
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Input.Events; 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;
@ -13,7 +12,7 @@ using OpenTK;
namespace osu.Game.Rulesets.Mania.Edit.Blueprints namespace osu.Game.Rulesets.Mania.Edit.Blueprints
{ {
public class ManiaPlacementBlueprint<T> : PlacementBlueprint public abstract class ManiaPlacementBlueprint<T> : PlacementBlueprint
where T : ManiaHitObject where T : ManiaHitObject
{ {
protected new T HitObject => (T)base.HitObject; protected new T HitObject => (T)base.HitObject;
@ -29,7 +28,7 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
[Resolved] [Resolved]
private IScrollingInfo scrollingInfo { get; set; } private IScrollingInfo scrollingInfo { get; set; }
public ManiaPlacementBlueprint(T hitObject) protected ManiaPlacementBlueprint(T hitObject)
: base(hitObject) : base(hitObject)
{ {
RelativeSizeAxes = Axes.None; RelativeSizeAxes = Axes.None;
@ -37,27 +36,17 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
protected override bool OnMouseMove(MouseMoveEvent e) protected override bool OnMouseMove(MouseMoveEvent e)
{ {
updateSnappedPosition(e); Column column = ColumnAt(e.ScreenSpaceMousePosition);
return true; if (column == null)
} SnappedMousePosition = e.MousePosition;
else
private ScheduledDelegate scheduledSnappedPositionUpdate;
private void updateSnappedPosition(MouseMoveEvent e)
{
scheduledSnappedPositionUpdate?.Cancel();
scheduledSnappedPositionUpdate = Schedule(() =>
{ {
Column column = ColumnAt(e.ScreenSpaceMousePosition); // Snap to the column
if (column == null) var parentPos = Parent.ToLocalSpace(column.ToScreenSpace(new Vector2(column.DrawWidth / 2, 0)));
SnappedMousePosition = e.MousePosition; SnappedMousePosition = new Vector2(parentPos.X, e.MousePosition.Y);
else }
{
// Snap to the column return true;
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)