Add option to set interval for progress bar update

This commit is contained in:
Sude 2017-08-18 09:33:10 +03:00
parent 4f8843312c
commit 8a71c63b20
3 changed files with 8 additions and 1 deletions

View File

@ -278,6 +278,7 @@ class Config
unsigned int iThreads;
int iWait;
size_t iChunkSize;
int iProgressInterval;
};
#endif // CONFIG_H__

View File

@ -218,6 +218,7 @@ int main(int argc, char *argv[])
("save-changelogs", bpo::value<bool>(&Globals::globalConfig.dlConf.bSaveChangelogs)->zero_tokens()->default_value(false), "Save changelogs when downloading")
("threads", bpo::value<unsigned int>(&Globals::globalConfig.iThreads)->default_value(4), "Number of download threads")
("dlc-list", bpo::value<std::string>(&Globals::globalConfig.sGameHasDLCList)->default_value("https://raw.githubusercontent.com/Sude-/lgogdownloader-lists/master/game_has_dlc.txt"), "Set URL for list of games that have DLC")
("progress-interval", bpo::value<int>(&Globals::globalConfig.iProgressInterval)->default_value(100), "Set interval for progress bar update (milliseconds)\nValue must be between 1 and 10000")
;
// Options read from config file
options_cfg_only.add_options()
@ -416,6 +417,11 @@ int main(int argc, char *argv[])
if (Globals::globalConfig.iWait > 0)
Globals::globalConfig.iWait *= 1000;
if (Globals::globalConfig.iProgressInterval < 1)
Globals::globalConfig.iProgressInterval = 1;
else if (Globals::globalConfig.iProgressInterval > 10000)
Globals::globalConfig.iProgressInterval = 10000;
if (Globals::globalConfig.iThreads < 1)
{
Globals::globalConfig.iThreads = 1;

View File

@ -3133,7 +3133,7 @@ void Downloader::printProgress()
dl_status = DLSTATUS_NOTSTARTED;
// Print progress information once per 100ms
std::this_thread::sleep_for(std::chrono::milliseconds(100));
std::this_thread::sleep_for(std::chrono::milliseconds(Globals::globalConfig.iProgressInterval));
std::cout << "\033[J\r" << std::flush; // Clear screen from the current line down to the bottom of the screen
// Print messages from message queue first