2020-09-20 01:21:28 +01:00
|
|
|
#include "list_download_tab.hpp"
|
|
|
|
|
|
|
|
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-09-20 01:21:28 +01:00
|
|
|
std::string operation = "Getting ";
|
2020-09-23 23:12:46 +01:00
|
|
|
std::string firmwareText("\uE016 Firmware dumps from 'https://darthsternie.net/switch-firmwares/'. "\
|
|
|
|
"Once downloaded, it will be extracted in '/firmware'. You can then install the update through Daybreak or ChoiDuJour.\n"\
|
2020-09-22 22:12:05 +01:00
|
|
|
"\uE016 Current FW: "
|
|
|
|
);
|
|
|
|
SetSysFirmwareVersion ver;
|
|
|
|
if (R_SUCCEEDED(setsysGetFirmwareVersion(&ver))) firmwareText += ver.display_version;
|
|
|
|
else firmwareText += "not found";
|
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 += "sigpatches";
|
|
|
|
this->description->setText(
|
|
|
|
"\uE016 Sigpatches allow your Switch to install and run unofficial NSP file. " \
|
|
|
|
"Make sure you pick the correct sigpatches for your setup (pure Atmosphere or Hekate+Atmosphere)."
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
case fw:
|
|
|
|
links = fetchLinks(FIRMWARE_URL);
|
|
|
|
operation += "firmware";
|
2020-09-22 22:12:05 +01:00
|
|
|
this->description->setText(firmwareText);
|
2020-09-20 01:21:28 +01:00
|
|
|
break;
|
|
|
|
case app:
|
|
|
|
std::get<0>(links).push_back("Latest version");
|
|
|
|
std::get<1>(links).push_back(APP_URL);
|
|
|
|
operation += "app";
|
|
|
|
break;
|
|
|
|
case cfw:
|
|
|
|
links = fetchLinks(CFW_URL);
|
|
|
|
operation += "CFW";
|
|
|
|
this->description->setText(
|
2020-09-23 23:12:46 +01:00
|
|
|
"\uE016 Main Switch CFWs. If you want to use Atmosphere with Hekate, download Atmosphere, then Hekate."
|
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("Latest (ver " + cheatsVer + ")");
|
|
|
|
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 += "cheats";
|
|
|
|
this->description->setText(
|
2020-09-23 23:12:46 +01:00
|
|
|
"\uE016 This will download a daily updated archive of cheat codes from 'gbatemp.net'. "\
|
2020-09-20 01:21:28 +01:00
|
|
|
"Cheat codes for games you don't have installed won't be extracted to your SD card. "\
|
2020-09-26 15:55:24 +01:00
|
|
|
"You can turn off cheat updated in 'Tools->Cheat menu'."
|
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];
|
|
|
|
std::string text("Downloading:\n" + std::get<0>(links)[i] + "\n\nFrom:\n" + url);
|
|
|
|
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, "Downloading...", [url, type](){downloadArchive(url, type);})
|
|
|
|
);
|
|
|
|
stagedFrame->addStage(
|
|
|
|
new WorkerPage(stagedFrame, "Extracting...", [type](){extractArchive(type);})
|
|
|
|
);
|
|
|
|
stagedFrame->addStage(
|
|
|
|
new ConfirmPage(stagedFrame, "All done!", true)
|
|
|
|
);
|
|
|
|
brls::Application::pushView(stagedFrame);
|
|
|
|
});
|
|
|
|
this->addView(linkItems[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
notFound = new brls::Label(
|
2020-09-21 19:36:46 +01:00
|
|
|
brls::LabelStyle::DESCRIPTION,
|
|
|
|
"Could not find a download link, make sure the Switch has access to the internet.\n"\
|
2020-09-23 23:12:46 +01:00
|
|
|
"If this problem persists, please open an issue on Github.",
|
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(){
|
|
|
|
|
|
|
|
}
|