1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 00:47:24 +08:00

Add key binding for beatmap selection in song select

This commit is contained in:
Salman Ahmed 2022-05-04 03:52:10 +03:00
parent 533574e3d0
commit d52a1a5d23
3 changed files with 24 additions and 20 deletions

View File

@ -100,10 +100,12 @@ namespace osu.Game.Input.Bindings
public IEnumerable<KeyBinding> SongSelectKeyBindings => new[]
{
new KeyBinding(InputKey.Left, GlobalAction.SelectPreviousBeatmap),
new KeyBinding(InputKey.Right, GlobalAction.SelectNextBeatmap),
new KeyBinding(InputKey.F1, GlobalAction.ToggleModSelection),
new KeyBinding(InputKey.F2, GlobalAction.SelectNextRandom),
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[]
@ -301,5 +303,11 @@ namespace osu.Game.Input.Bindings
[LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.EditorFlipVertically))]
EditorFlipVertically,
[LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.SelectPreviousBeatmap))]
SelectPreviousBeatmap,
[LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.SelectNextBeatmap))]
SelectNextBeatmap,
}
}

View File

@ -194,6 +194,16 @@ namespace osu.Game.Localisation
/// </summary>
public static LocalisableString ToggleInGameInterface => new TranslatableString(getKey(@"toggle_in_game_interface"), @"Toggle in-game interface");
/// <summary>
/// "Previous beatmap selection"
/// </summary>
public static LocalisableString SelectPreviousBeatmap => new TranslatableString(getKey(@"select_previous_beatmap"), @"Previous beatmap selection");
/// <summary>
/// "Next beatmap selection"
/// </summary>
public static LocalisableString SelectNextBeatmap => new TranslatableString(getKey(@"select_next_beatmap"), @"Next beatmap selection");
/// <summary>
/// "Toggle Mod Select"
/// </summary>

View File

@ -604,34 +604,20 @@ namespace osu.Game.Screens.Select
public void ScrollToSelected(bool immediate = false) =>
pendingScrollOperation = immediate ? PendingScrollOperation.Immediate : PendingScrollOperation.Standard;
#region Key / 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;
}
#region Button selection logic
public bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
{
switch (e.Action)
{
case GlobalAction.SelectNext:
SelectNext(1, false);
case GlobalAction.SelectNextBeatmap:
SelectNext(1, e.Action == GlobalAction.SelectNextBeatmap);
return true;
case GlobalAction.SelectPrevious:
SelectNext(-1, false);
case GlobalAction.SelectPreviousBeatmap:
SelectNext(-1, e.Action == GlobalAction.SelectPreviousBeatmap);
return true;
}