@@ -53,10 +53,18 @@ class OsuFreeplayState extends MusicBeatState
5353 var inSub : Bool = false ;
5454
5555 var staleBg : FlxSprite ;
56- var ticketCounter : FlxText = null ;
56+ var ticketCounterTop : FlxText = null ;
57+ var ticketCounterBottom : FlxText = null ;
5758 override function create ()
5859 {
60+ #if windows
61+ backend.window. CppAPI .resetAffixes ();
62+ backend.window. CppAPI .resetTitle ();
63+ #end
64+
5965 instance = this ; // For Archipelago
66+
67+ Paths .clearStoredWithoutStickers ();
6068
6169 Cursor .cursorMode = Default ;
6270
@@ -142,11 +150,15 @@ class OsuFreeplayState extends MusicBeatState
142150 changeSong ();
143151
144152 if (APEntryState .apGame != null && APEntryState .apGame .info () != null ) {
145- ticketCounter = new FlxText (0 , FlxG .height - 630 , 0 , " 0/0" , 32 );
146- ticketCounter .setFormat (Paths .font (" fnf1.ttf" ), 32 , FlxColor .WHITE , CENTER , FlxTextBorderStyle .OUTLINE , FlxColor .BLACK );
147- ticketCounter .scrollFactor .set ();
148- ticketCounter .screenCenter (X );
149- add (ticketCounter );
153+ ticketCounterTop = new FlxText (albumPhoto .x - 130 , albumPhoto .y - 230 , 0 , " 0/0" , 32 );
154+ ticketCounterTop .setFormat (Paths .font (" fnf1.ttf" ), 32 , FlxColor .WHITE , CENTER , FlxTextBorderStyle .OUTLINE , FlxColor .BLACK );
155+ ticketCounterTop .scrollFactor .set ();
156+ add (ticketCounterTop );
157+
158+ ticketCounterBottom = new FlxText (backHitbox .x + 100 , backHitbox .y , 0 , " 0/0" , 32 );
159+ ticketCounterBottom .setFormat (Paths .font (" fnf1.ttf" ), 28 , FlxColor .WHITE , CENTER , FlxTextBorderStyle .OUTLINE , FlxColor .BLACK );
160+ ticketCounterBottom .scrollFactor .set ();
161+ add (ticketCounterBottom );
150162 new FlxTimer ().start (1 , function (tmr : FlxTimer ) {
151163 archipelago. APGameState .haventranyet = false ;
152164 });
@@ -156,6 +168,13 @@ class OsuFreeplayState extends MusicBeatState
156168 archipelago. APItem .activeItem = null ;
157169
158170 super .create ();
171+
172+ #if DISCORD_ALLOWED
173+ // Updating Discord Rich Presence
174+ DiscordClient .changePresence (" In the Menus" , null );
175+ #end
176+
177+ Mods .loadTopMod ();
159178 }
160179
161180 var holdTime : Float = 0 ;
@@ -164,9 +183,22 @@ class OsuFreeplayState extends MusicBeatState
164183 var e : Int = 0 ;
165184 override public function update (elapsed : Float )
166185 {
186+ if (WeekData .weeksList .length < 1 )
187+ {
188+ FlxTransitionableState .skipNextTransIn = true ;
189+ persistentUpdate = false ;
190+ MusicBeatState .switchState (new states. ErrorState (" NO WEEKS ADDED FOR FREEPLAY\n\n Press ACCEPT to go to the Week Editor Menu.\n Press BACK to return to Main Menu." ,
191+ function () MusicBeatState .switchState (new states.editors. WeekEditorState ()),
192+ function () MusicBeatState .switchState (new states. MainMenuState ())));
193+ return ;
194+ }
195+
167196 e ++ ;
168197 FlxG .watch .addQuick (' Search Text' , searchTypeText .text );
169198
199+ if (FlxG .sound .music .volume < 0.8 )
200+ FlxG .sound .music .volume = Math .min (FlxG .sound .music .volume + 0.5 * elapsed , 0.8 );
201+
170202 for (item in songBox )
171203 {
172204 var coolEffect : Int = 0 ;
@@ -180,9 +212,51 @@ class OsuFreeplayState extends MusicBeatState
180212 }
181213
182214 #if ARCHIPELAGO_ALLOWED
183- victoryColor = FlxColor .fromHSL (((e / 2 ) / 300 * 360 ) % 360 , 1.0 , 0.5 * 1.0 );
215+ if (APEntryState .inArchipelagoMode ) {
216+ victoryColor = FlxColor .fromHSL (((e / 2 ) / 300 * 360 ) % 360 , 1.0 , 0.5 * 1.0 );
217+
218+ for (i in 0 ... FreeplayManager .songList .length ) {
219+ if (FreeplayManager .isVictorySong (FreeplayManager .songList [i ].songName , FreeplayManager .songList [i ].folder )) {
220+ songBox .members [i ].color = victoryColor ;
221+ }
222+ }
223+
224+ if (FlxG .keys .justPressed .L && APEntryState .inArchipelagoMode && ! isTyping ) {
225+ try { // Because this menu has no actual difficulty select, just assume it's the first difficulty
226+ var songLowercase : String = Paths .formatToSongPath (FreeplayManager .songList [curSelected ].songName );
227+ var poop : String = Highscore .formatSong (songLowercase , 0 );
228+ Mods .currentModDirectory = FreeplayManager .songList [curSelected ].folder ;
229+ Song .loadFromJson (poop , songLowercase );
230+ PlayState .isStoryMode = false ;
231+ PlayState .storyDifficulty = 0 ;
232+ } catch (e : Dynamic ) {
233+ trace (' Error loading song: ' + e );
234+ }
235+ try {
236+ FreeplayManager .forceUnlockCheck (FreeplayManager .songList [curSelected ].songName , WeekData .getCurrentWeek ().folder );
237+ } catch (e : Dynamic ) {
238+ trace (" You can't check nothing, silly!" );
239+ }
240+ MusicBeatState .resetState ();
241+ }
242+
243+ if (FlxG .keys .justPressed .H && APEntryState .inArchipelagoMode && ! isTyping ) {
244+ try {
245+ var SongInfo = APEntryState .apGame .getSongAndMod (FreeplayManager .songList [curSelected ].songName + (FreeplayManager .songList [curSelected ].folder != " " ? " (" + FreeplayManager .songList [curSelected ].folder + " )" : " " ));
246+ if (APEntryState .ap != null ) {
247+ APEntryState .ap .Say (" !hint " + SongInfo .song + ((SongInfo .mod != " " && SongInfo .mod != null ) ? " (" + SongInfo .mod + " )" : " " ));
248+ archipelago.console. SideUI .instance .active = true ;
249+ }
250+ } catch (e : Dynamic ) {
251+ trace (" You can't hint nothing, silly!" );
252+ }
253+ }
254+ }
184255 #end
185256
257+ persistentUpdate = true ;
258+ PlayState .isStoryMode = false ;
259+
186260 for (icon in iconGrp )
187261 {
188262 var theY : Float = 0 ;
@@ -283,24 +357,27 @@ class OsuFreeplayState extends MusicBeatState
283357 if (FreeplayManager .isVictorySong (FreeplayManager .songList [curSelected ].songName , FreeplayManager .songList [curSelected ].folder ) && ! vicCheck ) {
284358 FlxG .camera .shake (0.005 , 0.5 );
285359 FlxG .sound .play (Paths .sound (" badnoise" + FlxG .random .int (1 ,3 )), 1 );
360+ var ogColor = songBox .members [curSelected ].color ;
286361 songBox .forEach (function (item : FlxSprite )
287362 {
288- if (item. ID == curSelected ) FlxTween .color (item , 1 , 0xffcc0002 , 0xffffffff , {ease : FlxEase .sineIn });
363+ if (item. ID == curSelected ) FlxTween .color (item , 1 , 0xffcc0002 , ogColor , {ease : FlxEase .sineIn });
289364 });
290- FlxTween .color (ticketCounter , 1 , 0xffcc0002 , 0xffffffff , {ease : FlxEase .sineIn });
365+ FlxTween .color (ticketCounterTop , 1 , 0xffcc0002 , 0xffffffff , {ease : FlxEase .sineIn });
291366 return ;
292367 }
293368
294369 if (FreeplayManager .trueMissing .contains (FreeplayManager .songList [curSelected ].songName ) && ! FreeplayManager .unplayedList .contains (FreeplayManager .songList [curSelected ].songName )) {
295370 FlxG .camera .shake (0.005 , 0.5 );
296371 FlxG .sound .play (Paths .sound (" badnoise" + FlxG .random .int (1 ,3 )), 1 );
372+ var ogColor = songBox .members [curSelected ].color ;
297373 songBox .forEach (function (item : FlxSprite )
298374 {
299- if (item. ID == curSelected ) FlxTween .color (item , 1 , 0xffcc0002 , 0xffffffff , {ease : FlxEase .sineIn });
375+ if (item. ID == curSelected ) FlxTween .color (item , 1 , 0xffcc0002 , ogColor , {ease : FlxEase .sineIn });
300376 });
301377 return ;
302378 }
303379
380+ // loadDiffs(FreeplayManager.songList[curSelected]);
304381 inSub = true ;
305382 openSubState (new DifficultySelectorSubState (FreeplayManager .songList [curSelected ]));
306383 }
@@ -351,14 +428,14 @@ class OsuFreeplayState extends MusicBeatState
351428
352429 super .update (elapsed );
353430
354- if (ticketCounter != null ) {
355- ticketCounter .text = ' Current ticket amount: ${APInfo .ticketCount }\n ' +
431+ if (ticketCounterTop != null && ticketCounterBottom != null ) {
432+ ticketCounterTop .text = ' Current ticket amount: ${APInfo .ticketCount }\n ' +
356433 ' Tickets Needed: ${APInfo .ticketWinCount }\n ' +
357- ' Tickets Left: ${Std .int (APInfo .ticketWinCount - APInfo .ticketCount )}\n ' +
358- ' Hint Points Available: ${APInfo .hintPoints }\n ' +
359- ' Hint Cost: ${APInfo .hintCost }\n ' +
360- ' (L) to release song\n ' +
361- ' (H) to hint song' ;
434+ ' Tickets Left: ${Std .int (APInfo .ticketWinCount - APInfo .ticketCount )}\n ' ;
435+ ticketCounterBottom . text = ' Hint Points Available: ${APInfo .hintPoints }' +
436+ ' Hint Cost: ${APInfo .hintCost }' +
437+ ' (L) to release song' +
438+ ' (H) to hint song' ;
362439 }
363440 }
364441
@@ -445,7 +522,8 @@ class OsuFreeplayState extends MusicBeatState
445522 }
446523 }
447524 }
448- if (playSound ) FlxG .sound .play (Paths .sound (' scrollMenu' ), 0.4 );
525+ if (playSound )
526+ FlxG .sound .play (Paths .sound (' scrollMenu' ), 0.4 );
449527 }
450528
451529 public static var vocals : FlxSound = null ;
@@ -463,7 +541,32 @@ class OsuFreeplayState extends MusicBeatState
463541 FlxG .mouse .visible = false ;
464542 instance = null ;
465543 if (! FlxG .sound .music .playing && ! stopMusicPlay )
466- MusicManager .playMenuMusic (0 );
544+ MusicManager .playMenuMusic (1 );
545+ }
546+
547+ function loadDiffs (song : Dynamic ) {
548+ var week : WeekData = WeekData .weeksLoaded .get (WeekData .weeksList [FreeplayManager .songList [curSelected ].week ]);
549+ Difficulty .loadFromWeek (week );
550+
551+ var diffInt : Int = 0 ;
552+ for (j in 0 ... Difficulty .list .length )
553+ {
554+ var songBox : SongBox = new SongBox (320 , 100 );
555+ songBox .loadGraphic (Paths .image (' OSUState/bars/background2' ));
556+ songBox .setGraphicSize (650 , 50 );
557+ songBox .setColorTransform (- 1 , - 1 , - 1 , 1 , FreeplayManager .songList [curSelected ].color [0 ][0 ], FreeplayManager .songList [curSelected ].color [0 ][1 ], FreeplayManager .songList [curSelected ].color [0 ][2 ], 1 );
558+ songBox. ID = song. ID + diffInt ;
559+ this .songBox .add (songBox );
560+
561+ // try {metadata = FreeplayManager.metadata.get(FreeplayManager.songList[i].songName.toLowerCase());}
562+ // catch(e) {metadata = null;}
563+
564+ var text : FlxText = new FlxText (0 , 0 , 500 , ' ' , 20 );
565+ text .text = Difficulty .list [j ];
566+ text .alignment = ' left' ;
567+ text. ID = song. ID + diffInt ;
568+ this .textGrp .add (text );
569+ }
467570 }
468571
469572 function loadSongArray (reset : Bool , searching : Bool = false , searchQuery : String = ' ' )
@@ -536,36 +639,6 @@ class OsuFreeplayState extends MusicBeatState
536639 text .alignment = ' left' ;
537640 text. ID = i ;
538641 textGrp .add (text );
539-
540- /* var week:WeekData = WeekData.weeksLoaded.get(WeekData.weeksList[FreeplayManager.songList[i].week]);
541- Difficulty.loadFromWeek(week);
542-
543- for (j in 0...Difficulty.list.length)
544- {
545- trueInt++;
546-
547- var songBox:SongBox = new SongBox(320, 100);
548- songBox.loadGraphic(Paths.image('OSUState/bars/background2'));
549- songBox.setGraphicSize(650, 100);
550- 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);
551- songBox.ID = trueInt;
552- songBoxParent.add(songBox);
553-
554- var icon:HealthIcon = new HealthIcon(FreeplayManager.songList[i].songCharacter, false);
555- icon.setPosition(320, 100);
556- icon.ID = trueInt;
557- icon.setGraphicSize(Std.int(icon.width / 1.7), Std.int(icon.height / 1.7));
558- this.iconGrp.add(icon);
559-
560- try {metadata = FreeplayManager.metadata.get(FreeplayManager.songList[i].songName.toLowerCase());}
561- catch(e) {metadata = null;}
562-
563- var text:FlxText = new FlxText(0, 0, 500, '', 20);
564- text.text = FreeplayManager.songList[i].songName + '\n' + Difficulty.list[j];
565- text.alignment = 'left';
566- text.ID = trueInt;
567- this.textGrp.add(text);
568- }*/
569642 }
570643
571644 maxSelected = songBox .length ;
0 commit comments