From d6f694491b60484364344f72bb059df95526e46f Mon Sep 17 00:00:00 2001 From: HackDev <80620538+Hackx2@users.noreply.github.com> Date: Tue, 27 Aug 2024 16:28:47 +0100 Subject: [PATCH] lmao --- source/funkin/backend/Song.hx | 4 +- .../backend/system/ui/FunkinSoundTray.hx | 78 ++---- source/funkin/game/Main.hx | 7 - source/funkin/game/editors/ChartingState.hx | 7 +- source/funkin/game/objects/MenuItem.hx | 32 ++- .../game/objects/characters/Character.hx | 6 +- source/funkin/game/states/ErrorState.hx | 49 ++++ source/funkin/game/states/PlayState.hx | 2 + source/funkin/game/states/StoryMenuState.hx | 227 +++++++++--------- 9 files changed, 212 insertions(+), 200 deletions(-) create mode 100644 source/funkin/game/states/ErrorState.hx diff --git a/source/funkin/backend/Song.hx b/source/funkin/backend/Song.hx index 00f8dd24..c44085bf 100644 --- a/source/funkin/backend/Song.hx +++ b/source/funkin/backend/Song.hx @@ -173,7 +173,9 @@ class Song switch(convertTo) { case 'astro_v0.3': - if(!fmt.toLowerCase().startsWith('astro_v0.3')) //Convert to Psych 1.0 format + // psych support :3 + final fmt = fmt.toLowerCase(); + if(!fmt.startsWith('astro_v0.3') && !fmt.startsWith('psych_v1')) //Convert to Psych 1.0 format { trace('converting chart $nameForError with format $fmt to astro_v0.3 format...'); songJson.format = 'astro_v0.3_convert'; diff --git a/source/funkin/backend/system/ui/FunkinSoundTray.hx b/source/funkin/backend/system/ui/FunkinSoundTray.hx index 9e0a9f4d..de483a59 100644 --- a/source/funkin/backend/system/ui/FunkinSoundTray.hx +++ b/source/funkin/backend/system/ui/FunkinSoundTray.hx @@ -1,24 +1,14 @@ package funkin.backend.system.ui; -import haxe.io.Bytes; -import openfl.utils.AssetType; + import flixel.system.ui.FlxSoundTray; -import flixel.tweens.FlxTween; -import flixel.system.FlxAssets; -import flixel.tweens.FlxEase; import openfl.display.Bitmap; import openfl.display.BitmapData; import openfl.utils.Assets; -#if sys -import sys.io.File; -import sys.FileSystem; -#end /** - * Extends the default flixel soundtray, but with some art - * and lil polish! - * - * Gets added to the game in Main.hx, right after FlxGame is new'd - * since it's a Sprite rather than Flixel related object + * V-Slice SoundTray + * Wouldnt say this is the best way of implemeting this, but it works. + * Also Supports The Mods Folders */ class FunkinSoundTray extends FlxSoundTray { @@ -30,12 +20,11 @@ class FunkinSoundTray extends FlxSoundTray public function new() { - // calls super, then removes all children to add our own - // graphics super(); + removeChildren(); - var bg:Bitmap = new Bitmap(getPath("images/soundtray/volumebox", IMAGE)); + var bg:Bitmap = new Bitmap(getPathImage("soundtray/volumebox")); bg.scaleX = graphicScale; bg.scaleY = graphicScale; addChild(bg); @@ -43,8 +32,7 @@ class FunkinSoundTray extends FlxSoundTray y = -height; visible = false; - // makes an alpha'd version of all the bars (bar_10.png) - var backingBar:Bitmap = new Bitmap(getPath('images/soundtray/bars_10', IMAGE)); + var backingBar:Bitmap = new Bitmap(getPathImage('soundtray/bars_10')); backingBar.x = 9; backingBar.y = 5; backingBar.scaleX = graphicScale; @@ -52,15 +40,11 @@ class FunkinSoundTray extends FlxSoundTray addChild(backingBar); backingBar.alpha = 0.4; - // clear the bars array entirely, it was initialized - // in the super class _bars = []; - // 1...11 due to how block named the assets, - // we are trying to get assets bars_1-10 for (i in 1...11) { - var bar:Bitmap = new Bitmap(getPath('images/soundtray/bars_$i', IMAGE), false); + var bar:Bitmap = new Bitmap(getPathImage('soundtray/bars_$i'), false); bar.x = 9; bar.y = 5; bar.scaleX = graphicScale; @@ -77,29 +61,15 @@ class FunkinSoundTray extends FlxSoundTray volumeMaxSound = 'VolMAX'; } - function getPath(path:String, ?TYPE:AssetType = IMAGE):Dynamic + function getPathImage(path:String):Dynamic { - var ext = ''; - switch (TYPE) - { - case IMAGE: - ext = 'png'; - var file = Paths.getPath('$path.$ext', IMAGE); - #if MODS_ALLOWED - return BitmapData.fromFile(file); - #end - return Assets.getBitmapData(file); - case SOUND: - ext = Paths.SOUND_EXT; - var uhh = Paths.getPath('$path.$ext', TYPE); - #if MODS_ALLOWED - return uhh; - #end - default: - ext = ''; - }; + final ext = 'png'; + final file = Paths.getPath('images/$path.$ext'); - return null; + #if MODS_ALLOWED + return BitmapData.fromFile(file); + #end + return Assets.getBitmapData(file); } override public function update(MS:Float):Void @@ -107,7 +77,6 @@ class FunkinSoundTray extends FlxSoundTray y = CoolUtil.coolLerp(y, lerpYPos, 0.1); alpha = CoolUtil.coolLerp(alpha, alphaTarget, 0.25); - // Animate sound tray thing if (_timer > 0) { _timer -= (MS / 1000); @@ -125,7 +94,6 @@ class FunkinSoundTray extends FlxSoundTray active = false; #if FLX_SAVE - // Save sound preferences if (FlxG.save.isBound) { FlxG.save.data.mute = FlxG.sound.muted; @@ -136,11 +104,6 @@ class FunkinSoundTray extends FlxSoundTray } } - /** - * Makes the little volume tray slide out. - * - * @param up Whether the volume is increasing. - */ override public function show(up:Bool = false):Void { _timer = 1; @@ -160,11 +123,16 @@ class FunkinSoundTray extends FlxSoundTray #if MODS_ALLOWED sound = Paths.returnSound('sounds/soundtray/${up ? volumeUpSound : volumeDownSound}'); #else - sound = FlxAssets.getSound(up ? volumeUpSound : volumeDownSound); + final path = 'assets/shared/sounds/soundtray/'; + sound = FlxAssets.getSound(path + (up ? volumeUpSound : volumeDownSound)); #end if (globalVolume == 10) + #if MODS_ALLOWED sound = Paths.returnSound('sounds/soundtray/$volumeMaxSound'); + #else + sound = FlxAssets.getSound('assets/shared/sounds/soundtray/$volumeMaxSound'); + #end if (sound != null) FlxG.sound.load(sound).play(); @@ -173,13 +141,9 @@ class FunkinSoundTray extends FlxSoundTray for (i in 0..._bars.length) { if (i < globalVolume) - { _bars[i].visible = true; - } else - { _bars[i].visible = false; - } } } } diff --git a/source/funkin/game/Main.hx b/source/funkin/game/Main.hx index 6c44a04b..92faa17e 100644 --- a/source/funkin/game/Main.hx +++ b/source/funkin/game/Main.hx @@ -52,13 +52,6 @@ class Main extends Sprite public function new() { - #if CRISP_VISUALS - @:functionCode(" - #include - setProcessDPIAware() - ") - #end - super(); if (stage != null) diff --git a/source/funkin/game/editors/ChartingState.hx b/source/funkin/game/editors/ChartingState.hx index 50ace1b9..df2129ad 100644 --- a/source/funkin/game/editors/ChartingState.hx +++ b/source/funkin/game/editors/ChartingState.hx @@ -1832,10 +1832,11 @@ class ChartingState extends MusicBeatState implements FlxUIEventHandler.FlxUIEve catch (e:Dynamic) {} } - #if DISCORD_ALLOWED - DiscordClient.changePresence('Chart Editor', 'Song: ' + PlayState.SONG.song); - WindowUtil.setTitle('Chart Editor - ${PlayState.SONG.song} (${Difficulty.list[PlayState.storyDifficulty]})'); + #if DISCORD_ALLOWED + DiscordClient.changePresence('Chart Editor', 'Song: ' + PlayState.SONG.song); #end + WindowUtil.setTitle('Chart Editor - ${PlayState.SONG.song} (${Difficulty.list[PlayState.storyDifficulty]})'); + updateAudioVolume(); setPitch(); diff --git a/source/funkin/game/objects/MenuItem.hx b/source/funkin/game/objects/MenuItem.hx index 5ce504c5..7fb5fe8f 100644 --- a/source/funkin/game/objects/MenuItem.hx +++ b/source/funkin/game/objects/MenuItem.hx @@ -10,40 +10,36 @@ import flixel.util.FlxColor; class MenuItem extends FlxSprite { public var targetY:Float = 0; - public var flashingInt:Int = 0; public function new(x:Float, y:Float, weekName:String = '') { super(x, y); loadGraphic(Paths.image('storymenu/' + weekName)); + antialiasing = ClientPrefs.data.antialiasing; //trace('Test added: ' + WeekData.getWeekNumber(weekNum) + ' (' + weekNum + ')'); - antialiasing = funkin.backend.utils.ClientPrefs.data.globalAntialiasing; } - private var isFlashing:Bool = false; + public var isFlashing(default, set):Bool = false; + private var _flashingElapsed:Float = 0; + final _flashColor = 0xFF33FFFF; + final flashes_ps:Int = 6; - public function startFlashing():Void + public function set_isFlashing(value:Bool = true):Bool { - isFlashing = true; + isFlashing = value; + _flashingElapsed = 0; + color = (isFlashing) ? _flashColor : FlxColor.WHITE; + return isFlashing; } - // if it runs at 60fps, fake framerate will be 6 - // if it runs at 144 fps, fake framerate will be like 14, and will update the graphic every 0.016666 * 3 seconds still??? - // so it runs basically every so many seconds, not dependant on framerate?? - // I'm still learning how math works thanks whoever is reading this lol - var fakeFramerate:Int = Math.round((1 / FlxG.elapsed) / 10); - override function update(elapsed:Float) { super.update(elapsed); - y = FlxMath.lerp(y, (targetY * 120) + 480, CoolUtil.boundTo(elapsed * 10.2, 0, 1)); if (isFlashing) - flashingInt += 1; - - if (flashingInt % fakeFramerate >= Math.floor(fakeFramerate / 2)) - color = 0xFF33ffff; - else - color = FlxColor.WHITE; + { + _flashingElapsed += elapsed; + color = (Math.floor(_flashingElapsed * FlxG.updateFramerate * flashes_ps) % 2 == 0) ? _flashColor : FlxColor.WHITE; + } } } diff --git a/source/funkin/game/objects/characters/Character.hx b/source/funkin/game/objects/characters/Character.hx index 70ed81c4..37dde660 100644 --- a/source/funkin/game/objects/characters/Character.hx +++ b/source/funkin/game/objects/characters/Character.hx @@ -90,6 +90,8 @@ class Character extends FlxSprite this.isPlayer = isPlayer; changeCharacter(character); + + #if BASE_GAME_FILES switch(curCharacter) { case 'pico-speaker': @@ -99,6 +101,7 @@ class Character extends FlxSprite case 'pico-blazin', 'darnell-blazin': skipDance = true; } + #end } public function changeCharacter(character:String) @@ -284,7 +287,7 @@ class Character extends FlxSprite dance(); finishAnimation(); } - + #if BASE_GAME_FILES switch(curCharacter) { case 'pico-speaker': @@ -299,6 +302,7 @@ class Character extends FlxSprite } if(isAnimationFinished()) playAnim(getAnimationName(), false, false, animation.curAnim.frames.length - 3); } + #end if (getAnimationName().startsWith('sing')) holdTimer += elapsed; else if(isPlayer) holdTimer = 0; diff --git a/source/funkin/game/states/ErrorState.hx b/source/funkin/game/states/ErrorState.hx new file mode 100644 index 00000000..e19a6320 --- /dev/null +++ b/source/funkin/game/states/ErrorState.hx @@ -0,0 +1,49 @@ +package funkin.game.states; + +class ErrorState extends MusicBeatState +{ + public var acceptCallback:Void->Void; + public var backCallback:Void->Void; + public var errorMsg:String; + + public function new(error:String, accept:Void->Void = null, back:Void->Void = null) + { + this.errorMsg = error; + this.acceptCallback = accept; + this.backCallback = back; + + super(); + } + + public var errorSine:Float = 0; + public var errorText:FlxText; + override function create() + { + var bg = new FlxSprite().loadGraphic(Paths.image('menuDesat')); + bg.color = FlxColor.GRAY; + bg.antialiasing = ClientPrefs.data.antialiasing; + add(bg); + bg.screenCenter(); + + errorText = new FlxText(0, 0, FlxG.width - 300, errorMsg, 32); + errorText.setFormat(Paths.font("vcr.ttf"), 32, FlxColor.WHITE, CENTER, FlxTextBorderStyle.OUTLINE, FlxColor.BLACK); + errorText.scrollFactor.set(); + errorText.borderSize = 2; + errorText.screenCenter(); + add(errorText); + super.create(); + } + + override function update(elapsed:Float) + { + errorSine += 180 * elapsed; + errorText.alpha = 1 - Math.sin((Math.PI * errorSine) / 180); + + if(controls.ACCEPT && acceptCallback != null) + acceptCallback(); + else if(controls.BACK && backCallback != null) + backCallback(); + + super.update(elapsed); + } +} \ No newline at end of file diff --git a/source/funkin/game/states/PlayState.hx b/source/funkin/game/states/PlayState.hx index 37ca3a65..0a725e36 100644 --- a/source/funkin/game/states/PlayState.hx +++ b/source/funkin/game/states/PlayState.hx @@ -450,6 +450,7 @@ class PlayState extends MusicBeatState switch (curStage) { case 'stage': new Stage(); //Week 1 + #if BASE_GAME_FILES case 'spooky': new Spooky(); //Week 2 case 'philly': new Philly(); //Week 3 case 'limo': new Limo(); //Week 4 @@ -460,6 +461,7 @@ class PlayState extends MusicBeatState case 'tank': new Tank(); //Week 7 - Ugh, Guns, Stress case 'phillyStreets': new PhillyStreets(); //Weekend 1 - Darnell, Lit Up, 2Hot case 'phillyBlazin': new PhillyBlazin(); //Weekend 1 - Blazin + #end } add(gfGroup); //Needed for blammed lights diff --git a/source/funkin/game/states/StoryMenuState.hx b/source/funkin/game/states/StoryMenuState.hx index 4fc05e1d..f827b170 100644 --- a/source/funkin/game/states/StoryMenuState.hx +++ b/source/funkin/game/states/StoryMenuState.hx @@ -65,28 +65,38 @@ class StoryMenuState extends MusicBeatState Paths.clearStoredMemory(); Paths.clearUnusedMemory(); + persistentUpdate = persistentDraw = true; PlayState.isStoryMode = true; WeekData.reloadWeekFiles(true); + + #if DISCORD_ALLOWED + // Updating Discord Rich Presence + DiscordClient.changePresence("Story Menu", null); + WindowUtil.setTitle('Story Menu'); + #end + + if(WeekData.weeksList.length < 1) + { + FlxTransitionableState.skipNextTransIn = true; + persistentUpdate = false; + MusicBeatState.switchState(new ErrorState("NO WEEKS ADDED FOR STORY MODE\n\nPress ACCEPT to go to the Week Editor Menu.\nPress BACK to return to Main Menu.", + function() MusicBeatState.switchState(new funkin.game.editors.WeekEditorState()), + function() MusicBeatState.switchState(new MainMenuState()))); + return; + } + if(curWeek >= WeekData.weeksList.length) curWeek = 0; - persistentUpdate = persistentDraw = true; - scoreText = new FlxText(10, 10, 0, "SCORE: 49324858", 36); + scoreText = new FlxText(10, 10, 0, 'WEEK SCORE: $lerpScore', 36); scoreText.setFormat("VCR OSD Mono", 32); txtWeekTitle = new FlxText(FlxG.width * 0.7, 10, 0, "", 32); txtWeekTitle.setFormat("VCR OSD Mono", 32, FlxColor.WHITE, RIGHT); txtWeekTitle.alpha = 0.7; - var rankText:FlxText = new FlxText(0, 10); - rankText.text = 'RANK: ASS'; - rankText.setFormat(Paths.font("vcr.ttf"), 32); - rankText.size = scoreText.size; - rankText.screenCenter(X); - var ui_tex = Paths.getSparrowAtlas('storymenu/props/campaign_menu_UI_assets'); var bgYellow:FlxSprite = new FlxSprite(0, 56).makeGraphic(FlxG.width, 386, 0xFFF9CF51); bgSprite = new FlxSprite(0, 56); - bgSprite.antialiasing = ClientPrefs.data.globalAntialiasing; grpWeekText = new FlxTypedGroup(); add(grpWeekText); @@ -99,13 +109,8 @@ class StoryMenuState extends MusicBeatState grpLocks = new FlxTypedGroup(); add(grpLocks); - #if desktop - // Updating Discord Rich Presence - DiscordClient.changePresence("Story Menu", null); - WindowUtil.setTitle('Story'); - #end - var num:Int = 0; + var itemTargetY:Float = 0; for (i in 0...WeekData.weeksList.length) { var weekFile:WeekData = WeekData.weeksLoaded.get(WeekData.weeksList[i]); @@ -116,22 +121,23 @@ class StoryMenuState extends MusicBeatState WeekData.setDirectoryFromWeek(weekFile); var weekThing:MenuItem = new MenuItem(0, bgSprite.y + 396, WeekData.weeksList[i]); weekThing.y += ((weekThing.height + 20) * num); - weekThing.targetY = num; + weekThing.ID = num; + weekThing.targetY = itemTargetY; + itemTargetY += Math.max(weekThing.height, 110) + 10; grpWeekText.add(weekThing); weekThing.screenCenter(X); - weekThing.antialiasing = ClientPrefs.data.globalAntialiasing; // weekThing.updateHitbox(); // Needs an offset thingie if (isLocked) { var lock:FlxSprite = new FlxSprite(weekThing.width + 10 + weekThing.x); + lock.antialiasing = ClientPrefs.data.antialiasing; lock.frames = ui_tex; lock.animation.addByPrefix('lock', 'lock'); lock.animation.play('lock'); lock.ID = i; - lock.antialiasing = ClientPrefs.data.globalAntialiasing; grpLocks.add(lock); } num++; @@ -150,12 +156,12 @@ class StoryMenuState extends MusicBeatState difficultySelectors = new FlxGroup(); add(difficultySelectors); - leftArrow = new FlxSprite(grpWeekText.members[0].x + grpWeekText.members[0].width + 10, grpWeekText.members[0].y + 10); + leftArrow = new FlxSprite(850, grpWeekText.members[0].y + 10); + leftArrow.antialiasing = ClientPrefs.data.antialiasing; leftArrow.frames = ui_tex; leftArrow.animation.addByPrefix('idle', "arrow left"); leftArrow.animation.addByPrefix('press', "arrow push left"); leftArrow.animation.play('idle'); - leftArrow.antialiasing = ClientPrefs.data.globalAntialiasing; difficultySelectors.add(leftArrow); Difficulty.resetList(); @@ -166,31 +172,31 @@ class StoryMenuState extends MusicBeatState curDifficulty = Math.round(Math.max(0, Difficulty.defaultList.indexOf(lastDifficultyName))); sprDifficulty = new FlxSprite(0, leftArrow.y); - sprDifficulty.antialiasing = ClientPrefs.data.globalAntialiasing; + sprDifficulty.antialiasing = ClientPrefs.data.antialiasing; difficultySelectors.add(sprDifficulty); rightArrow = new FlxSprite(leftArrow.x + 376, leftArrow.y); + rightArrow.antialiasing = ClientPrefs.data.antialiasing; rightArrow.frames = ui_tex; rightArrow.animation.addByPrefix('idle', 'arrow right'); rightArrow.animation.addByPrefix('press', "arrow push right", 24, false); rightArrow.animation.play('idle'); - rightArrow.antialiasing = ClientPrefs.data.globalAntialiasing; difficultySelectors.add(rightArrow); add(bgYellow); add(bgSprite); add(grpWeekCharacters); - var tracksSprite:FlxSprite = new FlxSprite(FlxG.width * 0.07, bgSprite.y + 425).loadGraphic(Paths.image('storymenu/props/Menu_Tracks')); - tracksSprite.antialiasing = ClientPrefs.data.globalAntialiasing; + var tracksSprite:FlxSprite = new FlxSprite(FlxG.width * 0.07 + 100, bgSprite.y + 425).loadGraphic(Paths.image('storymenu/props/Menu_Tracks')); + tracksSprite.antialiasing = ClientPrefs.data.antialiasing; + tracksSprite.x -= tracksSprite.width/2; add(tracksSprite); txtTracklist = new FlxText(FlxG.width * 0.05, tracksSprite.y + 60, 0, "", 32); txtTracklist.alignment = CENTER; - txtTracklist.font = rankText.font; + txtTracklist.font = Paths.font("vcr.ttf"); txtTracklist.color = 0xFFe55777; add(txtTracklist); - // add(rankText); add(scoreText); add(txtWeekTitle); @@ -208,28 +214,44 @@ class StoryMenuState extends MusicBeatState override function update(elapsed:Float) { - // scoreText.setFormat('VCR OSD Mono', 32); - lerpScore = Math.floor(FlxMath.lerp(lerpScore, intendedScore, CoolUtil.boundTo(elapsed * 30, 0, 1))); - if(Math.abs(intendedScore - lerpScore) < 10) lerpScore = intendedScore; + if(grpWeekText.length < 1) + { + if (controls.BACK && !movedBack && !selectedWeek) + { + FlxG.sound.play(Paths.sound('cancelMenu')); + movedBack = true; + MusicBeatState.switchState(new MainMenuState()); + } + super.update(elapsed); + return; + } - scoreText.text = "WEEK SCORE:" + lerpScore; + // scoreText.setFormat('VCR OSD Mono', 32); + if(intendedScore != lerpScore) + { + lerpScore = Math.floor(FlxMath.lerp(intendedScore, lerpScore, Math.exp(-elapsed * 30))); + if(Math.abs(intendedScore - lerpScore) < 10) lerpScore = intendedScore; + + scoreText.text = 'WEEK SCORE: $lerpScore'; + } // FlxG.watch.addQuick('font', scoreText.font); if (!movedBack && !selectedWeek) { - var upP = controls.UI_UP_P; - var downP = controls.UI_DOWN_P; - if (upP) + var changeDiff = false; + if (controls.UI_UP_P) { changeWeek(-1); FlxG.sound.play(Paths.sound('scrollMenu')); + changeDiff = true; } - if (downP) + if (controls.UI_DOWN_P) { changeWeek(1); FlxG.sound.play(Paths.sound('scrollMenu')); + changeDiff = true; } if(FlxG.mouse.wheel != 0) @@ -253,7 +275,7 @@ class StoryMenuState extends MusicBeatState changeDifficulty(1); else if (controls.UI_LEFT_P) changeDifficulty(-1); - else if (upP || downP) + else if (changeDiff) changeDifficulty(); if(FlxG.keys.justPressed.CONTROL) @@ -268,25 +290,24 @@ class StoryMenuState extends MusicBeatState //FlxG.sound.play(Paths.sound('scrollMenu')); } else if (controls.ACCEPT) - { selectWeek(); - } } if (controls.BACK && !movedBack && !selectedWeek) { FlxG.sound.play(Paths.sound('cancelMenu')); movedBack = true; - MusicBeatState.switchState(new funkin.game.states.MainMenuState()); + MusicBeatState.switchState(new MainMenuState()); } super.update(elapsed); + + var offY:Float = grpWeekText.members[curWeek].targetY; + for (num => item in grpWeekText.members) + item.y = FlxMath.lerp(item.targetY - offY + 480, item.y, Math.exp(-elapsed * 10.2)); - grpLocks.forEach(function(lock:FlxSprite) - { - lock.y = grpWeekText.members[lock.ID].y; - lock.visible = (lock.y > FlxG.height / 2); - }); + for (num => lock in grpLocks.members) + lock.y = grpWeekText.members[lock.ID].y + grpWeekText.members[lock.ID].height/2 - lock.height/2; } var movedBack:Bool = false; @@ -297,12 +318,40 @@ class StoryMenuState extends MusicBeatState { if (!weekIsLocked(loadedWeeks[curWeek].fileName)) { + // We can't use Dynamic Array .copy() because that crashes HTML5, here's a workaround. + var songArray:Array = []; + var leWeek:Array = loadedWeeks[curWeek].songs; + for (i in 0...leWeek.length) { + songArray.push(leWeek[i][0]); + } + + // Nevermind that's stupid lmao + try + { + PlayState.storyPlaylist = songArray; + PlayState.isStoryMode = true; + selectedWeek = true; + + var diffic = Difficulty.getFilePath(curDifficulty); + if(diffic == null) diffic = ''; + + PlayState.storyDifficulty = curDifficulty; + + Song.loadFromJson(PlayState.storyPlaylist[0].toLowerCase() + diffic, PlayState.storyPlaylist[0].toLowerCase()); + PlayState.campaignScore = 0; + PlayState.campaignMisses = 0; + } + catch(e:Dynamic) + { + trace('ERROR! $e'); + return; + } + if (stopspamming == false) { FlxG.sound.play(Paths.sound('confirmMenu')); - - grpWeekText.members[curWeek].startFlashing(); - + + grpWeekText.members[curWeek].isFlashing = true; for (char in grpWeekCharacters.members) { if (char.character != '' && char.hasConfirmAnimation) @@ -313,40 +362,26 @@ class StoryMenuState extends MusicBeatState stopspamming = true; } - // We can't use Dynamic Array .copy() because that crashes HTML5, here's a workaround. - var songArray:Array = []; - var leWeek:Array = loadedWeeks[curWeek].songs; - for (i in 0...leWeek.length) { - songArray.push(leWeek[i][0]); - } - - // Nevermind that's stupid lmao - PlayState.storyPlaylist = songArray; - PlayState.isStoryMode = true; - selectedWeek = true; + var directory = StageData.forceNextDirectory; + //LoadingState.loadNextDirectory(); + StageData.forceNextDirectory = directory; + Paths.setCurrentLevel(directory); - var diffic = Difficulty.getFilePath(curDifficulty); - if(diffic == null) diffic = ''; - - PlayState.storyDifficulty = curDifficulty; - - PlayState.SONG = Song.loadFromJson(PlayState.storyPlaylist[0].toLowerCase() + diffic, PlayState.storyPlaylist[0].toLowerCase()); - PlayState.campaignScore = 0; - PlayState.campaignMisses = 0; + // LoadingState.prepareToSong(); new FlxTimer().start(1, function(tmr:FlxTimer) { + #if !SHOW_LOADING_SCREEN FlxG.sound.music.stop(); #end LoadingState.loadAndSwitchState(new PlayState(), true); - funkin.game.states.FreeplayState.destroyFreeplayVocals(); + FreeplayState.destroyFreeplayVocals(); }); + #if (MODS_ALLOWED && DISCORD_ALLOWED) DiscordClient.loadModRPC(); #end - } else { - FlxG.sound.play(Paths.sound('cancelMenu')); } + else FlxG.sound.play(Paths.sound('cancelMenu')); } - var tweenDifficulty:FlxTween; function changeDifficulty(change:Int = 0):Void { curDifficulty += change; @@ -358,7 +393,7 @@ class StoryMenuState extends MusicBeatState WeekData.setDirectoryFromWeek(loadedWeeks[curWeek]); - var diff:String = Difficulty.list[curDifficulty]; + var diff:String = Difficulty.getString(curDifficulty); var newImage:FlxGraphic = Paths.image('menudifficulties/' + Paths.formatToSongPath(diff)); //trace(Mods.currentModDirectory + ', menudifficulties/' + Paths.formatToSongPath(diff)); @@ -368,13 +403,10 @@ class StoryMenuState extends MusicBeatState sprDifficulty.x = leftArrow.x + 60; sprDifficulty.x += (308 - sprDifficulty.width) / 3; sprDifficulty.alpha = 0; - sprDifficulty.y = leftArrow.y - 15; + sprDifficulty.y = leftArrow.y - sprDifficulty.height + 50; - if(tweenDifficulty != null) tweenDifficulty.cancel(); - tweenDifficulty = FlxTween.tween(sprDifficulty, {y: leftArrow.y + 15, alpha: 1}, 0.07, {onComplete: function(twn:FlxTween) - { - tweenDifficulty = null; - }}); + FlxTween.cancelTweensOf(sprDifficulty); + FlxTween.tween(sprDifficulty, {y: sprDifficulty.y + 30, alpha: 1}, 0.07); } lastDifficultyName = diff; @@ -383,7 +415,7 @@ class StoryMenuState extends MusicBeatState #end } - var lerpScore:Int = 0; + var lerpScore:Int = 49324858; var intendedScore:Int = 0; function changeWeek(change:Int = 0):Void @@ -402,17 +434,12 @@ class StoryMenuState extends MusicBeatState txtWeekTitle.text = leName.toUpperCase(); txtWeekTitle.x = FlxG.width - (txtWeekTitle.width + 10); - var bullShit:Int = 0; - var unlocked:Bool = !weekIsLocked(leWeek.fileName); - for (item in grpWeekText.members) + for (num => item in grpWeekText.members) { - item.targetY = bullShit - curWeek; - if (item.targetY == Std.int(0) && unlocked) + item.alpha = 0.6; + if (num - curWeek == 0 && unlocked) item.alpha = 1; - else - item.alpha = 0.6; - bullShit++; } bgSprite.visible = true; @@ -425,38 +452,12 @@ class StoryMenuState extends MusicBeatState PlayState.storyWeek = curWeek; Difficulty.loadFromWeek(); - var diffStr:String = WeekData.getCurrentWeek().difficulties; - if(diffStr != null) diffStr = diffStr.trim(); //Fuck you HTML5 difficultySelectors.visible = unlocked; - if(diffStr != null && diffStr.length > 0) - { - var diffs:Array = diffStr.split(','); - var i:Int = diffs.length - 1; - while (i > 0) - { - if(diffs[i] != null) - { - diffs[i] = diffs[i].trim(); - if(diffs[i].length < 1) diffs.remove(diffs[i]); - } - --i; - } - - if(diffs.length > 0 && diffs[0].length > 0) - { - Difficulty.list = diffs; - } - } - if(Difficulty.list.contains(Difficulty.getDefault())) - { curDifficulty = Math.round(Math.max(0, Difficulty.defaultList.indexOf(Difficulty.getDefault()))); - } else - { curDifficulty = 0; - } var newPos:Int = Difficulty.list.indexOf(lastDifficultyName); //trace('Pos of ' + lastDifficultyName + ' is ' + newPos); @@ -488,7 +489,7 @@ class StoryMenuState extends MusicBeatState txtTracklist.text = ''; for (i in 0...stringThing.length) { - txtTracklist.text += stringThing[i].formatText() + '\n'; + txtTracklist.text += stringThing[i] + '\n'; } txtTracklist.text = txtTracklist.text.toUpperCase(); @@ -500,4 +501,4 @@ class StoryMenuState extends MusicBeatState intendedScore = Highscore.getWeekScore(loadedWeeks[curWeek].fileName, curDifficulty); #end } -} +} \ No newline at end of file