LOTS of UI related stuff, and a few other small fixes

This commit is contained in:
Huntereb 2019-10-26 23:36:45 -04:00
parent 9b09a49349
commit 64d3ed3ae4
24 changed files with 148 additions and 48 deletions

View file

@ -2,6 +2,7 @@
#include <string>
namespace inst::ui {
void setTopInstInfoText(std::string ourText);
void setInstInfoText(std::string ourText);
void setInstBarPerc(double ourPercent);
void hideInstBar(bool hidden);

View file

@ -10,8 +10,12 @@ namespace inst::ui {
PU_SMART_CTOR(instPage)
void onInput(u64 Down, u64 Up, u64 Held, pu::ui::Touch Pos);
TextBlock::Ref pageInfoText;
TextBlock::Ref installInfoText;
pu::ui::elm::ProgressBar::Ref installBar;
Image::Ref awooImage;
private:
TextBlock::Ref topText;
Rectangle::Ref infoRect;
Rectangle::Ref topRect;
Image::Ref titleImage;
};
}

View file

@ -14,19 +14,17 @@ namespace inst::ui {
void settingsMenuItem_Click();
void exitMenuItem_Click();
void onInput(u64 Down, u64 Up, u64 Held, pu::ui::Touch Pos);
Image::Ref awooImage;
private:
TextBlock::Ref topText;
TextBlock::Ref butText;
Rectangle::Ref topRect;
Rectangle::Ref botRect;
Image::Ref titleImage;
pu::ui::elm::Menu::Ref optionMenu;
pu::ui::elm::MenuItem::Ref installMenuItem;
pu::ui::elm::MenuItem::Ref netInstallMenuItem;
pu::ui::elm::MenuItem::Ref sigPatchesMenuItem;
pu::ui::elm::MenuItem::Ref settingsMenuItem;
pu::ui::elm::MenuItem::Ref exitMenuItem;
TextBlock::Ref infoText;
Rectangle::Ref topRect;
TextBlock::Ref bottomText;
Image::Ref preview;
Image::Ref image;
std::string url;
};
}

View file

@ -8,12 +8,16 @@ namespace inst::ui {
public:
netInstPage();
PU_SMART_CTOR(netInstPage)
void startInstall();
void startInstall(bool urlMode);
void startNetwork();
void onInput(u64 Down, u64 Up, u64 Held, pu::ui::Touch Pos);
TextBlock::Ref pageInfoText;
private:
TextBlock::Ref topText;
TextBlock::Ref butText;
Rectangle::Ref topRect;
Rectangle::Ref infoRect;
Rectangle::Ref botRect;
Image::Ref titleImage;
pu::ui::elm::Menu::Ref menu;
};
}

View file

@ -12,7 +12,11 @@ namespace inst::ui {
void onInput(u64 Down, u64 Up, u64 Held, pu::ui::Touch Pos);
TextBlock::Ref pageInfoText;
private:
TextBlock::Ref topText;
TextBlock::Ref butText;
Rectangle::Ref topRect;
Rectangle::Ref infoRect;
Rectangle::Ref botRect;
Image::Ref titleImage;
pu::ui::elm::Menu::Ref menu;
};
}

View file

@ -10,7 +10,11 @@ namespace inst::ui {
PU_SMART_CTOR(optionsPage)
void onInput(u64 Down, u64 Up, u64 Held, pu::ui::Touch Pos);
private:
TextBlock::Ref topText;
TextBlock::Ref butText;
Rectangle::Ref topRect;
Rectangle::Ref infoRect;
Rectangle::Ref botRect;
Image::Ref titleImage;
TextBlock::Ref pageInfoText;
pu::ui::elm::Menu::Ref menu;
void setMenuText();

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

BIN
romfs/background.jpg Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

BIN
romfs/cloud-download.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

BIN
romfs/exit-run.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

BIN
romfs/logo.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

BIN
romfs/micro-sd.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
romfs/package-down.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 686 B

BIN
romfs/package.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 615 B

BIN
romfs/settings.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

BIN
romfs/wrench.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

View file

@ -97,6 +97,8 @@ namespace netInstStuff{
inst::ui::loadInstallScreen();
if (ourStorage) m_destStorageId = FsStorageId_NandUser;
try {
inst::ui::setTopInstInfoText("Installing " + inst::util::formatUrlString(ourUrl) + "...");
tin::install::nsp::HTTPNSP httpNSP(ourUrl);
printf("%s %s\n", "NSP_INSTALL_FROM", ourUrl.c_str());

View file

@ -14,11 +14,16 @@
namespace inst::ui {
extern MainApplication *mainApp;
void setInstInfoText(std::string ourText){
void setTopInstInfoText(std::string ourText){
mainApp->instpage->pageInfoText->SetText(ourText);
mainApp->CallForRender();
}
void setInstInfoText(std::string ourText){
mainApp->instpage->installInfoText->SetText(ourText);
mainApp->CallForRender();
}
void setInstBarPerc(double ourPercent){
mainApp->instpage->installBar->SetVisible(true);
mainApp->instpage->installBar->SetProgress(ourPercent);
@ -31,6 +36,7 @@ namespace inst::ui {
void loadInstallScreen(){
mainApp->instpage->pageInfoText->SetText("");
mainApp->instpage->installInfoText->SetText("");
mainApp->instpage->installBar->SetProgress(0);
mainApp->instpage->installBar->SetVisible(false);
mainApp->LoadLayout(mainApp->instpage);
@ -57,6 +63,8 @@ namespace nspInstStuff {
try
{
inst::ui::setTopInstInfoText("Installing " + ourNsp + "...");
nx::fs::IFileSystem fileSystem;
fileSystem.OpenFileSystemWithId(path, FsFileSystemType_ApplicationPackage, 0);
tin::install::nsp::SimpleFileSystem simpleFS(fileSystem, "/", path + "/");
@ -90,7 +98,7 @@ namespace nspInstStuff {
}
}
if(nspInstalled) if(inst::ui::mainApp->CreateShowDialog(ourNsp + " installed! Delete NSP from SD card?", "", {"No","Yes"}, false)) std::filesystem::remove("sdmc:/" + ourNsp);
if(nspInstalled) if(inst::ui::mainApp->CreateShowDialog(ourNsp + " installed! Delete NSP from SD card?", "", {"No","Yes"}, false) == 1) std::filesystem::remove("sdmc:/" + ourNsp);
printf("Done");
appletUnlockExit();

View file

@ -1,6 +1,7 @@
#include <filesystem>
#include "ui/MainApplication.hpp"
#include "ui/instPage.hpp"
#include "util/config.hpp"
#define COLOR(hex) pu::ui::Color::FromHex(hex)
@ -9,15 +10,25 @@ namespace inst::ui {
instPage::instPage() : Layout::Layout() {
this->SetBackgroundColor(COLOR("#670000FF"));
this->topText = TextBlock::New(10, 2, "Awoo Installer", 35);
this->topText->SetColor(COLOR("#FFFFFFFF"));
this->pageInfoText = TextBlock::New(10, 180, "", 35);
this->SetBackgroundImage("romfs:/background.jpg");
this->topRect = Rectangle::New(0, 0, 1280, 93, COLOR("#170909FF"));
this->infoRect = Rectangle::New(0, 93, 1280, 60, COLOR("#17090980"));
this->titleImage = Image::New(0, 0, "romfs:/logo.png");
this->pageInfoText = TextBlock::New(10, 109, "", 30);
this->pageInfoText->SetColor(COLOR("#FFFFFFFF"));
this->installBar = pu::ui::elm::ProgressBar::New(340, 360, 600, 48, 100.0f);
this->installInfoText = TextBlock::New(15, 568, "", 22);
this->installInfoText->SetColor(COLOR("#FFFFFFFF"));
this->installBar = pu::ui::elm::ProgressBar::New(10, 600, 800, 40, 100.0f);
this->installBar->SetColor(COLOR("#222222FF"));
this->Add(this->topText);
this->awooImage = Image::New(510, 166, "romfs:/awoos/7d8a05cddfef6da4901b20d2698d5a71.png");
this->Add(this->topRect);
this->Add(this->infoRect);
this->Add(this->titleImage);
this->Add(this->pageInfoText);
this->Add(this->installInfoText);
this->Add(this->installBar);
this->Add(this->awooImage);
if (inst::config::gayMode) this->awooImage->SetVisible(false);
}
void instPage::onInput(u64 Down, u64 Up, u64 Held, pu::ui::Touch Pos) {

View file

@ -2,6 +2,7 @@
#include "ui/MainApplication.hpp"
#include "ui/mainPage.hpp"
#include "util/util.hpp"
#include "util/config.hpp"
#include "sigInstall.hpp"
#define COLOR(hex) pu::ui::Color::FromHex(hex)
@ -11,27 +12,43 @@ namespace inst::ui {
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->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");
this->butText = TextBlock::New(10, 676, "(A)-Select (B)-Exit", 30);
this->butText->SetColor(COLOR("#FFFFFFFF"));
this->optionMenu = pu::ui::elm::Menu::New(0, 93, 1280, COLOR("#67000000"), 113, (567 / 113));
this->optionMenu->SetOnFocusColor(COLOR("#00000033"));
this->installMenuItem = pu::ui::elm::MenuItem::New("Install NSP");
this->optionMenu->SetScrollbarColor(COLOR("#170909FF"));
this->installMenuItem = pu::ui::elm::MenuItem::New("Install NSP from SD Card");
this->installMenuItem->SetColor(COLOR("#FFFFFFFF"));
this->installMenuItem->SetIcon("romfs:/micro-sd.png");
this->netInstallMenuItem = pu::ui::elm::MenuItem::New("Install NSP Over LAN or Internet");
this->netInstallMenuItem->SetColor(COLOR("#FFFFFFFF"));
this->netInstallMenuItem->SetIcon("romfs:/cloud-download.png");
this->sigPatchesMenuItem = pu::ui::elm::MenuItem::New("Manage Signature Patches");
this->sigPatchesMenuItem->SetColor(COLOR("#FFFFFFFF"));
this->sigPatchesMenuItem->SetIcon("romfs:/wrench.png");
this->settingsMenuItem = pu::ui::elm::MenuItem::New("Settings");
this->settingsMenuItem->SetColor(COLOR("#FFFFFFFF"));
this->settingsMenuItem->SetIcon("romfs:/settings.png");
this->exitMenuItem = pu::ui::elm::MenuItem::New("Exit");
this->exitMenuItem->SetColor(COLOR("#FFFFFFFF"));
this->Add(this->topText);
this->exitMenuItem->SetIcon("romfs:/exit-run.png");
this->awooImage = Image::New(410, 190, "romfs:/awoos/5bbdbcf9a5625cd307c9e9bc360d78bd.png");
this->Add(this->topRect);
this->Add(this->botRect);
this->Add(this->titleImage);
this->Add(this->butText);
this->optionMenu->AddItem(this->installMenuItem);
this->optionMenu->AddItem(this->netInstallMenuItem);
this->optionMenu->AddItem(this->sigPatchesMenuItem);
this->optionMenu->AddItem(this->settingsMenuItem);
this->optionMenu->AddItem(this->exitMenuItem);
this->Add(this->optionMenu);
this->Add(this->awooImage);
if (inst::config::gayMode) this->awooImage->SetVisible(false);
}
void MainPage::installMenuItem_Click() {

View file

@ -14,19 +14,30 @@ namespace inst::ui {
netInstPage::netInstPage() : Layout::Layout() {
this->SetBackgroundColor(COLOR("#670000FF"));
this->topText = TextBlock::New(10, 2, "Awoo Installer", 35);
this->topText->SetColor(COLOR("#FFFFFFFF"));
this->pageInfoText = TextBlock::New(10, 45, "", 35);
this->SetBackgroundImage("romfs:/background.jpg");
this->topRect = Rectangle::New(0, 0, 1280, 93, COLOR("#170909FF"));
this->infoRect = Rectangle::New(0, 93, 1280, 60, COLOR("#17090980"));
this->botRect = Rectangle::New(0, 660, 1280, 60, COLOR("#17090980"));
this->titleImage = Image::New(0, 0, "romfs:/logo.png");
this->pageInfoText = TextBlock::New(10, 109, "", 30);
this->pageInfoText->SetColor(COLOR("#FFFFFFFF"));
this->menu = pu::ui::elm::Menu::New(0, 160, 1280, COLOR("#FFFFFF00"), 80, (560 / 80));
this->butText = TextBlock::New(10, 676, "", 30);
this->butText->SetColor(COLOR("#FFFFFFFF"));
this->menu = pu::ui::elm::Menu::New(0, 153, 1280, COLOR("#FFFFFF00"), 84, (506 / 84));
this->menu->SetOnFocusColor(COLOR("#00000033"));
this->Add(this->topText);
this->menu->SetScrollbarColor(COLOR("#17090980"));
this->Add(this->topRect);
this->Add(this->infoRect);
this->Add(this->botRect);
this->Add(this->titleImage);
this->Add(this->butText);
this->Add(this->pageInfoText);
this->Add(this->menu);
}
void netInstPage::startNetwork() {
this->pageInfoText->SetText("");
this->butText->SetText("(B)-Cancel (Y)-Install From URL");
this->menu->SetVisible(false);
this->menu->ClearItems();
mainApp->LoadLayout(mainApp->netinstPage);
@ -41,13 +52,13 @@ namespace inst::ui {
rc = swkbdCreate(&kbd, 0);
if (R_SUCCEEDED(rc)) {
swkbdConfigMakePresetDefault(&kbd);
swkbdConfigSetHeaderText(&kbd, "Enter the location of a NSP! URL must be HTTP.");
swkbdConfigSetGuideText(&kbd, "Enter the location of a NSP! URL must be HTTP.");
swkbdConfigSetInitialText(&kbd, "http://");
rc = swkbdShow(&kbd, tmpoutstr, sizeof(tmpoutstr));
swkbdClose(&kbd);
if (R_SUCCEEDED(rc) && (tmpoutstr[0] != 0 || tmpoutstr != "http://")) {
if (R_SUCCEEDED(rc) && tmpoutstr[0] != 0) {
ourUrls[0] = tmpoutstr;
netInstPage::startInstall();
netInstPage::startInstall(true);
return;
} else {
mainApp->LoadLayout(mainApp->mainPage);
@ -55,11 +66,13 @@ namespace inst::ui {
}
}
} else {
this->pageInfoText->SetText("Select a NSP to install! Press B to cancel!");
this->pageInfoText->SetText("Select a NSP to install!");
this->butText->SetText("(A)-Install NSP (B)-Cancel");
for (auto& url: ourUrls) {
pu::String itm = inst::util::formatUrlString(url);
auto ourEntry = pu::ui::elm::MenuItem::New(itm);
ourEntry->SetColor(COLOR("#FFFFFFFF"));
ourEntry->SetIcon("romfs:/package-down.png");
this->menu->AddItem(ourEntry);
}
}
@ -67,10 +80,14 @@ namespace inst::ui {
return;
}
void netInstPage::startInstall() {
void netInstPage::startInstall(bool urlMode) {
std::string ourUrl = ourUrls[this->menu->GetSelectedIndex()];
int dialogResult = mainApp->CreateShowDialog("Where should " + inst::util::formatUrlString(ourUrl) + " be installed to?", "Press B to cancel", {"SD", "Internal Storage"}, false);
if (dialogResult == -1) return;
if (dialogResult == -1 && !urlMode) return;
else if (dialogResult == -1 && urlMode) {
mainApp->LoadLayout(mainApp->mainPage);
return;
}
netInstStuff::installNspLan(ourUrl, dialogResult);
return;
}
@ -80,7 +97,7 @@ namespace inst::ui {
mainApp->LoadLayout(mainApp->mainPage);
}
if (Down & KEY_A) {
if (this->menu->IsVisible()) startInstall();
if (this->menu->IsVisible()) startInstall(false);
}
}
}

View file

@ -14,20 +14,31 @@ namespace inst::ui {
nspInstPage::nspInstPage() : Layout::Layout() {
this->SetBackgroundColor(COLOR("#670000FF"));
this->topText = TextBlock::New(10, 2, "Awoo Installer", 35);
this->topText->SetColor(COLOR("#FFFFFFFF"));
this->pageInfoText = TextBlock::New(10, 45, "Select a NSP to install! Put NSP files on the root of your SD!", 35);
this->SetBackgroundImage("romfs:/background.jpg");
this->topRect = Rectangle::New(0, 0, 1280, 93, COLOR("#170909FF"));
this->infoRect = Rectangle::New(0, 93, 1280, 60, COLOR("#17090980"));
this->botRect = Rectangle::New(0, 660, 1280, 60, COLOR("#17090980"));
this->titleImage = Image::New(0, 0, "romfs:/logo.png");
this->pageInfoText = TextBlock::New(10, 109, "Select a NSP to install! Put NSP files on the root of your SD!", 30);
this->pageInfoText->SetColor(COLOR("#FFFFFFFF"));
this->menu = pu::ui::elm::Menu::New(0, 160, 1280, COLOR("#FFFFFF00"), 80, (560 / 80));
this->butText = TextBlock::New(10, 676, "(A)-Install NSP (B)-Cancel", 30);
this->butText->SetColor(COLOR("#FFFFFFFF"));
this->menu = pu::ui::elm::Menu::New(0, 153, 1280, COLOR("#FFFFFF00"), 84, (506 / 84));
this->menu->SetOnFocusColor(COLOR("#00000033"));
this->menu->SetScrollbarColor(COLOR("#17090980"));
ourFiles = util::getDirectoryFiles("sdmc:/", {".nsp"});
for (auto& file: ourFiles) {
pu::String itm = file.string().erase(0, 6);
auto ourEntry = pu::ui::elm::MenuItem::New(itm);
ourEntry->SetColor(COLOR("#FFFFFFFF"));
ourEntry->SetIcon("romfs:/package.png");
this->menu->AddItem(ourEntry);
}
this->Add(this->topText);
this->Add(this->topRect);
this->Add(this->infoRect);
this->Add(this->botRect);
this->Add(this->titleImage);
this->Add(this->butText);
this->Add(this->pageInfoText);
this->Add(this->menu);
}

View file

@ -1,6 +1,7 @@
#include <filesystem>
#include "ui/MainApplication.hpp"
#include "ui/mainPage.hpp"
#include "ui/instPage.hpp"
#include "ui/optionsPage.hpp"
#include "util/util.hpp"
#include "util/config.hpp"
@ -14,13 +15,23 @@ namespace inst::ui {
optionsPage::optionsPage() : Layout::Layout() {
this->SetBackgroundColor(COLOR("#670000FF"));
this->topText = TextBlock::New(10, 2, "Awoo Installer", 35);
this->topText->SetColor(COLOR("#FFFFFFFF"));
this->pageInfoText = TextBlock::New(10, 45, "Settings Menu", 35);
this->SetBackgroundImage("romfs:/background.jpg");
this->topRect = Rectangle::New(0, 0, 1280, 93, COLOR("#170909FF"));
this->infoRect = Rectangle::New(0, 93, 1280, 60, COLOR("#17090980"));
this->botRect = Rectangle::New(0, 660, 1280, 60, COLOR("#17090980"));
this->titleImage = Image::New(0, 0, "romfs:/logo.png");
this->pageInfoText = TextBlock::New(10, 109, "Change application settings!", 30);
this->pageInfoText->SetColor(COLOR("#FFFFFFFF"));
this->menu = pu::ui::elm::Menu::New(0, 160, 1280, COLOR("#FFFFFF00"), 80, (560 / 80));
this->butText = TextBlock::New(10, 676, "(A)-Toggle (B)-Cancel", 30);
this->butText->SetColor(COLOR("#FFFFFFFF"));
this->menu = pu::ui::elm::Menu::New(0, 153, 1280, COLOR("#FFFFFF00"), 84, (506 / 84));
this->menu->SetOnFocusColor(COLOR("#00000033"));
this->Add(this->topText);
this->menu->SetScrollbarColor(COLOR("#17090980"));
this->Add(this->topRect);
this->Add(this->infoRect);
this->Add(this->botRect);
this->Add(this->titleImage);
this->Add(this->butText);
this->Add(this->pageInfoText);
optionsPage::setMenuText();
this->Add(this->menu);
@ -54,8 +65,16 @@ namespace inst::ui {
optionsPage::setMenuText();
break;
case 1:
if (inst::config::gayMode) inst::config::gayMode = false;
else inst::config::gayMode = true;
if (inst::config::gayMode) {
inst::config::gayMode = false;
mainApp->mainPage->awooImage->SetVisible(true);
mainApp->instpage->awooImage->SetVisible(true);
}
else {
inst::config::gayMode = true;
mainApp->mainPage->awooImage->SetVisible(false);
mainApp->instpage->awooImage->SetVisible(false);
}
inst::config::setConfig();
optionsPage::setMenuText();
break;