diff --git a/include/constants.hpp b/include/constants.hpp index ce7bf68..a50e66f 100644 --- a/include/constants.hpp +++ b/include/constants.hpp @@ -81,6 +81,8 @@ #define ROMFS_FORWARDER "romfs:/aiosu-forwarder.nro" #define FORWARDER_PATH "/config/aio-switch-updater/aiosu-forwarder.nro" +#define HIDDEN_AIO_FILE "/config/aio-switch-updater/.aio-switch-updater" + #define LISTITEM_HEIGHT 50 diff --git a/include/warning_page.hpp b/include/warning_page.hpp new file mode 100644 index 0000000..2d4e513 --- /dev/null +++ b/include/warning_page.hpp @@ -0,0 +1,20 @@ +#pragma once + +#include +#include + +class WarningPage : public brls::View +{ + private: + brls::Button* button = nullptr; + brls::Label* label = nullptr; + std::chrono::system_clock::time_point start = std::chrono::high_resolution_clock::now(); + + public: + WarningPage(std::string text); + ~WarningPage(); + + 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; + brls::View* getDefaultFocus() override; +}; \ No newline at end of file diff --git a/resources/i18n/en-US/menus.json b/resources/i18n/en-US/menus.json index 7515945..1f30d9f 100644 --- a/resources/i18n/en-US/menus.json +++ b/resources/i18n/en-US/menus.json @@ -237,7 +237,9 @@ "files_not_found": "The following files were not found and couldn't be copied:\n", "copy_files_not_found": "This tool allows you to copy files to other locations, which may be needed for your bootloader/trinket. Grab copy_files.json at 'https://git.io/aiosu_copy_files' and add it to your config folder. This will also be performed after updates.", - "delete_contents": "Would you like to remove the existing '/atmosphere/contents/' directory? This will prevent crashes if you have sysmodules that do not support the latest Atmosphère. Please note that it will delete all your existing sysmodules and cheats." + "delete_contents": "Would you like to remove the existing '/atmosphere/contents/' directory? This will prevent crashes if you have sysmodules that do not support the latest Atmosphère. Please note that it will delete all your existing sysmodules and cheats.", + + "launch_warning": "Please pay attention to the following points before using the app:\n\n\uE016 Read up on how to manually update your Switch first. This will help you understand the app better and you'll know what to do in case something goes wrong.\n\uE016 On Mariko (i.e. chipped) switches, payloads cannot be launched from HOS. This means you WILL NOT be able to update Atmosphère with this app. You won't be able to use the reboot to payload feature either.\n\uE016 Please note that using this app (or any homebrew) on a exFAT SD card is not recommended, as those are more likely to corrupt.\n\nThis screen won't show again." diff --git a/source/confirm_page.cpp b/source/confirm_page.cpp index 07274b5..739d208 100644 --- a/source/confirm_page.cpp +++ b/source/confirm_page.cpp @@ -8,7 +8,7 @@ namespace i18n = brls::i18n; using namespace i18n::literals; ConfirmPage::ConfirmPage(brls::StagedAppletFrame* frame, std::string text, bool done, bool reboot): done(done), reboot(reboot) { - this->button = (new brls::Button(brls::ButtonStyle::BORDERLESS))->setLabel(done ? "menus/Back"_i18n : "menus/Continue"_i18n ); + this->button = (new brls::Button(brls::ButtonStyle::REGULAR))->setLabel(done ? "menus/Back"_i18n : "menus/Continue"_i18n ); this->button->setParent(this); this->button->getClickEvent()->subscribe([frame, this](View* view) { if (!frame->isLastStage()) { diff --git a/source/dialogue_page.cpp b/source/dialogue_page.cpp index 4d8369b..a4c2a82 100644 --- a/source/dialogue_page.cpp +++ b/source/dialogue_page.cpp @@ -8,9 +8,9 @@ using namespace i18n::literals; DialoguePage::DialoguePage(brls::StagedAppletFrame* frame, std::string text) { - this->button1 = (new brls::Button(brls::ButtonStyle::BORDERLESS))->setLabel("menus/Yes"_i18n); + this->button1 = (new brls::Button(brls::ButtonStyle::REGULAR))->setLabel("menus/Yes"_i18n); this->button1->setParent(this); - this->button2 = (new brls::Button(brls::ButtonStyle::BORDERLESS))->setLabel("menus/No"_i18n); + this->button2 = (new brls::Button(brls::ButtonStyle::REGULAR))->setLabel("menus/No"_i18n); this->button2->setParent(this); this->button1->getClickEvent()->subscribe([frame, this](View* view) { diff --git a/source/main.cpp b/source/main.cpp index 93104ca..73c8d79 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -7,6 +7,8 @@ #include "constants.hpp" #include "utils.hpp" #include "current_cfw.hpp" +#include "warning_page.hpp" +#include namespace i18n = brls::i18n; using namespace i18n::literals; @@ -46,11 +48,13 @@ int main(int argc, char* argv[]) brls::Logger::setLogLevel(brls::LogLevel::DEBUG); brls::Logger::debug("Start"); - // Create root view - MainFrame *mainFrame = new MainFrame(); + if(std::filesystem::exists(HIDDEN_AIO_FILE)) { + brls::Application::pushView(new MainFrame()); + } + else { + brls::Application::pushView(new WarningPage("menus/launch_warning"_i18n)); + } - // Add the root view to the stack - brls::Application::pushView(mainFrame); // Run the app while (brls::Application::mainLoop()); diff --git a/source/main_frame.cpp b/source/main_frame.cpp index 98cd834..8b2cefc 100644 --- a/source/main_frame.cpp +++ b/source/main_frame.cpp @@ -49,7 +49,8 @@ MainFrame::MainFrame() : TabFrame() if(hideStatus.find("cheats") == hideStatus.end() || !hideStatus["cheats"]) this->addTab("menus/main_cheats"_i18n, new ListDownloadTab(cheats)); - this->addTab("menus/main_tools"_i18n , new ToolsTab(tag)); + if(hideStatus.find("tools") == hideStatus.end() || !hideStatus["tools"]) + this->addTab("menus/main_tools"_i18n , new ToolsTab(tag)); this->registerAction("" , brls::Key::B, [this] { return true; }); diff --git a/source/tools_tab.cpp b/source/tools_tab.cpp index ce09f72..4fe202b 100644 --- a/source/tools_tab.cpp +++ b/source/tools_tab.cpp @@ -133,7 +133,7 @@ ToolsTab::ToolsTab(std::string tag) : brls::List() if (R_FAILED(rc)) error += "\uE016 Error starting Browser\n\uE016 Lookup error code for more info " + rc; } else { // Running under applet - error += "\uE016 Running in applet mode.\n\uE016 Please launch hbmenu by holding [R] on a game"; + error += "\uE016 Running in applet mode/through a forwarder.\n\uE016 Please launch hbmenu by holding [R] on a game"; } if(!error.empty()){ brls::Dialog* dialog = new brls::Dialog(error); diff --git a/source/warning_page.cpp b/source/warning_page.cpp new file mode 100644 index 0000000..4884b75 --- /dev/null +++ b/source/warning_page.cpp @@ -0,0 +1,76 @@ +#include "warning_page.hpp" +#include "main_frame.hpp" +#include "constants.hpp" +#include "utils.hpp" +#include +#include + +namespace i18n = brls::i18n; +using namespace i18n::literals; +WarningPage::WarningPage(std::string text) +{ + createTree(CONFIG_PATH); + std::ofstream(HIDDEN_AIO_FILE); + this->button = (new brls::Button(brls::ButtonStyle::PRIMARY))->setLabel("menus/Continue"_i18n); + this->button->setParent(this); + this->button->getClickEvent()->subscribe([this](View* view) { + brls::Application::pushView(new MainFrame()); + }); + + this->label = new brls::Label(brls::LabelStyle::REGULAR, text, true); + this->label->setHorizontalAlign(NVG_ALIGN_LEFT); + //this->setBackground(brls::ViewBackground::DEBUG); + this->label->setParent(this); + + this->registerAction("", brls::Key::B, [this] { return true; }); +} + +void WarningPage::draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, brls::Style* style, brls::FrameContext* ctx) +{ + + auto end = std::chrono::high_resolution_clock::now(); + auto missing = std::max(1l - std::chrono::duration_cast(end - start).count(), 0l); + auto text = std::string("menus/Continue"_i18n ); + if (missing > 0) { + this->button->setLabel(text + " (" + std::to_string(missing) + ")"); + this->button->setState(brls::ButtonState::DISABLED); + } else { + this->button->setLabel(text); + this->button->setState(brls::ButtonState::ENABLED); + } + this->button->invalidate(); + + this->label->frame(ctx); + this->button->frame(ctx); +} + +brls::View* WarningPage::getDefaultFocus() +{ + return this->button; +} + +void WarningPage::layout(NVGcontext* vg, brls::Style* style, brls::FontStash* stash) +{ + this->label->setWidth(0.8f * this->width); + this->label->invalidate(true); + this->label->setBoundaries( + this->x + this->width / 2 - this->label->getWidth() / 2, + this->y + (this->height - this->label->getHeight() - this->y - style->CrashFrame.buttonHeight)/2, + this->label->getWidth(), + this->label->getHeight()); + + this->button->setBoundaries( + this->x + this->width / 2 - style->CrashFrame.buttonWidth / 2, + this->y + (this->height-style->CrashFrame.buttonHeight*3), + style->CrashFrame.buttonWidth, + style->CrashFrame.buttonHeight); + this->button->invalidate(); + + start = std::chrono::high_resolution_clock::now() + std::chrono::milliseconds(150); +} + +WarningPage::~WarningPage() +{ + delete this->label; + delete this->button; +} \ No newline at end of file diff --git a/source/worker_page.cpp b/source/worker_page.cpp index 70a266d..6c73ed1 100644 --- a/source/worker_page.cpp +++ b/source/worker_page.cpp @@ -17,7 +17,7 @@ WorkerPage::WorkerPage(brls::StagedAppletFrame* frame, const std::string& text, this->label->setHorizontalAlign(NVG_ALIGN_CENTER); this->label->setParent(this); - this->button = new brls::Button(brls::ButtonStyle::BORDERLESS); // avoid back button bug + this->button = new brls::Button(brls::ButtonStyle::REGULAR); this->button->setParent(this); this->registerAction("", brls::Key::B, [this] { return true; });