2019-10-17 20:20:40 +00:00
|
|
|
#include <filesystem>
|
2019-10-23 02:11:21 +00:00
|
|
|
#include "ui/MainApplication.hpp"
|
2019-10-17 20:20:40 +00:00
|
|
|
#include "ui/mainPage.hpp"
|
2019-10-25 01:33:41 +00:00
|
|
|
#include "util/util.hpp"
|
2019-10-27 03:36:45 +00:00
|
|
|
#include "util/config.hpp"
|
2019-10-25 01:33:41 +00:00
|
|
|
#include "sigInstall.hpp"
|
2019-10-17 20:20:40 +00:00
|
|
|
|
|
|
|
#define COLOR(hex) pu::ui::Color::FromHex(hex)
|
|
|
|
|
|
|
|
namespace inst::ui {
|
|
|
|
extern MainApplication *mainApp;
|
|
|
|
|
|
|
|
MainPage::MainPage() : Layout::Layout() {
|
|
|
|
this->SetBackgroundColor(COLOR("#670000FF"));
|
2019-10-27 03:36:45 +00:00
|
|
|
this->SetBackgroundImage("romfs:/background.jpg");
|
|
|
|
this->topRect = Rectangle::New(0, 0, 1280, 93, COLOR("#170909FF"));
|
|
|
|
this->botRect = Rectangle::New(0, 660, 1280, 60, COLOR("#17090980"));
|
|
|
|
this->titleImage = Image::New(0, 0, "romfs:/logo.png");
|
2019-11-14 01:23:30 +00:00
|
|
|
this->appVersionText = TextBlock::New(480, 49, "v" + inst::config::appVersion, 22);
|
|
|
|
this->appVersionText->SetColor(COLOR("#FFFFFFFF"));
|
2019-10-29 01:00:50 +00:00
|
|
|
this->butText = TextBlock::New(10, 678, "\ue0e0 Select \ue0e1 Exit ", 24);
|
2019-10-27 03:36:45 +00:00
|
|
|
this->butText->SetColor(COLOR("#FFFFFFFF"));
|
|
|
|
this->optionMenu = pu::ui::elm::Menu::New(0, 93, 1280, COLOR("#67000000"), 113, (567 / 113));
|
2019-10-17 20:20:40 +00:00
|
|
|
this->optionMenu->SetOnFocusColor(COLOR("#00000033"));
|
2019-10-27 03:36:45 +00:00
|
|
|
this->optionMenu->SetScrollbarColor(COLOR("#170909FF"));
|
|
|
|
this->installMenuItem = pu::ui::elm::MenuItem::New("Install NSP from SD Card");
|
2019-10-17 20:20:40 +00:00
|
|
|
this->installMenuItem->SetColor(COLOR("#FFFFFFFF"));
|
2019-10-27 03:36:45 +00:00
|
|
|
this->installMenuItem->SetIcon("romfs:/micro-sd.png");
|
2019-10-26 21:08:47 +00:00
|
|
|
this->netInstallMenuItem = pu::ui::elm::MenuItem::New("Install NSP Over LAN or Internet");
|
2019-10-17 20:20:40 +00:00
|
|
|
this->netInstallMenuItem->SetColor(COLOR("#FFFFFFFF"));
|
2019-10-27 03:36:45 +00:00
|
|
|
this->netInstallMenuItem->SetIcon("romfs:/cloud-download.png");
|
2019-10-25 01:33:41 +00:00
|
|
|
this->sigPatchesMenuItem = pu::ui::elm::MenuItem::New("Manage Signature Patches");
|
2019-10-17 20:20:40 +00:00
|
|
|
this->sigPatchesMenuItem->SetColor(COLOR("#FFFFFFFF"));
|
2019-10-27 03:36:45 +00:00
|
|
|
this->sigPatchesMenuItem->SetIcon("romfs:/wrench.png");
|
2019-10-26 04:38:12 +00:00
|
|
|
this->settingsMenuItem = pu::ui::elm::MenuItem::New("Settings");
|
|
|
|
this->settingsMenuItem->SetColor(COLOR("#FFFFFFFF"));
|
2019-10-27 03:36:45 +00:00
|
|
|
this->settingsMenuItem->SetIcon("romfs:/settings.png");
|
2019-10-17 20:20:40 +00:00
|
|
|
this->exitMenuItem = pu::ui::elm::MenuItem::New("Exit");
|
|
|
|
this->exitMenuItem->SetColor(COLOR("#FFFFFFFF"));
|
2019-10-27 03:36:45 +00:00
|
|
|
this->exitMenuItem->SetIcon("romfs:/exit-run.png");
|
|
|
|
this->awooImage = Image::New(410, 190, "romfs:/awoos/5bbdbcf9a5625cd307c9e9bc360d78bd.png");
|
2019-10-31 15:42:40 +00:00
|
|
|
this->eggImage = Image::New(410, 190, "romfs:/awoos/a8cb40e465dadaf9708c9b1896777ce6.png");
|
2019-10-27 03:36:45 +00:00
|
|
|
this->Add(this->topRect);
|
|
|
|
this->Add(this->botRect);
|
|
|
|
this->Add(this->titleImage);
|
2019-11-14 01:23:30 +00:00
|
|
|
this->Add(this->appVersionText);
|
2019-10-27 03:36:45 +00:00
|
|
|
this->Add(this->butText);
|
2019-10-17 20:20:40 +00:00
|
|
|
this->optionMenu->AddItem(this->installMenuItem);
|
|
|
|
this->optionMenu->AddItem(this->netInstallMenuItem);
|
|
|
|
this->optionMenu->AddItem(this->sigPatchesMenuItem);
|
2019-10-26 04:38:12 +00:00
|
|
|
this->optionMenu->AddItem(this->settingsMenuItem);
|
2019-10-17 20:20:40 +00:00
|
|
|
this->optionMenu->AddItem(this->exitMenuItem);
|
|
|
|
this->Add(this->optionMenu);
|
2019-10-27 03:36:45 +00:00
|
|
|
this->Add(this->awooImage);
|
2019-10-31 15:42:40 +00:00
|
|
|
this->Add(this->eggImage);
|
2019-10-27 03:36:45 +00:00
|
|
|
if (inst::config::gayMode) this->awooImage->SetVisible(false);
|
2019-10-31 15:42:40 +00:00
|
|
|
this->eggImage->SetVisible(false);
|
2019-10-17 20:20:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainPage::installMenuItem_Click() {
|
2019-11-06 22:09:47 +00:00
|
|
|
if (inst::util::getDirectoryFiles("sdmc:/", {".nsp", ".nsz"}).size()) {
|
2019-11-02 00:12:00 +00:00
|
|
|
mainApp->nspinstPage->drawMenuItems(true);
|
2019-10-23 01:33:13 +00:00
|
|
|
mainApp->LoadLayout(mainApp->nspinstPage);
|
|
|
|
} else {
|
2019-11-06 22:09:47 +00:00
|
|
|
mainApp->CreateShowDialog("No NSP or NSZ files found!", "Copy them to the root of your SD card!", {"OK"}, true);
|
2019-10-23 01:33:13 +00:00
|
|
|
}
|
2019-10-17 20:20:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainPage::netInstallMenuItem_Click() {
|
2019-10-23 01:33:13 +00:00
|
|
|
mainApp->netinstPage->startNetwork();
|
2019-10-17 20:20:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainPage::sigPatchesMenuItem_Click() {
|
2019-10-25 01:33:41 +00:00
|
|
|
sig::installSigPatches();
|
2019-10-17 20:20:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainPage::exitMenuItem_Click() {
|
|
|
|
mainApp->Close();
|
|
|
|
}
|
|
|
|
|
2019-10-26 04:38:12 +00:00
|
|
|
void MainPage::settingsMenuItem_Click() {
|
2019-10-26 20:03:15 +00:00
|
|
|
mainApp->LoadLayout(mainApp->optionspage);
|
2019-10-26 04:38:12 +00:00
|
|
|
}
|
|
|
|
|
2019-10-17 20:20:40 +00:00
|
|
|
void MainPage::onInput(u64 Down, u64 Up, u64 Held, pu::ui::Touch Pos) {
|
|
|
|
if ((Down & KEY_PLUS) || (Down & KEY_MINUS) || (Down & KEY_B)) {
|
|
|
|
mainApp->Close();
|
|
|
|
}
|
2019-10-31 15:42:40 +00:00
|
|
|
if ((Down & KEY_A) || (Up & KEY_TOUCH)) {
|
2019-10-23 02:11:21 +00:00
|
|
|
switch (this->optionMenu->GetSelectedIndex()) {
|
|
|
|
case 0:
|
|
|
|
MainPage::installMenuItem_Click();
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
MainPage::netInstallMenuItem_Click();
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
MainPage::sigPatchesMenuItem_Click();
|
|
|
|
break;
|
|
|
|
case 3:
|
2019-10-26 04:38:12 +00:00
|
|
|
MainPage::settingsMenuItem_Click();
|
|
|
|
break;
|
|
|
|
case 4:
|
2019-10-23 02:11:21 +00:00
|
|
|
MainPage::exitMenuItem_Click();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2019-10-31 15:42:40 +00:00
|
|
|
if (Down & KEY_X) {
|
|
|
|
this->awooImage->SetVisible(false);
|
|
|
|
this->eggImage->SetVisible(true);
|
|
|
|
}
|
|
|
|
if (Up & KEY_X) {
|
|
|
|
this->eggImage->SetVisible(false);
|
|
|
|
if (!inst::config::gayMode) this->awooImage->SetVisible(true);
|
|
|
|
}
|
2019-10-17 20:20:40 +00:00
|
|
|
}
|
|
|
|
}
|