2020-09-20 01:21:28 +01:00
|
|
|
#include "app_page.hpp"
|
2020-10-05 23:53:12 +01:00
|
|
|
|
|
|
|
namespace i18n = brls::i18n;
|
|
|
|
using namespace i18n::literals;
|
2021-02-06 17:24:47 +00:00
|
|
|
AppPage::AppPage(bool cheatSlips) : AppletFrame(true, true)
|
2020-09-20 01:21:28 +01:00
|
|
|
{
|
2020-10-05 23:53:12 +01:00
|
|
|
this->setTitle("menus/app_title"_i18n );
|
2020-09-20 01:21:28 +01:00
|
|
|
list = new brls::List();
|
|
|
|
label = new brls::Label(
|
|
|
|
brls::LabelStyle::DESCRIPTION,
|
2021-02-06 17:24:47 +00:00
|
|
|
cheatSlips ? "menus/app_cheatslips_label"_i18n : "menus/app_label"_i18n,
|
2020-09-20 01:21:28 +01:00
|
|
|
true
|
|
|
|
);
|
|
|
|
list->addView(label);
|
|
|
|
|
|
|
|
NsApplicationRecord record;
|
|
|
|
uint64_t tid;
|
|
|
|
NsApplicationControlData controlData;
|
|
|
|
NacpLanguageEntry* langEntry = NULL;
|
|
|
|
|
|
|
|
Result rc;
|
|
|
|
size_t i = 0;
|
|
|
|
int recordCount = 0;
|
|
|
|
size_t controlSize = 0;
|
|
|
|
|
|
|
|
titles = readLineByLine(UPDATED_TITLES_PATH);
|
|
|
|
|
2021-02-06 17:24:47 +00:00
|
|
|
if(!titles.empty() || cheatSlips){
|
2020-09-20 01:21:28 +01:00
|
|
|
while (true)
|
|
|
|
{
|
|
|
|
rc = nsListApplicationRecord(&record, sizeof(record), i, &recordCount);
|
|
|
|
if (R_FAILED(rc)) break;
|
2021-02-06 17:24:47 +00:00
|
|
|
if(recordCount <= 0) break;
|
2020-09-20 01:21:28 +01:00
|
|
|
|
|
|
|
tid = record.application_id;
|
|
|
|
rc = nsGetApplicationControlData(NsApplicationControlSource_Storage, tid, &controlData, sizeof(controlData), &controlSize);
|
|
|
|
if (R_FAILED(rc)) break;
|
|
|
|
rc = nacpGetLanguageEntry(&controlData.nacp, &langEntry);
|
|
|
|
if (R_FAILED(rc)) break;
|
2021-02-06 17:24:47 +00:00
|
|
|
|
|
|
|
if (!langEntry->name) {
|
|
|
|
i++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if(!cheatSlips && titles.find(formatApplicationId(tid)) == titles.end()) {
|
2020-09-20 01:21:28 +01:00
|
|
|
i++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2021-02-06 17:24:47 +00:00
|
|
|
listItem = new brls::ListItem(formatListItemTitle(std::string(langEntry->name)), "", formatApplicationId(tid));
|
|
|
|
listItem->setThumbnail(controlData.icon, sizeof(controlData.icon));
|
|
|
|
if(cheatSlips){
|
|
|
|
listItem->getClickEvent()->subscribe([&, tid](brls::View* view) {
|
|
|
|
brls::Application::pushView(new DownloadCheatsPage(tid));
|
|
|
|
});
|
|
|
|
}
|
2020-09-20 01:21:28 +01:00
|
|
|
|
|
|
|
list->addView(listItem);
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
2021-02-06 17:24:47 +00:00
|
|
|
std::string text("menus/text_download"_i18n);
|
2020-09-20 01:21:28 +01:00
|
|
|
std::string url = "";
|
|
|
|
switch(getCFW()){
|
|
|
|
case ams:
|
|
|
|
url += CHEATS_URL_CONTENTS;
|
|
|
|
break;
|
|
|
|
case rnx:
|
|
|
|
url += CHEATS_URL_CONTENTS;
|
|
|
|
break;
|
|
|
|
case sxos:
|
|
|
|
url += CHEATS_URL_CONTENTS;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
text += url;
|
2020-10-05 23:53:12 +01:00
|
|
|
download = new brls::ListItem("menus/text_download_list"_i18n );
|
2020-09-20 01:21:28 +01:00
|
|
|
archiveType type = cheats;
|
|
|
|
download->getClickEvent()->subscribe([&, url, text, type](brls::View* view) {
|
|
|
|
brls::StagedAppletFrame* stagedFrame = new brls::StagedAppletFrame();
|
2020-10-05 23:53:12 +01:00
|
|
|
stagedFrame->setTitle("menus/text_title"_i18n );
|
2020-09-20 01:21:28 +01:00
|
|
|
stagedFrame->addStage(
|
|
|
|
new ConfirmPage(stagedFrame, text)
|
|
|
|
);
|
|
|
|
stagedFrame->addStage(
|
2020-10-05 23:53:12 +01:00
|
|
|
new WorkerPage(stagedFrame, "menus/Downloading"_i18n , [url, type](){downloadArchive(url, type);})
|
2020-09-20 01:21:28 +01:00
|
|
|
);
|
|
|
|
stagedFrame->addStage(
|
2020-10-05 23:53:12 +01:00
|
|
|
new WorkerPage(stagedFrame, "menus/Extracting"_i18n , [type](){extractArchive(type);})
|
2020-09-20 01:21:28 +01:00
|
|
|
);
|
|
|
|
stagedFrame->addStage(
|
2020-10-05 23:53:12 +01:00
|
|
|
new ConfirmPage(stagedFrame, "menus/All_done"_i18n , true)
|
2020-09-20 01:21:28 +01:00
|
|
|
);
|
|
|
|
brls::Application::pushView(stagedFrame);
|
|
|
|
});
|
|
|
|
list->addView(download);
|
|
|
|
this->setContentView(list);
|
|
|
|
}
|