1
0
Fork 0
mirror of https://github.com/HamletDuFromage/aio-switch-updater.git synced 2024-11-24 18:42:05 +00:00

Add a multi-language option and a Chinese option

This commit is contained in:
tiansongyu 2020-10-05 08:59:46 +08:00
parent 843edbb5c9
commit 79ef5aadd6
29 changed files with 947 additions and 153 deletions

2
.gitmodules vendored
View file

@ -3,4 +3,4 @@
url = https://github.com/HamletDuFromage/zipper
[submodule "lib/borealis"]
path = lib/borealis
url = https://github.com/natinusala/borealis
url = https://github.com/tiansongyu/borealis

View file

@ -47,7 +47,7 @@ APP_TITLE := All-in-One Switch Updater
APP_AUTHOR := HamletDuFromage
APP_VERSION := 1.1.3
#ROMFS := $(BUILD)/romfs
ROMFS = res
BOREALIS_PATH := lib/borealis
#BOREALIS_RESOURCES := romfs:/borealis/
#APP_RESOURCES := romfs:/

BIN
icon.jpg Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View file

@ -2,8 +2,6 @@
#include <borealis.hpp>
#include <borealis.hpp>
class AboutTab : public brls::List
{
public:

227
include/fs.hpp Normal file
View file

@ -0,0 +1,227 @@
#pragma once
#include <cstdint>
#include <string>
#include <vector>
#include <switch.h>
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<FsDirectoryEntry> list() {
std::int64_t total = 0;
auto c = this->count();
auto entries = std::vector<FsDirectoryEntry>(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<std::int64_t>(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<std::int64_t>(offset), buf, static_cast<std::uint64_t>(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<std::int64_t>(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<std::int64_t>(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<std::uint8_t>(buf_size);
std::size_t size = source_f.size(), offset = 0;
while (size) {
auto read = source_f.read(static_cast<void *>(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

35
include/lang.hpp Normal file
View file

@ -0,0 +1,35 @@
#pragma once
#include <string>
#include <json.hpp>
#include <switch.h>
namespace lang {
enum class Language {
English,
Chinese,
/* French,
Dutch,
Italian,
German,
Spanish,*/
Default,
};
const nlohmann::json &get_json();
Language get_current_language();
Result set_language(Language lang);
Result initialize_to_system_language();
std::string get_string(std::string key, const nlohmann::json &json = get_json());
namespace literals {
inline std::string operator ""_lang(const char *key, size_t size) {
return get_string(std::string(key, size));
}
} // namespace literals
}; // namespace lang

View file

@ -0,0 +1,18 @@
#pragma once
#include <borealis.hpp>
#include "app_page.hpp"
#include "exclude_page.hpp"
class LanguageOptionPage : public brls::AppletFrame
{
private:
brls::List* list;
brls::ListItem* English;
brls::ListItem* Chinese;
brls::StagedAppletFrame* stagedFrame;
public:
LanguageOptionPage();
};

View file

@ -7,6 +7,7 @@
#include "payload_page.hpp"
#include "download_payload_page.hpp"
#include "changelog_page.hpp"
#include "language_option_page.hpp"
#include "JC_page.hpp"
#include "extract.hpp"
#include "utils.hpp"
@ -20,6 +21,8 @@ class ToolsTab : public brls::List
brls::ListItem* rebootPayload;
brls::ListItem* downloadPayload;
brls::ListItem* changelog;
brls::ListItem* language;
brls::StagedAppletFrame* stagedFrame;
public:

0
pack_release.sh Executable file → Normal file
View file

150
res/lang/ch.json Normal file
View file

@ -0,0 +1,150 @@
{
"about_tab.cpp":"",
"About_Title": "多工具合一任天堂Switch更新器",
"copyright": "多工具合一任天堂Switch更新器遵循 GPL-3.0 协议\n\u00A9 2020 HamletDuFromage",
"Disclaimers": "\uE016 除了从主Gbatemp线程镜像的金手指外,本软件作者不拥有任何金手指。所有的信用归于各自的所有者\n\uE016 链接每三个小时刷新一次. 如果链接在3小时后仍然有问题请到Github给作者 issue.\n",
"app_page.cpp":"",
"app_title": "安装金手指",
"app_label": "以下游戏在您上次使用该应用程序时已经收到作弊代码更新。请注意,尽管已经更新下载的游戏,作弊可能不匹配其当前更新",
"text_download": "下载中:\n最新的金手指\n\n来自:\n",
"text_download_list": "下载最新的金手指",
"text_title": "获取金手指",
"Downloading": "下载中...",
"Extracting": "解压中...",
"All_done": "完成!",
"changelog_page.cpp":"",
"Changelog": "更新日志",
"v1_0_1": "v1.0.1",
"v1_0_1_text": "\uE016 增加了询问ini文件的对话框.\n\uE016 修复在没有链接到网络时更新软件链接的问题.\n\uE016 小更新.",
"v1_0_2": "v1.0.2",
"v1_0_2_text": "\uE016 修复ini文件处理不当安装签名时,现在提示用户是否需要替换hetake_ipl.ini文件",
"v1_0_3": "v1.0.3",
"v1_0_3_text": "\uE016 修复进度条在解压时有时被卡住的问题",
"v1_1_0": "v1.1.0",
"v1_1_0_text": "\uE016 增加了一个选项下载有效载荷'/bootloader/注入文件'.\n\uE016 清理了一些东西,使.ini覆盖更干净。\n",
"v1_1_1": "v1.1.1",
"v1_1_1_text": "\uE016 增加了下载/解压前的安全检查\n\uE016 增加了复制注入文件到'/atmosphere/reboot_payload.bin的可能性'\n\uE016 在'工具'中添加了更新日志\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 现在显示最新安装的金手指版本.\n\uE016 如果有新的更新可用,现在在应用程序标题中警告",
"Ok_button": "确定",
"cheats_page.cpp":"",
"cheat_menu": "金手指菜单",
"cheat_view": "查看已安装金手指",
"cheat_exclude": "下载的金手指中,不存在可用金手指的游戏",
"cheat_delete_all_ex": "删除所有现有的金手指",
"cheat_delete_all_cheat": "删除所有金手指",
"cheat_Deleting": "删除中",
"cheat_All_done": "完成!",
"choice_page.cpp":"",
"choice_yes":"是",
"choice_no":"否",
"chnfirm_page.cpp":"",
"Back": "返回",
"Continue": "继续",
"download_payload_page.cpp":"",
"Download_payloads": "下载注入程序",
"select": "选择要下载的注入文件'",
"Download": "下载中:\n",
"from": "\n\n从:\n",
"getting_paylaod": "获取注入文件",
"down": "下载中...",
"download_all_done": "完成!",
"description": "如果点击后界面没有反应,请确认switch是否连接网络\n如果检查后问题依然存在,请到github上给我提交issue",
"back": "返回",
"exclude_page.cpp":"",
"exclude_titles": "不包括的游戏",
"you_can": "你可以用这个菜单关闭金手指更新",
"save": "保存并返回",
"JC_page.cpp":"",
"joy_con": "Joy-Con 颜色更换器",
"jc_you_can_1": "你可以改变游戏机里的手柄颜色确保手柄已经插入switch.\n颜色风格文件存储在 ' ",
"jc_you_can_goto": "'. 去这里 'http://bit.ly/JC-color' ",
"jc_you_can_2": "去制作你自己的颜色主题文件",
"jc_backup": "备份当前主题文件",
"jc_color": "手柄颜色修改器",
"jc_backing": "备份当前的颜色配置文件,确定手柄已经插入switch如果进程卡住请拔插手柄反复试一下.",
"jc_all_done": "完成!",
"jc_con_color": "手柄颜色转换器",
"jc_change": "改变颜色,确保手柄已经被插入.如果进程卡住,请拔插手柄反复试一下 ",
"jc_all_": "完成,你可能需要拔插手柄来启动刚才的颜色更新",
"Language_option_page.cpp":"",
"Language_Option":"语言设置",
"reset_machine":"语言已经改变,请重启程序更换新语言",
"list_donwload.cpp":"",
"Getting": "获取 ",
"firmware_text": "\uE016 固件从 'https://darthsternie.net/switch-firmwares/ 下载'. 下载之后,文件会被解压到 '/firmware'. 你可以使用 Daybreak 或者 ChoiDuJour (大白兔)安装他们.\n\uE016 当前FW版本: ",
"currentCeatsver": "\uE016 这个金手指的下载和更新地址是 'gbatemp.net'. 你的机器中没有的游戏,这些金手指不会解压到你的SD卡中 你可以在'工具->金手指菜单' 关闭金手指更新.\n\uE016 当前金手指版本: ",
"operation_1": "数字签名",
"list_sigpatches": "\uE016 数字签名允许你运行没被任天堂收录的nsp文件. 确保为您的设置选择了正确的签名 (pure Atmosphere (大气层)or Hekate+Atmosphere).",
"operation_2": "固件",
"list_not": "没有找到",
"list_latest": "最新版本",
"list_app": "应用",
"list_cfw": "自制系统",
"list_main": "\uE016 主要 Switch 破解系统. 如果你使用 Atmosphere with Hekate, 下载 Atmosphere, 然后 Hekate.",
"list_latest_ver": "最新版本 (版本 ",
"list_cheats": "金手指",
"list_down": "下载中:\n",
"list_from": "\n\n从:\n",
"list_downing": "下载中...",
"list_extracting": "解压中...",
"list_All": "完成!",
"list_could_done": "如果点击功能后,界面没有反应,确保switch已经连接互联网\n如果问题依然存在\n请到github(https://github.com/HamletDuFromage/AIO-switch-updater)上为作者提交issue.",
"main_frame.cpp":"",
"main_app": " - 最版本可用,请更新最新版本",
"main_v": " 版本号",
"main_about": "介绍",
"main_update_cfw": "更新自制系统版本",
"main_update_si": "更新数字签名",
"main_firmwares": "下载破解固件",
"main_cheats": "下载金手指",
"main_tools": "工具",
"payload_page.cpp":"",
"payload_reboot": "重启菜单",
"payload_select": "选择一个注入文件重启.",
"payload_set": "设置 reboot_payload.bin",
"payload_success": "成功复制 '",
"payload_to": "' to '",
"payload_ok": "确定",
"payload_shut": "停止",
"payload_reboot_2": "重启",
"tools_tab.cpp":"",
"tool_cheats": "金手指菜单",
"tool_change": "改变手柄颜色",
"tool_download": "下载注入文件存储到 ",
"tool_inject": "启用注入文件",
"tool_update": "更新软件版本 (v",
"tool_DownLoad": "下载中:\nAIO-switch-updater\n\n从:\n",
"tool_updating": "更新软件",
"tool_downloading":"下载中...",
"tool_extracting": "解压中....",
"tool_all_done": " 成功完成!",
"tool_changelog": "更新日志",
"utils.cpp":"",
"utils_because": "由于 FW archive的文件大小, 仅支持在 Applet Mode 模式下更新固件. (百度查询进入applet Mode模式方法)请让程序在Applet Mode下启动",
"utils_ok": "确定",
"utils_do": "你想要覆盖已经存在的",
"utils_no": "否",
"utils_yes": "是",
"utils_the": "下载的文件没有数字签名认证. 可能是由于链接出问题了.如果3个小时还有类似的问题, 请到github上给作者提出issue.",
"utils_the_downloaded": "下载的文件没有数字签名认证. 可能是由于链接出问题了.如果3个小时还有类似的问题, 请到github上给作者提出issue",
"ultils_overwrite": "你想要覆盖已经存在的.ini 设置文件吗?",
"ultis_file": "下载的文件CFW出现问题. 可能是由于链接出问题了.如果3个小时还有类似的问题, 请到github上给作者提出issue."
}

149
res/lang/en.json Normal file
View file

@ -0,0 +1,149 @@
{
"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",
"app_page.cpp":"",
"app_title": "Installed cheats",
"app_label": "The following titles have recieved cheat code updates the last time you used the app. Please note that despite having been downloaded for a game, cheats may not match its current update.",
"text_download": "Downloading:\nLatest cheat codes\n\nFrom:\n",
"text_download_list": "Download latest cheat codes",
"text_title": "Getting cheat codes",
"Downloading": "Downloading...",
"Extracting": "Extracting...",
"All_done": "All done!",
"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.",
"Ok_button": "Ok",
"cheats_page.cpp":"",
"cheat_menu": "Cheats menu",
"cheat_view": "View installed cheats",
"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_All_done": "All done!",
"choice_page.cpp":"",
"choice_yes":"yes",
"choice_no":"no",
"chnfirm_page.cpp":"",
"Back": "Back",
"Continue": "Continue",
"download_payload_page.cpp":"",
"Download_payloads": "Download payloads",
"select": "Select a payload to download to '",
"Download": "Downloading:\n",
"from": "\n\nFrom:\n",
"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",
"back": "Back",
"Language_option_page.cpp":"",
"Language_Option":"Language Option",
"reset_machine":"language has changed .please reboot the app to use the new language",
"exclude_page.cpp":"",
"exclude_titles": "Exclude titles",
"you_can": "You can turn off cheat updates with this menu",
"save": "Save choice and return",
"JC_page.cpp":"",
"joy_con": "Joy-Con color swapper",
"jc_you_can_1": "You can change the internal color of your Joy-Cons. Make sure they're docked.\nColor profiles are stored in '",
"jc_you_can_goto": "'. Go to 'http://bit.ly/JC-color' ",
"jc_you_can_2": "to generate your own custom profiles.",
"jc_backup": "Backup current color profile",
"jc_color": "Joy-Con color swapper",
"jc_backing": "Backing up the current color profile. Make sure the Joy-Con are docked. If the process hangs, try docking/undocking the JCs.",
"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",
"list_donwload.cpp":"",
"Getting": "Getting ",
"firmware_text": "\uE016 Firmware dumps from 'https://darthsternie.net/switch-firmwares/'. Once downloaded, it will be extracted in '/firmware'. You can then install the update through Daybreak or ChoiDuJour.\n\uE016 Current FW: ",
"currentCeatsver": "\uE016 This will download a daily updated archive of cheat codes from 'gbatemp.net'. Cheat codes for games you don't have installed won't be extracted to your SD card. You can turn off cheat updated in 'Tools->Cheat menu'.\n\uE016 Current cheats version: ",
"operation_1": "sigpatches",
"list_sigpatches": "\uE016 Sigpatches allow your Switch to install and run unofficial NSP file. Make sure you pick the correct sigpatches for your setup (pure Atmosphere or Hekate+Atmosphere).",
"operation_2": "firmware",
"list_not": "not found",
"list_latest": "Latest version",
"list_app": "app",
"list_cfw": "CFW",
"list_main": "\uE016 Main Switch CFWs. If you want to use Atmosphere with Hekate, download Atmosphere, then Hekate.",
"list_latest_ver": "Latest (ver ",
"list_cheats": "cheats",
"list_down": "Downloading:\n",
"list_from": "\n\nFrom:\n",
"list_downing": "Downloading...",
"list_extracting": "Extracting...",
"list_All": "All done!",
"list_could_done": "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.",
"main_frame.cpp":"",
"main_app": " - New app update available",
"main_v": " v",
"main_about": "About",
"main_update_cfw": "Update CFW",
"main_update_si": "Update sigpatches",
"main_firmwares": "Download firmwares",
"main_cheats": "Download cheats",
"main_tools": "Tools",
"payload_page.cpp":"",
"payload_reboot": "Reboot menu",
"payload_select": " Select a payload to reboot to.",
"payload_set": "Set as reboot_payload.bin",
"payload_success": "Successfully copied '",
"payload_to": "' to '",
"payload_ok": "Ok",
"payload_shut": "Shut Down",
"payload_reboot_2": "Reboot",
"tools_tab.cpp":"",
"tool_cheats": "Cheats menu",
"tool_change": "Change the Joy-Cons color",
"tool_download": "Dowload payloads to ",
"tool_inject": "Inject payload",
"tool_update": "Update the app (v",
"tool_DownLoad": "Downloading:\nAIO-switch-updater\n\nFrom:\n",
"tool_updating": "Updating app",
"tool_downloading":"Downloading...",
"tool_extracting": "Extracting....",
"tool_all_done": " All done!",
"tool_changelog": "Changelog",
"utils.cpp":"",
"utils_because": "Because of the size of the FW archive, downloading firmwares in Applet Mode is not supported. Please launch the app with full RAM access.",
"utils_ok": "Ok",
"utils_do": " Do you want to overwrite existing ",
"utils_no": "No",
"utils_yes": "Yes",
"utils_the": "The downloaded file is not a sigpatches archive. This is most likely due to a broken link. If the problem persists after more than 3 hours, please open an issue on Github.",
"utils_the_downloaded": "The downloaded file is not a firmware archive. This is most likely due to a broken link. If the problem persists after more than 3 hours, please open an issue on Github.",
"ultils_overwrite": "Do you want to overwrite existing .ini config files?",
"ultis_file": "The downloaded file is not a CFW archive. This is most likely due to a broken link. If the problem persists after more than 3 hours, please open an issue on Github."
}

View file

@ -1,26 +1,25 @@
#include "JC_page.hpp"
#include "lang.hpp"
using namespace lang::literals;
JCPage::JCPage() : AppletFrame(true, true)
{
this->setTitle("Joy-Con color swapper");
this->setTitle("joy_con"_lang);
list = new brls::List();
std::string labelText = "You can change the internal color of your Joy-Cons. Make sure they're docked.\n"\
"Color profiles are stored in '" + std::string(COLOR_PROFILES_PATH) + "'. Go to 'http://bit.ly/JC-color' "\
"to generate your own custom profiles.";
std::string labelText = "jc_you_can_1"_lang + std::string(COLOR_PROFILES_PATH) + "jc_you_can_goto"\
"jc_you_can_2"_lang;
label = new brls::Label(brls::LabelStyle::DESCRIPTION, labelText, true);
list->addView(label);
backup = new brls::ListItem("Backup current color profile");
backup = new brls::ListItem("jc_backup"_lang);
backup->getClickEvent()->subscribe([&](brls::View* view) {
brls::StagedAppletFrame* stagedFrame = new brls::StagedAppletFrame();
stagedFrame->setTitle("Joy-Con color swapper");
stagedFrame->setTitle("jc_color"_lang);
stagedFrame->addStage(
new WorkerPage(stagedFrame, "Backing up the current color profile. Make sure the Joy-Con are docked. "\
"If the process hangs, try docking/undocking the JCs.",
new WorkerPage(stagedFrame, "jc_backing"_lang,
[](){backupJCColor(COLOR_PROFILES_PATH);})
);
stagedFrame->addStage(
new ConfirmPage(stagedFrame, "All done!", true)
new ConfirmPage(stagedFrame, "jc_all_done"_lang, true)
);
brls::Application::pushView(stagedFrame);
});
@ -38,14 +37,13 @@ JCPage::JCPage() : AppletFrame(true, true)
items[i] = new brls::ListItem(names[i]);
items[i]->getClickEvent()->subscribe([&, value](brls::View* view) {
brls::StagedAppletFrame* stagedFrame = new brls::StagedAppletFrame();
stagedFrame->setTitle("Joy-Con color swapper");
stagedFrame->setTitle("jc_concolor"_lang);
stagedFrame->addStage(
new WorkerPage(stagedFrame, "Changing color. Make sure the Joy-Con are docked. "\
"If the process hangs, try docking/undocking the JCs.",
new WorkerPage(stagedFrame, "jc_changing"_lang,
[value](){changeJCColor(value);})
);
stagedFrame->addStage(
new ConfirmPage(stagedFrame, "All done! You may need to dock/undock your Joy-Cons for the change to take effect", true)
new ConfirmPage(stagedFrame, "jc_all_"_lang, true)
);
brls::Application::pushView(stagedFrame);
});

View file

@ -1,11 +1,13 @@
#include "about_tab.hpp"
#include "lang.hpp"
using namespace lang::literals;
AboutTab::AboutTab()
{
// Subtitle
brls::Label *subTitle = new brls::Label(
brls::LabelStyle::REGULAR,
"All-in-One Nintendo Switch Updater",
"About_Title"_lang ,
true
);
subTitle->setHorizontalAlign(NVG_ALIGN_CENTER);
@ -14,8 +16,7 @@ AboutTab::AboutTab()
// Copyright
brls::Label *copyright = new brls::Label(
brls::LabelStyle::DESCRIPTION,
"AIO-switch-updater is licensed under GPL-3.0\n" \
"\u00A9 2020 HamletDuFromage",
"copyright"_lang,
true
);
copyright->setHorizontalAlign(NVG_ALIGN_CENTER);
@ -25,9 +26,7 @@ AboutTab::AboutTab()
this->addView(new brls::Header("Disclaimers"));
brls::Label *links = new brls::Label(
brls::LabelStyle::SMALL,
"\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"_lang,
true
);
this->addView(links);

View file

@ -1,14 +1,14 @@
#include "app_page.hpp"
//TODO: Serialize it in extract.cpp
#include "lang.hpp"
using namespace lang::literals;
AppPage::AppPage() : AppletFrame(true, true)
{
this->setTitle("Installed cheats");
this->setTitle("app_title"_lang);
list = new brls::List();
label = new brls::Label(
brls::LabelStyle::DESCRIPTION,
"The following titles have recieved cheat code updates the last time you used the app. Please note that despite having been "\
"downloaded for a game, cheats may not match its current update.",
"app_label"_lang,
true
);
list->addView(label);
@ -60,7 +60,7 @@ AppPage::AppPage() : AppletFrame(true, true)
i++;
}
}
std::string text("Downloading:\nLatest cheat codes\n\nFrom:\n");
std::string text("text_download");
std::string url = "";
switch(getCFW()){
case ams:
@ -74,22 +74,22 @@ AppPage::AppPage() : AppletFrame(true, true)
break;
}
text += url;
download = new brls::ListItem("Download latest cheat codes");
download = new brls::ListItem("text_download_list"_lang);
archiveType type = cheats;
download->getClickEvent()->subscribe([&, url, text, type](brls::View* view) {
brls::StagedAppletFrame* stagedFrame = new brls::StagedAppletFrame();
stagedFrame->setTitle("Getting cheat codes");
stagedFrame->setTitle("text_title"_lang);
stagedFrame->addStage(
new ConfirmPage(stagedFrame, text)
);
stagedFrame->addStage(
new WorkerPage(stagedFrame, "Downloading...", [url, type](){downloadArchive(url, type);})
new WorkerPage(stagedFrame, "Downloading"_lang, [url, type](){downloadArchive(url, type);})
);
stagedFrame->addStage(
new WorkerPage(stagedFrame, "Extracting...", [type](){extractArchive(type);})
new WorkerPage(stagedFrame, "Extracting"_lang, [type](){extractArchive(type);})
);
stagedFrame->addStage(
new ConfirmPage(stagedFrame, "All done!", true)
new ConfirmPage(stagedFrame, "All_done"_lang, true)
);
brls::Application::pushView(stagedFrame);
});

View file

@ -1,39 +1,34 @@
#include "changelog_page.hpp"
#include "lang.hpp"
using namespace lang::literals;
ChangelogPage::ChangelogPage() : AppletFrame(true, true)
{
this->setTitle("Changelog");
this->setTitle("Changelog"_lang);
list = new brls::List();
std::vector<std::string> verTitles;
std::string change;
std::vector<std::string> changes;
verTitles.push_back("v1.0.1");
changes.push_back("\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.");
verTitles.push_back("v1_0_1"_lang);
changes.push_back("v1_0_1_text"_lang);
verTitles.push_back("v1.0.2");
changes.push_back("\uE016 Fixed .ini files being handled poorly when installing sigpatches. Now prompts the user if they want to replace hetake_ipl.ini.");
verTitles.push_back("v1_0_2"_lang);
changes.push_back("v1_0_2_text"_lang);
verTitles.push_back("v1.0.3");
changes.push_back("\uE016 Fixed progress bar sometimes being stuck when extracting.");
verTitles.push_back("v1_0_3"_lang);
changes.push_back("v1_0_3_text"_lang);
verTitles.push_back("v1.1.0");
changes.push_back("\uE016 Added an option to download payloads to '/bootloader/payloads'.\n"\
"\uE016 Cleaned up some stuff, made .ini overwriting cleaner.\n");
verTitles.push_back("v1_1_0"_lang);
changes.push_back("v1_1_0_text"_lang);
verTitles.push_back("v1.1.1");
changes.push_back("\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");
verTitles.push_back("v1_1_1"_lang);
changes.push_back("v1_1_1_text"_lang);
verTitles.push_back("v1.1.2");
changes.push_back("\uE016 Added GUI to disable cheat updates for specific titles.");
verTitles.push_back("v1_1_2"_lang);
changes.push_back("v1_1_2_text"_lang);
verTitles.push_back("v1.1.3");
changes.push_back("\uE016 Now displays the latest installed cheat version.\n"\
"\uE016 Now warns in the app title if a new update is available.");
verTitles.push_back("v1_1_3"_lang);
changes.push_back("v1_1_3_text"_lang);
int nbVersions = verTitles.size();
items.reserve(nbVersions);
@ -45,7 +40,7 @@ ChangelogPage::ChangelogPage() : AppletFrame(true, true)
brls::GenericEvent::Callback callback = [dialog](brls::View* view) {
dialog->close();
};
dialog->addButton("Ok", callback);
dialog->addButton("Ok_button"_lang, callback);
dialog->setCancelable(true);
dialog->open();
});

View file

@ -1,32 +1,33 @@
#include "cheats_page.hpp"
#include "lang.hpp"
using namespace lang::literals;
CheatsPage::CheatsPage() : AppletFrame(true, true)
{
this->setTitle("Cheats menu");
this->setTitle("cheat_menu"_lang);
list = new brls::List();
view = new brls::ListItem("View installed cheats");
view = new brls::ListItem("cheat_view"_lang);
view->getClickEvent()->subscribe([&](brls::View* view){
brls::Application::pushView(new AppPage());
});
list->addView(view);
exclude = new brls::ListItem("Exclude games from recieving cheat updates");
exclude = new brls::ListItem("cheat_exclude"_lang);
exclude->getClickEvent()->subscribe([&](brls::View* view){
brls::Application::pushView(new ExcludePage());
});
list->addView(exclude);
deleteCheats = new brls::ListItem("Delete all existing cheat codes");
deleteCheats = new brls::ListItem("cheat_delete_all_ex"_lang);
deleteCheats->getClickEvent()->subscribe([&](brls::View* view){
stagedFrame = new brls::StagedAppletFrame();
stagedFrame->setTitle("Delete all cheats");
stagedFrame->setTitle("cheat_delete_all_cheat"_lang);
stagedFrame->addStage(
new WorkerPage(stagedFrame, "Deleting", [](){removeCheats(getCFW());})
new WorkerPage(stagedFrame, "cheat_Deleting"_lang , [](){removeCheats(getCFW());})
);
stagedFrame->addStage(
new ConfirmPage(stagedFrame, "All done!", true)
new ConfirmPage(stagedFrame, "cheat_All_done"_lang, true)
);
brls::Application::pushView(stagedFrame);
});

View file

@ -1,5 +1,6 @@
#include "choice_page.hpp"
#include "lang.hpp"
using namespace lang::literals;
ChoicePage::ChoicePage(brls::StagedAppletFrame* frame, std::string text)
{
this->yes = (new brls::Button(brls::ButtonStyle::BORDERLESS))->setLabel("yes");

View file

@ -1,8 +1,9 @@
#include "confirm_page.hpp"
#include "lang.hpp"
using namespace lang::literals;
ConfirmPage::ConfirmPage(brls::StagedAppletFrame* frame, std::string text, bool done): done(done)
{
this->button = (new brls::Button(brls::ButtonStyle::BORDERLESS))->setLabel(done ? "Back": "Continue");
this->button = (new brls::Button(brls::ButtonStyle::BORDERLESS))->setLabel(done ? "Back"_lang: "Continue"_lang);
this->button->setParent(this);
this->button->getClickEvent()->subscribe([frame, this](View* view) {
if (!frame->isLastStage()) frame->nextStage();
@ -15,7 +16,7 @@ ConfirmPage::ConfirmPage(brls::StagedAppletFrame* frame, std::string text, bool
this->label->setHorizontalAlign(NVG_ALIGN_CENTER);
this->label->setParent(this);
this->registerAction("Back", brls::Key::B, [this] {
this->registerAction("Back"_lang, brls::Key::B, [this] {
brls::Application::popView();
return true;
});
@ -26,7 +27,7 @@ void ConfirmPage::draw(NVGcontext* vg, int x, int y, unsigned width, unsigned he
if(!this->done){
auto end = std::chrono::high_resolution_clock::now();
auto missing = std::max(1l - std::chrono::duration_cast<std::chrono::seconds>(end - start).count(), 0l);
auto text = std::string("Continue");
auto text = std::string("Continue"_lang);
if (missing > 0) {
this->button->setLabel(text + " (" + std::to_string(missing) + ")");
this->button->setState(brls::ButtonState::DISABLED);

View file

@ -1,12 +1,13 @@
#include "download_payload_page.hpp"
#include "lang.hpp"
using namespace lang::literals;
DownloadPayloadPage::DownloadPayloadPage() : AppletFrame(true, true)
{
this->setTitle("Download payloads");
this->setTitle("Download_payloads"_lang);
list = new brls::List();
label = new brls::Label(
brls::LabelStyle::DESCRIPTION,
"Select a payload to download to '" + std::string(BOOTLOADER_PL_PATH) + "'.",
"select"_lang + std::string(BOOTLOADER_PL_PATH) + "'."_lang,
true
);
list->addView(label);
@ -17,20 +18,20 @@ DownloadPayloadPage::DownloadPayloadPage() : AppletFrame(true, true)
for (int i = 0; i<nbLinks; i++){
std::string url = std::get<1>(links)[i];
std::string path = std::string(BOOTLOADER_PL_PATH) + std::get<0>(links)[i];
std::string text("Downloading:\n" + std::get<0>(links)[i] + "\n\nFrom:\n" + url);
std::string text("Download"_lang + std::get<0>(links)[i] + "from"_lang+ url);
items[i] = new brls::ListItem(std::get<0>(links)[i]);
items[i]->getClickEvent()->subscribe([&, text, url, path](brls::View* view) {
createTree(BOOTLOADER_PL_PATH);
brls::StagedAppletFrame* stagedFrame = new brls::StagedAppletFrame();
stagedFrame->setTitle("Getting payload");
stagedFrame->setTitle("getting_paylaod"_lang);
stagedFrame->addStage(
new ConfirmPage(stagedFrame, text)
);
stagedFrame->addStage(
new WorkerPage(stagedFrame, "Downloading...", [url, path](){downloadFile(url.c_str(), path.c_str(), OFF);})
new WorkerPage(stagedFrame, "down"_lang, [url, path](){downloadFile(url.c_str(), path.c_str(), OFF);})
);
stagedFrame->addStage(
new ConfirmPage(stagedFrame, "All done!", true)
new ConfirmPage(stagedFrame, "download_all_done"_lang, true)
);
brls::Application::pushView(stagedFrame);
});
@ -40,13 +41,12 @@ DownloadPayloadPage::DownloadPayloadPage() : AppletFrame(true, true)
else{
notFound = new brls::Label(
brls::LabelStyle::DESCRIPTION,
"Could not find a download link, make sure the Switch has access to the internet.\n"\
"If this problem persists, please open an issue on Github",
"description"_lang,
true
);
notFound->setHorizontalAlign(NVG_ALIGN_CENTER);
list->addView(notFound);
brls::ListItem* back = new brls::ListItem("Back");
brls::ListItem* back = new brls::ListItem("back"_lang);
back->getClickEvent()->subscribe([&](brls::View* view) {
brls::Application::popView();
});

View file

@ -1,12 +1,13 @@
#include "exclude_page.hpp"
#include "lang.hpp"
using namespace lang::literals;
ExcludePage::ExcludePage() : AppletFrame(true, true)
{
this->setTitle("Exclude titles");
this->setTitle("exclude_titles"_lang);
list = new brls::List();
label = new brls::Label(
brls::LabelStyle::DESCRIPTION,
"You can turn off cheat updates with this menu",
"you_can"_lang,
true
);
list->addView(label);
@ -65,7 +66,7 @@ ExcludePage::ExcludePage() : AppletFrame(true, true)
i++;
}
list->registerAction("Save choice and return", brls::Key::B, [this] {
list->registerAction("save"_lang, brls::Key::B, [this] {
std::set<std::string> exclude{};
for(int i = 0; i < (int) std::get<1>(items).size(); i++){
if(!std::get<0>(items)[i]->getToggleState()){

View file

@ -1,7 +1,8 @@
#include "extract.hpp"
#include "utils.hpp"
#include "download.hpp"
#include "lang.hpp"
using namespace lang::literals;
void extract(const char * filename, const char* workingPath, int overwriteInis){
ProgressEvent::instance().reset();
ProgressEvent::instance().setStep(1);

122
source/lang.cpp Normal file
View file

@ -0,0 +1,122 @@
#include <switch.h>
#include <json.hpp>
#include <fs.hpp>
#include <lang.hpp>
using json = nlohmann::json;
namespace lang {
namespace {
static json lang_json = nullptr;
static Language current_language = Language::Default;
} // namespace
const json &get_json() {
return lang_json;
}
Language get_current_language() {
return current_language;
}
Result set_language(Language lang) {
const char *path;
current_language = lang;
switch (lang) {
case Language::Chinese:
path = "romfs:/lang/ch.json";
break;
//if you need add a new language
//use it !
/*case Language::French:
path = "romfs:/lang/fr.json";
break;
case Language::Dutch:
path = "romfs:/lang/nl.json";
break;
case Language::Italian:
path = "romfs:/lang/it.json";
break;
case Language::German:
path = "romfs:/lang/de.json";
break;
case Language::Spanish:
path = "romfs:/lang/es.json";
break;*/
case Language::English:
case Language::Default:
default:
path = "romfs:/lang/en.json";
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);
return 0;
}
Result initialize_to_system_language() {
if (auto rc = setInitialize(); R_FAILED(rc)) {
setExit();
return rc;
}
u64 l;
if (auto rc = setGetSystemLanguage(&l); R_FAILED(rc)) {
setExit();
return rc;
}
SetLanguage sl;
if (auto rc = setMakeLanguage(l, &sl); R_FAILED(rc)) {
setExit();
return rc;
}
switch (sl) {
case SetLanguage_ENGB:
case SetLanguage_ENUS:
return set_language(Language::English);
case SetLanguage_ZHCN:
case SetLanguage_ZHHANS:
return set_language(Language::Chinese);
//if you need add a new language
//use it !
/*case SetLanguage_FR:
return set_language(Language::French);
case SetLanguage_NL:
return set_language(Language::Dutch);
case SetLanguage_IT:
return set_language(Language::Italian);
case SetLanguage_DE:
return set_language(Language::German);
case SetLanguage_ES:
return set_language(Language::Spanish);*/
default:
return set_language(Language::Default);
}
}
std::string get_string(std::string key, const json &json) {
return json.value(key, key);
}
} // namespace lang

View file

@ -0,0 +1,44 @@
#include "language_option_page.hpp"
#include "lang.hpp"
#include <cstdio>
using namespace lang::literals;
//this page is for language page
LanguageOptionPage::LanguageOptionPage() : AppletFrame(true, true)
{
this->setTitle("Language_Option"_lang);
list = new brls::List();
English = new brls::ListItem("English");
English->getClickEvent()->subscribe([&](brls::View* view){
nlohmann::json json_file;
json_file["language"]=(int)lang::Language::English;
std::ofstream o("/switch/AIO-switch-updater/config.ini");
o<<std::setw(4)<<json_file<<std::endl;
brls::StagedAppletFrame* stagedFrame = new brls::StagedAppletFrame();
stagedFrame->addStage(
new ConfirmPage(stagedFrame, "reset_machine"_lang,false)
);
brls::Application::pushView(stagedFrame);
});
list->addView(English);
Chinese = new brls::ListItem("中文");
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");
o<<std::setw(4)<<json_file<<std::endl;
brls::StagedAppletFrame* stagedFrame = new brls::StagedAppletFrame();
stagedFrame->addStage(
new ConfirmPage(stagedFrame, "reset_machine"_lang,false)
);
brls::Application::pushView(stagedFrame);
});
list->addView(Chinese);
this->setContentView(list);
}

View file

@ -1,55 +1,50 @@
#include "list_download_tab.hpp"
#include "lang.hpp"
using namespace lang::literals;
ListDownloadTab::ListDownloadTab(archiveType type) :
brls::List()
{
std::tuple<std::vector<std::string>, std::vector<std::string>> links;
std::string operation = "Getting ";
std::string firmwareText("\uE016 Firmware dumps from 'https://darthsternie.net/switch-firmwares/'. "\
"Once downloaded, it will be extracted in '/firmware'. You can then install the update through Daybreak or ChoiDuJour.\n"\
"\uE016 Current FW: "
std::string operation = "Getting"_lang;
std::string firmwareText("firmware_text"_lang
);
std::string currentCheatsVer =
"\uE016 This will download a daily updated archive of cheat codes from 'gbatemp.net'. "\
"Cheat codes for games you don't have installed won't be extracted to your SD card. "\
"You can turn off cheat updated in 'Tools->Cheat menu'.\n"\
"\uE016 Current cheats version: ";
"currentCeatsver"_lang;
this->description = new brls::Label(brls::LabelStyle::DESCRIPTION, "", true);
switch(type){
case sigpatches:
links = fetchLinks(SIGPATCHES_URL);
operation += "sigpatches";
operation += "operation_1"_lang;
this->description->setText(
"\uE016 Sigpatches allow your Switch to install and run unofficial NSP file. " \
"Make sure you pick the correct sigpatches for your setup (pure Atmosphere or Hekate+Atmosphere)."
"list_sigpatches"_lang
);
break;
case fw:
links = fetchLinks(FIRMWARE_URL);
operation += "firmware";
operation += "operation_2"_lang;
SetSysFirmwareVersion ver;
if (R_SUCCEEDED(setsysGetFirmwareVersion(&ver))) firmwareText += ver.display_version;
else firmwareText += "not found";
else firmwareText += "list_not"_lang;
this->description->setText(firmwareText);
break;
case app:
std::get<0>(links).push_back("Latest version");
std::get<0>(links).push_back("list_latest"_lang);
std::get<1>(links).push_back(APP_URL);
operation += "app";
operation += "list_app"_lang;
break;
case cfw:
links = fetchLinks(CFW_URL);
operation += "CFW";
operation += "list_cfw"_lang;
this->description->setText(
"\uE016 Main Switch CFWs. If you want to use Atmosphere with Hekate, download Atmosphere, then Hekate."
"list_main"_lang
);
break;
case cheats:
std::string cheatsVer = fetchTitle(CHEATS_RELEASE_URL);
if(cheatsVer != "-1"){
std::get<0>(links).push_back("Latest (ver " + cheatsVer + ")");
std::get<0>(links).push_back("list_latest_ver"_lang + cheatsVer + ")");
switch(getCFW()){
case sxos:
std::get<1>(links).push_back(CHEATS_URL_TITLES);
@ -62,7 +57,7 @@ ListDownloadTab::ListDownloadTab(archiveType type) :
break;
}
}
operation += "cheats";
operation += "list_cheats"_lang;
currentCheatsVer += readVersion(CHEATS_VERSION);
this->description->setText(currentCheatsVer);
break;
@ -76,7 +71,7 @@ ListDownloadTab::ListDownloadTab(archiveType type) :
linkItems.reserve(nbLinks);
for (int i = 0; i<nbLinks; i++){
std::string url = std::get<1>(links)[i];
std::string text("Downloading:\n" + std::get<0>(links)[i] + "\n\nFrom:\n" + url);
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]->getClickEvent()->subscribe([&, text, url, type, operation](brls::View* view) {
brls::StagedAppletFrame* stagedFrame = new brls::StagedAppletFrame();
@ -85,13 +80,13 @@ ListDownloadTab::ListDownloadTab(archiveType type) :
new ConfirmPage(stagedFrame, text)
);
stagedFrame->addStage(
new WorkerPage(stagedFrame, "Downloading...", [url, type](){downloadArchive(url, type);})
new WorkerPage(stagedFrame, "list_downing"_lang, [url, type](){downloadArchive(url, type);})
);
stagedFrame->addStage(
new WorkerPage(stagedFrame, "Extracting...", [type](){extractArchive(type);})
new WorkerPage(stagedFrame, "list_extracting"_lang, [type](){extractArchive(type);})
);
stagedFrame->addStage(
new ConfirmPage(stagedFrame, "All done!", true)
new ConfirmPage(stagedFrame, "list_All"_lang, true)
);
brls::Application::pushView(stagedFrame);
});
@ -101,8 +96,7 @@ ListDownloadTab::ListDownloadTab(archiveType type) :
else{
notFound = new brls::Label(
brls::LabelStyle::DESCRIPTION,
"Could not find a download link, make sure the Switch has access to the internet.\n"\
"If this problem persists, please open an issue on Github.",
"list_could_done",
true
);
notFound->setHorizontalAlign(NVG_ALIGN_CENTER);

View file

@ -8,6 +8,7 @@
#include "main_frame.hpp"
#include "constants.hpp"
#include "utils.hpp"
#include "lang.hpp"
#include <string.h>
#include <stdio.h>
@ -15,7 +16,10 @@
#include <arpa/inet.h>
#include <sys/errno.h>
#include <unistd.h>
#include <dirent.h>
#include <sstream>
#include<fstream>
int main(int argc, char* argv[])
{
// Init the app
@ -31,6 +35,10 @@ int main(int argc, char* argv[])
#endif
// Initialize services with a PC shim
setsysInitialize();
plInitialize(PlServiceType_User);
romfsInit();
nsInitialize();
socketInitializeDefault();
nxlinkStdio();
@ -41,6 +49,47 @@ 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)
{
std::ifstream i("/switch/AIO-switch-updater/config.ini");
nlohmann::json lang_json;
i>>lang_json;
int tmp_number =lang_json["language"];
lang::set_language((lang::Language)(tmp_number));
}
else
{
//init system language automatically
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);
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");
o<<std::setw(4)<<json_file<<std::endl;
}
//end by tiansongyu
// Create root view
MainFrame *mainFrame = new MainFrame();
@ -54,5 +103,8 @@ int main(int argc, char* argv[])
splExit();
socketExit();
nsExit();
setsysExit();
plExit();
romfsExit();
return EXIT_SUCCESS;
}

View file

@ -1,23 +1,23 @@
#include "main_frame.hpp"
#include "lang.hpp"
using namespace lang::literals;
MainFrame::MainFrame() : TabFrame()
{
std::string tag = getLatestTag(TAGS_INFO);
if(!tag.empty() && tag != APP_VERSION)
setTitle(std::string(APP_TITLE) + " - New app update available");
setTitle(std::string(APP_TITLE) + "main_app"_lang);
else
setTitle(std::string(APP_TITLE) + " v" + std::string(APP_VERSION));
this->addTab("About", new AboutTab());
setTitle(std::string(APP_TITLE) + "main_v"_lang + std::string(APP_VERSION));
this->addTab("main_about"_lang, new AboutTab());
this->addSeparator();
this->addTab("Update CFW", new ListDownloadTab(cfw));
this->addTab("Update sigpatches", new ListDownloadTab(sigpatches));
this->addTab("Download firmwares", new ListDownloadTab(fw));
this->addTab("Download cheats", new ListDownloadTab(cheats));
this->addTab("main_update_cfw"_lang, new ListDownloadTab(cfw));
this->addTab("main_update_si"_lang, new ListDownloadTab(sigpatches));
this->addTab("main_firmwares"_lang, new ListDownloadTab(fw));
this->addTab("main_cheats"_lang, new ListDownloadTab(cheats));
this->addSeparator();
this->addTab("Tools", new ToolsTab(tag));
this->addTab("main_tools"_lang, new ToolsTab(tag));
}

View file

@ -1,13 +1,14 @@
#include "payload_page.hpp"
#include "lang.hpp"
using namespace lang::literals;
PayloadPage::PayloadPage() : AppletFrame(true, true)
{
CFW cfw = getCFW();
this->setTitle("Reboot menu");
this->setTitle("payload_reboot"_lang);
list = new brls::List();
label = new brls::Label(
brls::LabelStyle::DESCRIPTION,
"Select a payload to reboot to.",
"payload_select"_lang,
true
);
list->addView(label);
@ -22,13 +23,13 @@ PayloadPage::PayloadPage() : AppletFrame(true, true)
brls::Application::popView();
});
if(cfw == ams){
items[i]->registerAction("Set as reboot_payload.bin", brls::Key::X, [this, payload] {
items[i]->registerAction("payload_set"_lang, brls::Key::X, [this, payload] {
if(R_SUCCEEDED(CopyFile(payload.c_str(), REBOOT_PAYLOAD_PATH))){
brls::Dialog* dialog = new brls::Dialog("Successfully copied '" + payload + "' to '" + std::string(REBOOT_PAYLOAD_PATH) + "'.");
brls::Dialog* dialog = new brls::Dialog("payload_success"_lang + payload + "payload_to"_lang + std::string(REBOOT_PAYLOAD_PATH) + "'.");
brls::GenericEvent::Callback callback = [dialog](brls::View* view) {
dialog->close();
};
dialog->addButton("Ok", callback);
dialog->addButton("payload_ok"_lang, callback);
dialog->setCancelable(true);
dialog->open();
}
@ -40,14 +41,14 @@ PayloadPage::PayloadPage() : AppletFrame(true, true)
}
list->addView(new brls::ListItemGroupSpacing(true));
shutDown = new brls::ListItem("Shut Down");
shutDown = new brls::ListItem("payload_shut"_lang);
shutDown->getClickEvent()->subscribe([](brls::View* view) {
shut_down(false);
brls::Application::popView();
});
list->addView(shutDown);
reboot = new brls::ListItem("Reboot");
reboot = new brls::ListItem("payload_reboot_2"_lang);
reboot->getClickEvent()->subscribe([](brls::View* view) {
shut_down(true);
brls::Application::popView();

View file

@ -1,57 +1,64 @@
#include "tools_tab.hpp"
#include "lang.hpp"
using namespace lang::literals;
ToolsTab::ToolsTab(std::string tag) : brls::List()
{
cheats = new brls::ListItem("Cheats menu");
cheats = new brls::ListItem("tool_cheats"_lang);
cheats->getClickEvent()->subscribe([&](brls::View* view){
brls::Application::pushView(new CheatsPage());
});
this->addView(cheats);
JCcolor = new brls::ListItem("Change the Joy-Cons color");
JCcolor = new brls::ListItem("tool_change"_lang);
JCcolor->getClickEvent()->subscribe([&](brls::View* view){
brls::Application::pushView(new JCPage());
});
this->addView(JCcolor);
downloadPayload = new brls::ListItem("Dowload payloads to " + std::string(BOOTLOADER_PL_PATH));
downloadPayload = new brls::ListItem("tool_download"_lang + std::string(BOOTLOADER_PL_PATH));
downloadPayload->getClickEvent()->subscribe([&](brls::View* view){
brls::Application::pushView(new DownloadPayloadPage());
});
this->addView(downloadPayload);
rebootPayload = new brls::ListItem("Inject payload");
rebootPayload = new brls::ListItem("tool_inject"_lang);
rebootPayload->getClickEvent()->subscribe([&](brls::View* view){
brls::Application::pushView(new PayloadPage());
});
this->addView(rebootPayload);
if(!tag.empty() && tag != APP_VERSION){
updateApp = new brls::ListItem("Update the app (v" + tag +")");
std::string text("Downloading:\nAIO-switch-updater\n\nFrom:\n" + std::string(APP_URL));
updateApp = new brls::ListItem("tool_update"_lang + tag +")");
std::string text("tool_DownLoad"_lang + std::string(APP_URL));
updateApp->getClickEvent()->subscribe([&, text](brls::View* view) {
brls::StagedAppletFrame* stagedFrame = new brls::StagedAppletFrame();
stagedFrame->setTitle("Updating app");
stagedFrame->setTitle("tool_updating"_lang);
stagedFrame->addStage(
new ConfirmPage(stagedFrame, text)
);
stagedFrame->addStage(
new WorkerPage(stagedFrame, "Downloading...", [](){downloadArchive(APP_URL, app);})
new WorkerPage(stagedFrame, "tool_downloading"_lang, [](){downloadArchive(APP_URL, app);})
);
stagedFrame->addStage(
new WorkerPage(stagedFrame, "Extracting....", [](){extractArchive(app);})
new WorkerPage(stagedFrame, "tool_extracting"_lang, [](){extractArchive(app);})
);
stagedFrame->addStage(
new ConfirmPage(stagedFrame, "All done!", true)
new ConfirmPage(stagedFrame, "tool_all_done"_lang, true)
);
brls::Application::pushView(stagedFrame);
});
this->addView(updateApp);
}
changelog = new brls::ListItem("Changelog");
changelog = new brls::ListItem("tool_changelog"_lang);
changelog->getClickEvent()->subscribe([&](brls::View* view){
brls::Application::pushView(new ChangelogPage());
});
this->addView(changelog);
language = new brls::ListItem("Language_Option"_lang);
language->getClickEvent()->subscribe([&](brls::View* view){
brls::Application::pushView(new LanguageOptionPage());
});
this->addView(language);
}

View file

@ -1,5 +1,6 @@
#include "utils.hpp"
#include "lang.hpp"
using namespace lang::literals;
bool isServiceRunning(const char *serviceName) {
Handle handle;
SmServiceName service_name = smEncodeName(serviceName);
@ -68,8 +69,7 @@ void downloadArchive(std::string url, archiveType type){
downloadFile(url.c_str(), FIRMWARE_FILENAME, OFF);
}
else{
showDialogBox("Because of the size of the FW archive, downloading firmwares in Applet Mode is not supported. "\
"Please launch the app with full RAM access.", "Ok");
showDialogBox("utils_because"_lang, "utils_ok"_lang);
brls::Application::pushView(new MainFrame());
}
break;
@ -134,7 +134,7 @@ void extractArchive(archiveType type){
std::string backup(HEKATE_IPL_PATH);
backup += ".old";
if(std::filesystem::exists(HEKATE_IPL_PATH)){
overwriteInis = showDialogBox("Do you want to overwrite existing " + std::string(HEKATE_IPL_PATH) +"?", "No", "Yes");
overwriteInis = showDialogBox("utils_do"_lang + std::string(HEKATE_IPL_PATH) +"?", "utils_no"_lang, "utils_yes"_lang);
if(overwriteInis == 0){
extract(SIGPATCHES_FILENAME, ROOT_PATH, HEKATE_IPL_PATH);
}
@ -147,8 +147,7 @@ void extractArchive(archiveType type){
}
}
else{
showDialogBox("The downloaded file is not a sigpatches archive. This is most likely due to a broken link. If the problem persists after more than 3 hours, "\
"please open an issue on Github.", "Ok");
showDialogBox("utils_the"_lang, "utils_ok"_lang);
brls::Application::pushView(new MainFrame());
}
break;
@ -159,8 +158,7 @@ void extractArchive(archiveType type){
break;
case fw:
if(std::filesystem::file_size(FIRMWARE_FILENAME) < 200000){
showDialogBox("The downloaded file is not a firmware archive. This is most likely due to a broken link. If the problem persists after more than 3 hours, "\
"please open an issue on Github.", "Ok");
showDialogBox("utils_the_downloaded"_lang, "utils_ok"_lang);
brls::Application::pushView(new MainFrame());
}
else{
@ -174,12 +172,11 @@ void extractArchive(archiveType type){
break;
case cfw:
if(isArchive(CFW_FILENAME)){
overwriteInis = showDialogBox("Do you want to overwrite existing .ini config files?", "No", "Yes");
overwriteInis = showDialogBox("ultils_overwrite"_lang, "utils_no"_lang, "utils_yes"_lang);
extract(CFW_FILENAME, ROOT_PATH, overwriteInis);
}
else{
showDialogBox("The downloaded file is not a CFW archive. This is most likely due to a broken link. If the problem persists after more than 3 hours, "\
"please open an issue on Github.", "Ok");
showDialogBox("ultis_file"_lang, "utils_ok"_lang);
brls::Application::pushView(new MainFrame());
}
break;