more stuff for themes added

This commit is contained in:
mrdude2478 2023-09-29 06:20:21 +01:00
parent be7259ebc2
commit 6271664c19
3 changed files with 95 additions and 50 deletions

View File

@ -78,7 +78,7 @@
}, },
"top_info": "Select what files you want to install, then press the \ue0ef button!", "top_info": "Select what files you want to install, then press the \ue0ef button!",
"source_string": " from SD card", "source_string": " from SD card",
"delete_info": "installed, Delete it from the SD card?", "delete_info": "installed.\nDelete it from the SD card?",
"delete_info_multi": " files installed successfully!\n\nDelete them from the SD card?", "delete_info_multi": " files installed successfully!\n\nDelete them from the SD card?",
"delete_desc": "The original files aren't needed anymore after they've been installed", "delete_desc": "The original files aren't needed anymore after they've been installed",
"buttons": "\ue0e0 Select File \ue0e3 Select All \ue0ef Install File(s) \ue0e2 Help \ue0e1 Cancel" "buttons": "\ue0e0 Select File \ue0e3 Select All \ue0ef Install File(s) \ue0e2 Help \ue0e1 Cancel"
@ -90,7 +90,7 @@
}, },
"top_info": "Select the files you want to install, then press the \ue0ef button!", "top_info": "Select the files you want to install, then press the \ue0ef button!",
"source_string": " from hard drive", "source_string": " from hard drive",
"delete_info": " installed\nDelete it from the hard drive?", "delete_info": " installed.\nDelete it from the hard drive?",
"delete_info_multi": " files installed successfully!\nDelete them from the hard drive?", "delete_info_multi": " files installed successfully!\nDelete them from the hard drive?",
"delete_desc": "The original files aren't needed anymore after they've been installed", "delete_desc": "The original files aren't needed anymore after they've been installed",
"buttons": "\ue0e0 Select File \ue0e3 Select All \ue0ef Install File(s) \ue0e2 Help \ue0e1 Cancel" "buttons": "\ue0e0 Select File \ue0e3 Select All \ue0ef Install File(s) \ue0e2 Help \ue0e1 Cancel"

View File

@ -264,21 +264,28 @@ namespace inst::ui {
void MainPage::netInstallMenuItem_Click() { void MainPage::netInstallMenuItem_Click() {
if (inst::util::getIPAddress() == "1.0.0.127") { if (inst::util::getIPAddress() == "1.0.0.127") {
inst::ui::mainApp->CreateShowDialog("main.net.title"_lang, "main.net.desc"_lang, { "common.ok"_lang }, true, "romfs:/images/icons/information.png"); if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(inst::config::appDir + "icons_others.information"_theme)) {
inst::ui::mainApp->CreateShowDialog("main.net.title"_lang, "main.net.desc"_lang, { "common.ok"_lang }, true, inst::config::appDir + "icons_others.information"_theme);
}
else inst::ui::mainApp->CreateShowDialog("main.net.title"_lang, "main.net.desc"_lang, { "common.ok"_lang }, true, "romfs:/images/icons/information.png");
return; return;
} }
mainApp->netinstPage->startNetwork(); mainApp->netinstPage->startNetwork();
} }
void MainPage::usbInstallMenuItem_Click() { void MainPage::usbInstallMenuItem_Click() {
std::string usb = "romfs:/images/icons/usb.png";
if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(inst::config::appDir + "icons_others.usb"_theme)) {
usb = inst::config::appDir + "icons_others.usb"_theme;
}
if (!inst::config::usbAck) { if (!inst::config::usbAck) {
if (mainApp->CreateShowDialog("main.usb.warn.title"_lang, "main.usb.warn.desc"_lang, { "common.ok"_lang, "main.usb.warn.opt1"_lang }, false, "romfs:/images/icons/usb.png") == 1) { if (mainApp->CreateShowDialog("main.usb.warn.title"_lang, "main.usb.warn.desc"_lang, { "common.ok"_lang, "main.usb.warn.opt1"_lang }, false, usb) == 1) {
inst::config::usbAck = true; inst::config::usbAck = true;
inst::config::setConfig(); inst::config::setConfig();
} }
} }
if (inst::util::getUsbState() == 5) mainApp->usbinstPage->startUsb(); if (inst::util::getUsbState() == 5) mainApp->usbinstPage->startUsb();
else mainApp->CreateShowDialog("main.usb.error.title"_lang, "main.usb.error.desc"_lang, { "common.ok"_lang }, true, "romfs:/images/icons/usb.png"); else mainApp->CreateShowDialog("main.usb.error.title"_lang, "main.usb.error.desc"_lang, { "common.ok"_lang }, true, usb);
} }
void MainPage::HdInstallMenuItem_Click() { void MainPage::HdInstallMenuItem_Click() {
@ -288,7 +295,11 @@ namespace inst::ui {
mainApp->LoadLayout(mainApp->HDinstPage); mainApp->LoadLayout(mainApp->HDinstPage);
} }
else { else {
inst::ui::mainApp->CreateShowDialog("main.hdd.title"_lang, "main.hdd.notfound"_lang, { "common.ok"_lang }, true, "romfs:/images/icons/drive.png"); std::string drive = "romfs:/images/icons/drive.png";
if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(inst::config::appDir + "icons_others.drive"_theme)) {
drive = inst::config::appDir + "icons_others.drive"_theme;
}
inst::ui::mainApp->CreateShowDialog("main.hdd.title"_lang, "main.hdd.notfound"_lang, { "common.ok"_lang }, true, drive);
} }
} }

View File

@ -20,26 +20,54 @@ namespace inst::ui {
sdInstPage::sdInstPage() : Layout::Layout() { sdInstPage::sdInstPage() : Layout::Layout() {
std::string default_background = inst::config::appDir + "bg_images.default_background"_theme; std::string default_background = inst::config::appDir + "bg_images.default_background"_theme;
std::string sd_top = inst::config::appDir + "bg_images.sd_top"_theme; std::string sd_top = inst::config::appDir + "bg_images.sd_top"_theme;
std::string bg_colour = "colour.background"_theme;
std::string tbar_colour = "colour.topbar"_theme;
std::string bbar_colour = "colour.bottombar"_theme;
std::string infoRect_colour = "colour.inforect"_theme;
std::string pageinfo_colour = "colour.pageinfo_text"_theme;
std::string bottombar_text = "colour.bottombar_text"_theme;
std::string background_overlay1 = "colour.background_overlay1"_theme;
std::string background_overlay2 = "colour.background_overlay2"_theme;
std::string focus = "colour.focus"_theme;
std::string scrollbar = "colour.scrollbar"_theme;
this->infoRect = Rectangle::New(0, 95, 1280, 60, COLOR("#00000080")); if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json")) this->infoRect = Rectangle::New(0, 95, 1280, 60, COLOR(infoRect_colour));
this->SetBackgroundColor(COLOR("#000000FF")); else this->infoRect = Rectangle::New(0, 95, 1280, 60, COLOR("#00000080"));
this->topRect = Rectangle::New(0, 0, 1280, 94, COLOR("#000000FF"));
this->botRect = Rectangle::New(0, 659, 1280, 61, COLOR("#000000FF"));
if (inst::config::useTheme && std::filesystem::exists(sd_top)) this->titleImage = Image::New(0, 0, (sd_top)); if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json")) this->SetBackgroundColor(COLOR(bg_colour));
else this->SetBackgroundColor(COLOR("#000000FF"));
if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json")) this->topRect = Rectangle::New(0, 0, 1280, 94, COLOR(tbar_colour));
else this->topRect = Rectangle::New(0, 0, 1280, 94, COLOR("#000000FF"));
if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json")) this->botRect = Rectangle::New(0, 659, 1280, 61, COLOR(bbar_colour));
else this->botRect = Rectangle::New(0, 659, 1280, 61, COLOR("#000000FF"));
if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(sd_top)) this->titleImage = Image::New(0, 0, (sd_top));
else this->titleImage = Image::New(0, 0, "romfs:/images/Sd.png"); else this->titleImage = Image::New(0, 0, "romfs:/images/Sd.png");
if (inst::config::useTheme && std::filesystem::exists(default_background)) this->SetBackgroundImage(default_background); if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(default_background)) this->SetBackgroundImage(default_background);
else this->SetBackgroundImage("romfs:/images/Background.png"); else this->SetBackgroundImage("romfs:/images/Background.png");
this->pageInfoText = TextBlock::New(10, 109, "inst.sd.top_info"_lang); this->pageInfoText = TextBlock::New(10, 109, "inst.sd.top_info"_lang);
this->pageInfoText->SetFont(pu::ui::MakeDefaultFontName(30)); this->pageInfoText->SetFont(pu::ui::MakeDefaultFontName(30));
this->pageInfoText->SetColor(COLOR("#FFFFFFFF"));
if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json")) this->pageInfoText->SetColor(COLOR(pageinfo_colour));
else this->pageInfoText->SetColor(COLOR("#FFFFFFFF"));
this->butText = TextBlock::New(10, 678, "inst.sd.buttons"_lang); this->butText = TextBlock::New(10, 678, "inst.sd.buttons"_lang);
this->butText->SetColor(COLOR("#FFFFFFFF")); if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json")) this->butText->SetColor(COLOR(bottombar_text));
this->menu = pu::ui::elm::Menu::New(0, 156, 1280, COLOR("#FFFFFF00"), COLOR("#4f4f4d33"), 84, (506 / 84)); else this->butText->SetColor(COLOR("#FFFFFFFF"));
this->menu->SetItemsFocusColor(COLOR("#4f4f4dAA"));
this->menu->SetScrollbarColor(COLOR("#1A1919FF")); if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json")) this->menu = pu::ui::elm::Menu::New(0, 156, 1280, COLOR(background_overlay1), COLOR(background_overlay2), 84, (506 / 84));
else this->menu = pu::ui::elm::Menu::New(0, 156, 1280, COLOR("#FFFFFF00"), COLOR("#4f4f4d33"), 84, (506 / 84));
if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json")) this->menu->SetItemsFocusColor(COLOR(focus));
else this->menu->SetItemsFocusColor(COLOR("#4f4f4dAA"));
if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json")) this->menu->SetScrollbarColor(COLOR(scrollbar));
else this->menu->SetScrollbarColor(COLOR("#1A1919FF"));
this->Add(this->topRect); this->Add(this->topRect);
this->Add(this->infoRect); this->Add(this->infoRect);
this->Add(this->botRect); this->Add(this->botRect);
@ -51,6 +79,7 @@ namespace inst::ui {
void sdInstPage::drawMenuItems(bool clearItems, std::filesystem::path ourPath) { 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. int myindex = this->menu->GetSelectedIndex(); //store index so when page redraws we can get the last item we checked.
std::string text_colour = "colour.main_text"_theme;
if (clearItems) this->selectedTitles = {}; if (clearItems) this->selectedTitles = {};
this->currentDir = ourPath; this->currentDir = ourPath;
@ -78,16 +107,27 @@ namespace inst::ui {
std::string itm = ".."; std::string itm = "..";
auto ourEntry = pu::ui::elm::MenuItem::New(itm); auto ourEntry = pu::ui::elm::MenuItem::New(itm);
ourEntry->SetColor(COLOR("#FFFFFFFF")); if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json")) ourEntry->SetColor(COLOR(text_colour));
ourEntry->SetIcon("romfs:/images/icons/folder-upload.png"); else ourEntry->SetColor(COLOR("#FFFFFFFF"));
if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(inst::config::appDir + "icons_others.folder_up"_theme)) {
ourEntry->SetIcon(inst::config::appDir + "icons_others.folder_up"_theme);
}
else ourEntry->SetIcon("romfs:/images/icons/folder-upload.png");
this->menu->AddItem(ourEntry); this->menu->AddItem(ourEntry);
for (auto& file : this->ourDirectories) { for (auto& file : this->ourDirectories) {
if (file == "..") break; if (file == "..") break;
std::string itm = file.filename().string(); std::string itm = file.filename().string();
auto ourEntry = pu::ui::elm::MenuItem::New(itm); auto ourEntry = pu::ui::elm::MenuItem::New(itm);
ourEntry->SetColor(COLOR("#FFFFFFFF")); if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json")) ourEntry->SetColor(COLOR(text_colour));
ourEntry->SetIcon("romfs:/images/icons/folder.png"); else ourEntry->SetColor(COLOR("#FFFFFFFF"));
if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(inst::config::appDir + "icons_others.folder"_theme)) {
ourEntry->SetIcon(inst::config::appDir + "icons_others.folder"_theme);
}
else ourEntry->SetIcon("romfs:/images/icons/folder.png");
this->menu->AddItem(ourEntry); this->menu->AddItem(ourEntry);
} }
@ -100,8 +140,11 @@ namespace inst::ui {
itm = file.filename().string(); itm = file.filename().string();
} }
auto ourEntry = pu::ui::elm::MenuItem::New(itm); auto ourEntry = pu::ui::elm::MenuItem::New(itm);
ourEntry->SetColor(COLOR("#FFFFFFFF")); if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json")) ourEntry->SetColor(COLOR(text_colour));
else ourEntry->SetColor(COLOR("#FFFFFFFF"));
ourEntry->SetIcon("romfs:/images/icons/checkbox-blank-outline.png"); ourEntry->SetIcon("romfs:/images/icons/checkbox-blank-outline.png");
for (long unsigned int i = 0; i < this->selectedTitles.size(); i++) { for (long unsigned int i = 0; i < this->selectedTitles.size(); i++) {
if (this->selectedTitles[i] == file) { if (this->selectedTitles[i] == file) {
ourEntry->SetIcon("romfs:/images/icons/check-box-outline.png"); ourEntry->SetIcon("romfs:/images/icons/check-box-outline.png");
@ -175,18 +218,13 @@ namespace inst::ui {
int var = this->menu->GetItems().size(); int var = this->menu->GetItems().size();
auto s = std::to_string(var); auto s = std::to_string(var);
if (s == "0") { 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()); this->selectNsp(this->menu->GetSelectedIndex());
if (this->ourFiles.size() == 1 && this->selectedTitles.size() == 1) { if (this->ourFiles.size() == 1 && this->selectedTitles.size() == 1) {
this->startInstall(); this->startInstall();
} }
} }
} }
} }
} }
@ -212,11 +250,7 @@ namespace inst::ui {
int var = this->menu->GetItems().size(); int var = this->menu->GetItems().size();
auto s = std::to_string(var); auto s = std::to_string(var);
if (s == "0") { 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") { if (this->selectedTitles.size() == 0 && this->menu->GetItems()[this->menu->GetSelectedIndex()]->GetIconPath() == "romfs:/images/icons/checkbox-blank-outline.png") {
this->selectNsp(this->menu->GetSelectedIndex()); this->selectNsp(this->menu->GetSelectedIndex());
} }