2019-10-18 15:01:51 -04:00
|
|
|
#include <filesystem>
|
|
|
|
#include "ui/MainApplication.hpp"
|
|
|
|
#include "ui/mainPage.hpp"
|
|
|
|
#include "ui/netInstPage.hpp"
|
|
|
|
#include "util.hpp"
|
|
|
|
#include "netInstall.hpp"
|
|
|
|
|
|
|
|
#define COLOR(hex) pu::ui::Color::FromHex(hex)
|
|
|
|
|
|
|
|
namespace inst::ui {
|
|
|
|
extern MainApplication *mainApp;
|
|
|
|
|
|
|
|
std::vector<std::string> ourUrls;
|
|
|
|
|
|
|
|
netInstPage::netInstPage() : Layout::Layout() {
|
|
|
|
this->SetBackgroundColor(COLOR("#670000FF"));
|
|
|
|
this->topText = TextBlock::New(10, 2, "Awoo Installer", 35);
|
|
|
|
this->topText->SetColor(COLOR("#FFFFFFFF"));
|
2019-10-20 21:10:27 -04:00
|
|
|
this->pageInfoText = TextBlock::New(10, 45, "", 35);
|
2019-10-18 15:01:51 -04:00
|
|
|
this->pageInfoText->SetColor(COLOR("#FFFFFFFF"));
|
2019-10-22 21:33:13 -04:00
|
|
|
this->menu = pu::ui::elm::Menu::New(0, 160, 1280, COLOR("#FFFFFF00"), 80, (560 / 80));
|
|
|
|
this->menu->SetOnFocusColor(COLOR("#00000033"));
|
2019-10-18 15:01:51 -04:00
|
|
|
this->Add(this->topText);
|
|
|
|
this->Add(this->pageInfoText);
|
2019-10-22 21:33:13 -04:00
|
|
|
this->Add(this->menu);
|
2019-10-18 15:01:51 -04:00
|
|
|
}
|
|
|
|
|
2019-10-22 21:33:13 -04:00
|
|
|
void netInstPage::startNetwork() {
|
2019-10-24 15:53:54 -04:00
|
|
|
this->pageInfoText->SetText("");
|
2019-10-22 21:33:13 -04:00
|
|
|
this->menu->SetVisible(false);
|
|
|
|
this->menu->ClearItems();
|
2019-10-20 21:10:27 -04:00
|
|
|
mainApp->LoadLayout(mainApp->netinstPage);
|
|
|
|
ourUrls = netInstStuff::OnSelected();
|
2019-10-22 21:33:13 -04:00
|
|
|
if (!ourUrls.size()) {
|
2019-10-24 15:53:54 -04:00
|
|
|
mainApp->LoadLayout(mainApp->mainPage);
|
2019-10-20 21:10:27 -04:00
|
|
|
return;
|
2019-10-22 21:33:13 -04:00
|
|
|
} else {
|
2019-10-24 15:53:54 -04:00
|
|
|
this->pageInfoText->SetText("Select a NSP to install! Press B to cancel!");
|
2019-10-22 21:33:13 -04:00
|
|
|
for (auto& url: ourUrls) {
|
|
|
|
pu::String itm = url;
|
|
|
|
auto ourEntry = pu::ui::elm::MenuItem::New(itm);
|
|
|
|
ourEntry->SetColor(COLOR("#FFFFFFFF"));
|
|
|
|
this->menu->AddItem(ourEntry);
|
|
|
|
}
|
2019-10-20 21:10:27 -04:00
|
|
|
}
|
2019-10-22 21:33:13 -04:00
|
|
|
this->menu->SetVisible(true);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void netInstPage::startInstall() {
|
|
|
|
std::string ourUrl = ourUrls[this->menu->GetSelectedIndex()];
|
|
|
|
int dialogResult = mainApp->CreateShowDialog("Where should " + ourUrl + " be installed to?", "Press B to cancel", {"SD", "Internal Storage"}, false);
|
|
|
|
if (dialogResult == -1) return;
|
2019-10-24 15:53:54 -04:00
|
|
|
netInstStuff::installNspLan(ourUrl, dialogResult);
|
2019-10-20 21:10:27 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-10-18 15:01:51 -04:00
|
|
|
void netInstPage::onInput(u64 Down, u64 Up, u64 Held, pu::ui::Touch Pos) {
|
|
|
|
if (Down & KEY_B) {
|
|
|
|
mainApp->LoadLayout(mainApp->mainPage);
|
|
|
|
}
|
2019-10-22 21:33:13 -04:00
|
|
|
if (Down & KEY_A) {
|
|
|
|
if (this->menu->IsVisible()) startInstall();
|
|
|
|
}
|
2019-10-18 15:01:51 -04:00
|
|
|
}
|
|
|
|
}
|