From fb26aeb71a3cf27dca0de92986a0da4f59315c66 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Sun, 8 Dec 2024 20:12:38 -0500 Subject: [PATCH] feat: Switching sorting in Freeplay, if your currently selected song is in the next section, we move there immediately for easier navigation --- source/funkin/ui/freeplay/FreeplayState.hx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/source/funkin/ui/freeplay/FreeplayState.hx b/source/funkin/ui/freeplay/FreeplayState.hx index 91ebef25d..cdf3daa7c 100644 --- a/source/funkin/ui/freeplay/FreeplayState.hx +++ b/source/funkin/ui/freeplay/FreeplayState.hx @@ -497,6 +497,8 @@ class FreeplayState extends MusicBeatSubState // Reminder, this is a callback function being set, rather than these being called here in create() letterSort.changeSelectionCallback = (str) -> { + var curSong:Null = grpCapsules.members[curSelected]?.freeplayData; + switch (str) { case 'fav': @@ -509,9 +511,14 @@ class FreeplayState extends MusicBeatSubState generateSongList({filterType: REGEXP, filterData: str}, true); } - // We want to land on the first song of the group, rather than random song when changing letter sorts + // If the current song is still in the list (aka not null?), we'll land on it + // Otherwise we want to land on the first song of the group, rather than random song when changing letter sorts // that is, only if there's more than one song in the group! - if (grpCapsules.members.length > 0) + if (curSong != null && currentFilteredSongs.length > 1) + { + changeSelection(); + } + else if (grpCapsules.members.length > 0) { FunkinSound.playOnce(Paths.sound('scrollMenu'), 0.4); curSelected = 1;