1
0
Fork 0
mirror of https://github.com/HamletDuFromage/aio-switch-updater.git synced 2024-09-19 21:45:04 +01:00
AIO-switch-updater/source/list_download_tab.cpp

113 lines
4.2 KiB
C++
Raw Normal View History

2020-09-20 01:21:28 +01:00
#include "list_download_tab.hpp"
namespace i18n = brls::i18n;
using namespace i18n::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 = "menus/Getting"_i18n ;
std::string firmwareText("menus/firmware_text"_i18n
);
std::string currentCheatsVer =
"menus/currentCeatsver"_i18n ;
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 += "menus/operation_1"_i18n ;
2020-09-20 01:21:28 +01:00
this->description->setText(
"menus/list_sigpatches"_i18n
2020-09-20 01:21:28 +01:00
);
break;
case fw:
links = fetchLinks(FIRMWARE_URL);
operation += "menus/operation_2"_i18n ;
SetSysFirmwareVersion ver;
if (R_SUCCEEDED(setsysGetFirmwareVersion(&ver))) firmwareText += ver.display_version;
else firmwareText += "menus/list_not"_i18n ;
this->description->setText(firmwareText);
2020-09-20 01:21:28 +01:00
break;
case app:
std::get<0>(links).push_back("menus/list_latest"_i18n );
2020-09-20 01:21:28 +01:00
std::get<1>(links).push_back(APP_URL);
operation += "menus/list_app"_i18n ;
2020-09-20 01:21:28 +01:00
break;
case cfw:
links = fetchLinks(CFW_URL);
operation += "menus/list_cfw"_i18n ;
2020-09-20 01:21:28 +01:00
this->description->setText(
"menus/list_main"_i18n
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("menus/list_latest_ver"_i18n + 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 += "menus/list_cheats"_i18n ;
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("menus/list_down"_i18n + std::get<0>(links)[i] + "menus/list_from"_i18n + url);
2020-09-20 01:21:28 +01:00
linkItems[i] = new brls::ListItem(std::get<0>(links)[i]);
2020-10-05 16:14:10 +01:00
linkItems[i]->setHeight(LISTITEM_HEIGHT);
2020-09-20 01:21:28 +01:00
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, "menus/list_downing"_i18n , [url, type](){downloadArchive(url, type);})
2020-09-20 01:21:28 +01:00
);
stagedFrame->addStage(
new WorkerPage(stagedFrame, "menus/list_extracting"_i18n , [type](){extractArchive(type);})
2020-09-20 01:21:28 +01:00
);
stagedFrame->addStage(
new ConfirmPage(stagedFrame, "menus/list_All"_i18n , 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,
"menus/list_could_done"_i18n ,
true
);
notFound->setHorizontalAlign(NVG_ALIGN_CENTER);
this->addView(notFound);
2020-09-20 01:21:28 +01:00
}
}
ListDownloadTab::~ListDownloadTab(){
}