mirror of
https://github.com/ppy/osu.git
synced 2026-05-18 06:29:52 +08:00
Add left/right keybinds to pool selector
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
@@ -13,6 +15,7 @@ using osu.Game.Online.Matchmaking;
|
||||
using osu.Game.Rulesets;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
using osuTK.Input;
|
||||
|
||||
namespace osu.Game.Screens.OnlinePlay.Matchmaking
|
||||
{
|
||||
@@ -53,6 +56,35 @@ namespace osu.Game.Screens.OnlinePlay.Matchmaking
|
||||
}, true);
|
||||
}
|
||||
|
||||
protected override bool OnKeyDown(KeyDownEvent e)
|
||||
{
|
||||
if (e.Key != Key.Left && e.Key != Key.Right)
|
||||
return false;
|
||||
|
||||
if (SelectedPool.Value == null)
|
||||
{
|
||||
SelectedPool.Value = AvailablePools.Value[0];
|
||||
return true;
|
||||
}
|
||||
|
||||
int currentPoolIndex = Array.IndexOf(AvailablePools.Value, SelectedPool.Value);
|
||||
|
||||
switch (e.Key)
|
||||
{
|
||||
case Key.Left:
|
||||
SelectedPool.Value = currentPoolIndex == 0
|
||||
? AvailablePools.Value[^1]
|
||||
: AvailablePools.Value[(currentPoolIndex - 1) % AvailablePools.Value.Length];
|
||||
break;
|
||||
|
||||
case Key.Right:
|
||||
SelectedPool.Value = AvailablePools.Value[(currentPoolIndex + 1) % AvailablePools.Value.Length];
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private partial class SelectorButton : CompositeDrawable
|
||||
{
|
||||
public readonly Bindable<MatchmakingPool?> SelectedPool = new Bindable<MatchmakingPool?>();
|
||||
|
||||
Reference in New Issue
Block a user