mirror of
https://github.com/ppy/osu.git
synced 2025-03-14 05:47:20 +08:00
Fix incorrect keyboard navigation order in score panel list
This commit is contained in:
parent
2097889ce1
commit
8cc444df5f
@ -7,6 +7,7 @@ using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using JetBrains.Annotations;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
@ -306,18 +307,18 @@ namespace osu.Game.Screens.Ranking
|
||||
if (expandedPanel == null)
|
||||
return base.OnKeyDown(e);
|
||||
|
||||
var expandedPanelIndex = flow.GetPanelIndex(expandedPanel.Score);
|
||||
|
||||
switch (e.Key)
|
||||
{
|
||||
case Key.Left:
|
||||
if (expandedPanelIndex > 0)
|
||||
SelectedScore.Value = flow.Children[expandedPanelIndex - 1].Panel.Score;
|
||||
var previousScore = flow.GetPreviousScore(expandedPanel.Score);
|
||||
if (previousScore != null)
|
||||
SelectedScore.Value = previousScore;
|
||||
return true;
|
||||
|
||||
case Key.Right:
|
||||
if (expandedPanelIndex < flow.Count - 1)
|
||||
SelectedScore.Value = flow.Children[expandedPanelIndex + 1].Panel.Score;
|
||||
var nextScore = flow.GetNextScore(expandedPanel.Score);
|
||||
if (nextScore != null)
|
||||
SelectedScore.Value = nextScore;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -336,6 +337,12 @@ namespace osu.Game.Screens.Ranking
|
||||
|
||||
public int GetPanelIndex(ScoreInfo score) => applySorting(Children).TakeWhile(s => s.Panel.Score != score).Count();
|
||||
|
||||
[CanBeNull]
|
||||
public ScoreInfo GetPreviousScore(ScoreInfo score) => applySorting(Children).TakeWhile(s => s.Panel.Score != score).LastOrDefault()?.Panel.Score;
|
||||
|
||||
[CanBeNull]
|
||||
public ScoreInfo GetNextScore(ScoreInfo score) => applySorting(Children).SkipWhile(s => s.Panel.Score != score).ElementAtOrDefault(1)?.Panel.Score;
|
||||
|
||||
private IEnumerable<ScorePanelTrackingContainer> applySorting(IEnumerable<Drawable> drawables) => drawables.OfType<ScorePanelTrackingContainer>()
|
||||
.OrderByDescending(GetLayoutPosition)
|
||||
.ThenBy(s => s.Panel.Score.OnlineScoreID);
|
||||
|
Loading…
x
Reference in New Issue
Block a user