1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-19 09:53:22 +08:00

add right click for abort

This commit is contained in:
OliBomby 2023-12-31 02:26:14 +01:00
parent c952e2f620
commit 7a0535a2eb

View File

@ -11,6 +11,7 @@ using osu.Game.Rulesets.Osu.Edit.Blueprints.Spinners;
using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Screens.Edit.Compose.Components; using osu.Game.Screens.Edit.Compose.Components;
using osuTK; using osuTK;
using osuTK.Input;
namespace osu.Game.Rulesets.Osu.Edit namespace osu.Game.Rulesets.Osu.Edit
{ {
@ -62,28 +63,23 @@ namespace osu.Game.Rulesets.Osu.Edit
} }
protected override bool OnMouseDown(MouseDownEvent e) protected override bool OnMouseDown(MouseDownEvent e)
{
return isPlacingGridFromPoints || base.OnMouseDown(e);
}
protected override bool OnClick(ClickEvent e)
{ {
if (!isPlacingGridFromPoints) if (!isPlacingGridFromPoints)
return base.OnClick(e); return base.OnMouseDown(e);
var pos = ToLocalSpace(Composer.FindSnappedPositionAndTime(e.ScreenSpaceMousePosition, ~SnapType.GlobalGrids).ScreenSpacePosition); var pos = snappedLocalPosition(e);
if (!gridFromPointsStart.HasValue) if (!gridFromPointsStart.HasValue)
{
gridFromPointsStart = pos; gridFromPointsStart = pos;
}
else else
{ {
gridToolbox.SetGridFromPoints(gridFromPointsStart.Value, pos); gridToolbox.SetGridFromPoints(gridFromPointsStart.Value, pos);
isPlacingGridFromPoints = false; isPlacingGridFromPoints = false;
gridFromPointsStart = null;
} }
if (e.Button == MouseButton.Right)
isPlacingGridFromPoints = false;
return true; return true;
} }
@ -92,18 +88,16 @@ namespace osu.Game.Rulesets.Osu.Edit
if (!isPlacingGridFromPoints) if (!isPlacingGridFromPoints)
return base.OnMouseMove(e); return base.OnMouseMove(e);
var pos = ToLocalSpace(Composer.FindSnappedPositionAndTime(e.ScreenSpaceMousePosition, ~SnapType.GlobalGrids).ScreenSpacePosition); var pos = snappedLocalPosition(e);
if (!gridFromPointsStart.HasValue) if (!gridFromPointsStart.HasValue)
{
gridToolbox.StartPosition.Value = pos; gridToolbox.StartPosition.Value = pos;
}
else else
{
gridToolbox.SetGridFromPoints(gridFromPointsStart.Value, pos); gridToolbox.SetGridFromPoints(gridFromPointsStart.Value, pos);
}
return true; return true;
} }
private Vector2 snappedLocalPosition(UIEvent e) => ToLocalSpace(Composer.FindSnappedPositionAndTime(e.ScreenSpaceMousePosition, ~SnapType.GlobalGrids).ScreenSpacePosition);
} }
} }