From bf54ce62de53600c783bb13b6d90fc93c850d4ac Mon Sep 17 00:00:00 2001 From: mrdude2478 Date: Thu, 28 Sep 2023 04:35:57 +0100 Subject: [PATCH] start code cleanup --- include/ui/instPage.hpp | 2 -- include/ui/mainPage.hpp | 2 -- source/ui/HDInstPage.cpp | 18 ++++-------------- source/ui/ThemeInstPage.cpp | 20 ++++++-------------- source/ui/instPage.cpp | 20 ++++++-------------- source/ui/mainPage.cpp | 33 ++++++--------------------------- source/ui/netInstPage.cpp | 20 ++++++-------------- source/ui/optionsPage.cpp | 25 +++++++------------------ source/ui/sdInstPage.cpp | 20 ++++++-------------- source/ui/usbInstPage.cpp | 20 ++++++-------------- 10 files changed, 47 insertions(+), 133 deletions(-) diff --git a/include/ui/instPage.hpp b/include/ui/instPage.hpp index 55452c2..ca61deb 100644 --- a/include/ui/instPage.hpp +++ b/include/ui/instPage.hpp @@ -14,7 +14,6 @@ namespace inst::ui { TextBlock::Ref sdInfoText; TextBlock::Ref nandInfoText; TextBlock::Ref countText; - Image::Ref awooImage; pu::ui::elm::ProgressBar::Ref installBar; static void setTopInstInfoText(std::string ourText); static void setInstInfoText(std::string ourText); @@ -26,6 +25,5 @@ namespace inst::ui { Rectangle::Ref infoRect; Rectangle::Ref topRect; Image::Ref titleImage; - TextBlock::Ref appVersionText; }; } \ No newline at end of file diff --git a/include/ui/mainPage.hpp b/include/ui/mainPage.hpp index 8fe4293..902dbd5 100644 --- a/include/ui/mainPage.hpp +++ b/include/ui/mainPage.hpp @@ -15,7 +15,6 @@ namespace inst::ui { void settingsMenuItem_Click(); void exitMenuItem_Click(); void onInput(u64 Down, u64 Up, const u64 Held, pu::ui::TouchPoint touch_pos); - Image::Ref awooImage; private: bool appletFinished; @@ -32,7 +31,6 @@ namespace inst::ui { pu::ui::elm::MenuItem::Ref HdInstallMenuItem; pu::ui::elm::MenuItem::Ref settingsMenuItem; pu::ui::elm::MenuItem::Ref exitMenuItem; - Image::Ref eggImage; Image::Ref hdd; }; } \ No newline at end of file diff --git a/source/ui/HDInstPage.cpp b/source/ui/HDInstPage.cpp index 61e13be..2a51e19 100644 --- a/source/ui/HDInstPage.cpp +++ b/source/ui/HDInstPage.cpp @@ -20,22 +20,12 @@ namespace inst::ui { this->topRect = Rectangle::New(0, 0, 1280, 94, COLOR("#000000FF")); this->botRect = Rectangle::New(0, 659, 1280, 61, COLOR("#000000FF")); - if (inst::config::useTheme) { - if - (std::filesystem::exists(inst::config::appDir + "/images/Hd.png")) this->titleImage = Image::New(0, 0, (inst::config::appDir + "/images/Hd.png")); - else - this->titleImage = Image::New(0, 0, "romfs:/images/Hd.png"); + if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/images/Hd.png")) this->titleImage = Image::New(0, 0, (inst::config::appDir + "/images/Hd.png")); + else this->titleImage = Image::New(0, 0, "romfs:/images/Hd.png"); - if - (std::filesystem::exists(inst::config::appDir + "/images/Background.png")) this->SetBackgroundImage(inst::config::appDir + "/images/Background.png"); - else - this->SetBackgroundImage("romfs:/images/Background.png"); - } + if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/images/Background.png")) this->SetBackgroundImage(inst::config::appDir + "/images/Background.png"); + else this->SetBackgroundImage("romfs:/images/Background.png"); - else { - this->SetBackgroundImage("romfs:/images/Background.png"); - this->titleImage = Image::New(0, 0, "romfs:/images/Hd.png"); - } this->pageInfoText = TextBlock::New(10, 109, "inst.hd.top_info"_lang); this->pageInfoText->SetFont(pu::ui::MakeDefaultFontName(30)); this->pageInfoText->SetColor(COLOR("#FFFFFFFF")); diff --git a/source/ui/ThemeInstPage.cpp b/source/ui/ThemeInstPage.cpp index b8900eb..da04256 100644 --- a/source/ui/ThemeInstPage.cpp +++ b/source/ui/ThemeInstPage.cpp @@ -33,19 +33,12 @@ namespace inst::ui { this->topRect = Rectangle::New(0, 0, 1280, 94, COLOR("#000000FF")); this->botRect = Rectangle::New(0, 659, 1280, 61, COLOR("#000000FF")); - if (inst::config::useTheme) { - if (std::filesystem::exists(inst::config::appDir + "/images/Net.png")) this->titleImage = Image::New(0, 0, (inst::config::appDir + "/images/Net.png")); - else this->titleImage = Image::New(0, 0, "romfs:/images/Net.png"); - if (std::filesystem::exists(inst::config::appDir + "/images/Background.png")) this->SetBackgroundImage(inst::config::appDir + "/images/Background.png"); - else this->SetBackgroundImage("romfs:/images/Background.png"); - this->appVersionText = TextBlock::New(1210, 680, ""); - } - else { - this->SetBackgroundImage("romfs:/images/Background.png"); - this->titleImage = Image::New(0, 0, "romfs:/images/Net.png"); - this->appVersionText = TextBlock::New(1210, 680, ""); - } - this->appVersionText->SetColor(COLOR("#FFFFFFFF")); + if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/images/Net.png")) this->titleImage = Image::New(0, 0, (inst::config::appDir + "/images/Net.png")); + else this->titleImage = Image::New(0, 0, "romfs:/images/Net.png"); + + if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/images/Background.png")) this->SetBackgroundImage(inst::config::appDir + "/images/Background.png"); + 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")); @@ -59,7 +52,6 @@ namespace inst::ui { this->Add(this->infoRect); this->Add(this->botRect); this->Add(this->titleImage); - this->Add(this->appVersionText); this->Add(this->butText); this->Add(this->pageInfoText); this->Add(this->menu); diff --git a/source/ui/instPage.cpp b/source/ui/instPage.cpp index f321219..41ddc0b 100644 --- a/source/ui/instPage.cpp +++ b/source/ui/instPage.cpp @@ -30,19 +30,12 @@ namespace inst::ui { this->SetBackgroundColor(COLOR("#000000FF")); this->topRect = Rectangle::New(0, 0, 1280, 94, COLOR("#000000FF")); - if (inst::config::useTheme) { - if (std::filesystem::exists(inst::config::appDir + "/images/Install.png")) this->titleImage = Image::New(0, 0, (inst::config::appDir + "/images/Install.png")); - else this->titleImage = Image::New(0, 0, "romfs:/images/Install.png"); - if (std::filesystem::exists(inst::config::appDir + "/images/Background.png")) this->SetBackgroundImage(inst::config::appDir + "/images/Background.png"); - else this->SetBackgroundImage("romfs:/images/Background.png"); - this->appVersionText = TextBlock::New(0, 0, ""); - } - else { - this->SetBackgroundImage("romfs:/images/Background.png"); - this->titleImage = Image::New(0, 0, "romfs:/images/Install.png"); - this->appVersionText = TextBlock::New(0, 0, ""); - } - this->appVersionText->SetColor(COLOR("#FFFFFFFF")); + if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/images/Install.png")) this->titleImage = Image::New(0, 0, (inst::config::appDir + "/images/Install.png")); + else this->titleImage = Image::New(0, 0, "romfs:/images/Install.png"); + + if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/images/Background.png")) this->SetBackgroundImage(inst::config::appDir + "/images/Background.png"); + 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")); @@ -64,7 +57,6 @@ namespace inst::ui { this->Add(this->topRect); this->Add(this->infoRect); this->Add(this->titleImage); - this->Add(this->appVersionText); this->Add(this->pageInfoText); this->Add(this->installInfoText); this->Add(this->sdInfoText); diff --git a/source/ui/mainPage.cpp b/source/ui/mainPage.cpp index c4e79cf..44ae094 100644 --- a/source/ui/mainPage.cpp +++ b/source/ui/mainPage.cpp @@ -154,18 +154,12 @@ namespace inst::ui { this->topRect = Rectangle::New(0, 0, 1280, 94, COLOR("#000000FF")); this->botRect = Rectangle::New(0, 659, 1280, 61, COLOR("#000000FF")); - if (inst::config::useTheme) { - if (std::filesystem::exists(inst::config::appDir + "/images/Main.png")) this->titleImage = Image::New(0, 0, (inst::config::appDir + "/images/Main.png")); - else - this->titleImage = Image::New(0, 0, "romfs:/images/Main.png"); - if (std::filesystem::exists(inst::config::appDir + "/images/Background.png")) this->SetBackgroundImage(inst::config::appDir + "/images/Background.png"); - else - this->SetBackgroundImage("romfs:/images/Background.png"); - } - else { - this->SetBackgroundImage("romfs:/images/Background.png"); - this->titleImage = Image::New(0, 0, "romfs:/images/Main.png"); - } + if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/images/Main.png")) this->titleImage = Image::New(0, 0, (inst::config::appDir + "/images/Main.png")); + else this->titleImage = Image::New(0, 0, "romfs:/images/Main.png"); + + if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/images/Background.png")) this->SetBackgroundImage(inst::config::appDir + "/images/Background.png"); + else this->SetBackgroundImage("romfs:/images/Background.png"); + this->butText = TextBlock::New(10, 678, "main.buttons"_lang); this->butText->SetColor(COLOR("#FFFFFFFF")); this->optionMenu = pu::ui::elm::Menu::New(0, 95, 1280, COLOR("#FFFFFF00"), COLOR("#4f4f4d33"), 94, 6); @@ -189,14 +183,6 @@ namespace inst::ui { this->exitMenuItem = pu::ui::elm::MenuItem::New("main.menu.exit"_lang); this->exitMenuItem->SetColor(COLOR("#FFFFFFFF")); this->exitMenuItem->SetIcon("romfs:/images/icons/exit-run.png"); - if (inst::config::useTheme) { - if (std::filesystem::exists(inst::config::appDir + "/images/Main.png")) this->awooImage = Image::New(0, 0, inst::config::appDir + "/images/Main.png"); - else this->awooImage = Image::New(0, 0, "romfs:/images/Main.png"); - } - else { - this->awooImage = Image::New(0, 0, "romfs:/images/Main.png"); - } - this->eggImage = Image::New(0, 0, ""); this->Add(this->topRect); this->Add(this->botRect); this->Add(this->titleImage); @@ -211,9 +197,6 @@ namespace inst::ui { this->hdd = Image::New(1156, 669, "romfs:/images/icons/usb-hd-connected.png"); this->Add(this->hdd); } - this->Add(this->awooImage); - this->Add(this->eggImage); - this->awooImage->SetVisible(!inst::config::useTheme); this->Add(this->optionMenu); this->AddRenderCallback(mainMenuThread); } @@ -307,13 +290,9 @@ namespace inst::ui { } if (Down & HidNpadButton_X) { - this->awooImage->SetVisible(false); - this->eggImage->SetVisible(true); } if (Up & HidNpadButton_A) { - this->eggImage->SetVisible(false); - if (!inst::config::useTheme) this->awooImage->SetVisible(true); } if (Down & HidNpadButton_Y) { diff --git a/source/ui/netInstPage.cpp b/source/ui/netInstPage.cpp index 4bdd6b6..2399148 100644 --- a/source/ui/netInstPage.cpp +++ b/source/ui/netInstPage.cpp @@ -26,19 +26,12 @@ namespace inst::ui { this->topRect = Rectangle::New(0, 0, 1280, 94, COLOR("#000000FF")); this->botRect = Rectangle::New(0, 659, 1280, 61, COLOR("#000000FF")); - if (inst::config::useTheme) { - if (std::filesystem::exists(inst::config::appDir + "/images/Net.png")) this->titleImage = Image::New(0, 0, (inst::config::appDir + "/images/Net.png")); - else this->titleImage = Image::New(0, 0, "romfs:/images/Net.png"); - if (std::filesystem::exists(inst::config::appDir + "/images/Background.png")) this->SetBackgroundImage(inst::config::appDir + "/images/Background.png"); - else this->SetBackgroundImage("romfs:/images/Background.png"); - this->appVersionText = TextBlock::New(1210, 680, ""); - } - else { - this->SetBackgroundImage("romfs:/images/Background.png"); - this->titleImage = Image::New(0, 0, "romfs:/images/Net.png"); - this->appVersionText = TextBlock::New(1210, 680, ""); - } - this->appVersionText->SetColor(COLOR("#FFFFFFFF")); + if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/images/Net.png")) this->titleImage = Image::New(0, 0, (inst::config::appDir + "/images/Net.png")); + else this->titleImage = Image::New(0, 0, "romfs:/images/Net.png"); + + if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/images/Background.png")) this->SetBackgroundImage(inst::config::appDir + "/images/Background.png"); + 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")); @@ -52,7 +45,6 @@ namespace inst::ui { this->Add(this->infoRect); this->Add(this->botRect); this->Add(this->titleImage); - this->Add(this->appVersionText); this->Add(this->butText); this->Add(this->pageInfoText); this->Add(this->menu); diff --git a/source/ui/optionsPage.cpp b/source/ui/optionsPage.cpp index 7fb8bb2..f9c637a 100644 --- a/source/ui/optionsPage.cpp +++ b/source/ui/optionsPage.cpp @@ -27,18 +27,13 @@ namespace inst::ui { this->topRect = Rectangle::New(0, 0, 1280, 94, COLOR("#000000FF")); this->botRect = Rectangle::New(0, 659, 1280, 61, COLOR("#000000FF")); - if (inst::config::useTheme) { - if (std::filesystem::exists(inst::config::appDir + "/images/Settings.png")) this->titleImage = Image::New(0, 0, (inst::config::appDir + "/images/Settings.png")); - else this->titleImage = Image::New(0, 0, "romfs:/images/Settings.png"); - if (std::filesystem::exists(inst::config::appDir + "/images/Background.png")) this->SetBackgroundImage(inst::config::appDir + "/images/Background.png"); - else this->SetBackgroundImage("romfs:/images/Background.png"); - this->appVersionText = TextBlock::New(1200, 680, "v" + inst::config::appVersion); - } - else { - this->SetBackgroundImage("romfs:/images/Background.png"); - this->titleImage = Image::New(0, 0, "romfs:/images/Settings.png"); - this->appVersionText = TextBlock::New(1200, 680, "v" + inst::config::appVersion); - } + if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/images/Settings.png")) this->titleImage = Image::New(0, 0, (inst::config::appDir + "/images/Settings.png")); + else this->titleImage = Image::New(0, 0, "romfs:/images/Settings.png"); + + if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/images/Background.png")) this->SetBackgroundImage(inst::config::appDir + "/images/Background.png"); + else this->SetBackgroundImage("romfs:/images/Background.png"); + + this->appVersionText = TextBlock::New(1200, 680, "v" + inst::config::appVersion); this->appVersionText->SetColor(COLOR("#FFFFFFFF")); this->appVersionText->SetFont(pu::ui::MakeDefaultFontName(20)); this->pageInfoText = TextBlock::New(10, 109, "options.title"_lang); @@ -346,12 +341,6 @@ namespace inst::ui { inst::config::setConfig(); break; case 9: - if (inst::config::useTheme) { - mainApp->mainPage->awooImage->SetVisible(true); - } - else { - mainApp->mainPage->awooImage->SetVisible(false); - } thememessage(); inst::config::setConfig(); this->setMenuText(); diff --git a/source/ui/sdInstPage.cpp b/source/ui/sdInstPage.cpp index 8524e53..af62ab2 100644 --- a/source/ui/sdInstPage.cpp +++ b/source/ui/sdInstPage.cpp @@ -22,19 +22,12 @@ namespace inst::ui { this->topRect = Rectangle::New(0, 0, 1280, 94, COLOR("#000000FF")); this->botRect = Rectangle::New(0, 659, 1280, 61, COLOR("#000000FF")); - if (inst::config::useTheme) { - if (std::filesystem::exists(inst::config::appDir + "/images/Sd.png")) this->titleImage = Image::New(0, 0, (inst::config::appDir + "/images/Sd.png")); - else this->titleImage = Image::New(0, 0, "romfs:/images/Sd.png"); - if (std::filesystem::exists(inst::config::appDir + "/images/Background.png")) this->SetBackgroundImage(inst::config::appDir + "/images/Background.png"); - else this->SetBackgroundImage("romfs:/images/Background.png"); - this->appVersionText = TextBlock::New(0, 0, ""); - } - else { - this->SetBackgroundImage("romfs:/images/Background.png"); - this->titleImage = Image::New(0, 0, "romfs:/images/Sd.png"); - this->appVersionText = TextBlock::New(0, 0, ""); - } - this->appVersionText->SetColor(COLOR("#FFFFFFFF")); + if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/images/Sd.png")) this->titleImage = Image::New(0, 0, (inst::config::appDir + "/images/Sd.png")); + else this->titleImage = Image::New(0, 0, "romfs:/images/Sd.png"); + + if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/images/Background.png")) this->SetBackgroundImage(inst::config::appDir + "/images/Background.png"); + 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")); @@ -47,7 +40,6 @@ namespace inst::ui { this->Add(this->infoRect); this->Add(this->botRect); this->Add(this->titleImage); - this->Add(this->appVersionText); this->Add(this->butText); this->Add(this->pageInfoText); this->Add(this->menu); diff --git a/source/ui/usbInstPage.cpp b/source/ui/usbInstPage.cpp index 743f56f..1e5a5d7 100644 --- a/source/ui/usbInstPage.cpp +++ b/source/ui/usbInstPage.cpp @@ -18,19 +18,12 @@ namespace inst::ui { this->topRect = Rectangle::New(0, 0, 1280, 94, COLOR("#000000FF")); this->botRect = Rectangle::New(0, 659, 1280, 61, COLOR("#000000FF")); - if (inst::config::useTheme) { - if (std::filesystem::exists(inst::config::appDir + "/images/Usb.png")) this->titleImage = Image::New(0, 0, (inst::config::appDir + "/images/Usb.png")); - else this->titleImage = Image::New(0, 0, "romfs:/images/Usb.png"); - if (std::filesystem::exists(inst::config::appDir + "/images/Background.png")) this->SetBackgroundImage(inst::config::appDir + "/images/Background.png"); - else this->SetBackgroundImage("romfs:/images/Background.png"); - this->appVersionText = TextBlock::New(0, 0, ""); - } - else { - this->SetBackgroundImage("romfs:/images/Background.png"); - this->titleImage = Image::New(0, 0, "romfs:/images/Usb.png"); - this->appVersionText = TextBlock::New(0, 0, ""); - } - this->appVersionText->SetColor(COLOR("#FFFFFFFF")); + if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/images/Usb.png")) this->titleImage = Image::New(0, 0, (inst::config::appDir + "/images/Usb.png")); + else this->titleImage = Image::New(0, 0, "romfs:/images/Usb.png"); + + if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/images/Background.png")) this->SetBackgroundImage(inst::config::appDir + "/images/Background.png"); + else this->SetBackgroundImage("romfs:/images/Background.png"); + this->pageInfoText = TextBlock::New(10, 109, ""); this->pageInfoText->SetColor(COLOR("#FFFFFFFF")); this->pageInfoText->SetFont(pu::ui::MakeDefaultFontName(30)); @@ -44,7 +37,6 @@ namespace inst::ui { this->Add(this->infoRect); this->Add(this->botRect); this->Add(this->titleImage); - this->Add(this->appVersionText); this->Add(this->butText); this->Add(this->pageInfoText); this->Add(this->menu);