Don't duplicate default asset library

This commit is contained in:
Ralty
2025-08-04 18:08:21 +07:00
parent d90f068e67
commit 38997b4765
5 changed files with 44 additions and 39 deletions
@@ -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);
+2 -2
View File
@@ -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;
}
-11
View File
@@ -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;
+7 -7
View File
@@ -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;
}
}
+17 -9
View File
@@ -473,14 +473,22 @@ class FreeplaySonglist {
public function new() {}
public function getSongsFromSource(source:funkin.backend.assets.AssetSource, useTxt:Bool = true) {
var oldPath = Paths.txt("freeplaySonglist");
var newPath = Paths.txt("config/freeplaySonglist");
var path:String = useTxt && !Paths.assetsTree.existsSpecific(newPath, "TEXT", source) && Paths.assetsTree.existsSpecific(oldPath, "TEXT", source) ? {
Logs.warn("data/freeplaySonglist.txt is deprecated and will be removed in the future. Please move the file to data/config/", DARKYELLOW, "FreeplaySonglist");
oldPath;
} : newPath;
var songsFound:Array<String> = useTxt && Paths.assetsTree.existsSpecific(path, "TEXT", source) ? CoolUtil.coolTextFile(path): Paths.getFolderDirectories("songs", false, source);
var songsFound:Array<String> = null;
if (useTxt) {
var oldPath = Paths.txt('freeplaySonglist');
var newPath = Paths.txt('config/freeplaySonglist');
trace(oldPath, newPath, source);
if (Paths.assetsTree.existsSpecific(newPath, "TEXT", source)) {
trace('new');
songsFound = CoolUtil.coolTextFile(newPath);
}
else if (Paths.assetsTree.existsSpecific(oldPath, "TEXT", source)) {
trace('old');
Logs.warn("data/freeplaySonglist.txt is deprecated and will be removed in the future. Please move the file to data/config/", DARKYELLOW, "FreeplaySonglist");
songsFound = CoolUtil.coolTextFile(oldPath);
}
}
if (songsFound == null) songsFound = Paths.getFolderDirectories("songs", false, source);
if (songsFound.length > 0) {
for (s in songsFound) songs.push(Chart.loadChartMeta(s, Flags.DEFAULT_DIFFICULTY, source == MODS));
return false;
@@ -499,7 +507,7 @@ class FreeplaySonglist {
songList.getSongsFromSource(SOURCE, useTxt);
songList.getSongsFromSource(MODS, useTxt);
default /*case 'override'*/:
if (songList.getSongsFromSource(MODS, useTxt))
if (!songList.getSongsFromSource(MODS, useTxt))
songList.getSongsFromSource(SOURCE, useTxt);
}