mirror of
https://github.com/Huntereb/Awoo-Installer
synced 2024-11-29 07:00:37 +00:00
Select languages in options menu
This commit is contained in:
parent
a5cd41e47e
commit
49651f448b
7 changed files with 60 additions and 11 deletions
|
@ -5,4 +5,5 @@ overClock=0
|
||||||
deletePrompt=1
|
deletePrompt=1
|
||||||
gayMode=0
|
gayMode=0
|
||||||
sigPatchesUrl=https://github.com/Huntereb/Awoo-Installer/releases/download/SignaturePatches/patches.zip
|
sigPatchesUrl=https://github.com/Huntereb/Awoo-Installer/releases/download/SignaturePatches/patches.zip
|
||||||
|
languageSetting=99
|
||||||
usbAck=0
|
usbAck=0
|
||||||
|
|
|
@ -21,5 +21,6 @@ namespace inst::ui {
|
||||||
pu::ui::elm::Menu::Ref menu;
|
pu::ui::elm::Menu::Ref menu;
|
||||||
void setMenuText();
|
void setMenuText();
|
||||||
std::string getMenuOptionIcon(bool ourBool);
|
std::string getMenuOptionIcon(bool ourBool);
|
||||||
|
std::string getMenuLanguage(int ourLangCode);
|
||||||
};
|
};
|
||||||
}
|
}
|
|
@ -10,6 +10,7 @@ namespace inst::config {
|
||||||
extern std::string sigPatchesUrl;
|
extern std::string sigPatchesUrl;
|
||||||
extern std::string gAuthKey;
|
extern std::string gAuthKey;
|
||||||
extern std::vector<std::string> updateInfo;
|
extern std::vector<std::string> updateInfo;
|
||||||
|
extern int languageSetting;
|
||||||
extern bool ignoreReqVers;
|
extern bool ignoreReqVers;
|
||||||
extern bool validateNCAs;
|
extern bool validateNCAs;
|
||||||
extern bool overClock;
|
extern bool overClock;
|
||||||
|
|
|
@ -149,6 +149,7 @@
|
||||||
"auto_update": "Check for updates to Awoo Installer automatically",
|
"auto_update": "Check for updates to Awoo Installer automatically",
|
||||||
"gay_option": "Remove anime",
|
"gay_option": "Remove anime",
|
||||||
"sig_url": "Signature patches source URL: ",
|
"sig_url": "Signature patches source URL: ",
|
||||||
|
"language": "Language: ",
|
||||||
"check_update": "Check for updates to Awoo Installer",
|
"check_update": "Check for updates to Awoo Installer",
|
||||||
"credits": "Credits"
|
"credits": "Credits"
|
||||||
},
|
},
|
||||||
|
@ -176,6 +177,11 @@
|
||||||
"title": "Thanks to the following people!",
|
"title": "Thanks to the following people!",
|
||||||
"desc": "- HookedBehemoth for A LOT of contributions\n- Adubbz and other contributors for Tinfoil\n- XorTroll for Plutonium and Goldleaf\n- blawar (wife beater) and nicoboss for NSZ support\n- The kind folks at the AtlasNX Discuck (or at least some of them)\n- The also kind folks at the RetroNX Discuck (of no direct involvement)\n- namako8982 for the Momiji art\n- TheXzoron for being a baka"
|
"desc": "- HookedBehemoth for A LOT of contributions\n- Adubbz and other contributors for Tinfoil\n- XorTroll for Plutonium and Goldleaf\n- blawar (wife beater) and nicoboss for NSZ support\n- The kind folks at the AtlasNX Discuck (or at least some of them)\n- The also kind folks at the RetroNX Discuck (of no direct involvement)\n- namako8982 for the Momiji art\n- TheXzoron for being a baka"
|
||||||
},
|
},
|
||||||
|
"language": {
|
||||||
|
"title": "Select Awoo Installer's language",
|
||||||
|
"desc": "The software will be closed after changing languages. Press B to cancel.",
|
||||||
|
"system_language": "System default"
|
||||||
|
},
|
||||||
"title": "Change Awoo Installer's settings!",
|
"title": "Change Awoo Installer's settings!",
|
||||||
"buttons": "\ue0e0 Select/Change \ue0e1 Cancel "
|
"buttons": "\ue0e0 Select/Change \ue0e1 Cancel "
|
||||||
},
|
},
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
namespace inst::ui {
|
namespace inst::ui {
|
||||||
extern MainApplication *mainApp;
|
extern MainApplication *mainApp;
|
||||||
|
|
||||||
|
std::vector<pu::String> languageStrings = {"English"};
|
||||||
|
|
||||||
optionsPage::optionsPage() : Layout::Layout() {
|
optionsPage::optionsPage() : Layout::Layout() {
|
||||||
this->SetBackgroundColor(COLOR("#670000FF"));
|
this->SetBackgroundColor(COLOR("#670000FF"));
|
||||||
if (std::filesystem::exists(inst::config::appDir + "/background.png")) this->SetBackgroundImage(inst::config::appDir + "/background.png");
|
if (std::filesystem::exists(inst::config::appDir + "/background.png")) this->SetBackgroundImage(inst::config::appDir + "/background.png");
|
||||||
|
@ -72,6 +74,16 @@ namespace inst::ui {
|
||||||
else return "romfs:/images/icons/checkbox-blank-outline.png";
|
else return "romfs:/images/icons/checkbox-blank-outline.png";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string optionsPage::getMenuLanguage(int ourLangCode) {
|
||||||
|
switch (ourLangCode) {
|
||||||
|
case(1):
|
||||||
|
case(12):
|
||||||
|
return languageStrings[0].AsUTF8();
|
||||||
|
default:
|
||||||
|
return "options.language.system_language"_lang;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void optionsPage::setMenuText() {
|
void optionsPage::setMenuText() {
|
||||||
this->menu->ClearItems();
|
this->menu->ClearItems();
|
||||||
auto ignoreFirmOption = pu::ui::elm::MenuItem::New("options.menu_items.ignore_firm"_lang);
|
auto ignoreFirmOption = pu::ui::elm::MenuItem::New("options.menu_items.ignore_firm"_lang);
|
||||||
|
@ -101,6 +113,9 @@ namespace inst::ui {
|
||||||
auto sigPatchesUrlOption = pu::ui::elm::MenuItem::New("options.menu_items.sig_url"_lang + inst::util::shortenString(inst::config::sigPatchesUrl, 42, false));
|
auto sigPatchesUrlOption = pu::ui::elm::MenuItem::New("options.menu_items.sig_url"_lang + inst::util::shortenString(inst::config::sigPatchesUrl, 42, false));
|
||||||
sigPatchesUrlOption->SetColor(COLOR("#FFFFFFFF"));
|
sigPatchesUrlOption->SetColor(COLOR("#FFFFFFFF"));
|
||||||
this->menu->AddItem(sigPatchesUrlOption);
|
this->menu->AddItem(sigPatchesUrlOption);
|
||||||
|
auto languageOption = pu::ui::elm::MenuItem::New("options.menu_items.language"_lang + this->getMenuLanguage(inst::config::languageSetting));
|
||||||
|
languageOption->SetColor(COLOR("#FFFFFFFF"));
|
||||||
|
this->menu->AddItem(languageOption);
|
||||||
auto updateOption = pu::ui::elm::MenuItem::New("options.menu_items.check_update"_lang);
|
auto updateOption = pu::ui::elm::MenuItem::New("options.menu_items.check_update"_lang);
|
||||||
updateOption->SetColor(COLOR("#FFFFFFFF"));
|
updateOption->SetColor(COLOR("#FFFFFFFF"));
|
||||||
this->menu->AddItem(updateOption);
|
this->menu->AddItem(updateOption);
|
||||||
|
@ -115,7 +130,9 @@ namespace inst::ui {
|
||||||
}
|
}
|
||||||
if ((Down & KEY_A) || (Up & KEY_TOUCH)) {
|
if ((Down & KEY_A) || (Up & KEY_TOUCH)) {
|
||||||
std::string keyboardResult;
|
std::string keyboardResult;
|
||||||
|
int rc;
|
||||||
std::vector<std::string> downloadUrl;
|
std::vector<std::string> downloadUrl;
|
||||||
|
std::vector<pu::String> languageList;
|
||||||
switch (this->menu->GetSelectedIndex()) {
|
switch (this->menu->GetSelectedIndex()) {
|
||||||
case 0:
|
case 0:
|
||||||
inst::config::ignoreReqVers = !inst::config::ignoreReqVers;
|
inst::config::ignoreReqVers = !inst::config::ignoreReqVers;
|
||||||
|
@ -167,6 +184,22 @@ namespace inst::ui {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 7:
|
||||||
|
languageList = languageStrings;
|
||||||
|
languageList.push_back("options.language.system_language"_lang);
|
||||||
|
rc = inst::ui::mainApp->CreateShowDialog("options.language.title"_lang, "options.language.desc"_lang, languageList, false);
|
||||||
|
if (rc == -1) break;
|
||||||
|
switch(rc) {
|
||||||
|
case 0:
|
||||||
|
inst::config::languageSetting = 1;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
inst::config::languageSetting = 99;
|
||||||
|
}
|
||||||
|
inst::config::setConfig();
|
||||||
|
mainApp->FadeOut();
|
||||||
|
mainApp->Close();
|
||||||
|
break;
|
||||||
|
case 8:
|
||||||
if (inst::util::getIPAddress() == "1.0.0.127") {
|
if (inst::util::getIPAddress() == "1.0.0.127") {
|
||||||
inst::ui::mainApp->CreateShowDialog("main.net.title"_lang, "main.net.desc"_lang, {"common.ok"_lang}, true);
|
inst::ui::mainApp->CreateShowDialog("main.net.title"_lang, "main.net.desc"_lang, {"common.ok"_lang}, true);
|
||||||
break;
|
break;
|
||||||
|
@ -178,7 +211,7 @@ namespace inst::ui {
|
||||||
}
|
}
|
||||||
this->askToUpdate(downloadUrl);
|
this->askToUpdate(downloadUrl);
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 9:
|
||||||
inst::ui::mainApp->CreateShowDialog("options.credits.title"_lang, "options.credits.desc"_lang, {"common.close"_lang}, true);
|
inst::ui::mainApp->CreateShowDialog("options.credits.title"_lang, "options.credits.desc"_lang, {"common.close"_lang}, true);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -5,10 +5,11 @@
|
||||||
#include "util/config.hpp"
|
#include "util/config.hpp"
|
||||||
|
|
||||||
namespace inst::config {
|
namespace inst::config {
|
||||||
static const char* configBase = "[settings]\nignoreReqVers=%d\nvalidateNCAs=%d\noverClock=%d\ndeletePrompt=%d\nautoUpdate=%d\ngayMode=%d\nsigPatchesUrl=%s\ngAuthKey=%s\nusbAck=%d";
|
static const char* configBase = "[settings]\nignoreReqVers=%d\nvalidateNCAs=%d\noverClock=%d\ndeletePrompt=%d\nautoUpdate=%d\ngayMode=%d\nsigPatchesUrl=%s\ngAuthKey=%s\nlanguageSetting=%i\nusbAck=%d";
|
||||||
std::string sigPatchesUrl;
|
std::string sigPatchesUrl;
|
||||||
std::string gAuthKey;
|
std::string gAuthKey;
|
||||||
std::vector<std::string> updateInfo;
|
std::vector<std::string> updateInfo;
|
||||||
|
int languageSetting;
|
||||||
bool ignoreReqVers;
|
bool ignoreReqVers;
|
||||||
bool validateNCAs;
|
bool validateNCAs;
|
||||||
bool overClock;
|
bool overClock;
|
||||||
|
@ -27,14 +28,15 @@ namespace inst::config {
|
||||||
gayMode = reader.GetBoolean("settings", "gayMode", false);
|
gayMode = reader.GetBoolean("settings", "gayMode", false);
|
||||||
sigPatchesUrl = reader.GetString("settings", "sigPatchesUrl", "https://github.com/Huntereb/Awoo-Installer/releases/download/SignaturePatches/patches.zip");
|
sigPatchesUrl = reader.GetString("settings", "sigPatchesUrl", "https://github.com/Huntereb/Awoo-Installer/releases/download/SignaturePatches/patches.zip");
|
||||||
gAuthKey = reader.GetString("settings", "gAuthKey", {0x41,0x49,0x7a,0x61,0x53,0x79,0x42,0x4d,0x71,0x76,0x34,0x64,0x58,0x6e,0x54,0x4a,0x4f,0x47,0x51,0x74,0x5a,0x5a,0x53,0x33,0x43,0x42,0x6a,0x76,0x66,0x37,0x34,0x38,0x51,0x76,0x78,0x53,0x7a,0x46,0x30});
|
gAuthKey = reader.GetString("settings", "gAuthKey", {0x41,0x49,0x7a,0x61,0x53,0x79,0x42,0x4d,0x71,0x76,0x34,0x64,0x58,0x6e,0x54,0x4a,0x4f,0x47,0x51,0x74,0x5a,0x5a,0x53,0x33,0x43,0x42,0x6a,0x76,0x66,0x37,0x34,0x38,0x51,0x76,0x78,0x53,0x7a,0x46,0x30});
|
||||||
|
languageSetting = reader.GetInteger("settings", "languageSetting", 99);
|
||||||
usbAck = reader.GetBoolean("settings", "usbAck", false);
|
usbAck = reader.GetBoolean("settings", "usbAck", false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setConfig() {
|
void setConfig() {
|
||||||
std::filesystem::remove(inst::config::configPath);
|
std::filesystem::remove(inst::config::configPath);
|
||||||
char data[119 + sigPatchesUrl.size() + gAuthKey.size()];
|
char data[139 + sigPatchesUrl.size() + gAuthKey.size()];
|
||||||
sprintf(data, configBase, ignoreReqVers, validateNCAs, overClock, deletePrompt, autoUpdate, gayMode, sigPatchesUrl.c_str(), gAuthKey.c_str(), usbAck);
|
sprintf(data, configBase, ignoreReqVers, validateNCAs, overClock, deletePrompt, autoUpdate, gayMode, sigPatchesUrl.c_str(), gAuthKey.c_str(), languageSetting, usbAck);
|
||||||
FILE * configFile = fopen(inst::config::configPath.c_str(), "w");
|
FILE * configFile = fopen(inst::config::configPath.c_str(), "w");
|
||||||
fwrite(data, sizeof(char), strlen(data), configFile);
|
fwrite(data, sizeof(char), strlen(data), configFile);
|
||||||
fflush(configFile);
|
fflush(configFile);
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <switch.h>
|
#include <switch.h>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
#include "util/config.hpp"
|
||||||
|
|
||||||
namespace Language {
|
namespace Language {
|
||||||
json lang;
|
json lang;
|
||||||
|
@ -10,13 +11,17 @@ namespace Language {
|
||||||
void Load() {
|
void Load() {
|
||||||
std::ifstream ifs;
|
std::ifstream ifs;
|
||||||
std::string languagePath;
|
std::string languagePath;
|
||||||
setInitialize();
|
int langInt = inst::config::languageSetting;
|
||||||
|
if (langInt == 99) {
|
||||||
|
SetLanguage ourLang;
|
||||||
u64 lcode = 0;
|
u64 lcode = 0;
|
||||||
SetLanguage ourLang = SetLanguage_ENUS;
|
setInitialize();
|
||||||
setGetSystemLanguage(&lcode);
|
setGetSystemLanguage(&lcode);
|
||||||
setMakeLanguage(lcode, &ourLang);
|
setMakeLanguage(lcode, &ourLang);
|
||||||
setExit();
|
setExit();
|
||||||
switch (ourLang) {
|
langInt = (int)ourLang;
|
||||||
|
}
|
||||||
|
switch (langInt) {
|
||||||
case 0:
|
case 0:
|
||||||
languagePath = "romfs:/lang/ja.json";
|
languagePath = "romfs:/lang/ja.json";
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue