mirror of
https://github.com/HamletDuFromage/aio-switch-updater.git
synced 2024-11-08 11:31:43 +00:00
chainload the forwarder in a more sensible way, refactor
This commit is contained in:
parent
2edf92b5e8
commit
f77c64c3ee
11 changed files with 76 additions and 47 deletions
|
@ -5,19 +5,35 @@
|
||||||
|
|
||||||
class ConfirmPage : public brls::View
|
class ConfirmPage : public brls::View
|
||||||
{
|
{
|
||||||
private:
|
protected:
|
||||||
brls::Button* button = nullptr;
|
brls::Button* button = nullptr;
|
||||||
brls::Label* label = nullptr;
|
brls::Label* label = nullptr;
|
||||||
std::chrono::system_clock::time_point start = std::chrono::high_resolution_clock::now();
|
std::chrono::system_clock::time_point start = std::chrono::high_resolution_clock::now();
|
||||||
bool done = false;
|
bool done = false;
|
||||||
bool reboot = false;
|
|
||||||
bool erista = true;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ConfirmPage(brls::StagedAppletFrame* frame, const std::string& text, bool done = false, bool reboot = false, bool erista = true);
|
ConfirmPage(brls::StagedAppletFrame* frame, const std::string& text);
|
||||||
~ConfirmPage();
|
~ConfirmPage();
|
||||||
|
|
||||||
void draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, brls::Style* style, brls::FrameContext* ctx) override;
|
void draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, brls::Style* style, brls::FrameContext* ctx) override;
|
||||||
void layout(NVGcontext* vg, brls::Style* style, brls::FontStash* stash) override;
|
void layout(NVGcontext* vg, brls::Style* style, brls::FontStash* stash) override;
|
||||||
brls::View* getDefaultFocus() override;
|
brls::View* getDefaultFocus() override;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ConfirmPage_Done : public ConfirmPage
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ConfirmPage_Done(brls::StagedAppletFrame* frame, const std::string& text);
|
||||||
|
};
|
||||||
|
|
||||||
|
class ConfirmPage_AppUpdate : public ConfirmPage_Done
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ConfirmPage_AppUpdate(brls::StagedAppletFrame* frame, const std::string& text);
|
||||||
|
};
|
||||||
|
|
||||||
|
class ConfirmPage_AmsUpdate : public ConfirmPage_Done
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ConfirmPage_AmsUpdate(brls::StagedAppletFrame* frame, const std::string& text, bool erista = true);
|
||||||
};
|
};
|
|
@ -22,7 +22,7 @@ JCPage::JCPage() : AppletFrame(true, true)
|
||||||
new WorkerPage(stagedFrame, "menus/joy_con/backing_up"_i18n,
|
new WorkerPage(stagedFrame, "menus/joy_con/backing_up"_i18n,
|
||||||
[]() { JC::backupJCColor(JC_COLOR_PATH); }));
|
[]() { JC::backupJCColor(JC_COLOR_PATH); }));
|
||||||
stagedFrame->addStage(
|
stagedFrame->addStage(
|
||||||
new ConfirmPage(stagedFrame, "menus/common/all_done"_i18n, true));
|
new ConfirmPage_Done(stagedFrame, "menus/common/all_done"_i18n));
|
||||||
brls::Application::pushView(stagedFrame);
|
brls::Application::pushView(stagedFrame);
|
||||||
});
|
});
|
||||||
list->addView(backup);
|
list->addView(backup);
|
||||||
|
@ -40,7 +40,7 @@ JCPage::JCPage() : AppletFrame(true, true)
|
||||||
new WorkerPage(stagedFrame, "menus/joy_con/changing"_i18n,
|
new WorkerPage(stagedFrame, "menus/joy_con/changing"_i18n,
|
||||||
[value]() { JC::changeJCColor(value); }));
|
[value]() { JC::changeJCColor(value); }));
|
||||||
stagedFrame->addStage(
|
stagedFrame->addStage(
|
||||||
new ConfirmPage(stagedFrame, "menus/joy_con/all_done"_i18n, true));
|
new ConfirmPage_Done(stagedFrame, "menus/joy_con/all_done"_i18n));
|
||||||
brls::Application::pushView(stagedFrame);
|
brls::Application::pushView(stagedFrame);
|
||||||
});
|
});
|
||||||
list->addView(listItem);
|
list->addView(listItem);
|
||||||
|
|
|
@ -23,7 +23,7 @@ PCPage::PCPage() : AppletFrame(true, true)
|
||||||
new WorkerPage(stagedFrame, "menus/pro_con/backing_up"_i18n,
|
new WorkerPage(stagedFrame, "menus/pro_con/backing_up"_i18n,
|
||||||
[]() { PC::backupPCColor(PC_COLOR_PATH); }));
|
[]() { PC::backupPCColor(PC_COLOR_PATH); }));
|
||||||
stagedFrame->addStage(
|
stagedFrame->addStage(
|
||||||
new ConfirmPage(stagedFrame, "menus/common/all_done"_i18n, true));
|
new ConfirmPage_Done(stagedFrame, "menus/common/all_done"_i18n));
|
||||||
brls::Application::pushView(stagedFrame);
|
brls::Application::pushView(stagedFrame);
|
||||||
});
|
});
|
||||||
list->addView(backup);
|
list->addView(backup);
|
||||||
|
@ -41,7 +41,7 @@ PCPage::PCPage() : AppletFrame(true, true)
|
||||||
new WorkerPage(stagedFrame, "menus/pro_con/changing"_i18n,
|
new WorkerPage(stagedFrame, "menus/pro_con/changing"_i18n,
|
||||||
[value]() { PC::changePCColor(value); }));
|
[value]() { PC::changePCColor(value); }));
|
||||||
stagedFrame->addStage(
|
stagedFrame->addStage(
|
||||||
new ConfirmPage(stagedFrame, "menus/pro_con/all_done"_i18n, true));
|
new ConfirmPage_Done(stagedFrame, "menus/pro_con/all_done"_i18n));
|
||||||
brls::Application::pushView(stagedFrame);
|
brls::Application::pushView(stagedFrame);
|
||||||
});
|
});
|
||||||
list->addView(listItem);
|
list->addView(listItem);
|
||||||
|
|
|
@ -122,9 +122,9 @@ void AmsTab::CreateStagedFrames(const std::string& text, const std::string& url,
|
||||||
new WorkerPage(stagedFrame, "menus/common/extracting"_i18n, []() { util::extractArchive(contentType::bootloaders); }));
|
new WorkerPage(stagedFrame, "menus/common/extracting"_i18n, []() { util::extractArchive(contentType::bootloaders); }));
|
||||||
}
|
}
|
||||||
if (ams)
|
if (ams)
|
||||||
stagedFrame->addStage(new ConfirmPage(stagedFrame, "menus/ams_update/reboot_rcm"_i18n, false, true, erista));
|
stagedFrame->addStage(new ConfirmPage_AmsUpdate(stagedFrame, "menus/ams_update/reboot_rcm"_i18n, erista));
|
||||||
else
|
else
|
||||||
stagedFrame->addStage(new ConfirmPage(stagedFrame, "menus/common/all_done"_i18n, true));
|
stagedFrame->addStage(new ConfirmPage_Done(stagedFrame, "menus/common/all_done"_i18n));
|
||||||
brls::Application::pushView(stagedFrame);
|
brls::Application::pushView(stagedFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -102,7 +102,7 @@ void AppPage::CreateDownloadAllButton()
|
||||||
stagedFrame->addStage(
|
stagedFrame->addStage(
|
||||||
new WorkerPage(stagedFrame, "menus/common/extracting"_i18n, []() { util::extractArchive(contentType::cheats); }));
|
new WorkerPage(stagedFrame, "menus/common/extracting"_i18n, []() { util::extractArchive(contentType::cheats); }));
|
||||||
stagedFrame->addStage(
|
stagedFrame->addStage(
|
||||||
new ConfirmPage(stagedFrame, "menus/common/all_done"_i18n, true));
|
new ConfirmPage_Done(stagedFrame, "menus/common/all_done"_i18n));
|
||||||
brls::Application::pushView(stagedFrame);
|
brls::Application::pushView(stagedFrame);
|
||||||
});
|
});
|
||||||
list->addView(download);
|
list->addView(download);
|
||||||
|
|
|
@ -36,7 +36,7 @@ CheatsPage::CheatsPage() : AppletFrame(true, true)
|
||||||
stagedFrame->addStage(
|
stagedFrame->addStage(
|
||||||
new WorkerPage(stagedFrame, "menus/cheats/deleting"_i18n, []() { extract::removeCheats(); }));
|
new WorkerPage(stagedFrame, "menus/cheats/deleting"_i18n, []() { extract::removeCheats(); }));
|
||||||
stagedFrame->addStage(
|
stagedFrame->addStage(
|
||||||
new ConfirmPage(stagedFrame, "menus/common/all_done"_i18n, true));
|
new ConfirmPage_Done(stagedFrame, "menus/common/all_done"_i18n));
|
||||||
brls::Application::pushView(stagedFrame);
|
brls::Application::pushView(stagedFrame);
|
||||||
});
|
});
|
||||||
list->addView(item);
|
list->addView(item);
|
||||||
|
@ -48,7 +48,7 @@ CheatsPage::CheatsPage() : AppletFrame(true, true)
|
||||||
stagedFrame->addStage(
|
stagedFrame->addStage(
|
||||||
new WorkerPage(stagedFrame, "menus/cheats/deleting"_i18n, []() { extract::removeOrphanedCheats(); }));
|
new WorkerPage(stagedFrame, "menus/cheats/deleting"_i18n, []() { extract::removeOrphanedCheats(); }));
|
||||||
stagedFrame->addStage(
|
stagedFrame->addStage(
|
||||||
new ConfirmPage(stagedFrame, "menus/common/all_done"_i18n, true));
|
new ConfirmPage_Done(stagedFrame, "menus/common/all_done"_i18n));
|
||||||
brls::Application::pushView(stagedFrame);
|
brls::Application::pushView(stagedFrame);
|
||||||
});
|
});
|
||||||
list->addView(item);
|
list->addView(item);
|
||||||
|
@ -70,7 +70,7 @@ CheatsPage::CheatsPage() : AppletFrame(true, true)
|
||||||
stagedFrame->addStage(
|
stagedFrame->addStage(
|
||||||
new WorkerPage(stagedFrame, "menus/common/extracting"_i18n, [cheatsVer]() { extract::extractAllCheats(CHEATS_ZIP_PATH, CurrentCfw::running_cfw, cheatsVer); }));
|
new WorkerPage(stagedFrame, "menus/common/extracting"_i18n, [cheatsVer]() { extract::extractAllCheats(CHEATS_ZIP_PATH, CurrentCfw::running_cfw, cheatsVer); }));
|
||||||
stagedFrame->addStage(
|
stagedFrame->addStage(
|
||||||
new ConfirmPage(stagedFrame, "menus/common/all_done"_i18n, true));
|
new ConfirmPage_Done(stagedFrame, "menus/common/all_done"_i18n));
|
||||||
brls::Application::pushView(stagedFrame);
|
brls::Application::pushView(stagedFrame);
|
||||||
});
|
});
|
||||||
list->addView(item);
|
list->addView(item);
|
||||||
|
|
|
@ -10,42 +10,58 @@
|
||||||
|
|
||||||
namespace i18n = brls::i18n;
|
namespace i18n = brls::i18n;
|
||||||
using namespace i18n::literals;
|
using namespace i18n::literals;
|
||||||
ConfirmPage::ConfirmPage(brls::StagedAppletFrame* frame, const std::string& text, bool done, bool reboot, bool erista) : done(done), reboot(reboot), erista(erista)
|
ConfirmPage::ConfirmPage(brls::StagedAppletFrame* frame, const std::string& text)
|
||||||
{
|
{
|
||||||
this->button = (new brls::Button(brls::ButtonStyle::REGULAR))->setLabel(done ? "menus/common/back"_i18n : "menus/common/continue"_i18n);
|
this->button = (new brls::Button(brls::ButtonStyle::REGULAR))->setLabel("menus/common/back"_i18n);
|
||||||
this->button->setParent(this);
|
this->button->setParent(this);
|
||||||
this->button->getClickEvent()->subscribe([frame, this](View* view) {
|
this->button->getClickEvent()->subscribe([frame, this](View* view) {
|
||||||
if (!frame->isLastStage()) {
|
if (!frame->isLastStage())
|
||||||
frame->nextStage();
|
frame->nextStage();
|
||||||
}
|
else
|
||||||
else if (this->done) {
|
|
||||||
brls::Application::pushView(new MainFrame());
|
brls::Application::pushView(new MainFrame());
|
||||||
}
|
|
||||||
else if (this->reboot) {
|
|
||||||
if (this->erista) {
|
|
||||||
util::rebootToPayload(RCM_PAYLOAD_PATH);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (std::filesystem::exists(UPDATE_BIN_PATH)) {
|
|
||||||
fs::copyFile(UPDATE_BIN_PATH, MARIKO_PAYLOAD_PATH_TEMP);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
fs::copyFile(REBOOT_PAYLOAD_PATH, MARIKO_PAYLOAD_PATH_TEMP);
|
|
||||||
}
|
|
||||||
fs::copyFile(RCM_PAYLOAD_PATH, MARIKO_PAYLOAD_PATH);
|
|
||||||
util::shutDown(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this->label = new brls::Label(brls::LabelStyle::DIALOG, text, true);
|
this->label = new brls::Label(brls::LabelStyle::DIALOG, text, true);
|
||||||
this->label->setHorizontalAlign(NVG_ALIGN_CENTER);
|
this->label->setHorizontalAlign(NVG_ALIGN_CENTER);
|
||||||
this->label->setParent(this);
|
this->label->setParent(this);
|
||||||
|
|
||||||
if (this->done || this->reboot)
|
|
||||||
this->registerAction("", brls::Key::B, [this] { return true; });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ConfirmPage_Done::ConfirmPage_Done(brls::StagedAppletFrame* frame, const std::string& text) : ConfirmPage(frame, text)
|
||||||
|
{
|
||||||
|
this->button->setLabel("menus/common/back"_i18n);
|
||||||
|
this->done = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
ConfirmPage_AppUpdate::ConfirmPage_AppUpdate(brls::StagedAppletFrame* frame, const std::string& text) : ConfirmPage_Done(frame, text)
|
||||||
|
{
|
||||||
|
this->button->getClickEvent()->subscribe([](View* view) {
|
||||||
|
envSetNextLoad(FORWARDER_PATH, fmt::format("\"{}\"", FORWARDER_PATH).c_str());
|
||||||
|
romfsExit();
|
||||||
|
brls::Application::quit();
|
||||||
|
});
|
||||||
|
this->registerAction("", brls::Key::B, [this] { return true; });
|
||||||
|
}
|
||||||
|
|
||||||
|
ConfirmPage_AmsUpdate::ConfirmPage_AmsUpdate(brls::StagedAppletFrame* frame, const std::string& text, bool erista) : ConfirmPage_Done(frame, text)
|
||||||
|
{
|
||||||
|
this->button->getClickEvent()->subscribe([this, erista](View* view) {
|
||||||
|
if (erista) {
|
||||||
|
util::rebootToPayload(RCM_PAYLOAD_PATH);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (std::filesystem::exists(UPDATE_BIN_PATH)) {
|
||||||
|
fs::copyFile(UPDATE_BIN_PATH, MARIKO_PAYLOAD_PATH_TEMP);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fs::copyFile(REBOOT_PAYLOAD_PATH, MARIKO_PAYLOAD_PATH_TEMP);
|
||||||
|
}
|
||||||
|
fs::copyFile(RCM_PAYLOAD_PATH, MARIKO_PAYLOAD_PATH);
|
||||||
|
util::shutDown(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this->registerAction("", brls::Key::B, [this] { return true; });
|
||||||
|
};
|
||||||
|
|
||||||
void ConfirmPage::draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, brls::Style* style, brls::FrameContext* ctx)
|
void ConfirmPage::draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, brls::Style* style, brls::FrameContext* ctx)
|
||||||
{
|
{
|
||||||
if (!this->done) {
|
if (!this->done) {
|
||||||
|
@ -53,7 +69,7 @@ void ConfirmPage::draw(NVGcontext* vg, int x, int y, unsigned width, unsigned he
|
||||||
auto missing = std::max(1l - std::chrono::duration_cast<std::chrono::seconds>(end - start).count(), 0l);
|
auto missing = std::max(1l - std::chrono::duration_cast<std::chrono::seconds>(end - start).count(), 0l);
|
||||||
auto text = std::string("menus/common/continue"_i18n);
|
auto text = std::string("menus/common/continue"_i18n);
|
||||||
if (missing > 0) {
|
if (missing > 0) {
|
||||||
this->button->setLabel(text + " (" + std::to_string(missing) + ")");
|
this->button->setLabel(fmt::format("{} ({})", text, missing));
|
||||||
this->button->setState(brls::ButtonState::DISABLED);
|
this->button->setState(brls::ButtonState::DISABLED);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -34,7 +34,7 @@ DownloadPayloadPage::DownloadPayloadPage(const nlohmann::ordered_json& payloads)
|
||||||
stagedFrame->addStage(
|
stagedFrame->addStage(
|
||||||
new WorkerPage(stagedFrame, "menus/common/downloading"_i18n, [url, path]() { download::downloadFile(url, path, OFF); }));
|
new WorkerPage(stagedFrame, "menus/common/downloading"_i18n, [url, path]() { download::downloadFile(url, path, OFF); }));
|
||||||
stagedFrame->addStage(
|
stagedFrame->addStage(
|
||||||
new ConfirmPage(stagedFrame, "menus/common/all_done"_i18n, true));
|
new ConfirmPage_Done(stagedFrame, "menus/common/all_done"_i18n));
|
||||||
brls::Application::pushView(stagedFrame);
|
brls::Application::pushView(stagedFrame);
|
||||||
});
|
});
|
||||||
list->addView(listItem);
|
list->addView(listItem);
|
||||||
|
|
|
@ -96,16 +96,16 @@ void ListDownloadTab::createList(contentType type)
|
||||||
stagedFrame->addStage(new DialoguePage_fw(stagedFrame, doneMsg));
|
stagedFrame->addStage(new DialoguePage_fw(stagedFrame, doneMsg));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
stagedFrame->addStage(new ConfirmPage(stagedFrame, doneMsg, true));
|
stagedFrame->addStage(new ConfirmPage_Done(stagedFrame, doneMsg));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case contentType::sigpatches:
|
case contentType::sigpatches:
|
||||||
doneMsg += "\n" + "menus/sigpatches/reboot"_i18n;
|
doneMsg += "\n" + "menus/sigpatches/reboot"_i18n;
|
||||||
stagedFrame->addStage(new ConfirmPage(stagedFrame, doneMsg, true));
|
stagedFrame->addStage(new ConfirmPage_Done(stagedFrame, doneMsg));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
stagedFrame->addStage(new ConfirmPage(stagedFrame, doneMsg, true));
|
stagedFrame->addStage(new ConfirmPage_Done(stagedFrame, doneMsg));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
brls::Application::pushView(stagedFrame);
|
brls::Application::pushView(stagedFrame);
|
||||||
|
|
|
@ -40,7 +40,7 @@ ToolsTab::ToolsTab(const std::string& tag, const nlohmann::ordered_json& payload
|
||||||
stagedFrame->addStage(
|
stagedFrame->addStage(
|
||||||
new WorkerPage(stagedFrame, "menus/common/extracting"_i18n, []() { util::extractArchive(contentType::app); }));
|
new WorkerPage(stagedFrame, "menus/common/extracting"_i18n, []() { util::extractArchive(contentType::app); }));
|
||||||
stagedFrame->addStage(
|
stagedFrame->addStage(
|
||||||
new ConfirmPage(stagedFrame, "menus/common/all_done"_i18n, true));
|
new ConfirmPage_AppUpdate(stagedFrame, "menus/common/all_done"_i18n));
|
||||||
brls::Application::pushView(stagedFrame);
|
brls::Application::pushView(stagedFrame);
|
||||||
});
|
});
|
||||||
updateApp->setHeight(LISTITEM_HEIGHT);
|
updateApp->setHeight(LISTITEM_HEIGHT);
|
||||||
|
|
|
@ -174,9 +174,6 @@ namespace util {
|
||||||
case contentType::app:
|
case contentType::app:
|
||||||
extract::extract(APP_FILENAME, CONFIG_PATH);
|
extract::extract(APP_FILENAME, CONFIG_PATH);
|
||||||
fs::copyFile(ROMFS_FORWARDER, FORWARDER_PATH);
|
fs::copyFile(ROMFS_FORWARDER, FORWARDER_PATH);
|
||||||
envSetNextLoad(FORWARDER_PATH, fmt::format("\"{}\"", FORWARDER_PATH).c_str());
|
|
||||||
romfsExit();
|
|
||||||
brls::Application::quit();
|
|
||||||
break;
|
break;
|
||||||
case contentType::bootloaders: {
|
case contentType::bootloaders: {
|
||||||
int overwriteInis = showDialogBoxBlocking("menus/utils/overwrite_inis"_i18n, "menus/common/no"_i18n, "menus/common/yes"_i18n);
|
int overwriteInis = showDialogBoxBlocking("menus/utils/overwrite_inis"_i18n, "menus/common/no"_i18n, "menus/common/yes"_i18n);
|
||||||
|
|
Loading…
Reference in a new issue