From 0f37595c308d55d850853329cfcfa82f3e6e3d50 Mon Sep 17 00:00:00 2001 From: ac-stef Date: Tue, 1 Sep 2015 21:55:09 +0200 Subject: [PATCH] alternative progress visualisation for map and mod downloads no need to switch to the loadingscreen for those --- source/src/autodownload.cpp | 14 +++++++++----- source/src/client.cpp | 2 +- source/src/protos.h | 2 +- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/source/src/autodownload.cpp b/source/src/autodownload.cpp index ed73622b..7b3ad86c 100644 --- a/source/src/autodownload.cpp +++ b/source/src/autodownload.cpp @@ -338,11 +338,15 @@ int progress_n, progress_of; int progress_callback_dlpackage(void *data, float progress) { - loadingscreen("downloading package %d of %d...\n%s %d%%\n(ESC to cancel)", progress_n, progress_of, (const char *)data, int(100.0 * progress)); + if(progress_of < 0) + { + defformatstring(txt)("downloading %s... (esc to abort)", (const char *)data); + show_out_of_renderloop_progress(min(progress, 1.0f), txt); + } + else loadingscreen("downloading package %d of %d...\n%s %d%%\n(ESC to cancel)", progress_n, progress_of, (const char *)data, int(100.0 * progress)); if(interceptkey(SDLK_ESCAPE)) { canceldownloads = true; - loadingscreen(); return 1; } return 0; @@ -398,12 +402,12 @@ int pckserversort(pckserver **a, pckserver **b) return (*b)->ping - (*a)->ping; // or whichever ping is not zero } -int downloadpackages() // get all pending packages +int downloadpackages(bool loadscr) // get all pending packages { bool failed = false; httpget h; canceldownloads = false; - progress_of = pendingpackages.length(); + progress_of = loadscr ? pendingpackages.length() : -1; sem_pckservers.wait(); pckservers.sort(pckserversort); loopv(pendingpackages) @@ -501,7 +505,7 @@ void writepcksourcecfg() void getmod(char *name) { - if(requirepackage(PCK_MOD, name) && downloadpackages()) conoutf("mod package %s successfully downloaded", name); + if(requirepackage(PCK_MOD, name) && downloadpackages(false)) conoutf("mod package %s successfully downloaded", name); else conoutf("failed to download mod package %s", name); } COMMAND(getmod, "s"); diff --git a/source/src/client.cpp b/source/src/client.cpp index ebc26899..a9ac3d93 100644 --- a/source/src/client.cpp +++ b/source/src/client.cpp @@ -797,7 +797,7 @@ void getmap(char *name, char *callback) else { requirepackage(PCK_MAP, name); - if(downloadpackages()) + if(downloadpackages(false)) { if(callback && *callback) execute(callback); conoutf("map %s installed successfully", name); diff --git a/source/src/protos.h b/source/src/protos.h index 593a903e..2cd5ffb7 100644 --- a/source/src/protos.h +++ b/source/src/protos.h @@ -376,7 +376,7 @@ extern int autodownload; extern void setupautodownload(); extern void pollautodownloadresponse(); extern bool requirepackage(int type, const char *name, const char *host = NULL); -extern int downloadpackages(); +extern int downloadpackages(bool loadscr = true); extern void sortpckservers(); extern void writepcksourcecfg();