1
0
Fork 0
mirror of https://github.com/HamletDuFromage/aio-switch-updater.git synced 2024-12-28 18:36:02 +00:00

added warning screen, couple of visual tweaks

This commit is contained in:
flb 2021-02-16 01:46:39 +01:00
parent db9c34b5b0
commit b124e8bc2e
10 changed files with 116 additions and 11 deletions

View file

@ -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

20
include/warning_page.hpp Normal file
View file

@ -0,0 +1,20 @@
#pragma once
#include <borealis.hpp>
#include <chrono>
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;
};

View file

@ -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."

View file

@ -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()) {

View file

@ -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) {

View file

@ -7,6 +7,8 @@
#include "constants.hpp"
#include "utils.hpp"
#include "current_cfw.hpp"
#include "warning_page.hpp"
#include <filesystem>
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());

View file

@ -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; });

View file

@ -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);

76
source/warning_page.cpp Normal file
View file

@ -0,0 +1,76 @@
#include "warning_page.hpp"
#include "main_frame.hpp"
#include "constants.hpp"
#include "utils.hpp"
#include <algorithm>
#include <fstream>
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<std::chrono::seconds>(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;
}

View file

@ -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; });