From f90bc8b6200b4fd71341252d9f425155d77f63c3 Mon Sep 17 00:00:00 2001 From: Steven Smith Date: Fri, 24 Apr 2015 15:18:33 -0700 Subject: [PATCH] Only update progress display when the percentage has changed. --- source/main.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/source/main.cpp b/source/main.cpp index 4c84056..342acfb 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -73,7 +73,7 @@ int main(int argc, char **argv) { } std::stringstream stream; - stream << "FBI v1.3.5" << "\n"; + stream << "FBI v1.3.6" << "\n"; stream << "Free Space: " << freeSpace << " bytes (" << std::fixed << std::setprecision(2) << freeSpace / 1024.0f / 1024.0f << "MB)" << "\n"; stream << "Destination: " << (destination == NAND ? "NAND" : "SD") << ", Mode: " << (mode == INSTALL_CIA ? "Install CIA" : mode == DELETE_CIA ? "Delete CIA" : mode == DELETE_TITLE ? "Delete Title" : "Launch Title") << "\n"; stream << "L - Switch Destination, R - Switch Mode" << "\n"; @@ -96,13 +96,19 @@ int main(int argc, char **argv) { std::string batchInfo = ""; + int prevProgress = -1; auto onProgress = [&](u64 pos, u64 totalSize) { - std::stringstream details; - details << batchInfo; - details << "(" << pos << " / " << totalSize << ")" << "\n"; - details << "Press B to cancel."; + u32 progress = (u32) ((pos * 100) / totalSize); + if(prevProgress != (int) progress) { + prevProgress = (int) progress; + + std::stringstream details; + details << batchInfo; + details << "Press B to cancel."; + + uiDisplayProgress(TOP_SCREEN, "Installing", details.str(), true, progress); + } - uiDisplayProgress(TOP_SCREEN, "Installing", details.str(), true, (u32) ((pos * 100) / totalSize)); inputPoll(); return !inputIsPressed(BUTTON_B); }; @@ -136,6 +142,7 @@ int main(int argc, char **argv) { confirmStream << "Size: " << file.fileSize << " bytes (" << std::fixed << std::setprecision(2) << file.fileSize / 1024.0f / 1024.0f << "MB)" << "\n"; if(!showNetworkPrompts || uiPrompt(TOP_SCREEN, confirmStream.str(), true)) { AppResult ret = appInstall(destination, file.fd, file.fileSize, onProgress); + prevProgress = -1; if(showNetworkPrompts || ret != APP_SUCCESS) { std::stringstream resultMsg; resultMsg << "Install "; @@ -178,6 +185,7 @@ int main(int argc, char **argv) { batchInfo = batchInstallStream.str(); AppResult ret = appInstallFile(destination, path, onProgress); + prevProgress = -1; batchInfo = ""; if(ret != APP_SUCCESS) { Error error = platformGetError(); @@ -244,6 +252,7 @@ int main(int argc, char **argv) { if(mode == INSTALL_CIA) { AppResult ret = appInstallFile(destination, path, onProgress); + prevProgress = -1; if(ret == APP_SUCCESS) { resultMsg << "succeeded!"; } else {