mirror of
https://github.com/DarkStore-3DS/DarkStore.git
synced 2026-07-03 00:39:02 +00:00
Do Download Speed optional.
Cause I cannot properly fix that now.
This commit is contained in:
@@ -851,22 +851,10 @@ void displayProgressBar() {
|
||||
downloadTotal = downloadNow;
|
||||
}
|
||||
|
||||
if (!curlResult) {
|
||||
curl_off_t speed;
|
||||
curlResult = curl_easy_getinfo(hnd, CURLINFO_SPEED_DOWNLOAD_T, &speed);
|
||||
if (!curlResult) {
|
||||
snprintf(str, sizeof(str), "%s / %s (%.2f%%) \n\n\n\n\n %s %lld %s",
|
||||
formatBytes(downloadNow).c_str(),
|
||||
formatBytes(downloadTotal).c_str(),
|
||||
((float)downloadNow/(float)downloadTotal) * 100.0f,
|
||||
Lang::get("DOWNLOAD_SPEED").c_str(), (speed / 1000), Lang::get("KB_PER_SECOND").c_str());
|
||||
} else {
|
||||
snprintf(str, sizeof(str), "%s / %s (%.2f%%)",
|
||||
formatBytes(downloadNow).c_str(),
|
||||
formatBytes(downloadTotal).c_str(),
|
||||
((float)downloadNow/(float)downloadTotal) * 100.0f);
|
||||
}
|
||||
}
|
||||
snprintf(str, sizeof(str), "%s / %s (%.2f%%)",
|
||||
formatBytes(downloadNow).c_str(),
|
||||
formatBytes(downloadTotal).c_str(),
|
||||
((float)downloadNow/(float)downloadTotal) * 100.0f);
|
||||
break;
|
||||
case ProgressBar::Extracting:
|
||||
snprintf(str, sizeof(str), "%s / %s (%.2f%%)",
|
||||
@@ -893,6 +881,16 @@ void displayProgressBar() {
|
||||
switch(progressbarType) {
|
||||
case ProgressBar::Downloading:
|
||||
Gui::DrawStringCentered(0, 80, 0.6f, isScriptSelected ? TextColor : config->textColor(), str, 400);
|
||||
|
||||
if (!curlResult && hnd != nullptr && config->showSpeed()) {
|
||||
curl_off_t speed = 0;
|
||||
curlResult = curl_easy_getinfo(hnd, CURLINFO_SPEED_DOWNLOAD_T, &speed);
|
||||
if (!curlResult) {
|
||||
GFX::TextFormatted(0, 170, 0.6f, "%s %lld %s", Lang::get("DOWNLOAD_SPEED").c_str(), (speed / 1000), Lang::get("KB_PER_SECOND").c_str());
|
||||
} else {
|
||||
Gui::DrawStringCentered(0, 170, 0.6f, isScriptSelected ? TextColor : config->textColor(), Lang::get("DOWNLOAD_SPEED") + "?");
|
||||
}
|
||||
}
|
||||
Animation::DrawProgressBar(downloadNow, downloadTotal);
|
||||
break;
|
||||
case ProgressBar::Extracting:
|
||||
|
||||
@@ -98,4 +98,14 @@ void GFX::DrawButton(int x, int y, std::string ButtonText, u32 color) {
|
||||
C2D_SetImageTint(&tint, C2D_BotRight, color, 0.5);
|
||||
C2D_DrawImageAt(C2D_SpriteSheetGetImage(sprites, sprites_button_idx), x, y, 0.5f, &tint);
|
||||
Gui::DrawStringCentered(- (158/2) + x, y + (61/2) - (Gui::GetStringHeight(0.6f, ButtonText) / 2), 0.6f, isScriptSelected ? TextColor : config->textColor(), ButtonText, 145, 30);
|
||||
}
|
||||
|
||||
void GFX::TextFormatted(float x, float y, float size, const char *format, ...) {
|
||||
char str[512];
|
||||
va_list va;
|
||||
va_start(va, format);
|
||||
vsnprintf(str, 512, format, va);
|
||||
va_end(va);
|
||||
char * Text = strtok(str, "\n");
|
||||
Gui::DrawStringCentered(x, y, size, isScriptSelected ? TextColor : config->textColor(), Text);
|
||||
}
|
||||
@@ -68,6 +68,7 @@ void Config::initialize() {
|
||||
this->setString("LANGUAGE", "en");
|
||||
this->setBool("FIRST_STARTUP", true);
|
||||
this->setBool("USE_SCRIPT_COLORS", true);
|
||||
this->setBool("SHOW_SPEED", false);
|
||||
this->setInt("VERSION", this->configVersion);
|
||||
|
||||
// Write to file.
|
||||
@@ -258,6 +259,12 @@ Config::Config() {
|
||||
this->useScriptColor(this->getBool("USE_SCRIPT_COLORS"));
|
||||
}
|
||||
|
||||
if (!this->json.contains("SHOW_SPEED")) {
|
||||
this->showSpeed(false);
|
||||
} else {
|
||||
this->showSpeed(this->getBool("SHOW_SPEED"));
|
||||
}
|
||||
|
||||
this->changesMade = false; // No changes made yet.
|
||||
}
|
||||
|
||||
@@ -294,6 +301,7 @@ void Config::save() {
|
||||
this->setString("LANGUAGE", this->language());
|
||||
this->setBool("FIRST_STARTUP", this->firstStartup());
|
||||
this->setBool("USE_SCRIPT_COLORS", this->useScriptColor());
|
||||
this->setBool("SHOW_SPEED", this->showSpeed());
|
||||
// Write changes to file.
|
||||
fwrite(this->json.dump(1, '\t').c_str(), 1, this->json.dump(1, '\t').size(), file);
|
||||
fclose(file);
|
||||
|
||||
Reference in New Issue
Block a user