1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-15 07:22:55 +08:00

Merge pull request #18082 from frenzibyte/beatmap-selection-keybinding

Add key binding for beatmap selection in song select
This commit is contained in:
Dean Herbert 2022-05-05 20:14:16 +09:00 committed by GitHub
commit 85dd49cdb0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 27 additions and 22 deletions

View File

@ -59,6 +59,9 @@ namespace osu.Game.Input.Bindings
new KeyBinding(InputKey.Up, GlobalAction.SelectPrevious), new KeyBinding(InputKey.Up, GlobalAction.SelectPrevious),
new KeyBinding(InputKey.Down, GlobalAction.SelectNext), new KeyBinding(InputKey.Down, GlobalAction.SelectNext),
new KeyBinding(InputKey.Left, GlobalAction.SelectPreviousGroup),
new KeyBinding(InputKey.Right, GlobalAction.SelectNextGroup),
new KeyBinding(InputKey.Space, GlobalAction.Select), new KeyBinding(InputKey.Space, GlobalAction.Select),
new KeyBinding(InputKey.Enter, GlobalAction.Select), new KeyBinding(InputKey.Enter, GlobalAction.Select),
new KeyBinding(InputKey.KeypadEnter, GlobalAction.Select), new KeyBinding(InputKey.KeypadEnter, GlobalAction.Select),
@ -105,7 +108,7 @@ namespace osu.Game.Input.Bindings
new KeyBinding(InputKey.F1, GlobalAction.ToggleModSelection), new KeyBinding(InputKey.F1, GlobalAction.ToggleModSelection),
new KeyBinding(InputKey.F2, GlobalAction.SelectNextRandom), new KeyBinding(InputKey.F2, GlobalAction.SelectNextRandom),
new KeyBinding(new[] { InputKey.Shift, InputKey.F2 }, GlobalAction.SelectPreviousRandom), new KeyBinding(new[] { InputKey.Shift, InputKey.F2 }, GlobalAction.SelectPreviousRandom),
new KeyBinding(InputKey.F3, GlobalAction.ToggleBeatmapOptions) new KeyBinding(InputKey.F3, GlobalAction.ToggleBeatmapOptions),
}; };
public IEnumerable<KeyBinding> AudioControlKeyBindings => new[] public IEnumerable<KeyBinding> AudioControlKeyBindings => new[]
@ -309,5 +312,11 @@ namespace osu.Game.Input.Bindings
[LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.EditorDecreaseDistanceSpacing))] [LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.EditorDecreaseDistanceSpacing))]
EditorDecreaseDistanceSpacing, EditorDecreaseDistanceSpacing,
[LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.SelectPreviousGroup))]
SelectPreviousGroup,
[LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.SelectNextGroup))]
SelectNextGroup,
} }
} }

View File

@ -129,6 +129,16 @@ namespace osu.Game.Localisation
/// </summary> /// </summary>
public static LocalisableString SelectNext => new TranslatableString(getKey(@"select_next"), @"Next selection"); public static LocalisableString SelectNext => new TranslatableString(getKey(@"select_next"), @"Next selection");
/// <summary>
/// "Select previous group"
/// </summary>
public static LocalisableString SelectPreviousGroup => new TranslatableString(getKey(@"select_previous_group"), @"Select previous group");
/// <summary>
/// "Select next group"
/// </summary>
public static LocalisableString SelectNextGroup => new TranslatableString(getKey(@"select_next_group"), @"Select next group");
/// <summary> /// <summary>
/// "Home" /// "Home"
/// </summary> /// </summary>

View File

@ -372,12 +372,12 @@ namespace osu.Game.Overlays.Volume
switch (e.Action) switch (e.Action)
{ {
case GlobalAction.SelectPrevious: case GlobalAction.SelectPreviousGroup:
State = SelectionState.Selected; State = SelectionState.Selected;
adjust(1, false); adjust(1, false);
return true; return true;
case GlobalAction.SelectNext: case GlobalAction.SelectNextGroup:
State = SelectionState.Selected; State = SelectionState.Selected;
adjust(-1, false); adjust(-1, false);
return true; return true;

View File

@ -604,34 +604,20 @@ namespace osu.Game.Screens.Select
public void ScrollToSelected(bool immediate = false) => public void ScrollToSelected(bool immediate = false) =>
pendingScrollOperation = immediate ? PendingScrollOperation.Immediate : PendingScrollOperation.Standard; pendingScrollOperation = immediate ? PendingScrollOperation.Immediate : PendingScrollOperation.Standard;
#region Key / button selection logic #region Button selection logic
protected override bool OnKeyDown(KeyDownEvent e)
{
switch (e.Key)
{
case Key.Left:
SelectNext(-1);
return true;
case Key.Right:
SelectNext();
return true;
}
return false;
}
public bool OnPressed(KeyBindingPressEvent<GlobalAction> e) public bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
{ {
switch (e.Action) switch (e.Action)
{ {
case GlobalAction.SelectNext: case GlobalAction.SelectNext:
SelectNext(1, false); case GlobalAction.SelectNextGroup:
SelectNext(1, e.Action == GlobalAction.SelectNextGroup);
return true; return true;
case GlobalAction.SelectPrevious: case GlobalAction.SelectPrevious:
SelectNext(-1, false); case GlobalAction.SelectPreviousGroup:
SelectNext(-1, e.Action == GlobalAction.SelectPreviousGroup);
return true; return true;
} }