mirror of
https://github.com/DarkStore-3DS/DarkStore.git
synced 2026-07-03 00:39:02 +00:00
See desc for more.
- Add `skip` function. - Fix dirSelect. - Move LangSelect to settings. - Add bars, to keep the U-U style.
This commit is contained in:
@@ -53,7 +53,7 @@ private:
|
||||
std::vector<std::unique_ptr<StoreEntry>> entries;
|
||||
std::vector<std::string> 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. */
|
||||
|
||||
@@ -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> &store, std::vector<std::unique_ptr<StoreEntry>> &entries, std::unique_ptr<Meta> &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> &store, std::vector<std::unique_ptr<StoreEntry>> &entries, std::unique_ptr<Meta> &meta, int &sPos);
|
||||
|
||||
/* Sorting. */
|
||||
void DrawSorting(const bool &asc, const SortType &st);
|
||||
|
||||
@@ -44,19 +44,15 @@ static const std::vector<Structs::ButtonPos> mainButtons = {
|
||||
*/
|
||||
std::string Overlays::SelectDir(const std::string &oldDir, const std::string &msg, const std::unique_ptr<Store> &store) {
|
||||
std::string currentPath = oldDir;
|
||||
bool dirChanged = true;
|
||||
bool dirChanged = false;
|
||||
int selection = 0, sPos = 0;
|
||||
|
||||
std::vector<DirEntry> dirContents;
|
||||
|
||||
if (dirChanged) {
|
||||
dirChanged = false;
|
||||
|
||||
dirContents.clear();
|
||||
|
||||
/* Make sure. */
|
||||
if (access(oldDir.c_str(), F_OK) == 0) {
|
||||
chdir(oldDir.c_str());
|
||||
if (access((oldDir + std::string("/")).c_str(), F_OK) == 0) {
|
||||
chdir((oldDir + std::string("/")).c_str());
|
||||
|
||||
} else {
|
||||
currentPath = "sdmc:/";
|
||||
@@ -69,7 +65,6 @@ std::string Overlays::SelectDir(const std::string &oldDir, const std::string &ms
|
||||
for(uint i = 0; i < dirContentsTemp.size(); i++) {
|
||||
dirContents.push_back(dirContentsTemp[i]);
|
||||
}
|
||||
}
|
||||
|
||||
while(1) {
|
||||
Gui::clearTextBufs();
|
||||
|
||||
@@ -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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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<std::string> 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<Structs::ButtonPos> 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> &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;
|
||||
}
|
||||
}
|
||||
@@ -37,7 +37,6 @@
|
||||
extern bool checkWifiStatus();
|
||||
extern bool touching(touchPosition touch, Structs::ButtonPos button);
|
||||
static const std::vector<Structs::ButtonPos> 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<Structs::ButtonPos> 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,16 +151,18 @@ 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");
|
||||
if (URL != "") doSheet = DownloadUniStore(URL, -1, file, false);
|
||||
|
||||
if (doSheet) {
|
||||
FILE *temp = fopen(file.c_str(), "rt");
|
||||
nlohmann::json storeJson = nlohmann::json::parse(temp, nullptr, false);
|
||||
fclose(temp);
|
||||
|
||||
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<std::string> locs = storeJson["storeInfo"]["sheetURL"].get<std::vector<std::string>>();
|
||||
@@ -177,7 +178,6 @@ static bool DownloadSheet(const std::string &file) {
|
||||
|
||||
} else {
|
||||
Msg::waitMsg(Lang::get("SHEET_SLASH"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -194,12 +194,13 @@ static bool DownloadSheet(const std::string &file) {
|
||||
|
||||
} else {
|
||||
Msg::waitMsg(Lang::get("SHEET_SLASH"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return doSheet;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -237,25 +238,24 @@ void Overlays::SelectStore(std::unique_ptr<Store> &store, std::vector<std::uniqu
|
||||
GFX::DrawTop();
|
||||
}
|
||||
|
||||
Gui::DrawStringCentered(0, 1, 0.7f, TEXT_COLOR, Lang::get("SELECT_UNISTORE_2"), 390);
|
||||
Gui::DrawStringCentered(0, 1, 0.7f, TEXT_COLOR, info[selection].Title, 390);
|
||||
|
||||
if (info.size() > 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> &store, std::vector<std::uniqu
|
||||
|
||||
GFX::DrawBottom();
|
||||
|
||||
for(int i = 0; i < 7 && i < (int)info.size(); i++) {
|
||||
Gui::Draw_Rect(0, 0, 320, 25, ENTRY_BAR_COLOR);
|
||||
Gui::Draw_Rect(0, 25, 320, 1, ENTRY_BAR_OUTL_COLOR);
|
||||
GFX::DrawSprite(sprites_arrow_idx, mainButtons[10].x, mainButtons[10].y);
|
||||
Gui::DrawStringCentered(0, 2, 0.6, TEXT_COLOR, Lang::get("SELECT_UNISTORE_2"), 310);
|
||||
|
||||
for(int i = 0; i < 6 && i < (int)info.size(); i++) {
|
||||
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, info[sPos + i].FileName, 295);
|
||||
@@ -273,11 +278,10 @@ void Overlays::SelectStore(std::unique_ptr<Store> &store, std::vector<std::uniqu
|
||||
|
||||
if (info.size() <= 0) GFX::DrawBottom(); // Otherwise we'd draw on top.
|
||||
|
||||
GFX::DrawSprite(sprites_delete_idx, mainButtons[7].x, mainButtons[7].y);
|
||||
GFX::DrawSprite(sprites_update_idx, mainButtons[8].x, mainButtons[8].y);
|
||||
GFX::DrawSprite(sprites_sheet_idx, mainButtons[9].x, mainButtons[9].y);
|
||||
GFX::DrawSprite(sprites_add_idx, mainButtons[10].x, mainButtons[10].y);
|
||||
GFX::DrawSprite(sprites_qr_code_idx, mainButtons[11].x, mainButtons[11].y);
|
||||
GFX::DrawSprite(sprites_delete_idx, mainButtons[6].x, mainButtons[6].y);
|
||||
GFX::DrawSprite(sprites_update_idx, mainButtons[7].x, mainButtons[7].y);
|
||||
GFX::DrawSprite(sprites_add_idx, mainButtons[8].x, mainButtons[8].y);
|
||||
GFX::DrawSprite(sprites_qr_code_idx, mainButtons[9].x, mainButtons[9].y);
|
||||
C3D_FrameEnd(0);
|
||||
|
||||
hidScanInput();
|
||||
@@ -297,12 +301,12 @@ void Overlays::SelectStore(std::unique_ptr<Store> &store, std::vector<std::uniqu
|
||||
}
|
||||
|
||||
if (hRepeat & KEY_RIGHT) {
|
||||
if (selection + 7 < (int)info.size()-1) selection += 7;
|
||||
else selection = info.size()-1;
|
||||
if (selection + 6 < (int)info.size() - 1) selection += 6;
|
||||
else selection = info.size() - 1;
|
||||
}
|
||||
|
||||
if (hRepeat & KEY_LEFT) {
|
||||
if (selection - 7 > 0) selection -= 8;
|
||||
if (selection - 6 > 0) selection -= 6;
|
||||
else selection = 0;
|
||||
}
|
||||
|
||||
@@ -328,7 +332,7 @@ void Overlays::SelectStore(std::unique_ptr<Store> &store, std::vector<std::uniqu
|
||||
}
|
||||
|
||||
if (hidKeysDown() & KEY_TOUCH) {
|
||||
for (int i = 0; i < 7; i++) {
|
||||
for (int i = 0; i < 6; i++) {
|
||||
if (touching(touch, mainButtons[i])) {
|
||||
if (i + sPos < (int)info.size() && info[i + sPos].File != "") { // Ensure to check for this.
|
||||
if (!(info[i + sPos].File.find("/") != std::string::npos)) {
|
||||
@@ -351,7 +355,7 @@ void Overlays::SelectStore(std::unique_ptr<Store> &store, std::vector<std::uniqu
|
||||
}
|
||||
|
||||
/* Delete UniStore. */
|
||||
if (hidKeysDown() & KEY_TOUCH && touching(touch, mainButtons[7])) {
|
||||
if ((hidKeysDown() & KEY_X) || (hidKeysDown() & KEY_TOUCH && touching(touch, mainButtons[6]))) {
|
||||
if (info[selection].FileName != "") {
|
||||
DeleteStore(info[selection].FileName);
|
||||
selection = 0;
|
||||
@@ -359,31 +363,24 @@ void Overlays::SelectStore(std::unique_ptr<Store> &store, std::vector<std::uniqu
|
||||
}
|
||||
}
|
||||
|
||||
/* Update checks. */
|
||||
if (hidKeysDown() & KEY_TOUCH && touching(touch, mainButtons[8])) {
|
||||
/* Download latest UniStore. */
|
||||
if ((hidKeysDown() & KEY_START) || (hidKeysDown() & KEY_TOUCH && touching(touch, mainButtons[7]))) {
|
||||
if (checkWifiStatus()) {
|
||||
if (info[selection].Revision > 0) {
|
||||
const bool result = IsUpdateAvailable(info[selection].URL, info[selection].Revision);
|
||||
Msg::waitMsg((result ? Lang::get("UPDATE_AVAILABLE") : Lang::get("UPDATE_NOT_AVAILABLE")));
|
||||
if (info[selection].URL != "") {
|
||||
if (UpdateStore(info[selection].URL)) {
|
||||
selection = 0;
|
||||
info = GetUniStoreInfo(_STORE_PATH);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* SpriteSheet Download. */
|
||||
if (hidKeysDown() & KEY_TOUCH && touching(touch, mainButtons[9])) {
|
||||
if (checkWifiStatus()) {
|
||||
if (info[selection].FileName != "") {
|
||||
DownloadSheet(info[selection].FileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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> &store, std::vector<std::uniqu
|
||||
}
|
||||
|
||||
/* UniStore QR Code Download. */
|
||||
if (hidKeysDown() & KEY_TOUCH && touching(touch, mainButtons[11])) {
|
||||
if ((hidKeysDown() & KEY_SELECT) || (hidKeysDown() & KEY_TOUCH && touching(touch, mainButtons[9]))) {
|
||||
if (checkWifiStatus()) {
|
||||
if (DownloadStore()) {
|
||||
selection = 0;
|
||||
@@ -402,6 +399,9 @@ void Overlays::SelectStore(std::unique_ptr<Store> &store, std::vector<std::uniqu
|
||||
}
|
||||
}
|
||||
|
||||
if (hidKeysDown() & KEY_B) doOut = true;
|
||||
/* Go out of the menu. */
|
||||
if ((hidKeysDown() & KEY_B) || (hidKeysDown() & KEY_TOUCH && touching(touch, mainButtons[10]))) {
|
||||
doOut = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -118,7 +118,7 @@ void MainScreen::Draw(void) const {
|
||||
|
||||
case 4:
|
||||
/* Settings. */
|
||||
StoreUtils::DrawSettings(this->sPage, 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;
|
||||
}
|
||||
}
|
||||
|
||||
+150
-6
@@ -39,6 +39,18 @@ static const std::vector<Structs::ButtonPos> mainButtons = {
|
||||
{ 54, 212, 262, 22 }
|
||||
};
|
||||
|
||||
static const std::vector<Structs::ButtonPos> 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<Structs::ButtonPos> 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<std::string> mainStrings = { "LANGUAGE", "SELECT_UNISTORE", "AUTO_UPDATE_SETTINGS_BTN", "GUI_SETTINGS_BTN", "DIRECTORY_SETTINGS_BTN", "CREDITS", "EXIT_APP" };
|
||||
static const std::vector<std::string> dirStrings = { "CHANGE_3DSX_PATH", "CHANGE_NDS_PATH", "CHANGE_ARCHIVE_PATH" };
|
||||
|
||||
static const std::vector<std::string> 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> &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<std::unique_ptr<StoreEntry>> &entries: Reference to the StoreEntries.
|
||||
std::unique_ptr<Meta> &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> &store, std::vector<std::unique_ptr<StoreEntry>> &entries, std::unique_ptr<Meta> &meta) {
|
||||
void StoreUtils::SettingsHandle(u32 hDown, u32 hHeld, touchPosition touch, int &page, bool &dspSettings, int &storeMode, int &selection, std::unique_ptr<Store> &store, std::vector<std::unique_ptr<StoreEntry>> &entries, std::unique_ptr<Meta> &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;
|
||||
}
|
||||
}
|
||||
@@ -32,9 +32,6 @@
|
||||
#include <functional>
|
||||
#include <unistd.h>
|
||||
|
||||
extern bool touching(touchPosition touch, Structs::ButtonPos button);
|
||||
extern touchPosition touch;
|
||||
|
||||
bool nameEndsWith(const std::string &name, const std::vector<std::string> &extensionList) {
|
||||
if (name.substr(0, 2) == "._") return false;
|
||||
|
||||
|
||||
@@ -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.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user