diff --git a/source/funkin/backend/system/modules/FunkinCache.hx b/source/funkin/backend/system/modules/FunkinCache.hx index e1d8283497..ef3919088a 100644 --- a/source/funkin/backend/system/modules/FunkinCache.hx +++ b/source/funkin/backend/system/modules/FunkinCache.hx @@ -53,6 +53,24 @@ class FunkinCache extends AssetCache { sound = []; } + public function clearAll() + { + for (k in bitmapData.keys()) + { + LimeAssets.cache.image.remove(k); + var g = FlxG.bitmap.get(k); + if (g != null && g.useCount <= 0) + FlxG.bitmap.remove(g); + } + for (k in font.keys()) + LimeAssets.cache.font.remove(k); + for (k in sound.keys()) + LimeAssets.cache.audio.remove(k); + bitmapData = []; + font = []; + sound = []; + } + public function clearSecondLayer() { for(k=>b in bitmapData2) { FlxG.bitmap.removeByKey(k); diff --git a/source/funkin/backend/utils/TranslationUtil.hx b/source/funkin/backend/utils/TranslationUtil.hx index 3f8095b94e..4300094d1a 100644 --- a/source/funkin/backend/utils/TranslationUtil.hx +++ b/source/funkin/backend/utils/TranslationUtil.hx @@ -8,6 +8,7 @@ import haxe.io.Path; import haxe.xml.Access; import haxe.Exception; import funkin.backend.utils.translations.FormatUtil; +import funkin.backend.system.modules.FunkinCache; /** * The class used for translations based on the XMLs inside the translations folders. @@ -112,6 +113,8 @@ final class TranslationUtil if(mod is TranslatedAssetLibrary) cast(mod, TranslatedAssetLibrary).langFolder = name; + if (FunkinCache.instance != null) FunkinCache.instance.clearAll(); + Paths.assetsTree.resetAssetPathCache(); config = getConfig(name); stringMap = loadLanguage(name); alternativeStringMap = name == Flags.DEFAULT_LANGUAGE || config.get("showMissingIds").getDefault("false") == "true" ? [] : loadLanguage(Flags.DEFAULT_LANGUAGE);