Fixed source assets, I hate this code so much please fix later
Fixed naming convention
This commit is contained in:
@@ -123,9 +123,15 @@ class MusicBeatState extends FlxState implements IBeatReceiver
|
||||
var scriptPaths = [];
|
||||
(scripts = new ScriptPack(scriptName)).setParent(this);
|
||||
scriptPaths = Paths.getScriptPaths('assets/data/states/$scriptName');
|
||||
for (i in Paths.getScriptPaths('assets/data/states', '/$scriptName.'))
|
||||
for (i in Paths.getScriptPaths('assets/data/states', '/$scriptName.'))
|
||||
scriptPaths.push(i);
|
||||
if (scriptPaths.length > 0) for (i in scriptPaths) addScript(i);
|
||||
if (scriptPaths.length > 0)
|
||||
for (i in scriptPaths) {
|
||||
var old = Assets.forceAssetLibrary;
|
||||
Assets.forceAssetLibrary = i.library;
|
||||
addScript(i.file);
|
||||
Assets.forceAssetLibrary = old;
|
||||
}
|
||||
if (Type.getClass(this) != PlayState) scripts.load();
|
||||
}
|
||||
else
|
||||
|
||||
@@ -109,9 +109,15 @@ class MusicBeatSubstate extends FlxSubState implements IBeatReceiver
|
||||
var scriptName = this.scriptName != null ? this.scriptName : className.substr(className.lastIndexOf(".")+1);
|
||||
var scriptPaths = [];
|
||||
scriptPaths = Paths.getScriptPaths('assets/data/states/$scriptName');
|
||||
for (i in Paths.getScriptPaths('assets/data/states', '/$scriptName.'))
|
||||
for (i in Paths.getScriptPaths('assets/data/states', '/$scriptName.'))
|
||||
scriptPaths.push(i);
|
||||
if (scriptPaths.length > 0) for (i in scriptPaths) addScript(i);
|
||||
if (scriptPaths.length > 0)
|
||||
for (i in scriptPaths) {
|
||||
var old = Assets.forceAssetLibrary;
|
||||
Assets.forceAssetLibrary = i.library;
|
||||
addScript(i.file);
|
||||
Assets.forceAssetLibrary = old;
|
||||
}
|
||||
scripts.load();
|
||||
}
|
||||
else
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package funkin.backend.assets;
|
||||
|
||||
import funkin.backend.assets.ModsAssetLibrary;
|
||||
import funkin.backend.assets.IModsAssetLibrary;
|
||||
import lime.utils.AssetLibrary;
|
||||
|
||||
class AssetsLibraryList extends AssetLibrary {
|
||||
@@ -60,8 +60,8 @@ class AssetsLibraryList extends AssetLibrary {
|
||||
|
||||
// TODO: do base folder scanning
|
||||
#if MOD_SUPPORT
|
||||
if (l is ModsAssetLibrary) {
|
||||
var lib = cast(l, ModsAssetLibrary);
|
||||
if (l is IModsAssetLibrary) {
|
||||
var lib = cast(l, IModsAssetLibrary);
|
||||
for(e in lib.getFiles(folder))
|
||||
content.push(e);
|
||||
}
|
||||
@@ -84,8 +84,8 @@ class AssetsLibraryList extends AssetLibrary {
|
||||
|
||||
// TODO: do base folder scanning
|
||||
#if MOD_SUPPORT
|
||||
if (l is ModsAssetLibrary) {
|
||||
var lib = cast(l, ModsAssetLibrary);
|
||||
if (l is IModsAssetLibrary) {
|
||||
var lib = cast(l, IModsAssetLibrary);
|
||||
for(e in lib.getFolders(folder))
|
||||
content.push(e);
|
||||
}
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ import sys.FileSystem;
|
||||
|
||||
using StringTools;
|
||||
|
||||
interface ModsAssetLibrary {
|
||||
interface IModsAssetLibrary {
|
||||
public var prefix:String;
|
||||
public var libName:String;
|
||||
|
||||
@@ -102,7 +102,7 @@ class ModsFolder {
|
||||
return font;
|
||||
}
|
||||
|
||||
public static function prepareModLibrary(libName:String, lib:ModsAssetLibrary, force:Bool = false) {
|
||||
public static function prepareModLibrary(libName:String, lib:IModsAssetLibrary, force:Bool = false) {
|
||||
var openLib = prepareLibrary(libName, force);
|
||||
lib.prefix = 'assets/';
|
||||
@:privateAccess
|
||||
|
||||
@@ -15,7 +15,7 @@ import sys.FileSystem;
|
||||
|
||||
using StringTools;
|
||||
|
||||
class ModsFolderLibrary extends AssetLibrary implements ModsAssetLibrary {
|
||||
class ModsFolderLibrary extends AssetLibrary implements IModsAssetLibrary {
|
||||
public var folderPath:String;
|
||||
public var libName:String;
|
||||
public var useImageCache:Bool = true;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package funkin.backend.assets;
|
||||
|
||||
import lime.utils.AssetLibrary;
|
||||
import flixel.graphics.frames.FlxFramesCollection;
|
||||
import haxe.io.Path;
|
||||
import funkin.backend.assets.LimeLibrarySymbol;
|
||||
@@ -97,22 +98,32 @@ class Paths
|
||||
}
|
||||
return getPath('images/$key.png', library);
|
||||
}
|
||||
static public function getScriptPaths(key:String, excep:String = ""):Array<String> {
|
||||
var scriptsPaths:Array<String> = [];
|
||||
static public function getScriptPaths(key:String, excep:String = ""):Array<ScriptPathInfo> {
|
||||
var scriptsPaths:Array<ScriptPathInfo> = [];
|
||||
var reallib = assetsTree.libraries.copy();
|
||||
reallib.pop();
|
||||
|
||||
key = key.replace("//", "/");
|
||||
|
||||
if (!key.endsWith("/")) key += "/";
|
||||
for (e in reallib) {
|
||||
if (!OpenFlAssets.exists(e.getPath(key).startsWith(".") ? "." + e.getPath(key) : e.getPath(key))) continue;
|
||||
for (i in sys.FileSystem.readDirectory(e.getPath(key)))
|
||||
if (Script.scriptExtensions.contains(Path.extension(i))) {
|
||||
var path = '${e.getPath(key)}$i';
|
||||
if (path.startsWith(".")) path = "." + path;
|
||||
if (path.contains(excep) || excep == "") scriptsPaths.push(path.replace("//", "/"));
|
||||
for (library in reallib) {
|
||||
if (!library.exists(key, null)) continue;
|
||||
|
||||
var path = library.getPath(key);
|
||||
if(path == null) continue;
|
||||
|
||||
for (i in sys.FileSystem.readDirectory(path)) {
|
||||
var file = Path.withoutDirectory(i);
|
||||
if (Script.scriptExtensions.contains(Path.extension(file))) {
|
||||
var filepath = '${key}$file'.replace("//", "/");
|
||||
|
||||
if (filepath.contains(excep) || excep == "")
|
||||
scriptsPaths.push(new ScriptPathInfo(filepath, library));
|
||||
}
|
||||
}
|
||||
}
|
||||
return scriptsPaths;
|
||||
}
|
||||
|
||||
inline static public function script(key:String, ?library:String, isAssetsPath:Bool = false) {
|
||||
var scriptPath = isAssetsPath ? key : getPath(key, library);
|
||||
if (!Script.scriptExtensions.contains(Path.extension(scriptPath))) {
|
||||
@@ -280,9 +291,9 @@ class Paths
|
||||
|
||||
var content:Array<String> = [];
|
||||
#if MOD_SUPPORT
|
||||
if (library is funkin.backend.assets.ModsAssetLibrary) {
|
||||
if (library is funkin.backend.assets.IModsAssetLibrary) {
|
||||
// easy task, can immediately scan for files!
|
||||
var lib = cast(library, funkin.backend.assets.ModsAssetLibrary);
|
||||
var lib = cast(library, funkin.backend.assets.IModsAssetLibrary);
|
||||
content = lib.getFiles(libThing.symbolName);
|
||||
if (addPath)
|
||||
for(i in 0...content.length)
|
||||
@@ -316,3 +327,13 @@ class Paths
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
class ScriptPathInfo {
|
||||
public var file:String;
|
||||
public var library:AssetLibrary;
|
||||
|
||||
public function new(file:String, library:AssetLibrary) {
|
||||
this.file = file;
|
||||
this.library = library;
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,7 @@ import haxe.zip.Reader;
|
||||
import funkin.backend.utils.SysZip;
|
||||
import funkin.backend.utils.SysZip.SysZipEntry;
|
||||
|
||||
class ZipFolderLibrary extends AssetLibrary implements ModsAssetLibrary {
|
||||
class ZipFolderLibrary extends AssetLibrary implements IModsAssetLibrary {
|
||||
public var zipPath:String;
|
||||
public var libName:String;
|
||||
public var useImageCache:Bool = false;
|
||||
|
||||
@@ -82,7 +82,12 @@ class GlobalScript {
|
||||
scripts = new ScriptPack("global");
|
||||
var scriptPaths = Paths.getScriptPaths("assets/data", "/global.");
|
||||
for (i in Paths.getScriptPaths("assets/data/global")) scriptPaths.push(i);
|
||||
for (i in scriptPaths) scripts.add(Script.create(Paths.script(i, null, true)));
|
||||
var old = Assets.forceAssetLibrary;
|
||||
for (i in scriptPaths) {
|
||||
Assets.forceAssetLibrary = i.library;
|
||||
scripts.add(Script.create(Paths.script(i.file, null, true)));
|
||||
}
|
||||
Assets.forceAssetLibrary = old;
|
||||
scripts.load();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package funkin.backend.system.framerate;
|
||||
|
||||
import funkin.backend.assets.ModsAssetLibrary;
|
||||
import funkin.backend.assets.IModsAssetLibrary;
|
||||
|
||||
class AssetTreeInfo extends FramerateCategory {
|
||||
public function new() {
|
||||
@@ -20,8 +20,8 @@ class AssetTreeInfo extends FramerateCategory {
|
||||
if (al.__proxy != null) l = al.__proxy;
|
||||
}
|
||||
|
||||
if (l is ModsAssetLibrary)
|
||||
text += '${Type.getClassName(Type.getClass(l))} - ${cast(l, ModsAssetLibrary).libName} (${cast(l, ModsAssetLibrary).prefix})\n';
|
||||
if (l is IModsAssetLibrary)
|
||||
text += '${Type.getClassName(Type.getClass(l))} - ${cast(l, IModsAssetLibrary).libName} (${cast(l, IModsAssetLibrary).prefix})\n';
|
||||
else
|
||||
text += Std.string(e) + "\n";
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ import flixel.util.FlxColor;
|
||||
import flixel.util.FlxSort;
|
||||
import flixel.util.FlxTimer;
|
||||
import haxe.io.Path;
|
||||
import lime.utils.Assets;
|
||||
import funkin.backend.system.Conductor;
|
||||
import funkin.game.cutscenes.*;
|
||||
|
||||
@@ -557,17 +556,26 @@ class PlayState extends MusicBeatState
|
||||
// ADD YOUR HARDCODED SCRIPTS HERE!
|
||||
default:
|
||||
for(content in [Paths.getScriptPaths('assets/songs/${SONG.meta.name.toLowerCase()}/scripts'), Paths.getScriptPaths('assets/data/charts/')])
|
||||
for(file in content) addScript(file);
|
||||
for(file in content) {
|
||||
var old = Assets.forceAssetLibrary;
|
||||
Assets.forceAssetLibrary = file.library;
|
||||
addScript(file.file);
|
||||
Assets.forceAssetLibrary = old;
|
||||
}
|
||||
|
||||
var songEvents:Array<String> = [];
|
||||
for (event in SONG.events)
|
||||
for (event in SONG.events)
|
||||
if (!songEvents.contains(event.name)) songEvents.push(event.name);
|
||||
|
||||
for (file in Paths.getScriptPaths('assets/data/events/')) {
|
||||
var fileName:String = Path.withoutExtension(Path.withoutDirectory(file));
|
||||
if (EventsData.eventsList.contains(fileName) && songEvents.contains(fileName)) addScript(file);
|
||||
var old = Assets.forceAssetLibrary;
|
||||
Assets.forceAssetLibrary = file.library;
|
||||
|
||||
var fileName:String = Path.withoutExtension(Path.withoutDirectory(file.file));
|
||||
if (EventsData.eventsList.contains(fileName) && songEvents.contains(fileName)) addScript(file.file);
|
||||
|
||||
Assets.forceAssetLibrary = old;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
add(comboGroup);
|
||||
|
||||
@@ -3,7 +3,7 @@ package funkin.menus.ui;
|
||||
import openfl.utils.AssetLibrary;
|
||||
import haxe.xml.Access;
|
||||
import funkin.backend.assets.LimeLibrarySymbol;
|
||||
import funkin.backend.assets.ModsAssetLibrary;
|
||||
import funkin.backend.assets.IModsAssetLibrary;
|
||||
import flixel.graphics.frames.FlxAtlasFrames;
|
||||
import flixel.group.FlxSpriteGroup;
|
||||
import flixel.util.FlxTimer;
|
||||
@@ -100,8 +100,8 @@ class Alphabet extends FlxSpriteGroup
|
||||
@:privateAccess
|
||||
library = cast(library.__proxy, AssetLibrary);
|
||||
}
|
||||
if (library is ModsAssetLibrary) {
|
||||
var modLib = cast(library, ModsAssetLibrary);
|
||||
if (library is IModsAssetLibrary) {
|
||||
var modLib = cast(library, IModsAssetLibrary);
|
||||
@:privateAccess
|
||||
if (!modLib.__isCacheValid(library.cachedBytes, libThing.symbolName)) {
|
||||
refreshAlphabetXML(alphabetPath);
|
||||
|
||||
@@ -24,8 +24,8 @@ class FunkinSave {
|
||||
public static var save:FlxSave;
|
||||
|
||||
public static function init() {
|
||||
trace(Application.current.meta.get('save-path'));
|
||||
trace(Application.current.meta.get('save-name'));
|
||||
//trace(Application.current.meta.get('save-path'));
|
||||
//trace(Application.current.meta.get('save-name'));
|
||||
save = new FlxSave();
|
||||
save.bind('save-default', #if sys 'YoshiCrafter29/CodenameEngine' #else 'CodenameEngine' #end);
|
||||
load();
|
||||
|
||||
@@ -48,6 +48,8 @@ class Assets
|
||||
{
|
||||
public static var cache:IAssetCache = new AssetCache();
|
||||
|
||||
public static var forceAssetLibrary:LimeAssetLibrary = null;
|
||||
|
||||
@:noCompletion private static var dispatcher:EventDispatcher #if !macro = new EventDispatcher() #end;
|
||||
private static var libraryBindings:Map<String, AssetLibrary> = new Map();
|
||||
|
||||
@@ -76,6 +78,9 @@ class Assets
|
||||
**/
|
||||
public static function exists(id:String, type:AssetType = null):Bool
|
||||
{
|
||||
if(forceAssetLibrary != null) {
|
||||
return forceAssetLibrary.exists(id, cast type);
|
||||
}
|
||||
#if lime
|
||||
return LimeAssets.exists(id, cast type);
|
||||
#else
|
||||
@@ -260,6 +265,9 @@ class Assets
|
||||
**/
|
||||
public static function getPath(id:String):String
|
||||
{
|
||||
if(forceAssetLibrary != null) {
|
||||
return forceAssetLibrary.getPath(id);
|
||||
}
|
||||
#if lime
|
||||
return LimeAssets.getPath(id);
|
||||
#else
|
||||
@@ -317,6 +325,9 @@ class Assets
|
||||
**/
|
||||
public static function getText(id:String):String
|
||||
{
|
||||
if(forceAssetLibrary != null) {
|
||||
return forceAssetLibrary.getText(id);
|
||||
}
|
||||
#if lime
|
||||
return LimeAssets.getText(id);
|
||||
#else
|
||||
|
||||
Reference in New Issue
Block a user