From 3e89939308f00087dbca7a4dc26f7fb5e4d0c2bc Mon Sep 17 00:00:00 2001 From: J-D-K Date: Mon, 14 Jun 2021 23:00:03 -0400 Subject: [PATCH] Add language override bool --- inc/data.h | 2 +- inc/uistr.h | 4 ++-- romfs/lang/en-US.txt | 2 ++ src/data.cpp | 4 ++++ src/ui.cpp | 2 +- src/ui/ttlsel.cpp | 2 -- src/ui/txtui.cpp | 8 +++++++- src/ui/uistr.cpp | 49 +++++++++++++++++++++++++++++++++++++++----- 8 files changed, 61 insertions(+), 12 deletions(-) diff --git a/inc/data.h b/inc/data.h index 92d57c6..e077bbc 100644 --- a/inc/data.h +++ b/inc/data.h @@ -140,7 +140,7 @@ namespace data void restoreDefaultConfig(); extern int selUser, selData; extern SetLanguage sysLang; - extern bool incDev, autoBack, ovrClk, holdDel, holdRest, holdOver, forceMount, accSysSave, sysSaveWrite, directFsCmd, skipUser, zip; + extern bool incDev, autoBack, ovrClk, holdDel, holdRest, holdOver, forceMount, accSysSave, sysSaveWrite, directFsCmd, skipUser, zip, langOverride; extern uint8_t sortType; } diff --git a/inc/uistr.h b/inc/uistr.h index 5e040c9..7e77019 100644 --- a/inc/uistr.h +++ b/inc/uistr.h @@ -16,9 +16,9 @@ namespace ui //Strings for extras menu extern std::string exMenuStr[11]; //Strings for options menu - extern std::string optMenuStr[14]; + extern std::string optMenuStr[15]; //Strings for options explanations - extern std::string optMenuExp[14]; + extern std::string optMenuExp[15]; //Strings for the holding thing extern std::string holdingText[3]; //Strings for sort type diff --git a/romfs/lang/en-US.txt b/romfs/lang/en-US.txt index 0a73ad9..01ff3a4 100644 --- a/romfs/lang/en-US.txt +++ b/romfs/lang/en-US.txt @@ -108,6 +108,7 @@ optMenu = 10, "Direct FS Cmd: " optMenu = 11, "Skip User Select: " optMenu = 12, "Export to ZIP: " optMenu = 13, "Sort: " +optMenu = 14, "Language Override: " #Explanations of what options do. optMenuExp = 0, "Includes Device Save data in user accounts." @@ -124,6 +125,7 @@ optMenuExp = 10, "Directly uses the Switch's FS commands to copy files instead o optMenuExp = 11, "Skips the user selection screen and jumps directly to the first user account found." optMenuExp = 12, "Exports saves to zip files." optMenuExp = 13, "Changes the way titles are sorted and listed." +opeMenuExp = 14, "Forces English to be used regardless of system language." #Sort Types sortType = 0, "Alphabetical" diff --git a/src/data.cpp b/src/data.cpp index 179c2cb..26351d0 100644 --- a/src/data.cpp +++ b/src/data.cpp @@ -31,6 +31,7 @@ SetLanguage data::sysLang; //Options bool data::incDev = false, data::autoBack = true, data::ovrClk = false, data::holdDel = true, data::holdRest = true, data::holdOver = true; bool data::forceMount = true, data::accSysSave = false, data::sysSaveWrite = false, data::directFsCmd = false, data::skipUser = false, data::zip = false; +bool data::langOverride = false; uint8_t data::sortType = 0; //For other save types @@ -588,6 +589,7 @@ void data::loadCfg() data::directFsCmd = cfgIn >> 53 & 1; data::skipUser = cfgIn >> 52 & 1; data::zip = cfgIn >> 51 & 1; + data::langOverride = cfgIn >> 50 & 1; } } @@ -611,6 +613,7 @@ void data::saveCfg() cfgOut |= (uint64_t)data::directFsCmd << 53; cfgOut |= (uint64_t)data::skipUser << 52; cfgOut |= (uint64_t)data::zip << 51; + cfgOut |= (uint64_t)data::langOverride << 50; fwrite(&cfgOut, sizeof(uint64_t), 1, cfg); fwrite(&data::sortType, 1, 1, cfg); @@ -633,6 +636,7 @@ void data::restoreDefaultConfig() data::skipUser = false; data::zip = false; data::sortType = 0; + data::langOverride = false; } void data::loadFav() diff --git a/src/ui.cpp b/src/ui.cpp index b5c1d50..fe7ea60 100644 --- a/src/ui.cpp +++ b/src/ui.cpp @@ -60,7 +60,7 @@ static std::unordered_map uistrdef = static void loadTrans() { bool transFile = fs::fileExists(fs::getWorkDir() + "trans.txt"); - if(!transFile && data::sysLang == SetLanguage_ENUS) + if(!transFile && (data::sysLang == SetLanguage_ENUS || data::langOverride)) return;//Don't bother loading from file. It serves as a translation guide std::string file; diff --git a/src/ui/ttlsel.cpp b/src/ui/ttlsel.cpp index 3816396..0afc8ee 100644 --- a/src/ui/ttlsel.cpp +++ b/src/ui/ttlsel.cpp @@ -18,8 +18,6 @@ static bool clrAdd = true; //Selected rectangle X and Y. static unsigned selRectX = 66, selRectY = 94; -static SDL_Texture *panel; - static inline void reset() { start = 0; diff --git a/src/ui/txtui.cpp b/src/ui/txtui.cpp index d3d6c61..525f64c 100644 --- a/src/ui/txtui.cpp +++ b/src/ui/txtui.cpp @@ -368,7 +368,7 @@ static inline void changeSort() void ui::optMenuInit() { optMenu.setParams(76, 98, 310); - for(unsigned i = 0; i < 14; i++) + for(unsigned i = 0; i < 15; i++) optMenu.addOpt(ui::optMenuStr[i]); } @@ -391,6 +391,8 @@ void ui::updateOptMenu(const uint64_t& down, const uint64_t& held) optMenu.editOpt(11, optMenuStr[11] + getBoolText(data::skipUser)); optMenu.editOpt(12, optMenuStr[12] + getBoolText(data::zip)); optMenu.editOpt(13, optMenuStr[13] + ui::sortString[data::sortType]); + optMenu.editOpt(14, optMenuStr[14] + getBoolText(data::langOverride)); + if(down & HidNpadButton_A) { @@ -452,6 +454,10 @@ void ui::updateOptMenu(const uint64_t& down, const uint64_t& held) changeSort(); data::loadUsersTitles(false); break; + + case 14: + switchBool(data::langOverride); + break; } } else if(down & HidNpadButton_X) diff --git a/src/ui/uistr.cpp b/src/ui/uistr.cpp index a03f19b..2c26103 100644 --- a/src/ui/uistr.cpp +++ b/src/ui/uistr.cpp @@ -28,10 +28,48 @@ std::string ui::confEraseFolder = "*WARNING*: This *will* delete the current sav std::string ui::noSavesFound = "No saves found for #%s#!"; std::string ui::errorConnecting = "Error Connecting!"; std::string ui::noUpdate = "No updates available!"; -std::string ui::advMenuStr[6] = { "Copy to ", "Delete", "Rename", "Make Dir", "Properties", "Close" }; -std::string ui::exMenuStr[11] = { "SD to SD Browser", "BIS: PRODINFOF", "BIS: SAFE", "BIS: SYSTEM", "BIS: USER", "Remove Update", "Terminate Process", "Mount System Save", "Rescan Titles", "Mount Process RomFS", "Backup JKSV Folder" }; -std::string ui::optMenuStr[14] = { "Include Dev Sv: ", "AutoBackup: ", "Overclock: ", "Hold to Delete: ", "Hold to Restore: ", "Hold to Overwrite: ", "Force Mount: ", "Account Sys. Saves: ", "Write to Sys. Saves: ", "Text UI Mode: ", "Direct FS Cmd: ", "Skip User Select: ", "Export to ZIP: ", "Sort: "}; -std::string ui::optMenuExp[14] = +std::string ui::advMenuStr[6] = +{ + "Copy to ", + "Delete", + "Rename", + "Make Dir", + "Properties", + "Close" +}; +std::string ui::exMenuStr[11] = +{ + "SD to SD Browser", + "BIS: PRODINFOF", + "BIS: SAFE", + "BIS: SYSTEM", + "BIS: USER", + "Remove Update", + "Terminate Process", + "Mount System Save", + "Rescan Titles", + "Mount Process RomFS", + "Backup JKSV Folder" +}; +std::string ui::optMenuStr[15] = +{ + "Include Dev Sv: ", + "AutoBackup: ", + "Overclock: ", + "Hold to Delete: ", + "Hold to Restore: ", + "Hold to Overwrite: ", + "Force Mount: ", + "Account Sys. Saves: ", + "Write to Sys. Saves: ", + "Text UI Mode: ", + "Direct FS Cmd: ", + "Skip User Select: ", + "Export to ZIP: ", + "Sort: ", + "Language Override: " +}; +std::string ui::optMenuExp[15] = { "Includes Device Save data in user accounts.", "Automatically creates a save backup before restoring a save.", @@ -46,7 +84,8 @@ std::string ui::optMenuExp[14] = "Directly uses the Switch's FS commands to copy files instead of stdio.", "Skips the user selection screen and jumps directly to the first user account found.", "Exports saves to ZIP files.", - "Changes the way titles are sorted and listed." + "Changes the way titles are sorted and listed.", + "Forces English to be used regardless of system language." }; std::string ui::holdingText[3] = { "(Hold) ", "(Keep Holding) ", "(Almost there!) " }; std::string ui::sortString[3] = { "Alphabetical", "Time Played", "Last Played" };