diff --git a/include/utils/config.hpp b/include/utils/config.hpp index 4f99684..64cced9 100644 --- a/include/utils/config.hpp +++ b/include/utils/config.hpp @@ -32,7 +32,7 @@ namespace Config { extern int LangPath, Color1, Color2, Color3, TxtColor, SelectedColor, UnselectedColor, viewMode, progressbarColor, autoboot, outdated, uptodate, notFound, future, Button, keyDelay; extern std::string lang, ScriptPath, MusicPath, StorePath, AutobootFile; - extern bool Logging, UseBars, fading; + extern bool Logging, UseBars, fading, progress; void load(); void save(); diff --git a/romfs/lang/en/app.json b/romfs/lang/en/app.json index 144ef45..be25f79 100644 --- a/romfs/lang/en/app.json +++ b/romfs/lang/en/app.json @@ -178,5 +178,7 @@ "ENABLED": "Enabled!", "DISABLED": "Disabled!", "DOWNLOAD_SPEED": "Download Speed: ", - "BYTES_PER_SECOND": " bytes per second" + "BYTES_PER_SECOND": " bytes per second", + "PROGRESS_BAR_ENABLE": "Would you like to enable the progressbar?", + "PROGRESS_BAR_DISABLE": "Would you like to disable the progressbar?" } diff --git a/source/animation.cpp b/source/animation.cpp index 958d005..1ef93fd 100644 --- a/source/animation.cpp +++ b/source/animation.cpp @@ -34,26 +34,41 @@ extern C2D_SpriteSheet sprites; // Draws a Rectangle as the progressbar. void Animation::DrawProgressBar(float currentProgress, float totalProgress, int mode) { - if (mode == 1) { - Gui::Draw_Rect(31, 121, (int)(((float)currentProgress / (float)totalProgress) * 338.0f), 28, progressBar); - } else { - Gui::Draw_Rect(31, 121, (int)(((float)currentProgress / (float)totalProgress) * 338.0f), 28, Config::progressbarColor); + if (Config::progress) { + // Outline of progressbar. + Gui::Draw_Rect(30, 120, 340, 30, BLACK); + + if (mode == 1) { + Gui::Draw_Rect(31, 121, (int)(((float)currentProgress / (float)totalProgress) * 338.0f), 28, progressBar); + } else { + Gui::Draw_Rect(31, 121, (int)(((float)currentProgress / (float)totalProgress) * 338.0f), 28, Config::progressbarColor); + } } } void Animation::DrawProgressBarInstall(u64 currentProgress, u64 totalProgress, int mode) { - if (mode == 1) { - Gui::Draw_Rect(31, 121, (int)(((float)currentProgress / (float)totalProgress) * 338.0f), 28, progressBar); - } else { - Gui::Draw_Rect(31, 121, (int)(((float)currentProgress / (float)totalProgress) * 338.0f), 28, Config::progressbarColor); + if (Config::progress) { + // Outline of progressbar. + Gui::Draw_Rect(30, 120, 340, 30, BLACK); + + if (mode == 1) { + Gui::Draw_Rect(31, 121, (int)(((float)currentProgress / (float)totalProgress) * 338.0f), 28, progressBar); + } else { + Gui::Draw_Rect(31, 121, (int)(((float)currentProgress / (float)totalProgress) * 338.0f), 28, Config::progressbarColor); + } } } void Animation::DrawProgressBarExtract(u64 currentProgress, u64 totalProgress, int mode) { - if (mode == 1) { - Gui::Draw_Rect(31, 141, (int)(((float)currentProgress / (float)totalProgress) * 338.0f), 28, progressBar); - } else { - Gui::Draw_Rect(31, 141, (int)(((float)currentProgress / (float)totalProgress) * 338.0f), 28, Config::progressbarColor); + if (Config::progress) { + // Outline of progressbar. + Gui::Draw_Rect(30, 140, 340, 30, BLACK); + + if (mode == 1) { + Gui::Draw_Rect(31, 141, (int)(((float)currentProgress / (float)totalProgress) * 338.0f), 28, progressBar); + } else { + Gui::Draw_Rect(31, 141, (int)(((float)currentProgress / (float)totalProgress) * 338.0f), 28, Config::progressbarColor); + } } } diff --git a/source/download/download.cpp b/source/download/download.cpp index f740899..22795b7 100644 --- a/source/download/download.cpp +++ b/source/download/download.cpp @@ -861,7 +861,7 @@ void displayProgressBar() { formatBytes(downloadNow).c_str(), formatBytes(downloadTotal).c_str(), ((float)downloadNow/(float)downloadTotal) * 100.0f, - Lang::get("DOWNLOAD_SPEED").c_str(), (downloadSpeed / 1024), Lang::get("BYTES_PER_SECOND").c_str()); + Lang::get("DOWNLOAD_SPEED").c_str(), (downloadSpeed), Lang::get("BYTES_PER_SECOND").c_str()); // Extracting. } else if (progressBarType == 1) { snprintf(str, sizeof(str), "%s / %s (%.2f%%)", @@ -895,8 +895,7 @@ void displayProgressBar() { } else { Gui::DrawStringCentered(0, 80, 0.6f, Config::TxtColor, str, 400); } - // Outline of progressbar. - Gui::Draw_Rect(30, 120, 340, 30, BLACK); + if (isScriptSelected == true) { Animation::DrawProgressBar(downloadNow, downloadTotal, 1); } else { @@ -916,8 +915,6 @@ void displayProgressBar() { Gui::DrawStringCentered(0, 100, 0.6f, Config::TxtColor, std::to_string(filesExtracted) + " " + (filesExtracted == 1 ? (Lang::get("FILE_EXTRACTED")).c_str() :(Lang::get("FILES_EXTRACTED"))), 400); Gui::DrawStringCentered(0, 40, 0.6f, Config::TxtColor, Lang::get("CURRENTLY_EXTRACTING") + "\n" + extractingFile, 400); } - // Outline of progressbar. - Gui::Draw_Rect(30, 140, 340, 30, BLACK); // Progressbar. if (isScriptSelected == true) { Animation::DrawProgressBarExtract(writeOffset, extractSize, 1); @@ -933,8 +930,7 @@ void displayProgressBar() { } else { Gui::DrawStringCentered(0, 80, 0.6f, Config::TxtColor, str, 400); } - // Outline of progressbar. - Gui::Draw_Rect(30, 120, 340, 30, BLACK); + if (isScriptSelected == true) { Animation::DrawProgressBarInstall(installOffset, installSize, 1); } else { diff --git a/source/screens/settings.cpp b/source/screens/settings.cpp index 3f385ae..0f55e3a 100644 --- a/source/screens/settings.cpp +++ b/source/screens/settings.cpp @@ -318,6 +318,22 @@ void Settings::MiscSettingsLogic(u32 hDown, u32 hHeld, touchPosition touch) { mode = 0; } + // No idea where to place the button for it, so do it here for now. + if (hDown & KEY_SELECT) { + if (Config::progress) { + if (Msg::promptMsg(Lang::get("PROGRESS_BAR_DISABLE"))) { + Config::progress = false; + Msg::DisplayWarnMsg(Lang::get("DISABLED")); + changesMade = true; + } + } else { + if (Msg::promptMsg(Lang::get("PROGRESS_BAR_ENABLE"))) { + Config::progress = true; + Msg::DisplayWarnMsg(Lang::get("ENABLED")); + changesMade = true; + } + } + } // Navigation. if (hDown & KEY_UP) { diff --git a/source/utils/config.cpp b/source/utils/config.cpp index a074910..b4bddbb 100644 --- a/source/utils/config.cpp +++ b/source/utils/config.cpp @@ -56,6 +56,7 @@ int Config::future; int Config::Button; int Config::keyDelay = 5; bool Config::fading = false; +bool Config::progress = true; nlohmann::json configJson; extern bool changesMade; @@ -214,6 +215,12 @@ void Config::load() { fading = getBool("SCREEN_FADE"); } + if(!configJson.contains("PROGRESS_DISPLAY")) { + progress = true; + } else { + progress = getBool("PROGRESS_DISPLAY"); + } + fclose(file); } else { Color1 = BarColor; @@ -240,6 +247,7 @@ void Config::load() { Button = C2D_Color32(0, 0, 50, 255); keyDelay = 5; fading = false; + progress = true; } } @@ -268,6 +276,7 @@ void Config::save() { setInt("BUTTON", Button); setInt("KEY_DELAY", keyDelay); setBool("SCREEN_FADE", fading); + setBool("PROGRESS_DISPLAY", progress); FILE* file = fopen("sdmc:/3ds/Universal-Updater/Settings.json", "w"); if(file) fwrite(configJson.dump(1, '\t').c_str(), 1, configJson.dump(1, '\t').size(), file); @@ -302,6 +311,7 @@ void Config::initializeNewConfig() { setInt("BUTTON", C2D_Color32(0, 0, 50, 255)); setInt("KEY_DELAY", 5); setBool("SCREEN_FADE", false); + setBool("PROGRESS_DISPLAY", true); if(file) fwrite(configJson.dump(1, '\t').c_str(), 1, configJson.dump(1, '\t').size(), file); fclose(file);