mirror of
https://github.com/Huntereb/Awoo-Installer
synced 2024-11-22 19:53:07 +00:00
USB install stuff is super pretty now
This commit is contained in:
parent
aef3b8f6d0
commit
a69e48abaf
10 changed files with 37 additions and 21 deletions
|
@ -10,6 +10,7 @@ namespace inst::ui {
|
|||
PU_SMART_CTOR(MainPage)
|
||||
void installMenuItem_Click();
|
||||
void netInstallMenuItem_Click();
|
||||
void usbInstallMenuItem_Click();
|
||||
void sigPatchesMenuItem_Click();
|
||||
void settingsMenuItem_Click();
|
||||
void exitMenuItem_Click();
|
||||
|
@ -24,6 +25,7 @@ namespace inst::ui {
|
|||
pu::ui::elm::Menu::Ref optionMenu;
|
||||
pu::ui::elm::MenuItem::Ref installMenuItem;
|
||||
pu::ui::elm::MenuItem::Ref netInstallMenuItem;
|
||||
pu::ui::elm::MenuItem::Ref usbInstallMenuItem;
|
||||
pu::ui::elm::MenuItem::Ref sigPatchesMenuItem;
|
||||
pu::ui::elm::MenuItem::Ref settingsMenuItem;
|
||||
pu::ui::elm::MenuItem::Ref exitMenuItem;
|
||||
|
|
1
include/ui/usbInstPage.hpp
Normal file → Executable file
1
include/ui/usbInstPage.hpp
Normal file → Executable file
|
@ -24,6 +24,7 @@ namespace inst::ui {
|
|||
Image::Ref titleImage;
|
||||
TextBlock::Ref appVersionText;
|
||||
pu::ui::elm::Menu::Ref menu;
|
||||
Image::Ref infoImage;
|
||||
void drawMenuItems(bool clearItems);
|
||||
void selectNsp(int selectedIndex);
|
||||
};
|
||||
|
|
|
@ -14,4 +14,5 @@ namespace inst::util {
|
|||
std::string readTextFromFile(std::string ourFile);
|
||||
std::string softwareKeyboard(std::string guideText, std::string initialText, int LenMax);
|
||||
std::string getDriveFileName(std::string fileId);
|
||||
int getUsbState();
|
||||
}
|
BIN
romfs/usb-connection-waiting.png
Executable file
BIN
romfs/usb-connection-waiting.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 7.3 KiB |
BIN
romfs/usb-port.png
Executable file
BIN
romfs/usb-port.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
|
@ -120,7 +120,7 @@ namespace tin::install::nsp
|
|||
u64 downloadSizeMB = bufferedPlaceholderWriter.GetSizeBuffered() / 1000000;
|
||||
int downloadProgress = (int)(((double)bufferedPlaceholderWriter.GetSizeBuffered() / (double)bufferedPlaceholderWriter.GetTotalDataSize()) * 100.0);
|
||||
|
||||
//printf("> Download Progress: %lu/%lu MB (%i%s) (%.2f MB/s)\r", downloadSizeMB, totalSizeMB, downloadProgress, "%", speed);
|
||||
printf("> Download Progress: %lu/%lu MB (%i%s) (%.2f MB/s)\r", downloadSizeMB, totalSizeMB, downloadProgress, "%", speed);
|
||||
inst::ui::setInstInfoText("Downloading " + inst::util::formatUrlString(ncaFileName) + " at " + std::to_string(speed).substr(0, std::to_string(speed).size()-4) + "MB/s");
|
||||
inst::ui::setInstBarPerc((double)downloadProgress);
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ namespace tin::install::nsp
|
|||
u64 installSizeMB = bufferedPlaceholderWriter.GetSizeWrittenToPlaceholder() / 1000000;
|
||||
int installProgress = (int)(((double)bufferedPlaceholderWriter.GetSizeWrittenToPlaceholder() / (double)bufferedPlaceholderWriter.GetTotalDataSize()) * 100.0);
|
||||
|
||||
//printf("> Install Progress: %lu/%lu MB (%i%s)\r", installSizeMB, totalSizeMB, installProgress, "%");
|
||||
printf("> Install Progress: %lu/%lu MB (%i%s)\r", installSizeMB, totalSizeMB, installProgress, "%");
|
||||
inst::ui::setInstBarPerc((double)installProgress);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace inst::ui {
|
|||
this->appVersionText->SetColor(COLOR("#FFFFFFFF"));
|
||||
this->butText = TextBlock::New(10, 678, "\ue0e0 Select \ue0e1 Exit ", 24);
|
||||
this->butText->SetColor(COLOR("#FFFFFFFF"));
|
||||
this->optionMenu = pu::ui::elm::Menu::New(0, 93, 1280, COLOR("#67000000"), 113, (567 / 113));
|
||||
this->optionMenu = pu::ui::elm::Menu::New(0, 93, 1280, COLOR("#67000000"), 94, (567 / 94));
|
||||
this->optionMenu->SetOnFocusColor(COLOR("#00000033"));
|
||||
this->optionMenu->SetScrollbarColor(COLOR("#170909FF"));
|
||||
this->installMenuItem = pu::ui::elm::MenuItem::New("Install from SD Card");
|
||||
|
@ -29,6 +29,9 @@ namespace inst::ui {
|
|||
this->netInstallMenuItem = pu::ui::elm::MenuItem::New("Install Over LAN or Internet");
|
||||
this->netInstallMenuItem->SetColor(COLOR("#FFFFFFFF"));
|
||||
this->netInstallMenuItem->SetIcon("romfs:/cloud-download.png");
|
||||
this->usbInstallMenuItem = pu::ui::elm::MenuItem::New("Install Over USB");
|
||||
this->usbInstallMenuItem->SetColor(COLOR("#FFFFFFFF"));
|
||||
this->usbInstallMenuItem->SetIcon("romfs:/usb-port.png");
|
||||
this->sigPatchesMenuItem = pu::ui::elm::MenuItem::New("Manage Signature Patches");
|
||||
this->sigPatchesMenuItem->SetColor(COLOR("#FFFFFFFF"));
|
||||
this->sigPatchesMenuItem->SetIcon("romfs:/wrench.png");
|
||||
|
@ -48,6 +51,7 @@ namespace inst::ui {
|
|||
this->Add(this->butText);
|
||||
this->optionMenu->AddItem(this->installMenuItem);
|
||||
this->optionMenu->AddItem(this->netInstallMenuItem);
|
||||
this->optionMenu->AddItem(this->usbInstallMenuItem);
|
||||
this->optionMenu->AddItem(this->sigPatchesMenuItem);
|
||||
this->optionMenu->AddItem(this->settingsMenuItem);
|
||||
this->optionMenu->AddItem(this->exitMenuItem);
|
||||
|
@ -71,6 +75,14 @@ namespace inst::ui {
|
|||
mainApp->netinstPage->startNetwork();
|
||||
}
|
||||
|
||||
void MainPage::usbInstallMenuItem_Click() {
|
||||
if (inst::util::getUsbState() == 5) mainApp->usbinstPage->startUsb();
|
||||
else {
|
||||
mainApp->CreateShowDialog("No USB connection detected", "Plug in to a compatible device to install over USB", {"OK"}, true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void MainPage::sigPatchesMenuItem_Click() {
|
||||
sig::installSigPatches();
|
||||
}
|
||||
|
@ -96,12 +108,15 @@ namespace inst::ui {
|
|||
MainPage::netInstallMenuItem_Click();
|
||||
break;
|
||||
case 2:
|
||||
MainPage::sigPatchesMenuItem_Click();
|
||||
MainPage::usbInstallMenuItem_Click();
|
||||
break;
|
||||
case 3:
|
||||
MainPage::settingsMenuItem_Click();
|
||||
MainPage::sigPatchesMenuItem_Click();
|
||||
break;
|
||||
case 4:
|
||||
MainPage::settingsMenuItem_Click();
|
||||
break;
|
||||
case 5:
|
||||
MainPage::exitMenuItem_Click();
|
||||
break;
|
||||
default:
|
||||
|
@ -116,8 +131,5 @@ namespace inst::ui {
|
|||
this->eggImage->SetVisible(false);
|
||||
if (!inst::config::gayMode) this->awooImage->SetVisible(true);
|
||||
}
|
||||
if (Down & KEY_Y) {
|
||||
mainApp->usbinstPage->startUsb();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ namespace inst::ui {
|
|||
this->menu = pu::ui::elm::Menu::New(0, 154, 1280, COLOR("#FFFFFF00"), 84, (506 / 84));
|
||||
this->menu->SetOnFocusColor(COLOR("#00000033"));
|
||||
this->menu->SetScrollbarColor(COLOR("#17090980"));
|
||||
this->infoImage = Image::New(460, 332, "romfs:/usb-connection-waiting.png");
|
||||
this->Add(this->topRect);
|
||||
this->Add(this->infoRect);
|
||||
this->Add(this->botRect);
|
||||
|
@ -37,6 +38,7 @@ namespace inst::ui {
|
|||
this->Add(this->butText);
|
||||
this->Add(this->pageInfoText);
|
||||
this->Add(this->menu);
|
||||
this->Add(this->infoImage);
|
||||
}
|
||||
|
||||
void usbInstPage::drawMenuItems(bool clearItems) {
|
||||
|
@ -66,20 +68,23 @@ namespace inst::ui {
|
|||
}
|
||||
|
||||
void usbInstPage::startUsb() {
|
||||
this->pageInfoText->SetText("");
|
||||
this->pageInfoText->SetText("USB connection successful! Waiting for files to be sent...");
|
||||
this->butText->SetText("");
|
||||
this->menu->SetVisible(false);
|
||||
this->menu->ClearItems();
|
||||
this->infoImage->SetVisible(true);
|
||||
mainApp->LoadLayout(mainApp->usbinstPage);
|
||||
mainApp->CallForRender();
|
||||
this->ourNsps = usbInstStuff::OnSelected();
|
||||
if (!this->ourNsps.size()) {
|
||||
mainApp->LoadLayout(mainApp->mainPage);
|
||||
return;
|
||||
} else {
|
||||
this->pageInfoText->SetText("Select what files you want to install from usb, then press the Plus button!");
|
||||
this->pageInfoText->SetText("Select what files you want to install over USB, then press the Plus button!");
|
||||
this->butText->SetText("\ue0e0 Select File \ue0e3 Select All \ue0ef Install File(s) \ue0e1 Cancel ");
|
||||
this->drawMenuItems(true);
|
||||
}
|
||||
this->infoImage->SetVisible(false);
|
||||
this->menu->SetVisible(true);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -30,24 +30,13 @@ namespace usbInstStuff {
|
|||
std::vector<std::string> OnSelected() {
|
||||
Result rc = 0;
|
||||
|
||||
u32 usbState = 0;
|
||||
usbDsGetState(&usbState);
|
||||
if (usbState != 5) {
|
||||
inst::ui::mainApp->CreateShowDialog("Plug in usb ya faggot!", "", {"OK"}, false);
|
||||
return {};
|
||||
}
|
||||
|
||||
while(true) {
|
||||
hidScanInput();
|
||||
if (hidKeysDown(CONTROLLER_P1_AUTO) & KEY_B)
|
||||
break;
|
||||
rc = usbDsWaitReady(1000000);
|
||||
if (R_SUCCEEDED(rc)) break;
|
||||
else if ((rc & 0x3FFFFF) != 0xEA01)
|
||||
return {};
|
||||
}
|
||||
|
||||
inst::ui::setInstInfoText("USB install ready!\n");
|
||||
TUSHeader header;
|
||||
tin::util::USBRead(&header, sizeof(TUSHeader));
|
||||
|
||||
|
|
|
@ -167,4 +167,10 @@ namespace inst::util {
|
|||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
int getUsbState() {
|
||||
u32 usbState = 0;
|
||||
usbDsGetState(&usbState);
|
||||
return usbState;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue