mirror of
https://github.com/osukey/osukey.git
synced 2025-05-22 22:17:36 +09: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.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using JetBrains.Annotations;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
@ -306,18 +307,18 @@ namespace osu.Game.Screens.Ranking
|
|||||||
if (expandedPanel == null)
|
if (expandedPanel == null)
|
||||||
return base.OnKeyDown(e);
|
return base.OnKeyDown(e);
|
||||||
|
|
||||||
var expandedPanelIndex = flow.GetPanelIndex(expandedPanel.Score);
|
|
||||||
|
|
||||||
switch (e.Key)
|
switch (e.Key)
|
||||||
{
|
{
|
||||||
case Key.Left:
|
case Key.Left:
|
||||||
if (expandedPanelIndex > 0)
|
var previousScore = flow.GetPreviousScore(expandedPanel.Score);
|
||||||
SelectedScore.Value = flow.Children[expandedPanelIndex - 1].Panel.Score;
|
if (previousScore != null)
|
||||||
|
SelectedScore.Value = previousScore;
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case Key.Right:
|
case Key.Right:
|
||||||
if (expandedPanelIndex < flow.Count - 1)
|
var nextScore = flow.GetNextScore(expandedPanel.Score);
|
||||||
SelectedScore.Value = flow.Children[expandedPanelIndex + 1].Panel.Score;
|
if (nextScore != null)
|
||||||
|
SelectedScore.Value = nextScore;
|
||||||
return true;
|
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();
|
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>()
|
private IEnumerable<ScorePanelTrackingContainer> applySorting(IEnumerable<Drawable> drawables) => drawables.OfType<ScorePanelTrackingContainer>()
|
||||||
.OrderByDescending(GetLayoutPosition)
|
.OrderByDescending(GetLayoutPosition)
|
||||||
.ThenBy(s => s.Panel.Score.OnlineScoreID);
|
.ThenBy(s => s.Panel.Score.OnlineScoreID);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user