asset clearing!
This commit is contained in:
+1
-1
@@ -1 +1 @@
|
||||
1266
|
||||
1271
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user