diff --git a/.gitmodules b/.gitmodules index 000826a..54111f4 100644 --- a/.gitmodules +++ b/.gitmodules @@ -3,4 +3,4 @@ url = https://github.com/HamletDuFromage/zipper [submodule "lib/borealis"] path = lib/borealis - url = https://github.com/tiansongyu/borealis + url = https://github.com/HamletDuFromage/borealis diff --git a/Makefile b/Makefile index fc65044..b0e4416 100644 --- a/Makefile +++ b/Makefile @@ -45,7 +45,7 @@ DATA := data INCLUDES := include lib/zipper/include APP_TITLE := All-in-One Switch Updater APP_AUTHOR := HamletDuFromage -APP_VERSION := 1.1.3 +APP_VERSION := 1.2.0 ROMFS = res BOREALIS_PATH := lib/borealis diff --git a/README.md b/README.md index 1cdaee5..b5cfaee 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,8 @@ Downloads and extracts daily-updated cheat code. The program will only extract c ## Disclaimer I do not own, host nor distribute any of the files that can be downloaded with this homebrew tool. At the owner's request, I will immediately remove the ability to download the problematic files. +## Special thanks +- [tiansongyu](https://github.com/tiansongyu) for bringing support for multi-language and for his Chinese translation. ### Like the app? [//]: [![5cbed8a433a3f45a772abaf5_SupportMe_blue-p-500](https://user-images.githubusercontent.com/61667930/93899702-1a2b2680-fce4-11ea-9eaa-4e2b44eebe86.png)](https://ko-fi.com/hamletdufromage) diff --git a/icon.jpg b/icon.jpg old mode 100644 new mode 100755 index a6f7f4a..8a62d59 Binary files a/icon.jpg and b/icon.jpg differ diff --git a/include/constants.hpp b/include/constants.hpp index 919094c..b5b9fec 100644 --- a/include/constants.hpp +++ b/include/constants.hpp @@ -1,5 +1,7 @@ #pragma once +#define APP_LANG "/config/aio-switch-updater/lang.json" + #define ROOT_PATH "/" #define DOWNLOAD_PATH "/config/aio-switch-updater/" #define CONFIG_PATH "/config/aio-switch-updater/" @@ -43,6 +45,8 @@ #define BOOTLOADER_PL_PATH "/bootloader/payloads/" #define REBOOT_PAYLOAD_PATH "/atmosphere/reboot_payload.bin" +#define LISTITEM_HEIGHT 50 + enum archiveType{ sigpatches, diff --git a/include/fs.hpp b/include/fs.hpp deleted file mode 100644 index f6dd830..0000000 --- a/include/fs.hpp +++ /dev/null @@ -1,227 +0,0 @@ -#pragma once - -#include -#include -#include -#include - -namespace fs { - -struct Directory { - FsDir handle = {}; - - constexpr inline Directory() = default; - constexpr inline Directory(const FsDir &handle): handle(handle) { } - - inline ~Directory() { - this->close(); - } - - inline Result open(FsFileSystem *fs, const std::string &path) { - auto tmp = path; - tmp.reserve(FS_MAX_PATH); // Fails otherwise - return fsFsOpenDirectory(fs, tmp.c_str(), FsDirOpenMode_ReadDirs | FsDirOpenMode_ReadFiles, &this->handle); - } - - inline void close() { - fsDirClose(&this->handle); - } - - inline bool is_open() const { - // TODO: Better heuristic? - return this->handle.s.session; - } - - inline std::size_t count() { - std::int64_t count = 0; - fsDirGetEntryCount(&this->handle, &count); - return count; - } - - std::vector list() { - std::int64_t total = 0; - auto c = this->count(); - auto entries = std::vector(c); - fsDirRead(&this->handle, &total, c, entries.data()); - return entries; - } -}; - -struct File { - FsFile handle = {}; - - constexpr inline File() = default; - constexpr inline File(const FsFile &handle): handle(handle) { } - - inline ~File() { - this->close(); - } - - inline Result open(FsFileSystem *fs, const std::string &path, std::uint32_t mode = FsOpenMode_Read) { - auto tmp = path; - tmp.reserve(FS_MAX_PATH); - return fsFsOpenFile(fs, tmp.c_str(), mode, &this->handle); - } - - inline void close() { - fsFileClose(&this->handle); - } - - inline bool is_open() const { - return this->handle.s.session; - } - - inline std::size_t size() { - std::int64_t tmp = 0; - fsFileGetSize(&this->handle, &tmp); - return tmp; - } - - inline void size(std::size_t size) { - fsFileSetSize(&this->handle, static_cast(size)); - } - - inline std::size_t read(void *buf, std::size_t size, std::size_t offset = 0) { - std::uint64_t tmp = 0; - auto rc = fsFileRead(&this->handle, static_cast(offset), buf, static_cast(size), FsReadOption_None, &tmp); - if (R_FAILED(rc)) - printf("Read failed with %#x\n", rc); - return tmp; - } - - inline void write(const void *buf, std::size_t size, std::size_t offset = 0) { - fsFileWrite(&this->handle, static_cast(offset), buf, size, FsWriteOption_None); - } - - inline void flush() { - fsFileFlush(&this->handle); - } -}; - -struct Filesystem { - FsFileSystem handle = {}; - - constexpr inline Filesystem() = default; - constexpr inline Filesystem(const FsFileSystem &handle): handle(handle) { } - - inline ~Filesystem() { - this->close(); - } - - inline Result open(FsBisPartitionId id) { - return fsOpenBisFileSystem(&this->handle, id, ""); - } - - inline Result open_sdmc() { - return fsOpenSdCardFileSystem(&this->handle); - } - - inline void close() { - flush(); - fsFsClose(&this->handle); - } - - inline bool is_open() const { - return this->handle.s.session; - } - - inline Result flush() { - return fsFsCommit(&this->handle); - } - - inline std::size_t total_space() { - std::int64_t tmp = 0; - fsFsGetTotalSpace(&this->handle, "/", &tmp); - return tmp; - } - - inline std::size_t free_space() { - std::int64_t tmp = 0; - fsFsGetFreeSpace(&this->handle, "/", &tmp); - return tmp; - } - - inline Result open_directory(Directory &d, const std::string &path) { - return d.open(&this->handle, path); - } - - inline Result open_file(File &f, const std::string &path, std::uint32_t mode = FsOpenMode_Read) { - return f.open(&this->handle, path, mode); - } - - inline Result create_directory(const std::string &path) { - return fsFsCreateDirectory(&this->handle, path.c_str()); - } - - inline Result create_file(const std::string &path, std::size_t size = 0) { - return fsFsCreateFile(&this->handle, path.c_str(), static_cast(size), 0); - } - - inline Result copy_file(const std::string &source, const std::string &destination) { - File source_f, dest_f; - if (auto rc = this->open_file(source_f, source) | this->open_file(dest_f, destination, FsOpenMode_Write); R_FAILED(rc)) - return rc; - - constexpr std::size_t buf_size = 0x100000; // 1 MiB - auto buf = std::vector(buf_size); - - std::size_t size = source_f.size(), offset = 0; - while (size) { - auto read = source_f.read(static_cast(buf.data()), buf_size, offset); - dest_f.write(buf.data(), read, offset); - offset += read; - size -= read; - } - - source_f.close(); - dest_f.close(); - - return 0; - } - - inline FsDirEntryType get_path_type(const std::string &path) { - FsDirEntryType type; - fsFsGetEntryType(&this->handle, path.c_str(), &type); - return type; - } - - inline bool is_directory(const std::string &path) { - return get_path_type(path) == FsDirEntryType_Dir; - } - - inline bool is_file(const std::string &path) { - return get_path_type(path) == FsDirEntryType_File; - } - - inline FsTimeStampRaw get_timestamp(const std::string &path) { - FsTimeStampRaw ts = {}; - fsFsGetFileTimeStampRaw(&this->handle, path.c_str(), &ts); - return ts; - } - - inline std::uint64_t get_timestamp_created(const std::string &path) { - return this->get_timestamp(path).created; - } - - inline std::uint64_t get_timestamp_modified(const std::string &path) { - return this->get_timestamp(path).modified; - } - - inline Result move_directory(const std::string &old_path, const std::string &new_path) { - return fsFsRenameDirectory(&this->handle, old_path.c_str(), new_path.c_str()); - } - - inline Result move_file(const std::string &old_path, const std::string &new_path) { - return fsFsRenameFile(&this->handle, old_path.c_str(), new_path.c_str()); - } - - inline Result delete_directory(const std::string &path) { - return fsFsDeleteDirectoryRecursively(&this->handle, path.c_str()); - } - - inline Result delete_file(const std::string &path) { - return fsFsDeleteFile(&this->handle, path.c_str()); - } -}; - -} // namespace fs diff --git a/include/lang.hpp b/include/lang.hpp index 76701e3..c8695a1 100644 --- a/include/lang.hpp +++ b/include/lang.hpp @@ -8,7 +8,8 @@ namespace lang { enum class Language { English, Chinese, - /* French, + French, + /* Dutch, Italian, German, diff --git a/include/language_option_page.hpp b/include/language_option_page.hpp index f600eb2..f04e379 100644 --- a/include/language_option_page.hpp +++ b/include/language_option_page.hpp @@ -10,6 +10,7 @@ class LanguageOptionPage : public brls::AppletFrame brls::List* list; brls::ListItem* English; brls::ListItem* Chinese; + brls::ListItem* French; brls::StagedAppletFrame* stagedFrame; diff --git a/res/lang/ch.json b/res/lang/ch.json index 8ad0ad0..3cfca5b 100644 --- a/res/lang/ch.json +++ b/res/lang/ch.json @@ -29,6 +29,8 @@ "v1_1_2_text": "\uE016 Added GUI to disable cheat updates for specific titles.", "v1_1_3": "v1.1.3", "v1_1_3_text": "\uE016 现在显示最新安装的金手指版本.\n\uE016 如果有新的更新可用,现在在应用程序标题中警告", + "v1_2_0": "v1.2.0", + "v1_2_0_text": "\uE016 现在可以使用多种语言(感谢'github.com/tiansongyu').\n\uE016 目前支持中文和法文.", "Ok_button": "确定", "cheats_page.cpp":"", diff --git a/res/lang/en.json b/res/lang/en.json index 257c959..fd465eb 100644 --- a/res/lang/en.json +++ b/res/lang/en.json @@ -2,7 +2,7 @@ "about_tab.cpp":"", "About_Title": "All-in-One Nintendo Switch Updater", "copyright": "AIO-switch-updater is licensed under GPL-3.0\n\u00A9 2020 HamletDuFromage", - "Disclaimers": "\uE016 Aside from cheat codes that are mirrored from the main Gbatemp thread, HamletDuFromage isn't hosting anything. All credits go to respective owners\n\uE016 Links are refreshed every three hours. If a link remains broken after 3 hours have passed, please open a Github issue.\n", + "Disclaimers": "\uE016 Aside from cheat codes that are mirrored from the main Gbatemp thread, HamletDuFromage isn't hosting anything. All credits go to respective owners.\n\uE016 Links are refreshed every three hours. If a link remains broken after 3 hours have passed, please open a Github issue.\n", "app_page.cpp":"", "app_title": "Installed cheats", @@ -30,6 +30,8 @@ "v1_1_2_text": "\uE016 Added GUI to disable cheat updates for specific titles.", "v1_1_3": "v1.1.3", "v1_1_3_text": "\uE016 Now displays the latest installed cheat version.\n\uE016 Now warns in the app title if a new update is available.", + "v1_2_0": "v1.2.0", + "v1_2_0_text": "\uE016 Now multilingual (thanks to 'github.com/tiansongyu').\n\uE016 Chinese and French are currently supported.", "Ok_button": "Ok", "cheats_page.cpp":"", @@ -38,12 +40,12 @@ "cheat_exclude": "Exclude games from recieving cheat updates", "cheat_delete_all_ex": "Delete all existing cheat codes", "cheat_delete_all_cheat": "Delete all cheats", - "cheat_Deleting": "Deleting", + "cheat_Deleting": "Deleting...", "cheat_All_done": "All done!", "choice_page.cpp":"", - "choice_yes":"yes", - "choice_no":"no", + "choice_yes":"Yes", + "choice_no":"No", "chnfirm_page.cpp":"", "Back": "Back", @@ -57,12 +59,12 @@ "getting_paylaod": "getting payload files", "down": "Downloading...", "download_all_done": "All done!", - "description": "Could not find a download link, make sure the Switch has access to the internet.\nIf this problem persists, please open an issue on Github", + "description": "Could not find a download link, make sure the Switch has access to the internet.\nIf this problem persists, please open an issue on Github.", "back": "Back", "Language_option_page.cpp":"", "Language_Option":"Language Option", - "reset_machine":"language has changed .please reboot the app to use the new language", + "reset_machine":"Language has changed. Please reboot the app for the change to take effect", "exclude_page.cpp":"", "exclude_titles": "Exclude titles", @@ -80,7 +82,7 @@ "jc_all_done": "All done!", "jc_con_color": "Joy-Con color swapper", "jc_change": "Changing color. Make sure the Joy-Con are docked. If the process hangs, try docking/undocking the JCs.", - "jc_all_": "All done! You may need to dock/undock your Joy-Cons for the change to take effect", + "jc_all_": "All done! You may need to dock/undock your Joy-Cons for the change to take effect.", "list_donwload.cpp":"", "Getting": "Getting ", diff --git a/res/lang/fr.json b/res/lang/fr.json new file mode 100644 index 0000000..9909237 --- /dev/null +++ b/res/lang/fr.json @@ -0,0 +1,152 @@ +{ + "about_tab.cpp":"", + "About_Title": "All-in-One Nintendo Switch Updater", + "copyright": "AIO-switch-updater est distribuée sous la license GPL-3.0\n\u00A9 2020 HamletDuFromage", + "Disclaimers": "\uE016 A part les cheat codes qui proviennent d'un mirroir d'un topic Gbatemp, HamletDuFromage n'héberge rien. All credits go to respective owners\n\uE016 Les liens sont actualisés toutes les 3 heures. Si un lien demeure brisé après 3 heures, merci de bien vouloir ouvrir une issue.\n", + + "app_page.cpp":"", + "app_title": "Cheats installés", + "app_label": "Les titres suivants ont obtenu des codes de triche lors de la dernière utilisation de l'app. Sachez que même si un jeu a reçu des codes, il se peut que ceux_ci soient incompatibles avec la version actuelle de votre jeu..", + "text_download": "Télécharge:\nDerniers codes de cheat\n\nDe:\n", + "text_download_list": "Télécharger les derniers codes de triche", + "text_title": "Obtension des codes de triche", + "Downloading": "Téléchargement...", + "Extracting": "Extraction...", + "All_done": "Fini!", + + "changelog_page.cpp":"", + "Changelog":"Changelog", + "v1_0_1": "v1.0.1", + "v1_0_1_text": "\uE016 Added dialogue box asking about ini files.\n\uE016 Fixed update app link when not connected to the internet.\n\uE016 Minor fixes here and there.", + "v1_0_2": "v1.0.2", + "v1_0_2_text": "\uE016 Fixed .ini files being handled poorly when installing sigpatches. Now prompts the user if they want to replace hetake_ipl.ini.", + "v1_0_3": "v1.0.3", + "v1_0_3_text": "\uE016 Fixed progress bar sometimes being stuck when extracting.", + "v1_1_0": "v1.1.0", + "v1_1_0_text": "\uE016 Added an option to download payloads to '/bootloader/payloads'.\n\uE016 Cleaned up some stuff, made .ini overwriting cleaner.\n", + "v1_1_1": "v1.1.1", + "v1_1_1_text": "\uE016 Added some safety checks before downloading/extracting.\n\uE016 Added the possibility to copy a payload to '/atmosphere/reboot_payload.bin'\n\uE016 Added changelog in 'Tools'\n", + "v1_1_2": "v1.1.2", + "v1_1_2_text": "\uE016 Added GUI to disable cheat updates for specific titles.", + "v1_1_3": "v1.1.3", + "v1_1_3_text": "\uE016 Now displays the latest installed cheat version.\n\uE016 Now warns in the app title if a new update is available.", + "v1_2_0": "v1.2.0", + "v1_2_0_text": "\uE016 Now multilingual (thanks to 'github.com/tiansongyu').\n\uE016 Chinese and French are currently supported.", + + "Ok_button": "Ok", + + "cheats_page.cpp":"", + "cheat_menu": "Menu de cheat", + "cheat_view": "Voir les codes de triche installés", + "cheat_exclude": "Exclure l'obtension de codes de triche pour certains jeux", + "cheat_delete_all_ex": "Supprimer tous les codes présents sur la carte SD", + "cheat_delete_all_cheat": "Supprimer tous les codes", + "cheat_Deleting": "Suppression...", + "cheat_All_done": "Fini!", + + "choice_page.cpp":"", + "choice_yes":"Oui", + "choice_no":"Non", + + "chnfirm_page.cpp":"", + "Back": "Retour", + "Continue": "Continuer", + + "download_payload_page.cpp":"", + "Download_payloads": "Télécharger des payloads", + "select": "Choisir un payload à télécharger vers '", + "Download": "Télécharger:\n", + "from": "\n\nDe:\n", + "getting_paylaod": "obtension du payload", + "down": "Téléchargement...", + "download_all_done": "Fini!", + "description": "Impossible de trouver un lien de téléchargement, assurez vous que la Switch soit connectée à internet.\nSi ce problème persiste, veuillez ouvrir une issue sur Github.", + "back": "Retour", + + "Language_option_page.cpp":"", + "Language_Option":"Options de langue", + "reset_machine":"La langue a changé, veuillez redémarrer pour que le changement devienne effectif.", + + "exclude_page.cpp":"", + "exclude_titles": "Exclure des titres", + "you_can": "Vous pouvez desactiver les mises-à-jour de codes dans ce menu", + "save": "Sauvegarde et retour", + + "JC_page.cpp":"", + "joy_con": "Changement de couleur des Joy-Cons", + "jc_you_can_1": "Vous pouvez changer la couleur interne de vos Joy-Cons. Assurez vous qu'ils soient bien ancrés à la Swich.\nLes profils de couleur se trouvent dans '", + "jc_you_can_goto": "'. Visitez 'http://bit.ly/JC-color' ", + "jc_you_can_2": "pour générer des profils personalisés.", + "jc_backup": "Sauvegarde du profil actuel", + "jc_color": "Joy-Con color swapper", + "jc_backing": "Sauvegarde du profile actuel, assurez vous que les Joy-Cons soient bien ancrés à la Switch.", + "jc_all_done": "Fini!", + "jc_con_color": "Changement de couleur des Joy-Cons", + "jc_change": "Changement de couleur. Assurez vous que les Joy-Cons soient bien ancrés à la Switch.", + "jc_all_": "Fini! Vous devrez peut-être ancrer/détacher votre Joy-Cons pour que le changement prenne effet", + + "list_donwload.cpp":"", + "Getting": "Obtension ", + "firmware_text": "\uE016 Firmware dumps de 'https://darthsternie.net/switch-firmwares/'. Une fois téléchargés, ils seront dans '/firmware'. Vous pouvez ensuite les installer avec Daybreak ou ChoiDuJour.\n\uE016 FW actuel: ", + "currentCeatsver": "\uE016 Cela téléchargera une archive mise à jour quotidiennement des codes de triche de 'gbatemp.net'. Les codes de triche pour les jeux que vous n'avez pas installés ne seront pas extraits sur votre carte SD. Vous pouvez désactiver les mises à jour pour pour une selection de jeux dans le menu 'Outils->Menu de cheat'.\n\uE016 Version actuelle des cheats : ", + "operation_1": "sigpatches", + "list_sigpatches": "\uE016 Les Sigpatches permettent à votre Switch d'installer et d'exécuter des fichiers NSP non officiels. Assurez-vous de choisir les bons patchs pour votre configuration (Atmosphere pur ou Hekate+Atmosphere).", + "operation_2": "firmware", + "list_not": "not found", + "list_latest": "Dernière version", + "list_app": "app", + "list_cfw": "CFW", + "list_main": "\uE016 Principaux CFWs. Si vous souhaitez utiliser Atmosphere avec Hekate, téléchargez Atmosphere, puis Hekate.", + "list_latest_ver": "Derniers (ver ", + "list_cheats": "codes de triche", + "list_down": "Télécharger:\n", + "list_from": "\n\nFrom:\n", + "list_downing": "Téléchargement...", + "list_extracting": "Exctraction...", + "list_All": "Fini!", + "list_could_done": "Impossible de trouver un lien de téléchargement, assurez vous que la Switch soit connectée à internet.\nSi ce problème persiste, veuillez ouvrir une issue sur Github.", + + "main_frame.cpp":"", + "main_app": " - Nouvelle màj de l'app disponible", + "main_v": " v", + "main_about": "A propos", + "main_update_cfw": "MàJ du CFW", + "main_update_si": "MàJ des sigpatches", + "main_firmwares": "Téléch. des firmwares", + "main_cheats": "Télécharger des cheats", + "main_tools": "Outils", + + "payload_page.cpp":"", + "payload_reboot": "Menu de redémarrage", + "payload_select": " Selectionner un payload à redémarrer.", + "payload_set": "Définit comme reboot_payload.bin", + "payload_success": "Copié avec succès '", + "payload_to": "' vers '", + "payload_ok": "Ok", + "payload_shut": "Eteindre", + "payload_reboot_2": "Redemarrer", + + "tools_tab.cpp":"", + "tool_cheats": "Menu de cheat", + "tool_change": "Changer la couleur des Joy-Cons", + "tool_download": "Télécharger des payloads vers ", + "tool_inject": "Injecter un payload", + "tool_update": "Mettre à jour l'app (v", + "tool_DownLoad": "Télécharger:\nAIO-switch-updater\n\nDe:\n", + "tool_updating": "Mis à jour de l'app", + "tool_downloading":"Téléchargement...", + "tool_extracting": "Extraction....", + "tool_all_done": " Fini!", + "tool_changelog": "Changelog", + + "utils.cpp":"", + "utils_because": "En raison de la taille de l'archive FW, le téléchargement de firmwares en mode Applet n'est pas pris en charge. Veuillez lancer l'application avec un accès total à la RAM.", + "utils_ok": "Ok", + "utils_do": " Voulez-vous écraser l'existant ", + "utils_no": "Non", + "utils_yes": "Oui", + "utils_the": "Le fichier téléchargé n'est pas une archive de sigpatches. Cela est probablement dû à un lien brisé. Si le problème persiste après plus de 3 heures, veuillez ouvrir une issue sur Github.", + "utils_the_downloaded": "Le fichier téléchargé n'est pas une archive de firmare. Cela est probablement dû à un lien rompu. Si le problème persiste après plus de 3 heures, veuillez ouvrir une issue sur Github.", + "ultils_overwrite": "Voulez-vous écraser les fichiers de configuration .ini déja présents?", + "ultis_file": "Le fichier téléchargé n'est pas une archive de CFW. Cela est probablement dû à un lien rompu. Si le problème persiste après plus de 3 heures, veuillez ouvrir une issue sur Github." +} diff --git a/source/changelog_page.cpp b/source/changelog_page.cpp index 9bfd3e3..7657921 100644 --- a/source/changelog_page.cpp +++ b/source/changelog_page.cpp @@ -30,6 +30,9 @@ ChangelogPage::ChangelogPage() : AppletFrame(true, true) verTitles.push_back("v1_1_3"_lang); changes.push_back("v1_1_3_text"_lang); + verTitles.push_back("v1_2_0"_lang); + changes.push_back("v1_2_0_text"_lang); + int nbVersions = verTitles.size(); items.reserve(nbVersions); for(int i = nbVersions -1 ; i >= 0; i--){ diff --git a/source/lang.cpp b/source/lang.cpp index 78d2373..05df9ee 100644 --- a/source/lang.cpp +++ b/source/lang.cpp @@ -1,8 +1,8 @@ #include -#include - -#include -#include +#include "json.hpp" +#include "lang.hpp" +#include +#include using json = nlohmann::json; @@ -32,9 +32,10 @@ Result set_language(Language lang) { break; //if you need add a new language //use it ! - /*case Language::French: + case Language::French: path = "romfs:/lang/fr.json"; break; + /* case Language::Dutch: path = "romfs:/lang/nl.json"; break; @@ -54,22 +55,12 @@ Result set_language(Language lang) { break; } - auto *fp = fopen(path, "r"); - if (!fp) - return 1; - - fseek(fp, 0, SEEK_END); - std::size_t size = ftell(fp); - fseek(fp, 0, SEEK_SET); - - std::string contents(size, 0); - - if (auto read = fread(contents.data(), 1, size, fp); read != size) - return read; - fclose(fp); - - lang_json = json::parse(contents); - + std::fstream langFile; + if(std::filesystem::exists(path)){ + langFile.open(path, std::fstream::in); + langFile >> lang_json; + langFile.close(); + } return 0; } @@ -100,8 +91,9 @@ Result initialize_to_system_language() { return set_language(Language::Chinese); //if you need add a new language //use it ! - /*case SetLanguage_FR: + case SetLanguage_FR: return set_language(Language::French); + /* case SetLanguage_NL: return set_language(Language::Dutch); case SetLanguage_IT: diff --git a/source/language_option_page.cpp b/source/language_option_page.cpp index 4d692e6..ad7f87d 100644 --- a/source/language_option_page.cpp +++ b/source/language_option_page.cpp @@ -15,12 +15,12 @@ LanguageOptionPage::LanguageOptionPage() : AppletFrame(true, true) nlohmann::json json_file; json_file["language"]=(int)lang::Language::English; - std::ofstream o("/switch/AIO-switch-updater/config.ini"); + std::ofstream o(APP_LANG); o<addStage( - new ConfirmPage(stagedFrame, "reset_machine"_lang,false) + new ConfirmPage(stagedFrame, "reset_machine"_lang, true) ); brls::Application::pushView(stagedFrame); @@ -30,15 +30,30 @@ LanguageOptionPage::LanguageOptionPage() : AppletFrame(true, true) Chinese->getClickEvent()->subscribe([&](brls::View* view){ nlohmann::json json_file; json_file["language"]=(int)lang::Language::Chinese; - std::ofstream o("/switch/AIO-switch-updater/config.ini"); + std::ofstream o(APP_LANG); o<addStage( - new ConfirmPage(stagedFrame, "reset_machine"_lang,false) + new ConfirmPage(stagedFrame, "reset_machine"_lang, true) ); brls::Application::pushView(stagedFrame); }); list->addView(Chinese); + + French = new brls::ListItem("Français"); + French->getClickEvent()->subscribe([&](brls::View* view){ + nlohmann::json json_file; + json_file["language"]=(int)lang::Language::French; + std::ofstream o(APP_LANG); + o<addStage( + new ConfirmPage(stagedFrame, "reset_machine"_lang, true) + ); + brls::Application::pushView(stagedFrame); + }); + list->addView(French); this->setContentView(list); } \ No newline at end of file diff --git a/source/list_download_tab.cpp b/source/list_download_tab.cpp index bafacae..a3dcc74 100644 --- a/source/list_download_tab.cpp +++ b/source/list_download_tab.cpp @@ -73,6 +73,7 @@ ListDownloadTab::ListDownloadTab(archiveType type) : std::string url = std::get<1>(links)[i]; std::string text("list_down"_lang + std::get<0>(links)[i] + "list_from"_lang + url); linkItems[i] = new brls::ListItem(std::get<0>(links)[i]); + linkItems[i]->setHeight(LISTITEM_HEIGHT); linkItems[i]->getClickEvent()->subscribe([&, text, url, type, operation](brls::View* view) { brls::StagedAppletFrame* stagedFrame = new brls::StagedAppletFrame(); stagedFrame->setTitle(operation); diff --git a/source/main.cpp b/source/main.cpp index f9ae83b..4f3632e 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -49,30 +49,10 @@ int main(int argc, char* argv[]) brls::Logger::setLogLevel(brls::LogLevel::DEBUG); brls::Logger::debug("Start"); - - //start code by tiansongyu please clean the code if you want - //checkout the /switch/AIO-switch-updater/config.ini - //save the language mode - //or you can use this - /* - if (auto rc = lang::initialize_to_system_language(); R_FAILED(rc)) - brls::Logger::debug("Failed to init language: %#x, will fall back to key names\n", rc); - */ - //this code will automatically choose the machine language that the user use - //there are two ways to set the language . choose that you like way :D - const char* switch_dir= "/switch/"; - if(opendir(switch_dir)==NULL) - { - mkdir(switch_dir,0755); - } - const char* aio_config_file = "/switch/AIO-switch-updater/"; - if(opendir(aio_config_file)==NULL) - { - mkdir(aio_config_file,0755); - } - if(access("/switch/AIO-switch-updater/config.ini",F_OK) ==0) + //start code by tiansongyu + if(std::filesystem::exists(APP_LANG)) { - std::ifstream i("/switch/AIO-switch-updater/config.ini"); + std::ifstream i(APP_LANG); nlohmann::json lang_json; i>>lang_json; int tmp_number =lang_json["language"]; @@ -86,7 +66,7 @@ int main(int argc, char* argv[]) int language_number = (int)lang::get_current_language(); nlohmann::json json_file; json_file["language"]=language_number; - std::ofstream o("/switch/AIO-switch-updater/config.ini"); + std::ofstream o(APP_LANG); o<getClickEvent()->subscribe([&](brls::View* view){ brls::Application::pushView(new CheatsPage()); }); + cheats->setHeight(LISTITEM_HEIGHT); this->addView(cheats); JCcolor = new brls::ListItem("tool_change"_lang); JCcolor->getClickEvent()->subscribe([&](brls::View* view){ brls::Application::pushView(new JCPage()); }); + JCcolor->setHeight(LISTITEM_HEIGHT); this->addView(JCcolor); downloadPayload = new brls::ListItem("tool_download"_lang + std::string(BOOTLOADER_PL_PATH)); @@ -25,6 +27,7 @@ ToolsTab::ToolsTab(std::string tag) : brls::List() rebootPayload->getClickEvent()->subscribe([&](brls::View* view){ brls::Application::pushView(new PayloadPage()); }); + rebootPayload->setHeight(LISTITEM_HEIGHT); this->addView(rebootPayload); if(!tag.empty() && tag != APP_VERSION){ @@ -47,6 +50,7 @@ ToolsTab::ToolsTab(std::string tag) : brls::List() ); brls::Application::pushView(stagedFrame); }); + updateApp->setHeight(LISTITEM_HEIGHT); this->addView(updateApp); } @@ -54,11 +58,13 @@ ToolsTab::ToolsTab(std::string tag) : brls::List() changelog->getClickEvent()->subscribe([&](brls::View* view){ brls::Application::pushView(new ChangelogPage()); }); + changelog->setHeight(LISTITEM_HEIGHT); this->addView(changelog); language = new brls::ListItem("Language_Option"_lang); language->getClickEvent()->subscribe([&](brls::View* view){ brls::Application::pushView(new LanguageOptionPage()); }); + language->setHeight(LISTITEM_HEIGHT); this->addView(language); } \ No newline at end of file