1
0
Fork 0

Splash screen: add counter displaying how many MBs are left to extract

This commit is contained in:
legoboyvdlp R 2021-02-12 16:28:39 +00:00 committed by James Turner
parent 00dbd23bec
commit bf26817d53

View file

@ -685,6 +685,7 @@ void fgSplashProgress( const char *identifier, unsigned int percent )
std::ostringstream oss;
unsigned int kbytesPerSec = fgGetInt("/sim/terrasync/transfer-rate-bytes-sec") / 1024;
unsigned int kbytesPending = fgGetInt("/sim/terrasync/pending-kbytes");
unsigned int kbytesPendingExtract = fgGetInt("/sim/terrasync/extract-pending-kbytes");
if (kbytesPending > 0) {
if (kbytesPending > 1024) {
int mBytesPending = kbytesPending >> 10;
@ -693,15 +694,47 @@ void fgSplashProgress( const char *identifier, unsigned int percent )
oss << " " << kbytesPending << "KB";
}
}
if (kbytesPerSec > 100) {
double mbytesPerSec = kbytesPerSec / 1024.0;
oss << " - " << std::fixed << std::setprecision(1) << mbytesPerSec << "MB/sec";
} else {
} else if (kbytesPerSec > 0) {
oss << " - " << kbytesPerSec << " KB/sec";
} else if (kbytesPendingExtract > 0) {
const string extractText = globals->get_locale()->getLocalizedString("scenery-extract", "sys");
std::ostringstream os2;
if (kbytesPendingExtract > 1024) {
int mBytesPendingExtract = kbytesPendingExtract >> 10;
os2 << mBytesPendingExtract << "MB";
} else {
os2 << kbytesPendingExtract << "KB";
}
auto finalText = simgear::strutils::replace(extractText, "[VALUE]", os2.str());
oss << " - " << finalText;
}
fgSetString("/sim/startup/splash-progress-spinner", oss.str());
}
if (!strcmp(identifier, "loading-scenery")) {
unsigned int kbytesPendingExtract = fgGetInt("/sim/terrasync/extract-pending-kbytes");
if (kbytesPendingExtract > 0) {
const string extractText = globals->get_locale()->getLocalizedString("scenery-extract", "sys");
std::ostringstream oss;
if (kbytesPendingExtract > 1024) {
int mBytesPendingExtract = kbytesPendingExtract >> 10;
oss << mBytesPendingExtract << "MB";
} else {
oss << kbytesPendingExtract << "KB";
}
auto finalText = simgear::strutils::replace(extractText, "[VALUE]", oss.str());
fgSetString("/sim/startup/splash-progress-spinner", finalText);
} else {
fgSetString("/sim/startup/splash-progress-spinner", "");
}
}
// over-write the spinner
if (!strncmp(identifier, "navdata-", 8)) {
const string percentText = globals->get_locale()->getLocalizedString("navdata-load-percent", "sys");