mirror of
https://github.com/osukey/osukey.git
synced 2025-07-03 01:09:57 +09:00
Add SelectNext and SelectPrevious global actions
This commit is contained in:
@ -16,15 +16,17 @@ using osu.Framework.Bindables;
|
||||
using osu.Framework.Caching;
|
||||
using osu.Framework.Threading;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.Cursor;
|
||||
using osu.Game.Input.Bindings;
|
||||
using osu.Game.Screens.Select.Carousel;
|
||||
|
||||
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_bottom = Footer.HEIGHT;
|
||||
@ -435,41 +437,38 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
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)
|
||||
{
|
||||
case Key.Up:
|
||||
direction = -1;
|
||||
break;
|
||||
|
||||
case Key.Down:
|
||||
direction = 1;
|
||||
break;
|
||||
|
||||
case Key.Left:
|
||||
direction = -1;
|
||||
skipDifficulties = true;
|
||||
break;
|
||||
SelectNext(-1, true);
|
||||
return true;
|
||||
|
||||
case Key.Right:
|
||||
direction = 1;
|
||||
skipDifficulties = true;
|
||||
break;
|
||||
SelectNext(1, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (direction == 0)
|
||||
return base.OnKeyDown(e);
|
||||
return false;
|
||||
}
|
||||
|
||||
SelectNext(direction, skipDifficulties);
|
||||
return true;
|
||||
public bool OnPressed(GlobalAction action)
|
||||
{
|
||||
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()
|
||||
|
Reference in New Issue
Block a user