Skip to content
This repository was archived by the owner on Aug 5, 2025. It is now read-only.

Commit 38997b4

Browse files
committed
Don't duplicate default asset library
1 parent d90f068 commit 38997b4

File tree

5 files changed

+44
-39
lines changed

5 files changed

+44
-39
lines changed

source/funkin/backend/assets/AssetsLibraryList.hx

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,21 @@ class AssetsLibraryList extends AssetLibrary {
147147

148148
public function new(?base:AssetLibrary) {
149149
super();
150-
__defaultLibraries.push(addLibrary(this.base = (base == null ? Assets.getLibrary("default") : base), SOURCE));
150+
#if (sys && TEST_BUILD)
151+
Logs.infos("Used cne test / cne build. Switching into source assets.");
152+
#if MOD_SUPPORT
153+
ModsFolder.modsPath = './${pathBack}mods/';
154+
ModsFolder.addonsPath = './${pathBack}addons/';
155+
#end
156+
__defaultLibraries.push(ModsFolder.loadLibraryFromFolder('assets', './${pathBack}assets/', true, SOURCE));
157+
#elseif USE_ADAPTED_ASSETS
158+
__defaultLibraries.push(ModsFolder.loadLibraryFromFolder('assets', './assets/', true, SOURCE));
159+
#else
160+
if (base == null) (this.base = Assets.getLibrary("default")).tag = SOURCE;
161+
else this.base = base;
162+
__defaultLibraries.push(this.base);
163+
#end
164+
for (d in __defaultLibraries) addLibrary(d);
151165
}
152166

153167
public function unloadLibraries() {
@@ -162,19 +176,13 @@ class AssetsLibraryList extends AssetLibrary {
162176
libraries = [];
163177

164178
// adds default libraries in again
165-
for(d in __defaultLibraries)
166-
addLibrary(d);
179+
for (d in __defaultLibraries) addLibrary(d);
167180
}
168181

169182
public function addLibrary(lib:AssetLibrary, ?tag:AssetSource, ?addTransLib:Bool = true) {
170183
libraries.insert(0, lib);
171-
if(tag != null)
172-
lib.tag = tag;
173-
174-
if(lib.tag == null) { // if tag is null, set it to MODS, so it doesnt set the tag on the libs that exists
175-
lib.tag = MODS;
176-
//trace('AssetLibrary ${getCleanLibrary(lib)} tag not set, defaulting to MODS');
177-
}
184+
if (tag != null) lib.tag = tag;
185+
else if (lib.tag == null) lib.tag = MODS;
178186
#if TRANSLATIONS_SUPPORT
179187
if(addTransLib) {
180188
var cleanLib = getCleanLibrary(lib);

source/funkin/backend/assets/ModsFolder.hx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,12 @@ class ModsFolder {
153153
return font;
154154
}
155155

156-
public static function prepareModLibrary(libName:String, lib:IModsAssetLibrary, force:Bool = false, ?tag:AssetSource = MODS) {
156+
public static function prepareModLibrary(libName:String, lib:IModsAssetLibrary, force:Bool = false, ?tag:AssetSource) {
157157
var openLib = prepareLibrary(libName, force);
158158
lib.prefix = 'assets/';
159159
@:privateAccess
160160
openLib.__proxy = cast(lib, lime.utils.AssetLibrary);
161-
if(tag != null) {
161+
if (tag != null) {
162162
openLib.tag = tag;
163163
cast(lib, lime.utils.AssetLibrary).tag = tag;
164164
}

source/funkin/backend/system/Main.hx

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -138,17 +138,6 @@ class Main extends Sprite
138138
funkin.backend.scripting.GlobalScript.init();
139139
#end
140140

141-
#if (sys && TEST_BUILD)
142-
Logs.infos("Used cne test / cne build. Switching into source assets.");
143-
#if MOD_SUPPORT
144-
ModsFolder.modsPath = './${pathBack}mods/';
145-
ModsFolder.addonsPath = './${pathBack}addons/';
146-
#end
147-
Paths.assetsTree.__defaultLibraries.push(ModsFolder.loadLibraryFromFolder('assets', './${pathBack}assets/', true, SOURCE));
148-
#elseif USE_ADAPTED_ASSETS
149-
Paths.assetsTree.__defaultLibraries.push(ModsFolder.loadLibraryFromFolder('assets', './assets/', true, SOURCE));
150-
#end
151-
152141
var lib = new AssetLibrary();
153142
@:privateAccess
154143
lib.__proxy = Paths.assetsTree;

source/funkin/backend/system/MainState.hx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ package funkin.backend.system;
44
import sys.FileSystem;
55
#end
66
import flixel.FlxState;
7+
import funkin.backend.assets.AssetsLibraryList;
78
import funkin.backend.assets.ModsFolder;
89
import funkin.backend.assets.ModsFolderLibrary;
910
import funkin.backend.chart.EventsData;
@@ -127,14 +128,13 @@ class MainState extends FlxState {
127128

128129
if (Options.devMode && Options.allowConfigWarning) {
129130
var lib:ModsFolderLibrary;
130-
for (e in Paths.assetsTree.libraries) {
131-
@:privateAccess if (!(e is openfl.utils.AssetLibrary) || !((lib = cast cast(e, openfl.utils.AssetLibrary).__proxy) is ModsFolderLibrary)) continue;
132-
if (lib.modName == ModsFolder.currentModFolder) {
133-
if (lib.exists(Paths.ini("config/modpack"), lime.utils.AssetType.TEXT)) break;
131+
for (e in Paths.assetsTree.libraries) if ((lib = cast AssetsLibraryList.getCleanLibrary(e)) is ModsFolderLibrary
132+
&& lib.modName == ModsFolder.currentModFolder)
133+
{
134+
if (lib.exists(Paths.ini("config/modpack"), lime.utils.AssetType.TEXT)) break;
134135

135-
FlxG.switchState(new ModConfigWarning(lib));
136-
return;
137-
}
136+
FlxG.switchState(new ModConfigWarning(lib));
137+
return;
138138
}
139139
}
140140

source/funkin/menus/FreeplayState.hx

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -473,14 +473,22 @@ class FreeplaySonglist {
473473
public function new() {}
474474

475475
public function getSongsFromSource(source:funkin.backend.assets.AssetSource, useTxt:Bool = true) {
476-
var oldPath = Paths.txt("freeplaySonglist");
477-
var newPath = Paths.txt("config/freeplaySonglist");
478-
var path:String = useTxt && !Paths.assetsTree.existsSpecific(newPath, "TEXT", source) && Paths.assetsTree.existsSpecific(oldPath, "TEXT", source) ? {
479-
Logs.warn("data/freeplaySonglist.txt is deprecated and will be removed in the future. Please move the file to data/config/", DARKYELLOW, "FreeplaySonglist");
480-
oldPath;
481-
} : newPath;
482-
483-
var songsFound:Array<String> = useTxt && Paths.assetsTree.existsSpecific(path, "TEXT", source) ? CoolUtil.coolTextFile(path): Paths.getFolderDirectories("songs", false, source);
476+
var songsFound:Array<String> = null;
477+
if (useTxt) {
478+
var oldPath = Paths.txt('freeplaySonglist');
479+
var newPath = Paths.txt('config/freeplaySonglist');
480+
trace(oldPath, newPath, source);
481+
if (Paths.assetsTree.existsSpecific(newPath, "TEXT", source)) {
482+
trace('new');
483+
songsFound = CoolUtil.coolTextFile(newPath);
484+
}
485+
else if (Paths.assetsTree.existsSpecific(oldPath, "TEXT", source)) {
486+
trace('old');
487+
Logs.warn("data/freeplaySonglist.txt is deprecated and will be removed in the future. Please move the file to data/config/", DARKYELLOW, "FreeplaySonglist");
488+
songsFound = CoolUtil.coolTextFile(oldPath);
489+
}
490+
}
491+
if (songsFound == null) songsFound = Paths.getFolderDirectories("songs", false, source);
484492
if (songsFound.length > 0) {
485493
for (s in songsFound) songs.push(Chart.loadChartMeta(s, Flags.DEFAULT_DIFFICULTY, source == MODS));
486494
return false;
@@ -499,7 +507,7 @@ class FreeplaySonglist {
499507
songList.getSongsFromSource(SOURCE, useTxt);
500508
songList.getSongsFromSource(MODS, useTxt);
501509
default /*case 'override'*/:
502-
if (songList.getSongsFromSource(MODS, useTxt))
510+
if (!songList.getSongsFromSource(MODS, useTxt))
503511
songList.getSongsFromSource(SOURCE, useTxt);
504512
}
505513

0 commit comments

Comments
 (0)