From 04bce9ace4a5db76c6e34b2d9c4babe3dd667d1a Mon Sep 17 00:00:00 2001 From: mrdude2478 Date: Fri, 29 Sep 2023 07:11:48 +0100 Subject: [PATCH] theme updates to inst page --- source/ui/instPage.cpp | 59 +++++++++++++++++++++++++++-------- source/util/lang.cpp | 70 +++++++++++++++++++----------------------- 2 files changed, 78 insertions(+), 51 deletions(-) diff --git a/source/ui/instPage.cpp b/source/ui/instPage.cpp index a9225f3..1d22709 100644 --- a/source/ui/instPage.cpp +++ b/source/ui/instPage.cpp @@ -3,6 +3,7 @@ #include "ui/instPage.hpp" #include "util/config.hpp" #include "util/lang.hpp" +#include "util/theme.hpp" #include FsFileSystem* fs; @@ -26,34 +27,66 @@ namespace inst::ui { extern MainApplication* mainApp; instPage::instPage() : Layout::Layout() { - this->infoRect = Rectangle::New(0, 95, 1280, 60, COLOR("#00000080")); - this->SetBackgroundColor(COLOR("#000000FF")); - this->topRect = Rectangle::New(0, 0, 1280, 94, COLOR("#000000FF")); + + std::string infoRect_colour = "colour.inforect"_theme; + std::string bg_colour = "colour.background"_theme; + std::string tbar_colour = "colour.topbar"_theme; + std::string install_top = inst::config::appDir + "bg_images.install_top"_theme; + std::string default_background = inst::config::appDir + "bg_images.default_background"_theme; + std::string pageinfo_colour = "colour.pageinfo_text"_theme; + std::string installinfo_colour = "colour.installinfo_text"_theme; + std::string sdinfo_colour = "colour.sdinfo_text"_theme; + std::string nandinfo_colour = "colour.nandinfo_text"_theme; + std::string count_colour = "colour.count_text"_theme; + std::string progress_bg_colour = "colour.progress_bg"_theme; + std::string progress_fg_colour = "colour.progress_fg"_theme; + + 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/images/Install.png")) this->titleImage = Image::New(0, 0, (inst::config::appDir + "/theme/images/Install.png")); + if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(install_top)) this->titleImage = Image::New(0, 0, (install_top)); else this->titleImage = Image::New(0, 0, "romfs:/images/Install.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"); this->pageInfoText = TextBlock::New(10, 109, ""); 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->installInfoText = TextBlock::New(10, 640, ""); this->installInfoText->SetFont(pu::ui::MakeDefaultFontName(30)); - this->installInfoText->SetColor(COLOR("#FFFFFFFF")); + if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json")) this->installInfoText->SetColor(COLOR(installinfo_colour)); + else this->installInfoText->SetColor(COLOR("#FFFFFFFF")); + this->sdInfoText = TextBlock::New(10, 600, ""); this->sdInfoText->SetFont(pu::ui::MakeDefaultFontName(30)); - this->sdInfoText->SetColor(COLOR("#FFFFFFFF")); + if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json")) this->sdInfoText->SetColor(COLOR(sdinfo_colour)); + else this->sdInfoText->SetColor(COLOR("#FFFFFFFF")); + this->nandInfoText = TextBlock::New(10, 560, ""); this->nandInfoText->SetFont(pu::ui::MakeDefaultFontName(30)); - this->nandInfoText->SetColor(COLOR("#FFFFFFFF")); + if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json")) this->nandInfoText->SetColor(COLOR(nandinfo_colour)); + else this->nandInfoText->SetColor(COLOR("#FFFFFFFF")); + this->countText = TextBlock::New(10, 520, ""); this->countText->SetFont(pu::ui::MakeDefaultFontName(30)); - this->countText->SetColor(COLOR("#FFFFFFFF")); + if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json")) this->countText->SetColor(COLOR(count_colour)); + else this->countText->SetColor(COLOR("#FFFFFFFF")); + this->installBar = pu::ui::elm::ProgressBar::New(10, 680, 1260, 30, 100.0f); - this->installBar->SetBackgroundColor(COLOR("#000000FF")); - this->installBar->SetProgressColor(COLOR("#565759FF")); + if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json")) this->installBar->SetBackgroundColor(COLOR(progress_bg_colour)); + else this->installBar->SetBackgroundColor(COLOR("#000000FF")); + if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json")) this->installBar->SetProgressColor(COLOR(progress_fg_colour)); + else this->installBar->SetProgressColor(COLOR("#565759FF")); + this->Add(this->topRect); this->Add(this->infoRect); this->Add(this->titleImage); diff --git a/source/util/lang.cpp b/source/util/lang.cpp index 4693739..d3ecd7d 100644 --- a/source/util/lang.cpp +++ b/source/util/lang.cpp @@ -19,27 +19,6 @@ namespace Language { setMakeLanguage(lcode, &ourLang); setExit(); int syslang = (int)ourLang; - /* - 0 Japanese - 1 AmericanEnglish - 2 French - 3 German - 4 Italian - 5 Spanish - 6 Chinese - 7 Korean - 8 Dutch - 9 Portuguese - 10 Russian - 11 Taiwanese - 12 BritishEnglish - 13 CanadianFrench - 14 LatinAmericanSpanish - 15 [4.0.0+] SimplifiedChinese - 16 [4.0.0+] TraditionalChinese - 17 [10.1.0+] BrazilianPortuguese - */ - //Get language int from config file std::ifstream ifs; std::string languagePath; int langInt = inst::config::languageSetting; @@ -74,45 +53,60 @@ namespace Language { break; case 0: switch (syslang) { - case 0: + case 0: //Japanese languagePath = "romfs:/lang/jp.json"; break; - case 1: + case 1: //AmericanEnglish languagePath = "romfs:/lang/en.json"; break; - case 2: + case 2: //French languagePath = "romfs:/lang/fr.json"; break; - case 3: + case 3: //German languagePath = "romfs:/lang/de.json"; break; - case 4: + case 4: //Italian languagePath = "romfs:/lang/it.json"; break; - case 5: + case 5: //Spanish languagePath = "romfs:/lang/es.json"; break; - case 6: + case 6: //Chinese languagePath = "romfs:/lang/tw.json"; break; - case 10: - languagePath = "romfs:/lang/ru.json"; - break; - case 11: - languagePath = "romfs:/lang/tw.json"; - break; - case 12: + case 7: //Korean languagePath = "romfs:/lang/en.json"; break; - case 13: + case 8: //Dutch + languagePath = "romfs:/lang/en.json"; + break; + case 9: //Portuguese + languagePath = "romfs:/lang/en.json"; + break; + case 10: //Russian + languagePath = "romfs:/lang/ru.json"; + break; + case 11: //Taiwanese + languagePath = "romfs:/lang/tw.json"; + break; + case 12: //BritishEnglish + languagePath = "romfs:/lang/en.json"; + break; + case 13: //CanadianFrench languagePath = "romfs:/lang/fr.json"; break; - case 14: + case 14: //LatinAmericanSpanish languagePath = "romfs:/lang/es.json"; break; - case 16: + case 15: //SimplifiedChinese languagePath = "romfs:/lang/tw.json"; break; + case 16: //TraditionalChinese + languagePath = "romfs:/lang/tw.json"; + break; + case 17: //BrazilianPortuguese + languagePath = "romfs:/lang/en.json"; + break; default: languagePath = "romfs:/lang/en.json"; break;