make progress popup a little nicer, store json timeout is now 1h, initial work on storing update changelog
also removed the ability to cancel an update whilst unzipping the files, as this would result in a corrupted sphaira.nro install, which we don't want.
This commit is contained in:
@@ -472,7 +472,7 @@ auto InstallApp(ProgressBox* pbox, const Entry& entry) -> bool {
|
||||
}
|
||||
|
||||
if (strncasecmp(md5_str, entry.md5.data(), entry.md5.length())) {
|
||||
log_write("bad md5: %.*s vs %.*s\n", 32, md5_str, 32, entry.md5);
|
||||
log_write("bad md5: %.*s vs %.*s\n", 32, md5_str, 32, entry.md5.c_str());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1084,12 +1084,12 @@ Menu::Menu(const std::vector<NroEntry>& nro_entries) : MenuBase{"AppStore"_i18n}
|
||||
if (!time_stamp.is_valid) {
|
||||
download_file = true;
|
||||
} else {
|
||||
// check the date, if older than 1day, then fetch new file
|
||||
// check the date, if older than 1hour, then fetch new file
|
||||
// this relaxes the spam to their server, don't want to fetch repo
|
||||
// every time the user opens the app!
|
||||
const auto time_file = time_stamp.created;
|
||||
const auto time_cur = current_time;
|
||||
const auto day = 60 * 60 * 24;
|
||||
const auto day = 60 * 60;
|
||||
if (time_file > time_cur || time_cur - time_file >= day) {
|
||||
log_write("repo.json expired, downloading new! time_file: %zu time_cur: %zu\n", time_file, time_cur);
|
||||
download_file = true;
|
||||
|
||||
@@ -117,10 +117,6 @@ auto InstallUpdate(ProgressBox* pbox, const std::string url, const std::string v
|
||||
std::vector<char> buf(chunk_size);
|
||||
u64 offset{};
|
||||
while (offset < info.uncompressed_size) {
|
||||
if (pbox->ShouldExit()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto bytes_read = unzReadCurrentFile(zfile, buf.data(), buf.size());
|
||||
if (bytes_read <= 0) {
|
||||
// log_write("failed to read zip file: %s\n", inzip.c_str());
|
||||
@@ -171,6 +167,12 @@ MainMenu::MainMenu() {
|
||||
return true;
|
||||
}
|
||||
|
||||
auto body_key = yyjson_obj_get(root, "body");
|
||||
R_UNLESS(body_key, false);
|
||||
|
||||
const auto body = yyjson_get_str(body_key);
|
||||
R_UNLESS(body, false);
|
||||
|
||||
auto assets = yyjson_obj_get(root, "assets");
|
||||
R_UNLESS(assets, false);
|
||||
|
||||
@@ -185,8 +187,10 @@ MainMenu::MainMenu() {
|
||||
|
||||
m_update_version = version;
|
||||
m_update_url = url;
|
||||
m_update_description = body;
|
||||
m_update_state = UpdateState::Update;
|
||||
log_write("found url: %s\n", url);
|
||||
log_write("found body: %s\n", body);
|
||||
App::Notify("Update avaliable: "_i18n + m_update_version);
|
||||
|
||||
return true;
|
||||
|
||||
@@ -51,8 +51,8 @@ OptionBox::OptionBox(const std::string& message, const Option& a, const Option&
|
||||
|
||||
m_pos.w = 770.f;
|
||||
m_pos.h = 295.f;
|
||||
m_pos.x = (1280.f / 2.f) - (m_pos.w / 2.f);
|
||||
m_pos.y = (720.f / 2.f) - (m_pos.h / 2.f);
|
||||
m_pos.x = (SCREEN_WIDTH / 2.f) - (m_pos.w / 2.f);
|
||||
m_pos.y = (SCREEN_HEIGHT / 2.f) - (m_pos.h / 2.f);
|
||||
|
||||
auto box = m_pos;
|
||||
box.w /= 2.f;
|
||||
|
||||
@@ -31,6 +31,12 @@ ProgressBox::ProgressBox(const std::string& title, ProgressBoxCallback callback,
|
||||
m_pos.h = 430.f;
|
||||
m_pos.x = 255;
|
||||
m_pos.y = 145;
|
||||
145 + 430; // 575, 200, 420
|
||||
|
||||
m_pos.w = 770.f;
|
||||
m_pos.h = 295.f;
|
||||
m_pos.x = (SCREEN_WIDTH / 2.f) - (m_pos.w / 2.f);
|
||||
m_pos.y = (SCREEN_HEIGHT / 2.f) - (m_pos.h / 2.f);
|
||||
|
||||
m_done = done;
|
||||
m_title = title;
|
||||
@@ -81,8 +87,9 @@ auto ProgressBox::Draw(NVGcontext* vg, Theme* theme) -> void {
|
||||
|
||||
// The pop up shape.
|
||||
// const Vec4 box = { 255, 145, 770, 430 };
|
||||
const Vec4 prog_bar = { 400, 470, 480, 12 };
|
||||
const auto center_x = m_pos.x + m_pos.w/2;
|
||||
const auto end_y = m_pos.y + m_pos.h;
|
||||
const Vec4 prog_bar = { 400, end_y - 80, 480, 12 };
|
||||
|
||||
// shapes.
|
||||
if (offset && size) {
|
||||
@@ -93,12 +100,12 @@ auto ProgressBox::Draw(NVGcontext* vg, Theme* theme) -> void {
|
||||
gfx::drawTextArgs(vg, prog_bar.x + prog_bar.w + 10, prog_bar.y, 20, NVG_ALIGN_LEFT | NVG_ALIGN_TOP, gfx::Colour::WHITE, "%u%%", percentage);
|
||||
}
|
||||
|
||||
gfx::drawTextArgs(vg, center_x, 200, 25, NVG_ALIGN_CENTER | NVG_ALIGN_TOP, gfx::Colour::WHITE, title.c_str());
|
||||
gfx::drawTextArgs(vg, center_x, m_pos.y + 60, 25, NVG_ALIGN_CENTER | NVG_ALIGN_TOP, gfx::Colour::WHITE, title.c_str());
|
||||
// gfx::drawTextArgs(vg, center_x, 260, 20, NVG_ALIGN_CENTER | NVG_ALIGN_TOP, gfx::Colour::SILVER, "Please do not remove the gamecard or");
|
||||
// gfx::drawTextArgs(vg, center_x, 295, 20, NVG_ALIGN_CENTER | NVG_ALIGN_TOP, gfx::Colour::SILVER, "power off the system whilst installing.");
|
||||
// gfx::drawTextArgs(vg, center_x, 360, 20, NVG_ALIGN_CENTER | NVG_ALIGN_TOP, gfx::Colour::WHITE, "%.2f MiB/s", 24.0);
|
||||
if (!transfer.empty()) {
|
||||
gfx::drawTextArgs(vg, center_x, 420, 20, NVG_ALIGN_CENTER, gfx::Colour::WHITE, "%s", transfer.c_str());
|
||||
gfx::drawTextArgs(vg, center_x, prog_bar.y - 15 - 20 * 1.5, 20, NVG_ALIGN_CENTER, gfx::Colour::WHITE, "%s", transfer.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user