1
0
Fork 0
mirror of https://github.com/HamletDuFromage/aio-switch-updater.git synced 2024-11-08 19:41:49 +00:00
AIO-switch-updater/source/list_download_tab.cpp

110 lines
4 KiB
C++
Raw Normal View History

2020-09-20 01:21:28 +01:00
#include "list_download_tab.hpp"
#include "lang.hpp"
using namespace lang::literals;
2020-09-20 01:21:28 +01:00
ListDownloadTab::ListDownloadTab(archiveType type) :
brls::List()
{
std::tuple<std::vector<std::string>, std::vector<std::string>> links;
std::string operation = "Getting"_lang;
std::string firmwareText("firmware_text"_lang
);
std::string currentCheatsVer =
"currentCeatsver"_lang;
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);
operation += "operation_1"_lang;
2020-09-20 01:21:28 +01:00
this->description->setText(
"list_sigpatches"_lang
2020-09-20 01:21:28 +01:00
);
break;
case fw:
links = fetchLinks(FIRMWARE_URL);
operation += "operation_2"_lang;
SetSysFirmwareVersion ver;
if (R_SUCCEEDED(setsysGetFirmwareVersion(&ver))) firmwareText += ver.display_version;
else firmwareText += "list_not"_lang;
this->description->setText(firmwareText);
2020-09-20 01:21:28 +01:00
break;
case app:
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);
operation += "list_app"_lang;
2020-09-20 01:21:28 +01:00
break;
case cfw:
links = fetchLinks(CFW_URL);
operation += "list_cfw"_lang;
2020-09-20 01:21:28 +01:00
this->description->setText(
"list_main"_lang
2020-09-20 01:21:28 +01:00
);
break;
case cheats:
std::string cheatsVer = fetchTitle(CHEATS_RELEASE_URL);
if(cheatsVer != "-1"){
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;
}
}
operation += "list_cheats"_lang;
currentCheatsVer += readVersion(CHEATS_VERSION);
this->description->setText(currentCheatsVer);
2020-09-20 01:21:28 +01:00
break;
}
/* 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];
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(
new WorkerPage(stagedFrame, "list_downing"_lang, [url, type](){downloadArchive(url, type);})
2020-09-20 01:21:28 +01:00
);
stagedFrame->addStage(
new WorkerPage(stagedFrame, "list_extracting"_lang, [type](){extractArchive(type);})
2020-09-20 01:21:28 +01:00
);
stagedFrame->addStage(
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(
brls::LabelStyle::DESCRIPTION,
2020-10-05 02:43:47 +01:00
"list_could_done"_lang,
true
);
notFound->setHorizontalAlign(NVG_ALIGN_CENTER);
this->addView(notFound);
2020-09-20 01:21:28 +01:00
}
}
ListDownloadTab::~ListDownloadTab(){
}