2020-09-20 01:21:28 +01:00
|
|
|
#include "list_download_tab.hpp"
|
2020-10-05 01:59:46 +01:00
|
|
|
#include "lang.hpp"
|
|
|
|
using namespace lang::literals;
|
2020-09-20 01:21:28 +01:00
|
|
|
ListDownloadTab::ListDownloadTab(archiveType type) :
|
|
|
|
brls::List()
|
|
|
|
{
|
2020-09-21 19:36:46 +01:00
|
|
|
std::tuple<std::vector<std::string>, std::vector<std::string>> links;
|
2020-10-05 01:59:46 +01:00
|
|
|
std::string operation = "Getting"_lang;
|
|
|
|
std::string firmwareText("firmware_text"_lang
|
2020-09-22 22:12:05 +01:00
|
|
|
);
|
2020-09-29 15:41:43 +01:00
|
|
|
|
|
|
|
std::string currentCheatsVer =
|
2020-10-05 01:59:46 +01:00
|
|
|
"currentCeatsver"_lang;
|
2020-09-29 15:41:43 +01:00
|
|
|
|
2020-09-20 01:21:28 +01:00
|
|
|
this->description = new brls::Label(brls::LabelStyle::DESCRIPTION, "", true);
|
|
|
|
switch(type){
|
|
|
|
case sigpatches:
|
|
|
|
links = fetchLinks(SIGPATCHES_URL);
|
2020-10-05 01:59:46 +01:00
|
|
|
operation += "operation_1"_lang;
|
2020-09-20 01:21:28 +01:00
|
|
|
this->description->setText(
|
2020-10-05 01:59:46 +01:00
|
|
|
"list_sigpatches"_lang
|
2020-09-20 01:21:28 +01:00
|
|
|
);
|
|
|
|
break;
|
|
|
|
case fw:
|
|
|
|
links = fetchLinks(FIRMWARE_URL);
|
2020-10-05 01:59:46 +01:00
|
|
|
operation += "operation_2"_lang;
|
2020-09-29 15:41:43 +01:00
|
|
|
SetSysFirmwareVersion ver;
|
|
|
|
if (R_SUCCEEDED(setsysGetFirmwareVersion(&ver))) firmwareText += ver.display_version;
|
2020-10-05 01:59:46 +01:00
|
|
|
else firmwareText += "list_not"_lang;
|
2020-09-22 22:12:05 +01:00
|
|
|
this->description->setText(firmwareText);
|
2020-09-20 01:21:28 +01:00
|
|
|
break;
|
|
|
|
case app:
|
2020-10-05 01:59:46 +01:00
|
|
|
std::get<0>(links).push_back("list_latest"_lang);
|
2020-09-20 01:21:28 +01:00
|
|
|
std::get<1>(links).push_back(APP_URL);
|
2020-10-05 01:59:46 +01:00
|
|
|
operation += "list_app"_lang;
|
2020-09-20 01:21:28 +01:00
|
|
|
break;
|
|
|
|
case cfw:
|
|
|
|
links = fetchLinks(CFW_URL);
|
2020-10-05 01:59:46 +01:00
|
|
|
operation += "list_cfw"_lang;
|
2020-09-20 01:21:28 +01:00
|
|
|
this->description->setText(
|
2020-10-05 01:59:46 +01:00
|
|
|
"list_main"_lang
|
2020-09-20 01:21:28 +01:00
|
|
|
);
|
|
|
|
break;
|
|
|
|
case cheats:
|
|
|
|
std::string cheatsVer = fetchTitle(CHEATS_RELEASE_URL);
|
|
|
|
if(cheatsVer != "-1"){
|
2020-10-05 01:59:46 +01:00
|
|
|
std::get<0>(links).push_back("list_latest_ver"_lang + cheatsVer + ")");
|
2020-09-20 01:21:28 +01:00
|
|
|
switch(getCFW()){
|
|
|
|
case sxos:
|
|
|
|
std::get<1>(links).push_back(CHEATS_URL_TITLES);
|
|
|
|
break;
|
|
|
|
case ams:
|
|
|
|
std::get<1>(links).push_back(CHEATS_URL_CONTENTS);
|
|
|
|
break;
|
|
|
|
case rnx:
|
|
|
|
std::get<1>(links).push_back(CHEATS_URL_CONTENTS);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2020-10-05 01:59:46 +01:00
|
|
|
operation += "list_cheats"_lang;
|
2020-09-29 15:41:43 +01:00
|
|
|
currentCheatsVer += readVersion(CHEATS_VERSION);
|
|
|
|
this->description->setText(currentCheatsVer);
|
2020-09-20 01:21:28 +01:00
|
|
|
break;
|
|
|
|
}
|
2020-09-23 12:21:05 +01:00
|
|
|
/* std::get<0>(links).push_back("Test");
|
|
|
|
std::get<1>(links).push_back("https://github.com"); */
|
2020-09-20 01:21:28 +01:00
|
|
|
this->addView(description);
|
|
|
|
|
|
|
|
int nbLinks = std::get<0>(links).size();
|
|
|
|
if(nbLinks){
|
|
|
|
linkItems.reserve(nbLinks);
|
|
|
|
for (int i = 0; i<nbLinks; i++){
|
|
|
|
std::string url = std::get<1>(links)[i];
|
2020-10-05 01:59:46 +01:00
|
|
|
std::string text("list_down"_lang + std::get<0>(links)[i] + "list_from"_lang + url);
|
2020-09-20 01:21:28 +01:00
|
|
|
linkItems[i] = new brls::ListItem(std::get<0>(links)[i]);
|
|
|
|
linkItems[i]->getClickEvent()->subscribe([&, text, url, type, operation](brls::View* view) {
|
|
|
|
brls::StagedAppletFrame* stagedFrame = new brls::StagedAppletFrame();
|
|
|
|
stagedFrame->setTitle(operation);
|
|
|
|
stagedFrame->addStage(
|
|
|
|
new ConfirmPage(stagedFrame, text)
|
|
|
|
);
|
|
|
|
stagedFrame->addStage(
|
2020-10-05 01:59:46 +01:00
|
|
|
new WorkerPage(stagedFrame, "list_downing"_lang, [url, type](){downloadArchive(url, type);})
|
2020-09-20 01:21:28 +01:00
|
|
|
);
|
|
|
|
stagedFrame->addStage(
|
2020-10-05 01:59:46 +01:00
|
|
|
new WorkerPage(stagedFrame, "list_extracting"_lang, [type](){extractArchive(type);})
|
2020-09-20 01:21:28 +01:00
|
|
|
);
|
|
|
|
stagedFrame->addStage(
|
2020-10-05 01:59:46 +01:00
|
|
|
new ConfirmPage(stagedFrame, "list_All"_lang, true)
|
2020-09-20 01:21:28 +01:00
|
|
|
);
|
|
|
|
brls::Application::pushView(stagedFrame);
|
|
|
|
});
|
|
|
|
this->addView(linkItems[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
notFound = new brls::Label(
|
2020-09-21 19:36:46 +01:00
|
|
|
brls::LabelStyle::DESCRIPTION,
|
2020-10-05 02:43:47 +01:00
|
|
|
"list_could_done"_lang,
|
2020-09-21 19:36:46 +01:00
|
|
|
true
|
|
|
|
);
|
|
|
|
notFound->setHorizontalAlign(NVG_ALIGN_CENTER);
|
|
|
|
this->addView(notFound);
|
2020-09-20 01:21:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ListDownloadTab::~ListDownloadTab(){
|
|
|
|
|
|
|
|
}
|