Skip to content

Commit d4dc4e6

Browse files
committed
Beep.
1 parent 6c7e8f7 commit d4dc4e6

File tree

3 files changed

+39
-20
lines changed

3 files changed

+39
-20
lines changed

source/states/CategoryState.hx

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,24 @@ class CategoryState extends MusicBeatState
161161

162162
if (softCoded && catMode != 'Mods')
163163
for (week in weeks) {
164-
if (week.category != null && !existingCategories.contains(week.category.toLowerCase())) {
165-
menuItems.push(week.category);
164+
if (week.category != null) {
165+
if (Std.is(week.category, String)) {
166+
var category:String = cast week.category;
167+
if (!existingCategories.contains(category.toLowerCase())) {
168+
menuItems.push(category);
169+
}
170+
} else if (Std.is(week.category, Array)) {
171+
var categories:Array<String> = cast week.category;
172+
for (cat in categories) {
173+
if (!existingCategories.contains(cat.toLowerCase())) {
174+
menuItems.push(cat);
175+
}
176+
}
177+
}
166178
}
167-
}
179+
// menuItems.push(cast week.category);
180+
}
181+
168182

169183
// Remove duplicates from menuItems
170184
var filteredItems:Array<String> = [];

source/states/FreeplayState.hx

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -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
{

source/states/editors/WeekEditorState.hx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,7 @@ class WeekEditorState extends MusicBeatState implements PsychUIEventHandler.Psyc
391391
weekFile.difficulties = difficultiesInputText.text.trim();
392392
unsavedProgress = true;
393393
} else if(sender == categoryInputText) {
394+
categoryInputText.text = categoryInputText.text.replace("[", "").replace("]", "").replace("\"", "").replace("'", "");
394395
weekFile.category = categoryInputText.text.indexOf(",") != -1
395396
? categoryInputText.text.trim().split(",").map(function(item) return item.trim())
396397
: categoryInputText.text.trim();

0 commit comments

Comments
 (0)