|
|
|
@@ -21,7 +21,7 @@ class Paths
|
|
|
|
|
* Preferred sound extension for the game's audio files.
|
|
|
|
|
* Currently is set to `mp3` for web targets, and `ogg` for other targets.
|
|
|
|
|
*/
|
|
|
|
|
inline public static final SOUND_EXT = #if web "mp3" #else "ogg" #end;
|
|
|
|
|
public static inline final SOUND_EXT = #if web "mp3" #else "ogg" #end;
|
|
|
|
|
|
|
|
|
|
public static inline var translFolderName:String = "translations";
|
|
|
|
|
|
|
|
|
@@ -50,56 +50,53 @@ class Paths
|
|
|
|
|
public static inline function ndll(key:String)
|
|
|
|
|
return getPath('ndlls/$key.ndll');
|
|
|
|
|
|
|
|
|
|
inline static public function file(file:String, ?library:String)
|
|
|
|
|
public static inline function file(file:String, ?library:String)
|
|
|
|
|
return getPath(file, library);
|
|
|
|
|
|
|
|
|
|
inline static public function txt(key:String, ?library:String)
|
|
|
|
|
public static inline function txt(key:String, ?library:String)
|
|
|
|
|
return getPath('data/$key.txt', library);
|
|
|
|
|
|
|
|
|
|
inline static public function pack(key:String, ?library:String)
|
|
|
|
|
public static inline function pack(key:String, ?library:String)
|
|
|
|
|
return getPath('data/$key.pack', library);
|
|
|
|
|
|
|
|
|
|
inline static public function ini(key:String, ?library:String)
|
|
|
|
|
public static inline function ini(key:String, ?library:String)
|
|
|
|
|
return getPath('data/$key.ini', library);
|
|
|
|
|
|
|
|
|
|
inline static public function fragShader(key:String, ?library:String)
|
|
|
|
|
public static inline function fragShader(key:String, ?library:String)
|
|
|
|
|
return getPath('shaders/$key.frag', library);
|
|
|
|
|
|
|
|
|
|
inline static public function vertShader(key:String, ?library:String)
|
|
|
|
|
public static inline function vertShader(key:String, ?library:String)
|
|
|
|
|
return getPath('shaders/$key.vert', library);
|
|
|
|
|
|
|
|
|
|
inline static public function xml(key:String, ?library:String)
|
|
|
|
|
public static inline function xml(key:String, ?library:String)
|
|
|
|
|
return getPath('data/$key.xml', library);
|
|
|
|
|
|
|
|
|
|
inline static public function json(key:String, ?library:String)
|
|
|
|
|
public static inline function json(key:String, ?library:String)
|
|
|
|
|
return getPath('data/$key.json', library);
|
|
|
|
|
|
|
|
|
|
inline static public function ps1(key:String, ?library:String)
|
|
|
|
|
public static inline function ps1(key:String, ?library:String)
|
|
|
|
|
return getPath('data/$key.ps1', library);
|
|
|
|
|
|
|
|
|
|
static public function sound(key:String, ?library:String)
|
|
|
|
|
public static function sound(key:String, ?library:String)
|
|
|
|
|
return getPath('sounds/$key.$SOUND_EXT', library);
|
|
|
|
|
|
|
|
|
|
inline static public function soundRandom(key:String, min:Int, max:Int, ?library:String)
|
|
|
|
|
public static inline function soundRandom(key:String, min:Int, max:Int, ?library:String)
|
|
|
|
|
return sound(key + FlxG.random.int(min, max), library);
|
|
|
|
|
|
|
|
|
|
inline static public function music(key:String, ?library:String)
|
|
|
|
|
public static inline function music(key:String, ?library:String)
|
|
|
|
|
return getPath('music/$key.$SOUND_EXT', library);
|
|
|
|
|
|
|
|
|
|
inline static public function voices(song:String, difficulty:String = "normal", ?prefix:String = "")
|
|
|
|
|
{
|
|
|
|
|
public static inline function voices(song:String, difficulty:String = "normal", ?prefix:String = "") {
|
|
|
|
|
var diff = getPath('songs/${song.toLowerCase()}/song/Voices$prefix-${difficulty.toLowerCase()}.$SOUND_EXT', null);
|
|
|
|
|
return OpenFlAssets.exists(diff) ? diff : getPath('songs/${song.toLowerCase()}/song/Voices$prefix.$SOUND_EXT', null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline static public function inst(song:String, difficulty:String = "normal", ?prefix:String = "")
|
|
|
|
|
{
|
|
|
|
|
public static inline function inst(song:String, difficulty:String = "normal", ?prefix:String = "") {
|
|
|
|
|
var diff = getPath('songs/${song.toLowerCase()}/song/Inst$prefix-${difficulty.toLowerCase()}.$SOUND_EXT', null);
|
|
|
|
|
return OpenFlAssets.exists(diff) ? diff : getPath('songs/${song.toLowerCase()}/song/Inst$prefix.$SOUND_EXT', null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static public function image(key:String, ?library:String, checkForAtlas:Bool = false, ?ext:String = "png")
|
|
|
|
|
{
|
|
|
|
|
public static function image(key:String, ?library:String, checkForAtlas:Bool = false, ?ext:String = "png") {
|
|
|
|
|
if (checkForAtlas) {
|
|
|
|
|
var atlasPath = getPath('images/$key/spritemap.$ext', library);
|
|
|
|
|
var multiplePath = getPath('images/$key/1.$ext', library);
|
|
|
|
@@ -109,7 +106,7 @@ class Paths
|
|
|
|
|
return getPath('images/$key.$ext', library);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline static public function script(key:String, ?library:String, isAssetsPath:Bool = false) {
|
|
|
|
|
public static inline function script(key:String, ?library:String, isAssetsPath:Bool = false) {
|
|
|
|
|
var scriptPath = isAssetsPath ? key : getPath(key, library);
|
|
|
|
|
if (!OpenFlAssets.exists(scriptPath)) {
|
|
|
|
|
var p:String;
|
|
|
|
@@ -124,62 +121,61 @@ class Paths
|
|
|
|
|
return scriptPath;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static public function chart(song:String, ?difficulty:String = "normal"):String {
|
|
|
|
|
public static function chart(song:String, ?difficulty:String = "normal"):String {
|
|
|
|
|
difficulty = difficulty.toLowerCase();
|
|
|
|
|
song = song.toLowerCase();
|
|
|
|
|
|
|
|
|
|
return getPath('songs/$song/charts/$difficulty.json', null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static public function character(character:String):String {
|
|
|
|
|
public static function character(character:String):String {
|
|
|
|
|
return getPath('data/characters/$character.xml', null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline static public function font(key:String)
|
|
|
|
|
{
|
|
|
|
|
public static inline function font(key:String) {
|
|
|
|
|
return getPath('fonts/$key');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline static public function obj(key:String) {
|
|
|
|
|
public static inline function obj(key:String) {
|
|
|
|
|
return getPath('models/$key.obj');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline static public function dae(key:String) {
|
|
|
|
|
public static inline function dae(key:String) {
|
|
|
|
|
return getPath('models/$key.dae');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline static public function md2(key:String) {
|
|
|
|
|
public static inline function md2(key:String) {
|
|
|
|
|
return getPath('models/$key.md2');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline static public function md5(key:String) {
|
|
|
|
|
public static inline function md5(key:String) {
|
|
|
|
|
return getPath('models/$key.md5');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline static public function awd(key:String) {
|
|
|
|
|
public static inline function awd(key:String) {
|
|
|
|
|
return getPath('models/$key.awd');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline static public function getSparrowAtlas(key:String, ?library:String)
|
|
|
|
|
public static inline function getSparrowAtlas(key:String, ?library:String)
|
|
|
|
|
return FlxAtlasFrames.fromSparrow(image(key, library), file('images/$key.xml', library));
|
|
|
|
|
|
|
|
|
|
inline static public function getSparrowAtlasAlt(key:String)
|
|
|
|
|
public static inline function getSparrowAtlasAlt(key:String)
|
|
|
|
|
return FlxAtlasFrames.fromSparrow('$key.png', '$key.xml');
|
|
|
|
|
|
|
|
|
|
inline static public function getPackerAtlas(key:String, ?library:String)
|
|
|
|
|
public static inline function getPackerAtlas(key:String, ?library:String)
|
|
|
|
|
return FlxAtlasFrames.fromSpriteSheetPacker(image(key, library), file('images/$key.txt', library));
|
|
|
|
|
|
|
|
|
|
inline static public function getPackerAtlasAlt(key:String)
|
|
|
|
|
public static inline function getPackerAtlasAlt(key:String)
|
|
|
|
|
return FlxAtlasFrames.fromSpriteSheetPacker('$key.png', '$key.txt');
|
|
|
|
|
|
|
|
|
|
inline static public function getAsepriteAtlas(key:String, ?library:String)
|
|
|
|
|
public static inline function getAsepriteAtlas(key:String, ?library:String)
|
|
|
|
|
return FlxAtlasFrames.fromAseprite(image(key, library), file('images/$key.json', library));
|
|
|
|
|
|
|
|
|
|
inline static public function getAsepriteAtlasAlt(key:String)
|
|
|
|
|
public static inline function getAsepriteAtlasAlt(key:String)
|
|
|
|
|
return FlxAtlasFrames.fromAseprite('$key.png', '$key.json');
|
|
|
|
|
|
|
|
|
|
inline static public function getAssetsRoot():String
|
|
|
|
|
return ModsFolder.currentModFolder != null ? '${ModsFolder.modsPath}${ModsFolder.currentModFolder}' : './assets';
|
|
|
|
|
public static inline function getAssetsRoot():String
|
|
|
|
|
return ModsFolder.currentModFolder != null ? '${ModsFolder.modsPath}${ModsFolder.currentModFolder}' : './assets';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Gets frames at specified path.
|
|
|
|
@@ -239,7 +235,8 @@ class Paths
|
|
|
|
|
return null;
|
|
|
|
|
return graph.imageFrame;
|
|
|
|
|
}
|
|
|
|
|
static public function getFolderDirectories(key:String, addPath:Bool = false, source:AssetsLibraryList.AssetSource = BOTH):Array<String> {
|
|
|
|
|
|
|
|
|
|
public static function getFolderDirectories(key:String, addPath:Bool = false, source:AssetsLibraryList.AssetSource = BOTH):Array<String> {
|
|
|
|
|
if (!key.endsWith("/")) key += "/";
|
|
|
|
|
var content = assetsTree.getFolders('assets/$key', source);
|
|
|
|
|
if (addPath) {
|
|
|
|
@@ -248,7 +245,8 @@ class Paths
|
|
|
|
|
}
|
|
|
|
|
return content;
|
|
|
|
|
}
|
|
|
|
|
static public function getFolderContent(key:String, addPath:Bool = false, source:AssetsLibraryList.AssetSource = BOTH):Array<String> {
|
|
|
|
|
|
|
|
|
|
public static function getFolderContent(key:String, addPath:Bool = false, source:AssetsLibraryList.AssetSource = BOTH):Array<String> {
|
|
|
|
|
// designed to work both on windows and web
|
|
|
|
|
if (!key.endsWith("/")) key += "/";
|
|
|
|
|
var content = assetsTree.getFiles('assets/$key', source);
|
|
|
|
@@ -257,58 +255,6 @@ class Paths
|
|
|
|
|
content[k] = '$key$e';
|
|
|
|
|
}
|
|
|
|
|
return content;
|
|
|
|
|
/*
|
|
|
|
|
if (!key.endsWith("/")) key = key + "/";
|
|
|
|
|
|
|
|
|
|
if (ModsFolder.currentModFolder == null && !scanSource)
|
|
|
|
|
return getFolderContent(key, false, addPath, true);
|
|
|
|
|
|
|
|
|
|
var folderPath:String = scanSource ? getAssetsPath(key) : getLibraryPathForce(key, 'mods/${ModsFolder.currentModFolder}');
|
|
|
|
|
var libThing = new LimeLibrarySymbol(folderPath);
|
|
|
|
|
var library = libThing.library;
|
|
|
|
|
|
|
|
|
|
if (library is openfl.utils.AssetLibrary) {
|
|
|
|
|
var lib = cast(libThing.library, openfl.utils.AssetLibrary);
|
|
|
|
|
@:privateAccess
|
|
|
|
|
if (lib.__proxy != null) library = lib.__proxy;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var content:Array<String> = [];
|
|
|
|
|
#if MOD_SUPPORT
|
|
|
|
|
if (library is funkin.backend.assets.IModsAssetLibrary) {
|
|
|
|
|
// easy task, can immediately scan for files!
|
|
|
|
|
var lib = cast(library, funkin.backend.assets.IModsAssetLibrary);
|
|
|
|
|
content = lib.getFiles(libThing.symbolName);
|
|
|
|
|
if (addPath)
|
|
|
|
|
for(i in 0...content.length)
|
|
|
|
|
content[i] = '$folderPath${content[i]}';
|
|
|
|
|
} else #end {
|
|
|
|
|
@:privateAccess
|
|
|
|
|
for(k=>e in library.paths) {
|
|
|
|
|
if (k.toLowerCase().startsWith(libThing.symbolName.toLowerCase())) {
|
|
|
|
|
if (addPath) {
|
|
|
|
|
if (libThing.libraryName != "")
|
|
|
|
|
content.push('${libThing.libraryName}:$k');
|
|
|
|
|
else
|
|
|
|
|
content.push(k);
|
|
|
|
|
} else {
|
|
|
|
|
var barebonesFileName = k.substr(libThing.symbolName.length);
|
|
|
|
|
if (!barebonesFileName.contains("/"))
|
|
|
|
|
content.push(barebonesFileName);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (includeSource) {
|
|
|
|
|
var sourceResult = getFolderContent(key, false, addPath, true);
|
|
|
|
|
for(e in sourceResult)
|
|
|
|
|
if (!content.contains(e))
|
|
|
|
|
content.push(e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return content;
|
|
|
|
|
*/
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Used in Script.hx
|
|
|
|
|