@@ -489,28 +489,32 @@ class FreeplayState extends MusicBeatState
489489 // trace("CurUnlocked: " + curUnlocked);
490490 // trace("CurMissing: " + curMissing);
491491
492+ function nullIfEmptyArray <T >(array : Array <T >): Null <Array <T >> {
493+ if (array == null || array .length == 0 ) {
494+ return null ;
495+ }
496+ return array ;
497+ }
498+
492499 WeekData .setDirectoryFromWeek (leWeek );
493500 for (song in leWeek .songs )
494501 {
495- var categoryWhaat : flixel.util.typeLimit. OneOfTwo <String , Array <String >> = null ;
496- if (leWeek .category is String )
497- {
498- categoryWhaat = leWeek .category .split (' ,' ).map (function (cat : String ): String {
502+ var categoryWhaat : Array <String > = Std .isOfType (leWeek .category , String ) ?
503+ (cast leWeek .category : String ).split (' ,' ).map (function (cat : String ): String {
499504 return cat .trim ().toLowerCase ();
500- });
501- }
502- else if (leWeek .category is Array < String > )
503- {
504- categoryWhaat = leWeek .category .map (function (cat : String ): String {
505+ }) : Std .isOfType (leWeek .category , Array ) ?
506+ (cast leWeek .category : Array <String >).map (function (cat : String ): String {
505507 return cat .trim ().toLowerCase ();
506- });
507- }
508- else
509- {
510- categoryWhaat = [leWeek .category ].map (function (cat : String ): String {
508+ }) :
509+ [(cast leWeek .category : String )].map (function (cat : String ): String {
511510 return cat .trim ().toLowerCase ();
512511 });
512+
513+ if (categoryWhaat .length == 1 && categoryWhaat [0 ] == " " || categoryWhaat .length == 0 ) {
514+ categoryWhaat = [];
513515 }
516+
517+ // trace("CategoryWhaat2: " + categoryWhaat);
514518 var colors : Array <Int > = song [2 ];
515519 if (colors == null || colors .length < 3 )
516520 {
@@ -520,7 +524,7 @@ class FreeplayState extends MusicBeatState
520524 {
521525 addSong (song [0 ], i , song [1 ], FlxColor .fromRGB (colors [0 ], colors [1 ], colors [2 ]));
522526 }
523- else if (categoryWhaat .toLowerCase () == CategoryState . loadWeekForce || (CategoryState .loadWeekForce == " mods" && categoryWhaat == null ) || (CategoryState .loadWeekForce == " all" || APEntryState .inArchipelagoMode ))
527+ else if (categoryWhaat .indexOf ( CategoryState . loadWeekForce . toLowerCase ()) != - 1 || (CategoryState .loadWeekForce == " mods" && categoryWhaat . isEmpty () ) || (CategoryState .loadWeekForce == " all" || APEntryState .inArchipelagoMode ))
524528 {
525529 if (refresh )
526530 {
@@ -582,7 +586,7 @@ class FreeplayState extends MusicBeatState
582586 }
583587
584588 }
585- else if (categoryWhaat .toLowerCase () == CategoryState . loadWeekForce || (CategoryState .loadWeekForce == " mods" && categoryWhaat == null ) || CategoryState .loadWeekForce == " all" )
589+ else if (categoryWhaat .indexOf ( CategoryState . loadWeekForce . toLowerCase ()) != - 1 || (CategoryState .loadWeekForce == " mods" && categoryWhaat . isEmpty () ) || CategoryState .loadWeekForce == " all" )
586590 {
587591 if (APEntryState .inArchipelagoMode )
588592 {
@@ -635,7 +639,7 @@ class FreeplayState extends MusicBeatState
635639 addSong (song [0 ], i , song [1 ], FlxColor .fromRGB (colors [0 ], colors [1 ], colors [2 ]));
636640 }
637641 }
638- else if (categoryWhaat .toLowerCase () == CategoryState . loadWeekForce || (CategoryState .loadWeekForce == " mods" && categoryWhaat == null ) || CategoryState .loadWeekForce == " all" )
642+ else if (categoryWhaat .indexOf ( CategoryState . loadWeekForce . toLowerCase ()) != - 1 || (CategoryState .loadWeekForce == " mods" && categoryWhaat . isEmpty () ) || CategoryState .loadWeekForce == " all" )
639643 {
640644 if (APEntryState .inArchipelagoMode )
641645 {
0 commit comments