diff --git a/include/gui/gfx.hpp b/include/gui/gfx.hpp index 5c37db3..f4a7ec2 100644 --- a/include/gui/gfx.hpp +++ b/include/gui/gfx.hpp @@ -29,46 +29,23 @@ #include "common.hpp" #include "sprites.h" +#include "theme.hpp" #include #include +extern std::unique_ptr UIThemes; + /* Standard Colors. */ #define WHITE C2D_Color32(255, 255, 255, 255) #define BLACK C2D_Color32(0, 0, 0, 255) #define TRANSPARENT C2D_Color32(0, 0, 0, 0) #define DIM_COLOR C2D_Color32(0, 0, 0, 190) -struct UITheme { - uint32_t BarColor; - uint32_t BGColor; - uint32_t BarOutline; - uint32_t TextColor; - uint32_t EntryBar; - uint32_t EntryOutline; - uint32_t BoxInside; - uint32_t BoxSelected; - uint32_t BoxUnselected; - uint32_t ProgressbarOut; - uint32_t ProgressbarIn; - uint32_t SearchBar; - uint32_t SearchbarOutline; - uint32_t SideBarSelected; - uint32_t SideBarUnselected; - /* NOTE: Also used for the buttons. */ - uint32_t MarkSelected; - uint32_t MarkUnselected; - uint32_t DownListPrev; - uint32_t SideBarIconColor; -}; - namespace GFX { - extern std::vector Themes; - extern int SelectedTheme; - void DrawTop(void); void DrawBottom(); void DrawSprite(int img, int x, int y, float ScaleX = 1, float ScaleY = 1); - void DrawBox(float xPos, float yPos, float width = 50, float height = 50, bool selected = false, uint32_t clr = GFX::Themes[GFX::SelectedTheme].BoxInside); + void DrawBox(float xPos, float yPos, float width = 50, float height = 50, bool selected = false, uint32_t clr = UIThemes->BoxInside()); void DrawCheckbox(float xPos, float yPos, bool selected); void DrawToggle(float xPos, float yPos, bool toggled); void DrawTime(); diff --git a/include/overlays/overlay.hpp b/include/overlays/overlay.hpp index e727cdb..cc1d21e 100644 --- a/include/overlays/overlay.hpp +++ b/include/overlays/overlay.hpp @@ -35,6 +35,7 @@ namespace Overlays { void SelectLanguage(); void ShowCredits(); std::string SelectDir(const std::string &oldDir, const std::string &msg); + void SelectTheme(); }; #endif \ No newline at end of file diff --git a/include/utils/config.hpp b/include/utils/config.hpp index 08cae17..636fd27 100644 --- a/include/utils/config.hpp +++ b/include/utils/config.hpp @@ -95,8 +95,8 @@ public: void changelog(bool v) { this->v_changelog = v; if (!this->changesMade) this->changesMade = true; }; /* The active Theme. */ - int theme() const { return this->v_theme; }; - void theme(int v) { this->v_theme = v; if (!this->changesMade) this->changesMade = true; }; + std::string theme() const { return this->v_theme; }; + void theme(const std::string &v) { this->v_theme = v; if (!this->changesMade) this->changesMade = true; }; /* If showing prompt if action failed / succeeded. */ bool prompt() const { return this->v_prompt; }; @@ -113,11 +113,9 @@ private: nlohmann::json json; bool changesMade = false; - int v_theme = 0; - std::string v_language = "en", v_lastStore = "universal-db.unistore", v_3dsxPath = "sdmc:/3ds", v_ndsPath = "sdmc:", v_archivePath = "sdmc:", - v_shortcutPath = "sdmc:/3ds/Universal-Updater/shortcuts", v_firmPath = "sdmc:/luma/payloads"; + v_shortcutPath = "sdmc:/3ds/Universal-Updater/shortcuts", v_firmPath = "sdmc:/luma/payloads", v_theme = "Default"; bool v_list = false, v_autoUpdate = true, v_metadata = true, v_updateCheck = true, v_showBg = false, v_customFont = false, v_changelog = true, v_prompt = true, v_3dsxInFolder = false; diff --git a/include/utils/theme.hpp b/include/utils/theme.hpp new file mode 100644 index 0000000..698d619 --- /dev/null +++ b/include/utils/theme.hpp @@ -0,0 +1,72 @@ +/* +* This file is part of Universal-Updater +* Copyright (C) 2019-2021 Universal-Team +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* +* Additional Terms 7.b and 7.c of GPLv3 apply to this file: +* * Requiring preservation of specified reasonable legal notices or +* author attributions in that material or in the Appropriate Legal +* Notices displayed by works containing it. +* * Prohibiting misrepresentation of the origin of that material, +* or requiring that modified versions of such material be marked in +* reasonable ways as different from the original version. +*/ + +#ifndef _UNIVERSAL_UPDATER_THEME_HPP +#define _UNIVERSAL_UPDATER_THEME_HPP + +#include "json.hpp" +#include +#include + +class Theme { +public: + Theme(const std::string &ThemeJSON = "sdmc:/3ds/Universal-Updater/Themes.json"); + void InitWithDefaultColors(const std::string &ThemePath = "sdmc:/3ds/Universal-Updater/Themes.json"); + void LoadTheme(const std::string &ThemeName); + std::vector ThemeNames(); + uint32_t GetThemeColor(const std::string &colorString, const uint32_t DefaultColor); + + uint32_t BarColor() const { return this->vBarColor; }; + uint32_t BGColor() const { return this->vBGColor; }; + uint32_t BarOutline() const { return this->vBarOutline; }; + uint32_t TextColor() const { return this->vTextColor; }; + uint32_t EntryBar() const { return this->vEntryBar; }; + uint32_t EntryOutline() const { return this->vEntryOutline; }; + uint32_t BoxInside() const { return this->vBoxInside; }; + uint32_t BoxSelected() const { return this->vBoxSelected; }; + uint32_t BoxUnselected() const { return this->vBoxUnselected; }; + uint32_t ProgressbarOut() const { return this->vProgressbarOut; }; + uint32_t ProgressbarIn() const { return this->vProgressbarIn; }; + uint32_t SearchBar() const { return this->vSearchBar; }; + uint32_t SearchBarOutline() const { return this->vSearchBarOutline; }; + uint32_t SideBarSelected() const { return this->vSideBarSelected; }; + uint32_t SideBarUnselected() const { return this->vSideBarUnselected; }; + uint32_t MarkSelected() const { return this->vMarkSelected; }; + uint32_t MarkUnselected() const { return this->vMarkUnselected; }; + uint32_t DownListPrev() const { return this->vDownListPrev; }; + uint32_t SideBarIconColor() const { return this->vSideBarIconColor; }; +private: + uint32_t vBarColor = 0, vBGColor = 0, vBarOutline = 0, vTextColor = 0, vEntryBar = 0, vEntryOutline = 0, + vBoxInside = 0, vBoxSelected = 0, vBoxUnselected = 0, vProgressbarOut = 0, vProgressbarIn = 0, + vSearchBar = 0, vSearchBarOutline = 0, vSideBarSelected = 0, vSideBarUnselected = 0, + vMarkSelected = 0, vMarkUnselected = 0, vDownListPrev = 0, vSideBarIconColor = 0; + + int SelectedTheme = 0; + bool Loaded = false; + nlohmann::json json = nullptr; +}; + +#endif \ No newline at end of file diff --git a/resources/Themes.json b/resources/Themes.json new file mode 100644 index 0000000..bc29b2f --- /dev/null +++ b/resources/Themes.json @@ -0,0 +1,23 @@ +{ + "Default": [ + "#324962", + "#262C4D", + "#191E35", + "#FFFFFF", + "#324962", + "#191E35", + "#1C213A", + "#6C829B", + "#000000", + "#1C213A", + "#4D6580", + "#334B66", + "#191E35", + "#6C829B", + "#4D6580", + "#4D6580", + "#1C213A", + "#1C213A", + "#ADCCEF" + ] +} \ No newline at end of file diff --git a/romfs/lang/en/app.json b/romfs/lang/en/app.json index 42139af..4f7308b 100644 --- a/romfs/lang/en/app.json +++ b/romfs/lang/en/app.json @@ -112,6 +112,7 @@ "SCREENSHOT_COULD_NOT_LOAD": "Screenshot could not be loaded.", "SCREENSHOT_INSTRUCTIONS": "Press  to change and  to zoom", "SEARCH_FILTERS": "Search and Filters", + "SELECT_A_THEME": "Select a Theme", "SELECT_DIR": "Select a directory", "SELECT_LANG": "Choose the language", "SELECT_UNISTORE": "Select UniStore", diff --git a/source/gui/gfx.cpp b/source/gui/gfx.cpp index 9abbcde..9368bf1 100644 --- a/source/gui/gfx.cpp +++ b/source/gui/gfx.cpp @@ -29,68 +29,18 @@ #include "stringutils.hpp" #include -int GFX::SelectedTheme = 0; - -/* All available Themes here inside that vector. */ -std::vector GFX::Themes = { - /* Default Theme. */ - { - C2D_Color32(50, 73, 98, 255), // Bar. - C2D_Color32(38, 44, 77, 255), // BG. - C2D_Color32(25, 30, 53, 255), // Bar Outline. - WHITE, // Text. - C2D_Color32(50, 73, 98, 255), // Entry bar. - C2D_Color32(25, 30, 53, 255), // Entry Outline. - C2D_Color32(28, 33, 58, 255), // Box Inside. - C2D_Color32(108, 130, 155, 255), // Box Outside. - BLACK, // Box Selected. - C2D_Color32(28, 33, 58, 255), // Progressbar Out. - C2D_Color32(77, 101, 128, 255), // Progressbar In. - C2D_Color32(51, 75, 102, 255), // Searchbar. - C2D_Color32(25, 30, 53, 255), // Searchbar Outline. - C2D_Color32(108, 130, 155, 255), // Sidebar Selected. - C2D_Color32(77, 101, 128, 255), // Sidebar Unselected. - C2D_Color32(77, 101, 128, 255), // Mark Selected. - C2D_Color32(28, 33, 58, 255), // Mark Unselected. - C2D_Color32(28, 33, 58, 255), // Downlist Preview (Top). - C2D_Color32(173, 204, 239, 255) // SideBar Icon Color. - }, - /* Stack Theme. */ - { - C2D_Color32(44, 48, 64, 255), // Bar. - C2D_Color32(52, 56, 64, 255), // BG. - C2D_Color32(22, 24, 32, 255), // Bar Outline. - C2D_Color32(216, 228, 228, 255), // Text. - C2D_Color32(60, 63, 113, 255), // Entry bar. - C2D_Color32(42, 46, 54, 255), // Entry Outline. - C2D_Color32(60, 63, 113, 255), // Box Inside. - C2D_Color32(42, 46, 54, 255), // Box Outside. - C2D_Color32(102, 105, 170, 255), // Box Selected. - C2D_Color32(42, 46, 54, 255), // Progressbar Out. - C2D_Color32(60, 63, 113, 255), // Progressbar In. - C2D_Color32(60, 63, 113, 255), // Searchbar. - C2D_Color32(42, 46, 54, 255), // Searchbar Outline. - C2D_Color32(60, 63, 113, 255), // Sidebar Selected. - C2D_Color32(42, 46, 54, 255), // Sidebar Unselected. - C2D_Color32(60, 63, 113, 255), // Mark Selected. - C2D_Color32(42, 46, 54, 255), // Mark Unselected. - C2D_Color32(52, 60, 76, 255), // Downlist Preview (Top). - C2D_Color32(102, 105, 170, 255) // SideBar Icon Color. - } -}; - /* Draw the base top screen. */ void GFX::DrawTop(void) { Gui::ScreenDraw(Top); - Gui::Draw_Rect(0, 0, 400, 25, GFX::Themes[GFX::SelectedTheme].BarColor); - Gui::Draw_Rect(0, 26, 400, 214, GFX::Themes[GFX::SelectedTheme].BGColor); - Gui::Draw_Rect(0, 25, 400, 1, GFX::Themes[GFX::SelectedTheme].BarOutline); + Gui::Draw_Rect(0, 0, 400, 25, UIThemes->BarColor()); + Gui::Draw_Rect(0, 26, 400, 214, UIThemes->BGColor()); + Gui::Draw_Rect(0, 25, 400, 1, UIThemes->BarOutline()); } /* Draw the base bottom screen. */ void GFX::DrawBottom() { Gui::ScreenDraw(Bottom); - Gui::Draw_Rect(0, 0, 320, 240, GFX::Themes[GFX::SelectedTheme].BGColor); + Gui::Draw_Rect(0, 0, 320, 240, UIThemes->BGColor()); } /* @@ -104,15 +54,15 @@ void GFX::DrawBottom() { uint32_t clr: (Optional) The color of the inside of the box. */ void GFX::DrawBox(float xPos, float yPos, float width, float height, bool selected, uint32_t clr) { - Gui::Draw_Rect(xPos, yPos, width, height, GFX::Themes[GFX::SelectedTheme].BoxInside); // Draw middle BG. + Gui::Draw_Rect(xPos, yPos, width, height, UIThemes->BoxInside()); // Draw middle BG. if (selected) { static constexpr int depth = 3; - Gui::Draw_Rect(xPos - depth, yPos - depth, width + depth * 2, depth, GFX::Themes[GFX::SelectedTheme].BoxSelected); // Top. - Gui::Draw_Rect(xPos - depth, yPos - depth, depth, height + depth * 2, GFX::Themes[GFX::SelectedTheme].BoxSelected); // Left. - Gui::Draw_Rect(xPos + width, yPos - depth, depth, height + depth * 2, GFX::Themes[GFX::SelectedTheme].BoxSelected); // Right. - Gui::Draw_Rect(xPos - depth, yPos + height, width + depth * 2, depth, GFX::Themes[GFX::SelectedTheme].BoxSelected); // Bottom. + Gui::Draw_Rect(xPos - depth, yPos - depth, width + depth * 2, depth, UIThemes->BoxSelected()); // Top. + Gui::Draw_Rect(xPos - depth, yPos - depth, depth, height + depth * 2, UIThemes->BoxSelected()); // Left. + Gui::Draw_Rect(xPos + width, yPos - depth, depth, height + depth * 2, UIThemes->BoxSelected()); // Right. + Gui::Draw_Rect(xPos - depth, yPos + height, width + depth * 2, depth, UIThemes->BoxSelected()); // Bottom. } } @@ -158,7 +108,7 @@ void GFX::DrawTime() { struct tm *timeStruct = gmtime((const time_t *)&unixTime); const std::string str = StringUtils::format("%02i:%02i", timeStruct->tm_hour, timeStruct->tm_min); // :. - Gui::DrawString(11, 5, 0.5f, GFX::Themes[GFX::SelectedTheme].TextColor, str, 0, 0, font); + Gui::DrawString(11, 5, 0.5f, UIThemes->TextColor(), str, 0, 0, font); } static int blinkDelay = 40; @@ -228,7 +178,7 @@ void GFX::HandleBattery() { */ void GFX::DrawIcon(const int Idx, int X, int Y, float ScaleX, float ScaleY) { C2D_ImageTint tint; - C2D_PlainImageTint(&tint, GFX::Themes[GFX::SelectedTheme].SideBarIconColor, 1.0f); + C2D_PlainImageTint(&tint, UIThemes->SideBarIconColor(), 1.0f); C2D_DrawImageAt(C2D_SpriteSheetGetImage(sprites, Idx), X, Y, 0.5f, &tint, ScaleX, ScaleY); } \ No newline at end of file diff --git a/source/gui/msg.cpp b/source/gui/msg.cpp index 3bc95e0..37bfeca 100644 --- a/source/gui/msg.cpp +++ b/source/gui/msg.cpp @@ -39,7 +39,7 @@ void Msg::DisplayMsg(const std::string &Text) { C2D_TargetClear(Bottom, TRANSPARENT); GFX::DrawTop(); - Gui::DrawStringCentered(0, (240 - Gui::GetStringHeight(0.6f, Text)) / 2, 0.6f, GFX::Themes[GFX::SelectedTheme].TextColor, Text, 395, 0, font); + Gui::DrawStringCentered(0, (240 - Gui::GetStringHeight(0.6f, Text)) / 2, 0.6f, UIThemes->TextColor(), Text, 395, 0, font); GFX::DrawBottom(); C3D_FrameEnd(0); } @@ -56,7 +56,7 @@ void Msg::DisplayWarnMsg(const std::string &Text) { C2D_TargetClear(Bottom, TRANSPARENT); GFX::DrawTop(); - Gui::DrawStringCentered(0, 1, 0.6f, GFX::Themes[GFX::SelectedTheme].TextColor, Text, 390, 0, font); + Gui::DrawStringCentered(0, 1, 0.6f, UIThemes->TextColor(), Text, 390, 0, font); GFX::DrawBottom(); C3D_FrameEnd(0); @@ -78,11 +78,11 @@ bool Msg::promptMsg(const std::string &promptMsg) { C2D_TargetClear(Bottom, TRANSPARENT); GFX::DrawTop(); - Gui::Draw_Rect(0, 215, 400, 25, GFX::Themes[GFX::SelectedTheme].BarColor); - Gui::Draw_Rect(0, 214, 400, 1, GFX::Themes[GFX::SelectedTheme].BarOutline); - Gui::DrawStringCentered(0, (240 - Gui::GetStringHeight(0.6f, promptMsg)) / 2, 0.6f, GFX::Themes[GFX::SelectedTheme].TextColor, promptMsg, 395, 0, font); + Gui::Draw_Rect(0, 215, 400, 25, UIThemes->BarColor()); + Gui::Draw_Rect(0, 214, 400, 1, UIThemes->BarOutline()); + Gui::DrawStringCentered(0, (240 - Gui::GetStringHeight(0.6f, promptMsg)) / 2, 0.6f, UIThemes->TextColor(), promptMsg, 395, 0, font); - Gui::DrawStringCentered(0, 218, 0.6f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("CONFIRM_OR_CANCEL"), 390, 0, font); + Gui::DrawStringCentered(0, 218, 0.6f, UIThemes->TextColor(), Lang::get("CONFIRM_OR_CANCEL"), 390, 0, font); GFX::DrawBottom(); C3D_FrameEnd(0); @@ -116,10 +116,10 @@ void Msg::waitMsg(const std::string &msg) { C2D_TargetClear(Bottom, TRANSPARENT); GFX::DrawTop(); - Gui::DrawStringCentered(0, (240 - Gui::GetStringHeight(0.6f, msg)) / 2, 0.6f, GFX::Themes[GFX::SelectedTheme].TextColor, msg, 395, 0, font); - Gui::Draw_Rect(0, 215, 400, 25, GFX::Themes[GFX::SelectedTheme].BarColor); - Gui::Draw_Rect(0, 214, 400, 1, GFX::Themes[GFX::SelectedTheme].BarOutline); - Gui::DrawStringCentered(0, 218, 0.6f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("KEY_CONTINUE"), 390, 0, font); + Gui::DrawStringCentered(0, (240 - Gui::GetStringHeight(0.6f, msg)) / 2, 0.6f, UIThemes->TextColor(), msg, 395, 0, font); + Gui::Draw_Rect(0, 215, 400, 25, UIThemes->BarColor()); + Gui::Draw_Rect(0, 214, 400, 1, UIThemes->BarOutline()); + Gui::DrawStringCentered(0, 218, 0.6f, UIThemes->TextColor(), Lang::get("KEY_CONTINUE"), 390, 0, font); GFX::DrawBottom(); C3D_FrameEnd(0); diff --git a/source/init.cpp b/source/init.cpp index ce1f5ed..3888542 100644 --- a/source/init.cpp +++ b/source/init.cpp @@ -38,8 +38,10 @@ bool exiting = false, is3DSX = false, needUnloadFont = false; C2D_SpriteSheet sprites; int fadeAlpha = 0; u32 old_time_limit; +std::unique_ptr UIThemes = nullptr; std::unique_ptr Music = nullptr; bool dspfirmFound = false; +std::vector Themes = { }; /* Set, if 3DSX or CIA. @@ -131,6 +133,9 @@ Result Init::Initialize() { mkdir("sdmc:/3ds/Universal-Updater/shortcuts", 0777); config = std::make_unique(); + UIThemes = std::make_unique(); + UIThemes->LoadTheme(config->theme()); + Themes = UIThemes->ThemeNames(); CFG_Region region = CFG_REGION_USA; if(config->language() == "zh-CN") { @@ -148,8 +153,6 @@ Result Init::Initialize() { aptSetSleepAllowed(false); hidSetRepeatParameters(20, 8); - GFX::SelectedTheme = config->theme(); - if (GFX::SelectedTheme > (_THEME_AMOUNT - 1)) GFX::SelectedTheme = 0; // In case it is above the max themes. Lang::load(config->language()); Gui::loadSheet("romfs:/gfx/sprites.t3x", sprites); diff --git a/source/main.cpp b/source/main.cpp index a48a4e0..2ac02f3 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -49,6 +49,8 @@ static void InitForARG() { mkdir("sdmc:/3ds/Universal-Updater/shortcuts", 0777); config = std::make_unique(); + UIThemes = std::make_unique(); + UIThemes->LoadTheme(config->theme()); CFG_Region region = CFG_REGION_USA; if(config->language() == "zh-CN") { @@ -60,9 +62,6 @@ static void InitForARG() { } Gui::init(region); - config = std::make_unique(); - GFX::SelectedTheme = config->theme(); - if (GFX::SelectedTheme > (_THEME_AMOUNT - 1)) GFX::SelectedTheme = 0; // In case it is above the max themes. Lang::load(config->language()); Init::LoadFont(); osSetSpeedupEnable(true); // Enable speed-up for New 3DS users. diff --git a/source/menu/downList.cpp b/source/menu/downList.cpp index 90eb77c..d0d3cdf 100644 --- a/source/menu/downList.cpp +++ b/source/menu/downList.cpp @@ -111,17 +111,17 @@ void StoreUtils::DrawDownList(const std::vector &entries, bool fetc /* For the Top Screen. */ if (StoreUtils::store && StoreUtils::store->GetValid() && !fetch && entry) { if (entries.size() > 0) { - Gui::Draw_Rect(0, 174, 400, 66, GFX::Themes[GFX::SelectedTheme].DownListPrev); + Gui::Draw_Rect(0, 174, 400, 66, UIThemes->DownListPrev()); const C2D_Image tempImg = entry->GetIcon(); const uint8_t offsetW = (48 - tempImg.subtex->width) / 2; // Center W. const uint8_t offsetH = (48 - tempImg.subtex->height) / 2; // Center H. C2D_DrawImageAt(tempImg, 9 + offsetW, 174 + 9 + offsetH, 0.5); - Gui::DrawString(70, 174 + 15, 0.45f, GFX::Themes[GFX::SelectedTheme].TextColor, entries[StoreUtils::store->GetDownloadIndex()], 310, 0, font); + Gui::DrawString(70, 174 + 15, 0.45f, UIThemes->TextColor(), entries[StoreUtils::store->GetDownloadIndex()], 310, 0, font); if (!sizes.empty()) { if (sizes[StoreUtils::store->GetDownloadIndex()] != "") { - Gui::DrawString(70, 174 + 30, 0.45f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("SIZE") + ": " + sizes[StoreUtils::store->GetDownloadIndex()], 310, 0, font); + Gui::DrawString(70, 174 + 30, 0.45f, UIThemes->TextColor(), Lang::get("SIZE") + ": " + sizes[StoreUtils::store->GetDownloadIndex()], 310, 0, font); } } } @@ -132,15 +132,15 @@ void StoreUtils::DrawDownList(const std::vector &entries, bool fetc Animation::QueueEntryDone(); GFX::DrawBottom(); - Gui::Draw_Rect(40, 0, 280, 25, GFX::Themes[GFX::SelectedTheme].EntryBar); - Gui::Draw_Rect(40, 25, 280, 1, GFX::Themes[GFX::SelectedTheme].EntryOutline); - Gui::DrawStringCentered(17, 2, 0.6, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("AVAILABLE_DOWNLOADS"), 273, 0, font); + Gui::Draw_Rect(40, 0, 280, 25, UIThemes->EntryBar()); + Gui::Draw_Rect(40, 25, 280, 1, UIThemes->EntryOutline()); + Gui::DrawStringCentered(17, 2, 0.6, UIThemes->TextColor(), Lang::get("AVAILABLE_DOWNLOADS"), 273, 0, font); if (StoreUtils::store && StoreUtils::store->GetValid() && !fetch && entry) { if (entries.size() > 0) { for (int i = 0; i < DOWNLOAD_ENTRIES && i < (int)entries.size(); i++) { - if (StoreUtils::store->GetDownloadIndex() == i + StoreUtils::store->GetDownloadSIndex()) Gui::Draw_Rect(downloadBoxes[i].x, downloadBoxes[i].y, downloadBoxes[i].w, downloadBoxes[i].h, GFX::Themes[GFX::SelectedTheme].MarkSelected); - Gui::DrawStringCentered(46 - 160 + (241 / 2), downloadBoxes[i].y + 4, 0.45f, GFX::Themes[GFX::SelectedTheme].TextColor, entries[(i + StoreUtils::store->GetDownloadSIndex())], 235, 0, font); + if (StoreUtils::store->GetDownloadIndex() == i + StoreUtils::store->GetDownloadSIndex()) Gui::Draw_Rect(downloadBoxes[i].x, downloadBoxes[i].y, downloadBoxes[i].w, downloadBoxes[i].h, UIThemes->MarkSelected()); + Gui::DrawStringCentered(46 - 160 + (241 / 2), downloadBoxes[i].y + 4, 0.45f, UIThemes->TextColor(), entries[(i + StoreUtils::store->GetDownloadSIndex())], 235, 0, font); if (installs[(i + StoreUtils::store->GetDownloadSIndex())]) GFX::DrawSprite(sprites_installed_idx, installedPos[i].x, installedPos[i].y); } @@ -149,7 +149,7 @@ void StoreUtils::DrawDownList(const std::vector &entries, bool fetc } else { // If no downloads available.. - Gui::DrawStringCentered(46 - 160 + (241 / 2), downloadBoxes[0].y + 4, 0.5f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("NO_DOWNLOADS_AVAILABLE"), 235, 0, font); + Gui::DrawStringCentered(46 - 160 + (241 / 2), downloadBoxes[0].y + 4, 0.5f, UIThemes->TextColor(), Lang::get("NO_DOWNLOADS_AVAILABLE"), 235, 0, font); } } } diff --git a/source/menu/entryInfo.cpp b/source/menu/entryInfo.cpp index 301301c..c23edf1 100644 --- a/source/menu/entryInfo.cpp +++ b/source/menu/entryInfo.cpp @@ -42,23 +42,23 @@ extern bool QueueRuns; */ void StoreUtils::DrawEntryInfo(const std::unique_ptr &entry) { if (StoreUtils::store && entry) { // Ensure, store & entry is not a nullptr. - Gui::Draw_Rect(40, 0, 280, 36, GFX::Themes[GFX::SelectedTheme].EntryBar); - Gui::Draw_Rect(40, 36, 280, 1, GFX::Themes[GFX::SelectedTheme].EntryOutline); + Gui::Draw_Rect(40, 0, 280, 36, UIThemes->EntryBar()); + Gui::Draw_Rect(40, 36, 280, 1, UIThemes->EntryOutline()); - Gui::DrawStringCentered(17, 0, 0.6, GFX::Themes[GFX::SelectedTheme].TextColor, entry->GetTitle(), 273, 0, font); - Gui::DrawStringCentered(17, 20, 0.4, GFX::Themes[GFX::SelectedTheme].TextColor, entry->GetAuthor(), 273, 0, font); - Gui::DrawStringCentered(17, 50, 0.4, GFX::Themes[GFX::SelectedTheme].TextColor, entry->GetDescription(), 248, 0, font, C2D_WordWrap); + Gui::DrawStringCentered(17, 0, 0.6, UIThemes->TextColor(), entry->GetTitle(), 273, 0, font); + Gui::DrawStringCentered(17, 20, 0.4, UIThemes->TextColor(), entry->GetAuthor(), 273, 0, font); + Gui::DrawStringCentered(17, 50, 0.4, UIThemes->TextColor(), entry->GetDescription(), 248, 0, font, C2D_WordWrap); - Gui::DrawString(53, 130, 0.45, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("VERSION") + ": " + entry->GetVersion(), 248, 0, font); - Gui::DrawString(53, 145, 0.45, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("CATEGORY") + ": " + entry->GetCategory(), 248, 0, font); - Gui::DrawString(53, 160, 0.45, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("CONSOLE") + ": " + entry->GetConsole(), 248, 0, font); - Gui::DrawString(53, 175, 0.45, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("LAST_UPDATED") + ": " + entry->GetLastUpdated(), 248, 0, font); - Gui::DrawString(53, 190, 0.45, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("LICENSE") + ": " + entry->GetLicense(), 248, 0, font); + Gui::DrawString(53, 130, 0.45, UIThemes->TextColor(), Lang::get("VERSION") + ": " + entry->GetVersion(), 248, 0, font); + Gui::DrawString(53, 145, 0.45, UIThemes->TextColor(), Lang::get("CATEGORY") + ": " + entry->GetCategory(), 248, 0, font); + Gui::DrawString(53, 160, 0.45, UIThemes->TextColor(), Lang::get("CONSOLE") + ": " + entry->GetConsole(), 248, 0, font); + Gui::DrawString(53, 175, 0.45, UIThemes->TextColor(), Lang::get("LAST_UPDATED") + ": " + entry->GetLastUpdated(), 248, 0, font); + Gui::DrawString(53, 190, 0.45, UIThemes->TextColor(), Lang::get("LICENSE") + ": " + entry->GetLicense(), 248, 0, font); GFX::DrawBox(btn.x, btn.y, btn.w, btn.h, false); if (!entry->GetScreenshots().empty()) GFX::DrawSprite(sprites_screenshot_idx, sshot.x, sshot.y); if (entry->GetReleaseNotes() != "") GFX::DrawSprite(sprites_notes_idx, notes.x, notes.y); - Gui::DrawString(btn.x + 5, btn.y + 2, 0.6f, GFX::Themes[GFX::SelectedTheme].TextColor, "★", 0, 0, font); + Gui::DrawString(btn.x + 5, btn.y + 2, 0.6f, UIThemes->TextColor(), "★", 0, 0, font); } } diff --git a/source/menu/grid.cpp b/source/menu/grid.cpp index d54dc3c..0a5618e 100644 --- a/source/menu/grid.cpp +++ b/source/menu/grid.cpp @@ -56,7 +56,7 @@ void StoreUtils::DrawGrid() { C2D_DrawImageAt(StoreUtils::store->GetStoreImg(), 0, 26, 0.5f, nullptr); } else { - Gui::Draw_Rect(0, 26, 400, 214, GFX::Themes[GFX::SelectedTheme].BGColor); + Gui::Draw_Rect(0, 26, 400, 214, UIThemes->BGColor()); } for (int i = 0, i2 = 0 + (StoreUtils::store->GetScreenIndx() * 5); i2 < 15 + (StoreUtils::store->GetScreenIndx() * 5) && i2 < (int)StoreUtils::entries.size(); i2++, i++) { diff --git a/source/menu/list.cpp b/source/menu/list.cpp index 66fd7cf..b25c95e 100644 --- a/source/menu/list.cpp +++ b/source/menu/list.cpp @@ -42,7 +42,7 @@ void StoreUtils::DrawList() { C2D_DrawImageAt(StoreUtils::store->GetStoreImg(), 0, 26, 0.5f, nullptr); } else { - Gui::Draw_Rect(0, 26, 400, 214, GFX::Themes[GFX::SelectedTheme].BGColor); + Gui::Draw_Rect(0, 26, 400, 214, UIThemes->BGColor()); } if (StoreUtils::entries.size() > 0) { @@ -63,8 +63,8 @@ void StoreUtils::DrawList() { } if (StoreUtils::entries[i + StoreUtils::store->GetScreenIndx()]->GetUpdateAvl()) GFX::DrawSprite(sprites_update_app_idx, StoreBoxesList[i].x + 32, StoreBoxesList[i].y + 32); - Gui::DrawStringCentered(29, StoreBoxesList[i].y + 5, 0.6f, GFX::Themes[GFX::SelectedTheme].TextColor, StoreUtils::entries[i + StoreUtils::store->GetScreenIndx()]->GetTitle(), 300, 0, font); - Gui::DrawStringCentered(29, StoreBoxesList[i].y + 24, 0.6f, GFX::Themes[GFX::SelectedTheme].TextColor, StoreUtils::entries[i + StoreUtils::store->GetScreenIndx()]->GetAuthor(), 300, 0, font); + Gui::DrawStringCentered(29, StoreBoxesList[i].y + 5, 0.6f, UIThemes->TextColor(), StoreUtils::entries[i + StoreUtils::store->GetScreenIndx()]->GetTitle(), 300, 0, font); + Gui::DrawStringCentered(29, StoreBoxesList[i].y + 24, 0.6f, UIThemes->TextColor(), StoreUtils::entries[i + StoreUtils::store->GetScreenIndx()]->GetAuthor(), 300, 0, font); } } } diff --git a/source/menu/markMenu.cpp b/source/menu/markMenu.cpp index f40147f..581d56d 100644 --- a/source/menu/markMenu.cpp +++ b/source/menu/markMenu.cpp @@ -48,28 +48,28 @@ void StoreUtils::DisplayMarkBox(int marks) { Gui::Draw_Rect(0, 0, 320, 240, DIM_COLOR); // Darken. Gui::Draw_Rect(markBox[0].x, markBox[0].y, markBox[0].w, markBox[0].h, (marks & favoriteMarks::STAR ? - GFX::Themes[GFX::SelectedTheme].MarkSelected : GFX::Themes[GFX::SelectedTheme].MarkUnselected)); + UIThemes->MarkSelected() : UIThemes->MarkUnselected())); Gui::Draw_Rect(markBox[1].x, markBox[1].y, markBox[1].w, markBox[1].h, (marks & favoriteMarks::HEART ? - GFX::Themes[GFX::SelectedTheme].MarkSelected : GFX::Themes[GFX::SelectedTheme].MarkUnselected)); + UIThemes->MarkSelected() : UIThemes->MarkUnselected())); Gui::Draw_Rect(markBox[2].x, markBox[2].y, markBox[2].w, markBox[2].h, (marks & favoriteMarks::DIAMOND ? - GFX::Themes[GFX::SelectedTheme].MarkSelected : GFX::Themes[GFX::SelectedTheme].MarkUnselected)); + UIThemes->MarkSelected() : UIThemes->MarkUnselected())); Gui::Draw_Rect(markBox[3].x, markBox[3].y, markBox[3].w, markBox[3].h, (marks & favoriteMarks::CLUBS ? - GFX::Themes[GFX::SelectedTheme].MarkSelected : GFX::Themes[GFX::SelectedTheme].MarkUnselected)); + UIThemes->MarkSelected() : UIThemes->MarkUnselected())); Gui::Draw_Rect(markBox[4].x, markBox[4].y, markBox[4].w, markBox[4].h, (marks & favoriteMarks::SPADE ? - GFX::Themes[GFX::SelectedTheme].MarkSelected : GFX::Themes[GFX::SelectedTheme].MarkUnselected)); + UIThemes->MarkSelected() : UIThemes->MarkUnselected())); - Gui::DrawString(markBox[0].x + 15, markBox[0].y + 11, 0.9, GFX::Themes[GFX::SelectedTheme].TextColor, "★", 0, 0, font); - Gui::DrawString(markBox[1].x + 15, markBox[1].y + 11, 0.9, GFX::Themes[GFX::SelectedTheme].TextColor, "♥", 0, 0, font); - Gui::DrawString(markBox[2].x + 15, markBox[2].y + 11, 0.9, GFX::Themes[GFX::SelectedTheme].TextColor, "♦", 0, 0, font); - Gui::DrawString(markBox[3].x + 15, markBox[3].y + 11, 0.9, GFX::Themes[GFX::SelectedTheme].TextColor, "♣", 0, 0, font); - Gui::DrawString(markBox[4].x + 15, markBox[4].y + 11, 0.9, GFX::Themes[GFX::SelectedTheme].TextColor, "♠", 0, 0, font); + Gui::DrawString(markBox[0].x + 15, markBox[0].y + 11, 0.9, UIThemes->TextColor(), "★", 0, 0, font); + Gui::DrawString(markBox[1].x + 15, markBox[1].y + 11, 0.9, UIThemes->TextColor(), "♥", 0, 0, font); + Gui::DrawString(markBox[2].x + 15, markBox[2].y + 11, 0.9, UIThemes->TextColor(), "♦", 0, 0, font); + Gui::DrawString(markBox[3].x + 15, markBox[3].y + 11, 0.9, UIThemes->TextColor(), "♣", 0, 0, font); + Gui::DrawString(markBox[4].x + 15, markBox[4].y + 11, 0.9, UIThemes->TextColor(), "♠", 0, 0, font); GFX::DrawBox(markBox[5].x, markBox[5].y, markBox[5].w, markBox[5].h, false); - Gui::DrawString(markBox[5].x + 5, markBox[5].y + 2, 0.6f, GFX::Themes[GFX::SelectedTheme].TextColor, "★", 0, 0, font); + Gui::DrawString(markBox[5].x + 5, markBox[5].y + 2, 0.6f, UIThemes->TextColor(), "★", 0, 0, font); } /* diff --git a/source/menu/queueMenu.cpp b/source/menu/queueMenu.cpp index b66d43f..655e1ce 100644 --- a/source/menu/queueMenu.cpp +++ b/source/menu/queueMenu.cpp @@ -59,14 +59,14 @@ extern std::deque> queueEntries; void DrawStatus(QueueStatus s) { if (!ShowQueueProgress) { if (!queueEntries.empty()) { - Gui::DrawString(QueueBoxes[0].x + 10, QueueBoxes[0].y + 5, 0.4f, GFX::Themes[GFX::SelectedTheme].TextColor, queueEntries[0]->name, 230, 0, font); + Gui::DrawString(QueueBoxes[0].x + 10, QueueBoxes[0].y + 5, 0.4f, UIThemes->TextColor(), queueEntries[0]->name, 230, 0, font); char prog[256]; snprintf(prog, sizeof(prog), Lang::get("QUEUE_PROGRESS").c_str(), queueEntries[0]->current, queueEntries[0]->total); - Gui::DrawString(QueueBoxes[0].x + 241, QueueBoxes[0].y + 68, 0.4f, GFX::Themes[GFX::SelectedTheme].TextColor, prog, 80, 0, font, C2D_AlignRight); + Gui::DrawString(QueueBoxes[0].x + 241, QueueBoxes[0].y + 68, 0.4f, UIThemes->TextColor(), prog, 80, 0, font, C2D_AlignRight); - Gui::Draw_Rect(QueueBoxes[0].x + 60, QueueBoxes[0].y + 30, 182, 30, GFX::Themes[GFX::SelectedTheme].ProgressbarOut); - Gui::Draw_Rect(QueueBoxes[0].x + 60 + 1, QueueBoxes[0].y + 30 + 1, (int)(((float)queueEntries[0]->current / (float)queueEntries[0]->total) * 180.0f), 28, GFX::Themes[GFX::SelectedTheme].ProgressbarIn); + Gui::Draw_Rect(QueueBoxes[0].x + 60, QueueBoxes[0].y + 30, 182, 30, UIThemes->ProgressbarOut()); + Gui::Draw_Rect(QueueBoxes[0].x + 60 + 1, QueueBoxes[0].y + 30 + 1, (int)(((float)queueEntries[0]->current / (float)queueEntries[0]->total) * 180.0f), 28, UIThemes->ProgressbarIn()); switch(s) { case QueueStatus::Done: @@ -75,31 +75,31 @@ void DrawStatus(QueueStatus s) { break; case QueueStatus::Copying: - Gui::DrawString(QueueBoxes[0].x + 60, QueueBoxes[0].y + 68, 0.4f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("OP_COPYING"), 120, 0, font); + Gui::DrawString(QueueBoxes[0].x + 60, QueueBoxes[0].y + 68, 0.4f, UIThemes->TextColor(), Lang::get("OP_COPYING"), 120, 0, font); break; case QueueStatus::Deleting: - Gui::DrawString(QueueBoxes[0].x + 60, QueueBoxes[0].y + 68, 0.4f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("OP_DELETING"), 120, 0, font); + Gui::DrawString(QueueBoxes[0].x + 60, QueueBoxes[0].y + 68, 0.4f, UIThemes->TextColor(), Lang::get("OP_DELETING"), 120, 0, font); break; case QueueStatus::Downloading: - Gui::DrawString(QueueBoxes[0].x + 60, QueueBoxes[0].y + 68, 0.4f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("OP_DOWNLOADING"), 120, 0, font); + Gui::DrawString(QueueBoxes[0].x + 60, QueueBoxes[0].y + 68, 0.4f, UIThemes->TextColor(), Lang::get("OP_DOWNLOADING"), 120, 0, font); break; case QueueStatus::Extracting: - Gui::DrawString(QueueBoxes[0].x + 60, QueueBoxes[0].y + 68, 0.4f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("OP_EXTRACTING"), 120, 0, font); + Gui::DrawString(QueueBoxes[0].x + 60, QueueBoxes[0].y + 68, 0.4f, UIThemes->TextColor(), Lang::get("OP_EXTRACTING"), 120, 0, font); break; case QueueStatus::Installing: - Gui::DrawString(QueueBoxes[0].x + 60, QueueBoxes[0].y + 68, 0.4f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("OP_INSTALLING"), 120, 0, font); + Gui::DrawString(QueueBoxes[0].x + 60, QueueBoxes[0].y + 68, 0.4f, UIThemes->TextColor(), Lang::get("OP_INSTALLING"), 120, 0, font); break; case QueueStatus::Moving: - Gui::DrawString(QueueBoxes[0].x + 60, QueueBoxes[0].y + 68, 0.4f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("OP_MOVING"), 120, 0, font); + Gui::DrawString(QueueBoxes[0].x + 60, QueueBoxes[0].y + 68, 0.4f, UIThemes->TextColor(), Lang::get("OP_MOVING"), 120, 0, font); break; case QueueStatus::Request: - Gui::DrawString(QueueBoxes[0].x + 60, QueueBoxes[0].y + 68, 0.4f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("OP_WAITING"), 120, 0, font); + Gui::DrawString(QueueBoxes[0].x + 60, QueueBoxes[0].y + 68, 0.4f, UIThemes->TextColor(), Lang::get("OP_WAITING"), 120, 0, font); break; } } @@ -113,7 +113,7 @@ void DrawStatus(QueueStatus s) { if (!queueEntries.empty()) { char prog[256]; snprintf(prog, sizeof(prog), Lang::get("QUEUE_PROGRESS").c_str(), queueEntries[0]->current, queueEntries[0]->total); - Gui::DrawString((QueueBoxes[0].x + 241), QueueBoxes[0].y + 68, 0.4f, GFX::Themes[GFX::SelectedTheme].TextColor, prog, 80, 0, font, C2D_AlignRight); + Gui::DrawString((QueueBoxes[0].x + 241), QueueBoxes[0].y + 68, 0.4f, UIThemes->TextColor(), prog, 80, 0, font, C2D_AlignRight); } /* String Handle. */ @@ -183,54 +183,54 @@ void DrawStatus(QueueStatus s) { break; case QueueStatus::Copying: - Gui::DrawString(QueueBoxes[0].x + 10, QueueBoxes[0].y + 5, 0.4f, GFX::Themes[GFX::SelectedTheme].TextColor, str, 230, 0, font); - Gui::Draw_Rect(QueueBoxes[0].x + 60, QueueBoxes[0].y + 30, 182, 30, GFX::Themes[GFX::SelectedTheme].ProgressbarOut); - Gui::Draw_Rect(QueueBoxes[0].x + 60 + 1, QueueBoxes[0].y + 30 + 1, (int)(((float)copyOffset / (float)copySize) * 180.0f), 28, GFX::Themes[GFX::SelectedTheme].ProgressbarIn); + Gui::DrawString(QueueBoxes[0].x + 10, QueueBoxes[0].y + 5, 0.4f, UIThemes->TextColor(), str, 230, 0, font); + Gui::Draw_Rect(QueueBoxes[0].x + 60, QueueBoxes[0].y + 30, 182, 30, UIThemes->ProgressbarOut()); + Gui::Draw_Rect(QueueBoxes[0].x + 60 + 1, QueueBoxes[0].y + 30 + 1, (int)(((float)copyOffset / (float)copySize) * 180.0f), 28, UIThemes->ProgressbarIn()); break; case QueueStatus::Deleting: - Gui::DrawString(QueueBoxes[0].x + 10, QueueBoxes[0].y + 5, 0.4f, GFX::Themes[GFX::SelectedTheme].TextColor, str, 230, 0, font); + Gui::DrawString(QueueBoxes[0].x + 10, QueueBoxes[0].y + 5, 0.4f, UIThemes->TextColor(), str, 230, 0, font); break; case QueueStatus::Downloading: - Gui::DrawString(QueueBoxes[0].x + 10, QueueBoxes[0].y + 5, 0.4f, GFX::Themes[GFX::SelectedTheme].TextColor, str, 230, 0, font); - Gui::Draw_Rect(QueueBoxes[0].x + 60, QueueBoxes[0].y + 30, 182, 30, GFX::Themes[GFX::SelectedTheme].ProgressbarOut); - Gui::Draw_Rect(QueueBoxes[0].x + 60 + 1, QueueBoxes[0].y + 30 + 1, (int)(((float)downloadNow / (float)downloadTotal) * 180.0f), 28, GFX::Themes[GFX::SelectedTheme].ProgressbarIn); - Gui::DrawString(QueueBoxes[0].x + 60, QueueBoxes[0].y + 68, 0.4f, GFX::Themes[GFX::SelectedTheme].TextColor, str2, 120, 0, font); + Gui::DrawString(QueueBoxes[0].x + 10, QueueBoxes[0].y + 5, 0.4f, UIThemes->TextColor(), str, 230, 0, font); + Gui::Draw_Rect(QueueBoxes[0].x + 60, QueueBoxes[0].y + 30, 182, 30, UIThemes->ProgressbarOut()); + Gui::Draw_Rect(QueueBoxes[0].x + 60 + 1, QueueBoxes[0].y + 30 + 1, (int)(((float)downloadNow / (float)downloadTotal) * 180.0f), 28, UIThemes->ProgressbarIn()); + Gui::DrawString(QueueBoxes[0].x + 60, QueueBoxes[0].y + 68, 0.4f, UIThemes->TextColor(), str2, 120, 0, font); break; case QueueStatus::Extracting: - Gui::DrawString(QueueBoxes[0].x + 10, QueueBoxes[0].y + 5, 0.4f, GFX::Themes[GFX::SelectedTheme].TextColor, str, 230, 0, font); - Gui::Draw_Rect(QueueBoxes[0].x + 60, QueueBoxes[0].y + 30, 182, 30, GFX::Themes[GFX::SelectedTheme].ProgressbarOut); - Gui::Draw_Rect(QueueBoxes[0].x + 60 + 1, QueueBoxes[0].y + 30 + 1, (int)(((float)writeOffset / (float)extractSize) * 180.0f), 28, GFX::Themes[GFX::SelectedTheme].ProgressbarIn); - Gui::DrawString(QueueBoxes[0].x + 60, QueueBoxes[0].y + 68, 0.4f, GFX::Themes[GFX::SelectedTheme].TextColor, str2, 120, 0, font); + Gui::DrawString(QueueBoxes[0].x + 10, QueueBoxes[0].y + 5, 0.4f, UIThemes->TextColor(), str, 230, 0, font); + Gui::Draw_Rect(QueueBoxes[0].x + 60, QueueBoxes[0].y + 30, 182, 30, UIThemes->ProgressbarOut()); + Gui::Draw_Rect(QueueBoxes[0].x + 60 + 1, QueueBoxes[0].y + 30 + 1, (int)(((float)writeOffset / (float)extractSize) * 180.0f), 28, UIThemes->ProgressbarIn()); + Gui::DrawString(QueueBoxes[0].x + 60, QueueBoxes[0].y + 68, 0.4f, UIThemes->TextColor(), str2, 120, 0, font); break; case QueueStatus::Installing: - Gui::DrawString(QueueBoxes[0].x + 10, QueueBoxes[0].y + 5, 0.4f, GFX::Themes[GFX::SelectedTheme].TextColor, str, 230, 0, font); - Gui::Draw_Rect(QueueBoxes[0].x + 60, QueueBoxes[0].y + 30, 182, 30, GFX::Themes[GFX::SelectedTheme].ProgressbarOut); - Gui::Draw_Rect(QueueBoxes[0].x + 60 + 1, QueueBoxes[0].y + 30 + 1, (int)(((float)installOffset / (float)installSize) * 180.0f), 28, GFX::Themes[GFX::SelectedTheme].ProgressbarIn); + Gui::DrawString(QueueBoxes[0].x + 10, QueueBoxes[0].y + 5, 0.4f, UIThemes->TextColor(), str, 230, 0, font); + Gui::Draw_Rect(QueueBoxes[0].x + 60, QueueBoxes[0].y + 30, 182, 30, UIThemes->ProgressbarOut()); + Gui::Draw_Rect(QueueBoxes[0].x + 60 + 1, QueueBoxes[0].y + 30 + 1, (int)(((float)installOffset / (float)installSize) * 180.0f), 28, UIThemes->ProgressbarIn()); break; case QueueStatus::Moving: - Gui::DrawString(QueueBoxes[0].x + 10, QueueBoxes[0].y + 5, 0.4f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("OP_MOVING"), 230, 0, font); + Gui::DrawString(QueueBoxes[0].x + 10, QueueBoxes[0].y + 5, 0.4f, UIThemes->TextColor(), Lang::get("OP_MOVING"), 230, 0, font); break; case QueueStatus::Request: - Gui::DrawString(QueueBoxes[0].x + 10, QueueBoxes[0].y + 5, 0.4f, GFX::Themes[GFX::SelectedTheme].TextColor, str, 230, 0, font); - Gui::Draw_Rect(QueueBoxes[0].x + 60, QueueBoxes[0].y + 30, 182, 30, GFX::Themes[GFX::SelectedTheme].ProgressbarOut); - Gui::DrawStringCentered(QueueBoxes[0].x + 151 - 160, QueueBoxes[0].y + 32, 0.8f, GFX::Themes[GFX::SelectedTheme].TextColor, str2, 180, 0, font); + Gui::DrawString(QueueBoxes[0].x + 10, QueueBoxes[0].y + 5, 0.4f, UIThemes->TextColor(), str, 230, 0, font); + Gui::Draw_Rect(QueueBoxes[0].x + 60, QueueBoxes[0].y + 30, 182, 30, UIThemes->ProgressbarOut()); + Gui::DrawStringCentered(QueueBoxes[0].x + 151 - 160, QueueBoxes[0].y + 32, 0.8f, UIThemes->TextColor(), str2, 180, 0, font); break; } } void StoreUtils::DrawQueueMenu(const int queueIndex) { - Gui::Draw_Rect(40, 0, 280, 25, GFX::Themes[GFX::SelectedTheme].EntryBar); - Gui::Draw_Rect(40, 25, 280, 1, GFX::Themes[GFX::SelectedTheme].EntryOutline); - Gui::DrawStringCentered(17, 2, 0.6, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("QUEUE"), 273, 0, font); + Gui::Draw_Rect(40, 0, 280, 25, UIThemes->EntryBar()); + Gui::Draw_Rect(40, 25, 280, 1, UIThemes->EntryOutline()); + Gui::DrawStringCentered(17, 2, 0.6, UIThemes->TextColor(), Lang::get("QUEUE"), 273, 0, font); if (!queueEntries.empty()) { - Gui::Draw_Rect(QueueBoxes[0].x, QueueBoxes[0].y, QueueBoxes[0].w, QueueBoxes[0].h, GFX::Themes[GFX::SelectedTheme].MarkSelected); + Gui::Draw_Rect(QueueBoxes[0].x, QueueBoxes[0].y, QueueBoxes[0].w, QueueBoxes[0].h, UIThemes->MarkSelected()); const C2D_Image tempImg = queueEntries[0]->icn; const uint8_t offsetW = (48 - tempImg.subtex->width) / 2; // Center W. @@ -242,16 +242,16 @@ void StoreUtils::DrawQueueMenu(const int queueIndex) { /* The next Queue Entries being displayed below. */ if ((1 + queueMenuIdx) < (int)queueEntries.size()) { - Gui::Draw_Rect(QueueBoxes[1].x, QueueBoxes[1].y, QueueBoxes[1].w, QueueBoxes[1].h, GFX::Themes[GFX::SelectedTheme].MarkUnselected); + Gui::Draw_Rect(QueueBoxes[1].x, QueueBoxes[1].y, QueueBoxes[1].w, QueueBoxes[1].h, UIThemes->MarkUnselected()); const C2D_Image tempImg2 = queueEntries[1 + queueMenuIdx]->icn; const uint8_t offsetW2 = (48 - tempImg2.subtex->width) / 2; // Center W. const uint8_t offsetH2 = (48 - tempImg2.subtex->height) / 2; // Center H. C2D_DrawImageAt(tempImg2, QueueBoxes[1].x + 5 + offsetW2, QueueBoxes[1].y + 21 + offsetH2, 0.5f); - Gui::DrawString(QueueBoxes[1].x + 10, QueueBoxes[1].y + 5, 0.4f, GFX::Themes[GFX::SelectedTheme].TextColor, queueEntries[1 + queueMenuIdx]->name, 230, 0, font); + Gui::DrawString(QueueBoxes[1].x + 10, QueueBoxes[1].y + 5, 0.4f, UIThemes->TextColor(), queueEntries[1 + queueMenuIdx]->name, 230, 0, font); - Gui::DrawString(QueueBoxes[1].x + 60, QueueBoxes[1].y + 30, 0.4f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("QUEUE_POSITION") + ": " + std::to_string(queueMenuIdx + 1), 0, 0, font); + Gui::DrawString(QueueBoxes[1].x + 60, QueueBoxes[1].y + 30, 0.4f, UIThemes->TextColor(), Lang::get("QUEUE_POSITION") + ": " + std::to_string(queueMenuIdx + 1), 0, 0, font); /* Cancel. */ GFX::DrawSprite(sprites_cancel_idx, QueueBoxes[3].x, QueueBoxes[3].y); diff --git a/source/menu/releaseNotes.cpp b/source/menu/releaseNotes.cpp index fafc67b..432928e 100644 --- a/source/menu/releaseNotes.cpp +++ b/source/menu/releaseNotes.cpp @@ -32,17 +32,17 @@ void StoreUtils::DrawReleaseNotes(const int &scrollIndex, const std::unique_ptr &entry) { if (entry && StoreUtils::store) { Gui::ScreenDraw(Top); - Gui::Draw_Rect(0, 26, 400, 214, GFX::Themes[GFX::SelectedTheme].BGColor); - Gui::DrawString(5, 25 - scrollIndex, 0.5f, GFX::Themes[GFX::SelectedTheme].TextColor, entry->GetReleaseNotes(), 390, 0, font, C2D_WordWrap); - Gui::Draw_Rect(0, 0, 400, 25, GFX::Themes[GFX::SelectedTheme].BarColor); - Gui::Draw_Rect(0, 25, 400, 1, GFX::Themes[GFX::SelectedTheme].BarOutline); - Gui::DrawStringCentered(0, 1, 0.7f, GFX::Themes[GFX::SelectedTheme].TextColor, entry->GetTitle(), 390, 0, font); + Gui::Draw_Rect(0, 26, 400, 214, UIThemes->BGColor()); + Gui::DrawString(5, 25 - scrollIndex, 0.5f, UIThemes->TextColor(), entry->GetReleaseNotes(), 390, 0, font, C2D_WordWrap); + Gui::Draw_Rect(0, 0, 400, 25, UIThemes->BarColor()); + Gui::Draw_Rect(0, 25, 400, 1, UIThemes->BarOutline()); + Gui::DrawStringCentered(0, 1, 0.7f, UIThemes->TextColor(), entry->GetTitle(), 390, 0, font); } else { Gui::ScreenDraw(Top); - Gui::Draw_Rect(0, 0, 400, 25, GFX::Themes[GFX::SelectedTheme].BarColor); - Gui::Draw_Rect(0, 25, 400, 1, GFX::Themes[GFX::SelectedTheme].BarOutline); - Gui::Draw_Rect(0, 26, 400, 214, GFX::Themes[GFX::SelectedTheme].BGColor); + Gui::Draw_Rect(0, 0, 400, 25, UIThemes->BarColor()); + Gui::Draw_Rect(0, 25, 400, 1, UIThemes->BarOutline()); + Gui::Draw_Rect(0, 26, 400, 214, UIThemes->BGColor()); } Animation::QueueEntryDone(); @@ -89,18 +89,18 @@ void DisplayChangelog() { C2D_TargetClear(Bottom, C2D_Color32(0, 0, 0, 0)); Gui::ScreenDraw(Top); - Gui::Draw_Rect(0, 26, 400, 214, GFX::Themes[GFX::SelectedTheme].BGColor); - Gui::DrawString(5, 25 - scrollIndex, 0.5f, GFX::Themes[GFX::SelectedTheme].TextColor, notes, 390, 0, font, C2D_WordWrap); - Gui::Draw_Rect(0, 0, 400, 25, GFX::Themes[GFX::SelectedTheme].BarColor); - Gui::Draw_Rect(0, 25, 400, 1, GFX::Themes[GFX::SelectedTheme].BarOutline); - Gui::DrawStringCentered(0, 1, 0.7f, GFX::Themes[GFX::SelectedTheme].TextColor, "Universal-Updater", 390, 0, font); - Gui::Draw_Rect(0, 215, 400, 25, GFX::Themes[GFX::SelectedTheme].BarColor); - Gui::Draw_Rect(0, 214, 400, 1, GFX::Themes[GFX::SelectedTheme].BarOutline); - Gui::DrawStringCentered(0, 217, 0.7f, GFX::Themes[GFX::SelectedTheme].TextColor, C_V, 390, 0, font); + Gui::Draw_Rect(0, 26, 400, 214, UIThemes->BGColor()); + Gui::DrawString(5, 25 - scrollIndex, 0.5f, UIThemes->TextColor(), notes, 390, 0, font, C2D_WordWrap); + Gui::Draw_Rect(0, 0, 400, 25, UIThemes->BarColor()); + Gui::Draw_Rect(0, 25, 400, 1, UIThemes->BarOutline()); + Gui::DrawStringCentered(0, 1, 0.7f, UIThemes->TextColor(), "Universal-Updater", 390, 0, font); + Gui::Draw_Rect(0, 215, 400, 25, UIThemes->BarColor()); + Gui::Draw_Rect(0, 214, 400, 1, UIThemes->BarOutline()); + Gui::DrawStringCentered(0, 217, 0.7f, UIThemes->TextColor(), C_V, 390, 0, font); GFX::DrawBottom(); - Gui::Draw_Rect(0, 0, 320, 25, GFX::Themes[GFX::SelectedTheme].BarColor); - Gui::Draw_Rect(0, 25, 320, 1, GFX::Themes[GFX::SelectedTheme].BarOutline); + Gui::Draw_Rect(0, 0, 320, 25, UIThemes->BarColor()); + Gui::Draw_Rect(0, 25, 320, 1, UIThemes->BarOutline()); C3D_FrameEnd(0); hidScanInput(); diff --git a/source/menu/screenshotMenu.cpp b/source/menu/screenshotMenu.cpp index 242561d..38e1f6a 100644 --- a/source/menu/screenshotMenu.cpp +++ b/source/menu/screenshotMenu.cpp @@ -45,12 +45,12 @@ extern bool checkWifiStatus(); */ void StoreUtils::DrawScreenshotMenu(const C2D_Image &img, const int sIndex, const bool sFetch, const int screenshotSize, const std::string &name, const int zoom, const bool canDisplay) { Gui::ScreenDraw(Top); - Gui::Draw_Rect(0, 0, 400, 240, GFX::Themes[GFX::SelectedTheme].BGColor); + Gui::Draw_Rect(0, 0, 400, 240, UIThemes->BGColor()); if (sFetch) { Animation::QueueEntryDone(); GFX::DrawBottom(); - Gui::DrawStringCentered(0, 2, 0.6f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("LOADING_SCREENSHOT"), 310); + Gui::DrawStringCentered(0, 2, 0.6f, UIThemes->TextColor(), Lang::get("LOADING_SCREENSHOT"), 310); return; } @@ -59,10 +59,10 @@ void StoreUtils::DrawScreenshotMenu(const C2D_Image &img, const int sIndex, cons GFX::DrawBottom(); if (screenshotSize > 0) { // if texture is nullptr AND screenshot size is larger than 0. - Gui::DrawStringCentered(0, 2, 0.6f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("SCREENSHOT_COULD_NOT_LOAD"), 310); + Gui::DrawStringCentered(0, 2, 0.6f, UIThemes->TextColor(), Lang::get("SCREENSHOT_COULD_NOT_LOAD"), 310); } else { - Gui::DrawStringCentered(0, 2, 0.6f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("NO_SCREENSHOTS_AVAILABLE"), 310); + Gui::DrawStringCentered(0, 2, 0.6f, UIThemes->TextColor(), Lang::get("NO_SCREENSHOTS_AVAILABLE"), 310); } return; @@ -104,20 +104,20 @@ void StoreUtils::DrawScreenshotMenu(const C2D_Image &img, const int sIndex, cons delete bottom.subtex; } else { - Gui::Draw_Rect(0, 215, 320, 25, GFX::Themes[GFX::SelectedTheme].BarColor); - Gui::Draw_Rect(0, 214, 320, 1, GFX::Themes[GFX::SelectedTheme].BarOutline); - Gui::DrawStringCentered(0, 220, 0.5f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("SCREENSHOT_INSTRUCTIONS"), 310, 0, font); + Gui::Draw_Rect(0, 215, 320, 25, UIThemes->BarColor()); + Gui::Draw_Rect(0, 214, 320, 1, UIThemes->BarOutline()); + Gui::DrawStringCentered(0, 220, 0.5f, UIThemes->TextColor(), Lang::get("SCREENSHOT_INSTRUCTIONS"), 310, 0, font); char screenshots[0x100]; snprintf(screenshots, sizeof(screenshots), Lang::get("SCREENSHOT").c_str(), sIndex + 1, screenshotSize); - Gui::DrawStringCentered(0, 2, 0.6f, GFX::Themes[GFX::SelectedTheme].TextColor, screenshots, 310, 0, font); - Gui::DrawStringCentered(0, 40, 0.6f, GFX::Themes[GFX::SelectedTheme].TextColor, name, 310, 0, font); + Gui::DrawStringCentered(0, 2, 0.6f, UIThemes->TextColor(), screenshots, 310, 0, font); + Gui::DrawStringCentered(0, 40, 0.6f, UIThemes->TextColor(), name, 310, 0, font); } } else { Animation::QueueEntryDone(); GFX::DrawBottom(); - Gui::DrawStringCentered(0, 2, 0.6f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("NO_SCREENSHOTS_AVAILABLE"), 310); + Gui::DrawStringCentered(0, 2, 0.6f, UIThemes->TextColor(), Lang::get("NO_SCREENSHOTS_AVAILABLE"), 310); } } } diff --git a/source/menu/searchMenu.cpp b/source/menu/searchMenu.cpp index da0cbd2..6753bb6 100644 --- a/source/menu/searchMenu.cpp +++ b/source/menu/searchMenu.cpp @@ -65,65 +65,65 @@ static const std::vector SearchMenu = { isAND: isAND for the AND / OR mode. */ void StoreUtils::DrawSearchMenu(const std::vector &searchIncludes, const std::string &searchResult, int marks, bool updateFilter, bool isAND) { - Gui::Draw_Rect(40, 0, 280, 25, GFX::Themes[GFX::SelectedTheme].EntryBar); - Gui::Draw_Rect(40, 25, 280, 1, GFX::Themes[GFX::SelectedTheme].EntryOutline); - Gui::DrawStringCentered(21, 2, 0.6, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("SEARCH_FILTERS"), 269, 0, font); + Gui::Draw_Rect(40, 0, 280, 25, UIThemes->EntryBar()); + Gui::Draw_Rect(40, 25, 280, 1, UIThemes->EntryOutline()); + Gui::DrawStringCentered(21, 2, 0.6, UIThemes->TextColor(), Lang::get("SEARCH_FILTERS"), 269, 0, font); - Gui::Draw_Rect(50, 40, 264, SearchMenu[0].h + 2, GFX::Themes[GFX::SelectedTheme].SearchbarOutline); - Gui::Draw_Rect(SearchMenu[0].x, SearchMenu[0].y, SearchMenu[0].w, SearchMenu[0].h, GFX::Themes[GFX::SelectedTheme].SearchBar); + Gui::Draw_Rect(50, 40, 264, SearchMenu[0].h + 2, UIThemes->SearchBarOutline()); + Gui::Draw_Rect(SearchMenu[0].x, SearchMenu[0].y, SearchMenu[0].w, SearchMenu[0].h, UIThemes->SearchBar()); - Gui::DrawStringCentered(24, 46, 0.6, GFX::Themes[GFX::SelectedTheme].TextColor, searchResult, 265, 0, font); + Gui::DrawStringCentered(24, 46, 0.6, UIThemes->TextColor(), searchResult, 265, 0, font); /* Checkboxes. */ for (int i = 0; i < 4; i++) { GFX::DrawCheckbox(SearchMenu[i + 1].x, SearchMenu[i + 1].y, searchIncludes[i]); } - Gui::DrawString(84, 81, 0.5, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("INCLUDE_IN_RESULTS"), 265, 0, font); + Gui::DrawString(84, 81, 0.5, UIThemes->TextColor(), Lang::get("INCLUDE_IN_RESULTS"), 265, 0, font); - Gui::DrawString(SearchMenu[1].x + 18, SearchMenu[1].y + 1, 0.4, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("TITLE"), 90, 0, font); - Gui::DrawString(SearchMenu[2].x + 18, SearchMenu[2].y + 1, 0.4, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("AUTHOR"), 90, 0, font); + Gui::DrawString(SearchMenu[1].x + 18, SearchMenu[1].y + 1, 0.4, UIThemes->TextColor(), Lang::get("TITLE"), 90, 0, font); + Gui::DrawString(SearchMenu[2].x + 18, SearchMenu[2].y + 1, 0.4, UIThemes->TextColor(), Lang::get("AUTHOR"), 90, 0, font); - Gui::DrawString(SearchMenu[3].x + 18, SearchMenu[3].y + 1, 0.4, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("CATEGORY"), 90, 0, font); - Gui::DrawString(SearchMenu[4].x + 18, SearchMenu[4].y + 1, 0.4, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("CONSOLE"), 90, 0, font); + Gui::DrawString(SearchMenu[3].x + 18, SearchMenu[3].y + 1, 0.4, UIThemes->TextColor(), Lang::get("CATEGORY"), 90, 0, font); + Gui::DrawString(SearchMenu[4].x + 18, SearchMenu[4].y + 1, 0.4, UIThemes->TextColor(), Lang::get("CONSOLE"), 90, 0, font); /* Filters. */ - Gui::DrawString(84, SearchMenu[5].y - 20, 0.5f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("FILTER_TO"), 265, 0, font); + Gui::DrawString(84, SearchMenu[5].y - 20, 0.5f, UIThemes->TextColor(), Lang::get("FILTER_TO"), 265, 0, font); Gui::Draw_Rect(SearchMenu[5].x, SearchMenu[5].y, SearchMenu[5].w, SearchMenu[5].h, (marks & favoriteMarks::STAR ? - GFX::Themes[GFX::SelectedTheme].SideBarUnselected : GFX::Themes[GFX::SelectedTheme].BoxInside)); + UIThemes->SideBarUnselected() : UIThemes->BoxInside())); Gui::Draw_Rect(SearchMenu[6].x, SearchMenu[6].y, SearchMenu[6].w, SearchMenu[6].h, (marks & favoriteMarks::HEART ? - GFX::Themes[GFX::SelectedTheme].SideBarUnselected : GFX::Themes[GFX::SelectedTheme].BoxInside)); + UIThemes->SideBarUnselected() : UIThemes->BoxInside())); Gui::Draw_Rect(SearchMenu[7].x, SearchMenu[7].y, SearchMenu[7].w, SearchMenu[7].h, (marks & favoriteMarks::DIAMOND ? - GFX::Themes[GFX::SelectedTheme].SideBarUnselected : GFX::Themes[GFX::SelectedTheme].BoxInside)); + UIThemes->SideBarUnselected() : UIThemes->BoxInside())); Gui::Draw_Rect(SearchMenu[8].x, SearchMenu[8].y, SearchMenu[8].w, SearchMenu[8].h, (marks & favoriteMarks::CLUBS ? - GFX::Themes[GFX::SelectedTheme].SideBarUnselected : GFX::Themes[GFX::SelectedTheme].BoxInside)); + UIThemes->SideBarUnselected() : UIThemes->BoxInside())); Gui::Draw_Rect(SearchMenu[9].x, SearchMenu[9].y, SearchMenu[9].w, SearchMenu[9].h, (marks & favoriteMarks::SPADE ? - GFX::Themes[GFX::SelectedTheme].SideBarUnselected : GFX::Themes[GFX::SelectedTheme].BoxInside)); + UIThemes->SideBarUnselected() : UIThemes->BoxInside())); Gui::Draw_Rect(SearchMenu[10].x, SearchMenu[10].y, SearchMenu[10].w, SearchMenu[10].h, (updateFilter ? - GFX::Themes[GFX::SelectedTheme].SideBarUnselected : GFX::Themes[GFX::SelectedTheme].BoxInside)); + UIThemes->SideBarUnselected() : UIThemes->BoxInside())); - Gui::DrawString(SearchMenu[5].x + 9, SearchMenu[5].y + 7, 0.5f, GFX::Themes[GFX::SelectedTheme].TextColor, "★", 0, 0, font); - Gui::DrawString(SearchMenu[6].x + 9, SearchMenu[6].y + 7, 0.5f, GFX::Themes[GFX::SelectedTheme].TextColor, "♥", 0, 0, font); - Gui::DrawString(SearchMenu[7].x + 9, SearchMenu[7].y + 7, 0.5f, GFX::Themes[GFX::SelectedTheme].TextColor, "♦", 0, 0, font); - Gui::DrawString(SearchMenu[8].x + 9, SearchMenu[8].y + 7, 0.5f, GFX::Themes[GFX::SelectedTheme].TextColor, "♣", 0, 0, font); - Gui::DrawString(SearchMenu[9].x + 9, SearchMenu[9].y + 7, 0.5f, GFX::Themes[GFX::SelectedTheme].TextColor, "♠", 0, 0, font); + Gui::DrawString(SearchMenu[5].x + 9, SearchMenu[5].y + 7, 0.5f, UIThemes->TextColor(), "★", 0, 0, font); + Gui::DrawString(SearchMenu[6].x + 9, SearchMenu[6].y + 7, 0.5f, UIThemes->TextColor(), "♥", 0, 0, font); + Gui::DrawString(SearchMenu[7].x + 9, SearchMenu[7].y + 7, 0.5f, UIThemes->TextColor(), "♦", 0, 0, font); + Gui::DrawString(SearchMenu[8].x + 9, SearchMenu[8].y + 7, 0.5f, UIThemes->TextColor(), "♣", 0, 0, font); + Gui::DrawString(SearchMenu[9].x + 9, SearchMenu[9].y + 7, 0.5f, UIThemes->TextColor(), "♠", 0, 0, font); GFX::DrawSprite(sprites_update_filter_idx, SearchMenu[10].x + 8, SearchMenu[10].y + 8); - Gui::Draw_Rect(SearchMenu[11].x, SearchMenu[11].y, SearchMenu[11].w, SearchMenu[11].h, GFX::Themes[GFX::SelectedTheme].MarkUnselected); - Gui::DrawStringCentered(23, SearchMenu[11].y + 6, 0.45f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("SELECTION_QUEUE"), 280, 0, font); + Gui::Draw_Rect(SearchMenu[11].x, SearchMenu[11].y, SearchMenu[11].w, SearchMenu[11].h, UIThemes->MarkUnselected()); + Gui::DrawStringCentered(23, SearchMenu[11].y + 6, 0.45f, UIThemes->TextColor(), Lang::get("SELECTION_QUEUE"), 280, 0, font); /* AND / OR. */ - Gui::Draw_Rect(SearchMenu[12].x, SearchMenu[12].y, SearchMenu[12].w, SearchMenu[12].h, (isAND ? GFX::Themes[GFX::SelectedTheme].MarkSelected : GFX::Themes[GFX::SelectedTheme].MarkUnselected)); - Gui::DrawString(SearchMenu[12].x + 4, SearchMenu[12].y, 0.4f, GFX::Themes[GFX::SelectedTheme].TextColor, "AND", 0, 0, font); + Gui::Draw_Rect(SearchMenu[12].x, SearchMenu[12].y, SearchMenu[12].w, SearchMenu[12].h, (isAND ? UIThemes->MarkSelected() : UIThemes->MarkUnselected())); + Gui::DrawString(SearchMenu[12].x + 4, SearchMenu[12].y, 0.4f, UIThemes->TextColor(), "AND", 0, 0, font); - Gui::Draw_Rect(SearchMenu[13].x, SearchMenu[13].y, SearchMenu[13].w, SearchMenu[13].h, (!isAND ? GFX::Themes[GFX::SelectedTheme].MarkSelected : GFX::Themes[GFX::SelectedTheme].MarkUnselected)); - Gui::DrawString(SearchMenu[13].x + 8, SearchMenu[13].y, 0.4f, GFX::Themes[GFX::SelectedTheme].TextColor, "OR", 0, 0, font); + Gui::Draw_Rect(SearchMenu[13].x, SearchMenu[13].y, SearchMenu[13].w, SearchMenu[13].h, (!isAND ? UIThemes->MarkSelected() : UIThemes->MarkUnselected())); + Gui::DrawString(SearchMenu[13].x + 8, SearchMenu[13].y, 0.4f, UIThemes->TextColor(), "OR", 0, 0, font); } /* diff --git a/source/menu/settings.cpp b/source/menu/settings.cpp index 8bac2ea..16a8a1a 100644 --- a/source/menu/settings.cpp +++ b/source/menu/settings.cpp @@ -78,32 +78,31 @@ static const std::vector dirIcons = { }; static const Structs::ButtonPos back = { 45, 0, 24, 24 }; // Back arrow for directory. -static const Structs::ButtonPos Themes = { 40, 196, 280, 24 }; // Themes. +static const Structs::ButtonPos Theme = { 40, 196, 280, 24 }; // Themes. static const std::vector mainStrings = { "LANGUAGE", "SELECT_UNISTORE", "AUTO_UPDATE_SETTINGS_BTN", "GUI_SETTINGS_BTN", "DIRECTORY_SETTINGS_BTN", "CREDITS", "EXIT_APP" }; static const std::vector dirStrings = { "CHANGE_3DSX_PATH", "3DSX_IN_FOLDER", "CHANGE_NDS_PATH", "CHANGE_ARCHIVE_PATH", "CHANGE_SHORTCUT_PATH", "CHANGE_FIRM_PATH" }; +extern std::vector Themes; /* Note: Украïнська is spelled using a latin i with dieresis to work in the system font */ static const std::vector languages = { "Bruh", "Deutsch", "English", "Español", "Français", "Italiano", /* "Lietuvių", */ "Magyar", /* "Nederlands", */ "Polski", "Português", "Português (Brasil)", "Русский", "Украïнська", /* "עברית", */ "中文 (简体)", "中文 (繁體)", "日本語", /* "한국어" */ }; static const std::string langsTemp[] = { "br", "de", "en", "es", "fr", "it", /* "lt", */ "hu", /* "nl", */ "pl", "pt", "pt-BR", "ru", "uk", /* "he", */ "zh-CN", "zh-TW", "jp", /* "ko" */ }; static const std::pair langSprites[] = { {-1, 0}, {-1, 0}, {-1, 0}, {-1, 0}, {-1, 0}, {-1, 0}, /* {-1, 0}, */ {-1, 0}, /* {-1, 0}, */ {-1, 0}, {-1, 0}, {-1, 0}, {-1, 0}, {-1, 0}, /* {-1, 0}, */ {sprites_zh_CN_idx, 54}, {sprites_zh_TW_idx, 55}, {sprites_jp_idx, 31}, /* {sprites_ko_idx, 30} */ }; -static const std::vector ThemeNames = { "THEME_DEFAULT", "Stack" }; - /* Main Settings. int selection: The Settings Selection. */ static void DrawSettingsMain(int selection) { - Gui::Draw_Rect(40, 0, 280, 25, GFX::Themes[GFX::SelectedTheme].EntryBar); - Gui::Draw_Rect(40, 25, 280, 1, GFX::Themes[GFX::SelectedTheme].EntryOutline); - Gui::DrawStringCentered(20, 2, 0.6, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("SETTINGS"), 280, 0, font); + Gui::Draw_Rect(40, 0, 280, 25, UIThemes->EntryBar()); + Gui::Draw_Rect(40, 25, 280, 1, UIThemes->EntryOutline()); + Gui::DrawStringCentered(20, 2, 0.6, UIThemes->TextColor(), Lang::get("SETTINGS"), 280, 0, font); for (int i = 0; i < 7; i++) { - if (i == selection) Gui::Draw_Rect(mainButtons[i].x, mainButtons[i].y, mainButtons[i].w, mainButtons[i].h, GFX::Themes[GFX::SelectedTheme].MarkSelected); - Gui::DrawStringCentered(20, mainButtons[i].y + 4, 0.45f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get(mainStrings[i]), 255, 0, font); + if (i == selection) Gui::Draw_Rect(mainButtons[i].x, mainButtons[i].y, mainButtons[i].w, mainButtons[i].h, UIThemes->MarkSelected()); + Gui::DrawStringCentered(20, mainButtons[i].y + 4, 0.45f, UIThemes->TextColor(), Lang::get(mainStrings[i]), 255, 0, font); } } @@ -114,18 +113,18 @@ static void DrawSettingsMain(int selection) { int sPos: The Screen Position. */ static void DrawLanguageSettings(int selection, int sPos) { - Gui::Draw_Rect(40, 0, 280, 25, GFX::Themes[GFX::SelectedTheme].EntryBar); - Gui::Draw_Rect(40, 25, 280, 1, GFX::Themes[GFX::SelectedTheme].EntryOutline); + Gui::Draw_Rect(40, 0, 280, 25, UIThemes->EntryBar()); + Gui::Draw_Rect(40, 25, 280, 1, UIThemes->EntryOutline()); GFX::DrawSprite(sprites_arrow_idx, back.x, back.y); GFX::DrawSprite(sprites_add_font_idx, langButtons[6].x, langButtons[6].y); - Gui::DrawStringCentered(20, 2, 0.6, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("SELECT_LANG"), 248, 0, font); + Gui::DrawStringCentered(20, 2, 0.6, UIThemes->TextColor(), Lang::get("SELECT_LANG"), 248, 0, font); for(int i = 0; i < 6 && i < (int)languages.size(); i++) { - if (sPos + i == selection) Gui::Draw_Rect(langButtons[i].x, langButtons[i].y, langButtons[i].w, langButtons[i].h, GFX::Themes[GFX::SelectedTheme].MarkSelected); + if (sPos + i == selection) Gui::Draw_Rect(langButtons[i].x, langButtons[i].y, langButtons[i].w, langButtons[i].h, UIThemes->MarkSelected()); if(langSprites[sPos + i].first != -1) GFX::DrawSprite(langSprites[sPos + i].first, 160 + 20 - (langSprites[sPos + i].second / 2), langButtons[i].y + 6); else - Gui::DrawStringCentered(20, langButtons[i].y + 4, 0.45f, GFX::Themes[GFX::SelectedTheme].TextColor, languages[sPos + i], 280, 0, font); + Gui::DrawStringCentered(20, langButtons[i].y + 4, 0.45f, UIThemes->TextColor(), languages[sPos + i], 280, 0, font); } } @@ -135,17 +134,17 @@ static void DrawLanguageSettings(int selection, int sPos) { int selection: The Settings Selection. */ static void DrawSettingsDir(int selection) { - Gui::Draw_Rect(40, 0, 280, 25, GFX::Themes[GFX::SelectedTheme].EntryBar); - Gui::Draw_Rect(40, 25, 280, 1, GFX::Themes[GFX::SelectedTheme].EntryOutline); + Gui::Draw_Rect(40, 0, 280, 25, UIThemes->EntryBar()); + Gui::Draw_Rect(40, 25, 280, 1, UIThemes->EntryOutline()); GFX::DrawSprite(sprites_arrow_idx, back.x, back.y); - Gui::DrawStringCentered(20, 2, 0.6, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("DIRECTORY_SETTINGS"), 248, 0, font); + Gui::DrawStringCentered(20, 2, 0.6, UIThemes->TextColor(), Lang::get("DIRECTORY_SETTINGS"), 248, 0, font); for (int i = 0; i < (int)dirButtons.size(); i++) { - Gui::Draw_Rect(dirButtons[i].x, dirButtons[i].y, dirButtons[i].w, dirButtons[i].h, (selection == i ? GFX::Themes[GFX::SelectedTheme].MarkSelected : GFX::Themes[GFX::SelectedTheme].MarkUnselected)); - Gui::DrawString(dirButtons[i].x + 4, dirButtons[i].y + 4, 0.5f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get(dirStrings[i]), 210, 0, font); + Gui::Draw_Rect(dirButtons[i].x, dirButtons[i].y, dirButtons[i].w, dirButtons[i].h, (selection == i ? UIThemes->MarkSelected() : UIThemes->MarkUnselected())); + Gui::DrawString(dirButtons[i].x + 4, dirButtons[i].y + 4, 0.5f, UIThemes->TextColor(), Lang::get(dirStrings[i]), 210, 0, font); if(i == 1) { // Put 3DSX in folder has a toggle and description GFX::DrawToggle(dirIcons[i].x, dirIcons[i].y, config->_3dsxInFolder()); - Gui::DrawString(dirButtons[i].x + 4, dirButtons[i].y + 28, 0.4f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("3DSX_IN_FOLDER_DESC"), 265, 0, font, C2D_WordWrap); + Gui::DrawString(dirButtons[i].x + 4, dirButtons[i].y + 28, 0.4f, UIThemes->TextColor(), Lang::get("3DSX_IN_FOLDER_DESC"), 265, 0, font, C2D_WordWrap); } else { GFX::DrawSprite(sprites_arrow_idx, dirIcons[i].x, dirIcons[i].y, -1.0f); } @@ -156,22 +155,22 @@ static void DrawSettingsDir(int selection) { Draw Auto-Update Settings page. */ static void DrawAutoUpdate(int selection) { - Gui::Draw_Rect(40, 0, 280, 25, GFX::Themes[GFX::SelectedTheme].EntryBar); - Gui::Draw_Rect(40, 25, 280, 1, GFX::Themes[GFX::SelectedTheme].EntryOutline); + Gui::Draw_Rect(40, 0, 280, 25, UIThemes->EntryBar()); + Gui::Draw_Rect(40, 25, 280, 1, UIThemes->EntryOutline()); GFX::DrawSprite(sprites_arrow_idx, back.x, back.y); - Gui::DrawStringCentered(20, 2, 0.6, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("AUTO_UPDATE_SETTINGS"), 240, 0, font); + Gui::DrawStringCentered(20, 2, 0.6, UIThemes->TextColor(), Lang::get("AUTO_UPDATE_SETTINGS"), 240, 0, font); /* Toggle Boxes. */ - Gui::Draw_Rect(40, 44, 280, 24, (selection == 0 ? GFX::Themes[GFX::SelectedTheme].MarkSelected : GFX::Themes[GFX::SelectedTheme].MarkUnselected)); - Gui::DrawString(47, 48, 0.5f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("AUTO_UPDATE_UNISTORE"), 210, 0, font); + Gui::Draw_Rect(40, 44, 280, 24, (selection == 0 ? UIThemes->MarkSelected() : UIThemes->MarkUnselected())); + Gui::DrawString(47, 48, 0.5f, UIThemes->TextColor(), Lang::get("AUTO_UPDATE_UNISTORE"), 210, 0, font); GFX::DrawToggle(toggleAbles[0].x, toggleAbles[0].y, config->autoupdate()); - Gui::DrawString(47, 75, 0.4f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("AUTO_UPDATE_UNISTORE_DESC"), 265, 0, font, C2D_WordWrap); + Gui::DrawString(47, 75, 0.4f, UIThemes->TextColor(), Lang::get("AUTO_UPDATE_UNISTORE_DESC"), 265, 0, font, C2D_WordWrap); - Gui::Draw_Rect(40, 120, 280, 24, (selection == 1 ? GFX::Themes[GFX::SelectedTheme].MarkSelected : GFX::Themes[GFX::SelectedTheme].MarkUnselected)); - Gui::DrawString(47, 124, 0.5f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("AUTO_UPDATE_UU"), 210, 0, font); + Gui::Draw_Rect(40, 120, 280, 24, (selection == 1 ? UIThemes->MarkSelected() : UIThemes->MarkUnselected())); + Gui::DrawString(47, 124, 0.5f, UIThemes->TextColor(), Lang::get("AUTO_UPDATE_UU"), 210, 0, font); GFX::DrawToggle(toggleAbles[1].x, toggleAbles[1].y, config->updatecheck()); - Gui::DrawString(47, 151, 0.4f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("AUTO_UPDATE_UU_DESC"), 265, 0, font, C2D_WordWrap); + Gui::DrawString(47, 151, 0.4f, UIThemes->TextColor(), Lang::get("AUTO_UPDATE_UU_DESC"), 265, 0, font, C2D_WordWrap); } /* @@ -180,24 +179,26 @@ static void DrawAutoUpdate(int selection) { int selection: The Settings Selection. */ static void DrawGUISettings(int selection) { - Gui::Draw_Rect(40, 0, 280, 25, GFX::Themes[GFX::SelectedTheme].EntryBar); - Gui::Draw_Rect(40, 25, 280, 1, GFX::Themes[GFX::SelectedTheme].EntryOutline); + Gui::Draw_Rect(40, 0, 280, 25, UIThemes->EntryBar()); + Gui::Draw_Rect(40, 25, 280, 1, UIThemes->EntryOutline()); GFX::DrawSprite(sprites_arrow_idx, back.x, back.y); - Gui::DrawStringCentered(20, 2, 0.6, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("GUI_SETTINGS"), 248, 0, font); + Gui::DrawStringCentered(20, 2, 0.6, UIThemes->TextColor(), Lang::get("GUI_SETTINGS"), 248, 0, font); - Gui::Draw_Rect(40, 44, 280, 24, (selection == 0 ? GFX::Themes[GFX::SelectedTheme].MarkSelected : GFX::Themes[GFX::SelectedTheme].MarkUnselected)); - Gui::DrawString(47, 48, 0.5f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("UNISTORE_BG"), 210, 0, font); + Gui::Draw_Rect(40, 44, 280, 24, (selection == 0 ? UIThemes->MarkSelected() : UIThemes->MarkUnselected())); + Gui::DrawString(47, 48, 0.5f, UIThemes->TextColor(), Lang::get("UNISTORE_BG"), 210, 0, font); GFX::DrawToggle(toggleAbles[0].x, toggleAbles[0].y, config->usebg()); - Gui::DrawString(47, 75, 0.4f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("UNISTORE_BG_DESC"), 265, 0, font, C2D_WordWrap); + Gui::DrawString(47, 75, 0.4f, UIThemes->TextColor(), Lang::get("UNISTORE_BG_DESC"), 265, 0, font, C2D_WordWrap); - Gui::Draw_Rect(40, 120, 280, 24, (selection == 1 ? GFX::Themes[GFX::SelectedTheme].MarkSelected : GFX::Themes[GFX::SelectedTheme].MarkUnselected)); - Gui::DrawString(47, 124, 0.5f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("CUSTOM_FONT"), 210, 0, font); + Gui::Draw_Rect(40, 120, 280, 24, (selection == 1 ? UIThemes->MarkSelected() : UIThemes->MarkUnselected())); + Gui::DrawString(47, 124, 0.5f, UIThemes->TextColor(), Lang::get("CUSTOM_FONT"), 210, 0, font); GFX::DrawToggle(toggleAbles[1].x, toggleAbles[1].y, config->customfont()); - Gui::DrawString(47, 151, 0.4f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("CUSTOM_FONT_DESC"), 265, 0, font, C2D_WordWrap); + Gui::DrawString(47, 151, 0.4f, UIThemes->TextColor(), Lang::get("CUSTOM_FONT_DESC"), 265, 0, font, C2D_WordWrap); - Gui::Draw_Rect(40, 196, 280, 24, (selection == 2 ? GFX::Themes[GFX::SelectedTheme].MarkSelected : GFX::Themes[GFX::SelectedTheme].MarkUnselected)); - Gui::DrawString(47, 200, 0.5f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("ACTIVE_THEME") + ": " + (GFX::SelectedTheme == 0 ? Lang::get(ThemeNames[GFX::SelectedTheme]) : ThemeNames[GFX::SelectedTheme]), 210, 0, font); + if (!Themes.empty()) { + Gui::Draw_Rect(40, 196, 280, 24, (selection == 2 ? UIThemes->MarkSelected() : UIThemes->MarkUnselected())); + Gui::DrawString(47, 200, 0.5f, UIThemes->TextColor(), Lang::get("ACTIVE_THEME") + ": " + config->theme(), 270, 0, font); + } } @@ -489,7 +490,7 @@ static void GUISettingsLogic(int &page, int &selection) { } if (hRepeat & KEY_DOWN) { - if (selection < 2) selection++; + if (selection < (Themes.empty() ? 1 : 2)) selection++; } if (hRepeat & KEY_UP) { @@ -509,11 +510,8 @@ static void GUISettingsLogic(int &page, int &selection) { (config->customfont() ? Init::LoadFont() : Init::UnloadFont()); - } else if (touching(touch, Themes)) { - if (GFX::SelectedTheme < (_THEME_AMOUNT - 1)) GFX::SelectedTheme++; - else GFX::SelectedTheme = 0; - - config->theme(GFX::SelectedTheme); + } else if (touching(touch, Theme)) { + if (!Themes.empty()) Overlays::SelectTheme(); } } @@ -530,10 +528,7 @@ static void GUISettingsLogic(int &page, int &selection) { break; case 2: - if (GFX::SelectedTheme < (_THEME_AMOUNT - 1)) GFX::SelectedTheme++; - else GFX::SelectedTheme = 0; - - config->theme(GFX::SelectedTheme); + if (!Themes.empty()) Overlays::SelectTheme(); break; } } diff --git a/source/menu/sideMenu.cpp b/source/menu/sideMenu.cpp index a38980e..759ef2e 100644 --- a/source/menu/sideMenu.cpp +++ b/source/menu/sideMenu.cpp @@ -47,10 +47,10 @@ static const std::vector sidePos = { void StoreUtils::DrawSideMenu(int currentMenu) { for (int i = 0; i < 6; i++) { if (i == currentMenu) { - Gui::Draw_Rect(sidePos[i].x, sidePos[i].y, sidePos[i].w, sidePos[i].h, GFX::Themes[GFX::SelectedTheme].SideBarSelected); + Gui::Draw_Rect(sidePos[i].x, sidePos[i].y, sidePos[i].w, sidePos[i].h, UIThemes->SideBarSelected()); } else { - Gui::Draw_Rect(sidePos[i].x, sidePos[i].y, sidePos[i].w, sidePos[i].h, GFX::Themes[GFX::SelectedTheme].SideBarUnselected); + Gui::Draw_Rect(sidePos[i].x, sidePos[i].y, sidePos[i].w, sidePos[i].h, UIThemes->SideBarUnselected()); } } @@ -61,7 +61,7 @@ void StoreUtils::DrawSideMenu(int currentMenu) { GFX::DrawIcon(sprites_sort_idx, sidePos[4].x, sidePos[4].y); GFX::DrawIcon(sprites_settings_idx, sidePos[5].x, sidePos[5].y); - Gui::Draw_Rect(40, 0, 1, 240, GFX::Themes[GFX::SelectedTheme].BarOutline); + Gui::Draw_Rect(40, 0, 1, 240, UIThemes->BarOutline()); } /* diff --git a/source/menu/sortMenu.cpp b/source/menu/sortMenu.cpp index 5a8db85..75a7580 100644 --- a/source/menu/sortMenu.cpp +++ b/source/menu/sortMenu.cpp @@ -74,33 +74,33 @@ static const uint8_t GetType(SortType st) { SortType st: The SortType variable. */ void StoreUtils::DrawSorting(bool asc, SortType st) { - Gui::Draw_Rect(40, 0, 280, 25, GFX::Themes[GFX::SelectedTheme].EntryBar); - Gui::Draw_Rect(40, 25, 280, 1, GFX::Themes[GFX::SelectedTheme].EntryOutline); - Gui::DrawStringCentered(17, 2, 0.6, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("SORTING"), 273, 0, font); + Gui::Draw_Rect(40, 0, 280, 25, UIThemes->EntryBar()); + Gui::Draw_Rect(40, 25, 280, 1, UIThemes->EntryOutline()); + Gui::DrawStringCentered(17, 2, 0.6, UIThemes->TextColor(), Lang::get("SORTING"), 273, 0, font); /* Sort By. */ - Gui::DrawString(buttons[0].x + 1, buttons[0].y - 20, 0.6f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("SORT_BY"), 90, 0, font); + Gui::DrawString(buttons[0].x + 1, buttons[0].y - 20, 0.6f, UIThemes->TextColor(), Lang::get("SORT_BY"), 90, 0, font); for (int i = 0; i < 3; i++) { DrawCheck(i, i == GetType(st)); } - Gui::DrawString(buttons[0].x + 21, buttons[0].y + 2, 0.4f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("TITLE"), 80, 0, font); - Gui::DrawString(buttons[1].x + 21, buttons[1].y + 2, 0.4f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("AUTHOR"), 80, 0, font); - Gui::DrawString(buttons[2].x + 21, buttons[2].y + 2, 0.4f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("LAST_UPDATED"), 80, 0, font); + Gui::DrawString(buttons[0].x + 21, buttons[0].y + 2, 0.4f, UIThemes->TextColor(), Lang::get("TITLE"), 80, 0, font); + Gui::DrawString(buttons[1].x + 21, buttons[1].y + 2, 0.4f, UIThemes->TextColor(), Lang::get("AUTHOR"), 80, 0, font); + Gui::DrawString(buttons[2].x + 21, buttons[2].y + 2, 0.4f, UIThemes->TextColor(), Lang::get("LAST_UPDATED"), 80, 0, font); /* Direction. */ - Gui::DrawString(buttons[3].x + 1, buttons[3].y - 20, 0.6f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("DIRECTION"), 80, 0, font); + Gui::DrawString(buttons[3].x + 1, buttons[3].y - 20, 0.6f, UIThemes->TextColor(), Lang::get("DIRECTION"), 80, 0, font); DrawCheck(3, asc); DrawCheck(4, !asc); - Gui::DrawString(buttons[3].x + 21, buttons[3].y + 2, 0.4f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("ASCENDING"), 80, 0, font); - Gui::DrawString(buttons[4].x + 21, buttons[4].y + 2, 0.4f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("DESCENDING"), 80, 0, font); + Gui::DrawString(buttons[3].x + 21, buttons[3].y + 2, 0.4f, UIThemes->TextColor(), Lang::get("ASCENDING"), 80, 0, font); + Gui::DrawString(buttons[4].x + 21, buttons[4].y + 2, 0.4f, UIThemes->TextColor(), Lang::get("DESCENDING"), 80, 0, font); /* Top Style. */ - Gui::DrawString(buttons[5].x + 1, buttons[5].y - 20, 0.6f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("TOP_STYLE"), 90, 0, font); + Gui::DrawString(buttons[5].x + 1, buttons[5].y - 20, 0.6f, UIThemes->TextColor(), Lang::get("TOP_STYLE"), 90, 0, font); DrawCheck(5, config->list()); DrawCheck(6, !config->list()); - Gui::DrawString(buttons[5].x + 21, buttons[5].y + 2, 0.4f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("LIST"), 90, 0, font); - Gui::DrawString(buttons[6].x + 21, buttons[6].y + 2, 0.4f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("GRID"), 90, 0, font); + Gui::DrawString(buttons[5].x + 21, buttons[5].y + 2, 0.4f, UIThemes->TextColor(), Lang::get("LIST"), 90, 0, font); + Gui::DrawString(buttons[6].x + 21, buttons[6].y + 2, 0.4f, UIThemes->TextColor(), Lang::get("GRID"), 90, 0, font); } /* diff --git a/source/overlays/credits.cpp b/source/overlays/credits.cpp index d755b25..38cdadd 100644 --- a/source/overlays/credits.cpp +++ b/source/overlays/credits.cpp @@ -41,21 +41,21 @@ void Overlays::ShowCredits() { GFX::DrawTop(); GFX::DrawSprite(sprites_universal_updater_idx, 220, 26); - Gui::DrawStringCentered(0, 1, 0.7f, GFX::Themes[GFX::SelectedTheme].TextColor, "Universal-Updater - " + Lang::get("CREDITS"), 395, 0, font); + Gui::DrawStringCentered(0, 1, 0.7f, UIThemes->TextColor(), "Universal-Updater - " + Lang::get("CREDITS"), 395, 0, font); - Gui::DrawString(10, 30, 0.5f, GFX::Themes[GFX::SelectedTheme].TextColor, "- Universal-Team", 0, 0, font); - Gui::DrawString(10, 50, 0.5f, GFX::Themes[GFX::SelectedTheme].TextColor, "- devkitPro", 0, 0, font); - Gui::DrawString(10, 70, 0.5f, GFX::Themes[GFX::SelectedTheme].TextColor, "- dlbeer", 0, 0, font); - Gui::DrawString(10, 90, 0.5f, GFX::Themes[GFX::SelectedTheme].TextColor, "- FlagBrew", 0, 0, font); - Gui::DrawString(10, 110, 0.5f, GFX::Themes[GFX::SelectedTheme].TextColor, "- https://icons8.com/", 0, 0, font); - Gui::DrawString(10, 130, 0.5f, GFX::Themes[GFX::SelectedTheme].TextColor, "- Ivandeve", 0, 0, font); - Gui::DrawString(10, 150, 0.5f, GFX::Themes[GFX::SelectedTheme].TextColor, "- PabloMK7", 0, 0, font); - Gui::DrawString(10, 170, 0.5f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("CONTRIBUTOR_TRANSLATORS"), 210, 0, font); - Gui::DrawString(10, 197, 0.5f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("GITHUB"), 390, 0, font); + Gui::DrawString(10, 30, 0.5f, UIThemes->TextColor(), "- Universal-Team", 0, 0, font); + Gui::DrawString(10, 50, 0.5f, UIThemes->TextColor(), "- devkitPro", 0, 0, font); + Gui::DrawString(10, 70, 0.5f, UIThemes->TextColor(), "- dlbeer", 0, 0, font); + Gui::DrawString(10, 90, 0.5f, UIThemes->TextColor(), "- FlagBrew", 0, 0, font); + Gui::DrawString(10, 110, 0.5f, UIThemes->TextColor(), "- https://icons8.com/", 0, 0, font); + Gui::DrawString(10, 130, 0.5f, UIThemes->TextColor(), "- Ivandeve", 0, 0, font); + Gui::DrawString(10, 150, 0.5f, UIThemes->TextColor(), "- PabloMK7", 0, 0, font); + Gui::DrawString(10, 170, 0.5f, UIThemes->TextColor(), Lang::get("CONTRIBUTOR_TRANSLATORS"), 210, 0, font); + Gui::DrawString(10, 197, 0.5f, UIThemes->TextColor(), Lang::get("GITHUB"), 390, 0, font); - Gui::Draw_Rect(0, 215, 400, 25, GFX::Themes[GFX::SelectedTheme].BarColor); - Gui::Draw_Rect(0, 214, 400, 1, GFX::Themes[GFX::SelectedTheme].BarOutline); - Gui::DrawStringCentered(0, 218, 0.6f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("CURRENT_VERSION") + std::string(VER_NUMBER), 390, 0, font); + Gui::Draw_Rect(0, 215, 400, 25, UIThemes->BarColor()); + Gui::Draw_Rect(0, 214, 400, 1, UIThemes->BarOutline()); + Gui::DrawStringCentered(0, 218, 0.6f, UIThemes->TextColor(), Lang::get("CURRENT_VERSION") + std::string(VER_NUMBER), 390, 0, font); Animation::QueueEntryDone(); GFX::DrawBottom(); diff --git a/source/overlays/dirSelect.cpp b/source/overlays/dirSelect.cpp index f62f260..de9849b 100644 --- a/source/overlays/dirSelect.cpp +++ b/source/overlays/dirSelect.cpp @@ -75,31 +75,31 @@ std::string Overlays::SelectDir(const std::string &oldDir, const std::string &ms if (StoreUtils::store && config->usebg() && StoreUtils::store->customBG()) { Gui::ScreenDraw(Top); - Gui::Draw_Rect(0, 0, 400, 25, GFX::Themes[GFX::SelectedTheme].BarColor); - Gui::Draw_Rect(0, 25, 400, 1, GFX::Themes[GFX::SelectedTheme].BarOutline); + Gui::Draw_Rect(0, 0, 400, 25, UIThemes->BarColor()); + Gui::Draw_Rect(0, 25, 400, 1, UIThemes->BarOutline()); C2D_DrawImageAt(StoreUtils::store->GetStoreImg(), 0, 26, 0.5f, nullptr); } else { GFX::DrawTop(); } - Gui::DrawStringCentered(0, 1, 0.7f, GFX::Themes[GFX::SelectedTheme].TextColor, msg, 380, 0, font); + Gui::DrawStringCentered(0, 1, 0.7f, UIThemes->TextColor(), msg, 380, 0, font); - Gui::Draw_Rect(0, 215, 400, 25, GFX::Themes[GFX::SelectedTheme].BarColor); - Gui::Draw_Rect(0, 214, 400, 1, GFX::Themes[GFX::SelectedTheme].BarOutline); - Gui::DrawStringCentered(0, 217, 0.6f, GFX::Themes[GFX::SelectedTheme].TextColor, currentPath, 390, 0, font); + Gui::Draw_Rect(0, 215, 400, 25, UIThemes->BarColor()); + Gui::Draw_Rect(0, 214, 400, 1, UIThemes->BarOutline()); + Gui::DrawStringCentered(0, 217, 0.6f, UIThemes->TextColor(), currentPath, 390, 0, font); Animation::QueueEntryDone(); GFX::DrawBottom(); - Gui::Draw_Rect(0, 215, 320, 25, GFX::Themes[GFX::SelectedTheme].BarColor); - Gui::Draw_Rect(0, 214, 320, 1, GFX::Themes[GFX::SelectedTheme].BarOutline); - Gui::DrawStringCentered(0, 220, 0.5f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("START_SELECT"), 310, 0, font); + Gui::Draw_Rect(0, 215, 320, 25, UIThemes->BarColor()); + Gui::Draw_Rect(0, 214, 320, 1, UIThemes->BarOutline()); + Gui::DrawStringCentered(0, 220, 0.5f, UIThemes->TextColor(), Lang::get("START_SELECT"), 310, 0, font); if (dirContents.size() > 0) { for(int i = 0; i < 7 && i < (int)dirContents.size(); i++) { - if (sPos + i == selection) Gui::Draw_Rect(mainButtons[i].x, mainButtons[i].y, mainButtons[i].w, mainButtons[i].h, GFX::Themes[GFX::SelectedTheme].MarkSelected); - Gui::DrawStringCentered(10 - 160 + (300 / 2), mainButtons[i].y + 4, 0.45f, GFX::Themes[GFX::SelectedTheme].TextColor, dirContents[sPos + i].name, 295, 0, font); + if (sPos + i == selection) Gui::Draw_Rect(mainButtons[i].x, mainButtons[i].y, mainButtons[i].w, mainButtons[i].h, UIThemes->MarkSelected()); + Gui::DrawStringCentered(10 - 160 + (300 / 2), mainButtons[i].y + 4, 0.45f, UIThemes->TextColor(), dirContents[sPos + i].name, 295, 0, font); } } diff --git a/source/overlays/storeSelect.cpp b/source/overlays/storeSelect.cpp index 995c6e5..5c4a7f6 100644 --- a/source/overlays/storeSelect.cpp +++ b/source/overlays/storeSelect.cpp @@ -241,8 +241,8 @@ void Overlays::SelectStore() { if (StoreUtils::store && config->usebg() && StoreUtils::store->customBG()) { Gui::ScreenDraw(Top); - Gui::Draw_Rect(0, 0, 400, 25, GFX::Themes[GFX::SelectedTheme].BarColor); - Gui::Draw_Rect(0, 25, 400, 1, GFX::Themes[GFX::SelectedTheme].BarOutline); + Gui::Draw_Rect(0, 0, 400, 25, UIThemes->BarColor()); + Gui::Draw_Rect(0, 25, 400, 1, UIThemes->BarOutline()); C2D_DrawImageAt(StoreUtils::store->GetStoreImg(), 0, 26, 0.5f, nullptr); } else { @@ -251,29 +251,29 @@ void Overlays::SelectStore() { if (info.size() > 0) { if (info[selection].StoreSize != -1) { - Gui::DrawStringCentered(0, 1, 0.7f, GFX::Themes[GFX::SelectedTheme].TextColor, info[selection].Title, 390, 0, font); - Gui::DrawStringCentered(0, 30, 0.6f, GFX::Themes[GFX::SelectedTheme].TextColor, info[selection].Author, 380, 0, font); - Gui::DrawStringCentered(0, 70, 0.5f, GFX::Themes[GFX::SelectedTheme].TextColor, info[selection].Description, 380, 130, font, C2D_WordWrap); + Gui::DrawStringCentered(0, 1, 0.7f, UIThemes->TextColor(), info[selection].Title, 390, 0, font); + Gui::DrawStringCentered(0, 30, 0.6f, UIThemes->TextColor(), info[selection].Author, 380, 0, font); + Gui::DrawStringCentered(0, 70, 0.5f, UIThemes->TextColor(), info[selection].Description, 380, 130, font, C2D_WordWrap); } else { - Gui::DrawStringCentered(0, 1, 0.7f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("INVALID_UNISTORE"), 390, 0, font); + Gui::DrawStringCentered(0, 1, 0.7f, UIThemes->TextColor(), Lang::get("INVALID_UNISTORE"), 390, 0, font); } - Gui::DrawString(10, 200, 0.4, GFX::Themes[GFX::SelectedTheme].TextColor, "- " + Lang::get("ENTRIES") + ": " + std::to_string(info[selection].StoreSize), 150, 0, font); - Gui::DrawString(10, 210, 0.4, GFX::Themes[GFX::SelectedTheme].TextColor, "- " + Lang::get("VERSION") + ": " + std::to_string(info[selection].Version), 150, 0, font); - Gui::DrawString(10, 220, 0.4, GFX::Themes[GFX::SelectedTheme].TextColor, "- " + Lang::get("REVISION") + ": " + std::to_string(info[selection].Revision), 150, 0, font); + Gui::DrawString(10, 200, 0.4, UIThemes->TextColor(), "- " + Lang::get("ENTRIES") + ": " + std::to_string(info[selection].StoreSize), 150, 0, font); + Gui::DrawString(10, 210, 0.4, UIThemes->TextColor(), "- " + Lang::get("VERSION") + ": " + std::to_string(info[selection].Version), 150, 0, font); + Gui::DrawString(10, 220, 0.4, UIThemes->TextColor(), "- " + Lang::get("REVISION") + ": " + std::to_string(info[selection].Revision), 150, 0, font); Animation::QueueEntryDone(); GFX::DrawBottom(); - Gui::Draw_Rect(0, 0, 320, 25, GFX::Themes[GFX::SelectedTheme].BarColor); - Gui::Draw_Rect(0, 25, 320, 1, GFX::Themes[GFX::SelectedTheme].BarOutline); + Gui::Draw_Rect(0, 0, 320, 25, UIThemes->BarColor()); + Gui::Draw_Rect(0, 25, 320, 1, UIThemes->BarOutline()); GFX::DrawSprite(sprites_arrow_idx, mainButtons[9].x, mainButtons[9].y); - Gui::DrawStringCentered(0, 2, 0.6, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("SELECT_UNISTORE_2"), 310, 0, font); + Gui::DrawStringCentered(0, 2, 0.6, UIThemes->TextColor(), Lang::get("SELECT_UNISTORE_2"), 310, 0, font); for(int i = 0; i < 6 && i < (int)info.size(); i++) { - if (sPos + i == selection) Gui::Draw_Rect(mainButtons[i].x, mainButtons[i].y, mainButtons[i].w, mainButtons[i].h, GFX::Themes[GFX::SelectedTheme].MarkSelected); - Gui::DrawStringCentered(10 - 160 + (300 / 2), mainButtons[i].y + 4, 0.45f, GFX::Themes[GFX::SelectedTheme].TextColor, info[sPos + i].FileName, 295, 0, font); + if (sPos + i == selection) Gui::Draw_Rect(mainButtons[i].x, mainButtons[i].y, mainButtons[i].w, mainButtons[i].h, UIThemes->MarkSelected()); + Gui::DrawStringCentered(10 - 160 + (300 / 2), mainButtons[i].y + 4, 0.45f, UIThemes->TextColor(), info[sPos + i].FileName, 295, 0, font); } } diff --git a/source/overlays/themeSelect.cpp b/source/overlays/themeSelect.cpp new file mode 100644 index 0000000..bb898d7 --- /dev/null +++ b/source/overlays/themeSelect.cpp @@ -0,0 +1,138 @@ +/* +* This file is part of Universal-Updater +* Copyright (C) 2019-2021 Universal-Team +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* +* Additional Terms 7.b and 7.c of GPLv3 apply to this file: +* * Requiring preservation of specified reasonable legal notices or +* author attributions in that material or in the Appropriate Legal +* Notices displayed by works containing it. +* * Prohibiting misrepresentation of the origin of that material, +* or requiring that modified versions of such material be marked in +* reasonable ways as different from the original version. +*/ + +#include "animation.hpp" +#include "common.hpp" +#include "overlay.hpp" +#include "storeUtils.hpp" + +extern bool touching(touchPosition touch, Structs::ButtonPos button); +static const std::vector mainButtons = { + { 10, 6, 300, 22 }, + { 10, 36, 300, 22 }, + { 10, 66, 300, 22 }, + { 10, 96, 300, 22 }, + { 10, 126, 300, 22 }, + { 10, 156, 300, 22 }, + { 10, 186, 300, 22 } +}; + +extern std::vector Themes; + +/* Select a Theme. */ +void Overlays::SelectTheme() { + bool Finish = false; + int selection = 0, sPos = 0; + + while(!Finish) { + Gui::clearTextBufs(); + C3D_FrameBegin(C3D_FRAME_SYNCDRAW); + C2D_TargetClear(Top, TRANSPARENT); + C2D_TargetClear(Bottom, TRANSPARENT); + + if (StoreUtils::store && config->usebg() && StoreUtils::store->customBG()) { + Gui::ScreenDraw(Top); + Gui::Draw_Rect(0, 0, 400, 25, UIThemes->BarColor()); + Gui::Draw_Rect(0, 25, 400, 1, UIThemes->BarOutline()); + C2D_DrawImageAt(StoreUtils::store->GetStoreImg(), 0, 26, 0.5f, nullptr); + + } else { + GFX::DrawTop(); + } + + Gui::DrawStringCentered(0, 1, 0.7f, UIThemes->TextColor(), Lang::get("SELECT_A_THEME"), 380, 0, font); + + Gui::Draw_Rect(0, 215, 400, 25, UIThemes->BarColor()); + Gui::Draw_Rect(0, 214, 400, 1, UIThemes->BarOutline()); + + Animation::QueueEntryDone(); + GFX::DrawBottom(); + + Gui::Draw_Rect(0, 215, 320, 25, UIThemes->BarColor()); + Gui::Draw_Rect(0, 214, 320, 1, UIThemes->BarOutline()); + + if (Themes.size() > 0) { + for(int i = 0; i < 7 && i < (int)Themes.size(); i++) { + if (sPos + i == selection) Gui::Draw_Rect(mainButtons[i].x, mainButtons[i].y, mainButtons[i].w, mainButtons[i].h, UIThemes->MarkSelected()); + Gui::DrawStringCentered(10 - 160 + (300 / 2), mainButtons[i].y + 4, 0.45f, UIThemes->TextColor(), Themes[sPos + i], 295, 0, font); + } + } + + C3D_FrameEnd(0); + hidScanInput(); + touchPosition touch; + hidTouchRead(&touch); + u32 hRepeat = hidKeysDownRepeat(); + Animation::HandleQueueEntryDone(); + + if (Themes.size() > 0) { + if (hRepeat & KEY_DOWN) { + if (selection < (int)Themes.size() - 1) selection++; + else selection = 0; + } + + if (hRepeat & KEY_UP) { + if (selection > 0) selection--; + else selection = Themes.size() - 1; + } + + if (hRepeat & KEY_RIGHT) { + if (selection + 7 < (int)Themes.size()-1) selection += 7; + else selection = Themes.size()-1; + } + + if (hRepeat & KEY_LEFT) { + if (selection - 7 > 0) selection -= 7; + else selection = 0; + } + + if (hidKeysDown() & KEY_A) { + UIThemes->LoadTheme(Themes[selection]); + config->theme(Themes[selection]); + Finish = true; + } + + if (hidKeysDown() & KEY_TOUCH) { + for (int i = 0; i < 7; i++) { + if (touching(touch, mainButtons[i])) { + if (i + sPos < (int)Themes.size()) { + UIThemes->LoadTheme(Themes[i + sPos]); + config->theme(Themes[i + sPos]); + Finish = true; + } + } + } + } + + if (selection < sPos) sPos = selection; + else if (selection > sPos + 7 - 1) sPos = selection - 7 + 1; + } + + if (hidKeysDown() & KEY_B) { + Finish = true; + } + } +} \ No newline at end of file diff --git a/source/qr/qrcode.cpp b/source/qr/qrcode.cpp index e0a9559..4fd41f7 100644 --- a/source/qr/qrcode.cpp +++ b/source/qr/qrcode.cpp @@ -152,27 +152,27 @@ void QRCode::drawThread() { C2D_DrawImageAt(this->image, 0, 0, 0.5, nullptr, 1.0f, 1.0f); GFX::DrawBottom(); - Gui::Draw_Rect(0, 0, 320, 25, GFX::Themes[GFX::SelectedTheme].EntryBar); - Gui::Draw_Rect(0, 25, 320, 1, GFX::Themes[GFX::SelectedTheme].EntryOutline); + Gui::Draw_Rect(0, 0, 320, 25, UIThemes->EntryBar()); + Gui::Draw_Rect(0, 25, 320, 1, UIThemes->EntryOutline()); } else { GFX::DrawTop(); - Gui::DrawStringCentered(0, 1, 0.7, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("STORE_INFO"), 390, 0, font); + Gui::DrawStringCentered(0, 1, 0.7, UIThemes->TextColor(), Lang::get("STORE_INFO"), 390, 0, font); if (this->stores.size() > 0) { - Gui::DrawStringCentered(0, 30, 0.7f, GFX::Themes[GFX::SelectedTheme].TextColor, this->stores[this->selectedStore].Title, 390, 0, font); - Gui::DrawStringCentered(0, 50, 0.6f, GFX::Themes[GFX::SelectedTheme].TextColor, this->stores[this->selectedStore].Author, 380, 0, font); - Gui::DrawStringCentered(0, 90, 0.5f, GFX::Themes[GFX::SelectedTheme].TextColor, this->stores[this->selectedStore].Description, 380, 130, font, C2D_WordWrap); + Gui::DrawStringCentered(0, 30, 0.7f, UIThemes->TextColor(), this->stores[this->selectedStore].Title, 390, 0, font); + Gui::DrawStringCentered(0, 50, 0.6f, UIThemes->TextColor(), this->stores[this->selectedStore].Author, 380, 0, font); + Gui::DrawStringCentered(0, 90, 0.5f, UIThemes->TextColor(), this->stores[this->selectedStore].Description, 380, 130, font, C2D_WordWrap); } GFX::DrawBottom(); - Gui::Draw_Rect(0, 0, 320, 25, GFX::Themes[GFX::SelectedTheme].EntryBar); - Gui::Draw_Rect(0, 25, 320, 1, GFX::Themes[GFX::SelectedTheme].EntryOutline); - Gui::DrawStringCentered(0, 2, 0.6, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("RECOMMENDED_UNISTORES"), 310, 0, font); + Gui::Draw_Rect(0, 0, 320, 25, UIThemes->EntryBar()); + Gui::Draw_Rect(0, 25, 320, 1, UIThemes->EntryOutline()); + Gui::DrawStringCentered(0, 2, 0.6, UIThemes->TextColor(), Lang::get("RECOMMENDED_UNISTORES"), 310, 0, font); for(int i = 0; i < 6 && i < (int)this->stores.size(); i++) { - if (this->sPos + i == this->selectedStore) Gui::Draw_Rect(mainButtons[i].x, mainButtons[i].y, mainButtons[i].w, mainButtons[i].h, GFX::Themes[GFX::SelectedTheme].MarkSelected); - Gui::DrawStringCentered(10 - 160 + (300 / 2), mainButtons[i].y + 4, 0.45f, GFX::Themes[GFX::SelectedTheme].TextColor, this->stores[this->sPos + i].Title, 295, 0, font); + if (this->sPos + i == this->selectedStore) Gui::Draw_Rect(mainButtons[i].x, mainButtons[i].y, mainButtons[i].w, mainButtons[i].h, UIThemes->MarkSelected()); + Gui::DrawStringCentered(10 - 160 + (300 / 2), mainButtons[i].y + 4, 0.45f, UIThemes->TextColor(), this->stores[this->sPos + i].Title, 295, 0, font); } } diff --git a/source/screens/mainScreen.cpp b/source/screens/mainScreen.cpp index 67d0111..cf8f7fb 100644 --- a/source/screens/mainScreen.cpp +++ b/source/screens/mainScreen.cpp @@ -122,11 +122,11 @@ void MainScreen::Draw(void) const { } Gui::ScreenDraw(Top); - Gui::Draw_Rect(0, 0, 400, 25, GFX::Themes[GFX::SelectedTheme].BarColor); - Gui::Draw_Rect(0, 25, 400, 1, GFX::Themes[GFX::SelectedTheme].BarOutline); + Gui::Draw_Rect(0, 0, 400, 25, UIThemes->BarColor()); + Gui::Draw_Rect(0, 25, 400, 1, UIThemes->BarOutline()); - if (StoreUtils::store && StoreUtils::store->GetValid()) Gui::DrawStringCentered(0, 1, 0.7f, GFX::Themes[GFX::SelectedTheme].TextColor, StoreUtils::store->GetUniStoreTitle(), 360, 0, font); - else Gui::DrawStringCentered(0, 1, 0.7f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("INVALID_UNISTORE"), 370, 0, font); + if (StoreUtils::store && StoreUtils::store->GetValid()) Gui::DrawStringCentered(0, 1, 0.7f, UIThemes->TextColor(), StoreUtils::store->GetUniStoreTitle(), 360, 0, font); + else Gui::DrawStringCentered(0, 1, 0.7f, UIThemes->TextColor(), Lang::get("INVALID_UNISTORE"), 370, 0, font); config->list() ? StoreUtils::DrawList() : StoreUtils::DrawGrid(); GFX::DrawTime(); GFX::DrawBattery(); diff --git a/source/utils/animation.cpp b/source/utils/animation.cpp index 645dd48..f89bcc2 100644 --- a/source/utils/animation.cpp +++ b/source/utils/animation.cpp @@ -52,8 +52,8 @@ extern curl_off_t downloadNow; u64 totalProgress: The total progress. */ void Animation::DrawProgressBar(u64 currentProgress, u64 totalProgress) { - Gui::Draw_Rect(30, 120, 342, 30, GFX::Themes[GFX::SelectedTheme].ProgressbarOut); - Gui::Draw_Rect(31, 121, (int)(((float)currentProgress / (float)totalProgress) * 338.0f), 28, GFX::Themes[GFX::SelectedTheme].ProgressbarIn); + Gui::Draw_Rect(30, 120, 342, 30, UIThemes->ProgressbarOut()); + Gui::Draw_Rect(31, 121, (int)(((float)currentProgress / (float)totalProgress) * 338.0f), 28, UIThemes->ProgressbarIn()); } /* @@ -101,29 +101,29 @@ void Animation::displayProgressBar() { C2D_TargetClear(Top, TRANSPARENT); C2D_TargetClear(Bottom, TRANSPARENT); GFX::DrawTop(); - Gui::DrawStringCentered(0, 1, 0.7f, GFX::Themes[GFX::SelectedTheme].TextColor, progressBarMsg, 390, 0, font); + Gui::DrawStringCentered(0, 1, 0.7f, UIThemes->TextColor(), progressBarMsg, 390, 0, font); switch(progressbarType) { case ProgressBar::Downloading: - Gui::DrawStringCentered(0, 80, 0.6f, GFX::Themes[GFX::SelectedTheme].TextColor, str, 390, 0, font); + Gui::DrawStringCentered(0, 80, 0.6f, UIThemes->TextColor(), str, 390, 0, font); Animation::DrawProgressBar(downloadNow, downloadTotal); break; case ProgressBar::Extracting: - Gui::DrawStringCentered(0, 180, 0.6f, GFX::Themes[GFX::SelectedTheme].TextColor, str, 390, 0, font); - Gui::DrawStringCentered(0, 100, 0.6f, GFX::Themes[GFX::SelectedTheme].TextColor, std::to_string(filesExtracted) + " / " + std::to_string(extractFilesCount) + " " + (filesExtracted == 1 ? (Lang::get("FILE_EXTRACTED")).c_str() :(Lang::get("FILES_EXTRACTED"))), 390, 0, font); - Gui::DrawStringCentered(0, 40, 0.6f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("CURRENTLY_EXTRACTING"), 390, 0, font); - Gui::DrawStringCentered(0, 70, 0.6f, GFX::Themes[GFX::SelectedTheme].TextColor, extractingFile, 390, 0, font); + Gui::DrawStringCentered(0, 180, 0.6f, UIThemes->TextColor(), str, 390, 0, font); + Gui::DrawStringCentered(0, 100, 0.6f, UIThemes->TextColor(), std::to_string(filesExtracted) + " / " + std::to_string(extractFilesCount) + " " + (filesExtracted == 1 ? (Lang::get("FILE_EXTRACTED")).c_str() :(Lang::get("FILES_EXTRACTED"))), 390, 0, font); + Gui::DrawStringCentered(0, 40, 0.6f, UIThemes->TextColor(), Lang::get("CURRENTLY_EXTRACTING"), 390, 0, font); + Gui::DrawStringCentered(0, 70, 0.6f, UIThemes->TextColor(), extractingFile, 390, 0, font); Animation::DrawProgressBar(writeOffset, extractSize); break; case ProgressBar::Installing: - Gui::DrawStringCentered(0, 80, 0.6f, GFX::Themes[GFX::SelectedTheme].TextColor, str, 390, 0, font); + Gui::DrawStringCentered(0, 80, 0.6f, UIThemes->TextColor(), str, 390, 0, font); Animation::DrawProgressBar(installOffset, installSize); break; case ProgressBar::Copying: - Gui::DrawStringCentered(0, 80, 0.6f, GFX::Themes[GFX::SelectedTheme].TextColor, str, 390, 0, font); + Gui::DrawStringCentered(0, 80, 0.6f, UIThemes->TextColor(), str, 390, 0, font); Animation::DrawProgressBar(copyOffset, copySize); break; } @@ -140,7 +140,7 @@ extern std::deque> queueEntries; void Animation::DrawQueue(int x, int y) { GFX::DrawIcon(sprites_queue0_idx + frame, x, y); - Gui::DrawStringCentered(x + 20 - 160, y + 11, 0.6f, GFX::Themes[GFX::SelectedTheme].SideBarIconColor, QueueSystem::Wait ? "!" : std::to_string(queueEntries.size()), 0, 0, font); + Gui::DrawStringCentered(x + 20 - 160, y + 11, 0.6f, UIThemes->SideBarIconColor(), QueueSystem::Wait ? "!" : std::to_string(queueEntries.size()), 0, 0, font); } void Animation::QueueAnimHandle() { if (QueueRuns) { @@ -154,10 +154,10 @@ void Animation::QueueAnimHandle() { void Animation::QueueEntryDone() { if (QueueSystem::Popup) { - Gui::Draw_Rect(0, DisplayY, 400, 34, GFX::Themes[GFX::SelectedTheme].DownListPrev); + Gui::Draw_Rect(0, DisplayY, 400, 34, UIThemes->DownListPrev()); if (QueueSystem::EndMsg != "") { - Gui::DrawStringCentered(0, DisplayY + 8, 0.6f, GFX::Themes[GFX::SelectedTheme].TextColor, QueueSystem::EndMsg, 395, 0, font); + Gui::DrawStringCentered(0, DisplayY + 8, 0.6f, UIThemes->TextColor(), QueueSystem::EndMsg, 395, 0, font); } } } diff --git a/source/utils/config.cpp b/source/utils/config.cpp index 84d3664..6a7eead 100644 --- a/source/utils/config.cpp +++ b/source/utils/config.cpp @@ -65,11 +65,11 @@ void Config::sysLang() { case 6: this->language("zh-CN"); // Chinese (Simplified) break; - + // case 7: // this->language("ko"); // Korean // break; - + // case 8: // this->language("nl"); // Dutch // break; @@ -85,7 +85,7 @@ void Config::sysLang() { case 11: this->language("zh-TW"); // Chinese (Traditional) break; - + default: this->language("en"); // Fall back to English if missing break; @@ -138,7 +138,18 @@ Config::Config() { if (this->json.contains("CustomFont")) this->customfont(this->getBool("CustomFont")); if (this->json.contains("Shortcut_Path")) this->shortcut(this->getString("Shortcut_Path")); if (this->json.contains("Display_Changelog")) this->changelog(this->getBool("Display_Changelog")); - if (this->json.contains("Active_Theme")) this->theme(this->getInt("Active_Theme")); + + /* Exceptions for it. It was an INT before. */ + if (this->json.contains("Active_Theme")) { + if (this->json["Active_Theme"].is_number()) { + this->json["Active_Theme"] = "Default"; + this->theme(this->getString("Active_Theme")); + + } else { + this->theme(this->getString("Active_Theme")); + } + } + if (this->json.contains("Prompt")) this->prompt(this->getBool("Prompt")); this->changesMade = false; // No changes made yet. @@ -166,7 +177,7 @@ void Config::save() { this->setBool("CustomFont", this->customfont()); this->setString("Shortcut_Path", this->shortcut()); this->setBool("Display_Changelog", this->changelog()); - this->setInt("Active_Theme", this->theme()); + this->setString("Active_Theme", this->theme()); this->setBool("Prompt", this->prompt()); /* Write changes to file. */ diff --git a/source/utils/download.cpp b/source/utils/download.cpp index 3cca1c8..ea17473 100644 --- a/source/utils/download.cpp +++ b/source/utils/download.cpp @@ -862,19 +862,19 @@ void UpdateAction() { C2D_TargetClear(Bottom, C2D_Color32(0, 0, 0, 0)); Gui::ScreenDraw(Top); - Gui::Draw_Rect(0, 26, 400, 214, GFX::Themes[GFX::SelectedTheme].BGColor); - Gui::DrawString(5, 25 - scrollIndex, 0.5f, GFX::Themes[GFX::SelectedTheme].TextColor, res.Notes, 390, 0, font, C2D_WordWrap); - Gui::Draw_Rect(0, 0, 400, 25, GFX::Themes[GFX::SelectedTheme].BarColor); - Gui::Draw_Rect(0, 25, 400, 1, GFX::Themes[GFX::SelectedTheme].BarOutline); - Gui::DrawStringCentered(0, 1, 0.7f, GFX::Themes[GFX::SelectedTheme].TextColor, "Universal-Updater", 390, 0, font); - Gui::Draw_Rect(0, 215, 400, 25, GFX::Themes[GFX::SelectedTheme].BarColor); - Gui::Draw_Rect(0, 214, 400, 1, GFX::Themes[GFX::SelectedTheme].BarOutline); - Gui::DrawStringCentered(0, 217, 0.7f, GFX::Themes[GFX::SelectedTheme].TextColor, res.Version, 390, 0, font); + Gui::Draw_Rect(0, 26, 400, 214, UIThemes->BGColor()); + Gui::DrawString(5, 25 - scrollIndex, 0.5f, UIThemes->TextColor(), res.Notes, 390, 0, font, C2D_WordWrap); + Gui::Draw_Rect(0, 0, 400, 25, UIThemes->BarColor()); + Gui::Draw_Rect(0, 25, 400, 1, UIThemes->BarOutline()); + Gui::DrawStringCentered(0, 1, 0.7f, UIThemes->TextColor(), "Universal-Updater", 390, 0, font); + Gui::Draw_Rect(0, 215, 400, 25, UIThemes->BarColor()); + Gui::Draw_Rect(0, 214, 400, 1, UIThemes->BarOutline()); + Gui::DrawStringCentered(0, 217, 0.7f, UIThemes->TextColor(), res.Version, 390, 0, font); GFX::DrawBottom(); - Gui::Draw_Rect(0, 0, 320, 25, GFX::Themes[GFX::SelectedTheme].BarColor); - Gui::Draw_Rect(0, 25, 320, 1, GFX::Themes[GFX::SelectedTheme].BarOutline); - Gui::DrawStringCentered(0, 1, 0.7f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("UPDATE_AVAILABLE"), 310, 0, font); + Gui::Draw_Rect(0, 0, 320, 25, UIThemes->BarColor()); + Gui::Draw_Rect(0, 25, 320, 1, UIThemes->BarOutline()); + Gui::DrawStringCentered(0, 1, 0.7f, UIThemes->TextColor(), Lang::get("UPDATE_AVAILABLE"), 310, 0, font); C3D_FrameEnd(0); hidScanInput(); diff --git a/source/utils/theme.cpp b/source/utils/theme.cpp new file mode 100644 index 0000000..405eb4e --- /dev/null +++ b/source/utils/theme.cpp @@ -0,0 +1,140 @@ +/* +* This file is part of Universal-Updater +* Copyright (C) 2019-2021 Universal-Team +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* +* Additional Terms 7.b and 7.c of GPLv3 apply to this file: +* * Requiring preservation of specified reasonable legal notices or +* author attributions in that material or in the Appropriate Legal +* Notices displayed by works containing it. +* * Prohibiting misrepresentation of the origin of that material, +* or requiring that modified versions of such material be marked in +* reasonable ways as different from the original version. +*/ + +#include "theme.hpp" +#include +#include + +/** + * @brief Creates a 8 byte RGBA color + * @param r red component of the color + * @param g green component of the color + * @param b blue component of the color + * @param a alpha component of the color + */ +#define RGBA8(r, g, b, a) ((((r)&0xFF)<<0) | (((g)&0xFF)<<8) | (((b)&0xFF)<<16) | (((a)&0xFF)<<24)) + + +Theme::Theme(const std::string &ThemeJSON) { + /* Set Default colors. */ + this->vBarColor = C2D_Color32(50, 73, 98, 255); + this->vBGColor = C2D_Color32(38, 44, 77, 255); + this->vBarOutline = C2D_Color32(25, 30, 53, 255); + this->vTextColor = C2D_Color32(255, 255, 255, 255); + this->vEntryBar = C2D_Color32(50, 73, 98, 255); + this->vEntryOutline = C2D_Color32(25, 30, 53, 255); + this->vBoxInside = C2D_Color32(28, 33, 58, 255); + this->vBoxSelected = C2D_Color32(108, 130, 155, 255); + this->vBoxUnselected = C2D_Color32(0, 0, 0, 255); + this->vProgressbarOut = C2D_Color32(28, 33, 58, 255); + this->vProgressbarIn = C2D_Color32(77, 101, 128, 255); + this->vSearchBar = C2D_Color32(51, 75, 102, 255); + this->vSearchBarOutline = C2D_Color32(25, 30, 53, 255); + this->vSideBarSelected = C2D_Color32(108, 130, 155, 255); + this->vSideBarUnselected = C2D_Color32(77, 101, 128, 255); + this->vMarkSelected = C2D_Color32(77, 101, 128, 255); + this->vMarkUnselected = C2D_Color32(28, 33, 58, 255); + this->vDownListPrev = C2D_Color32(28, 33, 58, 255); + this->vSideBarIconColor = C2D_Color32(173, 204, 239, 255); + + if (access(ThemeJSON.c_str(), F_OK) != 0) this->InitWithDefaultColors(); + + FILE *file = fopen(ThemeJSON.c_str(), "r"); + this->json = nlohmann::json::parse(file, nullptr, false); + fclose(file); + this->Loaded = true; +} + +void Theme::InitWithDefaultColors(const std::string &ThemePath) { + const std::vector DefaultColors = { // Default Universal-Updater Theme. + "#324962", "#262C4D", "#191E35", "#FFFFFF", + "#324962", "#191E35", "#1C213A", "#6C829B", + "#000000", "#1C213A", "#4D6580", "#334B66", + "#191E35", "#6C829B", "#4D6580", "#4D6580", + "#1C213A", "#1C213A", "#ADCCEF" + }; + + nlohmann::json JS = { }; + JS["Default"] = DefaultColors; + + FILE *out = fopen(ThemePath.c_str(), "w"); + const std::string dump = JS.dump(1, '\t'); + fwrite(dump.c_str(), 1, JS.dump(1, '\t').size(), out); + fclose(out); +} + + +void Theme::LoadTheme(const std::string &ThemeName) { + if (this->Loaded && this->json.contains(ThemeName) && this->json[ThemeName].is_array()) { + if (this->json[ThemeName].size() == 19) { // 19 Colors array. + const std::vector Colors = this->json[ThemeName].get>(); + + this->vBarColor = this->GetThemeColor(Colors[0], C2D_Color32(50, 73, 98, 255)); + this->vBGColor = this->GetThemeColor(Colors[1], C2D_Color32(38, 44, 77, 255)); + this->vBarOutline = this->GetThemeColor(Colors[2], C2D_Color32(25, 30, 53, 255)); + this->vTextColor = this->GetThemeColor(Colors[3], C2D_Color32(255, 255, 255, 255)); + this->vEntryBar = this->GetThemeColor(Colors[4], C2D_Color32(50, 73, 98, 255)); + this->vEntryOutline = this->GetThemeColor(Colors[5], C2D_Color32(25, 30, 53, 255)); + this->vBoxInside = this->GetThemeColor(Colors[6], C2D_Color32(28, 33, 58, 255)); + this->vBoxSelected = this->GetThemeColor(Colors[7], C2D_Color32(108, 130, 155, 255)); + this->vBoxUnselected = this->GetThemeColor(Colors[8], C2D_Color32(0, 0, 0, 255)); + this->vProgressbarOut = this->GetThemeColor(Colors[9], C2D_Color32(28, 33, 58, 255)); + this->vProgressbarIn = this->GetThemeColor(Colors[10], C2D_Color32(77, 101, 128, 255)); + this->vSearchBar = this->GetThemeColor(Colors[11], C2D_Color32(51, 75, 102, 255)); + this->vSearchBarOutline = this->GetThemeColor(Colors[12], C2D_Color32(25, 30, 53, 255)); + this->vSideBarSelected = this->GetThemeColor(Colors[13], C2D_Color32(108, 130, 155, 255)); + this->vSideBarUnselected = this->GetThemeColor(Colors[14], C2D_Color32(77, 101, 128, 255)); + this->vMarkSelected = this->GetThemeColor(Colors[15], C2D_Color32(77, 101, 128, 255)); + this->vMarkUnselected = this->GetThemeColor(Colors[16], C2D_Color32(28, 33, 58, 255)); + this->vDownListPrev = this->GetThemeColor(Colors[17], C2D_Color32(28, 33, 58, 255)); + this->vSideBarIconColor = this->GetThemeColor(Colors[18], C2D_Color32(173, 204, 239, 255)); + } + } +} + +std::vector Theme::ThemeNames() { + std::vector Temp = { }; + + if (this->Loaded) { + for(auto it = this->json.begin(); it != this->json.end(); ++it) { + Temp.push_back(it.key().c_str()); + } + } + + return Temp; +} + + +uint32_t Theme::GetThemeColor(const std::string &colorString, const uint32_t DefaultColor) { + if (colorString.length() < 7 || std::regex_search(colorString.substr(1), std::regex("[^0-9A-F]"))) { // invalid color. + return DefaultColor; + } + + int r = std::stoi(colorString.substr(1, 2), nullptr, 16); + int g = std::stoi(colorString.substr(3, 2), nullptr, 16); + int b = std::stoi(colorString.substr(5, 2), nullptr, 16); + return RGBA8(r, g, b, 0xFF); +} \ No newline at end of file