1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-27 11:52:54 +08:00

Add key bindings for scroll speed

Closes #2689.
- [ ] Depends on ppy/osu-framework#1569 being fixed.
This commit is contained in:
Dean Herbert 2018-05-31 12:06:50 +09:00
parent 5d103a0088
commit 7f0cb0bbf6
2 changed files with 27 additions and 17 deletions

View File

@ -45,7 +45,9 @@ namespace osu.Game.Input.Bindings
public IEnumerable<KeyBinding> InGameKeyBindings => new[] public IEnumerable<KeyBinding> InGameKeyBindings => new[]
{ {
new KeyBinding(InputKey.Space, GlobalAction.SkipCutscene), new KeyBinding(InputKey.Space, GlobalAction.SkipCutscene),
new KeyBinding(InputKey.Tilde, GlobalAction.QuickRetry) new KeyBinding(InputKey.Tilde, GlobalAction.QuickRetry),
new KeyBinding(new[] { InputKey.Control, InputKey.Plus }, GlobalAction.IncreaseScrollSpeed),
new KeyBinding(new[] { InputKey.Control, InputKey.Minus }, GlobalAction.DecreaseScrollSpeed),
}; };
protected override IEnumerable<Drawable> KeyBindingInputQueue => protected override IEnumerable<Drawable> KeyBindingInputQueue =>
@ -85,6 +87,12 @@ namespace osu.Game.Input.Bindings
ToggleGameplayMouseButtons, ToggleGameplayMouseButtons,
[Description("Go back")] [Description("Go back")]
Back Back,
[Description("Increase scroll speed")]
IncreaseScrollSpeed,
[Description("Decrease scroll speed")]
DecreaseScrollSpeed,
} }
} }

View File

@ -4,30 +4,33 @@
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Configuration; using osu.Framework.Configuration;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Input; using osu.Framework.Input.Bindings;
using osu.Game.Input.Bindings;
using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Objects.Drawables;
using OpenTK.Input;
namespace osu.Game.Rulesets.UI.Scrolling namespace osu.Game.Rulesets.UI.Scrolling
{ {
/// <summary> /// <summary>
/// A type of <see cref="Playfield"/> specialized towards scrolling <see cref="DrawableHitObject"/>s. /// A type of <see cref="Playfield"/> specialized towards scrolling <see cref="DrawableHitObject"/>s.
/// </summary> /// </summary>
public abstract class ScrollingPlayfield : Playfield public abstract class ScrollingPlayfield : Playfield, IKeyBindingHandler<GlobalAction>
{ {
/// <summary> /// <summary>
/// The default span of time visible by the length of the scrolling axes. /// The default span of time visible by the length of the scrolling axes.
/// This is clamped between <see cref="time_span_min"/> and <see cref="time_span_max"/>. /// This is clamped between <see cref="time_span_min"/> and <see cref="time_span_max"/>.
/// </summary> /// </summary>
private const double time_span_default = 1500; private const double time_span_default = 1500;
/// <summary> /// <summary>
/// The minimum span of time that may be visible by the length of the scrolling axes. /// The minimum span of time that may be visible by the length of the scrolling axes.
/// </summary> /// </summary>
private const double time_span_min = 50; private const double time_span_min = 50;
/// <summary> /// <summary>
/// The maximum span of time that may be visible by the length of the scrolling axes. /// The maximum span of time that may be visible by the length of the scrolling axes.
/// </summary> /// </summary>
private const double time_span_max = 10000; private const double time_span_max = 10000;
/// <summary> /// <summary>
/// The step increase/decrease of the span of time visible by the length of the scrolling axes. /// The step increase/decrease of the span of time visible by the length of the scrolling axes.
/// </summary> /// </summary>
@ -78,27 +81,26 @@ namespace osu.Game.Rulesets.UI.Scrolling
HitObjects.TimeRange.BindTo(VisibleTimeRange); HitObjects.TimeRange.BindTo(VisibleTimeRange);
} }
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) protected sealed override HitObjectContainer CreateHitObjectContainer() => new ScrollingHitObjectContainer(direction);
public bool OnPressed(GlobalAction action)
{ {
if (!UserScrollSpeedAdjustment) if (!UserScrollSpeedAdjustment)
return false; return false;
if (state.Keyboard.ControlPressed) switch (action)
{ {
switch (args.Key) case GlobalAction.IncreaseScrollSpeed:
{ this.TransformBindableTo(VisibleTimeRange, VisibleTimeRange - time_span_step, 200, Easing.OutQuint);
case Key.Minus: return true;
this.TransformBindableTo(VisibleTimeRange, VisibleTimeRange + time_span_step, 200, Easing.OutQuint); case GlobalAction.DecreaseScrollSpeed:
break; this.TransformBindableTo(VisibleTimeRange, VisibleTimeRange + time_span_step, 200, Easing.OutQuint);
case Key.Plus: return true;
this.TransformBindableTo(VisibleTimeRange, VisibleTimeRange - time_span_step, 200, Easing.OutQuint);
break;
}
} }
return false; return false;
} }
protected sealed override HitObjectContainer CreateHitObjectContainer() => new ScrollingHitObjectContainer(direction); public bool OnReleased(GlobalAction action) => false;
} }
} }