diff --git a/romfs/lang/en.json b/romfs/lang/en.json index b75cd9e..af75174 100644 --- a/romfs/lang/en.json +++ b/romfs/lang/en.json @@ -78,7 +78,7 @@ }, "top_info": "Select what files you want to install, then press the \ue0ef button!", "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_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" @@ -90,7 +90,7 @@ }, "top_info": "Select the files you want to install, then press the \ue0ef button!", "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_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" diff --git a/source/ui/mainPage.cpp b/source/ui/mainPage.cpp index e611237..f7ed11e 100644 --- a/source/ui/mainPage.cpp +++ b/source/ui/mainPage.cpp @@ -153,7 +153,7 @@ namespace inst::ui { MainPage::MainPage() : Layout::Layout() { std::string default_background = inst::config::appDir + "bg_images.default_background"_theme; std::string main_top = inst::config::appDir + "bg_images.main_top"_theme; - + std::string icons_sd = inst::config::appDir + "icons_mainmenu.sd"_theme; std::string icons_net = inst::config::appDir + "icons_mainmenu.net"_theme; std::string icons_usb = inst::config::appDir + "icons_mainmenu.usb"_theme; @@ -161,7 +161,7 @@ namespace inst::ui { std::string icons_hdd_connected = inst::config::appDir + "icons_mainmenu.hdd_connected"_theme; std::string icons_settings = inst::config::appDir + "icons_mainmenu.settings"_theme; std::string icons_exit = inst::config::appDir + "icons_mainmenu.exit"_theme; - + std::string bg_colour = "colour.background"_theme; std::string tbar_colour = "colour.topbar"_theme; std::string bbar_colour = "colour.bottombar"_theme; @@ -171,14 +171,14 @@ namespace inst::ui { std::string background_overlay2 = "colour.background_overlay2"_theme; std::string focus = "colour.focus"_theme; std::string scrollbar = "colour.scrollbar"_theme; - - + + 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")); @@ -191,52 +191,52 @@ namespace inst::ui { this->butText = TextBlock::New(10, 678, "main.buttons"_lang); if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json")) this->butText->SetColor(COLOR(bottombar_text)); else this->butText->SetColor(COLOR("#FFFFFFFF")); - + if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json")) this->optionMenu = pu::ui::elm::Menu::New(0, 95, 1280, COLOR(background_overlay1), COLOR(background_overlay2), 94, 6); else this->optionMenu = pu::ui::elm::Menu::New(0, 95, 1280, COLOR("#FFFFFF00"), COLOR("#4f4f4d33"), 94, 6); - + if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json")) this->optionMenu->SetItemsFocusColor(COLOR(focus)); else this->optionMenu->SetItemsFocusColor(COLOR("#4f4f4dAA")); - + if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json")) this->optionMenu->SetScrollbarColor(COLOR(scrollbar)); else this->optionMenu->SetScrollbarColor(COLOR("#1A1919FF")); - + this->installMenuItem = pu::ui::elm::MenuItem::New("main.menu.sd"_lang); if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json")) this->installMenuItem->SetColor(COLOR(text_colour)); else this->installMenuItem->SetColor(COLOR("#FFFFFFFF")); if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(icons_sd)) this->installMenuItem->SetIcon(icons_sd); else this->installMenuItem->SetIcon("romfs:/images/icons/micro-sd.png"); - + this->netInstallMenuItem = pu::ui::elm::MenuItem::New("main.menu.net"_lang); if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json")) this->netInstallMenuItem->SetColor(COLOR(text_colour)); else this->netInstallMenuItem->SetColor(COLOR("#FFFFFFFF")); if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(icons_net)) this->netInstallMenuItem->SetIcon(icons_net); else this->netInstallMenuItem->SetIcon("romfs:/images/icons/cloud-download.png"); - + this->usbInstallMenuItem = pu::ui::elm::MenuItem::New("main.menu.usb"_lang); if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json")) this->usbInstallMenuItem->SetColor(COLOR(text_colour)); else this->usbInstallMenuItem->SetColor(COLOR("#FFFFFFFF")); if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(icons_usb)) this->usbInstallMenuItem->SetIcon(icons_usb); else this->usbInstallMenuItem->SetIcon("romfs:/images/icons/usb-port.png"); - + this->HdInstallMenuItem = pu::ui::elm::MenuItem::New("main.menu.hdd"_lang); if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json")) this->HdInstallMenuItem->SetColor(COLOR(text_colour)); else this->HdInstallMenuItem->SetColor(COLOR("#FFFFFFFF")); if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(icons_hdd)) this->HdInstallMenuItem->SetIcon(icons_hdd); else this->HdInstallMenuItem->SetIcon("romfs:/images/icons/usb-hd.png"); - + this->settingsMenuItem = pu::ui::elm::MenuItem::New("main.menu.set"_lang); if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json")) this->settingsMenuItem->SetColor(COLOR(text_colour)); else this->settingsMenuItem->SetColor(COLOR("#FFFFFFFF")); if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(icons_settings)) this->settingsMenuItem->SetIcon(icons_settings); else this->settingsMenuItem->SetIcon("romfs:/images/icons/settings.png"); - + this->exitMenuItem = pu::ui::elm::MenuItem::New("main.menu.exit"_lang); if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json")) this->exitMenuItem->SetColor(COLOR(text_colour)); else this->exitMenuItem->SetColor(COLOR("#FFFFFFFF")); if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(icons_exit)) this->exitMenuItem->SetIcon(icons_exit); else this->exitMenuItem->SetIcon("romfs:/images/icons/exit-run.png"); - + this->Add(this->topRect); this->Add(this->botRect); this->Add(this->titleImage); @@ -264,21 +264,28 @@ namespace inst::ui { void MainPage::netInstallMenuItem_Click() { 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; } mainApp->netinstPage->startNetwork(); } 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 (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::setConfig(); } } 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() { @@ -288,7 +295,11 @@ namespace inst::ui { mainApp->LoadLayout(mainApp->HDinstPage); } 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); } } diff --git a/source/ui/sdInstPage.cpp b/source/ui/sdInstPage.cpp index 5d772b7..6073976 100644 --- a/source/ui/sdInstPage.cpp +++ b/source/ui/sdInstPage.cpp @@ -20,26 +20,54 @@ namespace inst::ui { sdInstPage::sdInstPage() : Layout::Layout() { std::string default_background = inst::config::appDir + "bg_images.default_background"_theme; std::string sd_top = inst::config::appDir + "bg_images.sd_top"_theme; - - this->infoRect = Rectangle::New(0, 95, 1280, 60, COLOR("#00000080")); - this->SetBackgroundColor(COLOR("#000000FF")); - this->topRect = Rectangle::New(0, 0, 1280, 94, COLOR("#000000FF")); - this->botRect = Rectangle::New(0, 659, 1280, 61, COLOR("#000000FF")); + 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; - 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->infoRect = Rectangle::New(0, 95, 1280, 60, COLOR(infoRect_colour)); + else this->infoRect = Rectangle::New(0, 95, 1280, 60, COLOR("#00000080")); + + 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"); - 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"); this->pageInfoText = TextBlock::New(10, 109, "inst.sd.top_info"_lang); 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->SetColor(COLOR("#FFFFFFFF")); - this->menu = pu::ui::elm::Menu::New(0, 156, 1280, COLOR("#FFFFFF00"), COLOR("#4f4f4d33"), 84, (506 / 84)); - this->menu->SetItemsFocusColor(COLOR("#4f4f4dAA")); - this->menu->SetScrollbarColor(COLOR("#1A1919FF")); + if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json")) this->butText->SetColor(COLOR(bottombar_text)); + else this->butText->SetColor(COLOR("#FFFFFFFF")); + + 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->infoRect); this->Add(this->botRect); @@ -51,6 +79,7 @@ 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. + std::string text_colour = "colour.main_text"_theme; if (clearItems) this->selectedTitles = {}; this->currentDir = ourPath; @@ -78,16 +107,27 @@ namespace inst::ui { std::string itm = ".."; auto ourEntry = pu::ui::elm::MenuItem::New(itm); - ourEntry->SetColor(COLOR("#FFFFFFFF")); - ourEntry->SetIcon("romfs:/images/icons/folder-upload.png"); + if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json")) ourEntry->SetColor(COLOR(text_colour)); + 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); for (auto& file : this->ourDirectories) { if (file == "..") break; std::string itm = file.filename().string(); auto ourEntry = pu::ui::elm::MenuItem::New(itm); - ourEntry->SetColor(COLOR("#FFFFFFFF")); - ourEntry->SetIcon("romfs:/images/icons/folder.png"); + if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json")) ourEntry->SetColor(COLOR(text_colour)); + 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); } @@ -100,8 +140,11 @@ namespace inst::ui { itm = file.filename().string(); } 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"); + for (long unsigned int i = 0; i < this->selectedTitles.size(); i++) { if (this->selectedTitles[i] == file) { ourEntry->SetIcon("romfs:/images/icons/check-box-outline.png"); @@ -175,18 +218,13 @@ namespace inst::ui { 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 (s != "0") { this->selectNsp(this->menu->GetSelectedIndex()); if (this->ourFiles.size() == 1 && this->selectedTitles.size() == 1) { this->startInstall(); } } - } } } @@ -212,11 +250,7 @@ namespace inst::ui { 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 (s != "0") { if (this->selectedTitles.size() == 0 && this->menu->GetItems()[this->menu->GetSelectedIndex()]->GetIconPath() == "romfs:/images/icons/checkbox-blank-outline.png") { this->selectNsp(this->menu->GetSelectedIndex()); }