mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 05:53:10 +08:00
Add SelectNext and SelectPrevious global actions
This commit is contained in:
parent
ee73f3e2b2
commit
489bf16bea
@ -39,6 +39,9 @@ namespace osu.Game.Input.Bindings
|
|||||||
new KeyBinding(InputKey.Escape, GlobalAction.Back),
|
new KeyBinding(InputKey.Escape, GlobalAction.Back),
|
||||||
new KeyBinding(InputKey.ExtraMouseButton1, GlobalAction.Back),
|
new KeyBinding(InputKey.ExtraMouseButton1, GlobalAction.Back),
|
||||||
|
|
||||||
|
new KeyBinding(InputKey.Up, GlobalAction.SelectPrevious),
|
||||||
|
new KeyBinding(InputKey.Down, GlobalAction.SelectNext),
|
||||||
|
|
||||||
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),
|
||||||
@ -142,5 +145,11 @@ namespace osu.Game.Input.Bindings
|
|||||||
|
|
||||||
[Description("Toggle now playing overlay")]
|
[Description("Toggle now playing overlay")]
|
||||||
ToggleNowPlaying,
|
ToggleNowPlaying,
|
||||||
|
|
||||||
|
[Description("Previous Selection")]
|
||||||
|
SelectPrevious,
|
||||||
|
|
||||||
|
[Description("Next Selection")]
|
||||||
|
SelectNext,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,6 @@ using osu.Game.Graphics;
|
|||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osuTK.Input;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Input.Bindings;
|
using osu.Framework.Input.Bindings;
|
||||||
@ -204,35 +203,24 @@ namespace osu.Game.Screens.Play
|
|||||||
InternalButtons[selectionIndex].Selected.Value = true;
|
InternalButtons[selectionIndex].Selected.Value = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnKeyDown(KeyDownEvent e)
|
|
||||||
{
|
|
||||||
if (!e.Repeat)
|
|
||||||
{
|
|
||||||
switch (e.Key)
|
|
||||||
{
|
|
||||||
case Key.Up:
|
|
||||||
if (selectionIndex == -1 || selectionIndex == 0)
|
|
||||||
setSelected(InternalButtons.Count - 1);
|
|
||||||
else
|
|
||||||
setSelected(selectionIndex - 1);
|
|
||||||
return true;
|
|
||||||
|
|
||||||
case Key.Down:
|
|
||||||
if (selectionIndex == -1 || selectionIndex == InternalButtons.Count - 1)
|
|
||||||
setSelected(0);
|
|
||||||
else
|
|
||||||
setSelected(selectionIndex + 1);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return base.OnKeyDown(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool OnPressed(GlobalAction action)
|
public bool OnPressed(GlobalAction action)
|
||||||
{
|
{
|
||||||
switch (action)
|
switch (action)
|
||||||
{
|
{
|
||||||
|
case GlobalAction.SelectPrevious:
|
||||||
|
if (selectionIndex == -1 || selectionIndex == 0)
|
||||||
|
setSelected(InternalButtons.Count - 1);
|
||||||
|
else
|
||||||
|
setSelected(selectionIndex - 1);
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case GlobalAction.SelectNext:
|
||||||
|
if (selectionIndex == -1 || selectionIndex == InternalButtons.Count - 1)
|
||||||
|
setSelected(0);
|
||||||
|
else
|
||||||
|
setSelected(selectionIndex + 1);
|
||||||
|
return true;
|
||||||
|
|
||||||
case GlobalAction.Back:
|
case GlobalAction.Back:
|
||||||
BackAction.Invoke();
|
BackAction.Invoke();
|
||||||
return true;
|
return true;
|
||||||
|
@ -16,15 +16,17 @@ using osu.Framework.Bindables;
|
|||||||
using osu.Framework.Caching;
|
using osu.Framework.Caching;
|
||||||
using osu.Framework.Threading;
|
using osu.Framework.Threading;
|
||||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||||
|
using osu.Framework.Input.Bindings;
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
using osu.Game.Graphics.Cursor;
|
using osu.Game.Graphics.Cursor;
|
||||||
|
using osu.Game.Input.Bindings;
|
||||||
using osu.Game.Screens.Select.Carousel;
|
using osu.Game.Screens.Select.Carousel;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Select
|
namespace osu.Game.Screens.Select
|
||||||
{
|
{
|
||||||
public class BeatmapCarousel : CompositeDrawable
|
public class BeatmapCarousel : CompositeDrawable, IKeyBindingHandler<GlobalAction>
|
||||||
{
|
{
|
||||||
private const float bleed_top = FilterControl.HEIGHT;
|
private const float bleed_top = FilterControl.HEIGHT;
|
||||||
private const float bleed_bottom = Footer.HEIGHT;
|
private const float bleed_bottom = Footer.HEIGHT;
|
||||||
@ -435,41 +437,38 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
protected override bool OnKeyDown(KeyDownEvent e)
|
protected override bool OnKeyDown(KeyDownEvent e)
|
||||||
{
|
{
|
||||||
// allow for controlling volume when alt is held.
|
|
||||||
// this is required as the VolumeControlReceptor uses OnPressed, which is
|
|
||||||
// executed after all OnKeyDown events.
|
|
||||||
if (e.AltPressed)
|
|
||||||
return base.OnKeyDown(e);
|
|
||||||
|
|
||||||
int direction = 0;
|
|
||||||
bool skipDifficulties = false;
|
|
||||||
|
|
||||||
switch (e.Key)
|
switch (e.Key)
|
||||||
{
|
{
|
||||||
case Key.Up:
|
|
||||||
direction = -1;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case Key.Down:
|
|
||||||
direction = 1;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case Key.Left:
|
case Key.Left:
|
||||||
direction = -1;
|
SelectNext(-1, true);
|
||||||
skipDifficulties = true;
|
return true;
|
||||||
break;
|
|
||||||
|
|
||||||
case Key.Right:
|
case Key.Right:
|
||||||
direction = 1;
|
SelectNext(1, true);
|
||||||
skipDifficulties = true;
|
return true;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (direction == 0)
|
return false;
|
||||||
return base.OnKeyDown(e);
|
}
|
||||||
|
|
||||||
SelectNext(direction, skipDifficulties);
|
public bool OnPressed(GlobalAction action)
|
||||||
return true;
|
{
|
||||||
|
switch (action)
|
||||||
|
{
|
||||||
|
case GlobalAction.SelectNext:
|
||||||
|
SelectNext(1, false);
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case GlobalAction.SelectPrevious:
|
||||||
|
SelectNext(-1, false);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnReleased(GlobalAction action)
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
|
Loading…
Reference in New Issue
Block a user