Skip to content

Instantly share code, notes, and snippets.

@Turupawn
Last active September 9, 2018 23:27
Show Gist options
  • Save Turupawn/b2c58ee8a1cd35142e9ce9396ab87752 to your computer and use it in GitHub Desktop.
Save Turupawn/b2c58ee8a1cd35142e9ce9396ab87752 to your computer and use it in GitHub Desktop.
mod.io haxe wrapper downloadProgressString()
static function downloadProgressString()
{
var installed_mods:Array<Dynamic>;
installed_mods = ModioWrapper.getInstalledMods();
var download_queue:Array<Dynamic>;
download_queue = ModioWrapper.getModDownloadQueue();
var result:String = "";
if(installed_mods.length == 1)
{
result += installed_mods.length + " mod installed through mod.io. ";
}else
{
result += installed_mods.length + " mods installed through mod.io. ";
}
if(download_queue.length > 0)
{
result += download_queue.length + " mods downloading. ";
var current_download = download_queue[0];
if(current_download.current_progress != 0)
{
var progress = current_download.current_progress / current_download.total_size;
progress = Math.round( progress * 100 * Math.pow(10, 2) ) / Math.pow(10, 2);
result += current_download.current_progress + "/" + current_download.total_size + " (" + progress + "%)";
}else
{
result += "Initializing download, please wait.";
}
}else
{
result += "Install mods by subscribing to them.";
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment