Skip to content

Commit c4ebbf9

Browse files
committed
eeee
1 parent 905c5f4 commit c4ebbf9

File tree

17 files changed

+1491
-83
lines changed

17 files changed

+1491
-83
lines changed

source/Main.hx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,9 @@ class Main extends Sprite
292292
// "NativeTrace works with double quotes too!".NativeTrace(true);
293293
// testArray.NativeTrace(true, false);
294294

295+
backend.window.CppAPI.setWindowOpacity(1);
296+
297+
295298

296299
yutautil.Threader.runInThread(commandPrompt.start(), 0, "cmd", true, 0);
297300
#if HSCRIPT_ALLOWED

source/archipelago/APGameState.hx

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ class APGameState
541541
trace("No locations found for song: " + songName + " with mod: " + modName);
542542
archipelago.APItem.popup("No locations found for song: " + songName + " with mod: " + modName, "Archipelago", true);
543543
archipelago.substates.InfoPanelSubstate.show("Victory Song Missing", "No locations found for song: " + songName + " with mod: " + modName
544-
+ ".\n\nMake sure that the song is added to your game, or the mod for this song is enabled.", 0xFF0000, null);
544+
+ ".\n\nMake sure that the song is added to your game, or the mod for this song is enabled.\n\nIf it is installed correctly, this may be a false error. This is here to prevent auto-goaling from ending your run early.", 0xFF0000, null);
545545
return false;
546546
}
547547
for (location in locations)
@@ -699,7 +699,7 @@ class APGameState
699699

700700
function handleRetrievedPacket(retrievedPacket:haxe.DynamicAccess<Dynamic>):Void
701701
{
702-
//trace("Retrieved packet: " + retrievedPacket);
702+
trace("Retrieved packet: " + retrievedPacket);
703703
for (key in retrievedPacket.keys())
704704
{
705705
var value = retrievedPacket.get(key);
@@ -915,6 +915,21 @@ class APGameState
915915
var colors:Array<{name:String, color_code:String}> = _saveData.getItem("unlockedUnoColors");
916916
archipelago.APItem.unoColorsUnlocked = colors;
917917
}
918+
@:privateAccess
919+
if (_saveData.hasItem("confusionStacks"))
920+
{
921+
APItem.confusionStack = _saveData.getItem("confusionStacks");
922+
}
923+
if (_saveData.hasItem("currentMinigame"))
924+
{
925+
var minigameValue:Int = _saveData.getItem("currentMinigame");
926+
switch (minigameValue) {
927+
case 0: APInfo.inMinigame = None;
928+
case 1: APInfo.inMinigame = Uno;
929+
case 2: APInfo.inMinigame = Pong;
930+
default: APInfo.inMinigame = None;
931+
}
932+
}
918933
_saveData.save();
919934
}
920935

@@ -939,6 +954,17 @@ class APGameState
939954
_saveData.addItem("hasPocketLens", APItem.hasPocketLens);
940955
_saveData.addItem("hasDashMechanic", APItem.hasDashMechanic);
941956
_saveData.addItem("unlockedUnoColors", archipelago.APItem.unoColorsUnlocked);
957+
@:privateAccess
958+
_saveData.addItem("confusionStack", APItem.confusionStack);
959+
960+
// Save current minigame state
961+
var minigameValue:Int = switch (APInfo.inMinigame) {
962+
case None: 0;
963+
case Uno: 1;
964+
case Pong: 2;
965+
};
966+
_saveData.addItem("currentMinigame", minigameValue);
967+
942968
_saveData.save();
943969
trace("Save data updated!");
944970
}

source/archipelago/APItem.hx

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,20 @@ class APItem {
266266
t.isTrap = true;
267267
});
268268
case "Pong Challenge":
269-
return new APTrap(name, ConditionHelper.Everywhere(), function() {
269+
return new APTrap(name, ConditionHelper.Everywhere().funcAndReturn(function(c) {
270+
// Only allow if not already in a minigame
271+
c.extraConditions = [];
272+
c.extraConditions.push(function(e) {
273+
return archipelago.APInfo.inMinigame == archipelago.APInfo.APMinigame.None;
274+
});
275+
}), function() {
270276
popup('Ok but can you beat the Pong Master?', "APItem: Pong Challenge", true);
277+
278+
// Save current state before switching to minigame
279+
if (APEntryState.apGame != null) {
280+
APEntryState.apGame.updateSaveData();
281+
}
282+
271283
if (MusicBeatState.getState() == APPlayState.instance) {
272284
APPlayState.instance.paused = true;
273285
APPlayState.instance.canResync = false;
@@ -336,6 +348,12 @@ class APItem {
336348
});
337349
}), function() {
338350
popup('Win the round to survive!', "APItem: UNO Challenge", true);
351+
352+
// Save current state before switching to minigame
353+
if (APEntryState.apGame != null) {
354+
APEntryState.apGame.updateSaveData();
355+
}
356+
339357
if (MusicBeatState.getState() == APPlayState.instance) {
340358
APPlayState.instance.paused = true;
341359
APPlayState.instance.canResync = false;
@@ -1484,6 +1502,12 @@ class APItem {
14841502
case "Pong Trap":
14851503
return new APTrap(name, ConditionHelper.Everywhere(), function() {
14861504
popup('Ok but can you beat the Pong Master?', "TrapLink: Pong Trap", true);
1505+
1506+
// Save current state before switching to minigame
1507+
if (APEntryState.apGame != null) {
1508+
APEntryState.apGame.updateSaveData();
1509+
}
1510+
14871511
if (MusicBeatState.getState() == APPlayState.instance) {
14881512
APPlayState.instance.paused = true;
14891513
APPlayState.instance.canResync = false;
@@ -1849,6 +1873,12 @@ class APPongTrap extends APTrap {
18491873
var currentState = FlxG.state;
18501874
if (Std.isOfType(currentState, MusicBeatState)) {
18511875
var previousState = cast(currentState, MusicBeatState);
1876+
1877+
// Save current state before switching to minigame
1878+
if (APEntryState.apGame != null) {
1879+
APEntryState.apGame.updateSaveData();
1880+
}
1881+
18521882
activeTrapState = new archipelago.traps.games.APPongTrapState(previousState, this.difficulty);
18531883
archipelago.APInfo.inMinigame = archipelago.APInfo.APMinigame.Pong;
18541884
MusicBeatState.switchState(activeTrapState);
@@ -1883,6 +1913,12 @@ class APPongTrap extends APTrap {
18831913
var currentState = FlxG.state;
18841914
if (Std.isOfType(currentState, MusicBeatState)) {
18851915
var previousState = cast(currentState, MusicBeatState);
1916+
1917+
// Save current state before switching to minigame
1918+
if (APEntryState.apGame != null) {
1919+
APEntryState.apGame.updateSaveData();
1920+
}
1921+
18861922
activeTrapState = new archipelago.traps.games.APPongTrapState(previousState, nextDifficulty);
18871923
MusicBeatState.switchState(activeTrapState);
18881924
APItem.popup("Pong Challenge (" + getTrapDifficultyName(nextDifficulty) + ") activated from queue!");

source/archipelago/APPlayState.hx

Lines changed: 124 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import backend.Song;
44
import flixel.FlxObject;
55
import flixel.input.keyboard.FlxKey;
66
import flixel.tweens.misc.NumTween;
7+
import flixel.util.FlxColor;
78
import flixel.util.FlxDestroyUtil;
9+
import managers.FreeplayManager;
810
import objects.*;
911
import objects.Character;
1012
import objects.Note;
@@ -14,6 +16,9 @@ import openfl.filters.BlurFilter;
1416
import openfl.filters.ColorMatrixFilter;
1517
import shaders.MosaicEffect;
1618
import stages.StageData;
19+
import states.PlayState;
20+
import states.freeplay.FreeplayState;
21+
import states.freeplay.OsuFreeplayState;
1722
import streamervschat.*;
1823

1924
using yutautil.Table;
@@ -52,6 +57,9 @@ class APPlayState extends PlayState {
5257
private var lastDifficultyName:String = '';
5358
private var invulnCount:Int = 0;
5459
private var debugKeysDodge:Array<FlxKey>;
60+
61+
// Song unlock system
62+
private var songNotUnlocked:Bool = false;
5563
// private var unBlurShaderRestore:Map<Dynamic, Dynamic> = new Map<Dynamic, Dynamic>();
5664
var curDifficulty:Int = -1;
5765
var effectsActive:Map<String, Int> = new Map<String, Int>();
@@ -152,6 +160,64 @@ class APPlayState extends PlayState {
152160
allowDebugKeys = false;
153161
lives = livecount;
154162

163+
// Check if the current song/mod is unlocked; if not, set flag and show info panel
164+
if (APEntryState.inArchipelagoMode)
165+
{
166+
var found = false;
167+
for (entry in APFreeplayManager.curUnlocked)
168+
{
169+
if (entry.song == currentSong && entry.mod == currentMod)
170+
{
171+
found = true;
172+
break;
173+
}
174+
}
175+
if (!found) {
176+
songNotUnlocked = true;
177+
// Show info panel immediately
178+
showUnlockInfoPanel();
179+
return;
180+
}
181+
}
182+
183+
if (FlxG.save.data.manualOverride != null && FlxG.save.data.manualOverride)
184+
{
185+
// When manual override is active, ensure we're playing the correct saved song
186+
trace('Manual Override detected - verifying song consistency');
187+
188+
var savedSong = FlxG.save.data.SONG;
189+
var currentSong = PlayState.SONG;
190+
191+
// Check if the current song matches the saved song
192+
if (savedSong != null && currentSong != null) {
193+
var songMismatch = (savedSong.song != currentSong.song ||
194+
FlxG.save.data.storyWeek != PlayState.storyWeek ||
195+
FlxG.save.data.currentModDirectory != Mods.currentModDirectory ||
196+
FlxG.save.data.storyDifficulty != PlayState.storyDifficulty);
197+
198+
if (songMismatch) {
199+
trace('Song mismatch detected during manual override');
200+
trace('Expected: ' + savedSong.song + ' (Week: ' + FlxG.save.data.storyWeek + ', Mod: ' + FlxG.save.data.currentModDirectory + ')');
201+
trace('Current: ' + currentSong.song + ' (Week: ' + PlayState.storyWeek + ', Mod: ' + Mods.currentModDirectory + ')');
202+
203+
// Restore the correct song state and force a reset
204+
PlayState.storyWeek = FlxG.save.data.storyWeek;
205+
Mods.currentModDirectory = FlxG.save.data.currentModDirectory;
206+
Difficulty.list = FlxG.save.data.difficulties;
207+
curDifficulty = FlxG.save.data.curDifficulty;
208+
PlayState.SONG = FlxG.save.data.SONG;
209+
PlayState.storyDifficulty = FlxG.save.data.storyDifficulty;
210+
211+
212+
213+
trace('Song state corrected - resetting APPlayState');
214+
StageData.loadDirectory(PlayState.SONG);
215+
MusicBeatState.resetState();
216+
return;
217+
}
218+
}
219+
}
220+
155221
instance = this; // For traps and items
156222
if (APEntryState.inArchipelagoMode)
157223
{
@@ -187,18 +253,7 @@ class APPlayState extends PlayState {
187253
return;
188254
}
189255

190-
if (archipelago.APInfo.inMinigame != None)
191-
{
192-
switch (archipelago.APInfo.inMinigame) {
193-
case Uno:
194-
FlxG.switchState(new archipelago.traps.games.APUnoTrapState());
195-
return;
196-
case Pong:
197-
FlxG.switchState(new archipelago.traps.games.APPongTrapState());
198-
return;
199-
case None:
200-
}
201-
}
256+
202257
{
203258

204259
}
@@ -1458,6 +1513,12 @@ class APPlayState extends PlayState {
14581513

14591514
override public function startCountdown():Bool
14601515
{
1516+
// Prevent countdown if song is not unlocked
1517+
if (songNotUnlocked) {
1518+
// trace("Countdown blocked: Song not unlocked");
1519+
return false;
1520+
}
1521+
14611522
if (PlayState.SONG.player1.toLowerCase().contains('zenetta') || PlayState.SONG.player2.toLowerCase().contains('zenetta') || PlayState.SONG.gfVersion.toLowerCase().contains('zenetta'))
14621523
{
14631524
itemAmount = 69;
@@ -1570,6 +1631,27 @@ class APPlayState extends PlayState {
15701631
}
15711632
}
15721633

1634+
function showUnlockInfoPanel() {
1635+
var songDisplayName = currentSong != null && currentSong != "" ? currentSong : "this song";
1636+
var modDisplayName = currentMod != null && currentMod != "" ? " from " + currentMod : "";
1637+
1638+
var content = "You haven't unlocked " + songDisplayName + modDisplayName + " yet.\\n\\n" +
1639+
"Complete more checks in the Archipelago\\nmultiworld to unlock new songs!\\n\\n" +
1640+
"Press ESC or ENTER to return to Freeplay.";
1641+
1642+
archipelago.substates.InfoPanelSubstate.show(
1643+
"SONG LOCKED",
1644+
content,
1645+
FlxColor.RED,
1646+
returnToFreeplay
1647+
);
1648+
}
1649+
1650+
function returnToFreeplay() {
1651+
// Use FreeplayManager's built-in method to return to freeplay
1652+
FreeplayManager.openFreeplay();
1653+
}
1654+
15731655
override function destroy()
15741656
{
15751657
if (drunkTween != null && drunkTween.active)
@@ -1950,24 +2032,42 @@ class APPlayState extends PlayState {
19502032
var doRandomize:Bool = false;
19512033
override public function update(elapsed:Float)
19522034
{
2035+
2036+
if (archipelago.APInfo.inMinigame != None)
2037+
{
2038+
// Save current state before switching to minigame
2039+
if (APEntryState.apGame != null) {
2040+
APEntryState.apGame.updateSaveData();
2041+
}
2042+
2043+
switch (archipelago.APInfo.inMinigame) {
2044+
case Uno:
2045+
FlxG.switchState(new archipelago.traps.games.APUnoTrapState());
2046+
return;
2047+
case Pong:
2048+
FlxG.switchState(new archipelago.traps.games.APPongTrapState());
2049+
return;
2050+
case None:
2051+
}
2052+
}
19532053
// If Legacy Lua settings are being edited, don't allow AP PlayState during gameplay
19542054
// This prevents conflicts but doesn't interrupt mid-song
19552055
if (options.legacylua.LegacyLuaSettingsState.inLegacyLuaSettingsMode && !startedCountdown) {
19562056
// Only switch if we haven't started the song yet to avoid interrupting gameplay
1957-
FlxG.switchState(new states.PlayState());
2057+
FlxG.switchState(new PlayState());
19582058
return;
19592059
}
19602060

19612061
// If we're in Legacy Lua testing mode, switch to regular PlayState
1962-
if (states.PlayState.isLegacyLuaTest && !startedCountdown) {
1963-
FlxG.switchState(new states.PlayState());
2062+
if (PlayState.isLegacyLuaTest && !startedCountdown) {
2063+
FlxG.switchState(new PlayState());
19642064
return;
19652065
}
19662066

1967-
if (zenetta.holdTimer > Conductor.stepCrochet * 0.001 * zenetta.singDuration
1968-
&& zenetta.animation.curAnim.name.startsWith('sing')
1969-
&& !zenetta.animation.curAnim.name.endsWith('miss'))
1970-
zenetta.dance();
2067+
if (zenetta?.holdTimer > Conductor.stepCrochet * 0.001 * zenetta?.singDuration
2068+
&& zenetta?.animation.curAnim.name.startsWith('sing')
2069+
&& !zenetta?.animation.curAnim.name.endsWith('miss'))
2070+
zenetta?.dance();
19712071

19722072
// if (archipelago.APItem.activeItem is archipelago.APItem.APChartModifier && cast(archipealgo.APItem.activeItem:archipelago.APItem.APChartModifier).chartModifier != chartModifier)
19732073
//
@@ -2614,11 +2714,12 @@ class APPlayState extends PlayState {
26142714
if(note.isSustainNote)
26152715
{
26162716
var holdAnim:String = animToPlay + '-hold';
2617-
if(zenetta.animation.exists(holdAnim)) animToPlay = holdAnim;
2717+
if(zenetta?.animation.exists(holdAnim)) animToPlay = holdAnim;
26182718
}
26192719

2620-
zenetta.playAnim(animToPlay, true);
2720+
zenetta?.playAnim(animToPlay, true);
26212721
zenetta.holdTimer = 0;
2722+
"e".GoToTag();
26222723
}
26232724
}
26242725

@@ -2770,8 +2871,8 @@ class APPlayState extends PlayState {
27702871
if (releasethebeast) {
27712872
if (resistanceAmount < 1) resistanceAmount += 0.005;
27722873

2773-
if (curBeat % zenetta.danceEveryNumBeats == 0 && !zenetta.getAnimationName().endsWith('-alt')) {
2774-
zenetta.dance();
2874+
if (curBeat % zenetta?.danceEveryNumBeats == 0 && !zenetta?.getAnimationName().endsWith('-alt')) {
2875+
zenetta?.dance();
27752876
}
27762877
}
27772878
super.beatHit();

source/archipelago/APTagsManager.hx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package archipelago;
22

3+
import helder.Set;
34
import yutautil.TypeUtils.OneOrMore;
45

56
/**
@@ -80,6 +81,10 @@ class APTagsManager {
8081
if (newTags == null) newTags = [];
8182

8283
_tags = newTags.copy();
84+
85+
// Remove duplicates and trim whitespace
86+
87+
8388
syncToClient();
8489
trace('APTagsManager: Set tags to: ${_tags.join(", ")}');
8590
}

0 commit comments

Comments
 (0)