show percentage & refresh freespace during install

This commit is contained in:
mrdude2478 2023-10-07 10:25:37 +01:00
parent f127ddd7dc
commit 0b7f2dc624
8 changed files with 33 additions and 8 deletions

View File

@ -132,13 +132,17 @@ namespace tin::install::nsp
} }
inst::ui::instPage::setInstBarPerc(100); inst::ui::instPage::setInstBarPerc(100);
inst::ui::instPage::setInstInfoText("inst.info_page.top_info0"_lang + ncaFileName + "..."); //inst::ui::instPage::setInstInfoText("inst.info_page.top_info0"_lang + ncaFileName + "...");
inst::ui::instPage::setInstBarPerc(0); inst::ui::instPage::setInstBarPerc(0);
while (!bufferedPlaceholderWriter.IsPlaceholderComplete() && !stopThreadsHttpNsp) while (!bufferedPlaceholderWriter.IsPlaceholderComplete() && !stopThreadsHttpNsp)
{ {
int installProgress = (int)(((double)bufferedPlaceholderWriter.GetSizeWrittenToPlaceholder() / (double)bufferedPlaceholderWriter.GetTotalDataSize()) * 100.0); int installProgress = (int)(((double)bufferedPlaceholderWriter.GetSizeWrittenToPlaceholder() / (double)bufferedPlaceholderWriter.GetTotalDataSize()) * 100.0);
inst::ui::instPage::setInstBarPerc((double)installProgress); inst::ui::instPage::setInstBarPerc((double)installProgress);
//
std::stringstream x;
x << (int)(installProgress);
inst::ui::instPage::setInstInfoText("inst.info_page.top_info0"_lang + ncaFileName + " " + x.str() + "%");
} }
inst::ui::instPage::setInstBarPerc(100); inst::ui::instPage::setInstBarPerc(100);

View File

@ -137,7 +137,7 @@ namespace tin::install::xci
u64 totalSizeMB = bufferedPlaceholderWriter.GetTotalDataSize() / 1000000; u64 totalSizeMB = bufferedPlaceholderWriter.GetTotalDataSize() / 1000000;
#endif #endif
inst::ui::instPage::setInstInfoText("inst.info_page.top_info0"_lang + ncaFileName + "..."); //inst::ui::instPage::setInstInfoText("inst.info_page.top_info0"_lang + ncaFileName + "...");
inst::ui::instPage::setInstBarPerc(0); inst::ui::instPage::setInstBarPerc(0);
while (!bufferedPlaceholderWriter.IsPlaceholderComplete() && !stopThreadsHttpXci) while (!bufferedPlaceholderWriter.IsPlaceholderComplete() && !stopThreadsHttpXci)
{ {
@ -147,6 +147,10 @@ namespace tin::install::xci
LOG_DEBUG("> Install Progress: %lu/%lu MB (%i%s)\r", installSizeMB, totalSizeMB, installProgress, "%"); LOG_DEBUG("> Install Progress: %lu/%lu MB (%i%s)\r", installSizeMB, totalSizeMB, installProgress, "%");
#endif #endif
inst::ui::instPage::setInstBarPerc((double)installProgress); inst::ui::instPage::setInstBarPerc((double)installProgress);
//
std::stringstream x;
x << (int)(installProgress);
inst::ui::instPage::setInstInfoText("inst.info_page.top_info0"_lang + ncaFileName + " " + x.str() + "%");
} }
inst::ui::instPage::setInstBarPerc(100); inst::ui::instPage::setInstBarPerc(100);

View File

@ -127,7 +127,7 @@ namespace tin::install::nsp
std::thread audioThread(inst::util::playAudio, audioPath); std::thread audioThread(inst::util::playAudio, audioPath);
std::string information = "romfs:/images/icons/information.png"; std::string information = "romfs:/images/icons/information.png";
if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(inst::config::appDir + "icons_others.information"_theme)) { if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(inst::config::appDir + "icons_others.information"_theme)) {
information = inst::config::appDir + "icons_others.good"_theme; information = inst::config::appDir + "icons_others.information"_theme;
} }
int rc = inst::ui::mainApp->CreateShowDialog("inst.nca_verify.title"_lang, "inst.nca_verify.desc"_lang, { "common.cancel"_lang, "inst.nca_verify.opt1"_lang }, false, information); int rc = inst::ui::mainApp->CreateShowDialog("inst.nca_verify.title"_lang, "inst.nca_verify.desc"_lang, { "common.cancel"_lang, "inst.nca_verify.opt1"_lang }, false, information);
audioThread.join(); audioThread.join();

View File

@ -120,7 +120,7 @@ namespace tin::install::xci
std::thread audioThread(inst::util::playAudio, audioPath); std::thread audioThread(inst::util::playAudio, audioPath);
std::string information = "romfs:/images/icons/information.png"; std::string information = "romfs:/images/icons/information.png";
if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(inst::config::appDir + "icons_others.information"_theme)) { if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(inst::config::appDir + "icons_others.information"_theme)) {
information = inst::config::appDir + "icons_others.good"_theme; information = inst::config::appDir + "icons_others.information"_theme;
} }
int rc = inst::ui::mainApp->CreateShowDialog("inst.nca_verify.title"_lang, "inst.nca_verify.desc"_lang, { "common.cancel"_lang, "inst.nca_verify.opt1"_lang }, false, information); int rc = inst::ui::mainApp->CreateShowDialog("inst.nca_verify.title"_lang, "inst.nca_verify.desc"_lang, { "common.cancel"_lang, "inst.nca_verify.opt1"_lang }, false, information);
audioThread.join(); audioThread.join();

View File

@ -4,6 +4,7 @@
#include "nx/nca_writer.h" #include "nx/nca_writer.h"
#include "ui/instPage.hpp" #include "ui/instPage.hpp"
#include "util/lang.hpp" #include "util/lang.hpp"
#include <sstream>
namespace tin::install::nsp namespace tin::install::nsp
{ {
@ -38,7 +39,7 @@ namespace tin::install::nsp
try try
{ {
inst::ui::instPage::setInstInfoText("inst.info_page.top_info0"_lang + ncaFileName + "..."); //inst::ui::instPage::setInstInfoText("inst.info_page.top_info0"_lang + ncaFileName + "...");
inst::ui::instPage::setInstBarPerc(0); inst::ui::instPage::setInstBarPerc(0);
while (fileOff < ncaSize) while (fileOff < ncaSize)
{ {
@ -47,6 +48,10 @@ namespace tin::install::nsp
if (fileOff % (0x400000 * 3) == 0) { if (fileOff % (0x400000 * 3) == 0) {
LOG_DEBUG("> Progress: %lu/%lu MB (%d%s)\r", (fileOff / 1000000), (ncaSize / 1000000), (int)(progress * 100.0), "%"); LOG_DEBUG("> Progress: %lu/%lu MB (%d%s)\r", (fileOff / 1000000), (ncaSize / 1000000), (int)(progress * 100.0), "%");
inst::ui::instPage::setInstBarPerc((double)(progress * 100.0)); inst::ui::instPage::setInstBarPerc((double)(progress * 100.0));
//
std::stringstream x;
x << (int)(progress * 100.0);
inst::ui::instPage::setInstInfoText("inst.info_page.top_info0"_lang + ncaFileName + " " + x.str() + "%");
} }
if (fileOff + readSize >= ncaSize) readSize = ncaSize - fileOff; if (fileOff + readSize >= ncaSize) readSize = ncaSize - fileOff;

View File

@ -38,7 +38,7 @@ namespace tin::install::xci
try try
{ {
inst::ui::instPage::setInstInfoText("inst.info_page.top_info0"_lang + ncaFileName + "..."); //inst::ui::instPage::setInstInfoText("inst.info_page.top_info0"_lang + ncaFileName + "...");
inst::ui::instPage::setInstBarPerc(0); inst::ui::instPage::setInstBarPerc(0);
while (fileOff < ncaSize) while (fileOff < ncaSize)
{ {
@ -47,6 +47,10 @@ namespace tin::install::xci
if (fileOff % (0x400000 * 3) == 0) { if (fileOff % (0x400000 * 3) == 0) {
LOG_DEBUG("> Progress: %lu/%lu MB (%d%s)\r", (fileOff / 1000000), (ncaSize / 1000000), (int)(progress * 100.0), "%"); LOG_DEBUG("> Progress: %lu/%lu MB (%d%s)\r", (fileOff / 1000000), (ncaSize / 1000000), (int)(progress * 100.0), "%");
inst::ui::instPage::setInstBarPerc((double)(progress * 100.0)); inst::ui::instPage::setInstBarPerc((double)(progress * 100.0));
//
std::stringstream x;
x << (int)(progress * 100.0);
inst::ui::instPage::setInstInfoText("inst.info_page.top_info0"_lang + ncaFileName + " " + x.str() + "%");
} }
if (fileOff + readSize >= ncaSize) readSize = ncaSize - fileOff; if (fileOff + readSize >= ncaSize) readSize = ncaSize - fileOff;

View File

@ -163,7 +163,7 @@ namespace tin::install::nsp
u64 totalSizeMB = bufferedPlaceholderWriter.GetTotalDataSize() / 1000000; u64 totalSizeMB = bufferedPlaceholderWriter.GetTotalDataSize() / 1000000;
#endif #endif
inst::ui::instPage::setInstInfoText("inst.info_page.top_info0"_lang + ncaFileName + "..."); //inst::ui::instPage::setInstInfoText("inst.info_page.top_info0"_lang + ncaFileName + "...");
inst::ui::instPage::setInstBarPerc(0); inst::ui::instPage::setInstBarPerc(0);
while (!bufferedPlaceholderWriter.IsPlaceholderComplete() && !stopThreadsUsbNsp) while (!bufferedPlaceholderWriter.IsPlaceholderComplete() && !stopThreadsUsbNsp)
{ {
@ -173,6 +173,10 @@ namespace tin::install::nsp
LOG_DEBUG("> Install Progress: %lu/%lu MB (%i%s)\r", installSizeMB, totalSizeMB, installProgress, "%"); LOG_DEBUG("> Install Progress: %lu/%lu MB (%i%s)\r", installSizeMB, totalSizeMB, installProgress, "%");
#endif #endif
inst::ui::instPage::setInstBarPerc((double)installProgress); inst::ui::instPage::setInstBarPerc((double)installProgress);
//
std::stringstream x;
x << (int)(installProgress);
inst::ui::instPage::setInstInfoText("inst.info_page.top_info0"_lang + ncaFileName + " " + x.str() + "%");
} }
inst::ui::instPage::setInstBarPerc(100); inst::ui::instPage::setInstBarPerc(100);

View File

@ -162,7 +162,7 @@ namespace tin::install::xci
u64 totalSizeMB = bufferedPlaceholderWriter.GetTotalDataSize() / 1000000; u64 totalSizeMB = bufferedPlaceholderWriter.GetTotalDataSize() / 1000000;
#endif #endif
inst::ui::instPage::setInstInfoText("inst.info_page.top_info0"_lang + ncaFileName + "..."); //inst::ui::instPage::setInstInfoText("inst.info_page.top_info0"_lang + ncaFileName + "...");
inst::ui::instPage::setInstBarPerc(0); inst::ui::instPage::setInstBarPerc(0);
while (!bufferedPlaceholderWriter.IsPlaceholderComplete() && !stopThreadsUsbXci) while (!bufferedPlaceholderWriter.IsPlaceholderComplete() && !stopThreadsUsbXci)
{ {
@ -172,6 +172,10 @@ namespace tin::install::xci
LOG_DEBUG("> Install Progress: %lu/%lu MB (%i%s)\r", installSizeMB, totalSizeMB, installProgress, "%"); LOG_DEBUG("> Install Progress: %lu/%lu MB (%i%s)\r", installSizeMB, totalSizeMB, installProgress, "%");
#endif #endif
inst::ui::instPage::setInstBarPerc((double)installProgress); inst::ui::instPage::setInstBarPerc((double)installProgress);
//
std::stringstream x;
x << (int)(installProgress);
inst::ui::instPage::setInstInfoText("inst.info_page.top_info0"_lang + ncaFileName + " " + x.str() + "%");
} }
inst::ui::instPage::setInstBarPerc(100); inst::ui::instPage::setInstBarPerc(100);