Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
mcagabe19 committed Sep 21, 2024
2 parents e38d645 + 9a94921 commit feec08d
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 20 deletions.
32 changes: 30 additions & 2 deletions source/Paths.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -359,6 +361,32 @@ class Paths
return getPreloadPath(file);
}

public static inline function readDirectory(path:String):Array<String> {
#if sys
return FileSystem.readDirectory(path);
#else
// original by Karim Akra
var files:Array<String> = [];

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);
Expand Down
48 changes: 30 additions & 18 deletions source/UpdateState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit feec08d

Please sign in to comment.