@@ -1611,7 +1611,11 @@ class APAdvancedSettingsState extends MusicBeatState
16111611
16121612 function adjustSongLimit ()
16131613 {
1614- var maxSongs = calculateMaxAvailableSongs ();
1614+ // First save current settings and regenerate song list to get accurate count
1615+ saveCurrentSettings ();
1616+ APSettingsSubState .generateSongList ();
1617+ var maxSongs = Std .int (Math .max (5 , APSettingsSubState .globalSongList .length ));
1618+
16151619 openSliderControl (" Song Limit" , songLimit , 5 , maxSongs , 1 , function (value : Float )
16161620 {
16171621 songLimit = Std .int (value );
@@ -1993,39 +1997,34 @@ class APAdvancedSettingsState extends MusicBeatState
19931997
19941998 function updateSongStats ()
19951999 {
1996- // Calculate song counts and stats
1997- var totalSongs = 0 ;
2000+ // First save the current settings so the song list generation can use them
2001+ saveCurrentSettings ();
2002+
2003+ // Regenerate the song list with current settings
2004+ APSettingsSubState .generateSongList ();
2005+
2006+ // Calculate song counts and stats using the actual generated list
2007+ var totalSongs = APSettingsSubState .globalSongList .length ;
19982008 var totalChecks = 0 ;
19992009 var modCount = backend. Mods .parseList ().enabled .length ;
20002010
2001- // Base game songs
2011+ // Calculate base song count from actual included categories
2012+ var baseSongCount = 0 ;
20022013 if (includeVanilla )
20032014 {
2004- totalSongs + = APInfo .baseGame .length ;
2015+ baseSongCount + = APInfo .baseGame .length ;
20052016 }
2006-
2007- // Secret songs
20082017 if (includePico )
20092018 {
2010- totalSongs + = APInfo .basePico .length ;
2019+ baseSongCount + = APInfo .basePico .length ;
20112020 }
2012-
2013- // Secret songs
20142021 if (includeErect )
20152022 {
2016- totalSongs + = APInfo .baseErect .length ;
2023+ baseSongCount + = APInfo .baseErect .length ;
20172024 }
2018-
2019- // Secret songs
20202025 if (includeSecrets )
20212026 {
2022- totalSongs + = APInfo .secrets .length ;
2023- }
2024-
2025- // Mod songs (approximate)
2026- if (allowMods )
2027- {
2028- totalSongs + = modCount * 3 ; // Rough estimate
2027+ baseSongCount + = APInfo .secrets .length ;
20292028 }
20302029
20312030 // Calculate checks based on unlock method
@@ -2048,7 +2047,8 @@ class APAdvancedSettingsState extends MusicBeatState
20482047 }
20492048
20502049 var statsString = " === CURRENT STATS ===\n\n " ;
2051- statsString + = " Available Songs: " + totalSongs + " \n " ;
2050+ statsString + = " Total Songs Generated: " + totalSongs + " \n " ;
2051+ statsString + = " Base Songs Included: " + baseSongCount + " \n " ;
20522052 statsString + = " Song Limit: " + songLimit + " \n " ;
20532053 statsString + = " Expected Checks: " + totalChecks + " \n " ;
20542054 statsString + = " Trap Items: " + trapAmount + " \n " ;
@@ -2374,6 +2374,15 @@ class APAdvancedSettingsState extends MusicBeatState
23742374 {
23752375 APSettingsSubState .generateSongList ();
23762376 checks ++ ;
2377+ if (checks >= 20 )
2378+ {
2379+ openSubState (new InfoPanelSubstate (
2380+ " YAML Export Error" ,
2381+ " No songs were found within the allowed time. Check to make sure your settings permit songs to be selected." ,
2382+ FlxColor .RED
2383+ ));
2384+ return ;
2385+ }
23772386 }
23782387 APEntryState .gameSettings .FNF .songList = APSettingsSubState .globalSongList ;
23792388
@@ -2384,6 +2393,15 @@ class APAdvancedSettingsState extends MusicBeatState
23842393 APSettingsSubState .generateSongList ();
23852394 checks ++ ;
23862395 APEntryState .gameSettings .FNF .songList = APSettingsSubState .globalSongList ;
2396+ if (checks >= 20 )
2397+ {
2398+ openSubState (new InfoPanelSubstate (
2399+ " YAML Export Error" ,
2400+ " No songs were found within the allowed time. Check to make sure your settings permit songs to be selected." ,
2401+ FlxColor .RED
2402+ ));
2403+ return ;
2404+ }
23872405 }
23882406 }
23892407
@@ -3330,6 +3348,114 @@ class APAdvancedSettingsState extends MusicBeatState
33303348 return Std .int (Math .max (5 , total ));
33313349 }
33323350
3351+ /**
3352+ * Test function to validate that song filtering is working correctly
3353+ * Call this in the console to test the filtering functionality
3354+ */
3355+ public static function testSongFiltering (): Void
3356+ {
3357+ trace (" === TESTING SONG FILTERING ===" );
3358+
3359+ // Store original settings
3360+ var originalSettings = null ;
3361+ if (APEntryState .gameSettings != null && APEntryState .gameSettings .FNF != null ) {
3362+ var settings = APEntryState .gameSettings .FNF ;
3363+ originalSettings = {
3364+ include_vanilla : Reflect .hasField (settings , " include_vanilla" ) ? settings .include_vanilla : true ,
3365+ include_erect : Reflect .hasField (settings , " include_erect" ) ? settings .include_erect : true ,
3366+ include_pico : Reflect .hasField (settings , " include_pico" ) ? settings .include_pico : true ,
3367+ include_secrets : Reflect .hasField (settings , " include_secrets" ) ? settings .include_secrets : true ,
3368+ mods_enabled : settings .mods_enabled
3369+ };
3370+ }
3371+
3372+ // Initialize settings if they don't exist
3373+ if (APEntryState .gameSettings == null ) {
3374+ trace (" Warning: APEntryState.gameSettings is null - cannot test filtering" );
3375+ return ;
3376+ }
3377+ if (APEntryState .gameSettings .FNF == null ) {
3378+ trace (" Warning: APEntryState.gameSettings.FNF is null - cannot test filtering" );
3379+ return ;
3380+ }
3381+
3382+ var settings = APEntryState .gameSettings .FNF ;
3383+
3384+ // Test 1: Only Vanilla songs
3385+ trace (" Test 1: Only Vanilla songs" );
3386+ settings .include_vanilla = true ;
3387+ settings .include_erect = false ;
3388+ settings .include_pico = false ;
3389+ settings .include_secrets = false ;
3390+ settings .mods_enabled = false ;
3391+ APSettingsSubState .generateSongList ();
3392+ trace (" Expected: " + APInfo .baseGame .length + " songs, Generated: " + APSettingsSubState .globalSongList .length );
3393+
3394+ // Test 2: Only Erect songs
3395+ trace (" Test 2: Only Erect songs" );
3396+ settings .include_vanilla = false ;
3397+ settings .include_erect = true ;
3398+ settings .include_pico = false ;
3399+ settings .include_secrets = false ;
3400+ settings .mods_enabled = false ;
3401+ APSettingsSubState .generateSongList ();
3402+ trace (" Expected: " + APInfo .baseErect .length + " songs, Generated: " + APSettingsSubState .globalSongList .length );
3403+
3404+ // Test 3: Only Pico songs
3405+ trace (" Test 3: Only Pico songs" );
3406+ settings .include_vanilla = false ;
3407+ settings .include_erect = false ;
3408+ settings .include_pico = true ;
3409+ settings .include_secrets = false ;
3410+ settings .mods_enabled = false ;
3411+ APSettingsSubState .generateSongList ();
3412+ trace (" Expected: " + APInfo .basePico .length + " songs, Generated: " + APSettingsSubState .globalSongList .length );
3413+
3414+ // Test 4: Only Secrets
3415+ trace (" Test 4: Only Secrets" );
3416+ settings .include_vanilla = false ;
3417+ settings .include_erect = false ;
3418+ settings .include_pico = false ;
3419+ settings .include_secrets = true ;
3420+ settings .mods_enabled = false ;
3421+ APSettingsSubState .generateSongList ();
3422+ trace (" Expected: " + APInfo .secrets .length + " songs, Generated: " + APSettingsSubState .globalSongList .length );
3423+
3424+ // Test 5: All base content
3425+ trace (" Test 5: All base content" );
3426+ settings .include_vanilla = true ;
3427+ settings .include_erect = true ;
3428+ settings .include_pico = true ;
3429+ settings .include_secrets = true ;
3430+ settings .mods_enabled = false ;
3431+ APSettingsSubState .generateSongList ();
3432+ var expectedTotal = APInfo .baseGame .length + APInfo .baseErect .length + APInfo .basePico .length + APInfo .secrets .length ;
3433+ trace (" Expected: " + expectedTotal + " songs, Generated: " + APSettingsSubState .globalSongList .length );
3434+
3435+ // Test 6: Nothing included (should have 0 base songs, but might have mods)
3436+ trace (" Test 6: Nothing included" );
3437+ settings .include_vanilla = false ;
3438+ settings .include_erect = false ;
3439+ settings .include_pico = false ;
3440+ settings .include_secrets = false ;
3441+ settings .mods_enabled = false ;
3442+ APSettingsSubState .generateSongList ();
3443+ trace (" Expected: 0 base songs, Generated: " + APSettingsSubState .globalSongList .length );
3444+
3445+ // Restore original settings
3446+ if (originalSettings != null ) {
3447+ trace (" Restoring original settings..." );
3448+ settings .include_vanilla = originalSettings .include_vanilla ;
3449+ settings .include_erect = originalSettings .include_erect ;
3450+ settings .include_pico = originalSettings .include_pico ;
3451+ settings .include_secrets = originalSettings .include_secrets ;
3452+ settings .mods_enabled = originalSettings .mods_enabled ;
3453+ APSettingsSubState .generateSongList ();
3454+ }
3455+
3456+ trace (" === SONG FILTERING TEST COMPLETE ===" );
3457+ }
3458+
33333459 public static function restoreFromTemp (): APAdvancedSettingsState
33343460 {
33353461 var state = new APAdvancedSettingsState ();
0 commit comments