asset clearing!

This commit is contained in:
Yoshman29
2022-11-10 22:59:23 +01:00
parent 14007b448c
commit 194ad8e6d4
3 changed files with 22 additions and 56 deletions
+2 -51
View File
@@ -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<FlxGraphic> = [];
// @: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
}
}