Skip to content

Commit 932ba3d

Browse files
authored
Merge pull request #33598 from peppy/ssv2-difficulty-traversal-selection
Allow changing difficulties using up and down arrows when sets are grouped
2 parents 4b8ac8a + b16cb1a commit 932ba3d

File tree

5 files changed

+34
-21
lines changed

5 files changed

+34
-21
lines changed

osu.Game.Tests/Visual/SongSelectV2/TestSceneBeatmapCarouselArtistGrouping.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,13 +163,17 @@ public void TestKeyboardSelection()
163163
SelectNextGroup();
164164
WaitForGroupSelection(0, 1);
165165

166+
// Difficulties should get immediate selection even when using up and down traversal.
166167
SelectNextPanel();
168+
WaitForGroupSelection(0, 2);
167169
SelectNextPanel();
170+
WaitForGroupSelection(0, 3);
171+
168172
SelectNextPanel();
169-
SelectNextPanel();
173+
WaitForGroupSelection(0, 3);
170174

171175
SelectNextGroup();
172-
WaitForGroupSelection(0, 1);
176+
WaitForGroupSelection(0, 5);
173177

174178
SelectNextPanel();
175179
SelectNextGroup();

osu.Game.Tests/Visual/SongSelectV2/TestSceneBeatmapCarouselNoGrouping.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,15 +171,9 @@ public void TestKeyboardSelection()
171171
WaitForSelection(3, 0);
172172

173173
SelectNextPanel();
174-
WaitForSelection(3, 0);
175-
176-
Select();
177174
WaitForSelection(3, 1);
178175

179176
SelectNextPanel();
180-
WaitForSelection(3, 1);
181-
182-
Select();
183177
WaitForSelection(3, 2);
184178

185179
SelectNextPanel();

osu.Game/Graphics/Carousel/Carousel.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,12 @@ protected virtual void HandleFilterCompleted()
240240
/// <returns>Whether the provided item is a valid group target. If <c>false</c>, more panels will be checked in the user's requested direction until a valid target is found.</returns>
241241
protected virtual bool CheckValidForGroupSelection(CarouselItem item) => true;
242242

243+
/// <summary>
244+
/// Keyboard selection usually does not automatically activate an item. There may be exceptions to this rule.
245+
/// Returning <c>true</c> here will make keyboard traversal act like group traversal for the target item.
246+
/// </summary>
247+
protected virtual bool ShouldActivateOnKeyboardSelection(CarouselItem item) => false;
248+
243249
/// <summary>
244250
/// Called after an item becomes the <see cref="CurrentSelection"/>.
245251
/// Should be used to handle any group expansion, item visibility changes, etc.
@@ -500,8 +506,14 @@ private void traverseKeyboardSelection(int direction)
500506

501507
if (newItem.IsVisible)
502508
{
503-
playTraversalSound();
504-
setKeyboardSelection(newItem.Model);
509+
if (!CheckModelEquality(currentSelection.Model, newItem.Model) && ShouldActivateOnKeyboardSelection(newItem))
510+
Activate(newItem);
511+
else
512+
{
513+
playTraversalSound();
514+
setKeyboardSelection(newItem.Model);
515+
}
516+
505517
return;
506518
}
507519
} while (newIndex != originalIndex);

osu.Game/Screens/SelectV2/BeatmapCarousel.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,9 @@ private void beatmapSetsChanged(object? beatmaps, NotifyCollectionChangedEventAr
208208

209209
protected BeatmapSetInfo? ExpandedBeatmapSet { get; private set; }
210210

211+
protected override bool ShouldActivateOnKeyboardSelection(CarouselItem item) =>
212+
grouping.BeatmapSetsGroupedTogether && item.Model is BeatmapInfo;
213+
211214
protected override void HandleItemActivated(CarouselItem item)
212215
{
213216
try

osu.Game/Screens/SelectV2/BeatmapLeaderboardWedge.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -201,19 +201,19 @@ private void refetchScoresFromMods()
201201

202202
private void refetchScores()
203203
{
204-
refetchOperation?.Cancel();
205-
refetchOperation = Scheduler.AddDelayed(() =>
206-
{
207-
SetScores(Array.Empty<ScoreInfo>());
204+
SetScores(Array.Empty<ScoreInfo>());
208205

209-
if (beatmap.IsDefault)
210-
{
211-
SetState(LeaderboardState.NoneSelected);
212-
return;
213-
}
206+
if (beatmap.IsDefault)
207+
{
208+
SetState(LeaderboardState.NoneSelected);
209+
return;
210+
}
214211

215-
SetState(LeaderboardState.Retrieving);
212+
SetState(LeaderboardState.Retrieving);
216213

214+
refetchOperation?.Cancel();
215+
refetchOperation = Scheduler.AddDelayed(() =>
216+
{
217217
var fetchBeatmapInfo = beatmap.Value.BeatmapInfo;
218218
var fetchRuleset = ruleset.Value ?? fetchBeatmapInfo.Ruleset;
219219

@@ -230,7 +230,7 @@ private void refetchScores()
230230
fetchedScores.BindValueChanged(_ => updateScores(), true);
231231
initialFetchComplete = true;
232232
}
233-
}, initialFetchComplete ? 200 : 0);
233+
}, initialFetchComplete ? 300 : 0);
234234
}
235235

236236
private void updateScores()

0 commit comments

Comments
 (0)