1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 19:22:54 +08:00

Add momentary shortcuts to toggle grid/distance snap

Matching osu!stable. I use these quite a lot while mapping and I'm sure
others do as well.

Hold `Shift` = invert grid snap
Hold `Alt` = invert distance snap
This commit is contained in:
Dean Herbert 2022-10-19 20:06:39 +09:00
parent 31f499a950
commit 830b92d3ae
2 changed files with 68 additions and 0 deletions

View File

@ -26,6 +26,7 @@ using osu.Game.Rulesets.UI;
using osu.Game.Screens.Edit.Components.TernaryButtons;
using osu.Game.Screens.Edit.Compose.Components;
using osuTK;
using osuTK.Input;
namespace osu.Game.Rulesets.Catch.Edit
{
@ -88,6 +89,36 @@ namespace osu.Game.Rulesets.Catch.Edit
updateDistanceSnapGrid();
}
protected override bool OnKeyDown(KeyDownEvent e)
{
if (e.Repeat)
return false;
if (handleToggleViaKey(e.Key))
return true;
return base.OnKeyDown(e);
}
protected override void OnKeyUp(KeyUpEvent e)
{
handleToggleViaKey(e.Key);
base.OnKeyUp(e);
}
private bool handleToggleViaKey(Key key)
{
switch (key)
{
case Key.AltLeft:
case Key.AltRight:
distanceSnapToggle.Value = distanceSnapToggle.Value == TernaryState.False ? TernaryState.True : TernaryState.False;
return true;
}
return false;
}
public override bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
{
switch (e.Action)

View File

@ -13,6 +13,7 @@ using osu.Framework.Extensions.EnumExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Input.Events;
using osu.Game.Beatmaps;
using osu.Game.Graphics.UserInterface;
using osu.Game.Rulesets.Edit;
@ -24,6 +25,7 @@ using osu.Game.Rulesets.UI;
using osu.Game.Screens.Edit.Components.TernaryButtons;
using osu.Game.Screens.Edit.Compose.Components;
using osuTK;
using osuTK.Input;
namespace osu.Game.Rulesets.Osu.Edit
{
@ -229,6 +231,41 @@ namespace osu.Game.Rulesets.Osu.Edit
}
}
protected override bool OnKeyDown(KeyDownEvent e)
{
if (e.Repeat)
return false;
if (handleToggleViaKey(e.Key))
return true;
return base.OnKeyDown(e);
}
protected override void OnKeyUp(KeyUpEvent e)
{
handleToggleViaKey(e.Key);
base.OnKeyUp(e);
}
private bool handleToggleViaKey(Key key)
{
switch (key)
{
case Key.ShiftLeft:
case Key.ShiftRight:
rectangularGridSnapToggle.Value = rectangularGridSnapToggle.Value == TernaryState.False ? TernaryState.True : TernaryState.False;
return true;
case Key.AltLeft:
case Key.AltRight:
distanceSnapToggle.Value = distanceSnapToggle.Value == TernaryState.False ? TernaryState.True : TernaryState.False;
return true;
}
return false;
}
private DistanceSnapGrid createDistanceSnapGrid(IEnumerable<HitObject> selectedHitObjects)
{
if (BlueprintContainer.CurrentTool is SpinnerCompositionTool)