mirror of
https://github.com/HamletDuFromage/aio-switch-updater.git
synced 2024-11-08 11:31:43 +00:00
don't divide by 0
This commit is contained in:
parent
6a12ffc829
commit
9a7863504d
2 changed files with 13 additions and 14 deletions
|
@ -212,9 +212,7 @@
|
|||
},
|
||||
"worker": {
|
||||
"of": "of",
|
||||
"remaining": "Time remaining",
|
||||
"hours": "hours",
|
||||
"minutes": "minutes",
|
||||
"seconds": "seconds"
|
||||
"download_progress": "({:.1f} MB of {:.1f} MB - {:.1f} MB/s)",
|
||||
"time_left": "({} left)"
|
||||
}
|
||||
}
|
|
@ -33,27 +33,28 @@ WorkerPage::WorkerPage(brls::StagedAppletFrame* frame, const std::string& text,
|
|||
this->registerAction("", brls::Key::PLUS, [this] { return true; });
|
||||
}
|
||||
|
||||
std::string formatLabelText( double speed, double fileSizeCurrent, double fileSizeFinal)
|
||||
std::string formatLabelText(double speed, double fileSizeCurrent, double fileSizeFinal)
|
||||
{
|
||||
double fileSizeCurrentMB = fileSizeCurrent / 0x100000;
|
||||
double fileSizeFinalMB = fileSizeFinal / 0x100000;
|
||||
double speedMB = speed / 0x100000;
|
||||
|
||||
// Calcul du temps restant
|
||||
double timeRemaining = (fileSizeFinal - fileSizeCurrent) / speed;
|
||||
int hours = static_cast<int>(timeRemaining / 3600);
|
||||
int minutes = static_cast<int>((timeRemaining - hours * 3600) / 60);
|
||||
int seconds = static_cast<int>(timeRemaining - hours * 3600 - minutes * 60);
|
||||
|
||||
std::string labelText = fmt::format("({:.1f} MB {} {:.1f} MB - {:.1f} MB/s) - {}: ",
|
||||
fileSizeCurrentMB, "menus/worker/of"_i18n, fileSizeFinalMB, speedMB, "menus/worker/remaining"_i18n);
|
||||
|
||||
std::string labelText = fmt::format("menus/worker/download_progress"_i18n, fileSizeCurrentMB, fileSizeFinalMB, speedMB);
|
||||
if (speedMB > 0) {
|
||||
std::string eta;
|
||||
if (hours > 0)
|
||||
labelText += fmt::format("{}{} ", hours, "menus/worker/hours"_i18n);
|
||||
eta += fmt::format("{}h ", hours);
|
||||
if (minutes > 0)
|
||||
labelText += fmt::format("{}{} ", minutes, "menus/worker/minutes"_i18n);
|
||||
eta += fmt::format("{}m ", minutes);
|
||||
|
||||
labelText += fmt::format("{}{}", seconds, "menus/worker/seconds"_i18n);
|
||||
eta += fmt::format("{}s", seconds);
|
||||
labelText += "\n" + fmt::format("menus/worker/time_left"_i18n, eta);
|
||||
}
|
||||
|
||||
return labelText;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue