From b6d1de03c12734fe8774d30ab064a08cdba51435 Mon Sep 17 00:00:00 2001 From: StackZ <47382115+SuperSaiyajinStackZ@users.noreply.github.com> Date: Tue, 3 Nov 2020 02:41:38 +0100 Subject: [PATCH] See desc for more. - Add `skip` function. - Fix dirSelect. - Move LangSelect to settings. - Add bars, to keep the U-U style. --- include/screens/mainScreen.hpp | 2 +- include/store/storeUtils.hpp | 4 +- source/overlays/dirSelect.cpp | 31 +++---- source/overlays/langSelect.cpp | 133 --------------------------- source/overlays/storeSelect.cpp | 150 +++++++++++++++--------------- source/screens/mainScreen.cpp | 4 +- source/store/settings.cpp | 156 ++++++++++++++++++++++++++++++-- source/utils/fileBrowse.cpp | 3 - source/utils/scriptUtils.cpp | 11 +++ 9 files changed, 254 insertions(+), 240 deletions(-) delete mode 100644 source/overlays/langSelect.cpp diff --git a/include/screens/mainScreen.hpp b/include/screens/mainScreen.hpp index 57880ad..cc88ed2 100644 --- a/include/screens/mainScreen.hpp +++ b/include/screens/mainScreen.hpp @@ -53,7 +53,7 @@ private: std::vector> entries; std::vector dwnldList; bool initialized = false, fetchDown = false, showMarks = false, showSettings = false, ascending = false, updateFilter = false; - int storeMode = 0, marks = 0, markIndex = 0, sPage = 0, lMode = 0, sSelection = 0, lastMode = 0, smallDelay = 0; + int storeMode = 0, marks = 0, markIndex = 0, sPage = 0, lMode = 0, sSelection = 0, lastMode = 0, smallDelay = 0, sPos = 0; SortType sorttype = SortType::LAST_UPDATED; /* Title, Author, Category, Console. */ diff --git a/include/store/storeUtils.hpp b/include/store/storeUtils.hpp index b9e48b0..cd2ef34 100644 --- a/include/store/storeUtils.hpp +++ b/include/store/storeUtils.hpp @@ -71,8 +71,8 @@ namespace StoreUtils { void DrawCredits(); /* Settings. */ - void DrawSettings(const int &page, const int &selection); - void SettingsHandle(u32 hDown, u32 hHeld, touchPosition touch, int &page, bool &dspSettings, int &storeMode, int &selection, std::unique_ptr &store, std::vector> &entries, std::unique_ptr &meta); + void DrawSettings(const int &page, const int &selection, const int &sPos); + void SettingsHandle(u32 hDown, u32 hHeld, touchPosition touch, int &page, bool &dspSettings, int &storeMode, int &selection, std::unique_ptr &store, std::vector> &entries, std::unique_ptr &meta, int &sPos); /* Sorting. */ void DrawSorting(const bool &asc, const SortType &st); diff --git a/source/overlays/dirSelect.cpp b/source/overlays/dirSelect.cpp index 378bd58..fb27742 100644 --- a/source/overlays/dirSelect.cpp +++ b/source/overlays/dirSelect.cpp @@ -44,31 +44,26 @@ static const std::vector mainButtons = { */ std::string Overlays::SelectDir(const std::string &oldDir, const std::string &msg, const std::unique_ptr &store) { std::string currentPath = oldDir; - bool dirChanged = true; + bool dirChanged = false; int selection = 0, sPos = 0; std::vector dirContents; + dirContents.clear(); - if (dirChanged) { - dirChanged = false; + /* Make sure. */ + if (access((oldDir + std::string("/")).c_str(), F_OK) == 0) { + chdir((oldDir + std::string("/")).c_str()); - dirContents.clear(); + } else { + currentPath = "sdmc:/"; + chdir("sdmc:/"); + } - /* Make sure. */ - if (access(oldDir.c_str(), F_OK) == 0) { - chdir(oldDir.c_str()); + std::vector dirContentsTemp; + getDirectoryContents(dirContentsTemp, {"/"}); - } else { - currentPath = "sdmc:/"; - chdir("sdmc:/"); - } - - std::vector dirContentsTemp; - getDirectoryContents(dirContentsTemp, {"/"}); - - for(uint i = 0; i < dirContentsTemp.size(); i++) { - dirContents.push_back(dirContentsTemp[i]); - } + for(uint i = 0; i < dirContentsTemp.size(); i++) { + dirContents.push_back(dirContentsTemp[i]); } while(1) { diff --git a/source/overlays/langSelect.cpp b/source/overlays/langSelect.cpp deleted file mode 100644 index d360f9d..0000000 --- a/source/overlays/langSelect.cpp +++ /dev/null @@ -1,133 +0,0 @@ -/* -* This file is part of Universal-Updater -* Copyright (C) 2019-2020 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 "fileBrowse.hpp" -#include "keyboard.hpp" -#include "overlay.hpp" -#include "scriptUtils.hpp" -#include "storeUtils.hpp" - -extern bool checkWifiStatus(); -extern bool touching(touchPosition touch, Structs::ButtonPos button); -static const std::vector languages = { "Bruh", "Dansk", "Deutsch", "English", "Español", "Français", "Italiano", "Lietuvių", "Magyar", "Polski", "Português", "Português (Brasil)", "Русский", "日本語" }; -static const std::string langsTemp[] = { "br", "da", "de", "en", "es", "fr", "it", "lt", "hu", "pl", "pt", "pt-BR", "ru", "jp"}; - -static const std::vector mainButtons = { - { 10, 4, 300, 22 }, - { 10, 34, 300, 22 }, - { 10, 64, 300, 22 }, - { 10, 94, 300, 22 }, - { 10, 124, 300, 22 }, - { 10, 154, 300, 22 }, - { 10, 184, 300, 22 }, - { 10, 214, 300, 22 } -}; - -/* - Select a Language. - - Can be skipped with `B`. -*/ -void Overlays::SelectLanguage(const std::unique_ptr &store) { - bool doOut = false; - int selection = 0, sPos = 0; - - while(!doOut) { - Gui::clearTextBufs(); - C3D_FrameBegin(C3D_FRAME_SYNCDRAW); - C2D_TargetClear(Top, TRANSPARENT); - C2D_TargetClear(Bottom, TRANSPARENT); - - if (store && config->usebg() && store->customBG()) { - Gui::ScreenDraw(Top); - Gui::Draw_Rect(0, 0, 400, 25, BAR_COLOR); - Gui::Draw_Rect(0, 25, 400, 1, BAR_OUTL_COLOR); - C2D_DrawImageAt(store->GetStoreImg(), 0, 26, 0.5f, nullptr); - - } else { - GFX::DrawTop(); - } - - Gui::DrawStringCentered(0, 1, 0.7f, TEXT_COLOR, Lang::get("SELECT_LANG")); - GFX::DrawBottom(); - - for(int i = 0; i < 8 && i < (int)languages.size(); i++) { - 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); - - hidScanInput(); - touchPosition touch; - hidTouchRead(&touch); - u32 hRepeat = hidKeysDownRepeat(); - - if (hRepeat & KEY_DOWN) { - if (selection < (int)languages.size() - 1) selection++; - else selection = 0; - } - - if (hRepeat & KEY_UP) { - if (selection > 0) selection--; - else selection = languages.size() - 1; - } - - if (hRepeat & KEY_RIGHT) { - if (selection + 8 < (int)languages.size()-1) selection += 8; - else selection = languages.size()-1; - } - - if (hRepeat & KEY_LEFT) { - if (selection - 8 > 0) selection -= 8; - else selection = 0; - } - - if (hidKeysDown() & KEY_A) { - const std::string l = langsTemp[selection]; - config->language(l); - Lang::load(config->language()); - doOut = true; - } - - if (hidKeysDown() & KEY_TOUCH) { - for (int i = 0; i < 8; i++) { - if (touching(touch, mainButtons[i])) { - if (i + sPos < (int)languages.size()) { - const std::string l = langsTemp[i + sPos]; - config->language(l); - Lang::load(config->language()); - doOut = true; - } - } - } - } - - if (selection < sPos) sPos = selection; - else if (selection > sPos + 8 - 1) sPos = selection - 8 + 1; - - if (hidKeysDown() & KEY_B) doOut = true; - } -} \ No newline at end of file diff --git a/source/overlays/storeSelect.cpp b/source/overlays/storeSelect.cpp index 34b7786..47f265f 100644 --- a/source/overlays/storeSelect.cpp +++ b/source/overlays/storeSelect.cpp @@ -37,7 +37,6 @@ extern bool checkWifiStatus(); extern bool touching(touchPosition touch, Structs::ButtonPos button); static const std::vector mainButtons = { - { 10, 4, 300, 22 }, { 10, 34, 300, 22 }, { 10, 64, 300, 22 }, { 10, 94, 300, 22 }, @@ -46,11 +45,11 @@ static const std::vector mainButtons = { { 10, 184, 300, 22 }, /* Add, Delete, Info.. */ - { 70, 215, 16, 16 }, - { 114, 215, 16, 16 }, - { 158, 215, 16, 16 }, - { 202, 215, 16, 16 }, - { 246, 215, 16, 16 } + { 92, 215, 16, 16 }, + { 136, 215, 16, 16 }, + { 180, 215, 16, 16 }, + { 224, 215, 16, 16 }, + { 4, 0, 24, 24 } // Back. }; /* @@ -152,54 +151,56 @@ static bool DownloadStore(bool Cam = true) { return doSheet; } -/* - Re-Download SpriteSheets optional. +static bool UpdateStore(const std::string &URL) { + bool doSheet = false; + std::string file = ""; - const std::string &file: Const Reference to the UniStore filename. -*/ -static bool DownloadSheet(const std::string &file) { - FILE *temp = fopen((std::string(_STORE_PATH) + file).c_str(), "rt"); - nlohmann::json storeJson = nlohmann::json::parse(temp, nullptr, false); - fclose(temp); + if (URL != "") doSheet = DownloadUniStore(URL, -1, file, false); - if (storeJson["storeInfo"].contains("sheetURL") && storeJson["storeInfo"]["sheetURL"].is_array()) { - if (storeJson["storeInfo"].contains("sheet") && storeJson["storeInfo"]["sheet"].is_array()) { - const std::vector locs = storeJson["storeInfo"]["sheetURL"].get>(); - const std::vector sht = storeJson["storeInfo"]["sheet"].get>(); + if (doSheet) { + FILE *temp = fopen(file.c_str(), "rt"); + nlohmann::json storeJson = nlohmann::json::parse(temp, nullptr, false); + fclose(temp); - if (locs.size() == sht.size()) { - for (int i = 0; i < (int)sht.size(); i++) { - if (!(sht[i].find("/") != std::string::npos)) { - char msg[150]; - snprintf(msg, sizeof(msg), Lang::get("DOWNLOADING_SPRITE_SHEET2").c_str(), i + 1, sht.size()); - Msg::DisplayMsg(msg); - DownloadSpriteSheet(locs[i], sht[i]); + if (doSheet) { + if (storeJson["storeInfo"].contains("sheetURL") && storeJson["storeInfo"]["sheetURL"].is_array()) { + if (storeJson["storeInfo"].contains("sheet") && storeJson["storeInfo"]["sheet"].is_array()) { + const std::vector locs = storeJson["storeInfo"]["sheetURL"].get>(); + const std::vector sht = storeJson["storeInfo"]["sheet"].get>(); - } else { - Msg::waitMsg(Lang::get("SHEET_SLASH")); - return false; + if (locs.size() == sht.size()) { + for (int i = 0; i < (int)sht.size(); i++) { + if (!(sht[i].find("/") != std::string::npos)) { + char msg[150]; + snprintf(msg, sizeof(msg), Lang::get("DOWNLOADING_SPRITE_SHEET2").c_str(), i + 1, sht.size()); + Msg::DisplayMsg(msg); + DownloadSpriteSheet(locs[i], sht[i]); + + } else { + Msg::waitMsg(Lang::get("SHEET_SLASH")); + } } } } - } - } else if (storeJson["storeInfo"].contains("sheetURL") && storeJson["storeInfo"]["sheetURL"].is_string()) { - if (storeJson["storeInfo"].contains("sheet") && storeJson["storeInfo"]["sheet"].is_string()) { - const std::string fl = storeJson["storeInfo"]["sheetURL"]; - const std::string fl2 = storeJson["storeInfo"]["sheet"]; + } else if (storeJson["storeInfo"].contains("sheetURL") && storeJson["storeInfo"]["sheetURL"].is_string()) { + if (storeJson["storeInfo"].contains("sheet") && storeJson["storeInfo"]["sheet"].is_string()) { + const std::string fl = storeJson["storeInfo"]["sheetURL"]; + const std::string fl2 = storeJson["storeInfo"]["sheet"]; - if (!(fl2.find("/") != std::string::npos)) { - Msg::DisplayMsg(Lang::get("DOWNLOADING_SPRITE_SHEET")); - DownloadSpriteSheet(fl, fl2); + if (!(fl2.find("/") != std::string::npos)) { + Msg::DisplayMsg(Lang::get("DOWNLOADING_SPRITE_SHEET")); + DownloadSpriteSheet(fl, fl2); - } else { - Msg::waitMsg(Lang::get("SHEET_SLASH")); - return false; + } else { + Msg::waitMsg(Lang::get("SHEET_SLASH")); + } + } } } } - return true; + return doSheet; } /* @@ -237,25 +238,24 @@ void Overlays::SelectStore(std::unique_ptr &store, std::vector 0) { if (info[selection].StoreSize != -1) { - Gui::DrawStringCentered(0, 30, 0.6f, TEXT_COLOR, info[selection].Title, 380); - Gui::DrawStringCentered(0, 60, 0.5f, TEXT_COLOR, info[selection].Author, 380); + Gui::DrawStringCentered(0, 30, 0.6f, TEXT_COLOR, info[selection].Author, 380); if (info[selection].Description != "") { /* "\n\n" breaks C2D_WordWrap, so check here. */ if (!(info[selection].Description.find("\n\n") != std::string::npos)) { - Gui::DrawStringCentered(0, 100, 0.5f, TEXT_COLOR, info[selection].Description, 380, 95, nullptr, C2D_WordWrap); + Gui::DrawStringCentered(0, 70, 0.5f, TEXT_COLOR, info[selection].Description, 380, 130, nullptr, C2D_WordWrap); } else { - Gui::DrawStringCentered(0, 100, 0.5f, TEXT_COLOR, info[selection].Description, 380, 95); + Gui::DrawStringCentered(0, 70, 0.5f, TEXT_COLOR, info[selection].Description, 380, 130); } } } else { - Gui::DrawStringCentered(0, 30, 0.6f, TEXT_COLOR, Lang::get("INVALID_UNISTORE"), 380); + Gui::DrawStringCentered(0, 1, 0.7f, TEXT_COLOR, Lang::get("INVALID_UNISTORE"), 390); } Gui::DrawString(10, 200, 0.4, TEXT_COLOR, "- " + Lang::get("ENTRIES") + ": " + std::to_string(info[selection].StoreSize), 150); @@ -264,7 +264,12 @@ void Overlays::SelectStore(std::unique_ptr &store, std::vector &store, std::vector &store, std::vector 0) selection -= 8; + if (selection - 6 > 0) selection -= 6; else selection = 0; } @@ -328,7 +332,7 @@ void Overlays::SelectStore(std::unique_ptr &store, std::vector &store, std::vector &store, std::vector 0) { - const bool result = IsUpdateAvailable(info[selection].URL, info[selection].Revision); - Msg::waitMsg((result ? Lang::get("UPDATE_AVAILABLE") : Lang::get("UPDATE_NOT_AVAILABLE"))); - } - } - } - - /* SpriteSheet Download. */ - if (hidKeysDown() & KEY_TOUCH && touching(touch, mainButtons[9])) { - if (checkWifiStatus()) { - if (info[selection].FileName != "") { - DownloadSheet(info[selection].FileName); + if (info[selection].URL != "") { + if (UpdateStore(info[selection].URL)) { + selection = 0; + info = GetUniStoreInfo(_STORE_PATH); + } } } } if (selection < sPos) sPos = selection; - else if (selection > sPos + 7 - 1) sPos = selection - 7 + 1; + else if (selection > sPos + 6 - 1) sPos = selection - 6 + 1; } /* UniStore URL Download. */ - if ((hidKeysDown() & KEY_Y) || (hidKeysDown() & KEY_TOUCH && touching(touch, mainButtons[10]))) { + if ((hidKeysDown() & KEY_Y) || (hidKeysDown() & KEY_TOUCH && touching(touch, mainButtons[8]))) { if (checkWifiStatus()) { if (DownloadStore(false)) { selection = 0; @@ -393,7 +390,7 @@ void Overlays::SelectStore(std::unique_ptr &store, std::vector &store, std::vectorsPage, this->sSelection); + StoreUtils::DrawSettings(this->sPage, this->sSelection, this->sPos); break; } @@ -174,7 +174,7 @@ void MainScreen::Logic(u32 hDown, u32 hHeld, touchPosition touch) { break; case 4: - StoreUtils::SettingsHandle(hDown, hHeld, touch, this->sPage, this->showSettings, this->storeMode, this->sSelection, this->store, this->entries, this->meta); + StoreUtils::SettingsHandle(hDown, hHeld, touch, this->sPage, this->showSettings, this->storeMode, this->sSelection, this->store, this->entries, this->meta, this->sPos); break; } } diff --git a/source/store/settings.cpp b/source/store/settings.cpp index 21ada80..f309e20 100644 --- a/source/store/settings.cpp +++ b/source/store/settings.cpp @@ -39,6 +39,18 @@ static const std::vector mainButtons = { { 54, 212, 262, 22 } }; +static const std::vector langButtons = { + { 10, 34, 300, 22 }, + { 10, 64, 300, 22 }, + { 10, 94, 300, 22 }, + { 10, 124, 300, 22 }, + { 10, 154, 300, 22 }, + { 10, 184, 300, 22 }, + { 10, 214, 300, 22 }, + + { 52, 6, 24, 24 } // Back arrow. +}; + static const std::vector toggleAbles = { { 52, 6, 24, 24 }, // Back arrow. { 288, 64, 24, 24 }, @@ -51,6 +63,9 @@ static const Structs::ButtonPos back = { 52, 0, 24, 24 }; // Back arrow for dire 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", "CHANGE_NDS_PATH", "CHANGE_ARCHIVE_PATH" }; +static const std::vector languages = { "Bruh", "Dansk", "Deutsch", "English", "Español", "Français", "Italiano", "Lietuvių", "Magyar", "Polski", "Português", "Português (Brasil)", "Русский", "日本語" }; +static const std::string langsTemp[] = { "br", "da", "de", "en", "es", "fr", "it", "lt", "hu", "pl", "pt", "pt-BR", "ru", "jp"}; + /* Main Settings. @@ -67,6 +82,24 @@ static void DrawSettingsMain(const int &selection) { } } +/* + Draw the Language Selection. + + const int &selection: Const Reference to the Language Selection. + const int &sPos: Const Reference to the Screen Position. +*/ +static void DrawLanguageSettings(const int &selection, const int &sPos) { + Gui::Draw_Rect(48, 0, 272, 25, ENTRY_BAR_COLOR); + Gui::Draw_Rect(48, 25, 272, 1, ENTRY_BAR_OUTL_COLOR); + GFX::DrawSprite(sprites_arrow_idx, back.x, back.y); + Gui::DrawStringCentered(32, 2, 0.6, TEXT_COLOR, Lang::get("SELECT_LANG"), 240); + + for(int i = 0; i < 7 && i < (int)languages.size(); i++) { + if (sPos + 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, languages[sPos + i], 280); + } +} + /* Directory Change Draw. @@ -106,6 +139,11 @@ static void DrawAutoUpdate(const int &selection) { Gui::DrawString(55, 171, 0.4f, TEXT_COLOR, Lang::get("AUTO_UPDATE_UU_DESC"), 265, 0, nullptr, C2D_WordWrap); } +/* + Draw the GUI Settings. + + const int &selection: Const Reference to the Settings Selection. +*/ static void DrawGUISettings(const int &selection) { Gui::Draw_Rect(48, 0, 272, 36, ENTRY_BAR_COLOR); Gui::Draw_Rect(48, 36, 272, 1, ENTRY_BAR_OUTL_COLOR); @@ -169,7 +207,8 @@ static void SettingsHandleMain(u32 hDown, u32 hHeld, touchPosition touch, int &p if (hDown & KEY_TOUCH) { if (touching(touch, mainButtons[0])) { - Overlays::SelectLanguage(store); + selection = 0; + page = 4; } else if (touching(touch, mainButtons[1])) { Overlays::SelectStore(store, entries, meta); @@ -197,7 +236,8 @@ static void SettingsHandleMain(u32 hDown, u32 hHeld, touchPosition touch, int &p if (hDown & KEY_A) { switch(selection) { case 0: - Overlays::SelectLanguage(store); + selection = 0; + page = 4; break; case 1: @@ -310,6 +350,20 @@ static void SettingsHandleDir(u32 hDown, u32 hHeld, touchPosition touch, int &pa } } +/* + Logic of the Auto-Update Settings. + + Here you can.. + + - Enable / Disable Automatically updating the UniStore on boot. + - Enable / Disable Automatically check for Universal-Updater updates on boot. + + u32 hDown: The hidKeysDown() variable. + u32 hHeld: The hidKeysHeld() variable. + touchPosition touch: The TouchPosition variable. + int &page: Reference to the page. + int &selection: Reference to the Selection. +*/ static void AutoUpdateLogic(u32 hDown, u32 hHeld, touchPosition touch, int &page, int &selection) { if (hDown & KEY_B) { page = 0; @@ -350,7 +404,20 @@ static void AutoUpdateLogic(u32 hDown, u32 hHeld, touchPosition touch, int &page } } -static void GUISettingsLogic(u32 hDown, u32 hHeld, touchPosition touch, int &page, int &selection, const std::unique_ptr &store) { +/* + Logic of the GUI Settings. + + Here you can.. + + - Enable / Disable using the SpriteSheet Background Image, if exist. + + u32 hDown: The hidKeysDown() variable. + u32 hHeld: The hidKeysHeld() variable. + touchPosition touch: The TouchPosition variable. + int &page: Reference to the page. + int &selection: Reference to the Selection. +*/ +static void GUISettingsLogic(u32 hDown, u32 hHeld, touchPosition touch, int &page, int &selection) { if (hDown & KEY_B) { page = 0; selection = 3; @@ -375,13 +442,82 @@ static void GUISettingsLogic(u32 hDown, u32 hHeld, touchPosition touch, int &pag } } +/* + Logic of the Language Settings. + + Here you can.. + + - Select the language, which should be used with the app. + + u32 hDown: The hidKeysDown() variable. + u32 hHeld: The hidKeysHeld() variable. + touchPosition touch: The TouchPosition variable. + int &page: Reference to the page. + int &selection: Reference to the Selection. + int &sPos: Reference to the ScreenPos variable. +*/ +static void LanguageLogic(u32 hDown, u32 hHeld, touchPosition touch, int &page, int &selection, int &sPos) { + if (hRepeat & KEY_DOWN) { + if (selection < (int)languages.size() - 1) selection++; + else selection = 0; + } + + if (hRepeat & KEY_UP) { + if (selection > 0) selection--; + else selection = languages.size() - 1; + } + + if (hRepeat & KEY_RIGHT) { + if (selection + 7 < (int)languages.size()-1) selection += 7; + else selection = languages.size()-1; + } + + if (hRepeat & KEY_LEFT) { + if (selection - 7 > 0) selection -= 7; + else selection = 0; + } + + if ((hDown & KEY_B) || (hDown & KEY_TOUCH && touching(touch, langButtons[7]))) { + selection = 0; + sPos = 0; + page = 0; + } + + if (hDown & KEY_A) { + const std::string l = langsTemp[selection]; + config->language(l); + Lang::load(config->language()); + selection = 0; + sPos = 0; + page = 0; + } + + if (hDown & KEY_TOUCH) { + for (int i = 0; i < 7; i++) { + if (touching(touch, mainButtons[i])) { + if (i + sPos < (int)languages.size()) { + const std::string l = langsTemp[i + sPos]; + config->language(l); + Lang::load(config->language()); + selection = 0; + sPos = 0; + page = 0; + } + } + } + } + + if (selection < sPos) sPos = selection; + else if (selection > sPos + 7 - 1) sPos = selection - 7 + 1; +} + /* Draw the Settings. const int &page: Const Reference to the page. const int &selection: Const Reference to the selection. */ -void StoreUtils::DrawSettings(const int &page, const int &selection) { +void StoreUtils::DrawSettings(const int &page, const int &selection, const int &sPos) { switch(page) { case 0: DrawSettingsMain(selection); @@ -398,6 +534,10 @@ void StoreUtils::DrawSettings(const int &page, const int &selection) { case 3: DrawGUISettings(selection); break; + + case 4: + DrawLanguageSettings(selection, sPos); + break; } } @@ -415,7 +555,7 @@ void StoreUtils::DrawSettings(const int &page, const int &selection) { std::vector> &entries: Reference to the StoreEntries. std::unique_ptr &meta: Reference to the Meta class. */ -void StoreUtils::SettingsHandle(u32 hDown, u32 hHeld, touchPosition touch, int &page, bool &dspSettings, int &storeMode, int &selection, std::unique_ptr &store, std::vector> &entries, std::unique_ptr &meta) { +void StoreUtils::SettingsHandle(u32 hDown, u32 hHeld, touchPosition touch, int &page, bool &dspSettings, int &storeMode, int &selection, std::unique_ptr &store, std::vector> &entries, std::unique_ptr &meta, int &sPos) { switch(page) { case 0: SettingsHandleMain(hDown, hHeld, touch, page, dspSettings, storeMode, selection, store, entries, meta); @@ -430,7 +570,11 @@ void StoreUtils::SettingsHandle(u32 hDown, u32 hHeld, touchPosition touch, int & break; case 3: - GUISettingsLogic(hDown, hHeld, touch, page, selection, store); + GUISettingsLogic(hDown, hHeld, touch, page, selection); + break; + + case 4: + LanguageLogic(hDown, hHeld, touch, page, selection, sPos); break; } } \ No newline at end of file diff --git a/source/utils/fileBrowse.cpp b/source/utils/fileBrowse.cpp index 2d6dc52..6485b57 100644 --- a/source/utils/fileBrowse.cpp +++ b/source/utils/fileBrowse.cpp @@ -32,9 +32,6 @@ #include #include -extern bool touching(touchPosition touch, Structs::ButtonPos button); -extern touchPosition touch; - bool nameEndsWith(const std::string &name, const std::vector &extensionList) { if (name.substr(0, 2) == "._") return false; diff --git a/source/utils/scriptUtils.cpp b/source/utils/scriptUtils.cpp index e8fb61b..23f21c6 100644 --- a/source/utils/scriptUtils.cpp +++ b/source/utils/scriptUtils.cpp @@ -494,6 +494,17 @@ Result ScriptUtils::runFunctions(const nlohmann::json &storeJson, const int &sel if (!missing) ret = ScriptUtils::renameFile(oldFile, newFile, Message); else ret = SYNTAX_ERROR; + + } else if (type == "skip") { + int skipCount = -1; + + if (storeJson["storeContent"][selection][entry][i].contains("count") && storeJson["storeContent"][selection][entry][i]["count"].is_number()) { + skipCount = storeJson["storeContent"][selection][entry][i]["count"]; + } + + if (skipCount > 0) { + i += skipCount; // Skip. + } } } }