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:
parent
2b850694fa
commit
2f0283e4d4
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user