From 2221594883afa7cd0e518fca7ea975d05626692a Mon Sep 17 00:00:00 2001 From: Eric Date: Fri, 30 May 2025 22:48:22 -0400 Subject: [PATCH] [PUBLIC PR] Press Chart Editor key in Freeplay to open that song (#1061) Co-authored-by: Lasercar --- source/funkin/ui/freeplay/FreeplayState.hx | 44 +++++++++++++++++++++- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/source/funkin/ui/freeplay/FreeplayState.hx b/source/funkin/ui/freeplay/FreeplayState.hx index ae9b7e3d6..35a170394 100644 --- a/source/funkin/ui/freeplay/FreeplayState.hx +++ b/source/funkin/ui/freeplay/FreeplayState.hx @@ -45,7 +45,8 @@ import funkin.util.HapticUtil; import funkin.util.MathUtil; import funkin.util.SortUtil; import openfl.display.BlendMode; -import openfl.filters.ShaderFilter; +import funkin.data.freeplay.style.FreeplayStyleRegistry; +import funkin.ui.debug.charting.ChartEditorState; #if FEATURE_DISCORD_RPC import funkin.api.discord.DiscordClient; #end @@ -1844,6 +1845,45 @@ class FreeplayState extends MusicBeatSubState freeplayTxtBg.x = FullScreenScaleMode.gameNotchSize.x; _pressedOnFreeplay = false; } + if (controls.DEBUG_CHART && !busy) + { + busy = true; + var targetSongID = grpCapsules.members[curSelected]?.freeplayData?.data.id ?? 'unknown'; + if (targetSongID == 'unknown') + { + trace('CHART RANDOM SONG'); + letterSort.inputEnabled = false; + + var availableSongCapsules:Array = grpCapsules.members.filter(function(cap:SongMenuItem) { + // Dead capsules are ones which were removed from the list when changing filters. + return cap.alive && cap.freeplayData != null; + }); + + trace('Available songs: ${availableSongCapsules.map(function(cap) { + return cap?.freeplayData?.data.songName; + })}'); + + if (availableSongCapsules.length == 0) + { + trace('No songs available!'); + busy = false; + letterSort.inputEnabled = true; + FunkinSound.playOnce(Paths.sound('cancelMenu')); + return; + } + + var targetSong:SongMenuItem = FlxG.random.getObject(availableSongCapsules); + + // Seeing if I can do an animation... + curSelected = grpCapsules.members.indexOf(targetSong); + changeSelection(0); + targetSongID = grpCapsules.members[curSelected]?.freeplayData?.data.id ?? 'unknown'; + } + FlxG.switchState(() -> new ChartEditorState( + { + targetSongId: targetSongID, + })); + } } #end @@ -2498,7 +2538,7 @@ class FreeplayState extends MusicBeatSubState #end } - if (grpCapsules.countLiving() > 0 && !prepForNewRank) + if (grpCapsules.countLiving() > 0 && !prepForNewRank && !busy) { playCurSongPreview(daSongCapsule); grpCapsules.members[curSelected].selected = true;