diff --git a/include/ui/ThemeInstPage.hpp b/include/ui/ThemeInstPage.hpp index 4f0d5a3..a5479bb 100644 --- a/include/ui/ThemeInstPage.hpp +++ b/include/ui/ThemeInstPage.hpp @@ -27,7 +27,6 @@ namespace inst::ui { pu::ui::elm::Menu::Ref menu; Image::Ref infoImage; void drawMenuItems(bool clearItems); - void drawMenuItems_withext(bool clearItems); void selectTitle(int selectedIndex); }; } \ No newline at end of file diff --git a/source/HDInstall.cpp b/source/HDInstall.cpp index c7a8d8d..aaed5f5 100644 --- a/source/HDInstall.cpp +++ b/source/HDInstall.cpp @@ -59,6 +59,19 @@ namespace nspInstStuff_B { if (whereToInstall) m_destStorageId = NcmStorageId_BuiltInUser; unsigned int titleItr; + std::string bin = "romfs:/images/icons/bin.png"; + if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(inst::config::appDir + "icons_others.bin"_theme)) { + bin = inst::config::appDir + "icons_others.bin"_theme; + } + std::string info = "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)) { + info = inst::config::appDir + "icons_others.information"_theme; + } + std::string fail = "romfs:/images/icons/fail.png"; + if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(inst::config::appDir + "icons_others.fail"_theme)) { + fail = inst::config::appDir + "icons_others.fail"_theme; + } + std::vector previousClockValues; if (inst::config::overClock) { previousClockValues.push_back(inst::util::setClockSpeed(0, 1785000000)[0]); @@ -116,7 +129,7 @@ namespace nspInstStuff_B { audioThread.join(); } - inst::ui::mainApp->CreateShowDialog("inst.info_page.failed"_lang + inst::util::shortenString(ourTitleList[titleItr].filename().string(), 42, true) + "!", "inst.info_page.failed_desc"_lang + "\n\n" + (std::string)e.what(), { "common.ok"_lang }, true, "romfs:/images/icons/fail.png"); + inst::ui::mainApp->CreateShowDialog("inst.info_page.failed"_lang + inst::util::shortenString(ourTitleList[titleItr].filename().string(), 42, true) + "!", "inst.info_page.failed_desc"_lang + "\n\n" + (std::string)e.what(), { "common.ok"_lang }, true, fail); nspInstalled = false; } @@ -145,22 +158,22 @@ namespace nspInstStuff_B { if (ourTitleList.size() > 1) { if (inst::config::deletePrompt) { - if (inst::ui::mainApp->CreateShowDialog(std::to_string(ourTitleList.size()) + "inst.hd.delete_info_multi"_lang, "inst.hd.delete_desc"_lang, { "common.no"_lang,"common.yes"_lang }, false, "romfs:/images/icons/bin.png") == 1) { + if (inst::ui::mainApp->CreateShowDialog(std::to_string(ourTitleList.size()) + "inst.hd.delete_info_multi"_lang, "inst.hd.delete_desc"_lang, { "common.no"_lang,"common.yes"_lang }, false, bin) == 1) { for (long unsigned int i = 0; i < ourTitleList.size(); i++) { if (std::filesystem::exists(ourTitleList[i])) std::filesystem::remove(ourTitleList[i]); } } } - else inst::ui::mainApp->CreateShowDialog(std::to_string(ourTitleList.size()) + "inst.info_page.desc0"_lang, Language::GetRandomMsg(), { "common.ok"_lang }, true, "romfs:/images/icons/information.png"); + else inst::ui::mainApp->CreateShowDialog(std::to_string(ourTitleList.size()) + "inst.info_page.desc0"_lang, Language::GetRandomMsg(), { "common.ok"_lang }, true, info); } else { if (inst::config::deletePrompt) { - if (inst::ui::mainApp->CreateShowDialog(inst::util::shortenString(ourTitleList[0].filename().string(), 32, true) + "inst.hd.delete_info"_lang, "inst.hd.delete_desc"_lang, { "common.no"_lang,"common.yes"_lang }, false, "romfs:/images/icons/bin.png") == 1) if (std::filesystem::exists(ourTitleList[0])) std::filesystem::remove(ourTitleList[0]); + if (inst::ui::mainApp->CreateShowDialog(inst::util::shortenString(ourTitleList[0].filename().string(), 32, true) + "inst.hd.delete_info"_lang, "inst.hd.delete_desc"_lang, { "common.no"_lang,"common.yes"_lang }, false, bin) == 1) if (std::filesystem::exists(ourTitleList[0])) std::filesystem::remove(ourTitleList[0]); } - else inst::ui::mainApp->CreateShowDialog(inst::util::shortenString(ourTitleList[0].filename().string(), 42, true) + "inst.info_page.desc1"_lang, Language::GetRandomMsg(), { "common.ok"_lang }, true, "romfs:/images/icons/bin.png"); + else inst::ui::mainApp->CreateShowDialog(inst::util::shortenString(ourTitleList[0].filename().string(), 42, true) + "inst.info_page.desc1"_lang, Language::GetRandomMsg(), { "common.ok"_lang }, true, bin); } } - + LOG_DEBUG("Done"); inst::ui::instPage::loadMainMenu(); inst::util::deinitInstallServices(); diff --git a/source/ThemeInstall.cpp b/source/ThemeInstall.cpp index 02ee4d5..88de6db 100644 --- a/source/ThemeInstall.cpp +++ b/source/ThemeInstall.cpp @@ -36,6 +36,7 @@ SOFTWARE. #include "util/curl.hpp" #include "util/lang.hpp" #include "ui/MainApplication.hpp" +#include "util/theme.hpp" bool netConnected2 = false; @@ -125,6 +126,19 @@ namespace ThemeInstStuff { u64 startTime = armGetSystemTick(); OnUnwound(); + std::string info = "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)) { + info = inst::config::appDir + "icons_others.information"_theme; + } + std::string fail = "romfs:/images/icons/fail.png"; + if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(inst::config::appDir + "icons_others.fail"_theme)) { + fail = inst::config::appDir + "icons_others.fail"_theme; + } + std::string wait = "romfs:/images/icons/wait.png"; + if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(inst::config::appDir + "icons_others.wait"_theme)) { + wait = inst::config::appDir + "icons_others.wait"_theme; + } + try { ASSERT_OK(curl_global_init(CURL_GLOBAL_ALL), "Curl failed to initialized"); @@ -173,7 +187,7 @@ namespace ThemeInstStuff { 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::ui::mainApp->CreateShowDialog("theme.theme_fail"_lang, "inst.net.help.blank"_lang, { "common.ok"_lang }, true, info); inst::config::httplastUrl2 = url; inst::config::setConfig(); //refresh options page @@ -184,7 +198,7 @@ namespace ThemeInstStuff { 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"); + inst::ui::mainApp->CreateShowDialog("inst.net.url.invalid"_lang, "", { "common.ok"_lang }, false, fail); break; } else { @@ -197,7 +211,7 @@ namespace ThemeInstStuff { 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"); + inst::ui::mainApp->CreateShowDialog("theme.theme_error"_lang, "theme.theme_error_info"_lang, { "common.ok"_lang }, true, fail); break; } } @@ -221,7 +235,7 @@ namespace ThemeInstStuff { 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"); + inst::ui::mainApp->CreateShowDialog("inst.net.url.listwait"_lang + std::to_string(maxlist) + "inst.net.url.listwait2"_lang, "", { "common.ok"_lang }, false, wait); } while (index < response.size()) { std::string link; @@ -282,7 +296,7 @@ namespace ThemeInstStuff { } else { - inst::ui::mainApp->CreateShowDialog("theme.no_themes"_lang, "", { "common.ok"_lang }, false, "romfs:/images/icons/fail.png"); + inst::ui::mainApp->CreateShowDialog("theme.no_themes"_lang, "", { "common.ok"_lang }, false, fail); LOG_DEBUG("Failed to parse themes from HTML\n"); break; } @@ -290,14 +304,14 @@ namespace ThemeInstStuff { } else { - inst::ui::mainApp->CreateShowDialog("theme.theme_error"_lang, "theme.theme_error_info"_lang, { "common.ok"_lang }, true, "romfs:/images/icons/fail.png"); + inst::ui::mainApp->CreateShowDialog("theme.theme_error"_lang, "theme.theme_error_info"_lang, { "common.ok"_lang }, true, fail); 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"); + inst::ui::mainApp->CreateShowDialog("theme.theme_error"_lang, "theme.theme_error_info"_lang, { "common.ok"_lang }, true, fail); break; } } @@ -308,7 +322,7 @@ namespace ThemeInstStuff { LOG_DEBUG("Failed to perform remote install!\n"); LOG_DEBUG("%s", e.what()); fprintf(stdout, "%s", e.what()); - inst::ui::mainApp->CreateShowDialog("inst.net.failed"_lang, (std::string)e.what(), { "common.ok"_lang }, true, "romfs:/images/icons/fail.png"); + inst::ui::mainApp->CreateShowDialog("inst.net.failed"_lang, (std::string)e.what(), { "common.ok"_lang }, true, fail); return {}; } } diff --git a/source/install/install_nsp.cpp b/source/install/install_nsp.cpp index fa1d740..a3651d9 100644 --- a/source/install/install_nsp.cpp +++ b/source/install/install_nsp.cpp @@ -40,6 +40,7 @@ SOFTWARE. #include "util/util.hpp" #include "util/lang.hpp" #include "ui/MainApplication.hpp" +#include "util/theme.hpp" namespace inst::ui { extern MainApplication* mainApp; @@ -165,7 +166,11 @@ namespace tin::install::nsp 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"); + std::string info = "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)) { + info = inst::config::appDir + "icons_others.information"_theme; + } + inst::ui::mainApp->CreateShowDialog("main.usb.warn.title"_lang, "inst.nca_verify.ticket_missing"_lang, { "common.ok"_lang }, false, info); return; //don't bother trying to install the ticket or cert if it doesn't exist. } // end of ticket check diff --git a/source/netInstall.cpp b/source/netInstall.cpp index 964648b..fea3618 100644 --- a/source/netInstall.cpp +++ b/source/netInstall.cpp @@ -164,7 +164,12 @@ namespace netInstStuff { close(m_serverSocket); m_serverSocket = 0; } - inst::ui::mainApp->CreateShowDialog("Failed to initialize server socket!", (std::string)e.what(), { "OK" }, true, "romfs:/images/icons/fail.png"); + std::string fail = "romfs:/images/icons/fail.png"; + if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(inst::config::appDir + "icons_others.fail"_theme)) { + fail = inst::config::appDir + "icons_others.fail"_theme; + } + + inst::ui::mainApp->CreateShowDialog("Failed to initialize server socket!", (std::string)e.what(), { "OK" }, true, fail); } } @@ -253,7 +258,12 @@ namespace netInstStuff { audioThread.join(); } - inst::ui::mainApp->CreateShowDialog("inst.info_page.failed"_lang + urlNames[urlItr] + "!", "inst.info_page.failed_desc"_lang + "\n\n" + (std::string)e.what(), { "common.ok"_lang }, true, "romfs:/images/icons/fail.png"); + std::string fail = "romfs:/images/icons/fail.png"; + if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(inst::config::appDir + "icons_others.fail"_theme)) { + fail = inst::config::appDir + "icons_others.fail"_theme; + } + + inst::ui::mainApp->CreateShowDialog("inst.info_page.failed"_lang + urlNames[urlItr] + "!", "inst.info_page.failed_desc"_lang + "\n\n" + (std::string)e.what(), { "common.ok"_lang }, true, fail); nspInstalled = false; } @@ -285,11 +295,16 @@ namespace netInstStuff { audioThread.join(); } + std::string good = "romfs:/images/icons/good.png"; + if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(inst::config::appDir + "icons_others.good"_theme)) { + good = inst::config::appDir + "icons_others.good"_theme; + } + if (ourUrlList.size() > 1) { - inst::ui::mainApp->CreateShowDialog(std::to_string(ourUrlList.size()) + "inst.info_page.desc0"_lang, Language::GetRandomMsg(), { "common.ok"_lang }, true, "romfs:/images/icons/good.png"); + inst::ui::mainApp->CreateShowDialog(std::to_string(ourUrlList.size()) + "inst.info_page.desc0"_lang, Language::GetRandomMsg(), { "common.ok"_lang }, true, good); } else { - inst::ui::mainApp->CreateShowDialog(urlNames[0] + "inst.info_page.desc1"_lang, Language::GetRandomMsg(), { "common.ok"_lang }, true, "romfs:/images/icons/good.png"); + inst::ui::mainApp->CreateShowDialog(urlNames[0] + "inst.info_page.desc1"_lang, Language::GetRandomMsg(), { "common.ok"_lang }, true, good); } } @@ -332,6 +347,19 @@ namespace netInstStuff { std::vector urls; std::vector tmp_array; + std::string info = "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)) { + info = inst::config::appDir + "icons_others.information"_theme; + } + std::string fail = "romfs:/images/icons/fail.png"; + if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(inst::config::appDir + "icons_others.fail"_theme)) { + fail = inst::config::appDir + "icons_others.fail"_theme; + } + std::string wait = "romfs:/images/icons/wait.png"; + if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(inst::config::appDir + "icons_others.wait"_theme)) { + wait = inst::config::appDir + "icons_others.wait"_theme; + } + while (true) { padUpdate(&pad); @@ -356,7 +384,7 @@ namespace netInstStuff { } if (kDown & HidNpadButton_X) { - inst::ui::mainApp->CreateShowDialog("inst.net.help.title"_lang, "inst.net.help.desc"_lang, { "common.ok"_lang }, true, "romfs:/images/icons/information.png"); + inst::ui::mainApp->CreateShowDialog("inst.net.help.title"_lang, "inst.net.help.desc"_lang, { "common.ok"_lang }, true, info); } if (kDown & HidNpadButton_Minus) { @@ -378,7 +406,7 @@ namespace netInstStuff { if (url == "") { url = ("http://127.0.0.1"); - inst::ui::mainApp->CreateShowDialog("inst.net.help.title"_lang, "inst.net.help.blank"_lang, { "common.ok"_lang }, true, "romfs:/images/icons/information.png"); + inst::ui::mainApp->CreateShowDialog("inst.net.help.title"_lang, "inst.net.help.blank"_lang, { "common.ok"_lang }, true, info); inst::config::httpIndexUrl = url; inst::config::setConfig(); //refresh options page @@ -389,7 +417,7 @@ namespace netInstStuff { 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"); + inst::ui::mainApp->CreateShowDialog("inst.net.url.invalid"_lang, "", { "common.ok"_lang }, false, fail); break; } else { @@ -402,7 +430,7 @@ namespace netInstStuff { if (response.empty()) { response = inst::curl::html_to_buffer(url); if (response.empty()) { - inst::ui::mainApp->CreateShowDialog("inst.net.index_error"_lang, "inst.net.index_error_info"_lang, { "common.ok"_lang }, true, "romfs:/images/icons/fail.png"); + inst::ui::mainApp->CreateShowDialog("inst.net.index_error"_lang, "inst.net.index_error_info"_lang, { "common.ok"_lang }, true, fail); break; } } @@ -426,7 +454,7 @@ namespace netInstStuff { 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"); + inst::ui::mainApp->CreateShowDialog("inst.net.url.listwait"_lang + std::to_string(maxlist) + "inst.net.url.listwait2"_lang, "", { "common.ok"_lang }, false, wait); } while (index < response.size()) { std::string link; @@ -508,7 +536,7 @@ namespace netInstStuff { } else { - inst::ui::mainApp->CreateShowDialog("inst.net.url.nolinks"_lang, "", { "common.ok"_lang }, false, "romfs:/images/icons/fail.png"); + inst::ui::mainApp->CreateShowDialog("inst.net.url.nolinks"_lang, "", { "common.ok"_lang }, false, fail); LOG_DEBUG("Failed to parse games from HTML\n"); break; } @@ -516,7 +544,7 @@ namespace netInstStuff { } else { - inst::ui::mainApp->CreateShowDialog("inst.net.index_error"_lang, "inst.net.index_error_info"_lang, { "common.ok"_lang }, true, "romfs:/images/icons/fail.png"); + inst::ui::mainApp->CreateShowDialog("inst.net.index_error"_lang, "inst.net.index_error_info"_lang, { "common.ok"_lang }, true, fail); break; } } @@ -575,7 +603,11 @@ namespace netInstStuff { LOG_DEBUG("Failed to perform remote install!\n"); LOG_DEBUG("%s", e.what()); fprintf(stdout, "%s", e.what()); - inst::ui::mainApp->CreateShowDialog("inst.net.failed"_lang, (std::string)e.what(), { "common.ok"_lang }, true, "romfs:/images/icons/fail.png"); + std::string fail = "romfs:/images/icons/fail.png"; + if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(inst::config::appDir + "icons_others.fail"_theme)) { + fail = inst::config::appDir + "icons_others.fail"_theme; + } + inst::ui::mainApp->CreateShowDialog("inst.net.failed"_lang, (std::string)e.what(), { "common.ok"_lang }, true, fail); return {}; } } diff --git a/source/sdInstall.cpp b/source/sdInstall.cpp index 200c685..df1e808 100644 --- a/source/sdInstall.cpp +++ b/source/sdInstall.cpp @@ -112,7 +112,12 @@ namespace nspInstStuff { audioThread.join(); } - inst::ui::mainApp->CreateShowDialog("inst.info_page.failed"_lang + inst::util::shortenString(ourTitleList[titleItr].filename().string(), 42, true) + "!\n", "inst.info_page.failed_desc"_lang + "\n\n" + (std::string)e.what(), { "common.ok"_lang }, true); + std::string fail = "romfs:/images/icons/fail.png"; + if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(inst::config::appDir + "icons_others.fail"_theme)) { + fail = inst::config::appDir + "icons_others.fail"_theme; + } + + inst::ui::mainApp->CreateShowDialog("inst.info_page.failed"_lang + inst::util::shortenString(ourTitleList[titleItr].filename().string(), 42, true) + "!\n", "inst.info_page.failed_desc"_lang + "\n\n" + (std::string)e.what(), { "common.ok"_lang }, true, fail); nspInstalled = false; } @@ -126,6 +131,19 @@ namespace nspInstStuff { inst::ui::instPage::setInstInfoText("inst.info_page.complete"_lang); inst::ui::instPage::setInstBarPerc(100); + std::string bin = "romfs:/images/icons/bin.png"; + if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(inst::config::appDir + "icons_others.bin"_theme)) { + bin = inst::config::appDir + "icons_others.bin"_theme; + } + std::string info = "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)) { + info = inst::config::appDir + "icons_others.information"_theme; + } + std::string good = "romfs:/images/icons/good.png"; + if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(inst::config::appDir + "icons_others.good"_theme)) { + good = inst::config::appDir + "icons_others.good"_theme; + } + if (inst::config::useSound) { std::string audioPath = ""; std::string pass = inst::config::appDir + "audio.pass"_theme; @@ -141,7 +159,7 @@ namespace nspInstStuff { if (ourTitleList.size() > 1) { if (inst::config::deletePrompt) { - if (inst::ui::mainApp->CreateShowDialog(std::to_string(ourTitleList.size()) + "inst.sd.delete_info_multi"_lang, "inst.sd.delete_desc"_lang, { "common.no"_lang,"common.yes"_lang }, false, "romfs:/images/icons/bin.png") == 1) { + if (inst::ui::mainApp->CreateShowDialog(std::to_string(ourTitleList.size()) + "inst.sd.delete_info_multi"_lang, "inst.sd.delete_desc"_lang, { "common.no"_lang,"common.yes"_lang }, false, bin) == 1) { for (long unsigned int i = 0; i < ourTitleList.size(); i++) { if (std::filesystem::exists(ourTitleList[i])) { std::filesystem::remove(ourTitleList[i]); @@ -150,14 +168,14 @@ namespace nspInstStuff { } } else { - inst::ui::mainApp->CreateShowDialog(std::to_string(ourTitleList.size()) + "inst.info_page.desc0"_lang, Language::GetRandomMsg(), { "common.ok"_lang }, true, "romfs:/images/icons/good.png"); + inst::ui::mainApp->CreateShowDialog(std::to_string(ourTitleList.size()) + "inst.info_page.desc0"_lang, Language::GetRandomMsg(), { "common.ok"_lang }, true, good); } } else { if (inst::config::deletePrompt) { - if (inst::ui::mainApp->CreateShowDialog(inst::util::shortenString(ourTitleList[0].filename().string(), 32, true) + "inst.sd.delete_info"_lang, "inst.sd.delete_desc"_lang, { "common.no"_lang,"common.yes"_lang }, false, "romfs:/images/icons/bin.png") == 1) if (std::filesystem::exists(ourTitleList[0])) std::filesystem::remove(ourTitleList[0]); + if (inst::ui::mainApp->CreateShowDialog(inst::util::shortenString(ourTitleList[0].filename().string(), 32, true) + "inst.sd.delete_info"_lang, "inst.sd.delete_desc"_lang, { "common.no"_lang,"common.yes"_lang }, false, bin) == 1) if (std::filesystem::exists(ourTitleList[0])) std::filesystem::remove(ourTitleList[0]); } - else inst::ui::mainApp->CreateShowDialog(inst::util::shortenString(ourTitleList[0].filename().string(), 42, true) + "inst.info_page.desc1"_lang, Language::GetRandomMsg(), { "common.ok"_lang }, true, "romfs:/images/icons/information.png"); + else inst::ui::mainApp->CreateShowDialog(inst::util::shortenString(ourTitleList[0].filename().string(), 42, true) + "inst.info_page.desc1"_lang, Language::GetRandomMsg(), { "common.ok"_lang }, true, info); } } diff --git a/source/sigInstall.cpp b/source/sigInstall.cpp index e540ecf..e2de88f 100644 --- a/source/sigInstall.cpp +++ b/source/sigInstall.cpp @@ -6,6 +6,7 @@ #include "util/unzip.hpp" #include "util/config.hpp" #include "util/lang.hpp" +#include "util/theme.hpp" namespace inst::ui { extern MainApplication* mainApp; @@ -14,6 +15,23 @@ namespace inst::ui { namespace sig { void installSigPatches() { bpcInitialize(); + std::string fail = "romfs:/images/icons/fail.png"; + if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(inst::config::appDir + "icons_others.fail"_theme)) { + fail = inst::config::appDir + "icons_others.fail"_theme; + } + std::string patches = "romfs:/images/icons/patches.png"; + if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(inst::config::appDir + "icons_others.patches"_theme)) { + patches = inst::config::appDir + "icons_others.patches"_theme; + } + std::string update = "romfs:/images/icons/update.png"; + if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(inst::config::appDir + "icons_others.update"_theme)) { + update = inst::config::appDir + "icons_others.update"_theme; + } + std::string good = "romfs:/images/icons/good.png"; + if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(inst::config::appDir + "icons_others.good"_theme)) { + good = inst::config::appDir + "icons_others.good"_theme; + } + try { std::string patchesVersion = inst::util::readTextFromFile("sdmc:/atmosphere/exefs_patches/es_patches/patches.txt"); std::string versionText = ""; @@ -22,21 +40,21 @@ namespace sig { versionText = "\n\n" + "sig.version_text"_lang + patchesVersion + "."; installButtonText = "sig.update"_lang; } - int ourResult = inst::ui::mainApp->CreateShowDialog("sig.title0"_lang, "sig.desc0"_lang + versionText, { installButtonText, "sig.uninstall"_lang, "common.cancel"_lang }, true, "romfs:/images/icons/patches.png"); + int ourResult = inst::ui::mainApp->CreateShowDialog("sig.title0"_lang, "sig.desc0"_lang + versionText, { installButtonText, "sig.uninstall"_lang, "common.cancel"_lang }, true, patches); if (ourResult == 0) { if (inst::util::getIPAddress() == "1.0.0.127") { - inst::ui::mainApp->CreateShowDialog("main.net.title"_lang, "main.net.desc"_lang, { "common.ok"_lang }, true, "romfs:/images/icons/update.png"); + inst::ui::mainApp->CreateShowDialog("main.net.title"_lang, "main.net.desc"_lang, { "common.ok"_lang }, true, update); return; } if (!inst::util::copyFile("sdmc:/bootloader/patches.ini", inst::config::appDir + "/patches.ini.old")) { - if (inst::ui::mainApp->CreateShowDialog("sig.backup_failed"_lang, "sig.backup_failed_desc"_lang, { "common.yes"_lang, "common.no"_lang }, false, "romfs:/images/icons/fail.png")) return; + if (inst::ui::mainApp->CreateShowDialog("sig.backup_failed"_lang, "sig.backup_failed_desc"_lang, { "common.yes"_lang, "common.no"_lang }, false, fail)) return; } std::string ourPath = inst::config::appDir + "/patches.zip"; bool didDownload = inst::curl::downloadFile(inst::config::sigPatchesUrl, ourPath.c_str()); bool didExtract = false; if (didDownload) didExtract = inst::zip::extractFile(ourPath, "sdmc:/"); else { - inst::ui::mainApp->CreateShowDialog("sig.download_failed"_lang, "sig.download_failed_desc"_lang, { "common.ok"_lang }, true, "romfs:/images/icons/fail.png"); + inst::ui::mainApp->CreateShowDialog("sig.download_failed"_lang, "sig.download_failed_desc"_lang, { "common.ok"_lang }, true, fail); return; } std::filesystem::remove(ourPath); @@ -44,23 +62,23 @@ namespace sig { patchesVersion = inst::util::readTextFromFile("sdmc:/atmosphere/exefs_patches/es_patches/patches.txt"); versionText = ""; if (patchesVersion != "") versionText = "sig.version_text2"_lang + patchesVersion + "! "; - if (inst::ui::mainApp->CreateShowDialog("sig.install_complete"_lang, versionText + "\n\n" + "sig.complete_desc"_lang, { "sig.restart"_lang, "sig.later"_lang }, false, "romfs:/images/icons/good.png") == 0) bpcRebootSystem(); + if (inst::ui::mainApp->CreateShowDialog("sig.install_complete"_lang, versionText + "\n\n" + "sig.complete_desc"_lang, { "sig.restart"_lang, "sig.later"_lang }, false, good) == 0) bpcRebootSystem(); } else { - inst::ui::mainApp->CreateShowDialog("sig.extract_failed"_lang, "", { "common.ok"_lang }, true, "romfs:/images/icons/fail.png"); + inst::ui::mainApp->CreateShowDialog("sig.extract_failed"_lang, "", { "common.ok"_lang }, true, fail); return; } return; } else if (ourResult == 1) { if (!inst::util::copyFile(inst::config::appDir + "/patches.ini.old", "sdmc:/bootloader/patches.ini")) { - if (inst::ui::mainApp->CreateShowDialog("sig.restore_failed"_lang, "", { "common.yes"_lang, "common.no"_lang }, false, "romfs:/images/icons/fail.png")) return; + if (inst::ui::mainApp->CreateShowDialog("sig.restore_failed"_lang, "", { "common.yes"_lang, "common.no"_lang }, false, fail)) return; } else std::filesystem::remove(inst::config::appDir + "/patches.ini.old"); if (inst::util::removeDirectory("sdmc:/atmosphere/exefs_patches/es_patches")) { - if (inst::ui::mainApp->CreateShowDialog("sig.uninstall_complete"_lang, "sig.complete_desc"_lang, { "sig.restart"_lang, "sig.later"_lang }, false, "romfs:/images/icons/good.png") == 0) bpcRebootSystem(); + if (inst::ui::mainApp->CreateShowDialog("sig.uninstall_complete"_lang, "sig.complete_desc"_lang, { "sig.restart"_lang, "sig.later"_lang }, false, good) == 0) bpcRebootSystem(); } - else inst::ui::mainApp->CreateShowDialog("sig.remove_failed"_lang, "sig.remove_failed_desc"_lang, { "common.ok"_lang }, true, "romfs:/images/icons/fail.png"); + else inst::ui::mainApp->CreateShowDialog("sig.remove_failed"_lang, "sig.remove_failed_desc"_lang, { "common.ok"_lang }, true, fail); } else return; } @@ -69,7 +87,11 @@ namespace sig { LOG_DEBUG("Failed to install Signature Patches"); LOG_DEBUG("%s", e.what()); fprintf(stdout, "%s", e.what()); - inst::ui::mainApp->CreateShowDialog("sig.generic_error"_lang, (std::string)e.what(), { "common.ok"_lang }, true, "romfs:/images/icons/information.png"); + std::string fail = "romfs:/images/icons/fail.png"; + if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(inst::config::appDir + "icons_others.fail"_theme)) { + fail = inst::config::appDir + "icons_others.fail"_theme; + } + inst::ui::mainApp->CreateShowDialog("sig.generic_error"_lang, (std::string)e.what(), { "common.ok"_lang }, true, fail); } bpcExit(); } diff --git a/source/ui/HDInstPage.cpp b/source/ui/HDInstPage.cpp index 6e8f2bb..e90fa9d 100644 --- a/source/ui/HDInstPage.cpp +++ b/source/ui/HDInstPage.cpp @@ -15,6 +15,18 @@ namespace inst::ui { s32 zzz = 0; //touchscreen variable bool show_file_ext; + std::string checked_hdd = "romfs:/images/icons/check-box-outline.png"; + std::string unchecked_hdd = "romfs:/images/icons/checkbox-blank-outline.png"; + + void checkbox_hdd() { + if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(inst::config::appDir + "icons_others.checkbox-checked"_theme)) { + checked_hdd = inst::config::appDir + "icons_others.checkbox-checked"_theme; + } + if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(inst::config::appDir + "icons_others.checkbox-empty"_theme)) { + unchecked_hdd = inst::config::appDir + "icons_others.checkbox-empty"_theme; + } + } + HDInstPage::HDInstPage() : Layout::Layout() { std::string infoRect_colour = "colour.inforect"_theme; std::string bg_colour = "colour.background"_theme; @@ -72,6 +84,7 @@ namespace inst::ui { this->Add(this->butText); this->Add(this->pageInfoText); this->Add(this->menu); + checkbox_hdd(); } void HDInstPage::drawMenuItems(bool clearItems, std::filesystem::path ourPath) { @@ -137,10 +150,10 @@ namespace inst::ui { auto ourEntry = pu::ui::elm::MenuItem::New(itm); if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json")) ourEntry->SetColor(COLOR(text_colour)); else ourEntry->SetColor(COLOR("#FFFFFFFF")); - ourEntry->SetIcon("romfs:/images/icons/checkbox-blank-outline.png"); + ourEntry->SetIcon(unchecked_hdd); for (long unsigned int i = 0; i < this->selectedTitles.size(); i++) { if (this->selectedTitles[i] == file) { - ourEntry->SetIcon("romfs:/images/icons/check-box-outline.png"); + ourEntry->SetIcon(checked_hdd); } } this->menu->AddItem(ourEntry); @@ -170,12 +183,12 @@ namespace inst::ui { int dirListSize = this->ourDirectories.size(); dirListSize++; - if (this->menu->GetItems()[selectedIndex]->GetIconPath() == "romfs:/images/icons/check-box-outline.png") { + if (this->menu->GetItems()[selectedIndex]->GetIconPath() == checked_hdd) { for (long unsigned int i = 0; i < this->selectedTitles.size(); i++) { if (this->selectedTitles[i] == this->ourFiles[selectedIndex - dirListSize]) this->selectedTitles.erase(this->selectedTitles.begin() + i); } } - else if (this->menu->GetItems()[selectedIndex]->GetIconPath() == "romfs:/images/icons/checkbox-blank-outline.png") this->selectedTitles.push_back(this->ourFiles[selectedIndex - dirListSize]); + else if (this->menu->GetItems()[selectedIndex]->GetIconPath() == unchecked_hdd) this->selectedTitles.push_back(this->ourFiles[selectedIndex - dirListSize]); else { this->followDirectory(); return; @@ -226,7 +239,7 @@ namespace inst::ui { int topDir = 0; topDir++; for (long unsigned int i = this->ourDirectories.size() + topDir; i < this->menu->GetItems().size(); i++) { - if (this->menu->GetItems()[i]->GetIconPath() == "romfs:/images/icons/check-box-outline.png") continue; + if (this->menu->GetItems()[i]->GetIconPath() == checked_hdd) continue; else this->selectNsp(i); } this->drawMenuItems(false, currentDir); @@ -242,7 +255,7 @@ namespace inst::ui { } if (Down & HidNpadButton_Plus) { - if (this->selectedTitles.size() == 0 && this->menu->GetItems()[this->menu->GetSelectedIndex()]->GetIconPath() == "romfs:/images/icons/checkbox-blank-outline.png") { + if (this->selectedTitles.size() == 0 && this->menu->GetItems()[this->menu->GetSelectedIndex()]->GetIconPath() == unchecked_hdd) { this->selectNsp(this->menu->GetSelectedIndex()); } if (this->selectedTitles.size() > 0) this->startInstall(); diff --git a/source/ui/ThemeInstPage.cpp b/source/ui/ThemeInstPage.cpp index 30d110e..94765b4 100644 --- a/source/ui/ThemeInstPage.cpp +++ b/source/ui/ThemeInstPage.cpp @@ -23,6 +23,18 @@ namespace inst::ui { int myindex; int installing = 0; + std::string checked_theme = "romfs:/images/icons/check-box-outline.png"; + std::string unchecked_theme = "romfs:/images/icons/checkbox-blank-outline.png"; + + void checkbox_theme() { + if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(inst::config::appDir + "icons_others.checkbox-checked"_theme)) { + checked_theme = inst::config::appDir + "icons_others.checkbox-checked"_theme; + } + if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(inst::config::appDir + "icons_others.checkbox-empty"_theme)) { + unchecked_theme = inst::config::appDir + "icons_others.checkbox-empty"_theme; + } + } + std::string httplastUrl2 = "http://"; std::string lastFileID2 = ""; std::string sourceString2 = ""; @@ -102,33 +114,7 @@ namespace inst::ui { else this->installBar->SetProgressColor(COLOR("#565759FF")); this->Add(this->installBar); - } - - void ThemeInstPage::drawMenuItems_withext(bool clearItems) { - myindex = this->menu->GetSelectedIndex(); //store index so when page redraws we can get the last item we checked. - if (clearItems) this->selectedUrls = {}; - if (clearItems) this->alternativeNames = {}; - mainApp->ThemeinstPage->installBar->SetProgress(0); - mainApp->ThemeinstPage->installBar->SetVisible(false); - std::string itm; - std::string text_colour = "colour.main_text"_theme; - - this->menu->ClearItems(); - for (auto& urls : this->ourUrls) { - itm = inst::util::shortenString(inst::util::formatUrlString(urls), 56, true); - auto ourEntry = pu::ui::elm::MenuItem::New(itm); - if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json")) ourEntry->SetColor(COLOR(text_colour)); - else ourEntry->SetColor(COLOR("#FFFFFFFF")); - ourEntry->SetIcon("romfs:/images/icons/checkbox-blank-outline.png"); - long unsigned int i; - for (i = 0; i < this->selectedUrls.size(); i++) { - if (this->selectedUrls[i] == urls) { - ourEntry->SetIcon("romfs:/images/icons/check-box-outline.png"); - } - } - this->menu->AddItem(ourEntry); - this->menu->SetSelectedIndex(myindex); //jump to the index we saved from above - } + checkbox_theme(); } void ThemeInstPage::drawMenuItems(bool clearItems) { @@ -151,12 +137,12 @@ namespace inst::ui { auto ourEntry = pu::ui::elm::MenuItem::New(itm); if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json")) ourEntry->SetColor(COLOR(text_colour)); else ourEntry->SetColor(COLOR("#FFFFFFFF")); - ourEntry->SetIcon("romfs:/images/icons/checkbox-blank-outline.png"); + ourEntry->SetIcon(unchecked_theme); long unsigned int i; for (i = 0; i < this->selectedUrls.size(); i++) { if (this->selectedUrls[i] == urls) { - ourEntry->SetIcon("romfs:/images/icons/check-box-outline.png"); + ourEntry->SetIcon(checked_theme); } } this->menu->AddItem(ourEntry); @@ -316,7 +302,7 @@ namespace inst::ui { 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") { + if (this->menu->GetItems()[myindex]->GetIconPath() == checked_theme) { } this->selectedUrls.push_back(this->ourUrls[myindex]); this->drawMenuItems(false); @@ -350,17 +336,16 @@ namespace inst::ui { this->menu->SetSelectedIndex(std::min((s32)this->menu->GetItems().size() - 1, this->menu->GetSelectedIndex() + x)); } - //don't show file extensions + //refresh/redraw the items in the list if (Down & HidNpadButton_Left) { if (installing != 1) { this->drawMenuItems(true); } } - //show file extensions if (Down & HidNpadButton_Right) { if (installing != 1) { - this->drawMenuItems_withext(true); + this->drawMenuItems(true); } } } diff --git a/source/ui/netInstPage.cpp b/source/ui/netInstPage.cpp index 8ede66e..01d4795 100644 --- a/source/ui/netInstPage.cpp +++ b/source/ui/netInstPage.cpp @@ -16,6 +16,17 @@ namespace inst::ui { extern MainApplication* mainApp; s32 xxx = 0; + std::string checked_net = "romfs:/images/icons/check-box-outline.png"; + std::string unchecked_net = "romfs:/images/icons/checkbox-blank-outline.png"; + + void checkbox_net() { + if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(inst::config::appDir + "icons_others.checkbox-checked"_theme)) { + checked_net = inst::config::appDir + "icons_others.checkbox-checked"_theme; + } + if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(inst::config::appDir + "icons_others.checkbox-empty"_theme)) { + unchecked_net = inst::config::appDir + "icons_others.checkbox-empty"_theme; + } + } std::string httplastUrl = "http://"; std::string lastFileID = ""; @@ -86,6 +97,7 @@ namespace inst::ui { this->Add(this->pageInfoText); this->Add(this->menu); this->Add(this->infoImage); + checkbox_net(); } void netInstPage::drawMenuItems_withext(bool clearItems) { @@ -103,11 +115,11 @@ namespace inst::ui { if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json")) ourEntry->SetColor(COLOR(text_colour)); else ourEntry->SetColor(COLOR("#FFFFFFFF")); - ourEntry->SetIcon("romfs:/images/icons/checkbox-blank-outline.png"); + ourEntry->SetIcon(unchecked_net); long unsigned int i; for (i = 0; i < this->selectedUrls.size(); i++) { if (this->selectedUrls[i] == urls) { - ourEntry->SetIcon("romfs:/images/icons/check-box-outline.png"); + ourEntry->SetIcon(checked_net); } } this->menu->AddItem(ourEntry); @@ -155,11 +167,11 @@ namespace inst::ui { if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json")) ourEntry->SetColor(COLOR(text_colour)); else ourEntry->SetColor(COLOR("#FFFFFFFF")); - ourEntry->SetIcon("romfs:/images/icons/checkbox-blank-outline.png"); + ourEntry->SetIcon(unchecked_net); long unsigned int i; for (i = 0; i < this->selectedUrls.size(); i++) { if (this->selectedUrls[i] == urls) { - ourEntry->SetIcon("romfs:/images/icons/check-box-outline.png"); + ourEntry->SetIcon(checked_net); } } this->menu->AddItem(ourEntry); @@ -168,7 +180,7 @@ namespace inst::ui { } void netInstPage::selectTitle(int selectedIndex) { - if (this->menu->GetItems()[selectedIndex]->GetIconPath() == "romfs:/images/icons/check-box-outline.png") { + if (this->menu->GetItems()[selectedIndex]->GetIconPath() == checked_net) { for (long unsigned int i = 0; i < this->selectedUrls.size(); i++) { if (this->selectedUrls[i] == this->ourUrls[selectedIndex]) this->selectedUrls.erase(this->selectedUrls.begin() + i); } @@ -333,7 +345,7 @@ namespace inst::ui { if (this->selectedUrls.size() == this->menu->GetItems().size()) this->drawMenuItems(true); else { for (long unsigned int i = 0; i < this->menu->GetItems().size(); i++) { - if (this->menu->GetItems()[i]->GetIconPath() == "romfs:/images/icons/check-box-outline.png") continue; + if (this->menu->GetItems()[i]->GetIconPath() == checked_net) continue; else this->selectTitle(i); } this->drawMenuItems(false); diff --git a/source/ui/sdInstPage.cpp b/source/ui/sdInstPage.cpp index afd4edc..00edf4f 100644 --- a/source/ui/sdInstPage.cpp +++ b/source/ui/sdInstPage.cpp @@ -16,6 +16,17 @@ namespace inst::ui { extern MainApplication* mainApp; s32 yyy = 0; bool show_ext; + std::string checked = "romfs:/images/icons/check-box-outline.png"; + std::string unchecked = "romfs:/images/icons/checkbox-blank-outline.png"; + + void checkbox_sd() { + if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(inst::config::appDir + "icons_others.checkbox-checked"_theme)) { + checked = inst::config::appDir + "icons_others.checkbox-checked"_theme; + } + if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(inst::config::appDir + "icons_others.checkbox-empty"_theme)) { + unchecked = inst::config::appDir + "icons_others.checkbox-empty"_theme; + } + } sdInstPage::sdInstPage() : Layout::Layout() { std::string default_background = inst::config::appDir + "bg_images.default_background"_theme; @@ -75,6 +86,7 @@ namespace inst::ui { this->Add(this->butText); this->Add(this->pageInfoText); this->Add(this->menu); + checkbox_sd(); } void sdInstPage::drawMenuItems(bool clearItems, std::filesystem::path ourPath) { @@ -143,11 +155,11 @@ namespace inst::ui { if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json")) ourEntry->SetColor(COLOR(text_colour)); else ourEntry->SetColor(COLOR("#FFFFFFFF")); - ourEntry->SetIcon("romfs:/images/icons/checkbox-blank-outline.png"); + ourEntry->SetIcon(unchecked); for (long unsigned int i = 0; i < this->selectedTitles.size(); i++) { if (this->selectedTitles[i] == file) { - ourEntry->SetIcon("romfs:/images/icons/check-box-outline.png"); + ourEntry->SetIcon(checked); } } this->menu->AddItem(ourEntry); @@ -177,12 +189,12 @@ namespace inst::ui { int dirListSize = this->ourDirectories.size(); dirListSize++; - if (this->menu->GetItems()[selectedIndex]->GetIconPath() == "romfs:/images/icons/check-box-outline.png") { + if (this->menu->GetItems()[selectedIndex]->GetIconPath() == checked) { for (long unsigned int i = 0; i < this->selectedTitles.size(); i++) { if (this->selectedTitles[i] == this->ourFiles[selectedIndex - dirListSize]) this->selectedTitles.erase(this->selectedTitles.begin() + i); } } - else if (this->menu->GetItems()[selectedIndex]->GetIconPath() == "romfs:/images/icons/checkbox-blank-outline.png") this->selectedTitles.push_back(this->ourFiles[selectedIndex - dirListSize]); + else if (this->menu->GetItems()[selectedIndex]->GetIconPath() == unchecked) this->selectedTitles.push_back(this->ourFiles[selectedIndex - dirListSize]); else { this->followDirectory(); return; @@ -239,7 +251,7 @@ namespace inst::ui { int topDir = 0; topDir++; for (long unsigned int i = this->ourDirectories.size() + topDir; i < this->menu->GetItems().size(); i++) { - if (this->menu->GetItems()[i]->GetIconPath() == "romfs:/images/icons/check-box-outline.png") continue; + if (this->menu->GetItems()[i]->GetIconPath() == checked) continue; else this->selectNsp(i); } this->drawMenuItems(false, currentDir); @@ -259,7 +271,7 @@ namespace inst::ui { auto s = std::to_string(var); if (s != "0") { - if (this->selectedTitles.size() == 0 && this->menu->GetItems()[this->menu->GetSelectedIndex()]->GetIconPath() == "romfs:/images/icons/checkbox-blank-outline.png") { + if (this->selectedTitles.size() == 0 && this->menu->GetItems()[this->menu->GetSelectedIndex()]->GetIconPath() == unchecked) { this->selectNsp(this->menu->GetSelectedIndex()); } if (this->selectedTitles.size() > 0) this->startInstall(); diff --git a/source/ui/usbInstPage.cpp b/source/ui/usbInstPage.cpp index d823f9f..e8f202c 100644 --- a/source/ui/usbInstPage.cpp +++ b/source/ui/usbInstPage.cpp @@ -13,6 +13,18 @@ namespace inst::ui { extern MainApplication* mainApp; s32 www = 0; //touchscreen variable + std::string checked_usb = "romfs:/images/icons/check-box-outline.png"; + std::string unchecked_usb = "romfs:/images/icons/checkbox-blank-outline.png"; + + void checkbox_usb() { + if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(inst::config::appDir + "icons_others.checkbox-checked"_theme)) { + checked_usb = inst::config::appDir + "icons_others.checkbox-checked"_theme; + } + if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(inst::config::appDir + "icons_others.checkbox-empty"_theme)) { + unchecked_usb = inst::config::appDir + "icons_others.checkbox-empty"_theme; + } + } + usbInstPage::usbInstPage() : Layout::Layout() { std::string infoRect_colour = "colour.inforect"_theme; std::string bg_colour = "colour.background"_theme; @@ -78,6 +90,7 @@ namespace inst::ui { this->Add(this->pageInfoText); this->Add(this->menu); this->Add(this->infoImage); + checkbox_usb(); } void usbInstPage::drawMenuItems_withext(bool clearItems) { @@ -92,10 +105,10 @@ namespace inst::ui { if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json")) ourEntry->SetColor(COLOR(text_colour)); else ourEntry->SetColor(COLOR("#FFFFFFFF")); - ourEntry->SetIcon("romfs:/images/icons/checkbox-blank-outline.png"); + ourEntry->SetIcon(unchecked_usb); for (long unsigned int i = 0; i < this->selectedTitles.size(); i++) { if (this->selectedTitles[i] == url) { - ourEntry->SetIcon("romfs:/images/icons/check-box-outline.png"); + ourEntry->SetIcon(checked_usb); } } this->menu->AddItem(ourEntry); @@ -120,11 +133,11 @@ namespace inst::ui { if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json")) ourEntry->SetColor(COLOR(text_colour)); else ourEntry->SetColor(COLOR("#FFFFFFFF")); - ourEntry->SetIcon("romfs:/images/icons/checkbox-blank-outline.png"); + ourEntry->SetIcon(unchecked_usb); for (long unsigned int i = 0; i < this->selectedTitles.size(); i++) { if (this->selectedTitles[i] == url) { - ourEntry->SetIcon("romfs:/images/icons/check-box-outline.png"); + ourEntry->SetIcon(checked_usb); } } this->menu->AddItem(ourEntry); @@ -133,7 +146,7 @@ namespace inst::ui { } void usbInstPage::selectTitle(int selectedIndex) { - if (this->menu->GetItems()[selectedIndex]->GetIconPath() == "romfs:/images/icons/check-box-outline.png") { + if (this->menu->GetItems()[selectedIndex]->GetIconPath() == checked_usb) { for (long unsigned int i = 0; i < this->selectedTitles.size(); i++) { if (this->selectedTitles[i] == this->ourTitles[selectedIndex]) this->selectedTitles.erase(this->selectedTitles.begin() + i); } @@ -219,7 +232,7 @@ namespace inst::ui { if (this->selectedTitles.size() == this->menu->GetItems().size()) this->drawMenuItems(true); else { for (long unsigned int i = 0; i < this->menu->GetItems().size(); i++) { - if (this->menu->GetItems()[i]->GetIconPath() == "romfs:/images/icons/check-box-outline.png") continue; + if (this->menu->GetItems()[i]->GetIconPath() == checked_usb) continue; else this->selectTitle(i); } this->drawMenuItems(false); diff --git a/source/usbInstall.cpp b/source/usbInstall.cpp index 610e09e..22805a5 100644 --- a/source/usbInstall.cpp +++ b/source/usbInstall.cpp @@ -65,6 +65,10 @@ namespace usbInstStuff { padConfigureInput(8, HidNpadStyleSet_NpadStandard); PadState pad; padInitializeAny(&pad); + std::string info = "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)) { + info = inst::config::appDir + "icons_others.information"_theme; + } while (true) { if (bufferData(&header, sizeof(TUSHeader), 500000000) != 0) break; @@ -73,7 +77,7 @@ namespace usbInstStuff { u64 kDown = padGetButtonsDown(&pad); if (kDown & HidNpadButton_B) return {}; - if (kDown & HidNpadButton_X) inst::ui::mainApp->CreateShowDialog("inst.usb.help.title"_lang, "inst.usb.help.desc"_lang, { "common.ok"_lang }, true, "romfs:/images/icons/information.png"); + if (kDown & HidNpadButton_X) inst::ui::mainApp->CreateShowDialog("inst.usb.help.title"_lang, "inst.usb.help.desc"_lang, { "common.ok"_lang }, true, info); if (inst::util::getUsbState() != 5) return {}; } @@ -102,6 +106,15 @@ namespace usbInstStuff { bool nspInstalled = true; NcmStorageId m_destStorageId = NcmStorageId_SdCard; + std::string good = "romfs:/images/icons/good.png"; + if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(inst::config::appDir + "icons_others.good"_theme)) { + good = inst::config::appDir + "icons_others.good"_theme; + } + std::string fail = "romfs:/images/icons/fail.png"; + if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(inst::config::appDir + "icons_others.fail"_theme)) { + fail = inst::config::appDir + "icons_others.fail"_theme; + } + if (ourStorage) m_destStorageId = NcmStorageId_BuiltInUser; unsigned int fileItr; @@ -165,7 +178,7 @@ namespace usbInstStuff { audioThread.join(); } - inst::ui::mainApp->CreateShowDialog("inst.info_page.failed"_lang + fileNames[fileItr] + "!", "inst.info_page.failed_desc"_lang + "\n\n" + (std::string)e.what(), { "common.ok"_lang }, true, "romfs:/images/icons/fail.png"); + inst::ui::mainApp->CreateShowDialog("inst.info_page.failed"_lang + fileNames[fileItr] + "!", "inst.info_page.failed_desc"_lang + "\n\n" + (std::string)e.what(), { "common.ok"_lang }, true, fail); nspInstalled = false; } @@ -193,8 +206,8 @@ namespace usbInstStuff { audioThread.join(); } - if (ourTitleList.size() > 1) inst::ui::mainApp->CreateShowDialog(std::to_string(ourTitleList.size()) + "inst.info_page.desc0"_lang, Language::GetRandomMsg(), { "common.ok"_lang }, true, "romfs:/images/icons/good.png"); - else inst::ui::mainApp->CreateShowDialog(fileNames[0] + "inst.info_page.desc1"_lang, Language::GetRandomMsg(), { "common.ok"_lang }, true, "romfs:/images/icons/good.png"); + if (ourTitleList.size() > 1) inst::ui::mainApp->CreateShowDialog(std::to_string(ourTitleList.size()) + "inst.info_page.desc0"_lang, Language::GetRandomMsg(), { "common.ok"_lang }, true, good); + else inst::ui::mainApp->CreateShowDialog(fileNames[0] + "inst.info_page.desc1"_lang, Language::GetRandomMsg(), { "common.ok"_lang }, true, good); } LOG_DEBUG("Done");