diff --git a/osu.Game/Input/Bindings/GlobalActionContainer.cs b/osu.Game/Input/Bindings/GlobalActionContainer.cs index 5656c79975..3e7051cbf5 100644 --- a/osu.Game/Input/Bindings/GlobalActionContainer.cs +++ b/osu.Game/Input/Bindings/GlobalActionContainer.cs @@ -79,7 +79,8 @@ namespace osu.Game.Input.Bindings new KeyBinding(new[] { InputKey.F5 }, GlobalAction.EditorTestGameplay), new KeyBinding(new[] { InputKey.Control, InputKey.H }, GlobalAction.EditorFlipHorizontally), new KeyBinding(new[] { InputKey.Control, InputKey.J }, GlobalAction.EditorFlipVertically), - new KeyBinding(new[] { InputKey.Control, InputKey.Alt }, GlobalAction.EditorDistanceSpacing), + new KeyBinding(new[] { InputKey.Control, InputKey.Alt, InputKey.MouseWheelDown }, GlobalAction.EditorDecreaseDistanceSpacing), + new KeyBinding(new[] { InputKey.Control, InputKey.Alt, InputKey.MouseWheelUp }, GlobalAction.EditorIncreaseDistanceSpacing), }; public IEnumerable InGameKeyBindings => new[] @@ -303,7 +304,10 @@ namespace osu.Game.Input.Bindings [LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.EditorFlipVertically))] EditorFlipVertically, - [LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.EditorDistanceSpacing))] - EditorDistanceSpacing, + [LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.EditorIncreaseDistanceSpacing))] + EditorIncreaseDistanceSpacing, + + [LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.EditorDecreaseDistanceSpacing))] + EditorDecreaseDistanceSpacing, } } diff --git a/osu.Game/Localisation/GlobalActionKeyBindingStrings.cs b/osu.Game/Localisation/GlobalActionKeyBindingStrings.cs index 73cc7546ab..5086e7f4c7 100644 --- a/osu.Game/Localisation/GlobalActionKeyBindingStrings.cs +++ b/osu.Game/Localisation/GlobalActionKeyBindingStrings.cs @@ -240,9 +240,14 @@ namespace osu.Game.Localisation public static LocalisableString EditorFlipVertically => new TranslatableString(getKey(@"editor_flip_vertically"), @"Flip selection vertically"); /// - /// "Distance grid spacing (hold)" + /// "Increase distance grid spacing" /// - public static LocalisableString EditorDistanceSpacing => new TranslatableString(getKey(@"editor_distance_spacing"), @"Distance grid spacing (hold)"); + public static LocalisableString EditorIncreaseDistanceSpacing => new TranslatableString(getKey(@"editor_increase_distance_spacing"), @"Increase distance grid spacing"); + + /// + /// "Decrease distance grid spacing" + /// + public static LocalisableString EditorDecreaseDistanceSpacing => new TranslatableString(getKey(@"editor_decrease_distance_spacing"), @"Decrease distance grid spacing"); /// /// "Toggle skin editor" diff --git a/osu.Game/Rulesets/Edit/DistancedHitObjectComposer.cs b/osu.Game/Rulesets/Edit/DistancedHitObjectComposer.cs index 1a4ea845d0..e6bc36622f 100644 --- a/osu.Game/Rulesets/Edit/DistancedHitObjectComposer.cs +++ b/osu.Game/Rulesets/Edit/DistancedHitObjectComposer.cs @@ -20,7 +20,7 @@ namespace osu.Game.Rulesets.Edit /// /// The base type of supported objects. [Cached(typeof(IDistanceSnapProvider))] - public abstract class DistancedHitObjectComposer : HitObjectComposer, IDistanceSnapProvider, IKeyBindingHandler + public abstract class DistancedHitObjectComposer : HitObjectComposer, IDistanceSnapProvider, IScrollBindingHandler where TObject : HitObject { protected Bindable DistanceSpacingMultiplier { get; } = new BindableDouble(1.0) @@ -35,7 +35,6 @@ namespace osu.Game.Rulesets.Edit protected ExpandingToolboxContainer RightSideToolboxContainer { get; private set; } private ExpandableSlider> distanceSpacingSlider; - private bool distanceSpacingScrollActive; protected DistancedHitObjectComposer(Ruleset ruleset) : base(ruleset) @@ -79,11 +78,11 @@ namespace osu.Game.Rulesets.Edit public bool OnPressed(KeyBindingPressEvent e) { - if (!DistanceSpacingMultiplier.Disabled && e.Action == GlobalAction.EditorDistanceSpacing) + switch (e.Action) { - RightSideToolboxContainer.Expanded.Value = true; - distanceSpacingScrollActive = true; - return true; + case GlobalAction.EditorIncreaseDistanceSpacing: + case GlobalAction.EditorDecreaseDistanceSpacing: + return adjustDistanceSpacing(e.Action, 0.1f); } return false; @@ -91,22 +90,31 @@ namespace osu.Game.Rulesets.Edit public void OnReleased(KeyBindingReleaseEvent e) { - if (!DistanceSpacingMultiplier.Disabled && e.Action == GlobalAction.EditorDistanceSpacing) - { - RightSideToolboxContainer.Expanded.Value = false; - distanceSpacingScrollActive = false; - } } - protected override bool OnScroll(ScrollEvent e) + public bool OnScroll(KeyBindingScrollEvent e) { - if (distanceSpacingScrollActive) + switch (e.Action) { - DistanceSpacingMultiplier.Value += e.ScrollDelta.Y * (e.IsPrecise ? 0.01f : 0.1f); - return true; + case GlobalAction.EditorIncreaseDistanceSpacing: + case GlobalAction.EditorDecreaseDistanceSpacing: + return adjustDistanceSpacing(e.Action, e.IsPrecise ? 0.01f : 0.1f); } - return base.OnScroll(e); + return false; + } + + private bool adjustDistanceSpacing(GlobalAction action, float amount) + { + if (DistanceSpacingMultiplier.Disabled) + return false; + + if (action == GlobalAction.EditorIncreaseDistanceSpacing) + DistanceSpacingMultiplier.Value += amount; + else if (action == GlobalAction.EditorDecreaseDistanceSpacing) + DistanceSpacingMultiplier.Value -= amount; + + return true; } public virtual float GetBeatSnapDistanceAt(HitObject referenceObject)