diff --git a/source/funkin/backend/assets/ModsFolder.hx b/source/funkin/backend/assets/ModsFolder.hx index 9ae0265bc..015fa28a0 100644 --- a/source/funkin/backend/assets/ModsFolder.hx +++ b/source/funkin/backend/assets/ModsFolder.hx @@ -95,7 +95,12 @@ class ModsFolder { public static function getModsList():Array { var mods:Array = []; #if MOD_SUPPORT - for(modFolder in FileSystem.readDirectory(modsPath)) { + final modsList:Array = FileSystem.readDirectory(modsPath); + + if (modsList == null || modsList.length <= 0) + return mods; + + for (modFolder in modsList) { if (FileSystem.isDirectory('${modsPath}${modFolder}')) { mods.push(modFolder); } else { @@ -161,4 +166,4 @@ class ModsFolder { return prepareModLibrary(libName, new ZipFolderLibrary(zipPath, libName, modName), force); } #end -} \ No newline at end of file +} diff --git a/source/funkin/backend/system/Main.hx b/source/funkin/backend/system/Main.hx index 72e218b47..5faf46685 100644 --- a/source/funkin/backend/system/Main.hx +++ b/source/funkin/backend/system/Main.hx @@ -48,6 +48,10 @@ class Main extends Sprite public static var game:FunkinGame; + /** + * The time since the game was focused last time in seconds. + */ + public static var timeSinceFocus(get, never):Float; public static var time:Int = 0; // You can pretty much ignore everything from here on - your code should go in your states. @@ -165,6 +169,7 @@ class Main extends Sprite Conductor.init(); AudioSwitchFix.init(); EventManager.init(); + FlxG.signals.focusGained.add(onFocus); FlxG.signals.preStateSwitch.add(onStateSwitch); FlxG.signals.postStateSwitch.add(onStateSwitchPost); @@ -206,6 +211,10 @@ class Main extends Sprite {asset: diamond, width: 32, height: 32}, new FlxRect(-200, -200, FlxG.width * 1.4, FlxG.height * 1.4)); } + public static function onFocus() { + _tickFocused = FlxG.game.ticks; + } + private static function onStateSwitch() { scaleMode.resetSize(); } @@ -225,4 +234,9 @@ class Main extends Sprite MemoryUtil.clearMajor(); } + + private static var _tickFocused:Float = 0; + public static function get_timeSinceFocus():Float { + return (FlxG.game.ticks - _tickFocused) / 1000; + } } diff --git a/source/funkin/game/StrumLine.hx b/source/funkin/game/StrumLine.hx index 3e88bc7cc..b5880acc6 100644 --- a/source/funkin/game/StrumLine.hx +++ b/source/funkin/game/StrumLine.hx @@ -292,6 +292,7 @@ class StrumLine extends FlxTypedGroup { super.destroy(); if(startingPos != null) startingPos.put(); + notes = FlxDestroyUtil.destroy(notes); } /** diff --git a/source/funkin/menus/FreeplayState.hx b/source/funkin/menus/FreeplayState.hx index 9ff666462..f30788b86 100644 --- a/source/funkin/menus/FreeplayState.hx +++ b/source/funkin/menus/FreeplayState.hx @@ -2,6 +2,7 @@ package funkin.menus; import funkin.backend.chart.Chart; import funkin.backend.chart.ChartData.ChartMetaData; +import funkin.backend.system.Conductor; import haxe.io.Path; import openfl.text.TextField; import flixel.text.FlxText; @@ -244,7 +245,11 @@ class FreeplayState extends MusicBeatState autoplayElapsed += elapsed; if (!disableAutoPlay && !songInstPlaying && (autoplayElapsed > timeUntilAutoplay || FlxG.keys.justPressed.SPACE)) { if (curPlayingInst != (curPlayingInst = Paths.inst(songs[curSelected].name, songs[curSelected].difficulties[curDifficulty]))) { - var huh:Void->Void = function() FlxG.sound.playMusic(curPlayingInst, 0); + var huh:Void->Void = function() + { + FlxG.sound.playMusic(curPlayingInst, 0); + Conductor.changeBPM(songs[curSelected].bpm, songs[curSelected].beatsPerMeasure, songs[curSelected].stepsPerBeat); + } if(!disableAsyncLoading) Main.execAsync(huh); else huh(); } diff --git a/source/funkin/options/OptionsScreen.hx b/source/funkin/options/OptionsScreen.hx index 77d3e1063..ab6a3d400 100644 --- a/source/funkin/options/OptionsScreen.hx +++ b/source/funkin/options/OptionsScreen.hx @@ -58,7 +58,7 @@ class OptionsScreen extends FlxTypedSpriteGroup { if (members.length > 0) { members[curSelected].selected = true; - if (controls.ACCEPT || (FlxG.mouse.justReleased && !controls.touchC)) + if (controls.ACCEPT || ((FlxG.mouse.justReleased && !controls.touchC) && Main.timeSinceFocus > 0.25)) members[curSelected].onSelect(); if (controls.LEFT_P) members[curSelected].onChangeSelection(-1);