mirror of
https://github.com/ppy/osu
synced 2024-12-14 19:06:07 +00:00
Add ability to cycle through available types when selecting single control point on a slider
This commit is contained in:
parent
16ea8f67b0
commit
88bdc12022
@ -245,6 +245,43 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
||||
{
|
||||
}
|
||||
|
||||
protected override bool OnKeyDown(KeyDownEvent e)
|
||||
{
|
||||
if (e.Repeat || e.Key != Key.Tab)
|
||||
return false;
|
||||
|
||||
var selectedPieces = Pieces.Where(p => p.IsSelected.Value).ToArray();
|
||||
if (selectedPieces.Length != 1)
|
||||
return false;
|
||||
|
||||
var selectedPoint = selectedPieces.Single().ControlPoint;
|
||||
var validTypes = getValidPathTypes(selectedPoint).ToArray();
|
||||
int currentTypeIndex = Array.IndexOf(validTypes, selectedPoint.Type);
|
||||
|
||||
if (currentTypeIndex < 0 && e.ShiftPressed)
|
||||
currentTypeIndex = 0;
|
||||
|
||||
do
|
||||
{
|
||||
currentTypeIndex = (validTypes.Length + currentTypeIndex + (e.ShiftPressed ? -1 : 1)) % validTypes.Length;
|
||||
selectedPoint.Type = validTypes[currentTypeIndex];
|
||||
EnsureValidPathTypes();
|
||||
} while (selectedPoint.Type != validTypes[currentTypeIndex]);
|
||||
|
||||
return true;
|
||||
|
||||
IEnumerable<PathType?> getValidPathTypes(PathControlPoint pathControlPoint)
|
||||
{
|
||||
if (pathControlPoint != controlPoints[0])
|
||||
yield return null;
|
||||
|
||||
yield return PathType.LINEAR;
|
||||
yield return PathType.BEZIER;
|
||||
yield return PathType.PERFECT_CURVE;
|
||||
yield return PathType.BSpline(4);
|
||||
}
|
||||
}
|
||||
|
||||
private void selectionRequested(PathControlPointPiece<T> piece, MouseButtonEvent e)
|
||||
{
|
||||
if (e.Button == MouseButton.Left && inputManager.CurrentState.Keyboard.ControlPressed)
|
||||
|
Loading…
Reference in New Issue
Block a user