mirror of
https://github.com/HamletDuFromage/aio-switch-updater.git
synced 2025-01-01 12:16:02 +00:00
Added option to launch Daybreak with arguments after a sysupdate download
This commit is contained in:
parent
d03bbb13ea
commit
811eb4c18c
7 changed files with 112 additions and 42 deletions
|
@ -95,6 +95,8 @@ constexpr const char HOMEBREW[] = "/config/aio-switch-updater/language.json";
|
||||||
constexpr const char ROMFS_FORWARDER[] = "romfs:/aiosu-forwarder.nro";
|
constexpr const char ROMFS_FORWARDER[] = "romfs:/aiosu-forwarder.nro";
|
||||||
constexpr const char FORWARDER_PATH[] = "/config/aio-switch-updater/aiosu-forwarder.nro";
|
constexpr const char FORWARDER_PATH[] = "/config/aio-switch-updater/aiosu-forwarder.nro";
|
||||||
|
|
||||||
|
constexpr const char DAYBREAK_PATH[] = "/switch/daybreak.nro";
|
||||||
|
|
||||||
constexpr const char HIDDEN_AIO_FILE[] = "/config/aio-switch-updater/.aio-switch-updater";
|
constexpr const char HIDDEN_AIO_FILE[] = "/config/aio-switch-updater/.aio-switch-updater";
|
||||||
|
|
||||||
constexpr const int LISTITEM_HEIGHT = 50;
|
constexpr const int LISTITEM_HEIGHT = 50;
|
||||||
|
|
|
@ -2,22 +2,50 @@
|
||||||
|
|
||||||
#include <borealis.hpp>
|
#include <borealis.hpp>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
class DialoguePage : public brls::View
|
class DialoguePage : public brls::View
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
std::chrono::system_clock::time_point start = std::chrono::high_resolution_clock::now();
|
||||||
|
brls::NavigationMap navigationMap;
|
||||||
|
|
||||||
|
protected:
|
||||||
brls::Button* button1 = nullptr;
|
brls::Button* button1 = nullptr;
|
||||||
brls::Button* button2 = nullptr;
|
brls::Button* button2 = nullptr;
|
||||||
brls::Label* label = nullptr;
|
brls::Label* label = nullptr;
|
||||||
std::chrono::system_clock::time_point start = std::chrono::high_resolution_clock::now();
|
virtual void CreateView();
|
||||||
brls::NavigationMap navigationMap;
|
virtual void instantiateButtons(){};
|
||||||
bool erista = true;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DialoguePage(brls::StagedAppletFrame* frame, const std::string& text, bool erista = true);
|
DialoguePage(){};
|
||||||
|
|
||||||
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;
|
||||||
brls::View* getNextFocus(brls::FocusDirection direction, brls::View* currentView);
|
brls::View* getNextFocus(brls::FocusDirection direction, brls::View* currentView);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class DialoguePage_fw : public DialoguePage
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
void instantiateButtons() override;
|
||||||
|
std::string text;
|
||||||
|
brls::StagedAppletFrame* frame;
|
||||||
|
|
||||||
|
public:
|
||||||
|
DialoguePage_fw(brls::StagedAppletFrame* frame, const std::string& text) : DialoguePage(), text(text), frame(frame) { CreateView(); }
|
||||||
|
void draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, brls::Style* style, brls::FrameContext* ctx) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
class DialoguePage_ams : public DialoguePage
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
void instantiateButtons() override;
|
||||||
|
bool erista = true;
|
||||||
|
std::string text;
|
||||||
|
brls::StagedAppletFrame* frame;
|
||||||
|
|
||||||
|
public:
|
||||||
|
DialoguePage_ams(brls::StagedAppletFrame* frame, const std::string& text, bool erista = true) : DialoguePage(), erista(erista), text(text), frame(frame) { CreateView(); }
|
||||||
|
};
|
|
@ -185,6 +185,9 @@
|
||||||
"getting_ams": "Getting Atmosphère",
|
"getting_ams": "Getting Atmosphère",
|
||||||
"custom_packs_label": "Here are packs listed in the {} file. Be aware that those are not endorsed by aio-switch-updater so make sure you trust their source."
|
"custom_packs_label": "Here are packs listed in the {} file. Be aware that those are not endorsed by aio-switch-updater so make sure you trust their source."
|
||||||
},
|
},
|
||||||
|
"firmware": {
|
||||||
|
"launch_daybreak": "Do you want to launch Daybreak to install the downloaded sysupdate?"
|
||||||
|
},
|
||||||
"net": {
|
"net": {
|
||||||
"title": "Internet settings"
|
"title": "Internet settings"
|
||||||
},
|
},
|
||||||
|
|
|
@ -104,7 +104,7 @@ void AmsTab::CreateStagedFrames(const std::string& text, const std::string& url,
|
||||||
new WorkerPage(stagedFrame, "menus/common/extracting"_i18n, []() { util::extractArchive(archiveType::ams_cfw); }));
|
new WorkerPage(stagedFrame, "menus/common/extracting"_i18n, []() { util::extractArchive(archiveType::ams_cfw); }));
|
||||||
if (hekate) {
|
if (hekate) {
|
||||||
stagedFrame->addStage(
|
stagedFrame->addStage(
|
||||||
new DialoguePage(stagedFrame, text_hekate, erista));
|
new DialoguePage_ams(stagedFrame, text_hekate, erista));
|
||||||
stagedFrame->addStage(
|
stagedFrame->addStage(
|
||||||
new WorkerPage(stagedFrame, "menus/common/downloading"_i18n, [hekate_url]() { util::downloadArchive(hekate_url, archiveType::cfw); }));
|
new WorkerPage(stagedFrame, "menus/common/downloading"_i18n, [hekate_url]() { util::downloadArchive(hekate_url, archiveType::cfw); }));
|
||||||
stagedFrame->addStage(
|
stagedFrame->addStage(
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
#include "fs.hpp"
|
#include "fs.hpp"
|
||||||
#include "main_frame.hpp"
|
#include "main_frame.hpp"
|
||||||
|
@ -10,39 +11,15 @@
|
||||||
namespace i18n = brls::i18n;
|
namespace i18n = brls::i18n;
|
||||||
using namespace i18n::literals;
|
using namespace i18n::literals;
|
||||||
|
|
||||||
DialoguePage::DialoguePage(brls::StagedAppletFrame* frame, const std::string& text, bool erista) : erista(erista)
|
void DialoguePage::CreateView()
|
||||||
{
|
{
|
||||||
this->button1 = (new brls::Button(brls::ButtonStyle::REGULAR))->setLabel("menus/common/yes"_i18n);
|
this->button1 = (new brls::Button(brls::ButtonStyle::REGULAR))->setLabel("menus/common/yes"_i18n);
|
||||||
this->button1->setParent(this);
|
this->button1->setParent(this);
|
||||||
this->button2 = (new brls::Button(brls::ButtonStyle::REGULAR))->setLabel("menus/common/no"_i18n);
|
this->button2 = (new brls::Button(brls::ButtonStyle::REGULAR))->setLabel("menus/common/no"_i18n);
|
||||||
this->button2->setParent(this);
|
this->button2->setParent(this);
|
||||||
|
|
||||||
this->button1->getClickEvent()->subscribe([frame, this](View* view) {
|
this->instantiateButtons();
|
||||||
if (!frame->isLastStage())
|
|
||||||
frame->nextStage();
|
|
||||||
else {
|
|
||||||
brls::Application::pushView(new MainFrame());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
this->button2->getClickEvent()->subscribe([frame, this](View* view) {
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
brls::Application::popView();
|
|
||||||
});
|
|
||||||
|
|
||||||
this->label = new brls::Label(brls::LabelStyle::DIALOG, "menus/ams_update/install_hekate"_i18n + "\n\n" + text, true);
|
|
||||||
this->label->setHorizontalAlign(NVG_ALIGN_CENTER);
|
this->label->setHorizontalAlign(NVG_ALIGN_CENTER);
|
||||||
this->label->setParent(this);
|
this->label->setParent(this);
|
||||||
|
|
||||||
|
@ -114,3 +91,59 @@ brls::View* DialoguePage::getNextFocus(brls::FocusDirection direction, brls::Vie
|
||||||
{
|
{
|
||||||
return this->navigationMap.getNextFocus(direction, currentView);
|
return this->navigationMap.getNextFocus(direction, currentView);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DialoguePage_ams::instantiateButtons()
|
||||||
|
{
|
||||||
|
this->button1->getClickEvent()->subscribe([this](View* view) {
|
||||||
|
if (!frame->isLastStage())
|
||||||
|
frame->nextStage();
|
||||||
|
else {
|
||||||
|
brls::Application::pushView(new MainFrame());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this->button2->getClickEvent()->subscribe([this](View* view) {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
brls::Application::popView();
|
||||||
|
});
|
||||||
|
|
||||||
|
this->label = new brls::Label(brls::LabelStyle::DIALOG, "menus/ams_update/install_hekate"_i18n + "\n\n" + this->text, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialoguePage_fw::instantiateButtons()
|
||||||
|
{
|
||||||
|
this->button2->getClickEvent()->subscribe([this](View* view) {
|
||||||
|
if (!frame->isLastStage())
|
||||||
|
frame->nextStage();
|
||||||
|
else {
|
||||||
|
brls::Application::pushView(new MainFrame());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this->button1->getClickEvent()->subscribe([this](View* view) {
|
||||||
|
envSetNextLoad(DAYBREAK_PATH, fmt::format("\"{}\" \"/firmware\"", DAYBREAK_PATH).c_str());
|
||||||
|
romfsExit();
|
||||||
|
brls::Application::quit();
|
||||||
|
});
|
||||||
|
|
||||||
|
this->label = new brls::Label(brls::LabelStyle::DIALOG, fmt::format("{}\n\n{}", this->text, "menus/firmware/launch_daybreak"_i18n), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialoguePage_fw::draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, brls::Style* style, brls::FrameContext* ctx)
|
||||||
|
{
|
||||||
|
this->label->frame(ctx);
|
||||||
|
this->button1->frame(ctx);
|
||||||
|
this->button2->frame(ctx);
|
||||||
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include "app_page.hpp"
|
#include "app_page.hpp"
|
||||||
#include "confirm_page.hpp"
|
#include "confirm_page.hpp"
|
||||||
#include "current_cfw.hpp"
|
#include "current_cfw.hpp"
|
||||||
|
#include "dialogue_page.hpp"
|
||||||
#include "download.hpp"
|
#include "download.hpp"
|
||||||
#include "extract.hpp"
|
#include "extract.hpp"
|
||||||
#include "fs.hpp"
|
#include "fs.hpp"
|
||||||
|
@ -92,14 +93,11 @@ ListDownloadTab::ListDownloadTab(const archiveType type) : brls::List()
|
||||||
listItem->getClickEvent()->subscribe([&, text, url, type, operation, newCheatsVer, currentCheatsVer](brls::View* view) {
|
listItem->getClickEvent()->subscribe([&, text, url, type, operation, newCheatsVer, currentCheatsVer](brls::View* view) {
|
||||||
brls::StagedAppletFrame* stagedFrame = new brls::StagedAppletFrame();
|
brls::StagedAppletFrame* stagedFrame = new brls::StagedAppletFrame();
|
||||||
stagedFrame->setTitle(operation);
|
stagedFrame->setTitle(operation);
|
||||||
stagedFrame->addStage(
|
stagedFrame->addStage(new ConfirmPage(stagedFrame, text));
|
||||||
new ConfirmPage(stagedFrame, text));
|
|
||||||
if (type != archiveType::cheats || newCheatsVer != currentCheatsVer || !std::filesystem::exists(CHEATS_ZIP_PATH)) {
|
if (type != archiveType::cheats || newCheatsVer != currentCheatsVer || !std::filesystem::exists(CHEATS_ZIP_PATH)) {
|
||||||
stagedFrame->addStage(
|
stagedFrame->addStage(new WorkerPage(stagedFrame, "menus/common/downloading"_i18n, [url, type]() { util::downloadArchive(url, type); }));
|
||||||
new WorkerPage(stagedFrame, "menus/common/downloading"_i18n, [url, type]() { util::downloadArchive(url, type); }));
|
|
||||||
}
|
}
|
||||||
stagedFrame->addStage(
|
stagedFrame->addStage(new WorkerPage(stagedFrame, "menus/common/extracting"_i18n, [type]() { util::extractArchive(type); }));
|
||||||
new WorkerPage(stagedFrame, "menus/common/extracting"_i18n, [type]() { util::extractArchive(type); }));
|
|
||||||
std::string doneMsg = "menus/common/all_done"_i18n;
|
std::string doneMsg = "menus/common/all_done"_i18n;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case archiveType::fw: {
|
case archiveType::fw: {
|
||||||
|
@ -110,16 +108,22 @@ ListDownloadTab::ListDownloadTab(const archiveType type) : brls::List()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (std::filesystem::exists(DAYBREAK_PATH)) {
|
||||||
|
stagedFrame->addStage(new DialoguePage_fw(stagedFrame, doneMsg));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
stagedFrame->addStage(new ConfirmPage(stagedFrame, doneMsg, true));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case archiveType::sigpatches:
|
case archiveType::sigpatches:
|
||||||
doneMsg += "\n" + "menus/sigpatches/reboot"_i18n;
|
doneMsg += "\n" + "menus/sigpatches/reboot"_i18n;
|
||||||
|
stagedFrame->addStage(new ConfirmPage(stagedFrame, doneMsg, true));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
stagedFrame->addStage(new ConfirmPage(stagedFrame, doneMsg, true));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
stagedFrame->addStage(
|
|
||||||
new ConfirmPage(stagedFrame, doneMsg, true));
|
|
||||||
brls::Application::pushView(stagedFrame);
|
brls::Application::pushView(stagedFrame);
|
||||||
});
|
});
|
||||||
this->addView(listItem);
|
this->addView(listItem);
|
||||||
|
|
|
@ -147,7 +147,7 @@ namespace util {
|
||||||
case archiveType::app:
|
case archiveType::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, ("\"" + std::string(FORWARDER_PATH) + "\"").c_str());
|
envSetNextLoad(FORWARDER_PATH, fmt::format("\"{}\"", FORWARDER_PATH).c_str());
|
||||||
romfsExit();
|
romfsExit();
|
||||||
brls::Application::quit();
|
brls::Application::quit();
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue