Skip to content

Commit 3ab819f

Browse files
committed
k
1 parent 1605478 commit 3ab819f

File tree

3 files changed

+90
-97
lines changed

3 files changed

+90
-97
lines changed

source/managers/FreeplayManager.hx

Lines changed: 36 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -99,17 +99,6 @@ class FreeplayManager {
9999
for (i in 0...WeekData.weeksList.length) {
100100
if(weekIsLocked(WeekData.weeksList[i]) && !APEntryState.inArchipelagoMode) continue;
101101
var leWeek:WeekData = WeekData.weeksLoaded.get(WeekData.weeksList[i]);
102-
var leSongs:Array<String> = [];
103-
var leChars:Array<String> = [];
104-
105-
for (j in 0...leWeek.songs.length)
106-
{
107-
leSongs.push(leWeek.songs[j][0]);
108-
leChars.push(leWeek.songs[j][1]);
109-
}
110-
111-
// trace("CurUnlocked: " + curUnlocked);
112-
// trace("CurMissing: " + curMissing);
113102

114103
function nullIfEmptyArray<T>(array:Array<T>):Null<Array<T>> {
115104
if (array == null || array.length == 0) {
@@ -645,43 +634,47 @@ class FreeplayManager {
645634
}
646635

647636
public static function checkSongStatus() {
648-
for (i in 0...songList.length)
649-
{
650-
var songName:String = '';
651-
var modName:String = '';
652-
var locationId:Array<Int> = [];
653-
var isMissing:Bool = false;
654-
var color:FlxColor = 0xFFFFFFFF;
655-
var someLocationsNotMissing:Bool = false;
656-
657-
if (APEntryState.inArchipelagoMode) {
658-
songName = songList[i].songName;
659-
modName = WeekData.weeksLoaded.get(WeekData.weeksList[songList[i].week]).folder;
660-
locationId = APEntryState.apGame.locationData(songName, modName).concat(APEntryState.apGame.noteData(songName, modName));
661-
isMissing = [for (ID in locationId) APEntryState.apGame.isLocationMissing(APEntryState.apGame.info().get_location_name(ID))].indexOf(true) != -1 || locationId.length == 0;
662-
color = isMissing ? FlxColor.RED : FlxColor.GREEN;
663-
664-
665-
someLocationsNotMissing = isMissing && [for (ID in locationId) APEntryState.apGame.isLocationMissing(APEntryState.apGame.info().get_location_name(ID))].contains(false);
666-
667-
for (songObj in curUnlocked)
668-
{
669-
if (((songName.trim().toLowerCase().replace('-', ' ') == songObj.song.trim().toLowerCase().replace('-', ' ')) && modName == songObj.mod) && isMissing) {
670-
color = someLocationsNotMissing ? FlxColor.GRAY : FlxColor.WHITE;
671-
unplayedList.push(songName);
637+
for (i in 0...WeekData.weeksList.length) {
638+
var leWeek:WeekData = WeekData.weeksLoaded.get(WeekData.weeksList[i]);
639+
WeekData.setDirectoryFromWeek(leWeek);
640+
for (song in leWeek.songs)
641+
{
642+
var songName:String = '';
643+
var modName:String = '';
644+
var locationId:Array<Int> = [];
645+
var isMissing:Bool = false;
646+
var color:FlxColor = 0xFFFFFFFF;
647+
var someLocationsNotMissing:Bool = false;
648+
649+
if (APEntryState.inArchipelagoMode) {
650+
songName = song;
651+
modName = leWeek.folder;
652+
locationId = APEntryState.apGame.locationData(songName, modName).concat(APEntryState.apGame.noteData(songName, modName));
653+
isMissing = [for (ID in locationId) APEntryState.apGame.isLocationMissing(APEntryState.apGame.info().get_location_name(ID))].indexOf(true) != -1 || locationId.length == 0;
654+
color = isMissing ? FlxColor.RED : FlxColor.GREEN;
655+
656+
657+
someLocationsNotMissing = isMissing && [for (ID in locationId) APEntryState.apGame.isLocationMissing(APEntryState.apGame.info().get_location_name(ID))].contains(false);
658+
659+
for (songObj in curUnlocked)
660+
{
661+
if (((songName.trim().toLowerCase().replace('-', ' ') == songObj.song.trim().toLowerCase().replace('-', ' ')) && modName == songObj.mod) && isMissing) {
662+
color = someLocationsNotMissing ? FlxColor.GRAY : FlxColor.WHITE;
663+
unplayedList.push(songName);
664+
}
672665
}
673-
}
674666

675-
if (!unplayedList.contains(songName) && isMissing) {
676-
trueMissing.push(songName);
667+
if (!unplayedList.contains(songName) && isMissing) {
668+
trueMissing.push(songName);
669+
}
677670
}
678-
}
679671

680-
FreeplayManager.callVictory = FreeplayManager.isVictorySong(songName, modName) && !isMissing && !someLocationsNotMissing;
672+
FreeplayManager.callVictory = FreeplayManager.isVictorySong(songName, modName) && !isMissing && !someLocationsNotMissing;
681673

682-
if (FreeplayManager.callVictory) {
683-
trace("Apparently, the victory song has been cleared, so... Goaling!");
684-
APEntryState.apGame.checkGoal(songName, modName);
674+
if (FreeplayManager.callVictory) {
675+
trace("Apparently, the victory song has been cleared, so... Goaling!");
676+
APEntryState.apGame.checkGoal(songName, modName);
677+
}
685678
}
686679
}
687680
}

source/states/freeplay/FreeplayState.hx

Lines changed: 18 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -440,25 +440,27 @@ class FreeplayState extends MusicBeatState
440440
}
441441

442442
// trace (curUnlocked);
443-
443+
FreeplayManager.checkSongStatus();
444444
for (i in 0...WeekData.weeksList.length) {
445+
var leWeek:WeekData = WeekData.weeksLoaded.get(WeekData.weeksList[i]);
446+
WeekData.setDirectoryFromWeek(leWeek);
445447
for (i in 0...FreeplayManager.songList.length)
446448
{
447449
var songName:String = '';
448450
var modName:String = '';
449451
var isMissing:Bool = false;
452+
var locationId:Array<Int> = [];
450453
var color:FlxColor = 0xFFFFFFFF;
451454
var someLocationsNotMissing:Bool = false;
452455

453-
songName = songList[i].songName;
454-
modName = WeekData.weeksLoaded.get(WeekData.weeksList[songList[i].week]).folder;
456+
songName = FreeplayManager.songList[i].songName;
457+
modName = leWeek.folder;
458+
if (APEntryState.inArchipelagoMode) locationId = APEntryState.apGame.locationData(songName, modName).concat(APEntryState.apGame.noteData(songName, modName));
459+
isMissing = [for (ID in locationId) APEntryState.apGame.isLocationMissing(APEntryState.apGame.info().get_location_name(ID))].indexOf(true) != -1 || locationId.length == 0;
460+
color = isMissing ? FlxColor.RED : FlxColor.GREEN;
461+
455462

456463
var songText:Alphabet = null;
457-
// for (locId in locationId) {
458-
// // trace("Location ID: " + locId + " Location Name -> " + APEntryState.apGame.info().get_location_name(locId));
459-
// }
460-
// trace("Song Name: " + songName + " Mod Name: " + modName + " Missing: " + isMissing);
461-
462464
if (APEntryState.inArchipelagoMode) {
463465
var isBronze:Bool = FlxG.random.bool(50); // Randomly decide between orange and bronze
464466
var bronzeOrOrangeColor:Int = isBronze ? 0xFFCD7F32 : 0xFFFFA500; // Bronze or Orange color
@@ -483,37 +485,20 @@ class FreeplayState extends MusicBeatState
483485
APEntryState.apGame.checkGoal(songName, modName);
484486
}
485487

486-
// // Potential Emergency For Later.
487-
488-
// if (callVictory && !APEntryState.apGame.info().clientStatus != archipelago.PacketTypes.ClientStatus.GOAL)
489-
// {
490-
// trace("Apparently, AP didn't get the memo. Forcing goal...");
491-
// APEntryState.apGame.setGoal();
492-
// }
493-
494488
songText.scaleX = Math.min(1, 980 / songText.width);
495489
songText.snapToPosition();
496490

497491
Mods.currentModDirectory = FreeplayManager.songList[i].folder;
498492

499-
// too laggy with a lot of songs, so i had to recode the logic for it
500493
songText.visible = songText.active = songText.isMenuItem = false;
501494

502495
var isLock:Bool = APEntryState.inArchipelagoMode && CategoryState.loadWeekForce == "all" && isMissing && !FreeplayManager.unplayedList.contains(songName);
503496
var icon:HealthIcon = new HealthIcon(isLock ? "lock" : FreeplayManager.songList[i].songCharacter);
504497
icon.sprTracker = songText;
505498
icon.visible = icon.active = false;
506-
// using a FlxGroup is too much fuss!
507-
// but over on mixtape engine we do arrays better
508499
iconArray.push(icon);
509500
iconList.add(icon);
510-
// }
511-
512-
// songText.x += 40;
513-
// DONT PUT X IN THE FIRST PARAMETER OF new ALPHABET() !!
514-
// songText.screenCenter(X);
515501
}
516-
WeekData.setDirectoryFromWeek();
517502
}
518503
if (FreeplayManager.songList.length == -1 || FreeplayManager.songList.length == 0)
519504
FreeplayManager.addSong('SONG NOT FOUND', -999, 'face', [[255, 255, 255], [FlxColor.fromRGB(255, 255, 255)]]);
@@ -1187,17 +1172,15 @@ class FreeplayState extends MusicBeatState
11871172

11881173
var bullShit:Int = 0;
11891174

1190-
try {
1191-
for (i in 0...iconArray.length)
1175+
for (i in 0...iconArray.length)
1176+
{
1177+
if (iconArray[i] != null && iconArray[i].animation != null && iconArray[i].animation.curAnim != null)
11921178
{
1193-
if (iconArray[i] != null && iconArray[i].animation != null)
1194-
{
1195-
iconArray[i].alpha = 0.4;
1196-
switch (iconArray[i].type) {
1197-
case SINGLE: iconArray[i].animation.curAnim.curFrame = 0;
1198-
case WINNING: iconArray[i].animation.curAnim.curFrame = 0;
1199-
default: iconArray[i].animation.curAnim.curFrame = 0;
1200-
}
1179+
iconArray[i].alpha = 0.4;
1180+
switch (iconArray[i].type) {
1181+
case SINGLE: iconArray[i].animation.curAnim.curFrame = 0;
1182+
case WINNING: iconArray[i].animation.curAnim.curFrame = 2;
1183+
default: iconArray[i].animation.curAnim.curFrame = 1;
12011184
}
12021185
}
12031186

@@ -1211,10 +1194,6 @@ class FreeplayState extends MusicBeatState
12111194
}
12121195
}
12131196
}
1214-
catch(e)
1215-
{
1216-
trace("Your icon broke! Skipping...");
1217-
}
12181197

12191198
for (item in grpSongs.members)
12201199
{

source/states/freeplay/OsuFreeplayState.hx

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -398,27 +398,16 @@ class OsuFreeplayState extends MusicBeatState
398398
if(reset)
399399
curSelected = 0;
400400

401-
//run this 100 times cause running once only removes half of the items in the group!!??
402401
songBox.clear();
403402
iconGrp.clear();
404403
textGrp.clear();
405404

406405
var trueInt:Int = 0;
407406

407+
FreeplayManager.checkSongStatus();
408+
408409
for (i in 0...FreeplayManager.songList.length)
409410
{
410-
411-
412-
var week:WeekData = WeekData.weeksLoaded.get(WeekData.weeksList[FreeplayManager.songList[i].week]);
413-
414-
var difficulties:Array<String> = Difficulty.loadFromWeek(week);
415-
416-
for (j in 0...difficulties.length)
417-
{
418-
trueInt++;
419-
420-
421-
422411
var songBox:SongBox = new SongBox(320, 100);
423412
songBox.loadGraphic(Paths.image('OSUState/bars/background2'));
424413
songBox.setGraphicSize(650, 100);
@@ -436,12 +425,44 @@ class OsuFreeplayState extends MusicBeatState
436425
catch(e) {metadata = null;}
437426

438427
var text:FlxText = new FlxText(0, 0, 500, '', 20);
439-
text.text = FreeplayManager.songList[i].songName + '\n' + difficulties[j];
428+
if (metadata != null)
429+
text.text = FreeplayManager.songList[i].songName + '\nBy ${metadata.song.artist}';
430+
else
431+
text.text = FreeplayManager.songList[i].songName + '\nBy Unknown';
440432
text.alignment = 'left';
441433
text.ID = trueInt;
442434
this.textGrp.add(text);
435+
436+
/*var week:WeekData = WeekData.weeksLoaded.get(WeekData.weeksList[FreeplayManager.songList[i].week]);
437+
Difficulty.loadFromWeek(week);
438+
439+
for (j in 0...Difficulty.list.length)
440+
{
441+
trueInt++;
442+
443+
var songBox:SongBox = new SongBox(320, 100);
444+
songBox.loadGraphic(Paths.image('OSUState/bars/background2'));
445+
songBox.setGraphicSize(650, 100);
446+
songBox.setColorTransform(-1, -1, -1, 1, FreeplayManager.songList[i].color[0][0], FreeplayManager.songList[i].color[0][1], FreeplayManager.songList[i].color[0][2], 1);
447+
songBox.ID = trueInt;
448+
songBoxParent.add(songBox);
449+
450+
var icon:HealthIcon = new HealthIcon(FreeplayManager.songList[i].songCharacter, false);
451+
icon.setPosition(320, 100);
452+
icon.ID = trueInt;
453+
icon.setGraphicSize(Std.int(icon.width / 1.7), Std.int(icon.height / 1.7));
454+
this.iconGrp.add(icon);
455+
456+
try {metadata = FreeplayManager.metadata.get(FreeplayManager.songList[i].songName.toLowerCase());}
457+
catch(e) {metadata = null;}
458+
459+
var text:FlxText = new FlxText(0, 0, 500, '', 20);
460+
text.text = FreeplayManager.songList[i].songName + '\n' + Difficulty.list[j];
461+
text.alignment = 'left';
462+
text.ID = trueInt;
463+
this.textGrp.add(text);
464+
}*/
443465
}
444-
}
445466

446467
maxSelected = songBox.length;
447468

0 commit comments

Comments
 (0)