mirror of
https://github.com/Huntereb/Awoo-Installer
synced 2024-11-26 21:50:26 +00:00
Select all option, show count of how many selected
This commit is contained in:
parent
9a59359bd0
commit
f7f0d6186d
4 changed files with 40 additions and 22 deletions
|
@ -22,6 +22,6 @@ namespace inst::ui {
|
||||||
Image::Ref titleImage;
|
Image::Ref titleImage;
|
||||||
pu::ui::elm::Menu::Ref menu;
|
pu::ui::elm::Menu::Ref menu;
|
||||||
void drawMenuItems(bool clearItems);
|
void drawMenuItems(bool clearItems);
|
||||||
void selectNsp();
|
void selectNsp(int selectedIndex);
|
||||||
};
|
};
|
||||||
}
|
}
|
|
@ -22,6 +22,6 @@ namespace inst::ui {
|
||||||
Rectangle::Ref botRect;
|
Rectangle::Ref botRect;
|
||||||
Image::Ref titleImage;
|
Image::Ref titleImage;
|
||||||
pu::ui::elm::Menu::Ref menu;
|
pu::ui::elm::Menu::Ref menu;
|
||||||
void selectNsp();
|
void selectNsp(int selectedIndex);
|
||||||
};
|
};
|
||||||
}
|
}
|
|
@ -54,12 +54,12 @@ namespace inst::ui {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void netInstPage::selectNsp() {
|
void netInstPage::selectNsp(int selectedIndex) {
|
||||||
if (this->menu->GetItems()[this->menu->GetSelectedIndex()]->GetIcon() == "romfs:/check-box-outline.png") {
|
if (this->menu->GetItems()[selectedIndex]->GetIcon() == "romfs:/check-box-outline.png") {
|
||||||
for (long unsigned int i = 0; i < netInstPage::selectedUrls.size(); i++) {
|
for (long unsigned int i = 0; i < netInstPage::selectedUrls.size(); i++) {
|
||||||
if (netInstPage::selectedUrls[i] == netInstPage::ourUrls[this->menu->GetSelectedIndex()]) netInstPage::selectedUrls.erase(netInstPage::selectedUrls.begin() + i);
|
if (netInstPage::selectedUrls[i] == netInstPage::ourUrls[selectedIndex]) netInstPage::selectedUrls.erase(netInstPage::selectedUrls.begin() + i);
|
||||||
}
|
}
|
||||||
} else netInstPage::selectedUrls.push_back(netInstPage::ourUrls[this->menu->GetSelectedIndex()]);
|
} else netInstPage::selectedUrls.push_back(netInstPage::ourUrls[selectedIndex]);
|
||||||
netInstPage::drawMenuItems(false);
|
netInstPage::drawMenuItems(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ namespace inst::ui {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this->pageInfoText->SetText("Select NSP files to install from the server, then press the Plus button!");
|
this->pageInfoText->SetText("Select NSP files to install from the server, then press the Plus button!");
|
||||||
this->butText->SetText("\ue0e0 Select NSP \ue0ef Install NSP(s) \ue0e1 Cancel ");
|
this->butText->SetText("\ue0e0 Select NSP \ue0e3 Select All \ue0ef Install NSP(s) \ue0e1 Cancel ");
|
||||||
netInstPage::drawMenuItems(true);
|
netInstPage::drawMenuItems(true);
|
||||||
}
|
}
|
||||||
this->menu->SetVisible(true);
|
this->menu->SetVisible(true);
|
||||||
|
@ -111,7 +111,7 @@ namespace inst::ui {
|
||||||
int dialogResult = -1;
|
int dialogResult = -1;
|
||||||
if (netInstPage::selectedUrls.size() == 1) {
|
if (netInstPage::selectedUrls.size() == 1) {
|
||||||
dialogResult = mainApp->CreateShowDialog("Where should " + inst::util::shortenString(inst::util::formatUrlString(netInstPage::selectedUrls[0]), 48, true) + " be installed to?", "Press B to cancel", {"SD Card", "Internal Storage"}, false);
|
dialogResult = mainApp->CreateShowDialog("Where should " + inst::util::shortenString(inst::util::formatUrlString(netInstPage::selectedUrls[0]), 48, true) + " be installed to?", "Press B to cancel", {"SD Card", "Internal Storage"}, false);
|
||||||
} else dialogResult = mainApp->CreateShowDialog("Where should the selected files be installed to?", "Press B to cancel", {"SD Card", "Internal Storage"}, false);
|
} else dialogResult = mainApp->CreateShowDialog("Where should the selected " + std::to_string(netInstPage::selectedUrls.size()) + " files be installed to?", "Press B to cancel", {"SD Card", "Internal Storage"}, false);
|
||||||
if (dialogResult == -1 && !urlMode) return;
|
if (dialogResult == -1 && !urlMode) return;
|
||||||
else if (dialogResult == -1 && urlMode) {
|
else if (dialogResult == -1 && urlMode) {
|
||||||
mainApp->LoadLayout(mainApp->mainPage);
|
mainApp->LoadLayout(mainApp->mainPage);
|
||||||
|
@ -126,17 +126,26 @@ namespace inst::ui {
|
||||||
mainApp->LoadLayout(mainApp->mainPage);
|
mainApp->LoadLayout(mainApp->mainPage);
|
||||||
}
|
}
|
||||||
if ((Down & KEY_A) || (Up & KEY_TOUCH)) {
|
if ((Down & KEY_A) || (Up & KEY_TOUCH)) {
|
||||||
netInstPage::selectNsp();
|
netInstPage::selectNsp(this->menu->GetSelectedIndex());
|
||||||
if (this->menu->GetItems().size() == 1) {
|
if (this->menu->GetItems().size() == 1) {
|
||||||
netInstPage::startInstall(false);
|
netInstPage::startInstall(false);
|
||||||
netInstPage::selectNsp();
|
netInstPage::selectNsp(this->menu->GetSelectedIndex());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ((Down & KEY_Y)) {
|
||||||
|
if (netInstPage::selectedUrls.size() == this->menu->GetItems().size()) netInstPage::drawMenuItems(true);
|
||||||
|
else {
|
||||||
|
for (long unsigned int i = 0; i < this->menu->GetItems().size(); i++) {
|
||||||
|
if (this->menu->GetItems()[i]->GetIcon() == "romfs:/check-box-outline.png") continue;
|
||||||
|
else netInstPage::selectNsp(i);
|
||||||
|
}
|
||||||
|
netInstPage::drawMenuItems(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Down & KEY_PLUS) {
|
if (Down & KEY_PLUS) {
|
||||||
if (netInstPage::selectedUrls.size() == 0) {
|
if (netInstPage::selectedUrls.size() == 0) {
|
||||||
netInstPage::selectNsp();
|
netInstPage::selectNsp(this->menu->GetSelectedIndex());
|
||||||
netInstPage::startInstall(false);
|
netInstPage::startInstall(false);
|
||||||
netInstPage::selectNsp();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
netInstPage::startInstall(false);
|
netInstPage::startInstall(false);
|
||||||
|
|
|
@ -22,7 +22,7 @@ namespace inst::ui {
|
||||||
this->titleImage = Image::New(0, 0, "romfs:/logo.png");
|
this->titleImage = Image::New(0, 0, "romfs:/logo.png");
|
||||||
this->pageInfoText = TextBlock::New(10, 109, "Select NSP files to install, then press the Plus button!", 30);
|
this->pageInfoText = TextBlock::New(10, 109, "Select NSP files to install, then press the Plus button!", 30);
|
||||||
this->pageInfoText->SetColor(COLOR("#FFFFFFFF"));
|
this->pageInfoText->SetColor(COLOR("#FFFFFFFF"));
|
||||||
this->butText = TextBlock::New(10, 678, "\ue0e0 Select NSP \ue0ef Install NSP(s) \ue0e2 Help \ue0e1 Cancel ", 24);
|
this->butText = TextBlock::New(10, 678, "\ue0e0 Select NSP \ue0e3 Select All \ue0ef Install NSP(s) \ue0e2 Help \ue0e1 Cancel ", 24);
|
||||||
this->butText->SetColor(COLOR("#FFFFFFFF"));
|
this->butText->SetColor(COLOR("#FFFFFFFF"));
|
||||||
this->menu = pu::ui::elm::Menu::New(0, 154, 1280, COLOR("#FFFFFF00"), 84, (506 / 84));
|
this->menu = pu::ui::elm::Menu::New(0, 154, 1280, COLOR("#FFFFFF00"), 84, (506 / 84));
|
||||||
this->menu->SetOnFocusColor(COLOR("#00000033"));
|
this->menu->SetOnFocusColor(COLOR("#00000033"));
|
||||||
|
@ -54,12 +54,12 @@ namespace inst::ui {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void nspInstPage::selectNsp() {
|
void nspInstPage::selectNsp(int selectedIndex) {
|
||||||
if (this->menu->GetItems()[this->menu->GetSelectedIndex()]->GetIcon() == "romfs:/check-box-outline.png") {
|
if (this->menu->GetItems()[selectedIndex]->GetIcon() == "romfs:/check-box-outline.png") {
|
||||||
for (long unsigned int i = 0; i < nspInstPage::selectedNsps.size(); i++) {
|
for (long unsigned int i = 0; i < nspInstPage::selectedNsps.size(); i++) {
|
||||||
if (nspInstPage::selectedNsps[i] == nspInstPage::ourFiles[this->menu->GetSelectedIndex()].string()) nspInstPage::selectedNsps.erase(nspInstPage::selectedNsps.begin() + i);
|
if (nspInstPage::selectedNsps[i] == nspInstPage::ourFiles[selectedIndex].string()) nspInstPage::selectedNsps.erase(nspInstPage::selectedNsps.begin() + i);
|
||||||
}
|
}
|
||||||
} else nspInstPage::selectedNsps.push_back(nspInstPage::ourFiles[this->menu->GetSelectedIndex()]);
|
} else nspInstPage::selectedNsps.push_back(nspInstPage::ourFiles[selectedIndex]);
|
||||||
nspInstPage::drawMenuItems(false);
|
nspInstPage::drawMenuItems(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ namespace inst::ui {
|
||||||
if (nspInstPage::selectedNsps.size() == 1) {
|
if (nspInstPage::selectedNsps.size() == 1) {
|
||||||
std::string ourNsp = nspInstPage::selectedNsps[0].string().erase(0, 6);
|
std::string ourNsp = nspInstPage::selectedNsps[0].string().erase(0, 6);
|
||||||
dialogResult = mainApp->CreateShowDialog("Where should " + inst::util::shortenString(ourNsp, 48, true) + " be installed to?", "Press B to cancel", {"SD Card", "Internal Storage"}, false);
|
dialogResult = mainApp->CreateShowDialog("Where should " + inst::util::shortenString(ourNsp, 48, true) + " be installed to?", "Press B to cancel", {"SD Card", "Internal Storage"}, false);
|
||||||
} else dialogResult = mainApp->CreateShowDialog("Where should the selected files be installed to?", "Press B to cancel", {"SD Card", "Internal Storage"}, false);
|
} else dialogResult = mainApp->CreateShowDialog("Where should the selected " + std::to_string(nspInstPage::selectedNsps.size()) + " files be installed to?", "Press B to cancel", {"SD Card", "Internal Storage"}, false);
|
||||||
if (dialogResult == -1) return;
|
if (dialogResult == -1) return;
|
||||||
nspInstStuff::installNspFromFile(nspInstPage::selectedNsps, dialogResult);
|
nspInstStuff::installNspFromFile(nspInstPage::selectedNsps, dialogResult);
|
||||||
}
|
}
|
||||||
|
@ -78,10 +78,20 @@ namespace inst::ui {
|
||||||
mainApp->LoadLayout(mainApp->mainPage);
|
mainApp->LoadLayout(mainApp->mainPage);
|
||||||
}
|
}
|
||||||
if ((Down & KEY_A) || (Up & KEY_TOUCH)) {
|
if ((Down & KEY_A) || (Up & KEY_TOUCH)) {
|
||||||
nspInstPage::selectNsp();
|
nspInstPage::selectNsp(this->menu->GetSelectedIndex());
|
||||||
if (this->menu->GetItems().size() == 1) {
|
if (this->menu->GetItems().size() == 1) {
|
||||||
nspInstPage::startInstall();
|
nspInstPage::startInstall();
|
||||||
nspInstPage::selectNsp();
|
nspInstPage::selectNsp(this->menu->GetSelectedIndex());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ((Down & KEY_Y)) {
|
||||||
|
if (nspInstPage::selectedNsps.size() == this->menu->GetItems().size()) nspInstPage::drawMenuItems(true);
|
||||||
|
else {
|
||||||
|
for (long unsigned int i = 0; i < this->menu->GetItems().size(); i++) {
|
||||||
|
if (this->menu->GetItems()[i]->GetIcon() == "romfs:/check-box-outline.png") continue;
|
||||||
|
else nspInstPage::selectNsp(i);
|
||||||
|
}
|
||||||
|
nspInstPage::drawMenuItems(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((Down & KEY_X)) {
|
if ((Down & KEY_X)) {
|
||||||
|
@ -89,9 +99,8 @@ namespace inst::ui {
|
||||||
}
|
}
|
||||||
if (Down & KEY_PLUS) {
|
if (Down & KEY_PLUS) {
|
||||||
if (nspInstPage::selectedNsps.size() == 0) {
|
if (nspInstPage::selectedNsps.size() == 0) {
|
||||||
nspInstPage::selectNsp();
|
nspInstPage::selectNsp(this->menu->GetSelectedIndex());
|
||||||
nspInstPage::startInstall();
|
nspInstPage::startInstall();
|
||||||
nspInstPage::selectNsp();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
nspInstPage::startInstall();
|
nspInstPage::startInstall();
|
||||||
|
|
Loading…
Reference in a new issue