diff --git a/Makefile b/Makefile index 3e7ce08..a9bc7bf 100644 --- a/Makefile +++ b/Makefile @@ -87,7 +87,7 @@ GRAPHICS := assets/gfx ROMFS := romfs GFXBUILD := $(ROMFS)/gfx APP_AUTHOR := Universal-Team -APP_DESCRIPTION := A multiapp, JSON script-based updater for Nintendo 3DS +APP_DESCRIPTION := An easy to use app for installing and updating 3DS homebrew ICON := app/icon.png BNR_IMAGE := app/banner.png BNR_AUDIO := app/BannerAudio.wav diff --git a/README.md b/README.md index 888a8f9..6056ffe 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ To build Universal-Updater from source, you will need to setup devkitARM with li ## Screenshots -![](https://github.com/Universal-Team/Universal-Updater/blob/master/screenshots/Credits.png)![](https://github.com/Universal-Team/Universal-Updater/blob/master/screenshots/DirectorySelection.png)![](https://github.com/Universal-Team/Universal-Updater/blob/master/screenshots/DownloadList.png)![](https://github.com/Universal-Team/Universal-Updater/blob/master/screenshots/EntryInfo.png)![](https://github.com/Universal-Team/Universal-Updater/blob/master/screenshots/LanguageSelection.png)![](https://github.com/Universal-Team/Universal-Updater/blob/master/screenshots/ListStyle.png)![](https://github.com/Universal-Team/Universal-Updater/blob/master/screenshots/MarkMenu.png)![](https://github.com/Universal-Team/Universal-Updater/blob/master/screenshots/SearchMenu.png)![](https://github.com/Universal-Team/Universal-Updater/blob/master/screenshots/SettingsMenu.png)![](https://github.com/Universal-Team/Universal-Updater/blob/master/screenshots/SortMenu.png)![](https://github.com/Universal-Team/Universal-Updater/blob/master/screenshots/StoreSelection.png) +![](https://github.com/Universal-Team/Universal-Updater/blob/master/screenshots/Credits.png)![](https://github.com/Universal-Team/Universal-Updater/blob/master/screenshots/DirectorySelection.png)![](https://github.com/Universal-Team/Universal-Updater/blob/master/screenshots/DownloadList.png)![](https://github.com/Universal-Team/Universal-Updater/blob/master/screenshots/EntryInfo.png)![](https://github.com/Universal-Team/Universal-Updater/blob/master/screenshots/LanguageSelection.png)![](https://github.com/Universal-Team/Universal-Updater/blob/master/screenshots/ListStyle.png)![](https://github.com/Universal-Team/Universal-Updater/blob/master/screenshots/MarkMenu.png)![](https://github.com/Universal-Team/Universal-Updater/blob/master/screenshots/SearchMenu.png)![](https://github.com/Universal-Team/Universal-Updater/blob/master/screenshots/SettingsMenu.png)![](https://github.com/Universal-Team/Universal-Updater/blob/master/screenshots/SortMenu.png)![](https://github.com/Universal-Team/Universal-Updater/blob/master/screenshots/StoreSelection.png)![](https://github.com/Universal-Team/Universal-Updater/blob/master/screenshots/ToggleMenu.png) ## Credits diff --git a/assets/gfx/sprites.t3s b/assets/gfx/sprites.t3s index 4e60d64..145e747 100644 --- a/assets/gfx/sprites.t3s +++ b/assets/gfx/sprites.t3s @@ -1,6 +1,7 @@ --atlas -f rgba -z auto sprites/add.png +sprites/arrow.png sprites/checked.png sprites/delete.png sprites/download.png @@ -12,6 +13,8 @@ sprites/settings.png sprites/sort.png sprites/sort_checked.png sprites/sort_unchecked.png +sprites/toggle_off.png +sprites/toggle_on.png sprites/unchecked.png sprites/universal-updater.png sprites/universal-core.png diff --git a/assets/gfx/sprites/arrow.png b/assets/gfx/sprites/arrow.png new file mode 100644 index 0000000..8d685c1 Binary files /dev/null and b/assets/gfx/sprites/arrow.png differ diff --git a/assets/gfx/sprites/toggle_off.png b/assets/gfx/sprites/toggle_off.png new file mode 100644 index 0000000..f7818f5 Binary files /dev/null and b/assets/gfx/sprites/toggle_off.png differ diff --git a/assets/gfx/sprites/toggle_on.png b/assets/gfx/sprites/toggle_on.png new file mode 100644 index 0000000..347281f Binary files /dev/null and b/assets/gfx/sprites/toggle_on.png differ diff --git a/include/gui/gfx.hpp b/include/gui/gfx.hpp index c8aa60f..284fe07 100644 --- a/include/gui/gfx.hpp +++ b/include/gui/gfx.hpp @@ -48,19 +48,19 @@ #define BAR_OUTL_COLOR C2D_Color32(25, 30, 53, 255) #define BG_COLOR C2D_Color32(38, 44, 77, 255) -/* Progressbar Colors. */ -#define PROGRESSBAR_OUT_COLOR BLACK -#define PROGRESSBAR_IN_COLOR WHITE - /* Entry Colors. */ #define ENTRY_BAR_COLOR BAR_COLOR #define ENTRY_BAR_OUTL_COLOR BAR_OUTL_COLOR /* Entry Box Colors. */ -#define BOX_INSIDE_COLOR C2D_Color32(49, 49, 49, 255) -#define BOX_SELECTED_COLOR C2D_Color32(240, 0, 0, 255) +#define BOX_INSIDE_COLOR C2D_Color32(28, 33, 58, 255) +#define BOX_SELECTED_COLOR C2D_Color32(108, 130, 155, 255) #define BOX_UNSELECTED_COLOR BLACK +/* Progressbar Colors. */ +#define PROGRESSBAR_OUT_COLOR BOX_INSIDE_COLOR +#define PROGRESSBAR_IN_COLOR SIDEBAR_UNSELECTED_COLOR + /* Search Menu Colors. */ #define SEARCH_BAR_COLOR C2D_Color32(51, 75, 102, 255) #define SEARCH_BAR_OUTL_COLOR BAR_OUTL_COLOR @@ -73,9 +73,10 @@ namespace GFX { void DrawTop(void); void DrawBottom(); void DrawSprite(const int &img, const int &x, const int &y, const float &ScaleX = 1, const float &ScaleY = 1); - void drawBox(const float &xPos, const float &yPos, const float &width = 50, const float &height = 50, const bool &selected = false, const uint32_t &clr = BOX_INSIDE_COLOR); + void DrawBox(const float &xPos, const float &yPos, const float &width = 50, const float &height = 50, const bool &selected = false, const uint32_t &clr = BOX_INSIDE_COLOR); void DrawButton(const float &xPos, const float &yPos, const float &width, const float &height, const bool &selected, const std::string &Text = ""); void DrawCheckbox(const float &xPos, const float &yPos, const bool &selected); + void DrawToggle(float xPos, float yPos, bool toggled); }; #endif \ No newline at end of file diff --git a/romfs/lang/en/app.json b/romfs/lang/en/app.json index bcadc9c..a998f34 100644 --- a/romfs/lang/en/app.json +++ b/romfs/lang/en/app.json @@ -1,6 +1,12 @@ { "ASCENDING": "Ascending", "AUTHOR": "Author", + "AUTO_UPDATE_SETTINGS": "Auto-update Settings", + "AUTO_UPDATE_SETTINGS_BTN": "Auto-update settings...", + "AUTO_UPDATE_UNISTORE": "Auto-update UniStores", + "AUTO_UPDATE_UNISTORE_DESC": "With this, the last used UniStore will be updated automatically when launching Universal-Updater.", + "AUTO_UPDATE_UU": "Auto-update Universal-Updater", + "AUTO_UPDATE_UU_DESC": "When enabled, Universal-Updater will check for updates every time it's opened.", "BOOT_TITLE": "Would you like to boot this title?", "CATEGORY": "Category", "CHANGE_3DSX_PATH": "Change 3DSX path", diff --git a/screenshots/DirectorySelection.png b/screenshots/DirectorySelection.png index 97e7038..a10755b 100644 Binary files a/screenshots/DirectorySelection.png and b/screenshots/DirectorySelection.png differ diff --git a/screenshots/DownloadList.png b/screenshots/DownloadList.png index bf624b0..aa6dd00 100644 Binary files a/screenshots/DownloadList.png and b/screenshots/DownloadList.png differ diff --git a/screenshots/EntryInfo.png b/screenshots/EntryInfo.png index 31f98ca..b138a4c 100644 Binary files a/screenshots/EntryInfo.png and b/screenshots/EntryInfo.png differ diff --git a/screenshots/LanguageSelection.png b/screenshots/LanguageSelection.png index 1983be2..6617239 100644 Binary files a/screenshots/LanguageSelection.png and b/screenshots/LanguageSelection.png differ diff --git a/screenshots/ListStyle.png b/screenshots/ListStyle.png index e612a08..b7b3fc0 100644 Binary files a/screenshots/ListStyle.png and b/screenshots/ListStyle.png differ diff --git a/screenshots/MarkMenu.png b/screenshots/MarkMenu.png index 092324c..81f2dfd 100644 Binary files a/screenshots/MarkMenu.png and b/screenshots/MarkMenu.png differ diff --git a/screenshots/SearchMenu.png b/screenshots/SearchMenu.png index ac19d76..aae78d6 100644 Binary files a/screenshots/SearchMenu.png and b/screenshots/SearchMenu.png differ diff --git a/screenshots/SettingsMenu.png b/screenshots/SettingsMenu.png index 77cb539..0e655e9 100644 Binary files a/screenshots/SettingsMenu.png and b/screenshots/SettingsMenu.png differ diff --git a/screenshots/SortMenu.png b/screenshots/SortMenu.png index 74054cc..7f7e84b 100644 Binary files a/screenshots/SortMenu.png and b/screenshots/SortMenu.png differ diff --git a/screenshots/StoreSelection.png b/screenshots/StoreSelection.png index aa69b68..719b5cc 100644 Binary files a/screenshots/StoreSelection.png and b/screenshots/StoreSelection.png differ diff --git a/screenshots/ToggleMenu.png b/screenshots/ToggleMenu.png new file mode 100644 index 0000000..28d324e Binary files /dev/null and b/screenshots/ToggleMenu.png differ diff --git a/source/gui/gfx.cpp b/source/gui/gfx.cpp index 9e82002..8a709a4 100644 --- a/source/gui/gfx.cpp +++ b/source/gui/gfx.cpp @@ -55,16 +55,17 @@ void GFX::DrawBottom() { const bool &selected: Const Reference, if outline is selected (Red) or not (Black). const uint32_t &clr: (Optional) The color of the inside of the box. */ -void GFX::drawBox(const float &xPos, const float &yPos, const float &width, const float &height, const bool &selected, const uint32_t &clr) { - static constexpr int w = 1; - const uint32_t outlineColor = selected ? BOX_SELECTED_COLOR : BOX_UNSELECTED_COLOR; // Get Selected | Unselected color. +void GFX::DrawBox(const float &xPos, const float &yPos, const float &width, const float &height, const bool &selected, const uint32_t &clr) { + Gui::Draw_Rect(xPos, yPos, width, height, BOX_INSIDE_COLOR); // Draw middle BG. - Gui::Draw_Rect(xPos, yPos, width, height, clr); // Draw middle BG. + if (selected) { + static constexpr int depth = 2; - Gui::Draw_Rect(xPos, yPos, width, w, outlineColor); // Top. - Gui::Draw_Rect(xPos, yPos + w, w, height - 2 * w, outlineColor); // Left. - Gui::Draw_Rect(xPos + width - w, yPos + w, w, height - 2 * w, outlineColor); // Right. - Gui::Draw_Rect(xPos, yPos + height - w, width, w, outlineColor); // Bottom. + Gui::Draw_Rect(xPos - depth, yPos - depth, width + depth * 2, depth, BOX_SELECTED_COLOR); // Top. + Gui::Draw_Rect(xPos - depth, yPos - depth, depth, height + depth * 2, BOX_SELECTED_COLOR); // Left. + Gui::Draw_Rect(xPos + width, yPos - depth, depth, height + depth * 2, BOX_SELECTED_COLOR); // Right. + Gui::Draw_Rect(xPos - depth, yPos + height, width + depth * 2, depth, BOX_SELECTED_COLOR); // Bottom. + } } extern C2D_SpriteSheet sprites; @@ -82,22 +83,6 @@ void GFX::DrawSprite(const int &img, const int &x, const int &y, const float &Sc Gui::DrawSprite(sprites, img, x, y, ScaleX, ScaleY); } -/* - Draw a button (actually the box) with a centered string in it. - - const float &xPos: Const Reference to the X-Position where to draw the box. - const float &yPos: Const Reference to the Y-Position where to draw the box. - const float &width: Const Reference to the Width of the button. - const float &height: Const Reference to the Height of the button. - const bool &selected: Const Reference, if outline is selected (Red) or not (Black). - const std::string &Text: Const Reference of the Text which should be drawn. -*/ -void GFX::DrawButton(const float &xPos, const float &yPos, const float &width, const float &height, const bool &selected, const std::string &Text) { - drawBox(xPos, yPos, width, height, selected); - - Gui::DrawStringCentered(xPos - 160 + (width / 2), yPos + (height / 2) - (Gui::GetStringHeight(0.4f, Text) / 2), 0.4f, TEXT_COLOR, Text, width - 4, height - 4); -} - /* Draw the checkbox. @@ -107,4 +92,15 @@ void GFX::DrawButton(const float &xPos, const float &yPos, const float &width, c */ void GFX::DrawCheckbox(const float &xPos, const float &yPos, const bool &selected) { GFX::DrawSprite((selected ? sprites_checked_idx : sprites_unchecked_idx), xPos, yPos); +} + +/* + Draw the toggle box. + + float xPos: The X-Position where to draw the toggle. + float yPos: The Y-Position where to draw the toggle. + bool toggled: If toggled or not. +*/ +void GFX::DrawToggle(float xPos, float yPos, bool toggled) { + GFX::DrawSprite((toggled ? sprites_toggle_on_idx : sprites_toggle_off_idx), xPos, yPos); } \ No newline at end of file diff --git a/source/gui/msg.cpp b/source/gui/msg.cpp index 71a2db8..30ce211 100644 --- a/source/gui/msg.cpp +++ b/source/gui/msg.cpp @@ -81,7 +81,7 @@ bool Msg::promptMsg(const std::string &promptMsg) { Gui::Draw_Rect(0, 214, 400, 1, BAR_OUTL_COLOR); Gui::DrawStringCentered(0, (240 - Gui::GetStringHeight(0.6f, promptMsg)) / 2, 0.6f, TEXT_COLOR, promptMsg, 395); - Gui::DrawStringCentered(0, 217, 0.6f, TEXT_COLOR, Lang::get("CONFIRM_OR_CANCEL"), 390); + Gui::DrawStringCentered(0, 218, 0.6f, TEXT_COLOR, Lang::get("CONFIRM_OR_CANCEL"), 390); C3D_FrameEnd(0); for (int i = 0; i < 3; i++) gspWaitForVBlank(); @@ -111,7 +111,7 @@ void Msg::waitMsg(const std::string &msg) { Gui::Draw_Rect(0, 215, 400, 25, BAR_COLOR); Gui::Draw_Rect(0, 214, 400, 1, BAR_OUTL_COLOR); - Gui::DrawStringCentered(0, 217, 0.6f, TEXT_COLOR, Lang::get("KEY_CONTINUE"), 390); + Gui::DrawStringCentered(0, 218, 0.6f, TEXT_COLOR, Lang::get("KEY_CONTINUE"), 390); C3D_FrameEnd(0); for (int i = 0; i < 3; i++) gspWaitForVBlank(); diff --git a/source/init.cpp b/source/init.cpp index 1d01113..aa4a930 100644 --- a/source/init.cpp +++ b/source/init.cpp @@ -106,7 +106,7 @@ Result Init::MainLoop() { bool fullExit = false; if (Initialize() == -1) fullExit = true; - hidSetRepeatParameters(20, 10); + hidSetRepeatParameters(20, 8); /* Loop as long as the status is not fullExit. */ while (aptMainLoop() && !fullExit) { @@ -129,7 +129,7 @@ Result Init::MainLoop() { if (hDown & KEY_START) fullExit = true; // Make it optionally faster. if (fadeAlpha < 255) { - fadeAlpha += 2; + fadeAlpha += 4; if (fadeAlpha >= 255) { fullExit = true; } diff --git a/source/overlays/dirSelect.cpp b/source/overlays/dirSelect.cpp index 98e984d..83e119b 100644 --- a/source/overlays/dirSelect.cpp +++ b/source/overlays/dirSelect.cpp @@ -83,7 +83,7 @@ std::string Overlays::SelectDir(const std::string &oldDir, const std::string &ms if (dirContents.size() > 0) { for(int i = 0; i < 7 && i < (int)dirContents.size(); i++) { - GFX::drawBox(10, mainButtons[i].y, 300, 22, sPos + i == selection); + if (sPos + i == selection) GFX::DrawBox(mainButtons[i].x, mainButtons[i].y, mainButtons[i].w, mainButtons[i].h, false); Gui::DrawStringCentered(10 - 160 + (300 / 2), mainButtons[i].y + 4, 0.45f, TEXT_COLOR, dirContents[sPos + i].name, 295); } } diff --git a/source/overlays/langSelect.cpp b/source/overlays/langSelect.cpp index 654ded7..f14fd47 100644 --- a/source/overlays/langSelect.cpp +++ b/source/overlays/langSelect.cpp @@ -66,7 +66,7 @@ void Overlays::SelectLanguage() { GFX::DrawBottom(); for(int i = 0; i < 8 && i < (int)languages.size(); i++) { - GFX::drawBox(10, mainButtons[i].y, 300, 22, sPos + i == selection); + if (sPos + i == selection) GFX::DrawBox(mainButtons[i].x, mainButtons[i].y, mainButtons[i].w, mainButtons[i].h, false); Gui::DrawStringCentered(0, mainButtons[i].y + 4, 0.45f, TEXT_COLOR, languages[sPos + i], 280); } C3D_FrameEnd(0); diff --git a/source/overlays/storeSelect.cpp b/source/overlays/storeSelect.cpp index 866ee5d..b6f3df6 100644 --- a/source/overlays/storeSelect.cpp +++ b/source/overlays/storeSelect.cpp @@ -207,7 +207,8 @@ void Overlays::SelectStore(std::unique_ptr &store, std::vector @@ -32,6 +33,8 @@ extern int fadeAlpha; extern u32 hRepeat; +extern UniStoreInfo GetInfo(const std::string &file, const std::string &fileName); + /* MainScreen Constructor. @@ -46,13 +49,27 @@ MainScreen::MainScreen() { if (config->lastStore() != "universal-db-beta.unistore" || config->lastStore() != "") { if (access((std::string(_STORE_PATH) + config->lastStore()).c_str(), F_OK) != 0) { config->lastStore("universal-db-beta.unistore"); + + } else { + /* check version and file here. */ + const UniStoreInfo info = GetInfo((std::string(_STORE_PATH) + config->lastStore()), config->lastStore()); + + if (info.Version != 3) { + config->lastStore("universal-db-beta.unistore"); + } + + if (info.File != "") { // Ensure to check for this. + if ((info.File.find("/") != std::string::npos)) { + config->lastStore("universal-db-beta.unistore"); // It does contain a '/' which is invalid. + } + } } } /* If Universal DB --> Get! */ if (config->lastStore() == "universal-db-beta.unistore" || config->lastStore() == "") { if (access("sdmc:/3ds/Universal-Updater/stores/universal-db-beta.unistore", F_OK) != 0) { - std::string tmp = ""; + std::string tmp = ""; // Just a temp. DownloadUniStore("https://db.universal-team.net/unistore/universal-db-beta.unistore", -1, tmp, true, true); DownloadSpriteSheet("https://db.universal-team.net/unistore/universal-db.t3x", "universal-db.t3x"); } diff --git a/source/store/downList.cpp b/source/store/downList.cpp index 6d24470..7aa4619 100644 --- a/source/store/downList.cpp +++ b/source/store/downList.cpp @@ -52,7 +52,7 @@ void StoreUtils::DrawDownList(const std::unique_ptr &store, const std::ve if (store && !fetch) { if (entries.size() > 0) { for (int i = 0; i < DOWNLOAD_ENTRIES && i < (int)entries.size(); i++) { - GFX::drawBox(downloadBoxes[i].x, downloadBoxes[i].y, downloadBoxes[i].w, downloadBoxes[i].h, store->GetDownloadIndex() == i + store->GetDownloadSIndex()); + if (store->GetDownloadIndex() == i + store->GetDownloadSIndex()) GFX::DrawBox(downloadBoxes[i].x, downloadBoxes[i].y, downloadBoxes[i].w, downloadBoxes[i].h, false); Gui::DrawStringCentered(54 - 160 + (262 / 2), downloadBoxes[i].y + 4, 0.45f, TEXT_COLOR, entries[(i + store->GetDownloadSIndex())], 260); } diff --git a/source/store/entryInfo.cpp b/source/store/entryInfo.cpp index 2625d1a..a838e67 100644 --- a/source/store/entryInfo.cpp +++ b/source/store/entryInfo.cpp @@ -60,7 +60,7 @@ void StoreUtils::DrawEntryInfo(const std::unique_ptr &store, const std::u Gui::DrawString(61, 175, 0.45, TEXT_COLOR, Lang::get("LAST_UPDATED") + ": " + entry->GetLastUpdated(), 240); Gui::DrawString(61, 190, 0.45, TEXT_COLOR, Lang::get("LICENSE") + ": " + entry->GetLicense(), 240); - GFX::drawBox(btn.x, btn.y, btn.w, btn.h, false); + GFX::DrawBox(btn.x, btn.y, btn.w, btn.h, false); Gui::DrawString(btn.x + 3, btn.y, 0.6f, TEXT_COLOR, "★"); } } diff --git a/source/store/grid.cpp b/source/store/grid.cpp index cdba980..1ab02c9 100644 --- a/source/store/grid.cpp +++ b/source/store/grid.cpp @@ -58,12 +58,7 @@ void StoreUtils::DrawGrid(const std::unique_ptr &store, const std::vector for (int i = 0, i2 = 0 + (store->GetScreenIndx() * 5); i2 < 15 + (store->GetScreenIndx() * 5) && i2 < (int)entries.size(); i2++, i++) { /* Boxes. */ - if (i == store->GetBox()) { - GFX::drawBox(GridBoxes[i].x, GridBoxes[i].y, 50, 50, true); - - } else { - GFX::drawBox(GridBoxes[i].x, GridBoxes[i].y, 50, 50, false); - } + if (i == store->GetBox()) GFX::DrawBox(GridBoxes[i].x, GridBoxes[i].y, 50, 50, true); /* Ensure, entries is larger than the index. */ if ((int)entries.size() > i2) { @@ -123,6 +118,11 @@ void StoreUtils::GridLogic(u32 hDown, u32 hHeld, touchPosition touch, std::uniqu if (store->GetBox() < 14) { store->SetBox(store->GetBox() + 1); store->SetEntry(store->GetEntry() + 1); + + } else { + store->SetBox(10); + store->SetEntry(store->GetEntry() + 1); + needUpdate = true; } } } @@ -132,6 +132,11 @@ void StoreUtils::GridLogic(u32 hDown, u32 hHeld, touchPosition touch, std::uniqu if (store->GetBox() > 0) { store->SetBox(store->GetBox() - 1); store->SetEntry(store->GetEntry() - 1); + + } else { + store->SetBox(4); + store->SetEntry(store->GetEntry() - 1); + needUpdate = true; } } } diff --git a/source/store/list.cpp b/source/store/list.cpp index 6586c3c..f50f7f0 100644 --- a/source/store/list.cpp +++ b/source/store/list.cpp @@ -44,8 +44,9 @@ void StoreUtils::DrawList(const std::unique_ptr &store, const std::vector if (entries.size() > 0) { for (int i = 0; i < 3 && i < (int)entries.size(); i++) { - /* Boxes. */ - GFX::drawBox(StoreBoxesList[i].x, StoreBoxesList[i].y, StoreBoxesList[i].w, StoreBoxesList[i].h, i + store->GetScreenIndx() == store->GetEntry()); + if (i + store->GetScreenIndx() == store->GetEntry()) { + GFX::DrawBox(StoreBoxesList[i].x, StoreBoxesList[i].y, StoreBoxesList[i].w, StoreBoxesList[i].h, false); + } /* Ensure, entries is larger than the index. */ if ((int)entries.size() > i + store->GetScreenIndx()) { diff --git a/source/store/markMenu.cpp b/source/store/markMenu.cpp index c46e3b7..a158800 100644 --- a/source/store/markMenu.cpp +++ b/source/store/markMenu.cpp @@ -46,19 +46,28 @@ static const std::vector markBox = { void StoreUtils::DisplayMarkBox(const int &marks) { Gui::Draw_Rect(0, 0, 320, 240, DIM_COLOR); // Darken. - GFX::drawBox(markBox[0].x, markBox[0].y, markBox[0].w, markBox[0].h, marks & favoriteMarks::STAR); - GFX::drawBox(markBox[1].x, markBox[1].y, markBox[1].w, markBox[1].h, marks & favoriteMarks::HEART); - GFX::drawBox(markBox[2].x, markBox[2].y, markBox[2].w, markBox[2].h, marks & favoriteMarks::DIAMOND); - GFX::drawBox(markBox[3].x, markBox[3].y, markBox[3].w, markBox[3].h, marks & favoriteMarks::CLUBS); - GFX::drawBox(markBox[4].x, markBox[4].y, markBox[4].w, markBox[4].h, marks & favoriteMarks::SPADE); + Gui::Draw_Rect(markBox[0].x, markBox[0].y, markBox[0].w, markBox[0].h, (marks & favoriteMarks::STAR ? + SIDEBAR_UNSELECTED_COLOR : BOX_INSIDE_COLOR)); - Gui::DrawString(markBox[0].x + 15, markBox[0].y + 12, 0.9, TEXT_COLOR, "★"); - Gui::DrawString(markBox[1].x + 15, markBox[1].y + 12, 0.9, TEXT_COLOR, "♥"); - Gui::DrawString(markBox[2].x + 15, markBox[2].y + 12, 0.9, TEXT_COLOR, "♦"); - Gui::DrawString(markBox[3].x + 15, markBox[3].y + 12, 0.9, TEXT_COLOR, "♣"); - Gui::DrawString(markBox[4].x + 15, markBox[4].y + 12, 0.9, TEXT_COLOR, "♠"); + Gui::Draw_Rect(markBox[1].x, markBox[1].y, markBox[1].w, markBox[1].h, (marks & favoriteMarks::HEART ? + SIDEBAR_UNSELECTED_COLOR : BOX_INSIDE_COLOR)); - GFX::drawBox(markBox[5].x, markBox[5].y, markBox[5].w, markBox[5].h, false); + Gui::Draw_Rect(markBox[2].x, markBox[2].y, markBox[2].w, markBox[2].h, (marks & favoriteMarks::DIAMOND ? + SIDEBAR_UNSELECTED_COLOR : BOX_INSIDE_COLOR)); + + Gui::Draw_Rect(markBox[3].x, markBox[3].y, markBox[3].w, markBox[3].h, (marks & favoriteMarks::CLUBS ? + SIDEBAR_UNSELECTED_COLOR : BOX_INSIDE_COLOR)); + + Gui::Draw_Rect(markBox[4].x, markBox[4].y, markBox[4].w, markBox[4].h, (marks & favoriteMarks::SPADE ? + SIDEBAR_UNSELECTED_COLOR : BOX_INSIDE_COLOR)); + + Gui::DrawString(markBox[0].x + 15, markBox[0].y + 11, 0.9, TEXT_COLOR, "★"); + Gui::DrawString(markBox[1].x + 15, markBox[1].y + 11, 0.9, TEXT_COLOR, "♥"); + Gui::DrawString(markBox[2].x + 15, markBox[2].y + 11, 0.9, TEXT_COLOR, "♦"); + Gui::DrawString(markBox[3].x + 15, markBox[3].y + 11, 0.9, TEXT_COLOR, "♣"); + Gui::DrawString(markBox[4].x + 15, markBox[4].y + 11, 0.9, TEXT_COLOR, "♠"); + + GFX::DrawBox(markBox[5].x, markBox[5].y, markBox[5].w, markBox[5].h, false); Gui::DrawString(markBox[5].x + 3, markBox[5].y, 0.6f, TEXT_COLOR, "★"); } diff --git a/source/store/searchMenu.cpp b/source/store/searchMenu.cpp index 6db994d..6ea8001 100644 --- a/source/store/searchMenu.cpp +++ b/source/store/searchMenu.cpp @@ -75,21 +75,32 @@ void StoreUtils::DrawSearchMenu(const std::vector &searchIncludes, const s Gui::DrawString(SearchMenu[4].x + 18, SearchMenu[4].y + 1, 0.4, TEXT_COLOR, Lang::get("CONSOLE"), 90); /* Filters. */ - Gui::DrawString(84, 150, 0.5, TEXT_COLOR, Lang::get("FILTER_TO"), 265); + Gui::DrawString(84, 150, 0.5f, TEXT_COLOR, Lang::get("FILTER_TO"), 265); - GFX::drawBox(SearchMenu[5].x, SearchMenu[5].y, SearchMenu[5].w, SearchMenu[5].h, marks & favoriteMarks::STAR); - GFX::drawBox(SearchMenu[6].x, SearchMenu[6].y, SearchMenu[6].w, SearchMenu[6].h, marks & favoriteMarks::HEART); - GFX::drawBox(SearchMenu[7].x, SearchMenu[7].y, SearchMenu[7].w, SearchMenu[7].h, marks & favoriteMarks::DIAMOND); - GFX::drawBox(SearchMenu[8].x, SearchMenu[8].y, SearchMenu[8].w, SearchMenu[8].h, marks & favoriteMarks::CLUBS); - GFX::drawBox(SearchMenu[9].x, SearchMenu[9].y, SearchMenu[9].w, SearchMenu[9].h, marks & favoriteMarks::SPADE); - GFX::drawBox(SearchMenu[10].x, SearchMenu[10].y, SearchMenu[10].w, SearchMenu[10].h, updateFilter); + Gui::Draw_Rect(SearchMenu[5].x, SearchMenu[5].y, SearchMenu[5].w, SearchMenu[5].h, (marks & favoriteMarks::STAR ? + SIDEBAR_UNSELECTED_COLOR : BOX_INSIDE_COLOR)); + + Gui::Draw_Rect(SearchMenu[6].x, SearchMenu[6].y, SearchMenu[6].w, SearchMenu[6].h, (marks & favoriteMarks::HEART ? + SIDEBAR_UNSELECTED_COLOR : BOX_INSIDE_COLOR)); + + Gui::Draw_Rect(SearchMenu[7].x, SearchMenu[7].y, SearchMenu[7].w, SearchMenu[7].h, (marks & favoriteMarks::DIAMOND ? + SIDEBAR_UNSELECTED_COLOR : BOX_INSIDE_COLOR)); + + Gui::Draw_Rect(SearchMenu[8].x, SearchMenu[8].y, SearchMenu[8].w, SearchMenu[8].h, (marks & favoriteMarks::CLUBS ? + SIDEBAR_UNSELECTED_COLOR : BOX_INSIDE_COLOR)); + + Gui::Draw_Rect(SearchMenu[9].x, SearchMenu[9].y, SearchMenu[9].w, SearchMenu[9].h, (marks & favoriteMarks::SPADE ? + SIDEBAR_UNSELECTED_COLOR : BOX_INSIDE_COLOR)); + + Gui::Draw_Rect(SearchMenu[10].x, SearchMenu[10].y, SearchMenu[10].w, SearchMenu[10].h, (updateFilter ? + SIDEBAR_UNSELECTED_COLOR : BOX_INSIDE_COLOR)); + + Gui::DrawString(SearchMenu[5].x + 9, SearchMenu[5].y + 7, 0.5f, TEXT_COLOR, "★"); + Gui::DrawString(SearchMenu[6].x + 9, SearchMenu[6].y + 7, 0.5f, TEXT_COLOR, "♥"); + Gui::DrawString(SearchMenu[7].x + 9, SearchMenu[7].y + 7, 0.5f, TEXT_COLOR, "♦"); + Gui::DrawString(SearchMenu[8].x + 9, SearchMenu[8].y + 7, 0.5f, TEXT_COLOR, "♣"); + Gui::DrawString(SearchMenu[9].x + 9, SearchMenu[9].y + 7, 0.5f, TEXT_COLOR, "♠"); GFX::DrawSprite(sprites_update_filter_idx, SearchMenu[10].x + 8, SearchMenu[10].y + 8); - - Gui::DrawString(SearchMenu[5].x + 8, SearchMenu[5].y + 8, 0.5, TEXT_COLOR, "★"); - Gui::DrawString(SearchMenu[6].x + 8, SearchMenu[6].y + 8, 0.5, TEXT_COLOR, "♥"); - Gui::DrawString(SearchMenu[7].x + 8, SearchMenu[7].y + 8, 0.5, TEXT_COLOR, "♦"); - Gui::DrawString(SearchMenu[8].x + 8, SearchMenu[8].y + 8, 0.5, TEXT_COLOR, "♣"); - Gui::DrawString(SearchMenu[9].x + 8, SearchMenu[9].y + 8, 0.5, TEXT_COLOR, "♠"); } /* diff --git a/source/store/settings.cpp b/source/store/settings.cpp index 505fac8..fa1a338 100644 --- a/source/store/settings.cpp +++ b/source/store/settings.cpp @@ -39,10 +39,14 @@ static const std::vector mainButtons = { { 54, 184, 262, 22 } }; -static const std::string autoupdate() { return (config->autoupdate() ? "DISABLE_AUTOUPDATE_UNISTORE" : "ENABLE_AUTOUPDATE_UNISTORE"); }; -static const std::string updateCheck() { return (config->updatecheck() ? "DISABLE_UPDATE_CHECK" : "ENABLE_UPDATE_CHECK"); }; +static const std::vector toggleAbles = { + { 52, 6, 24, 24 }, // Back arrow. + { 288, 64, 24, 24 }, + { 288, 140, 24, 24 } +}; -static const std::vector mainStrings = { "LANGUAGE", "SELECT_UNISTORE", "CHANGE_DIRECTORIES", "CREDITS", "EXIT_APP" }; + +static const std::vector mainStrings = { "LANGUAGE", "SELECT_UNISTORE", "AUTO_UPDATE_SETTINGS_BTN", "CHANGE_DIRECTORIES", "CREDITS", "EXIT_APP" }; static const std::vector dirStrings = { "CHANGE_3DSX_PATH", "CHANGE_NDS_PATH", "CHANGE_ARCHIVE_PATH" }; /* @@ -51,17 +55,10 @@ static const std::vector dirStrings = { "CHANGE_3DSX_PATH", "CHANGE const int &selection: Const Reference to the Settings Selection. */ static void DrawSettingsMain(const int &selection) { - for (int i = 0; i < 7; i++) { - GFX::drawBox(mainButtons[i].x, mainButtons[i].y, mainButtons[i].w, mainButtons[i].h, i == selection); + for (int i = 0; i < 6; i++) { + if (i == selection) GFX::DrawBox(mainButtons[i].x, mainButtons[i].y, mainButtons[i].w, mainButtons[i].h, false); + Gui::DrawStringCentered(30, mainButtons[i].y + 4, 0.45f, TEXT_COLOR, Lang::get(mainStrings[i]), 255); } - - Gui::DrawStringCentered(54 - 160 + (262 / 2), mainButtons[0].y + 4, 0.45f, TEXT_COLOR, Lang::get(mainStrings[0]), 255); - Gui::DrawStringCentered(54 - 160 + (262 / 2), mainButtons[1].y + 4, 0.45f, TEXT_COLOR, Lang::get(mainStrings[1]), 255); - Gui::DrawStringCentered(54 - 160 + (262 / 2), mainButtons[2].y + 4, 0.45f, TEXT_COLOR, Lang::get(autoupdate()), 255); - Gui::DrawStringCentered(54 - 160 + (262 / 2), mainButtons[3].y + 4, 0.45f, TEXT_COLOR, Lang::get(updateCheck()), 255); - Gui::DrawStringCentered(54 - 160 + (262 / 2), mainButtons[4].y + 4, 0.45f, TEXT_COLOR, Lang::get(mainStrings[2]), 255); - Gui::DrawStringCentered(54 - 160 + (262 / 2), mainButtons[5].y + 4, 0.45f, TEXT_COLOR, Lang::get(mainStrings[3]), 255); - Gui::DrawStringCentered(54 - 160 + (262 / 2), mainButtons[6].y + 4, 0.45f, TEXT_COLOR, Lang::get(mainStrings[4]), 255); } /* @@ -71,10 +68,34 @@ static void DrawSettingsMain(const int &selection) { */ static void DrawSettingsDir(const int &selection) { for (int i = 0; i < 3; i++) { - GFX::DrawButton(mainButtons[i].x, mainButtons[i].y, mainButtons[i].w, mainButtons[i].h, i == selection, Lang::get(dirStrings[i])); + if (i == selection) GFX::DrawBox(mainButtons[i].x, mainButtons[i].y, mainButtons[i].w, mainButtons[i].h, false); + Gui::DrawStringCentered(30, mainButtons[i].y + 4, 0.45f, TEXT_COLOR, Lang::get(dirStrings[i]), 255); } } +/* + Draw Auto-Update Settings page. +*/ +static void DrawAutoUpdate() { + Gui::Draw_Rect(48, 0, 272, 36, ENTRY_BAR_COLOR); + Gui::Draw_Rect(48, 36, 272, 1, ENTRY_BAR_OUTL_COLOR); + GFX::DrawSprite(sprites_arrow_idx, 52, 6); + + Gui::DrawStringCentered(32, 7, 0.6, TEXT_COLOR, Lang::get("AUTO_UPDATE_SETTINGS"), 240); + + /* Toggle Boxes. */ + GFX::DrawBox(48, 64, 273, 24, false); + Gui::DrawString(55, 68, 0.5f, TEXT_COLOR, Lang::get("AUTO_UPDATE_UNISTORE"), 210); + GFX::DrawToggle(288, 64, config->autoupdate()); + Gui::DrawString(55, 95, 0.4f, TEXT_COLOR, Lang::get("AUTO_UPDATE_UNISTORE_DESC"), 265, 0, nullptr, C2D_WordWrap); + + GFX::DrawBox(48, 140, 273, 24, false); + Gui::DrawString(55, 144, 0.5f, TEXT_COLOR, Lang::get("AUTO_UPDATE_UU"), 210); + GFX::DrawToggle(288, 140, config->updatecheck()); + Gui::DrawString(55, 171, 0.4f, TEXT_COLOR, Lang::get("AUTO_UPDATE_UU_DESC"), 265, 0, nullptr, C2D_WordWrap); +} + + /* Settings Main Handle. Here you can.. @@ -103,18 +124,18 @@ static void SettingsHandleMain(u32 hDown, u32 hHeld, touchPosition touch, int &p } if (hRepeat & KEY_DOWN) { - if (selection < 6) selection++; + if (selection < 5) selection++; else selection = 0; } if (hRepeat & KEY_UP) { if (selection > 0) selection--; - else selection = mainStrings.size() + 1; + else selection = mainStrings.size() - 1; } if (hRepeat & KEY_RIGHT) { - if (selection + 8 < (int)mainStrings.size() + 1) selection += 8; - else selection = mainStrings.size() + 1; + if (selection + 8 < (int)mainStrings.size()) selection += 8; + else selection = mainStrings.size() - 1; } if (hRepeat & KEY_LEFT) { @@ -130,21 +151,18 @@ static void SettingsHandleMain(u32 hDown, u32 hHeld, touchPosition touch, int &p Overlays::SelectStore(store, entries, meta); } else if (touching(touch, mainButtons[2])) { - config->autoupdate(!config->autoupdate()); + selection = 0; + page = 2; } else if (touching(touch, mainButtons[3])) { - config->updatecheck(!config->updatecheck()); - - } else if (touching(touch, mainButtons[4])) { selection = 0; page = 1; - } else if (touching(touch, mainButtons[5])) { + } else if (touching(touch, mainButtons[4])) { Overlays::ShowCredits(); - } else if (touching(touch, mainButtons[6])) { + } else if (touching(touch, mainButtons[5])) { exiting = true; - } } @@ -159,23 +177,20 @@ static void SettingsHandleMain(u32 hDown, u32 hHeld, touchPosition touch, int &p break; case 2: - config->autoupdate(!config->autoupdate()); + selection = 0; + page = 2; break; case 3: - config->updatecheck(!config->updatecheck()); - break; - - case 4: selection = 0; page = 1; break; - case 5: + case 4: Overlays::ShowCredits(); break; - case 6: + case 5: exiting = true; break; } @@ -198,7 +213,7 @@ static void SettingsHandleMain(u32 hDown, u32 hHeld, touchPosition touch, int &p static void SettingsHandleDir(u32 hDown, u32 hHeld, touchPosition touch, int &page, int &selection) { if (hDown & KEY_B) { page = 0; - selection = 4; + selection = 3; } if (hRepeat & KEY_DOWN) { @@ -258,6 +273,26 @@ static void SettingsHandleDir(u32 hDown, u32 hHeld, touchPosition touch, int &pa } } +static void SettingsToggleLogic(u32 hDown, u32 hHeld, touchPosition touch, int &page, int &selection) { + if (hDown & KEY_B) { + page = 0; + selection = 2; + } + + if (hDown & KEY_TOUCH) { + if (touching(touch, toggleAbles[0])) { + page = 0; + selection = 2; + + } else if (touching(touch, toggleAbles[1])) { + config->autoupdate(!config->autoupdate()); + + } else if (touching(touch, toggleAbles[2])) { + config->updatecheck(!config->updatecheck()); + } + } +} + /* Draw the Settings. @@ -273,6 +308,10 @@ void StoreUtils::DrawSettings(const int &page, const int &selection) { case 1: DrawSettingsDir(selection); break; + + case 2: + DrawAutoUpdate(); + break; } } @@ -299,5 +338,9 @@ void StoreUtils::SettingsHandle(u32 hDown, u32 hHeld, touchPosition touch, int & case 1: SettingsHandleDir(hDown, hHeld, touch, page, selection); break; + + case 2: + SettingsToggleLogic(hDown, hHeld, touch, page, selection); + break; } } \ No newline at end of file diff --git a/source/utils/lang.cpp b/source/utils/lang.cpp index 41b0a7b..7e690d1 100644 --- a/source/utils/lang.cpp +++ b/source/utils/lang.cpp @@ -31,7 +31,7 @@ static nlohmann::json appJson; std::string Lang::get(const std::string &key) { - if (!appJson.contains(key)) return ""; + if (!appJson.contains(key)) return key; return appJson.at(key).get_ref(); }