mirror of
https://github.com/ppy/osu.git
synced 2025-01-06 06:53:21 +08:00
Add ability to navigate song select carousel using arrow keys.
This commit is contained in:
parent
10de34930b
commit
21f993d149
@ -1,19 +1,21 @@
|
|||||||
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using osu.Framework.Caching;
|
using osu.Framework.Caching;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Transformations;
|
using osu.Framework.Graphics.Transformations;
|
||||||
using osu.Game.Database;
|
using osu.Game.Database;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||||
using osu.Framework.Lists;
|
using osu.Framework.Lists;
|
||||||
using osu.Game.Beatmaps.Drawables;
|
using osu.Game.Beatmaps.Drawables;
|
||||||
using osu.Framework.Timing;
|
using osu.Framework.Timing;
|
||||||
|
using osu.Framework.Input;
|
||||||
|
using OpenTK.Input;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Select
|
namespace osu.Game.Screens.Select
|
||||||
{
|
{
|
||||||
@ -244,5 +246,47 @@ namespace osu.Game.Screens.Select
|
|||||||
updatePanel(p, halfHeight);
|
updatePanel(p, halfHeight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
|
||||||
|
{
|
||||||
|
int direction = 0;
|
||||||
|
bool skipDifficulties = false;
|
||||||
|
|
||||||
|
switch (args.Key)
|
||||||
|
{
|
||||||
|
case Key.Up:
|
||||||
|
direction = -1;
|
||||||
|
break;
|
||||||
|
case Key.Down:
|
||||||
|
direction = 1;
|
||||||
|
break;
|
||||||
|
case Key.Left:
|
||||||
|
direction = -1;
|
||||||
|
skipDifficulties = true;
|
||||||
|
break;
|
||||||
|
case Key.Right:
|
||||||
|
direction = 1;
|
||||||
|
skipDifficulties = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (direction != 0)
|
||||||
|
{
|
||||||
|
int index = SelectedGroup.BeatmapPanels.IndexOf(SelectedPanel) + direction;
|
||||||
|
|
||||||
|
if (!skipDifficulties && index >= 0 && index < SelectedGroup.BeatmapPanels.Count)
|
||||||
|
//changing difficulty panel, not set.
|
||||||
|
SelectGroup(SelectedGroup, SelectedGroup.BeatmapPanels[index]);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
index = (groups.IndexOf(SelectedGroup) + direction + groups.Count) % groups.Count;
|
||||||
|
SelectBeatmap(groups[index].BeatmapPanels.First().Beatmap);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return base.OnKeyDown(state, args);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user