diff --git a/buildnumber.txt b/buildnumber.txt index 4c8735ee..11b9a892 100644 --- a/buildnumber.txt +++ b/buildnumber.txt @@ -1 +1 @@ -1266 \ No newline at end of file +1271 \ No newline at end of file diff --git a/source/funkin/mods/ModsFolder.hx b/source/funkin/mods/ModsFolder.hx index 09cac902..58d43e0f 100644 --- a/source/funkin/mods/ModsFolder.hx +++ b/source/funkin/mods/ModsFolder.hx @@ -1,5 +1,6 @@ package funkin.mods; +import openfl.utils.AssetCache; import flixel.util.FlxSignal.FlxTypedSignal; import openfl.utils.Assets; import openfl.utils.AssetManifest; @@ -40,7 +41,7 @@ class ModsFolder { * Initialises `mods` folder by adding callbacks and such. */ public static function init() { - FlxG.signals.preStateCreate.add(onStateSwitch); + } /** @@ -159,54 +160,4 @@ class ModsFolder { } #end } - - private static function onStateSwitch(newState:FlxState) { - // Assets.cache.clear(); - // lime.utils.Assets.cache.clear(); - - // #if MOD_SUPPORT - // if (currentModFolder == null) return; - // var bmapsToRemove:Array = []; - // @:privateAccess - // for(bmap in FlxG.bitmap._cache) { - // if (bmap.assetsKey != null) { - // var e = new LimeLibrarySymbol(bmap.assetsKey); - // if (e.library is openfl.utils.AssetLibrary) { - // @:privateAccess - // e.library = cast(e.library, openfl.utils.AssetLibrary).__proxy; - // } - // if (e.library is ModsAssetLibrary) { - // var lib = cast(e.library, ModsAssetLibrary); - // if (!lib.__parseAsset(e.symbolName)) continue; - // if (!lib.__isCacheValid(e.library.cachedImages, lib._parsedAsset)) { - // e.library.cachedImages.remove(lib._parsedAsset); - // bmapsToRemove.push(bmap); - // } - // } - // } - // } - - // // TODO: add setting for cache clearing - // @:privateAccess - // for(libName=>lib in lime.utils.Assets.libraries) { - // var library = lib; - // if (library is openfl.utils.AssetLibrary) { - // var flLib = cast(library, openfl.utils.AssetLibrary); - // @:privateAccess - // if (flLib.__proxy != null) library = flLib.__proxy; - // } - // if (library is ModsAssetLibrary) { - // var modLib = cast(library, ModsAssetLibrary); - // @:privateAccess - // for(sound in library.cachedAudioBuffers) - // sound.dispose(); - // @:privateAccess - // library.cachedBytes = []; - - // } - // } - // for(e in bmapsToRemove) - // FlxG.bitmap.remove(e); - // #end - } } \ No newline at end of file diff --git a/source/funkin/system/Main.hx b/source/funkin/system/Main.hx index eef8aa1f..686065c3 100644 --- a/source/funkin/system/Main.hx +++ b/source/funkin/system/Main.hx @@ -1,5 +1,6 @@ package funkin.system; +import openfl.utils.AssetCache; import openfl.text.TextFormat; import flixel.system.ui.FlxSoundTray; import funkin.windows.WindowsAPI; @@ -143,9 +144,6 @@ class Main extends Sprite FlxG.fixedTimestep = false; refreshAssets(); - if (FlxG.game.soundTray != null) { - FlxG.game.soundTray.text.setTextFormat(new TextFormat(Paths.font("vcr.ttf"))); - } Conductor.init(); AudioSwitchFix.init(); @@ -160,11 +158,18 @@ class Main extends Sprite }); #end + FlxG.signals.preStateCreate.add(onStateSwitch); + initTransition(); } public static function refreshAssets() { FlxSoundTray.volumeChangeSFX = Paths.sound('menu/volume'); + + if (FlxG.game.soundTray != null) + FlxG.game.soundTray.text.setTextFormat(new TextFormat(Paths.font("vcr.ttf"))); + + } public static function initTransition() { @@ -176,6 +181,16 @@ class Main extends Sprite new FlxRect(-200, -200, FlxG.width * 1.4, FlxG.height * 1.4)); FlxTransitionableState.defaultTransOut = new TransitionData(FADE, 0xFF000000, 0.7, new FlxPoint(0, 1), {asset: diamond, width: 32, height: 32}, new FlxRect(-200, -200, FlxG.width * 1.4, FlxG.height * 1.4)); - } + + private static function onStateSwitch(newState:FlxState) { + // manual asset clearing since base openfl one doesnt clear lime one + // doesnt clear bitmaps since flixel fork does it auto + + var cache = cast(Assets.cache, AssetCache); + for (key=>font in cache.font) + cache.removeFont(key); + for (key=>sound in cache.sound) + cache.removeSound(key); + } }