2019-10-17 20:20:40 +00:00
|
|
|
#include <filesystem>
|
|
|
|
#include "MainApplication.hpp"
|
|
|
|
#include "ui/mainPage.hpp"
|
|
|
|
#include "curl.hpp"
|
2019-10-18 19:01:51 +00:00
|
|
|
#include "util.hpp"
|
2019-10-17 20:20:40 +00:00
|
|
|
#include "unzip.hpp"
|
2019-10-18 03:59:34 +00:00
|
|
|
#include "netInstall.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"));
|
|
|
|
this->topText = TextBlock::New(10, 2, "Awoo Installer", 35);
|
|
|
|
this->topText->SetColor(COLOR("#FFFFFFFF"));
|
|
|
|
this->optionMenu = pu::ui::elm::Menu::New(0, 160, 1280, COLOR("#FFFFFF00"), 80, (560 / 80));
|
|
|
|
this->optionMenu->SetOnFocusColor(COLOR("#00000033"));
|
|
|
|
this->installMenuItem = pu::ui::elm::MenuItem::New("Install NSP");
|
|
|
|
this->installMenuItem->AddOnClick(std::bind(&MainPage::installMenuItem_Click, this));
|
|
|
|
this->installMenuItem->SetColor(COLOR("#FFFFFFFF"));
|
|
|
|
this->netInstallMenuItem = pu::ui::elm::MenuItem::New("Install NSP Over LAN");
|
|
|
|
this->netInstallMenuItem->AddOnClick(std::bind(&MainPage::netInstallMenuItem_Click, this));
|
|
|
|
this->netInstallMenuItem->SetColor(COLOR("#FFFFFFFF"));
|
|
|
|
this->sigPatchesMenuItem = pu::ui::elm::MenuItem::New("Install Signature Patches");
|
|
|
|
this->sigPatchesMenuItem->AddOnClick(std::bind(&MainPage::sigPatchesMenuItem_Click, this));
|
|
|
|
this->sigPatchesMenuItem->SetColor(COLOR("#FFFFFFFF"));
|
|
|
|
this->exitMenuItem = pu::ui::elm::MenuItem::New("Exit");
|
|
|
|
this->exitMenuItem->AddOnClick(std::bind(&MainPage::exitMenuItem_Click, this));
|
|
|
|
this->exitMenuItem->SetColor(COLOR("#FFFFFFFF"));
|
|
|
|
this->Add(this->topText);
|
|
|
|
this->optionMenu->AddItem(this->installMenuItem);
|
|
|
|
this->optionMenu->AddItem(this->netInstallMenuItem);
|
|
|
|
this->optionMenu->AddItem(this->sigPatchesMenuItem);
|
|
|
|
this->optionMenu->AddItem(this->exitMenuItem);
|
|
|
|
this->Add(this->optionMenu);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainPage::installMenuItem_Click() {
|
2019-10-23 01:33:13 +00:00
|
|
|
if (util::getDirectoryFiles("sdmc:/", {".nsp"}).size()) {
|
|
|
|
mainApp->LoadLayout(mainApp->nspinstPage);
|
|
|
|
} else {
|
|
|
|
mainApp->CreateShowDialog("No NSP files found!", "NSPs can be placed on the root of your SD card!", {"OK"}, true);
|
|
|
|
}
|
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() {
|
|
|
|
std::string ourPath = appVariables::appDir + "patches.zip";
|
|
|
|
bool didDownload = curlStuff::downloadFile("http://github.com/Joonie86/hekate/releases/download/5.0.0J/Kosmos_patches_10_09_2019.zip", ourPath.c_str());
|
|
|
|
bool didExtract = false;
|
|
|
|
if (didDownload) didExtract = zipStuff::extractFile(ourPath, "sdmc:/");
|
|
|
|
else {
|
|
|
|
mainApp->CreateShowDialog("Could not download signature patches!", "", {"OK"}, true);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
std::filesystem::remove(ourPath);
|
|
|
|
if (didExtract) mainApp->CreateShowDialog("Install complete! Restart your console to apply!", "", {"OK"}, true);
|
|
|
|
else {
|
|
|
|
mainApp->CreateShowDialog("Could not extract files!", "", {"OK"}, true);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainPage::exitMenuItem_Click() {
|
|
|
|
mainApp->Close();
|
|
|
|
}
|
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|