From 8fd1c9ad605adfc345c7d50d5635aa3fb0c77ad5 Mon Sep 17 00:00:00 2001 From: StackZ <47382115+SuperSaiyajinStackZ@users.noreply.github.com> Date: Fri, 3 Jan 2020 07:19:28 +0100 Subject: [PATCH] Hopefully *Center* everything properly. --- include/utils/config.hpp | 4 +--- source/lang/lang.cpp | 8 +++++++- source/screens/credits.cpp | 12 ++++++------ source/screens/mainMenu.cpp | 8 ++++---- source/screens/scriptBrowse.cpp | 6 +++--- source/screens/scriptlist.cpp | 8 ++++---- source/screens/settings.cpp | 10 +++++----- source/screens/unistore.cpp | 31 +++++++++++++++++-------------- source/utils/config.cpp | 17 ++++++++++------- source/utils/fileBrowse.cpp | 20 ++++++++++---------- 10 files changed, 67 insertions(+), 57 deletions(-) diff --git a/include/utils/config.hpp b/include/utils/config.hpp index 27af67b..cd7d52d 100644 --- a/include/utils/config.hpp +++ b/include/utils/config.hpp @@ -30,7 +30,7 @@ #include namespace Config { - extern int lang, Color1, Color2, Color3, TxtColor, SelectedColor, UnselectedColor, viewMode, progressbarColor; + extern int LangPath, lang, Color1, Color2, Color3, TxtColor, SelectedColor, UnselectedColor, viewMode, progressbarColor; extern std::string ScriptPath, MusicPath, StorePath; extern bool Logging, UseBars; @@ -46,8 +46,6 @@ namespace Config { std::string getString(const std::string &key); void setString(const std::string &key, const std::string &v); - - int getLang(const std::string &key); } #endif \ No newline at end of file diff --git a/source/lang/lang.cpp b/source/lang/lang.cpp index 92c2a42..82b2ef5 100644 --- a/source/lang/lang.cpp +++ b/source/lang/lang.cpp @@ -1,5 +1,7 @@ #include "lang/lang.hpp" +#include "utils/config.hpp" + #include nlohmann::json appJson; @@ -15,7 +17,11 @@ std::string langs[] = {"br", "de", "en", "es", "fr", "it", "lt", "pt", "ru", "jp void Lang::load(int lang) { FILE* values; - values = fopen(("romfs:/lang/"+langs[lang]+"/app.json").c_str(), "rt"); + if (Config::LangPath == 1) { + values = fopen(("sdmc:/3ds/Universal-Updater/app.json"), "rt"); + } else { + values = fopen(("romfs:/lang/"+langs[lang]+"/app.json").c_str(), "rt"); + } if(values) appJson = nlohmann::json::parse(values, nullptr, false); fclose(values); } \ No newline at end of file diff --git a/source/screens/credits.cpp b/source/screens/credits.cpp index eb9d29f..a51ff99 100644 --- a/source/screens/credits.cpp +++ b/source/screens/credits.cpp @@ -64,12 +64,12 @@ void Credits::Draw(void) const { Gui::DrawString(180, 30, 0.6f, Config::TxtColor, "Русский\nFrançais\nPortuguês\nPortuguês\nBruh\nLietuvių\n日本語\nItaliano\nDeutsch, English\nEspañol"); } else if (creditsPage == 2) { Gui::DrawStringCentered(0, -2, 0.7f, Config::TxtColor, "Universal-Team", 320); - Gui::DrawStringCentered(-65, 35, 0.7f, Config::TxtColor, "DeadPhoenix"); - Gui::DrawStringCentered(-40, 65, 0.7f, Config::TxtColor, "Flame"); - Gui::DrawStringCentered(-38, 95, 0.7f, Config::TxtColor, "Pk11"); - Gui::DrawStringCentered(-60, 125, 0.7f, Config::TxtColor, "RocketRobz"); - Gui::DrawStringCentered(-42, 155, 0.7f, Config::TxtColor, "StackZ"); - Gui::DrawStringCentered(-65, 185, 0.7f, Config::TxtColor, "TotallyNotGuy"); + Gui::DrawStringCentered(0, 35, 0.7f, Config::TxtColor, "DeadPhoenix"); + Gui::DrawStringCentered(0, 65, 0.7f, Config::TxtColor, "Flame"); + Gui::DrawStringCentered(0, 95, 0.7f, Config::TxtColor, "Pk11"); + Gui::DrawStringCentered(0, 125, 0.7f, Config::TxtColor, "RocketRobz"); + Gui::DrawStringCentered(0, 155, 0.7f, Config::TxtColor, "StackZ"); + Gui::DrawStringCentered(0, 185, 0.7f, Config::TxtColor, "TotallyNotGuy"); } else if (creditsPage == 3) { Gui::DrawStringCentered(0, -2, 0.7f, Config::TxtColor, Lang::get("SCRIPTCREATORS"), 320); Gui::DrawString(5, 27, 0.55f, Config::TxtColor, "- DualBladedKirito\n\n- Glazed_Belmont\n\n- Pk11\n\n- StackZ\n\n- The Conceptionist\n\n- YoSoy"); diff --git a/source/screens/mainMenu.cpp b/source/screens/mainMenu.cpp index 9d4a147..cc3f88f 100644 --- a/source/screens/mainMenu.cpp +++ b/source/screens/mainMenu.cpp @@ -60,10 +60,10 @@ void MainMenu::Draw(void) const { } } - Gui::DrawString((320-Gui::GetStringWidth(0.6f, "UniStore"))/2-150+70+10, mainButtons[0].y+12, 0.6f, Config::TxtColor, "UniStore", 140); - Gui::DrawString((320-Gui::GetStringWidth(0.6f, Lang::get("SCRIPTS")))/2+150-70, mainButtons[1].y+12, 0.6f, Config::TxtColor, Lang::get("SCRIPTS"), 140); - Gui::DrawString((320-Gui::GetStringWidth(0.6f, Lang::get("SETTINGS")))/2-150+70, mainButtons[2].y+12, 0.6f, Config::TxtColor, Lang::get("SETTINGS"), 140); - Gui::DrawString((320-Gui::GetStringWidth(0.6f, "FTP"))/2+150-70, mainButtons[3].y+12, 0.6f, Config::TxtColor, "FTP", 140); + Gui::DrawStringCentered(-80+10, mainButtons[0].y+12, 0.6f, Config::TxtColor, "UniStore", 130); + Gui::DrawStringCentered(80, mainButtons[1].y+12, 0.6f, Config::TxtColor, Lang::get("SCRIPTS"), 130); + Gui::DrawStringCentered(-80, mainButtons[2].y+12, 0.6f, Config::TxtColor, Lang::get("SETTINGS"), 130); + Gui::DrawStringCentered(80, mainButtons[3].y+12, 0.6f, Config::TxtColor, "FTP", 130); // Draw UniStore Icon. ;P Gui::sprite(sprites_uniStore_idx, 10, 65); diff --git a/source/screens/scriptBrowse.cpp b/source/screens/scriptBrowse.cpp index 27ec225..57f02de 100644 --- a/source/screens/scriptBrowse.cpp +++ b/source/screens/scriptBrowse.cpp @@ -122,11 +122,11 @@ void ScriptBrowse::Draw(void) const { Gui::DrawStringCentered(0, 120, 0.6f, Config::TxtColor, std::string(infoJson[selection]["shortDesc"]), 400); if(infoJson[selection]["curRevision"] < infoJson[selection]["revision"]) { - Gui::DrawStringCentered(0, 219, 0.7f, Config::TxtColor, Lang::get("OUTDATED_SCRIPT"), 400); + Gui::DrawStringCentered(0, 219, 0.7f, Config::TxtColor, Lang::get("OUTDATED_SCRIPT"), 370); } else if(infoJson[selection]["curRevision"] == infoJson[selection]["revision"]) { - Gui::DrawStringCentered(0, 219, 0.7f, Config::TxtColor, Lang::get("UP-TO-DATE"), 400); + Gui::DrawStringCentered(0, 219, 0.7f, Config::TxtColor, Lang::get("UP-TO-DATE"), 370); } else if(infoJson[selection]["curRevision"] > infoJson[selection]["revision"]) { - Gui::DrawStringCentered(0, 219, 0.7f, Config::TxtColor, Lang::get("FUTURE_SCRIPT"), 400); + Gui::DrawStringCentered(0, 219, 0.7f, Config::TxtColor, Lang::get("FUTURE_SCRIPT"), 370); } Gui::DrawBottom(); Gui::DrawArrow(295, -1); diff --git a/source/screens/scriptlist.cpp b/source/screens/scriptlist.cpp index 5419ff6..aea134c 100644 --- a/source/screens/scriptlist.cpp +++ b/source/screens/scriptlist.cpp @@ -288,10 +288,10 @@ void ScriptList::DrawSubMenu(void) const { } } - Gui::DrawString((320-Gui::GetStringWidth(0.6f, Lang::get("SCRIPTLIST")))/2-150+70, subPos[0].y+12, 0.6f, Config::TxtColor, Lang::get("SCRIPTLIST"), 140); - Gui::DrawString((320-Gui::GetStringWidth(0.6f, Lang::get("GET_SCRIPTS")))/2+150-70, subPos[1].y+12, 0.6f, Config::TxtColor, Lang::get("GET_SCRIPTS"), 140); - Gui::DrawString((320-Gui::GetStringWidth(0.6f, Lang::get("SCRIPTCREATOR")))/2-150+70, subPos[2].y+12, 0.6f, Config::TxtColor, Lang::get("SCRIPTCREATOR"), 140); - Gui::DrawString((320-Gui::GetStringWidth(0.6f, Lang::get("CHANGE_SCRIPTPATH")))/2+150-70, subPos[3].y+12, 0.6f, Config::TxtColor, Lang::get("CHANGE_SCRIPTPATH"), 140); + Gui::DrawStringCentered(-80, subPos[0].y+12, 0.6f, Config::TxtColor, Lang::get("SCRIPTLIST"), 130); + Gui::DrawStringCentered(80, subPos[1].y+12, 0.6f, Config::TxtColor, Lang::get("GET_SCRIPTS"), 130); + Gui::DrawStringCentered(-80, subPos[2].y+12, 0.6f, Config::TxtColor, Lang::get("SCRIPTCREATOR"), 130); + Gui::DrawStringCentered(80, subPos[3].y+12, 0.6f, Config::TxtColor, Lang::get("CHANGE_SCRIPTPATH"), 130); } diff --git a/source/screens/settings.cpp b/source/screens/settings.cpp index da64f07..f35d87d 100644 --- a/source/screens/settings.cpp +++ b/source/screens/settings.cpp @@ -71,9 +71,9 @@ void Settings::DrawSubMenu(void) const { } } - Gui::DrawString((320-Gui::GetStringWidth(0.6f, Lang::get("LANGUAGE")))/2, mainButtons[0].y+10, 0.6f, Config::TxtColor, Lang::get("LANGUAGE"), 140); - Gui::DrawString((320-Gui::GetStringWidth(0.6f, Lang::get("COLORS")))/2, mainButtons[1].y+10, 0.6f, Config::TxtColor, Lang::get("COLORS"), 140); - Gui::DrawString((320-Gui::GetStringWidth(0.6f, Lang::get("CREDITS")))/2, mainButtons[2].y+10, 0.6f, Config::TxtColor, Lang::get("CREDITS"), 140); + Gui::DrawStringCentered(0, mainButtons[0].y+10, 0.6f, Config::TxtColor, Lang::get("LANGUAGE"), 130); + Gui::DrawStringCentered(0, mainButtons[1].y+10, 0.6f, Config::TxtColor, Lang::get("COLORS"), 130); + Gui::DrawStringCentered(0, mainButtons[2].y+10, 0.6f, Config::TxtColor, Lang::get("CREDITS"), 130); } void Settings::DrawLanguageSelection(void) const { @@ -207,8 +207,8 @@ void Settings::DrawMiscSettings(void) const { } } - Gui::DrawStringCentered(0, mainButtons[0].y+10, 0.6f, Config::TxtColor, Lang::get("CHANGE_MUSICFILE"), 140); - Gui::DrawStringCentered(0, mainButtons[1].y+10, 0.6f, Config::TxtColor, Lang::get("CHANGE_BAR_STYLE"), 140); + Gui::DrawStringCentered(0, mainButtons[0].y+10, 0.6f, Config::TxtColor, Lang::get("CHANGE_MUSICFILE"), 130); + Gui::DrawStringCentered(0, mainButtons[1].y+10, 0.6f, Config::TxtColor, Lang::get("CHANGE_BAR_STYLE"), 130); } void Settings::MiscSettingsLogic(u32 hDown, u32 hHeld, touchPosition touch) { diff --git a/source/screens/unistore.cpp b/source/screens/unistore.cpp index 9de55fd..8378673 100644 --- a/source/screens/unistore.cpp +++ b/source/screens/unistore.cpp @@ -192,9 +192,9 @@ void UniStore::DrawSubMenu(void) const { } } - Gui::DrawString((320-Gui::GetStringWidth(0.6f, Lang::get("STORE_LIST")))/2, subPos[0].y+10, 0.6f, Config::TxtColor, Lang::get("STORE_LIST"), 140); - Gui::DrawString((320-Gui::GetStringWidth(0.6f, Lang::get("STORE_SEARCH")))/2, subPos[1].y+10, 0.6f, Config::TxtColor, Lang::get("STORE_SEARCH"), 140); - Gui::DrawString((320-Gui::GetStringWidth(0.6f, Lang::get("CHANGE_STOREPATH")))/2, subPos[2].y+10, 0.6f, Config::TxtColor, Lang::get("CHANGE_STOREPATH"), 140); + Gui::DrawStringCentered(0, subPos[0].y+10, 0.6f, Config::TxtColor, Lang::get("STORE_LIST"), 130); + Gui::DrawStringCentered(0, subPos[1].y+10, 0.6f, Config::TxtColor, Lang::get("STORE_SEARCH"), 130); + Gui::DrawStringCentered(0, subPos[2].y+10, 0.6f, Config::TxtColor, Lang::get("CHANGE_STOREPATH"), 130); } @@ -307,7 +307,7 @@ void UniStore::DrawStore(void) const { info = appStoreList[screenPos2 + i]; if(screenPos2 + i == selection2) { Gui::Draw_Rect(0, 40+(i*57), 320, 45, selected); - } else { + } else { Gui::Draw_Rect(0, 40+(i*57), 320, 45, unselected); } Gui::DrawStringCentered(0, 50+(i*57), 0.7f, TextColor, info, 320); @@ -829,8 +829,9 @@ void UniStore::DrawSearch(void) const { Gui::Draw_Rect(URLBtn[i].x, URLBtn[i].y, URLBtn[i].w, URLBtn[i].h, Config::UnselectedColor); } } - Gui::DrawString((320-Gui::GetStringWidth(0.6f, Lang::get("FULL_URL")))/2-150+70, 110, 0.6f, Config::TxtColor, Lang::get("FULL_URL"), 140); - Gui::DrawString((320-Gui::GetStringWidth(0.6f, Lang::get("GITHUB")))/2+150-70, 110, 0.6f, Config::TxtColor, Lang::get("GITHUB"), 140); + + Gui::DrawStringCentered(-80, 110, 0.6f, Config::TxtColor, Lang::get("FULL_URL"), 130); + Gui::DrawStringCentered(80, 110, 0.6f, Config::TxtColor, Lang::get("GITHUB"), 130); } void UniStore::SearchLogic(u32 hDown, u32 hHeld, touchPosition touch) { @@ -872,16 +873,17 @@ void UniStore::DrawGitHubScreen(void) const { Gui::DrawBottom(); Gui::DrawArrow(0, 218, 0, 1); - Gui::DrawStringCentered(0, 28, 0.7f, Config::TxtColor, Lang::get("OWNER_AND_REPO"), 320); - Gui::DrawStringCentered(0, 108, 0.7f, Config::TxtColor, Lang::get("FILENAME"), 320); + Gui::DrawStringCentered(0, 28, 0.7f, Config::TxtColor, Lang::get("OWNER_AND_REPO"), 300); + Gui::DrawStringCentered(0, 108, 0.7f, Config::TxtColor, Lang::get("FILENAME"), 300); Gui::Draw_Rect(GitHubPos[0].x, GitHubPos[0].y, GitHubPos[0].w, GitHubPos[0].h, Config::Color1); Gui::Draw_Rect(GitHubPos[1].x, GitHubPos[1].y, GitHubPos[1].w, GitHubPos[1].h, Config::Color1); Gui::Draw_Rect(GitHubPos[2].x, GitHubPos[2].y, GitHubPos[2].w, GitHubPos[2].h, Config::Color1); - Gui::DrawStringCentered(0, 185, 0.7f, Config::TxtColor, Lang::get("OK"), 250); - Gui::DrawString(35, 57, 0.45f, Config::TxtColor, OwnerAndRepo, 250); - Gui::DrawString(35, 137, 0.45f, Config::TxtColor, fileName, 250); + Gui::DrawStringCentered(0, 185, 0.7f, Config::TxtColor, Lang::get("OK"), 40); + + Gui::DrawStringCentered(-70, 57, 0.5f, Config::TxtColor, OwnerAndRepo, 130); + Gui::DrawStringCentered(-70, 137, 0.5f, Config::TxtColor, fileName, 130); } void UniStore::GitHubLogic(u32 hDown, u32 hHeld, touchPosition touch) { @@ -932,9 +934,10 @@ void UniStore::DrawFullURLScreen(void) const { Gui::Draw_Rect(GitHubPos[1].x, GitHubPos[1].y, GitHubPos[1].w, GitHubPos[1].h, Config::Color1); Gui::Draw_Rect(GitHubPos[2].x, GitHubPos[2].y, GitHubPos[2].w, GitHubPos[2].h, Config::Color1); - Gui::DrawStringCentered(0, 185, 0.7f, Config::TxtColor, Lang::get("OK"), 250); - Gui::DrawString(35, 57, 0.45f, Config::TxtColor, FullURL, 250); - Gui::DrawString(35, 137, 0.45f, Config::TxtColor, fileName, 250); + Gui::DrawStringCentered(0, 185, 0.7f, Config::TxtColor, Lang::get("OK"), 40); + + Gui::DrawStringCentered(-70, 57, 0.45f, Config::TxtColor, FullURL, 130); + Gui::DrawStringCentered(-70, 137, 0.45f, Config::TxtColor, fileName, 130); } void UniStore::FullURLLogic(u32 hDown, u32 hHeld, touchPosition touch) { diff --git a/source/utils/config.cpp b/source/utils/config.cpp index 7f337fb..5e0b026 100644 --- a/source/utils/config.cpp +++ b/source/utils/config.cpp @@ -47,6 +47,7 @@ std::string Config::MusicPath; bool Config::Logging; bool Config::UseBars; std::string Config::StorePath; +int Config::LangPath; nlohmann::json configJson; void Config::load() { @@ -96,6 +97,12 @@ void Config::load() { Config::ScriptPath = getString("SCRIPTPATH"); } + if(!configJson.contains("LANGPATH")) { + Config::LangPath = 0; + } else { + Config::LangPath = getInt("LANGPATH"); + } + if(!configJson.contains("LANGUAGE")) { Config::lang = 2; } else { @@ -147,6 +154,7 @@ void Config::load() { Config::SelectedColor = SelectedColordefault; Config::UnselectedColor = UnselectedColordefault; Config::ScriptPath = SCRIPTS_PATH; + Config::LangPath = 0; Config::lang = 2; Config::viewMode = 0; Config::progressbarColor = WHITE; @@ -165,6 +173,7 @@ void Config::save() { Config::setInt("SELECTEDCOLOR", Config::SelectedColor); Config::setInt("UNSELECTEDCOLOR", Config::UnselectedColor); Config::setString("SCRIPTPATH", Config::ScriptPath); + Config::setInt("LANGPATH", Config::LangPath); Config::setInt("LANGUAGE", Config::lang); Config::setInt("VIEWMODE", Config::viewMode); Config::setInt("PROGRESSBARCOLOR", Config::progressbarColor); @@ -187,6 +196,7 @@ void Config::initializeNewConfig() { Config::setInt("SELECTEDCOLOR", SelectedColordefault); Config::setInt("UNSELECTEDCOLOR", UnselectedColordefault); Config::setString("SCRIPTPATH", SCRIPTS_PATH); + Config::setInt("LANGPATH", 0); Config::setInt("LANGUAGE", 2); Config::setInt("VIEWMODE", 0); Config::setInt("PROGRESSBARCOLOR", WHITE); @@ -228,11 +238,4 @@ std::string Config::getString(const std::string &key) { } void Config::setString(const std::string &key, const std::string &v) { configJson[key] = v; -} - -int Config::getLang(const std::string &key) { - if(!configJson.contains(key)) { - return 1; - } - return configJson.at(key).get_ref(); } \ No newline at end of file diff --git a/source/utils/fileBrowse.cpp b/source/utils/fileBrowse.cpp index a250a02..282e92b 100644 --- a/source/utils/fileBrowse.cpp +++ b/source/utils/fileBrowse.cpp @@ -229,11 +229,11 @@ std::string selectFilePath(std::string selectText, const std::vector