diff --git a/source/Paths.hx b/source/Paths.hx index d172ae34485..0d10cc59895 100644 --- a/source/Paths.hx +++ b/source/Paths.hx @@ -125,8 +125,10 @@ class Paths var config = splashConfigs.get(splashSkin); if (config == null) config = initSplashConfig(splashSkin); var maxAnims:Int = 0; - var animName = config.anim; - if(animName == null) + var animName:String = 'note splash'; + if (config != null) + animName = config.anim; + else if(animName == null) animName = config != null ? config.anim : 'note splash'; var shouldBreakLoop = false; @@ -359,6 +361,32 @@ class Paths return getPreloadPath(file); } + public static inline function readDirectory(path:String):Array { + #if sys + return FileSystem.readDirectory(path); + #else + // original by Karim Akra + var files:Array = []; + + for (possibleFile in Assets.list().filter((f) -> f.contains(path))) { + var file:String = possibleFile.replace('${path}/', ""); + if (file.contains("/")) + file = file.replace(file.substring(file.indexOf("/"), file.length), ""); + + if (!files.contains(file)) + files.push(file); + } + + files.sort((a, b) -> { + a = a.toUpperCase(); + b = b.toUpperCase(); + return (a < b) ? -1 : (a > b) ? 1 : 0; + }); + + return files; + #end + } + static public function getLibraryPath(file:String, library = "preload") { return if (library == "preload" || library == "default") getPreloadPath(file); else getLibraryPathForce(file, library); diff --git a/source/UpdateState.hx b/source/UpdateState.hx index 8b355f64a70..adbc6291ea2 100644 --- a/source/UpdateState.hx +++ b/source/UpdateState.hx @@ -156,24 +156,27 @@ class UpdateState extends MusicBeatState } } + inline function getPlatform():String + { + #if windows + return 'windows'; + #elseif mac + return 'macOS'; + #elseif linux + return 'linux'; + #elseif android + return 'android'; + /* + #elseif ios + return 'iOS'; + */ + #else + return ''; + #end + } + inline function getUpdateLink() { - function getPlatform():String - { - #if windows - return 'windows'; - #elseif mac - return 'macOS'; - #elseif linux - return 'linux'; - #elseif android - return 'android'; - /*#elseif ios - return 'iOS';*/ - #else - return ''; - #end - } var fileEnd = #if android 'apk' #else 'zip' #end; online_url = "https://github.com/JordanSantiagoYT/FNF-JS-Engine/releases/download/" + TitleState.updateVersion + '/FNF-JS-Engine-${getPlatform}.$fileEnd'; trace("update url: " + online_url); @@ -202,15 +205,23 @@ class UpdateState extends MusicBeatState } var httpHandler:Http; + var fatalError:Bool = false; public function startDownload() { trace("starting download process..."); + final url:String = requestUrl(online_url); + if (url != null && url.indexOf('Not Found') != -1) + { + trace('File not found error!'); + fatalError = true; + } + zip.load(new URLRequest(online_url)); - if (zip.bytesTotal <= 100) // since the games bytes are *way* more then that + if (fatalError) { - trace('File size is small! Assuming it couldn\'t find the url!'); + // trace('File size is small! Assuming it couldn\'t find the url!'); lime.app.Application.current.window.alert('Couldn\'t find the URL for the file! Cancelling download!'); FlxG.resetGame(); return; @@ -239,6 +250,7 @@ class UpdateState extends MusicBeatState httpHandler.onError = function(e) { trace("error while downloading file, error: " + e); + fatalError = true; } httpHandler.request(false); return r;