start theme mods

This commit is contained in:
mrdude2478 2023-09-29 03:27:12 +01:00
parent 722bc783fc
commit 1861d563b0
8 changed files with 204 additions and 139 deletions

View File

@ -41,6 +41,7 @@ SOFTWARE.
#include "util/lang.hpp" #include "util/lang.hpp"
#include "ui/MainApplication.hpp" #include "ui/MainApplication.hpp"
#include "ui/instPage.hpp" #include "ui/instPage.hpp"
#include "util/theme.hpp"
namespace inst::ui { namespace inst::ui {
extern MainApplication* mainApp; extern MainApplication* mainApp;
@ -101,16 +102,21 @@ namespace nspInstStuff_B {
fprintf(stdout, "%s", e.what()); fprintf(stdout, "%s", e.what());
inst::ui::instPage::setInstInfoText("inst.info_page.failed"_lang + inst::util::shortenString(ourTitleList[titleItr].filename().string(), 42, true)); inst::ui::instPage::setInstInfoText("inst.info_page.failed"_lang + inst::util::shortenString(ourTitleList[titleItr].filename().string(), 42, true));
inst::ui::instPage::setInstBarPerc(0); inst::ui::instPage::setInstBarPerc(0);
std::string audioPath = "";
if (inst::config::useSound) { if (inst::config::useSound) {
if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/sounds/failed.wav")) audioPath = (inst::config::appDir + "/theme/sounds/failed.wav"); std::string audioPath = "";
else audioPath = "romfs:/audio/ohno.wav"; std::string fail = inst::config::appDir + "audio.fail"_theme;
if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(fail)) {
audioPath = (fail);
}
else {
audioPath = "romfs:/audio/ohno.wav";
}
std::thread audioThread(inst::util::playAudio, audioPath);
audioThread.join();
} }
std::thread audioThread(inst::util::playAudio, audioPath);
inst::ui::mainApp->CreateShowDialog("inst.info_page.failed"_lang + inst::util::shortenString(ourTitleList[titleItr].filename().string(), 42, true) + "!", "inst.info_page.failed_desc"_lang + "\n\n" + (std::string)e.what(), { "common.ok"_lang }, true, "romfs:/images/icons/fail.png"); inst::ui::mainApp->CreateShowDialog("inst.info_page.failed"_lang + inst::util::shortenString(ourTitleList[titleItr].filename().string(), 42, true) + "!", "inst.info_page.failed_desc"_lang + "\n\n" + (std::string)e.what(), { "common.ok"_lang }, true, "romfs:/images/icons/fail.png");
audioThread.join();
nspInstalled = false; nspInstalled = false;
} }
@ -123,35 +129,20 @@ namespace nspInstStuff_B {
if (nspInstalled) { if (nspInstalled) {
inst::ui::instPage::setInstInfoText("inst.info_page.complete"_lang); inst::ui::instPage::setInstInfoText("inst.info_page.complete"_lang);
inst::ui::instPage::setInstBarPerc(100); inst::ui::instPage::setInstBarPerc(100);
std::string audioPath = "";
if (inst::config::useSound) { if (inst::config::useSound) {
if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/sounds/complete.wav")) audioPath = (inst::config::appDir + "/theme/sounds/complete.wav"); std::string audioPath = "";
else audioPath = "romfs:/audio/yipee.wav"; std::string pass = inst::config::appDir + "audio.pass"_theme;
if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(pass)) {
std::thread audioThread(inst::util::playAudio, audioPath); audioPath = (pass);
if (ourTitleList.size() > 1) {
if (inst::config::deletePrompt) {
if (inst::ui::mainApp->CreateShowDialog(std::to_string(ourTitleList.size()) + "inst.hd.delete_info_multi"_lang, "inst.hd.delete_desc"_lang, { "common.no"_lang,"common.yes"_lang }, false, "romfs:/images/icons/bin.png") == 1) {
for (long unsigned int i = 0; i < ourTitleList.size(); i++) {
if (std::filesystem::exists(ourTitleList[i])) std::filesystem::remove(ourTitleList[i]);
}
}
}
else inst::ui::mainApp->CreateShowDialog(std::to_string(ourTitleList.size()) + "inst.info_page.desc0"_lang, Language::GetRandomMsg(), { "common.ok"_lang }, true, "romfs:/images/icons/information.png");
} }
else { else {
if (inst::config::deletePrompt) { audioPath = "romfs:/audio/yipee.wav";
if (inst::ui::mainApp->CreateShowDialog(inst::util::shortenString(ourTitleList[0].filename().string(), 32, true) + "inst.hd.delete_info"_lang, "inst.hd.delete_desc"_lang, { "common.no"_lang,"common.yes"_lang }, false, "romfs:/images/icons/bin.png") == 1) if (std::filesystem::exists(ourTitleList[0])) std::filesystem::remove(ourTitleList[0]);
} }
else inst::ui::mainApp->CreateShowDialog(inst::util::shortenString(ourTitleList[0].filename().string(), 42, true) + "inst.info_page.desc1"_lang, Language::GetRandomMsg(), { "common.ok"_lang }, true, "romfs:/images/icons/install.png"); std::thread audioThread(inst::util::playAudio, audioPath);
}
audioThread.join(); audioThread.join();
} }
else {
if (ourTitleList.size() > 1) { if (ourTitleList.size() > 1) {
if (inst::config::deletePrompt) { if (inst::config::deletePrompt) {
if (inst::ui::mainApp->CreateShowDialog(std::to_string(ourTitleList.size()) + "inst.hd.delete_info_multi"_lang, "inst.hd.delete_desc"_lang, { "common.no"_lang,"common.yes"_lang }, false, "romfs:/images/icons/bin.png") == 1) { if (inst::ui::mainApp->CreateShowDialog(std::to_string(ourTitleList.size()) + "inst.hd.delete_info_multi"_lang, "inst.hd.delete_desc"_lang, { "common.no"_lang,"common.yes"_lang }, false, "romfs:/images/icons/bin.png") == 1) {
@ -169,7 +160,6 @@ namespace nspInstStuff_B {
else inst::ui::mainApp->CreateShowDialog(inst::util::shortenString(ourTitleList[0].filename().string(), 42, true) + "inst.info_page.desc1"_lang, Language::GetRandomMsg(), { "common.ok"_lang }, true, "romfs:/images/icons/bin.png"); else inst::ui::mainApp->CreateShowDialog(inst::util::shortenString(ourTitleList[0].filename().string(), 42, true) + "inst.info_page.desc1"_lang, Language::GetRandomMsg(), { "common.ok"_lang }, true, "romfs:/images/icons/bin.png");
} }
} }
}
LOG_DEBUG("Done"); LOG_DEBUG("Done");
inst::ui::instPage::loadMainMenu(); inst::ui::instPage::loadMainMenu();

View File

@ -1,22 +1,35 @@
#include <thread> #include <thread>
#include "switch.h" #include <string>
#include <switch.h>
#include "util/error.hpp" #include "util/error.hpp"
#include "ui/MainApplication.hpp" #include "ui/MainApplication.hpp"
#include "util/util.hpp" #include "util/util.hpp"
#include "util/config.hpp" #include "util/config.hpp"
#include "util/theme.hpp"
using namespace pu::ui::render; using namespace pu::ui::render;
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
inst::util::initApp(); inst::util::initApp();
try { try {
//const auto default_font_path = ("romfs:/fonts/Roboto-Regular.ttf"); Theme::Load();
int x = 0;
if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(inst::config::appDir + "fonts.default"_theme)) {
x = 1;
}
auto renderer_opts = pu::ui::render::RendererInitOptions(SDL_INIT_EVERYTHING, pu::ui::render::RendererHardwareFlags); auto renderer_opts = pu::ui::render::RendererInitOptions(SDL_INIT_EVERYTHING, pu::ui::render::RendererHardwareFlags);
renderer_opts.UseImage(pu::ui::render::IMGAllFlags); renderer_opts.UseImage(pu::ui::render::IMGAllFlags);
renderer_opts.UseAudio(pu::ui::render::MixerAllFlags); renderer_opts.UseAudio(pu::ui::render::MixerAllFlags);
//renderer_opts.UseTTF(default_font_path); if (x == 1) {
const auto default_font_path = (inst::config::appDir + "fonts.default"_theme);
renderer_opts.UseTTF(default_font_path);
}
renderer_opts.UseTTF(); renderer_opts.UseTTF();
//renderer_opts.SetExtraDefaultFontSize(35); if (x == 1) {
std::string size = "fonts.default_size"_theme;
int myint1 = stoi(size);
renderer_opts.SetExtraDefaultFontSize(myint1);
}
renderer_opts.UseRomfs(); renderer_opts.UseRomfs();
auto renderer = pu::ui::render::Renderer::New(renderer_opts); auto renderer = pu::ui::render::Renderer::New(renderer_opts);

View File

@ -45,6 +45,7 @@ SOFTWARE.
#include "util/lang.hpp" #include "util/lang.hpp"
#include "ui/MainApplication.hpp" #include "ui/MainApplication.hpp"
#include "ui/instPage.hpp" #include "ui/instPage.hpp"
#include "util/theme.hpp"
const unsigned int MAX_URL_SIZE = 1024; const unsigned int MAX_URL_SIZE = 1024;
const unsigned int MAX_URLS = 1000; const unsigned int MAX_URLS = 1000;
@ -242,16 +243,17 @@ namespace netInstStuff {
fprintf(stdout, "%s", e.what()); fprintf(stdout, "%s", e.what());
inst::ui::instPage::setInstInfoText("inst.info_page.failed"_lang + urlNames[urlItr]); inst::ui::instPage::setInstInfoText("inst.info_page.failed"_lang + urlNames[urlItr]);
inst::ui::instPage::setInstBarPerc(0); inst::ui::instPage::setInstBarPerc(0);
std::string audioPath = "";
if (inst::config::useSound) { if (inst::config::useSound) {
if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/sounds/failed.wav")) audioPath = (inst::config::appDir + "/theme/sounds/failed.wav"); std::string audioPath = "";
std::string fail = inst::config::appDir + "audio.fail"_theme;
if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(fail)) audioPath = (fail);
else audioPath = "romfs:/audio/ohno.wav"; else audioPath = "romfs:/audio/ohno.wav";
std::thread audioThread(inst::util::playAudio, audioPath);
audioThread.join();
} }
std::thread audioThread(inst::util::playAudio, audioPath);
inst::ui::mainApp->CreateShowDialog("inst.info_page.failed"_lang + urlNames[urlItr] + "!", "inst.info_page.failed_desc"_lang + "\n\n" + (std::string)e.what(), { "common.ok"_lang }, true, "romfs:/images/icons/fail.png"); inst::ui::mainApp->CreateShowDialog("inst.info_page.failed"_lang + urlNames[urlItr] + "!", "inst.info_page.failed_desc"_lang + "\n\n" + (std::string)e.what(), { "common.ok"_lang }, true, "romfs:/images/icons/fail.png");
audioThread.join();
nspInstalled = false; nspInstalled = false;
} }
@ -269,22 +271,25 @@ namespace netInstStuff {
if (nspInstalled) { if (nspInstalled) {
inst::ui::instPage::setInstInfoText("inst.info_page.complete"_lang); inst::ui::instPage::setInstInfoText("inst.info_page.complete"_lang);
inst::ui::instPage::setInstBarPerc(100); inst::ui::instPage::setInstBarPerc(100);
std::string audioPath = "";
if (inst::config::useSound) { if (inst::config::useSound) {
if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/sounds/complete.wav")) audioPath = (inst::config::appDir + "/theme/sounds/complete.wav"); std::string audioPath = "";
else audioPath = "romfs:/audio/yipee.wav"; std::string pass = inst::config::appDir + "audio.pass"_theme;
if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(pass)) {
audioPath = (pass);
}
else {
audioPath = "romfs:/audio/yipee.wav";
}
std::thread audioThread(inst::util::playAudio, audioPath); std::thread audioThread(inst::util::playAudio, audioPath);
if (ourUrlList.size() > 1) inst::ui::mainApp->CreateShowDialog(std::to_string(ourUrlList.size()) + "inst.info_page.desc0"_lang, Language::GetRandomMsg(), { "common.ok"_lang }, true, "romfs:/images/icons/good.png");
else inst::ui::mainApp->CreateShowDialog(urlNames[0] + "inst.info_page.desc1"_lang, Language::GetRandomMsg(), { "common.ok"_lang }, true, "romfs:/images/icons/good.png");
audioThread.join(); audioThread.join();
} }
if (ourUrlList.size() > 1) {
inst::ui::mainApp->CreateShowDialog(std::to_string(ourUrlList.size()) + "inst.info_page.desc0"_lang, Language::GetRandomMsg(), { "common.ok"_lang }, true, "romfs:/images/icons/good.png");
}
else { else {
if (ourUrlList.size() > 1) inst::ui::mainApp->CreateShowDialog(std::to_string(ourUrlList.size()) + "inst.info_page.desc0"_lang, Language::GetRandomMsg(), { "common.ok"_lang }, true, "romfs:/images/icons/information.png"); inst::ui::mainApp->CreateShowDialog(urlNames[0] + "inst.info_page.desc1"_lang, Language::GetRandomMsg(), { "common.ok"_lang }, true, "romfs:/images/icons/good.png");
else inst::ui::mainApp->CreateShowDialog(urlNames[0] + "inst.info_page.desc1"_lang, Language::GetRandomMsg(), { "common.ok"_lang }, true, "romfs:/images/icons/good.png");
} }
} }

View File

@ -41,6 +41,7 @@ SOFTWARE.
#include "util/lang.hpp" #include "util/lang.hpp"
#include "ui/MainApplication.hpp" #include "ui/MainApplication.hpp"
#include "ui/instPage.hpp" #include "ui/instPage.hpp"
#include "util/theme.hpp"
namespace inst::ui { namespace inst::ui {
extern MainApplication* mainApp; extern MainApplication* mainApp;
@ -101,16 +102,17 @@ namespace nspInstStuff {
fprintf(stdout, "%s", e.what()); fprintf(stdout, "%s", e.what());
inst::ui::instPage::setInstInfoText("inst.info_page.failed"_lang + inst::util::shortenString(ourTitleList[titleItr].filename().string(), 42, true)); inst::ui::instPage::setInstInfoText("inst.info_page.failed"_lang + inst::util::shortenString(ourTitleList[titleItr].filename().string(), 42, true));
inst::ui::instPage::setInstBarPerc(0); inst::ui::instPage::setInstBarPerc(0);
std::string audioPath = "";
if (inst::config::useSound) { if (inst::config::useSound) {
if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/sounds/failed.wav")) audioPath = (inst::config::appDir + "/theme/sounds/failed.wav"); std::string audioPath = "";
std::string fail = inst::config::appDir + "audio.fail"_theme;
if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(fail)) audioPath = (fail);
else audioPath = "romfs:/audio/ohno.wav"; else audioPath = "romfs:/audio/ohno.wav";
std::thread audioThread(inst::util::playAudio, audioPath);
audioThread.join();
} }
std::thread audioThread(inst::util::playAudio, audioPath);
inst::ui::mainApp->CreateShowDialog("inst.info_page.failed"_lang + inst::util::shortenString(ourTitleList[titleItr].filename().string(), 42, true) + "!\n", "inst.info_page.failed_desc"_lang + "\n\n" + (std::string)e.what(), { "common.ok"_lang }, true); inst::ui::mainApp->CreateShowDialog("inst.info_page.failed"_lang + inst::util::shortenString(ourTitleList[titleItr].filename().string(), 42, true) + "!\n", "inst.info_page.failed_desc"_lang + "\n\n" + (std::string)e.what(), { "common.ok"_lang }, true);
audioThread.join();
nspInstalled = false; nspInstalled = false;
} }
@ -123,45 +125,33 @@ namespace nspInstStuff {
if (nspInstalled) { if (nspInstalled) {
inst::ui::instPage::setInstInfoText("inst.info_page.complete"_lang); inst::ui::instPage::setInstInfoText("inst.info_page.complete"_lang);
inst::ui::instPage::setInstBarPerc(100); inst::ui::instPage::setInstBarPerc(100);
std::string audioPath = "";
if (inst::config::useSound) { if (inst::config::useSound) {
std::string audioPath = "";
if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/sounds/complete.wav")) audioPath = (inst::config::appDir + "/theme/sounds/complete.wav"); std::string pass = inst::config::appDir + "audio.pass"_theme;
else audioPath = "romfs:/audio/yipee.wav"; if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(pass)) {
audioPath = (pass);
std::thread audioThread(inst::util::playAudio, audioPath);
if (ourTitleList.size() > 1) {
if (inst::config::deletePrompt) {
if (inst::ui::mainApp->CreateShowDialog(std::to_string(ourTitleList.size()) + "inst.sd.delete_info_multi"_lang + "\n", "\n\n\n" + "inst.sd.delete_desc"_lang, { "common.no"_lang,"common.yes"_lang }, false, "romfs:/images/icons/bin.png") == 1) {
for (long unsigned int i = 0; i < ourTitleList.size(); i++) {
if (std::filesystem::exists(ourTitleList[i])) std::filesystem::remove(ourTitleList[i]);
}
}
}
else inst::ui::mainApp->CreateShowDialog(std::to_string(ourTitleList.size()) + "inst.info_page.desc0"_lang, Language::GetRandomMsg(), { "common.ok"_lang }, true, "romfs:/images/icons/information.png");
} }
else { else {
if (inst::config::deletePrompt) { audioPath = "romfs:/audio/yipee.wav";
if (inst::ui::mainApp->CreateShowDialog(inst::util::shortenString(ourTitleList[0].filename().string(), 32, true) + "\n\n" + "inst.sd.delete_info"_lang, "\n\n\n" + "inst.sd.delete_desc"_lang + "\n\n", { "common.no"_lang,"common.yes"_lang }, false, "romfs:/images/icons/bin.png") == 1) if (std::filesystem::exists(ourTitleList[0])) std::filesystem::remove(ourTitleList[0]);
} }
else inst::ui::mainApp->CreateShowDialog(inst::util::shortenString(ourTitleList[0].filename().string(), 42, true) + "inst.info_page.desc1"_lang, Language::GetRandomMsg(), { "common.ok"_lang }, true, "romfs:/images/icons/information.png"); std::thread audioThread(inst::util::playAudio, audioPath);
}
audioThread.join(); audioThread.join();
} }
else {
if (ourTitleList.size() > 1) { if (ourTitleList.size() > 1) {
if (inst::config::deletePrompt) { if (inst::config::deletePrompt) {
if (inst::ui::mainApp->CreateShowDialog(std::to_string(ourTitleList.size()) + "inst.sd.delete_info_multi"_lang, "inst.sd.delete_desc"_lang, { "common.no"_lang,"common.yes"_lang }, false, "romfs:/images/icons/bin.png") == 1) { if (inst::ui::mainApp->CreateShowDialog(std::to_string(ourTitleList.size()) + "inst.sd.delete_info_multi"_lang, "inst.sd.delete_desc"_lang, { "common.no"_lang,"common.yes"_lang }, false, "romfs:/images/icons/bin.png") == 1) {
for (long unsigned int i = 0; i < ourTitleList.size(); i++) { for (long unsigned int i = 0; i < ourTitleList.size(); i++) {
if (std::filesystem::exists(ourTitleList[i])) std::filesystem::remove(ourTitleList[i]); if (std::filesystem::exists(ourTitleList[i])) {
std::filesystem::remove(ourTitleList[i]);
} }
} }
} }
else inst::ui::mainApp->CreateShowDialog(std::to_string(ourTitleList.size()) + "inst.info_page.desc0"_lang, Language::GetRandomMsg(), { "common.ok"_lang }, true, "romfs:/images/icons/good.png"); }
else {
inst::ui::mainApp->CreateShowDialog(std::to_string(ourTitleList.size()) + "inst.info_page.desc0"_lang, Language::GetRandomMsg(), { "common.ok"_lang }, true, "romfs:/images/icons/good.png");
}
} }
else { else {
if (inst::config::deletePrompt) { if (inst::config::deletePrompt) {
@ -170,7 +160,6 @@ namespace nspInstStuff {
else inst::ui::mainApp->CreateShowDialog(inst::util::shortenString(ourTitleList[0].filename().string(), 42, true) + "inst.info_page.desc1"_lang, Language::GetRandomMsg(), { "common.ok"_lang }, true, "romfs:/images/icons/information.png"); else inst::ui::mainApp->CreateShowDialog(inst::util::shortenString(ourTitleList[0].filename().string(), 42, true) + "inst.info_page.desc1"_lang, Language::GetRandomMsg(), { "common.ok"_lang }, true, "romfs:/images/icons/information.png");
} }
} }
}
LOG_DEBUG("Done"); LOG_DEBUG("Done");
inst::ui::instPage::loadMainMenu(); inst::ui::instPage::loadMainMenu();

View File

@ -1,5 +1,6 @@
#include "ui/MainApplication.hpp" #include "ui/MainApplication.hpp"
#include "util/lang.hpp" #include "util/lang.hpp"
#include "util/theme.hpp"
namespace inst::ui { namespace inst::ui {
MainApplication* mainApp; MainApplication* mainApp;
@ -8,6 +9,7 @@ namespace inst::ui {
mainApp = this; mainApp = this;
Language::Load(); Language::Load();
//Theme::Load(); //load in main.cpp instead.
this->mainPage = MainPage::New(); this->mainPage = MainPage::New();
this->netinstPage = netInstPage::New(); this->netinstPage = netInstPage::New();

View File

@ -12,6 +12,7 @@
#include "data/buffered_placeholder_writer.hpp" #include "data/buffered_placeholder_writer.hpp"
#include "nx/usbhdd.h" #include "nx/usbhdd.h"
#include "usbhsfs.h" #include "usbhsfs.h"
#include "util/theme.hpp"
#include <sys/statvfs.h> #include <sys/statvfs.h>
#define COLOR(hex) pu::ui::Color::FromHex(hex) #define COLOR(hex) pu::ui::Color::FromHex(hex)
@ -150,39 +151,92 @@ namespace inst::ui {
} }
MainPage::MainPage() : Layout::Layout() { MainPage::MainPage() : Layout::Layout() {
this->SetBackgroundColor(COLOR("#000000FF")); std::string default_background = inst::config::appDir + "bg_images.default_background"_theme;
this->topRect = Rectangle::New(0, 0, 1280, 94, COLOR("#000000FF")); std::string main_top = inst::config::appDir + "bg_images.main_top"_theme;
this->botRect = Rectangle::New(0, 659, 1280, 61, COLOR("#000000FF"));
if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/images/Main.png")) this->titleImage = Image::New(0, 0, (inst::config::appDir + "/theme/images/Main.png")); 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;
std::string icons_hdd = inst::config::appDir + "icons_mainmenu.hdd"_theme;
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;
std::string bottombar_text = "colour.bottombar_text"_theme;
std::string text_colour = "colour.main_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(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(main_top)) this->titleImage = Image::New(0, 0, (main_top));
else this->titleImage = Image::New(0, 0, "romfs:/images/Main.png"); else this->titleImage = Image::New(0, 0, "romfs:/images/Main.png");
if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/images/Background.png")) this->SetBackgroundImage(inst::config::appDir + "/theme/images/Background.png"); 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->butText = TextBlock::New(10, 678, "main.buttons"_lang); this->butText = TextBlock::New(10, 678, "main.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->optionMenu = pu::ui::elm::Menu::New(0, 95, 1280, COLOR("#FFFFFF00"), COLOR("#4f4f4d33"), 94, 6); else this->butText->SetColor(COLOR("#FFFFFFFF"));
this->optionMenu->SetItemsFocusColor(COLOR("#4f4f4dAA"));
this->optionMenu->SetScrollbarColor(COLOR("#1A1919FF")); 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); this->installMenuItem = pu::ui::elm::MenuItem::New("main.menu.sd"_lang);
this->installMenuItem->SetColor(COLOR("#FFFFFFFF")); if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json")) this->installMenuItem->SetColor(COLOR(text_colour));
this->installMenuItem->SetIcon("romfs:/images/icons/micro-sd.png"); 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); this->netInstallMenuItem = pu::ui::elm::MenuItem::New("main.menu.net"_lang);
this->netInstallMenuItem->SetColor(COLOR("#FFFFFFFF")); if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json")) this->netInstallMenuItem->SetColor(COLOR(text_colour));
this->netInstallMenuItem->SetIcon("romfs:/images/icons/cloud-download.png"); 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); this->usbInstallMenuItem = pu::ui::elm::MenuItem::New("main.menu.usb"_lang);
this->usbInstallMenuItem->SetColor(COLOR("#FFFFFFFF")); if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json")) this->usbInstallMenuItem->SetColor(COLOR(text_colour));
this->usbInstallMenuItem->SetIcon("romfs:/images/icons/usb-port.png"); 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); this->HdInstallMenuItem = pu::ui::elm::MenuItem::New("main.menu.hdd"_lang);
this->HdInstallMenuItem->SetColor(COLOR("#FFFFFFFF")); if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json")) this->HdInstallMenuItem->SetColor(COLOR(text_colour));
this->HdInstallMenuItem->SetIcon("romfs:/images/icons/usb-hd.png"); 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); this->settingsMenuItem = pu::ui::elm::MenuItem::New("main.menu.set"_lang);
this->settingsMenuItem->SetColor(COLOR("#FFFFFFFF")); if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json")) this->settingsMenuItem->SetColor(COLOR(text_colour));
this->settingsMenuItem->SetIcon("romfs:/images/icons/settings.png"); 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); this->exitMenuItem = pu::ui::elm::MenuItem::New("main.menu.exit"_lang);
this->exitMenuItem->SetColor(COLOR("#FFFFFFFF")); if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json")) this->exitMenuItem->SetColor(COLOR(text_colour));
this->exitMenuItem->SetIcon("romfs:/images/icons/exit-run.png"); 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->topRect);
this->Add(this->botRect); this->Add(this->botRect);
this->Add(this->titleImage); this->Add(this->titleImage);
@ -194,7 +248,8 @@ namespace inst::ui {
this->optionMenu->AddItem(this->settingsMenuItem); this->optionMenu->AddItem(this->settingsMenuItem);
this->optionMenu->AddItem(this->exitMenuItem); this->optionMenu->AddItem(this->exitMenuItem);
if (nx::hdd::count() && nx::hdd::rootPath()) { if (nx::hdd::count() && nx::hdd::rootPath()) {
this->hdd = Image::New(1156, 669, "romfs:/images/icons/usb-hd-connected.png"); if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(icons_hdd_connected)) this->hdd = Image::New(1156, 669, icons_hdd_connected);
else this->hdd = Image::New(1156, 669, "romfs:/images/icons/usb-hd-connected.png");
this->Add(this->hdd); this->Add(this->hdd);
} }
this->Add(this->optionMenu); this->Add(this->optionMenu);

View File

@ -8,6 +8,7 @@
#include "util/util.hpp" #include "util/util.hpp"
#include "util/config.hpp" #include "util/config.hpp"
#include "util/lang.hpp" #include "util/lang.hpp"
#include "util/theme.hpp"
#define COLOR(hex) pu::ui::Color::FromHex(hex) #define COLOR(hex) pu::ui::Color::FromHex(hex)
@ -17,15 +18,18 @@ namespace inst::ui {
bool show_ext; bool show_ext;
sdInstPage::sdInstPage() : Layout::Layout() { 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->infoRect = Rectangle::New(0, 95, 1280, 60, COLOR("#00000080"));
this->SetBackgroundColor(COLOR("#000000FF")); this->SetBackgroundColor(COLOR("#000000FF"));
this->topRect = Rectangle::New(0, 0, 1280, 94, COLOR("#000000FF")); this->topRect = Rectangle::New(0, 0, 1280, 94, COLOR("#000000FF"));
this->botRect = Rectangle::New(0, 659, 1280, 61, COLOR("#000000FF")); this->botRect = Rectangle::New(0, 659, 1280, 61, COLOR("#000000FF"));
if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/images/Sd.png")) this->titleImage = Image::New(0, 0, (inst::config::appDir + "/theme/images/Sd.png")); if (inst::config::useTheme && 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(inst::config::appDir + "/theme/images/Background.png")) this->SetBackgroundImage(inst::config::appDir + "/theme/images/Background.png"); if (inst::config::useTheme && 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);

View File

@ -36,6 +36,7 @@ SOFTWARE.
#include "ui/MainApplication.hpp" #include "ui/MainApplication.hpp"
#include "ui/usbInstPage.hpp" #include "ui/usbInstPage.hpp"
#include "ui/instPage.hpp" #include "ui/instPage.hpp"
#include "util/theme.hpp"
namespace inst::ui { namespace inst::ui {
extern MainApplication* mainApp; extern MainApplication* mainApp;
@ -150,16 +151,21 @@ namespace usbInstStuff {
fprintf(stdout, "%s", e.what()); fprintf(stdout, "%s", e.what());
inst::ui::instPage::setInstInfoText("inst.info_page.failed"_lang + fileNames[fileItr]); inst::ui::instPage::setInstInfoText("inst.info_page.failed"_lang + fileNames[fileItr]);
inst::ui::instPage::setInstBarPerc(0); inst::ui::instPage::setInstBarPerc(0);
std::string audioPath = "";
if (inst::config::useSound) { if (inst::config::useSound) {
if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/sounds/failed.wav")) audioPath = (inst::config::appDir + "/theme/sounds/failed.wav"); std::string audioPath = "";
else audioPath = "romfs:/audio/ohno.wav"; std::string fail = inst::config::appDir + "audio.fail"_theme;
if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(fail)) {
audioPath = (fail);
}
else {
audioPath = "romfs:/audio/ohno.wav";
}
std::thread audioThread(inst::util::playAudio, audioPath);
audioThread.join();
} }
std::thread audioThread(inst::util::playAudio, audioPath);
inst::ui::mainApp->CreateShowDialog("inst.info_page.failed"_lang + fileNames[fileItr] + "!", "inst.info_page.failed_desc"_lang + "\n\n" + (std::string)e.what(), { "common.ok"_lang }, true, "romfs:/images/icons/fail.png"); inst::ui::mainApp->CreateShowDialog("inst.info_page.failed"_lang + fileNames[fileItr] + "!", "inst.info_page.failed_desc"_lang + "\n\n" + (std::string)e.what(), { "common.ok"_lang }, true, "romfs:/images/icons/fail.png");
audioThread.join();
nspInstalled = false; nspInstalled = false;
} }
@ -173,21 +179,22 @@ namespace usbInstStuff {
tin::util::USBCmdManager::SendExitCmd(); tin::util::USBCmdManager::SendExitCmd();
inst::ui::instPage::setInstInfoText("inst.info_page.complete"_lang); inst::ui::instPage::setInstInfoText("inst.info_page.complete"_lang);
inst::ui::instPage::setInstBarPerc(100); inst::ui::instPage::setInstBarPerc(100);
std::string audioPath = "";
if (inst::config::useSound) { if (inst::config::useSound) {
if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/sounds/complete.wav")) audioPath = (inst::config::appDir + "/theme/sounds/complete.wav"); std::string audioPath = "";
else audioPath = "romfs:/audio/yipee.wav"; std::string pass = inst::config::appDir + "audio.pass"_theme;
if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(pass)) {
audioPath = (pass);
}
else {
audioPath = "romfs:/audio/yipee.wav";
}
std::thread audioThread(inst::util::playAudio, audioPath); std::thread audioThread(inst::util::playAudio, audioPath);
audioThread.join();
}
if (ourTitleList.size() > 1) inst::ui::mainApp->CreateShowDialog(std::to_string(ourTitleList.size()) + "inst.info_page.desc0"_lang, Language::GetRandomMsg(), { "common.ok"_lang }, true, "romfs:/images/icons/good.png"); if (ourTitleList.size() > 1) inst::ui::mainApp->CreateShowDialog(std::to_string(ourTitleList.size()) + "inst.info_page.desc0"_lang, Language::GetRandomMsg(), { "common.ok"_lang }, true, "romfs:/images/icons/good.png");
else inst::ui::mainApp->CreateShowDialog(fileNames[0] + "inst.info_page.desc1"_lang, Language::GetRandomMsg(), { "common.ok"_lang }, true, "romfs:/images/icons/good.png"); else inst::ui::mainApp->CreateShowDialog(fileNames[0] + "inst.info_page.desc1"_lang, Language::GetRandomMsg(), { "common.ok"_lang }, true, "romfs:/images/icons/good.png");
audioThread.join();
}
else {
if (ourTitleList.size() > 1) inst::ui::mainApp->CreateShowDialog(std::to_string(ourTitleList.size()) + "inst.info_page.desc0"_lang, Language::GetRandomMsg(), { "common.ok"_lang }, true, "romfs:/images/icons/good.png");
else inst::ui::mainApp->CreateShowDialog(fileNames[0] + "inst.info_page.desc1"_lang, Language::GetRandomMsg(), { "common.ok"_lang }, true, "romfs:/images/icons/good.png");
}
} }
LOG_DEBUG("Done"); LOG_DEBUG("Done");