diff --git a/include/ui/ThemeInstPage.hpp b/include/ui/ThemeInstPage.hpp index 853b08d..4f0d5a3 100644 --- a/include/ui/ThemeInstPage.hpp +++ b/include/ui/ThemeInstPage.hpp @@ -8,8 +8,8 @@ namespace inst::ui { public: ThemeInstPage(); PU_SMART_CTOR(ThemeInstPage) + void onInput(u64 Down, u64 Up, u64 Held, pu::ui::TouchPoint touch_pos); void startNetwork(); - void onInput(u64 Down, u64 Up, u64 Held, pu::ui::TouchPoint touch_pos); static void setInstBarPerc(double ourPercent); pu::ui::elm::ProgressBar::Ref installBar; TextBlock::Ref pageInfoText; diff --git a/romfs/lang/de.json b/romfs/lang/de.json index c568b82..adee39d 100644 --- a/romfs/lang/de.json +++ b/romfs/lang/de.json @@ -249,5 +249,17 @@ "retry": "Theme-Extraktion fehlgeschlagen, erneut versuchen?", "wait": "Bitte warten!", "trying": "Ich versuche gerade, ein Theme zu installieren" + }, + "usage": { + "system_size": "Gesamtgröße des Systems:", + "gb": " GB", + "freespace": "\nFreier Systemspeicherplatz: ", + "percent_used": "\nSystemprozentsatz verwendet: ", + "percent": "%\n\n", + "percent_symbol": "%", + "sd_size": "Gesamtgröße der SD-Karte: ", + "sd_space": "\nFreier Speicherplatz auf der SD-Karte: ", + "sd_used": "\nProzentsatz der genutzten SD-Karte: ", + "space_info": "Informationen zur Speicherplatznutzung" } } \ No newline at end of file diff --git a/romfs/lang/en.json b/romfs/lang/en.json index f40793d..b75cd9e 100644 --- a/romfs/lang/en.json +++ b/romfs/lang/en.json @@ -249,5 +249,17 @@ "retry": "Theme Extraction failed, try again?", "wait": "Please Wait!", "trying": "I'm currently tryng to install a theme" + }, + "usage": { + "system_size": "System total size: ", + "gb": " GB", + "freespace": "\nSystem free space: ", + "percent_used": "\nSystem percent used: ", + "percent": "%\n\n", + "percent_symbol": "%", + "sd_size": "SD card total size: ", + "sd_space": "\nSD card free space: ", + "sd_used": "\nSD card percent used: ", + "space_info": "Space Usage Information" } } \ No newline at end of file diff --git a/romfs/lang/es.json b/romfs/lang/es.json index b76884f..18c1ecc 100644 --- a/romfs/lang/es.json +++ b/romfs/lang/es.json @@ -249,5 +249,17 @@ "retry": "Error al extraer el tema, ¿inténtalo de nuevo?", "wait": "¡Espere por favor!", "trying": "Actualmente estoy intentando instalar un tema." + }, + "usage": { + "system_size": "Tamaño total del sistema: ", + "gb": " GB", + "freespace": "\nEspacio libre del sistema: ", + "percent_used": "\nPorcentaje de uso del sistema: ", + "percent": "%\n\n", + "percent_symbol": "%", + "sd_size": "Tamaño total de la tarjeta SD: ", + "sd_space": "\nEspacio libre en la tarjeta SD: ", + "sd_used": "\nPorcentaje de tarjeta SD utilizada: ", + "space_info": "Información de uso del espacio" } } \ No newline at end of file diff --git a/romfs/lang/fr.json b/romfs/lang/fr.json index 647098c..b0ceb1c 100644 --- a/romfs/lang/fr.json +++ b/romfs/lang/fr.json @@ -249,5 +249,17 @@ "retry": "L'extraction du thème a échoué. Réessayez ?", "wait": "S'il vous plaît, attendez!", "trying": "J'essaie actuellement d'installer un thème" + }, + "usage": { + "system_size": "Taille totale du système: ", + "gb": " GB", + "freespace": "\nEspace libre du système: ", + "percent_used": "\nPourcentage du système utilisé: ", + "percent": "%\n\n", + "percent_symbol": "%", + "sd_size": "Taille totale de la carte SD: ", + "sd_space": "\nEspace libre sur la carte SD: ", + "sd_used": "\nPourcentage de carte SD utilisé: ", + "space_info": "Informations sur l'utilisation de l'espace" } } \ No newline at end of file diff --git a/romfs/lang/it.json b/romfs/lang/it.json index deea216..79233d6 100644 --- a/romfs/lang/it.json +++ b/romfs/lang/it.json @@ -249,5 +249,17 @@ "retry": "Estrazione del tema non riuscita, riprovare?", "wait": "Attendere prego!", "trying": "Attualmente sto provando a installare un tema" + }, + "usage": { + "system_size": "Dimensione totale del sistema: ", + "gb": " GB", + "freespace": "\nSpazio libero nel sistema: ", + "percent_used": "\nPercentuale di sistema utilizzata: ", + "percent": "%\n\n", + "percent_symbol": "%", + "sd_size": "Dimensione totale della scheda SD: ", + "sd_space": "\nSpazio libero sulla scheda SD: ", + "sd_used": "\nPercentuale scheda SD utilizzata: ", + "space_info": "Informazioni sull'utilizzo dello spazio" } } \ No newline at end of file diff --git a/romfs/lang/jp.json b/romfs/lang/jp.json index 3b6cf30..2ce3bec 100644 --- a/romfs/lang/jp.json +++ b/romfs/lang/jp.json @@ -249,5 +249,17 @@ "retry": "テーマの抽出に失敗しました。もう一度お試しください?", "wait": "お待ちください!", "trying": "現在テーマをインストールしようとしています" + }, + "usage": { + "system_size": "システムの合計サイズ: ", + "gb": " GB", + "freespace": "\nシステムの空き領域: ", + "percent_used": "\nシステムの使用率: ", + "percent": "%\n\n", + "percent_symbol": "%", + "sd_size": "SD カードの合計サイズ: ", + "sd_space": "\nSD カードの空き容量: ", + "sd_used": "\nSD カードの使用率: ", + "space_info": "スペースの使用状況情報" } } \ No newline at end of file diff --git a/romfs/lang/ru.json b/romfs/lang/ru.json index ae05702..9379461 100644 --- a/romfs/lang/ru.json +++ b/romfs/lang/ru.json @@ -249,5 +249,17 @@ "retry": "Не удалось извлечь тему, попробуйте еще раз?", "wait": "Пожалуйста, подождите!", "trying": "Сейчас я пытаюсь установить тему" + }, + "usage": { + "system_size": "Общий размер системы: ", + "gb": " ГБ", + "freespace": "\nСвободное пространство в системе: ", + "percent_used": "\nПроцент использования системы: ", + "percent": "%\n\n", + "percent_symbol": "%", + "sd_size": "Общий размер SD-карты: ", + "sd_space": "\nСвободное место на SD-карте: ", + "sd_used": "\nПроцент использования SD-карты: ", + "space_info": "Информация об использовании пространства" } } \ No newline at end of file diff --git a/romfs/lang/tw.json b/romfs/lang/tw.json index 2987342..71f9500 100644 --- a/romfs/lang/tw.json +++ b/romfs/lang/tw.json @@ -249,5 +249,17 @@ "retry": "主題擷取失敗,請重試?", "wait": "請稍候!", "trying": "我目前正在嘗試安裝主題" + }, + "usage": { + "system_size": "系統總大小:", + "gb": " GB", + "freespace": "\n系統可用空間: ", + "percent_used": "\n系統使用百分比: ", + "percent": "%\n\n", + "percent_symbol": "%", + "sd_size": "SD卡總大小:", + "sd_space": "\nSD 卡可用空間: ", + "sd_used": "\nSD 卡使用百分比: ", + "space_info": "空間使用資訊" } } \ No newline at end of file diff --git a/source/ThemeInstall.cpp b/source/ThemeInstall.cpp index 371b34f..02ee4d5 100644 --- a/source/ThemeInstall.cpp +++ b/source/ThemeInstall.cpp @@ -156,151 +156,151 @@ namespace ThemeInstStuff { } std::remove("temp.html"); - std::string url; - unsigned short maxlist = 50; - unsigned short nowlist = 0; + std::string url; + unsigned short maxlist = 50; + unsigned short nowlist = 0; - if (inst::config::httpkeyboard) { - url = inst::util::softwareKeyboard("theme.hint_theme"_lang, inst::config::httplastUrl2, 500); - inst::config::httplastUrl2 = url; - inst::config::setConfig(); - //refresh options page - inst::ui::mainApp->optionspage->setMenuText(); - } - else { - url = inst::config::httplastUrl2; - } + if (inst::config::httpkeyboard) { + url = inst::util::softwareKeyboard("theme.hint_theme"_lang, inst::config::httplastUrl2, 500); + inst::config::httplastUrl2 = url; + inst::config::setConfig(); + //refresh options page + inst::ui::mainApp->optionspage->setMenuText(); + } + else { + url = inst::config::httplastUrl2; + } - if (url == "") { - url = ("http://127.0.0.1"); - inst::ui::mainApp->CreateShowDialog("theme.theme_fail"_lang, "inst.net.help.blank"_lang, { "common.ok"_lang }, true, "romfs:/images/icons/information.png"); - inst::config::httplastUrl2 = url; - inst::config::setConfig(); - //refresh options page - inst::ui::mainApp->optionspage->setMenuText(); + if (url == "") { + url = ("http://127.0.0.1"); + inst::ui::mainApp->CreateShowDialog("theme.theme_fail"_lang, "inst.net.help.blank"_lang, { "common.ok"_lang }, true, "romfs:/images/icons/information.png"); + inst::config::httplastUrl2 = url; + inst::config::setConfig(); + //refresh options page + inst::ui::mainApp->optionspage->setMenuText(); + break; + } + + else { + std::string response; + if (inst::util::formatUrlString(url) == "" || url == "https://" || url == "http://" || url == "HTTP://" || url == "HTTPS://") { + inst::ui::mainApp->CreateShowDialog("inst.net.url.invalid"_lang, "", { "common.ok"_lang }, false, "romfs:/images/icons/fail.png"); break; } - else { - std::string response; - if (inst::util::formatUrlString(url) == "" || url == "https://" || url == "http://" || url == "HTTP://" || url == "HTTPS://") { - inst::ui::mainApp->CreateShowDialog("inst.net.url.invalid"_lang, "", { "common.ok"_lang }, false, "romfs:/images/icons/fail.png"); - break; - } - else { - if (url[url.size() - 1] != '/') //does this line even do anything? + if (url[url.size() - 1] != '/') //does this line even do anything? //First try and stream the links response = inst::curl::downloadToBuffer(url); - //If the above fails we probably have an html page - try to download it instead. + //If the above fails we probably have an html page - try to download it instead. + if (response.empty()) { + response = inst::curl::html_to_buffer(url); if (response.empty()) { - response = inst::curl::html_to_buffer(url); - if (response.empty()) { - inst::ui::mainApp->CreateShowDialog("theme.theme_error"_lang, "theme.theme_error_info"_lang, { "common.ok"_lang }, true, "romfs:/images/icons/fail.png"); - break; - } - } - } - - if (!response.empty()) { - if (response[0] == '*') { - try { - nlohmann::json j = nlohmann::json::parse(response); - for (const auto& file : j["files"]) { - urls.push_back(file["url"]); - } - - return urls; - response.clear(); - } - catch (const nlohmann::detail::exception& ex) { - LOG_DEBUG("Failed to parse JSON\n"); - } - } - else if (!response.empty()) { - std::size_t index = 0; - if (!inst::config::listoveride) { - inst::ui::mainApp->CreateShowDialog("inst.net.url.listwait"_lang + std::to_string(maxlist) + "inst.net.url.listwait2"_lang, "", { "common.ok"_lang }, false, "romfs:/images/icons/wait.png"); - } - while (index < response.size()) { - std::string link; - auto found = findCaseInsensitive(response, "href=\"", index); - if (found == std::string::npos) { - break; - } - - index = found + 6; - while (index < response.size()) { - if (response[index] == '"') { - if (findCaseInsensitive(link, ".zip") != std::string::npos) { - /* - Try to see if the href links contain http - if not add the own url - defined in the settings page - */ - if (!inst::config::listoveride && nowlist >= maxlist) { - break; - } - else { - if (link.find("http") == std::string::npos) { - std::string before_strip = stripfilename(url); - if (link[0] == '/') { - tmp_array.push_back(before_strip + link); - nowlist++; - } - else { - tmp_array.push_back(before_strip + "/" + link); - nowlist++; - - } - } - else { - tmp_array.push_back(link); - nowlist++; - } - } - } - break; //don't remove this or the net install screen will crash - } - link += response[index++]; - } - } - if (tmp_array.size() > 0) { - - //code to decode the url (if it's encoded), if not then (re)encode all urls. - for (unsigned long int i = 0; i < tmp_array.size(); i++) { - std::string debug = tmp_array[i]; - std::string decoded = url_decode(debug); - debug = urlencode(decoded); - urls.push_back(debug); - } - - tmp_array.clear(); //we may as well clear this now as it's done it's job.. - std::sort(urls.begin(), urls.end(), inst::util::ignoreCaseCompare); - return urls; - break; - } - - else { - inst::ui::mainApp->CreateShowDialog("theme.no_themes"_lang, "", { "common.ok"_lang }, false, "romfs:/images/icons/fail.png"); - LOG_DEBUG("Failed to parse themes from HTML\n"); - break; - } - response.clear(); - } - - else { inst::ui::mainApp->CreateShowDialog("theme.theme_error"_lang, "theme.theme_error_info"_lang, { "common.ok"_lang }, true, "romfs:/images/icons/fail.png"); break; } } + } + + if (!response.empty()) { + if (response[0] == '*') { + try { + nlohmann::json j = nlohmann::json::parse(response); + for (const auto& file : j["files"]) { + urls.push_back(file["url"]); + } + + return urls; + response.clear(); + } + catch (const nlohmann::detail::exception& ex) { + LOG_DEBUG("Failed to parse JSON\n"); + } + } + else if (!response.empty()) { + std::size_t index = 0; + if (!inst::config::listoveride) { + inst::ui::mainApp->CreateShowDialog("inst.net.url.listwait"_lang + std::to_string(maxlist) + "inst.net.url.listwait2"_lang, "", { "common.ok"_lang }, false, "romfs:/images/icons/wait.png"); + } + while (index < response.size()) { + std::string link; + auto found = findCaseInsensitive(response, "href=\"", index); + if (found == std::string::npos) { + break; + } + + index = found + 6; + while (index < response.size()) { + if (response[index] == '"') { + if (findCaseInsensitive(link, ".zip") != std::string::npos) { + /* + Try to see if the href links contain http - if not add the own url + defined in the settings page + */ + if (!inst::config::listoveride && nowlist >= maxlist) { + break; + } + else { + if (link.find("http") == std::string::npos) { + std::string before_strip = stripfilename(url); + if (link[0] == '/') { + tmp_array.push_back(before_strip + link); + nowlist++; + } + else { + tmp_array.push_back(before_strip + "/" + link); + nowlist++; + + } + } + else { + tmp_array.push_back(link); + nowlist++; + } + } + } + break; //don't remove this or the net install screen will crash + } + link += response[index++]; + } + } + if (tmp_array.size() > 0) { + + //code to decode the url (if it's encoded), if not then (re)encode all urls. + for (unsigned long int i = 0; i < tmp_array.size(); i++) { + std::string debug = tmp_array[i]; + std::string decoded = url_decode(debug); + debug = urlencode(decoded); + urls.push_back(debug); + } + + tmp_array.clear(); //we may as well clear this now as it's done it's job.. + std::sort(urls.begin(), urls.end(), inst::util::ignoreCaseCompare); + return urls; + break; + } + + else { + inst::ui::mainApp->CreateShowDialog("theme.no_themes"_lang, "", { "common.ok"_lang }, false, "romfs:/images/icons/fail.png"); + LOG_DEBUG("Failed to parse themes from HTML\n"); + break; + } + response.clear(); + } else { - LOG_DEBUG("Failed to fetch theme list\n"); inst::ui::mainApp->CreateShowDialog("theme.theme_error"_lang, "theme.theme_error_info"_lang, { "common.ok"_lang }, true, "romfs:/images/icons/fail.png"); break; } } + + else { + LOG_DEBUG("Failed to fetch theme list\n"); + inst::ui::mainApp->CreateShowDialog("theme.theme_error"_lang, "theme.theme_error_info"_lang, { "common.ok"_lang }, true, "romfs:/images/icons/fail.png"); + break; + } + } } return urls; } diff --git a/source/install/install_nsp.cpp b/source/install/install_nsp.cpp index 60b6ebe..fa1d740 100644 --- a/source/install/install_nsp.cpp +++ b/source/install/install_nsp.cpp @@ -155,20 +155,20 @@ namespace tin::install::nsp //int cal = 0; std::vector tikFileEntries = m_NSP->GetFileEntriesByExtension("tik"); std::vector certFileEntries = m_NSP->GetFileEntriesByExtension("cert"); - + //check if ticket exists - if not exit function and warn user std::stringstream ss; - for(auto it =tikFileEntries.begin();it!=tikFileEntries.end();it++) { - if(it != tikFileEntries.begin()) { - ss<<" "; + for (auto it = tikFileEntries.begin(); it != tikFileEntries.end(); it++) { + if (it != tikFileEntries.begin()) { + ss << " "; } ss << *it; - } - if (ss.str().length() == 0) { - inst::ui::mainApp->CreateShowDialog("main.usb.warn.title"_lang, "inst.nca_verify.ticket_missing"_lang, { "common.ok"_lang }, false, "romfs:/images/icons/information.png"); - return; //don't bother trying to install the ticket or cert if it doesn't exist. - } - // end of ticket check + } + if (ss.str().length() == 0) { + inst::ui::mainApp->CreateShowDialog("main.usb.warn.title"_lang, "inst.nca_verify.ticket_missing"_lang, { "common.ok"_lang }, false, "romfs:/images/icons/information.png"); + return; //don't bother trying to install the ticket or cert if it doesn't exist. + } + // end of ticket check for (size_t i = 0; i < tikFileEntries.size(); i++) { diff --git a/source/install/nsp.cpp b/source/install/nsp.cpp index ed24c36..1a35c07 100644 --- a/source/install/nsp.cpp +++ b/source/install/nsp.cpp @@ -94,9 +94,9 @@ namespace tin::install::nsp auto foundExtension = name.substr(name.find(".") + 1); // fix cert filename extension becoming corrupted when xcz/nsz is installing certs. - std::string cert ("cert"); + std::string cert("cert"); std::size_t found = name.find(cert); - if (found!=std::string::npos){ + if (found != std::string::npos) { int pos = 0; std::string mystr = name; pos = mystr.find_last_of('.'); @@ -163,7 +163,7 @@ namespace tin::install::nsp const char* NSP::GetFileEntryName(const PFS0FileEntry* fileEntry) { u64 stringTableStart = sizeof(PFS0BaseHeader) + this->GetBaseHeader()->numFiles * sizeof(PFS0FileEntry); - + //check for messed up filenames in our table.... usually when instaling xcz/xci /* FILE * fp; diff --git a/source/install/xci.cpp b/source/install/xci.cpp index d0189a5..39e4bd4 100644 --- a/source/install/xci.cpp +++ b/source/install/xci.cpp @@ -159,18 +159,18 @@ namespace tin::install::xci const HFS0FileEntry* fileEntry = this->GetFileEntry(i); std::string name(this->GetFileEntryName(fileEntry)); auto foundExtension = name.substr(name.find(".") + 1); - + // fix cert filename extension becoming corrupted when xcz/nsz is installing certs. - std::string cert ("cert"); + std::string cert("cert"); std::size_t found = name.find(cert); - if (found!=std::string::npos){ + if (found != std::string::npos) { int pos = 0; std::string mystr = name; pos = mystr.find_last_of('.'); mystr = mystr.substr(5, pos); foundExtension = mystr.substr(mystr.find(".") + 1); } - + if (foundExtension == extension) entryList.push_back(fileEntry); } diff --git a/source/nx/nca_writer.cpp b/source/nx/nca_writer.cpp index 74ac95d..2d3381c 100644 --- a/source/nx/nca_writer.cpp +++ b/source/nx/nca_writer.cpp @@ -102,7 +102,7 @@ public: { public: Crypto::Aes128Ctr crypto; - + SectionContext(const Section& s) : Section(s), crypto(s.cryptoKey, Crypto::AesCtr(Crypto::swapEndian(((u64*)&s.cryptoCounter)[0]))) { } diff --git a/source/ui/ThemeInstPage.cpp b/source/ui/ThemeInstPage.cpp index dcd8355..b8900eb 100644 --- a/source/ui/ThemeInstPage.cpp +++ b/source/ui/ThemeInstPage.cpp @@ -124,7 +124,7 @@ namespace inst::ui { this->menu->SetSelectedIndex(myindex); //jump to the index we saved from above } } - + void ThemeInstPage::setInstBarPerc(double ourPercent) { mainApp->ThemeinstPage->installBar->SetProgress(ourPercent); if (ourPercent >= 1 && ourPercent != 100) { @@ -134,21 +134,21 @@ namespace inst::ui { mainApp->ThemeinstPage->installBar->SetVisible(false); } // - if (installing == 1){ + if (installing == 1) { std::stringstream x; x << ourPercent; inst::ui::mainApp->ThemeinstPage->pageInfoText->SetText("theme.downloading"_lang + x.str() + "theme.percent"_lang); - if (x.str() == "100"){ + if (x.str() == "100") { inst::ui::mainApp->ThemeinstPage->pageInfoText->SetText("theme.extracting"_lang); } } - else{ + else { inst::ui::mainApp->ThemeinstPage->pageInfoText->SetText("theme.theme_top_info"_lang); } // mainApp->CallForRender(); } - + void ThemeInstPage::startNetwork() { this->butText->SetText("theme.please_wait"_lang); this->menu->SetVisible(false); @@ -180,62 +180,62 @@ namespace inst::ui { void ThemeInstPage::selectTitle(int selectedIndex) { if (installing != 1) { - for (long unsigned int i = 0; i < this->selectedUrls.size(); i++) { - inst::ui::mainApp->ThemeinstPage->setInstBarPerc(0); - ourPath = inst::config::appDir + "/temp_download.zip"; - installing = 1; - bool didDownload = inst::curl::downloadFile(selectedUrls[0], ourPath.c_str(), 0, true); - bool didExtract = false; - if (didDownload) { - inst::ui::mainApp->ThemeinstPage->pageInfoText->SetText("theme.complete"_lang); - try { - didExtract = inst::zip::extractFile(ourPath, "sdmc:/"); - } - catch (...) { - //extraction failed: still to do - put check in zip function... + for (long unsigned int i = 0; i < this->selectedUrls.size(); i++) { + inst::ui::mainApp->ThemeinstPage->setInstBarPerc(0); + ourPath = inst::config::appDir + "/temp_download.zip"; + installing = 1; + bool didDownload = inst::curl::downloadFile(selectedUrls[0], ourPath.c_str(), 0, true); + bool didExtract = false; + if (didDownload) { + inst::ui::mainApp->ThemeinstPage->pageInfoText->SetText("theme.complete"_lang); + try { + didExtract = inst::zip::extractFile(ourPath, "sdmc:/"); } - } - else { - inst::ui::mainApp->ThemeinstPage->pageInfoText->SetText("theme.failed"_lang); - installing = 0; - inst::ui::mainApp->ThemeinstPage->setInstBarPerc(0); - mainApp->ThemeinstPage->installBar->SetVisible(false); - inst::ui::mainApp->CreateShowDialog("theme.theme_error"_lang, "theme.theme_error_info"_lang, { "common.ok"_lang }, true, "romfs:/images/icons/fail.png"); - return; - } - std::filesystem::remove(ourPath); - if (didExtract) { - inst::ui::mainApp->ThemeinstPage->pageInfoText->SetText("theme.extracted"_lang); - int close = inst::ui::mainApp->CreateShowDialog("theme.installed"_lang, "theme.restart"_lang, { "sig.later"_lang, "sig.restart"_lang }, false, "romfs:/images/icons/good.png"); - inst::ui::mainApp->ThemeinstPage->setInstBarPerc(0); - mainApp->ThemeinstPage->installBar->SetVisible(false); - if (close != 0) { - mainApp->FadeOut(); - mainApp->Close(); - } - } - else { - inst::ui::mainApp->ThemeinstPage->pageInfoText->SetText("theme.retry"_lang); - installing = 0; - inst::ui::mainApp->ThemeinstPage->setInstBarPerc(0); - mainApp->ThemeinstPage->installBar->SetVisible(false); - return; - - } - installing = 0; - inst::ui::mainApp->ThemeinstPage->setInstBarPerc(0); - mainApp->ThemeinstPage->installBar->SetVisible(false); - return; - } - } - else { - inst::ui::mainApp->CreateShowDialog("theme.wait"_lang, "theme.trying"_lang, { "common.ok"_lang }, true, "romfs:/images/icons/information.png"); - } + catch (...) { + //extraction failed: still to do - put check in zip function... + } + } + else { + inst::ui::mainApp->ThemeinstPage->pageInfoText->SetText("theme.failed"_lang); + installing = 0; + inst::ui::mainApp->ThemeinstPage->setInstBarPerc(0); + mainApp->ThemeinstPage->installBar->SetVisible(false); + inst::ui::mainApp->CreateShowDialog("theme.theme_error"_lang, "theme.theme_error_info"_lang, { "common.ok"_lang }, true, "romfs:/images/icons/fail.png"); + return; + } + std::filesystem::remove(ourPath); + if (didExtract) { + inst::ui::mainApp->ThemeinstPage->pageInfoText->SetText("theme.extracted"_lang); + int close = inst::ui::mainApp->CreateShowDialog("theme.installed"_lang, "theme.restart"_lang, { "sig.later"_lang, "sig.restart"_lang }, false, "romfs:/images/icons/good.png"); + inst::ui::mainApp->ThemeinstPage->setInstBarPerc(0); + mainApp->ThemeinstPage->installBar->SetVisible(false); + if (close != 0) { + mainApp->FadeOut(); + mainApp->Close(); + } + } + else { + inst::ui::mainApp->ThemeinstPage->pageInfoText->SetText("theme.retry"_lang); + installing = 0; + inst::ui::mainApp->ThemeinstPage->setInstBarPerc(0); + mainApp->ThemeinstPage->installBar->SetVisible(false); + return; + + } + installing = 0; + inst::ui::mainApp->ThemeinstPage->setInstBarPerc(0); + mainApp->ThemeinstPage->installBar->SetVisible(false); + return; + } + } + else { + inst::ui::mainApp->CreateShowDialog("theme.wait"_lang, "theme.trying"_lang, { "common.ok"_lang }, true, "romfs:/images/icons/information.png"); + } installing = 0; } void ThemeInstPage::onInput(u64 Down, u64 Up, u64 Held, pu::ui::TouchPoint touch_pos) { - + if (Down & HidNpadButton_B) { if (installing != 1) { mainApp->LoadLayout(mainApp->optionspage); @@ -258,16 +258,16 @@ namespace inst::ui { if (xxxx != 1) { int var = this->menu->GetItems().size(); auto s = std::to_string(var); - if (s != "0") { - myindex = this->menu->GetSelectedIndex(); //store index so when page redraws we can get the last item we checked. - if (this->menu->GetItems()[myindex]->GetIconPath() == "romfs:/images/icons/check-box-outline.png") { - } - this->selectedUrls.push_back(this->ourUrls[myindex]); - this->drawMenuItems(false); - } + if (s != "0") { + myindex = this->menu->GetSelectedIndex(); //store index so when page redraws we can get the last item we checked. + if (this->menu->GetItems()[myindex]->GetIconPath() == "romfs:/images/icons/check-box-outline.png") { + } + this->selectedUrls.push_back(this->ourUrls[myindex]); + this->drawMenuItems(false); + } } } - + if (Down & HidNpadButton_Plus || (state.count != xxxx)) { this->selectTitle(myindex); } diff --git a/source/ui/mainPage.cpp b/source/ui/mainPage.cpp index 292ae19..c4e79cf 100644 --- a/source/ui/mainPage.cpp +++ b/source/ui/mainPage.cpp @@ -124,9 +124,8 @@ namespace inst::ui { //unmount user now as we already know how much space we have fsdevUnmountDevice("user"); - std::string Info = ("System total size: " + sdsize2 + " GB" + "\nSystem free space: " + freespace2 + " GB" + "\nSystem percent used: " + percent2 + "%" + "\n\n" + "SD card total size: " + sdsize + " GB" + "\nSD card free space: " + freespace + " GB" + "\nSD card percent used: " + percent + "%"); - //std::string Info = ("System total size: " + sdsize2 + " GB" + "\nSystem free space: " + freespace2 + " GB" + "\nSystem percent used: " + percent2 + "%" + "\n\n" + "SD card total size: " + sdsize + " GB" + "\nSD card free space: " + freespace + " GB" + "\nSD card percent used: " + percent + "%"); - inst::ui::mainApp->CreateShowDialog("Space Usage Information", Info, { "common.ok"_lang }, true, "romfs:/images/icons/drive.png"); + std::string Info = ("usage.system_size"_lang + sdsize2 + "usage.gb"_lang + "usage.freespace"_lang + freespace2 + "usage.gb"_lang + "usage.percent_used"_lang + percent2 + "usage.percent"_lang + "usage.sd_size"_lang + sdsize + "usage.gb"_lang + "usage.sd_space"_lang + freespace + "usage.gb"_lang + "usage.sd_used"_lang + percent + "usage.percent_symbol"_lang); + inst::ui::mainApp->CreateShowDialog("usage.space_info"_lang, Info, { "common.ok"_lang }, true, "romfs:/images/icons/drive.png"); } void mainMenuThread() { diff --git a/source/ui/optionsPage.cpp b/source/ui/optionsPage.cpp index f41ac2e..7fb8bb2 100644 --- a/source/ui/optionsPage.cpp +++ b/source/ui/optionsPage.cpp @@ -122,11 +122,11 @@ namespace inst::ui { } } else { - if (inst::config::useTheme) { - inst::config::useTheme = false; - mainApp->FadeOut(); - mainApp->Close(); - } + if (inst::config::useTheme) { + inst::config::useTheme = false; + mainApp->FadeOut(); + mainApp->Close(); + } } } @@ -177,17 +177,17 @@ namespace inst::ui { httpkeyboard->SetColor(COLOR("#FFFFFFFF")); httpkeyboard->SetIcon(this->getMenuOptionIcon(inst::config::httpkeyboard)); this->menu->AddItem(httpkeyboard); - + auto useThemeOption = pu::ui::elm::MenuItem::New("theme.theme_option"_lang); useThemeOption->SetColor(COLOR("#FFFFFFFF")); useThemeOption->SetIcon(this->getMenuOptionIcon(inst::config::useTheme)); this->menu->AddItem(useThemeOption); - + auto ThemeMenuOption = pu::ui::elm::MenuItem::New("theme.theme_menu"_lang); ThemeMenuOption->SetColor(COLOR("#FFFFFFFF")); ThemeMenuOption->SetIcon("romfs:/images/icons/thememenu.png"); this->menu->AddItem(ThemeMenuOption); - + // auto ThemeUrlOption = pu::ui::elm::MenuItem::New("theme.theme_url"_lang + inst::util::shortenString(inst::config::httplastUrl2, 42, false)); ThemeUrlOption->SetColor(COLOR("#FFFFFFFF")); @@ -362,7 +362,7 @@ namespace inst::ui { inst::ui::mainApp->CreateShowDialog("main.net.title"_lang, "main.net.desc"_lang, { "common.ok"_lang }, true, "romfs:/images/icons/information.png"); break; } - mainApp->ThemeinstPage->startNetwork(); + mainApp->ThemeinstPage->startNetwork(); break; case 11: keyboardResult = inst::util::softwareKeyboard("inst.net.url.hint"_lang, inst::config::httplastUrl2.c_str(), 500); diff --git a/source/util/lang.cpp b/source/util/lang.cpp index 64fe9d1..4693739 100644 --- a/source/util/lang.cpp +++ b/source/util/lang.cpp @@ -74,48 +74,48 @@ namespace Language { break; case 0: switch (syslang) { - case 0: - languagePath = "romfs:/lang/jp.json"; - break; - case 1: - languagePath = "romfs:/lang/en.json"; - break; - case 2: - languagePath = "romfs:/lang/fr.json"; - break; - case 3: - languagePath = "romfs:/lang/de.json"; - break; - case 4: - languagePath = "romfs:/lang/it.json"; - break; - case 5: - languagePath = "romfs:/lang/es.json"; - break; - case 6: - languagePath = "romfs:/lang/tw.json"; - break; - case 10: - languagePath = "romfs:/lang/ru.json"; - break; - case 11: - languagePath = "romfs:/lang/tw.json"; - break; - case 12: - languagePath = "romfs:/lang/en.json"; - break; - case 13: - languagePath = "romfs:/lang/fr.json"; - break; - case 14: - languagePath = "romfs:/lang/es.json"; - break; - case 16: - languagePath = "romfs:/lang/tw.json"; - break; - default: - languagePath = "romfs:/lang/en.json"; - break; + case 0: + languagePath = "romfs:/lang/jp.json"; + break; + case 1: + languagePath = "romfs:/lang/en.json"; + break; + case 2: + languagePath = "romfs:/lang/fr.json"; + break; + case 3: + languagePath = "romfs:/lang/de.json"; + break; + case 4: + languagePath = "romfs:/lang/it.json"; + break; + case 5: + languagePath = "romfs:/lang/es.json"; + break; + case 6: + languagePath = "romfs:/lang/tw.json"; + break; + case 10: + languagePath = "romfs:/lang/ru.json"; + break; + case 11: + languagePath = "romfs:/lang/tw.json"; + break; + case 12: + languagePath = "romfs:/lang/en.json"; + break; + case 13: + languagePath = "romfs:/lang/fr.json"; + break; + case 14: + languagePath = "romfs:/lang/es.json"; + break; + case 16: + languagePath = "romfs:/lang/tw.json"; + break; + default: + languagePath = "romfs:/lang/en.json"; + break; } break; default: