Don't duplicate default asset library
This commit is contained in:
@@ -147,7 +147,21 @@ class AssetsLibraryList extends AssetLibrary {
|
||||
|
||||
public function new(?base:AssetLibrary) {
|
||||
super();
|
||||
__defaultLibraries.push(addLibrary(this.base = (base == null ? Assets.getLibrary("default") : base), SOURCE));
|
||||
#if (sys && TEST_BUILD)
|
||||
Logs.infos("Used cne test / cne build. Switching into source assets.");
|
||||
#if MOD_SUPPORT
|
||||
ModsFolder.modsPath = './${pathBack}mods/';
|
||||
ModsFolder.addonsPath = './${pathBack}addons/';
|
||||
#end
|
||||
__defaultLibraries.push(ModsFolder.loadLibraryFromFolder('assets', './${pathBack}assets/', true, SOURCE));
|
||||
#elseif USE_ADAPTED_ASSETS
|
||||
__defaultLibraries.push(ModsFolder.loadLibraryFromFolder('assets', './assets/', true, SOURCE));
|
||||
#else
|
||||
if (base == null) (this.base = Assets.getLibrary("default")).tag = SOURCE;
|
||||
else this.base = base;
|
||||
__defaultLibraries.push(this.base);
|
||||
#end
|
||||
for (d in __defaultLibraries) addLibrary(d);
|
||||
}
|
||||
|
||||
public function unloadLibraries() {
|
||||
@@ -162,19 +176,13 @@ class AssetsLibraryList extends AssetLibrary {
|
||||
libraries = [];
|
||||
|
||||
// adds default libraries in again
|
||||
for(d in __defaultLibraries)
|
||||
addLibrary(d);
|
||||
for (d in __defaultLibraries) addLibrary(d);
|
||||
}
|
||||
|
||||
public function addLibrary(lib:AssetLibrary, ?tag:AssetSource, ?addTransLib:Bool = true) {
|
||||
libraries.insert(0, lib);
|
||||
if(tag != null)
|
||||
lib.tag = tag;
|
||||
|
||||
if(lib.tag == null) { // if tag is null, set it to MODS, so it doesnt set the tag on the libs that exists
|
||||
lib.tag = MODS;
|
||||
//trace('AssetLibrary ${getCleanLibrary(lib)} tag not set, defaulting to MODS');
|
||||
}
|
||||
if (tag != null) lib.tag = tag;
|
||||
else if (lib.tag == null) lib.tag = MODS;
|
||||
#if TRANSLATIONS_SUPPORT
|
||||
if(addTransLib) {
|
||||
var cleanLib = getCleanLibrary(lib);
|
||||
|
||||
@@ -153,12 +153,12 @@ class ModsFolder {
|
||||
return font;
|
||||
}
|
||||
|
||||
public static function prepareModLibrary(libName:String, lib:IModsAssetLibrary, force:Bool = false, ?tag:AssetSource = MODS) {
|
||||
public static function prepareModLibrary(libName:String, lib:IModsAssetLibrary, force:Bool = false, ?tag:AssetSource) {
|
||||
var openLib = prepareLibrary(libName, force);
|
||||
lib.prefix = 'assets/';
|
||||
@:privateAccess
|
||||
openLib.__proxy = cast(lib, lime.utils.AssetLibrary);
|
||||
if(tag != null) {
|
||||
if (tag != null) {
|
||||
openLib.tag = tag;
|
||||
cast(lib, lime.utils.AssetLibrary).tag = tag;
|
||||
}
|
||||
|
||||
@@ -138,17 +138,6 @@ class Main extends Sprite
|
||||
funkin.backend.scripting.GlobalScript.init();
|
||||
#end
|
||||
|
||||
#if (sys && TEST_BUILD)
|
||||
Logs.infos("Used cne test / cne build. Switching into source assets.");
|
||||
#if MOD_SUPPORT
|
||||
ModsFolder.modsPath = './${pathBack}mods/';
|
||||
ModsFolder.addonsPath = './${pathBack}addons/';
|
||||
#end
|
||||
Paths.assetsTree.__defaultLibraries.push(ModsFolder.loadLibraryFromFolder('assets', './${pathBack}assets/', true, SOURCE));
|
||||
#elseif USE_ADAPTED_ASSETS
|
||||
Paths.assetsTree.__defaultLibraries.push(ModsFolder.loadLibraryFromFolder('assets', './assets/', true, SOURCE));
|
||||
#end
|
||||
|
||||
var lib = new AssetLibrary();
|
||||
@:privateAccess
|
||||
lib.__proxy = Paths.assetsTree;
|
||||
|
||||
@@ -4,6 +4,7 @@ package funkin.backend.system;
|
||||
import sys.FileSystem;
|
||||
#end
|
||||
import flixel.FlxState;
|
||||
import funkin.backend.assets.AssetsLibraryList;
|
||||
import funkin.backend.assets.ModsFolder;
|
||||
import funkin.backend.assets.ModsFolderLibrary;
|
||||
import funkin.backend.chart.EventsData;
|
||||
@@ -127,14 +128,13 @@ class MainState extends FlxState {
|
||||
|
||||
if (Options.devMode && Options.allowConfigWarning) {
|
||||
var lib:ModsFolderLibrary;
|
||||
for (e in Paths.assetsTree.libraries) {
|
||||
@:privateAccess if (!(e is openfl.utils.AssetLibrary) || !((lib = cast cast(e, openfl.utils.AssetLibrary).__proxy) is ModsFolderLibrary)) continue;
|
||||
if (lib.modName == ModsFolder.currentModFolder) {
|
||||
if (lib.exists(Paths.ini("config/modpack"), lime.utils.AssetType.TEXT)) break;
|
||||
for (e in Paths.assetsTree.libraries) if ((lib = cast AssetsLibraryList.getCleanLibrary(e)) is ModsFolderLibrary
|
||||
&& lib.modName == ModsFolder.currentModFolder)
|
||||
{
|
||||
if (lib.exists(Paths.ini("config/modpack"), lime.utils.AssetType.TEXT)) break;
|
||||
|
||||
FlxG.switchState(new ModConfigWarning(lib));
|
||||
return;
|
||||
}
|
||||
FlxG.switchState(new ModConfigWarning(lib));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user