2020-09-20 01:21:28 +01:00
|
|
|
#include "payload_page.hpp"
|
|
|
|
|
|
|
|
PayloadPage::PayloadPage() : AppletFrame(true, true)
|
|
|
|
{
|
2020-09-23 12:21:05 +01:00
|
|
|
CFW cfw = getCFW();
|
2020-09-20 01:21:28 +01:00
|
|
|
this->setTitle("Reboot menu");
|
|
|
|
list = new brls::List();
|
|
|
|
label = new brls::Label(
|
|
|
|
brls::LabelStyle::DESCRIPTION,
|
2020-09-20 21:58:40 +01:00
|
|
|
"Select a payload to reboot to.",
|
2020-09-20 01:21:28 +01:00
|
|
|
true
|
|
|
|
);
|
|
|
|
list->addView(label);
|
|
|
|
std::vector<std::string> payloads = fetchPayloads();
|
|
|
|
int nbPayloads = payloads.size();
|
|
|
|
items.reserve(nbPayloads);
|
|
|
|
for (int i = 0; i < nbPayloads; i++){
|
|
|
|
std::string payload = payloads[i];
|
|
|
|
items[i] = new brls::ListItem(payload);
|
|
|
|
items[i]->getClickEvent()->subscribe([&, payload](brls::View* view) {
|
|
|
|
reboot_to_payload(payload.c_str());
|
|
|
|
brls::Application::popView();
|
|
|
|
});
|
2020-09-23 12:21:05 +01:00
|
|
|
if(cfw == ams){
|
|
|
|
items[i]->registerAction("Set as reboot_payload.bin", brls::Key::X, [this, payload] {
|
|
|
|
if(R_SUCCEEDED(CopyFile(payload.c_str(), REBOOT_PAYLOAD_PATH))){
|
|
|
|
brls::Dialog* dialog = new brls::Dialog("Successfully copied '" + payload + "' to '" + std::string(REBOOT_PAYLOAD_PATH) + "'.");
|
|
|
|
brls::GenericEvent::Callback callback = [dialog](brls::View* view) {
|
|
|
|
dialog->close();
|
|
|
|
};
|
|
|
|
dialog->addButton("Ok", callback);
|
|
|
|
dialog->setCancelable(true);
|
|
|
|
dialog->open();
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
}
|
2020-09-20 01:21:28 +01:00
|
|
|
list->addView(items[i]);
|
2020-09-23 12:21:05 +01:00
|
|
|
|
2020-09-20 01:21:28 +01:00
|
|
|
}
|
|
|
|
list->addView(new brls::ListItemGroupSpacing(true));
|
|
|
|
|
|
|
|
shutDown = new brls::ListItem("Shut Down");
|
|
|
|
shutDown->getClickEvent()->subscribe([](brls::View* view) {
|
|
|
|
shut_down(false);
|
|
|
|
brls::Application::popView();
|
|
|
|
});
|
|
|
|
list->addView(shutDown);
|
|
|
|
|
|
|
|
reboot = new brls::ListItem("Reboot");
|
|
|
|
reboot->getClickEvent()->subscribe([](brls::View* view) {
|
|
|
|
shut_down(true);
|
|
|
|
brls::Application::popView();
|
|
|
|
});
|
|
|
|
list->addView(reboot);
|
2020-09-23 12:21:05 +01:00
|
|
|
|
2020-09-20 01:21:28 +01:00
|
|
|
this->setContentView(list);
|
|
|
|
|
|
|
|
}
|