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

Simplify logic with new multi-grid snap support

This commit is contained in:
Dean Herbert 2022-10-25 14:22:28 +09:00
parent 2b850694fa
commit 2f0283e4d4
2 changed files with 18 additions and 45 deletions

View File

@ -103,25 +103,16 @@ namespace osu.Game.Rulesets.Catch.Edit
base.OnKeyUp(e);
}
private TernaryState? distanceSnapBeforeMomentary;
private bool distanceSnapMomentary;
private void handleToggleViaKey(KeyboardEvent key)
{
if (key.AltPressed)
bool altPressed = key.AltPressed;
if (altPressed != distanceSnapMomentary)
{
if (distanceSnapBeforeMomentary == null)
{
distanceSnapBeforeMomentary = distanceSnapToggle.Value;
distanceSnapToggle.Value = distanceSnapToggle.Value == TernaryState.False ? TernaryState.True : TernaryState.False;
}
}
else
{
if (distanceSnapBeforeMomentary != null)
{
distanceSnapToggle.Value = distanceSnapBeforeMomentary.Value;
distanceSnapBeforeMomentary = null;
}
distanceSnapMomentary = altPressed;
distanceSnapToggle.Value = distanceSnapToggle.Value == TernaryState.False ? TernaryState.True : TernaryState.False;
}
}

View File

@ -247,43 +247,25 @@ namespace osu.Game.Rulesets.Osu.Edit
return base.AdjustDistanceSpacing(action, amount);
}
private TernaryState? gridSnapBeforeMomentary;
private TernaryState? distanceSnapBeforeMomentary;
private bool distanceSnapMomentary;
private bool gridSnapMomentary;
private void handleToggleViaKey(KeyboardEvent key)
{
if (key.ShiftPressed)
bool altPressed = key.AltPressed;
if (altPressed != distanceSnapMomentary)
{
if (distanceSnapBeforeMomentary == null && gridSnapBeforeMomentary == null)
{
gridSnapBeforeMomentary = rectangularGridSnapToggle.Value;
rectangularGridSnapToggle.Value = rectangularGridSnapToggle.Value == TernaryState.False ? TernaryState.True : TernaryState.False;
}
}
else
{
if (gridSnapBeforeMomentary != null)
{
rectangularGridSnapToggle.Value = gridSnapBeforeMomentary.Value;
gridSnapBeforeMomentary = null;
}
distanceSnapMomentary = altPressed;
distanceSnapToggle.Value = distanceSnapToggle.Value == TernaryState.False ? TernaryState.True : TernaryState.False;
}
if (key.AltPressed)
bool shiftPressed = key.ShiftPressed;
if (shiftPressed != gridSnapMomentary)
{
if (gridSnapBeforeMomentary == null && distanceSnapBeforeMomentary == null)
{
distanceSnapBeforeMomentary = distanceSnapToggle.Value;
distanceSnapToggle.Value = distanceSnapToggle.Value == TernaryState.False ? TernaryState.True : TernaryState.False;
}
}
else
{
if (distanceSnapBeforeMomentary != null)
{
distanceSnapToggle.Value = distanceSnapBeforeMomentary.Value;
distanceSnapBeforeMomentary = null;
}
gridSnapMomentary = shiftPressed;
rectangularGridSnapToggle.Value = rectangularGridSnapToggle.Value == TernaryState.False ? TernaryState.True : TernaryState.False;
}
}