Skip to content

Commit 24d7209

Browse files
committed
Merge branch 'Archipelago' of https://github.com/Z11Coding/Mixtape-Engine-Rework into Archipelago
2 parents abf21ea + 3e64fc3 commit 24d7209

File tree

2 files changed

+63
-28
lines changed

2 files changed

+63
-28
lines changed

source/archipelago/APGameState.hx

Lines changed: 47 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -203,26 +203,24 @@ class APGameState {
203203
public static var isSync:Bool = false;
204204
function addSongs(song:Array<NetworkItem>)
205205
{
206+
states.FreeplayState.curMissing.clear();
207+
206208
for (songName in song)
207209
{
208210
var itemName = info().get_item_name(songName.item);
209211

210-
// Convert special keywords back to actual brackets
211-
itemName = itemName.replace("<cOpen>", "{")
212-
.replace("<cClose>", "}")
213-
.replace("<sOpen>", "[")
214-
.replace("<sClose>", "]");
212+
// Convert special keywords back to actual brackets
213+
itemName = itemName.replace("<cOpen>", "{")
214+
.replace("<cClose>", "}")
215+
.replace("<sOpen>", "[")
216+
.replace("<sClose>", "]");
215217

216-
217-
// trace("Item Name: " + itemName);
218218
var modName = "";
219219
var firstParenIndex = itemName.indexOf("(");
220220
var endParenIndex = itemName.lastIndexOf(")");
221221
while (firstParenIndex != -1) {
222-
// endParenIndex = itemName.lastIndexOf(")", firstParenIndex);
223222
if (endParenIndex != -1) {
224223
modName = itemName.substring(firstParenIndex + 1, endParenIndex);
225-
// trace("Mod Name: " + modName);
226224
if (isModName(modName)) {
227225
itemName = itemName.substring(0, firstParenIndex).trim();
228226
break;
@@ -237,26 +235,59 @@ class APGameState {
237235
modName = "";
238236
itemName = info().get_item_name(songName.item);
239237
}
238+
239+
var missing = false;
240+
for (missingLocation in info().missingLocations) {
241+
var locationName = info().get_location_name(missingLocation);
242+
locationName = locationName.replace("<cOpen>", "{")
243+
.replace("<cClose>", "}")
244+
.replace("<sOpen>", "[")
245+
.replace("<sClose>", "]");
246+
247+
var locationModName = "";
248+
var locationFirstParenIndex = locationName.indexOf("(");
249+
var locationEndParenIndex = locationName.lastIndexOf(")");
250+
while (locationFirstParenIndex != -1) {
251+
if (locationEndParenIndex != -1) {
252+
locationModName = locationName.substring(locationFirstParenIndex + 1, locationEndParenIndex);
253+
if (isModName(locationModName)) {
254+
locationName = locationName.substring(0, locationFirstParenIndex).trim();
255+
break;
256+
} else {
257+
locationFirstParenIndex = locationName.indexOf("(", locationFirstParenIndex + 1);
258+
}
259+
} else {
260+
break;
261+
}
262+
}
263+
if (locationFirstParenIndex == -1 || !isModName(locationModName)) {
264+
locationModName = "";
265+
locationName = info().get_location_name(missingLocation);
266+
}
267+
268+
if (locationName == itemName && locationModName == modName) {
269+
missing = true;
270+
break;
271+
}
272+
}
273+
trace("Location: " + songName.location + " Missing: " + missing);
274+
240275
if (!states.FreeplayState.curUnlocked.exists(itemName))
241276
{
242-
// trace('Item Recieved: '+itemName);
243277
if (itemName != "Unknown")
244278
{
245279
if (!isSync) ArchPopup.startPopupSong(itemName, 'archColor');
246280
states.FreeplayState.curUnlocked.set(itemName, modName);
281+
if (missing) {
282+
states.FreeplayState.curMissing.set(itemName, modName);
283+
}
247284
if (states.FreeplayState.instance != null) states.FreeplayState.instance.reloadSongs(true);
248-
// trace("Unlocked: " + itemName);
249-
// trace(states.FreeplayState.curUnlocked);
250-
// trace(song);
251285
for (song in states.FreeplayState.curUnlocked.keys())
252286
{
253287
var parts = song.split("||");
254288
var key = parts[0];
255289
var value = parts.length > 1 ? parts[1] : states.FreeplayState.curUnlocked.get(song);
256290
states.FreeplayState.curUnlocked.set(key, value);
257-
// trace("Unlocked: " + key);
258-
// trace("Mod: " + value);
259-
// trace("curUnlocked: " + states.FreeplayState.curUnlocked);
260291
}
261292
}
262293
}

source/states/FreeplayState.hx

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ class FreeplayState extends MusicBeatState
8282
var multiSongs:Array<String> = [];
8383

8484
public static var curUnlocked:Map<String, String> = new Map<String, String>();
85+
public static var curMissing:Map<String, String> = new Map<String, String>();
8586
public static var trueUnlocked:Array<String> = [];
8687
public static var doChange:Bool = false;
8788
public static var multisong:Bool = false;
@@ -520,6 +521,9 @@ class FreeplayState extends MusicBeatState
520521
leChars.push(leWeek.songs[j][1]);
521522
}
522523

524+
trace("CurUnlocked: " + curUnlocked);
525+
trace("CurMissing: " + curMissing);
526+
523527
WeekData.setDirectoryFromWeek(leWeek);
524528
for (song in leWeek.songs)
525529
{
@@ -556,9 +560,9 @@ class FreeplayState extends MusicBeatState
556560
if (APEntryState.inArchipelagoMode)
557561
{
558562
var songNameThing:String = song[0];
559-
for (songName in curUnlocked.keys())
563+
for (songName in (CategoryState.loadWeekForce == "unplayed" ? curMissing : curUnlocked).keys())
560564
{
561-
if ((songNameThing.trim().toLowerCase().replace('-', ' ') == songName.trim().toLowerCase().replace('-', ' ')) && leWeek.folder == curUnlocked.get(songName))
565+
if ((songNameThing.trim().toLowerCase().replace('-', ' ') == songName.trim().toLowerCase().replace('-', ' ')) && leWeek.folder == (CategoryState.loadWeekForce == "unplayed" ? curMissing : curUnlocked).get(songName))
562566
addSong(song[0], i, song[1], FlxColor.fromRGB(colors[0], colors[1], colors[2]));
563567
}
564568
}
@@ -568,7 +572,7 @@ class FreeplayState extends MusicBeatState
568572
}
569573
else
570574
{
571-
if (Std.string(song[0]).toLowerCase().trim().contains(searchBar.text.toLowerCase().trim()))
575+
if (Std.string(song[0]).toLowerCase().trim().contains(searchBar.text.toLowerCase().trim()))
572576
{
573577
var colors:Array<Int> = song[2];
574578
if(colors == null || colors.length < 3)
@@ -594,9 +598,9 @@ class FreeplayState extends MusicBeatState
594598
if (APEntryState.inArchipelagoMode)
595599
{
596600
var songNameThing:String = song[0];
597-
for (songName in curUnlocked.keys())
601+
for (songName in (CategoryState.loadWeekForce == "unplayed" ? curMissing : curUnlocked).keys())
598602
{
599-
if ((songNameThing.trim().toLowerCase().replace('-', ' ') == songName.trim().toLowerCase().replace('-', ' ')) && leWeek.folder == curUnlocked.get(songName))
603+
if ((songNameThing.trim().toLowerCase().replace('-', ' ') == songName.trim().toLowerCase().replace('-', ' ')) && leWeek.folder == (CategoryState.loadWeekForce == "unplayed" ? curMissing : curUnlocked).get(songName))
600604
addSong(song[0], i, song[1], FlxColor.fromRGB(colors[0], colors[1], colors[2]));
601605
}
602606
}
@@ -612,22 +616,22 @@ class FreeplayState extends MusicBeatState
612616
{
613617
if (refresh)
614618
{
615-
for (songName in curUnlocked.keys()) {
616-
if (songName.trim().toLowerCase().replace('-', ' ') == 'small argument'.trim().toLowerCase().replace('-', ' ') && curUnlocked.get(songName) == '')
619+
for (songName in (CategoryState.loadWeekForce == "unplayed" ? curMissing : curUnlocked).keys()) {
620+
if (songName.trim().toLowerCase().replace('-', ' ') == 'small argument'.trim().toLowerCase().replace('-', ' ') && (CategoryState.loadWeekForce == "unplayed" ? curMissing : curUnlocked).get(songName) == '')
617621
addSong('Small Argument', 0, "gfchibi", FlxColor.fromRGB(235, 100, 161));
618-
if (songName.trim().toLowerCase().replace('-', ' ') == 'beat battle'.trim().toLowerCase().replace('-', ' ') && curUnlocked.get(songName) == '')
622+
if (songName.trim().toLowerCase().replace('-', ' ') == 'beat battle'.trim().toLowerCase().replace('-', ' ') && (CategoryState.loadWeekForce == "unplayed" ? curMissing : curUnlocked).get(songName) == '')
619623
addSong('Beat Battle', 0, "gf", FlxColor.fromRGB(165, 0, 77));
620-
if (songName.trim().toLowerCase().replace('-', ' ') == 'beat battle 2'.trim().toLowerCase().replace('-', ' ') && curUnlocked.get(songName) == '')
624+
if (songName.trim().toLowerCase().replace('-', ' ') == 'beat battle 2'.trim().toLowerCase().replace('-', ' ') && (CategoryState.loadWeekForce == "unplayed" ? curMissing : curUnlocked).get(songName) == '')
621625
addSong('Beat Battle 2', 0, "gf", FlxColor.fromRGB(165, 0, 77));
622626
}
623627
}
624628
else
625629
{
626-
if (curUnlocked.exists('Small Argument'.toLowerCase()) && Std.string('Small Argument').toLowerCase().trim().contains(searchBar.text.toLowerCase().trim()) && FlxG.save.data.gotIntoAnArgument && (CategoryState.loadWeekForce == "secrets" || CategoryState.loadWeekForce == "all"))
630+
if ((CategoryState.loadWeekForce == "unplayed" ? curMissing : curUnlocked).exists('Small Argument'.toLowerCase()) && Std.string('Small Argument').toLowerCase().trim().contains(searchBar.text.toLowerCase().trim()) && FlxG.save.data.gotIntoAnArgument && (CategoryState.loadWeekForce == "secrets" || CategoryState.loadWeekForce == "all"))
627631
addSong('Small Argument', 0, "gfchibi", FlxColor.fromRGB(235, 100, 161));
628-
if (curUnlocked.exists('Beat Battle'.toLowerCase()) && Std.string('Beat Battle').toLowerCase().trim().contains(searchBar.text.toLowerCase().trim()) && FlxG.save.data.gotbeatbattle && (CategoryState.loadWeekForce == "secrets" || CategoryState.loadWeekForce == "all"))
632+
if ((CategoryState.loadWeekForce == "unplayed" ? curMissing : curUnlocked).exists('Beat Battle'.toLowerCase()) && Std.string('Beat Battle').toLowerCase().trim().contains(searchBar.text.toLowerCase().trim()) && FlxG.save.data.gotbeatbattle && (CategoryState.loadWeekForce == "secrets" || CategoryState.loadWeekForce == "all"))
629633
addSong('Beat Battle', 0, "gf", FlxColor.fromRGB(165, 0, 77));
630-
if (curUnlocked.exists('Beat Battle 2'.toLowerCase()) && Std.string('Beat Battle 2').toLowerCase().trim().contains(searchBar.text.toLowerCase().trim()) && FlxG.save.data.gotbeatbattle2 && (CategoryState.loadWeekForce == "secrets" || CategoryState.loadWeekForce == "all"))
634+
if ((CategoryState.loadWeekForce == "unplayed" ? curMissing : curUnlocked).exists('Beat Battle 2'.toLowerCase()) && Std.string('Beat Battle 2').toLowerCase().trim().contains(searchBar.text.toLowerCase().trim()) && FlxG.save.data.gotbeatbattle2 && (CategoryState.loadWeekForce == "secrets" || CategoryState.loadWeekForce == "all"))
631635
addSong('Beat Battle 2', 0, "gf", FlxColor.fromRGB(165, 0, 77));
632636
}
633637
}

0 commit comments

Comments
 (0)