Make progressbar optional.

This commit is contained in:
Stackie
2020-06-03 15:03:28 +02:00
parent 9e84ed3423
commit a08c0afa62
6 changed files with 60 additions and 21 deletions
+1 -1
View File
@@ -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();
+3 -1
View File
@@ -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?"
}
+27 -12
View File
@@ -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);
}
}
}
+3 -7
View File
@@ -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 {
+16
View File
@@ -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) {
+10
View File
@@ -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);