From 88bdc12022b3bb90e4b70877450c8dc5a0b57d5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Mon, 17 Jun 2024 15:28:52 +0200 Subject: [PATCH] Add ability to cycle through available types when selecting single control point on a slider --- .../Components/PathControlPointVisualiser.cs | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/Components/PathControlPointVisualiser.cs b/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/Components/PathControlPointVisualiser.cs index 47af16ffa6..2bdef4afe8 100644 --- a/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/Components/PathControlPointVisualiser.cs +++ b/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/Components/PathControlPointVisualiser.cs @@ -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 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 piece, MouseButtonEvent e) { if (e.Button == MouseButton.Left && inputManager.CurrentState.Keyboard.ControlPressed)