2020-12-12 15:41:56 +00:00
|
|
|
#include "ams_tab.hpp"
|
2021-02-10 16:28:47 +00:00
|
|
|
#include <string>
|
|
|
|
#include "download.hpp"
|
|
|
|
#include "extract.hpp"
|
|
|
|
#include "confirm_page.hpp"
|
|
|
|
#include "dialogue_page.hpp"
|
|
|
|
#include "worker_page.hpp"
|
|
|
|
#include "utils.hpp"
|
2021-03-10 20:43:00 +00:00
|
|
|
#include "current_cfw.hpp"
|
2020-12-12 15:41:56 +00:00
|
|
|
|
|
|
|
namespace i18n = brls::i18n;
|
|
|
|
using namespace i18n::literals;
|
|
|
|
|
|
|
|
AmsTab::AmsTab() :
|
|
|
|
brls::List()
|
|
|
|
{
|
2021-02-08 20:30:58 +00:00
|
|
|
std::vector<std::pair<std::string, std::string>> links;
|
2021-03-10 20:43:00 +00:00
|
|
|
std::string operation("menus/main/getting"_i18n);
|
2021-03-16 02:04:21 +00:00
|
|
|
this->description = new brls::Label(brls::LabelStyle::DESCRIPTION, "menus/main/ams_text"_i18n + (CurrentCfw::running_cfw == CFW::ams ? "\n" + "menus/ams_update/current_ams"_i18n + CurrentCfw::getAmsInfo() : ""), true);
|
2021-03-14 15:24:56 +00:00
|
|
|
this->addView(description);
|
2021-03-11 18:05:45 +00:00
|
|
|
operation += "menus/main/ams"_i18n;
|
2021-03-16 02:04:21 +00:00
|
|
|
links = download::getLinks(AMS_URL);
|
2020-12-12 15:41:56 +00:00
|
|
|
|
2021-03-16 14:56:46 +00:00
|
|
|
if(links.size()){
|
2021-03-16 02:04:21 +00:00
|
|
|
auto hekate_link = download::getLinks(HEKATE_URL);
|
2021-02-10 02:57:42 +00:00
|
|
|
std::string hekate_url = hekate_link[0].second;
|
2021-03-10 20:43:00 +00:00
|
|
|
std::string text_hekate = "menus/common/download"_i18n + hekate_link[0].first;
|
2020-12-13 13:52:51 +00:00
|
|
|
|
2021-03-16 14:56:46 +00:00
|
|
|
for (const auto& link : links){
|
|
|
|
std::string url = link.second;
|
|
|
|
std::string text("menus/common/download"_i18n + link.first + "menus/common/from"_i18n + url);
|
|
|
|
listItem = new brls::ListItem(link.first);
|
2021-02-06 17:24:47 +00:00
|
|
|
listItem->setHeight(LISTITEM_HEIGHT);
|
|
|
|
listItem->getClickEvent()->subscribe([&, text, text_hekate, url, hekate_url, operation](brls::View* view) {
|
2020-12-12 15:41:56 +00:00
|
|
|
brls::StagedAppletFrame* stagedFrame = new brls::StagedAppletFrame();
|
|
|
|
stagedFrame->setTitle(operation);
|
|
|
|
stagedFrame->addStage(
|
|
|
|
new ConfirmPage(stagedFrame, text)
|
|
|
|
);
|
|
|
|
stagedFrame->addStage(
|
2021-03-16 02:04:21 +00:00
|
|
|
new WorkerPage(stagedFrame, "menus/common/downloading"_i18n, [url](){util::downloadArchive(url, archiveType::ams_cfw);})
|
2020-12-12 15:41:56 +00:00
|
|
|
);
|
|
|
|
stagedFrame->addStage(
|
2021-03-16 02:04:21 +00:00
|
|
|
new WorkerPage(stagedFrame, "menus/common/extracting"_i18n, [](){util::extractArchive(archiveType::ams_cfw);})
|
2020-12-12 15:41:56 +00:00
|
|
|
);
|
|
|
|
stagedFrame->addStage(
|
|
|
|
new DialoguePage(stagedFrame, text_hekate)
|
|
|
|
);
|
|
|
|
stagedFrame->addStage(
|
2021-03-16 02:04:21 +00:00
|
|
|
new WorkerPage(stagedFrame, "menus/common/downloading"_i18n, [hekate_url](){util::downloadArchive(hekate_url, archiveType::cfw);})
|
2020-12-12 15:41:56 +00:00
|
|
|
);
|
|
|
|
stagedFrame->addStage(
|
2021-03-16 02:04:21 +00:00
|
|
|
new WorkerPage(stagedFrame, "menus/common/extracting"_i18n, [](){util::extractArchive(archiveType::cfw);})
|
2020-12-12 15:41:56 +00:00
|
|
|
);
|
|
|
|
stagedFrame->addStage(
|
2021-03-10 20:43:00 +00:00
|
|
|
new ConfirmPage(stagedFrame, "menus/ams_update/reboot_rcm"_i18n, false, true)
|
2020-12-12 15:41:56 +00:00
|
|
|
);
|
|
|
|
brls::Application::pushView(stagedFrame);
|
|
|
|
});
|
2021-02-06 17:24:47 +00:00
|
|
|
this->addView(listItem);
|
2020-12-12 15:41:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
notFound = new brls::Label(
|
|
|
|
brls::LabelStyle::DESCRIPTION,
|
2021-03-10 20:43:00 +00:00
|
|
|
"menus/main/links_not_found"_i18n,
|
2020-12-12 15:41:56 +00:00
|
|
|
true
|
|
|
|
);
|
|
|
|
notFound->setHorizontalAlign(NVG_ALIGN_CENTER);
|
|
|
|
this->addView(notFound);
|
|
|
|
}
|
2021-03-02 14:05:06 +00:00
|
|
|
}
|