Skip to content

Commit 1022bf9

Browse files
committed
e
1 parent ca3d9fa commit 1022bf9

File tree

4 files changed

+193
-27
lines changed

4 files changed

+193
-27
lines changed

source/archipelago/APAdvancedSettingsState.hx

Lines changed: 147 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -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();

source/archipelago/APSettingsSubState.hx

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,50 @@ class APSettingsSubState extends MusicBeatSubstate {
5050
var dim:FlxSprite;
5151

5252
public static function generateSongList() {
53-
globalSongList = APInfo.baseGame.concat(APInfo.baseErect).concat(APInfo.basePico).concat(APInfo.secrets);
53+
// Initialize with empty array and add song categories based on settings
54+
globalSongList = [];
55+
56+
// Check if the filtering settings exist, if not default to including everything
57+
var includeVanilla = true;
58+
var includeErect = true;
59+
var includePico = true;
60+
var includeSecrets = true;
61+
62+
// Try to get the filtering settings from the game settings
63+
if (APEntryState.gameSettings != null && APEntryState.gameSettings.FNF != null) {
64+
var settings = APEntryState.gameSettings.FNF;
65+
66+
// Use the settings if they exist, otherwise default to true
67+
if (Reflect.hasField(settings, "include_vanilla")) {
68+
includeVanilla = settings.include_vanilla;
69+
}
70+
if (Reflect.hasField(settings, "include_erect")) {
71+
includeErect = settings.include_erect;
72+
}
73+
if (Reflect.hasField(settings, "include_pico")) {
74+
includePico = settings.include_pico;
75+
}
76+
if (Reflect.hasField(settings, "include_secrets")) {
77+
includeSecrets = settings.include_secrets;
78+
}
79+
}
80+
81+
// Add song categories based on settings
82+
if (includeVanilla) {
83+
globalSongList = globalSongList.concat(APInfo.baseGame);
84+
}
85+
if (includeErect) {
86+
globalSongList = globalSongList.concat(APInfo.baseErect);
87+
}
88+
if (includePico) {
89+
globalSongList = globalSongList.concat(APInfo.basePico);
90+
}
91+
if (includeSecrets) {
92+
globalSongList = globalSongList.concat(APInfo.secrets);
93+
}
94+
95+
trace('Song filtering applied: Vanilla=$includeVanilla, Erect=$includeErect, Pico=$includePico, Secrets=$includeSecrets');
96+
trace('Base songs added to list: ${globalSongList.length} songs');
5497

5598
var tempSongList:Map<String, Bool> = new Map();
5699
// trace("Mods present: " + Mods.parseList().enabled);

source/archipelago/CustomAPLogic.hx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ class APHScriptContext {
260260
case PERCENT: "PERCENT";
261261
case STRING: "STRING";
262262
case KEYBIND: "KEYBIND";
263+
case LABEL: "LABEL";
263264
}
264265
}
265266

@@ -958,7 +959,7 @@ class APHScriptProcessor {
958959
if (modSaveData != null) {
959960
// The save data contains the raw values, but we need to access them like Option objects do
960961
// Copy the save data directly - these are the actual setting values
961-
if (Std.isOfType(modSaveData, Map)) {
962+
if (modSaveData.isMap()) {
962963
var modMap:Map<String, Dynamic> = cast modSaveData;
963964
for (key in modMap.keys()) {
964965
settings.set(key, modMap.get(key));

source/states/PlayState.hx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2604,10 +2604,6 @@ class PlayState extends MusicBeatState
26042604
insert(members.indexOf(dadGroup2) + 1, obj);
26052605
}
26062606

2607-
public function addAboveGF(obj:FlxBasic)
2608-
{
2609-
insert(members.indexOf(gfGroup) + 1, obj);
2610-
}
26112607

26122608
public function addNoteToField(note:Note, ?field:Int = 0)
26132609
{

0 commit comments

Comments
 (0)