mirror of
https://github.com/hax4dazy/TinWoo.git
synced 2025-02-09 19:25:05 +01:00
menu fixes, hd install fixed
This commit is contained in:
parent
303a76258f
commit
5e94cbf9ae
@ -9,7 +9,6 @@
|
||||
|
||||
#define COLOR(hex) pu::ui::Color::FromHex(hex)
|
||||
|
||||
|
||||
namespace inst::ui {
|
||||
extern MainApplication *mainApp;
|
||||
|
||||
@ -28,10 +27,8 @@ namespace inst::ui {
|
||||
if
|
||||
(std::filesystem::exists(inst::config::appDir + "/images/Background.png")) this->SetBackgroundImage(inst::config::appDir + "/images/Background.png");
|
||||
else
|
||||
{
|
||||
this->SetBackgroundImage("romfs:/images/Background.png");
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
this->SetBackgroundImage("romfs:/images/Background.png");
|
||||
@ -48,13 +45,13 @@ namespace inst::ui {
|
||||
this->Add(this->infoRect);
|
||||
this->Add(this->botRect);
|
||||
this->Add(this->titleImage);
|
||||
this->Add(this->appVersionText);
|
||||
this->Add(this->butText);
|
||||
this->Add(this->pageInfoText);
|
||||
this->Add(this->menu);
|
||||
}
|
||||
|
||||
void HDInstPage::drawMenuItems(bool clearItems, std::filesystem::path ourPath) {
|
||||
int myindex = this->menu->GetSelectedIndex(); //store index so when page redraws we can get the last item we checked.
|
||||
if (clearItems) this->selectedTitles = {};
|
||||
this->currentDir = ourPath;
|
||||
|
||||
@ -71,9 +68,7 @@ namespace inst::ui {
|
||||
try {
|
||||
this->ourDirectories = util::getDirsAtPath(this->currentDir);
|
||||
this->ourFiles = util::getDirectoryFiles(this->currentDir, {".nsp", ".nsz", ".xci", ".xcz"});
|
||||
}
|
||||
|
||||
catch (std::exception& e) {
|
||||
} catch (std::exception& e) {
|
||||
this->drawMenuItems(false, this->currentDir.parent_path());
|
||||
return;
|
||||
}
|
||||
@ -103,10 +98,10 @@ namespace inst::ui {
|
||||
}
|
||||
}
|
||||
this->menu->AddItem(ourEntry);
|
||||
this->menu->SetSelectedIndex(myindex); //jump to the index we saved from above
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void HDInstPage::followDirectory() {
|
||||
int selectedIndex = this->menu->GetSelectedIndex();
|
||||
int dirListSize = this->ourDirectories.size();
|
||||
@ -149,14 +144,11 @@ namespace inst::ui {
|
||||
nspInstStuff_B::installNspFromFile(this->selectedTitles, dialogResult);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void HDInstPage::onInput(u64 Down, u64 Up, u64 Held, pu::ui::TouchPoint touch_pos) {
|
||||
if (Down & HidNpadButton_B) {
|
||||
mainApp->LoadLayout(mainApp->mainPage);
|
||||
}
|
||||
//if ((Down & HidNpadButton_A) || (Up & HidGestureType_Touch)) {
|
||||
if (Down & HidNpadButton_A) {
|
||||
if ((Down & HidNpadButton_A)) {
|
||||
this->selectNsp(this->menu->GetSelectedIndex());
|
||||
if (this->ourFiles.size() == 1 && this->selectedTitles.size() == 1) {
|
||||
this->startInstall();
|
||||
|
@ -168,7 +168,7 @@ namespace inst::ui {
|
||||
}
|
||||
this->butText = TextBlock::New(10, 678, "main.buttons"_lang);
|
||||
this->butText->SetColor(COLOR("#FFFFFFFF"));
|
||||
this->optionMenu = pu::ui::elm::Menu::New(0, 95, 1280, COLOR("#343E8700"), COLOR("#4f4f4d33"), 94, 6);
|
||||
this->optionMenu = pu::ui::elm::Menu::New(0, 95, 1280, COLOR("#FFFFFF00"), COLOR("#4f4f4d33"), 94, 6);
|
||||
this->optionMenu->SetScrollbarColor(COLOR("#1A1919FF"));
|
||||
this->installMenuItem = pu::ui::elm::MenuItem::New("main.menu.sd"_lang);
|
||||
this->installMenuItem->SetColor(COLOR("#FFFFFFFF"));
|
||||
|
@ -50,10 +50,13 @@ namespace inst::ui {
|
||||
}
|
||||
|
||||
void sdInstPage::drawMenuItems(bool clearItems, std::filesystem::path ourPath) {
|
||||
int myindex = this->menu->GetSelectedIndex(); //store index so when page redraws we can get the last item we checked.
|
||||
|
||||
if (clearItems) this->selectedTitles = {};
|
||||
this->currentDir = ourPath;
|
||||
|
||||
auto pathStr = this->currentDir.string();
|
||||
|
||||
if(pathStr.length())
|
||||
{
|
||||
if(pathStr[pathStr.length() - 1] == ':')
|
||||
@ -66,7 +69,9 @@ namespace inst::ui {
|
||||
try {
|
||||
this->ourDirectories = util::getDirsAtPath(this->currentDir);
|
||||
this->ourFiles = util::getDirectoryFiles(this->currentDir, {".nsp", ".nsz", ".xci", ".xcz"});
|
||||
} catch (std::exception& e) {
|
||||
}
|
||||
|
||||
catch (std::exception& e) {
|
||||
this->drawMenuItems(false, this->currentDir.parent_path());
|
||||
return;
|
||||
}
|
||||
@ -85,6 +90,7 @@ namespace inst::ui {
|
||||
ourEntry->SetIcon("romfs:/images/icons/folder.png");
|
||||
this->menu->AddItem(ourEntry);
|
||||
}
|
||||
|
||||
for (auto& file: this->ourFiles) {
|
||||
std::string itm = file.filename().string();
|
||||
auto ourEntry = pu::ui::elm::MenuItem::New(itm);
|
||||
@ -96,6 +102,7 @@ namespace inst::ui {
|
||||
}
|
||||
}
|
||||
this->menu->AddItem(ourEntry);
|
||||
this->menu->SetSelectedIndex(myindex); //jump to the index we saved from above
|
||||
}
|
||||
}
|
||||
|
||||
@ -142,15 +149,29 @@ namespace inst::ui {
|
||||
}
|
||||
|
||||
void sdInstPage::onInput(u64 Down, u64 Up, u64 Held, pu::ui::TouchPoint touch_pos) {
|
||||
|
||||
if (Down & HidNpadButton_B) {
|
||||
mainApp->LoadLayout(mainApp->mainPage);
|
||||
}
|
||||
if ((Down & HidNpadButton_A) /*|| (Up & HidGestureType_Touch)*/) {
|
||||
|
||||
if (Down & HidNpadButton_A) {
|
||||
|
||||
int var = this->menu->GetItems().size();
|
||||
auto s = std::to_string(var);
|
||||
|
||||
if (s == "0") {
|
||||
//do nothing here because there's no items in the list, that way the app won't freeze
|
||||
}
|
||||
|
||||
else {
|
||||
this->selectNsp(this->menu->GetSelectedIndex());
|
||||
|
||||
if (this->ourFiles.size() == 1 && this->selectedTitles.size() == 1) {
|
||||
this->startInstall();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((Down & HidNpadButton_Y)) {
|
||||
if (this->selectedTitles.size() == this->ourFiles.size()) this->drawMenuItems(true, currentDir);
|
||||
else {
|
||||
@ -163,10 +184,20 @@ namespace inst::ui {
|
||||
this->drawMenuItems(false, currentDir);
|
||||
}
|
||||
}
|
||||
|
||||
if ((Down & HidNpadButton_X)) {
|
||||
inst::ui::mainApp->CreateShowDialog("inst.sd.help.title"_lang, "inst.sd.help.desc"_lang, {"common.ok"_lang}, true);
|
||||
}
|
||||
|
||||
if (Down & HidNpadButton_Plus) {
|
||||
int var = this->menu->GetItems().size();
|
||||
auto s = std::to_string(var);
|
||||
|
||||
if (s == "0") {
|
||||
//do nothing here because there's no items in the list, that way the app won't freeze
|
||||
}
|
||||
|
||||
else {
|
||||
if (this->selectedTitles.size() == 0 && this->menu->GetItems()[this->menu->GetSelectedIndex()]->GetIconPath() == "romfs:/images/icons/checkbox-blank-outline.png") {
|
||||
this->selectNsp(this->menu->GetSelectedIndex());
|
||||
}
|
||||
@ -174,3 +205,4 @@ namespace inst::ui {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -51,6 +51,7 @@ namespace inst::ui {
|
||||
}
|
||||
|
||||
void usbInstPage::drawMenuItems(bool clearItems) {
|
||||
int myindex = this->menu->GetSelectedIndex(); //store index so when page redraws we can get the last item we checked.
|
||||
if (clearItems) this->selectedTitles = {};
|
||||
this->menu->ClearItems();
|
||||
for (auto& url: this->ourTitles) {
|
||||
@ -64,6 +65,7 @@ namespace inst::ui {
|
||||
}
|
||||
}
|
||||
this->menu->AddItem(ourEntry);
|
||||
this->menu->SetSelectedIndex(myindex); //jump to the index we saved from above
|
||||
}
|
||||
}
|
||||
|
||||
@ -114,12 +116,25 @@ namespace inst::ui {
|
||||
if (Down & HidNpadButton_B) {
|
||||
mainApp->LoadLayout(mainApp->mainPage);
|
||||
}
|
||||
if ((Down & HidNpadButton_A) /*|| (Up & HidGestureType_Touch)*/) {
|
||||
|
||||
if (Down & HidNpadButton_A) {
|
||||
|
||||
int var = this->menu->GetItems().size();
|
||||
auto s = std::to_string(var);
|
||||
if (s == "0") {
|
||||
//do nothing here because there's no items in the list, that way the app won't freeze
|
||||
}
|
||||
else {
|
||||
this->selectTitle(this->menu->GetSelectedIndex());
|
||||
if (this->menu->GetItems().size() == 1 && this->selectedTitles.size() == 1) {
|
||||
this->startInstall();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ((Down & HidNpadButton_Y)) {
|
||||
if (this->selectedTitles.size() == this->menu->GetItems().size()) this->drawMenuItems(true);
|
||||
else {
|
||||
@ -130,7 +145,16 @@ namespace inst::ui {
|
||||
this->drawMenuItems(false);
|
||||
}
|
||||
}
|
||||
|
||||
if (Down & HidNpadButton_Plus) {
|
||||
int var = this->menu->GetItems().size();
|
||||
auto s = std::to_string(var);
|
||||
|
||||
if (s == "0") {
|
||||
//do nothing here because there's no items in the list, that way the app won't freeze
|
||||
}
|
||||
|
||||
else {
|
||||
if (this->selectedTitles.size() == 0) {
|
||||
this->selectTitle(this->menu->GetSelectedIndex());
|
||||
this->startInstall();
|
||||
@ -140,3 +164,4 @@ namespace inst::ui {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user