From 51625a75070499c07ddb00f3cfe24cc3d3334d6c Mon Sep 17 00:00:00 2001 From: "fix94.1" Date: Thu, 8 Aug 2013 18:21:11 +0000 Subject: [PATCH] -added a completely new menu to wiiflow, the language mange menu, now you can directly download and select the latest languages from the open-wiiflow-mod svn via wiiflows gui -updated english.ini --- source/menu/menu.cpp | 37 ++-- source/menu/menu.hpp | 16 +- source/menu/menu_config_adv.cpp | 50 +---- source/menu/menu_download.cpp | 111 +++++++++++ source/menu/menu_game.cpp | 26 --- source/menu/menu_language.cpp | 301 ++++++++++++++++++++++++++++++ wii/wiiflow/Languages/english.ini | 5 + 7 files changed, 459 insertions(+), 87 deletions(-) create mode 100644 source/menu/menu_language.cpp diff --git a/source/menu/menu.cpp b/source/menu/menu.cpp index 051b7e30..5715be4b 100644 --- a/source/menu/menu.cpp +++ b/source/menu/menu.cpp @@ -130,6 +130,9 @@ CMenu::CMenu() /* Explorer stuff */ m_txt_view = false; m_txt_path = NULL; + /* download stuff */ + m_file = NULL; + m_filesize = 0; } void CMenu::init() @@ -377,46 +380,46 @@ void CMenu::init() m_plugin.init(m_pluginsDir); m_devo_installed = DEVO_Installed(m_dataDir.c_str()); - u8 defaultMenuLanguage = 7; //English + const char *defLang = "Default"; switch (CONF_GetLanguage()) { case CONF_LANG_JAPANESE: - defaultMenuLanguage = 14; //Japanese + defLang = "japanese"; break; case CONF_LANG_GERMAN: - defaultMenuLanguage = 11; //German + defLang = "german"; break; case CONF_LANG_FRENCH: - defaultMenuLanguage = 9; //French + defLang = "french"; break; case CONF_LANG_SPANISH: - defaultMenuLanguage = 19; //Spanish + defLang = "spanish"; break; case CONF_LANG_ITALIAN: - defaultMenuLanguage = 13; //Italian + defLang = "italian"; break; case CONF_LANG_DUTCH: - defaultMenuLanguage = 6; //Dutch + defLang = "dutch"; break; case CONF_LANG_SIMP_CHINESE: - defaultMenuLanguage = 3; //Chinese_S + defLang = "chinese_s"; break; case CONF_LANG_TRAD_CHINESE: - defaultMenuLanguage = 4; //Chinese_T + defLang = "chinese_t"; break; case CONF_LANG_KOREAN: - defaultMenuLanguage = 7; // No Korean translation has been done for wiiflow, so the menu will use english in this case. + defLang = "korean"; break; } if (CONF_GetArea() == CONF_AREA_BRA) - defaultMenuLanguage = 2; //Brazilian + defLang = "brazilian"; - m_curLanguage = CMenu::_translations[m_cfg.getInt("GENERAL", "language", defaultMenuLanguage)]; - if (!m_loc.load(fmt("%s/%s.ini", m_languagesDir.c_str(), lowerCase(m_curLanguage).c_str()))) + m_curLanguage = m_cfg.getString("GENERAL", "language", defLang); + if(!m_loc.load(fmt("%s/%s.ini", m_languagesDir.c_str(), m_curLanguage.c_str()))) { - m_cfg.setInt("GENERAL", "language", 0); - m_curLanguage = CMenu::_translations[0]; - m_loc.load(fmt("%s/%s.ini", m_languagesDir.c_str(), lowerCase(m_curLanguage).c_str())); + m_curLanguage = "Default"; + m_cfg.setString("GENERAL", "language", m_curLanguage.c_str()); + m_loc.unload(); } m_tempView = false; @@ -1142,6 +1145,7 @@ void CMenu::_buildMenus(void) _initCFThemeMenu(); _initGameSettingsMenu(); _initCheatSettingsMenu(); + _initLangSettingsMenu(); _initSourceMenu(); _initPluginSettingsMenu(); _initCategorySettingsMenu(); @@ -2122,6 +2126,7 @@ void CMenu::_updateText(void) _textCode(); _textWBFS(); _textGameSettings(); + _textLangSettings(); _textNandEmu(); _textHome(); _textExitTo(); diff --git a/source/menu/menu.hpp b/source/menu/menu.hpp index 3f9cff37..2d2fb6b0 100644 --- a/source/menu/menu.hpp +++ b/source/menu/menu.hpp @@ -80,6 +80,7 @@ private: u32 m_base_font_size; u8 *m_wbf1_font; u8 *m_wbf2_font; + u8 *m_file; u8 m_aa; bool m_bnr_settings; bool m_directLaunch; @@ -214,9 +215,7 @@ private: s16 m_configAdvBtnCurThemeM; s16 m_configAdvBtnCurThemeP; s16 m_configAdvLblLanguage; - s16 m_configAdvLblCurLanguage; - s16 m_configAdvBtnCurLanguageM; - s16 m_configAdvBtnCurLanguageP; + s16 m_configAdvBtnManageLanguage; s16 m_configAdvLblCFTheme; s16 m_configAdvBtnCFTheme; s16 m_configAdvLblBootChange; @@ -835,6 +834,7 @@ private: void _initConfig4Menu(); void _initConfigSndMenu(); void _initConfigScreenMenu(); + void _initLangSettingsMenu(); void _initGameMenu(); void _initDownloadMenu(); void _initCodeMenu(); @@ -868,6 +868,7 @@ private: void _textConfig4(void); void _textConfigAdv(void); void _textConfigSnd(void); + void _textLangSettings(void); void _textGame(void); void _textDownload(void); void _textCode(void); @@ -885,6 +886,7 @@ private: // void _refreshBoot(); void _refreshExplorer(s8 direction = 0); + void _refreshLangSettings(); // void _hideCheatSettings(bool instant = false); void _hideError(bool instant = false); @@ -896,6 +898,7 @@ private: void _hideConfig4(bool instant = false); void _hideConfigAdv(bool instant = false); void _hideConfigSnd(bool instant = false); + void _hideLangSettings(bool instant = false); void _hideGame(bool instant = false); void _hideDownload(bool instant = false); void _hideSettings(bool instant = false); @@ -927,6 +930,7 @@ private: void _showConfigAdv(void); void _showConfigSnd(void); void _setPartition(s8 direction = 0); + void _showLangSettings(void); void _showGame(void); void _showDownload(void); void _showSettings(); @@ -983,8 +987,10 @@ private: }; void _cfNeedsUpdate(void); void _game(bool launch = false); + u8 *_downloadUrl(const char *url, u8 **dl_file, u32 *dl_size); void _download(string gameId = string()); void _downloadBnr(const char *gameID); + bool _LangSettings(void); void _code(void); void _about(bool help = false); bool _wbfsOp(WBFS_OP op); @@ -1097,10 +1103,11 @@ private: static int _NandFlasher(void *obj); int _FindEmuPart(string &emuPath, bool searchvalid); bool _checkSave(string id, bool nand); - bool _TestEmuNand(int epart, const char *path, bool indept); + bool _TestEmuNand(int epart, const char *path, bool indept); static u32 _downloadCheatFileAsync(void *obj); static u32 _downloadBannerAsync(void *obj); + static u32 _downloadUrlAsync(void *obj); void _playGameSound(void); void CheckGameSoundThread(void); @@ -1109,7 +1116,6 @@ private: static void _load_installed_cioses(); struct SOption { const char id[10]; const wchar_t text[16]; }; - static const string _translations[23]; static const SOption _languages[11]; static const SOption _GlobalVideoModes[6]; diff --git a/source/menu/menu_config_adv.cpp b/source/menu/menu_config_adv.cpp index ed3d083d..415f322c 100644 --- a/source/menu/menu_config_adv.cpp +++ b/source/menu/menu_config_adv.cpp @@ -16,6 +16,8 @@ template static inline T loopNum(T i, T s) return (i + s) % s; } +s16 m_configAdvBtnLanguage; + void CMenu::_hideConfigAdv(bool instant) { _hideConfigCommon(instant); @@ -27,9 +29,7 @@ void CMenu::_hideConfigAdv(bool instant) m_btnMgr.hide(m_configAdvBtnCurThemeM, instant); m_btnMgr.hide(m_configAdvBtnCurThemeP, instant); m_btnMgr.hide(m_configAdvLblLanguage, instant); - m_btnMgr.hide(m_configAdvLblCurLanguage, instant); - m_btnMgr.hide(m_configAdvBtnCurLanguageM, instant); - m_btnMgr.hide(m_configAdvBtnCurLanguageP, instant); + m_btnMgr.hide(m_configAdvBtnLanguage, instant); m_btnMgr.hide(m_configAdvLblCFTheme, instant); m_btnMgr.hide(m_configAdvBtnCFTheme, instant); for(u8 i = 0; i < ARRAY_SIZE(m_configAdvLblUser); ++i) @@ -50,9 +50,7 @@ void CMenu::_showConfigAdv(void) m_btnMgr.show(m_configAdvLblBootChange); m_btnMgr.show(m_configAdvBtnBootChange); m_btnMgr.show(m_configAdvLblLanguage); - m_btnMgr.show(m_configAdvLblCurLanguage); - m_btnMgr.show(m_configAdvBtnCurLanguageM); - m_btnMgr.show(m_configAdvBtnCurLanguageP); + m_btnMgr.show(m_configAdvBtnLanguage); m_btnMgr.show(m_configAdvLblCFTheme); m_btnMgr.show(m_configAdvBtnCFTheme); } @@ -60,7 +58,6 @@ void CMenu::_showConfigAdv(void) if(m_configAdvLblUser[i] != -1) m_btnMgr.show(m_configAdvLblUser[i]); - m_btnMgr.setText(m_configAdvLblCurLanguage, m_curLanguage); m_btnMgr.setText(m_configAdvLblCurTheme, m_cfg.getString("GENERAL", "theme")); } @@ -130,34 +127,10 @@ int CMenu::_configAdv(void) m_cfg.setInt(_domainFromView(), "last_cf_mode", 1); _showConfigAdv(); } - else if (m_btnMgr.selected(m_configAdvBtnCurLanguageP) || m_btnMgr.selected(m_configAdvBtnCurLanguageM)) + else if (m_configAdvBtnLanguage) { - _cfNeedsUpdate(); - s8 direction = m_btnMgr.selected(m_configAdvBtnCurLanguageP) ? 1 : -1; - int lang = (int)loopNum((u32)m_cfg.getInt("GENERAL", "language", 0) + direction, ARRAY_SIZE(CMenu::_translations)); - m_curLanguage = CMenu::_translations[lang]; - if (m_loc.load(fmt("%s/%s.ini", m_languagesDir.c_str(), lowerCase(m_curLanguage).c_str()))) - { - m_cfg.setInt("GENERAL", "language", lang); - lang_changed = true; - } - else - { - while (lang !=0) - { - lang = (int)loopNum((u32)lang + direction, ARRAY_SIZE(CMenu::_translations)); - m_curLanguage = CMenu::_translations[lang]; - struct stat langs; - if (stat(fmt("%s/%s.ini", m_languagesDir.c_str(), lowerCase(m_curLanguage).c_str()), &langs) == 0) - break; - } - m_cfg.setInt("GENERAL", "language", lang); - lang_changed = true; - m_curLanguage = CMenu::_translations[lang]; - m_loc.load(fmt("%s/%s.ini", m_languagesDir.c_str(), lowerCase(m_curLanguage).c_str())); - } _hideConfigAdv(); - _updateText(); + lang_changed = _LangSettings(); _showConfigAdv(); } else if (m_btnMgr.selected(m_configAdvBtnCFTheme)) @@ -191,9 +164,7 @@ void CMenu::_initConfigAdvMenu() m_configAdvBtnCurThemeM = _addPicButton("CONFIG_ADV/THEME_MINUS", theme.btnTexMinus, theme.btnTexMinusS, 330, 130, 56, 56); m_configAdvBtnCurThemeP = _addPicButton("CONFIG_ADV/THEME_PLUS", theme.btnTexPlus, theme.btnTexPlusS, 544, 130, 56, 56); m_configAdvLblLanguage = _addLabel("CONFIG_ADV/LANGUAGE", theme.lblFont, L"", 40, 190, 290, 56, theme.lblFontColor, FTGX_JUSTIFY_LEFT | FTGX_ALIGN_MIDDLE); - m_configAdvLblCurLanguage = _addLabel("CONFIG_ADV/LANGUAGE_BTN", theme.btnFont, L"", 386, 190, 158, 56, theme.btnFontColor, FTGX_JUSTIFY_CENTER | FTGX_ALIGN_MIDDLE, theme.btnTexC); - m_configAdvBtnCurLanguageM = _addPicButton("CONFIG_ADV/LANGUAGE_MINUS", theme.btnTexMinus, theme.btnTexMinusS, 330, 190, 56, 56); - m_configAdvBtnCurLanguageP = _addPicButton("CONFIG_ADV/LANGUAGE_PLUS", theme.btnTexPlus, theme.btnTexPlusS, 544, 190, 56, 56); + m_configAdvBtnLanguage = _addButton("CONFIG_ADV/LANGUAGE_BTN", theme.btnFont, L"", 330, 190, 270, 56, theme.btnFontColor); m_configAdvLblCFTheme = _addLabel("CONFIG_ADV/CUSTOMIZE_CF", theme.lblFont, L"", 40, 250, 290, 56, theme.lblFontColor, FTGX_JUSTIFY_LEFT | FTGX_ALIGN_MIDDLE); m_configAdvBtnCFTheme = _addButton("CONFIG_ADV/CUSTOMIZE_CF_BTN", theme.btnFont, L"", 330, 250, 270, 56, theme.btnFontColor); m_configAdvLblBootChange = _addLabel("CONFIG_ADV/BOOT_CHANGE", theme.lblFont, L"", 40, 310, 290, 56, theme.lblFontColor, FTGX_JUSTIFY_LEFT | FTGX_ALIGN_MIDDLE); @@ -204,9 +175,7 @@ void CMenu::_initConfigAdvMenu() _setHideAnim(m_configAdvBtnCurThemeM, "CONFIG_ADV/THEME_MINUS", 0, 0, 1.f, -1.f); _setHideAnim(m_configAdvBtnCurThemeP, "CONFIG_ADV/THEME_PLUS", 0, 0, 1.f, -1.f); _setHideAnim(m_configAdvLblLanguage, "CONFIG_ADV/LANGUAGE", 100, 0, -2.f, 0.f); - _setHideAnim(m_configAdvLblCurLanguage, "CONFIG_ADV/LANGUAGE_BTN", 0, 0, 1.f, -1.f); - _setHideAnim(m_configAdvBtnCurLanguageM, "CONFIG_ADV/LANGUAGE_MINUS", 0, 0, 1.f, -1.f); - _setHideAnim(m_configAdvBtnCurLanguageP, "CONFIG_ADV/LANGUAGE_PLUS", 0, 0, 1.f, -1.f); + _setHideAnim(m_configAdvBtnLanguage, "CONFIG_ADV/LANGUAGE_BTN", 0, 0, 1.f, -1.f); _setHideAnim(m_configAdvLblCFTheme, "CONFIG_ADV/CUSTOMIZE_CF", 100, 0, -2.f, 0.f); _setHideAnim(m_configAdvBtnCFTheme, "CONFIG_ADV/CUSTOMIZE_CF_BTN", 0, 0, 1.f, -1.f); _setHideAnim(m_configAdvLblBootChange, "CONFIG_ADV/BOOT_CHANGE", 100, 0, -2.f, 0.f); @@ -218,7 +187,8 @@ void CMenu::_initConfigAdvMenu() void CMenu::_textConfigAdv(void) { m_btnMgr.setText(m_configAdvLblTheme, _t("cfga7", L"Theme")); - m_btnMgr.setText(m_configAdvLblLanguage, _t("cfga6", L"Language")); + m_btnMgr.setText(m_configAdvLblLanguage, _t("cfgc9", L"Manage Languages")); + m_btnMgr.setText(m_configAdvBtnLanguage, _t("cfgc5", L"Go")); m_btnMgr.setText(m_configAdvLblCFTheme, _t("cfgc4", L"Adjust Coverflow")); m_btnMgr.setText(m_configAdvBtnCFTheme, _t("cfgc5", L"Go")); m_btnMgr.setText(m_configAdvLblBootChange, _t("cfgc8", L"Startup Settings")); diff --git a/source/menu/menu_download.cpp b/source/menu/menu_download.cpp index b925ca4f..5fbc5dc9 100644 --- a/source/menu/menu_download.cpp +++ b/source/menu/menu_download.cpp @@ -2133,3 +2133,114 @@ void CMenu::_downloadBnr(const char *gameID) m_btnMgr.hide(m_downloadPBar); m_btnMgr.hide(m_downloadBtnCancel); } + +const char *url_dl = NULL; +u8 *m_buffer = NULL; +u8 *CMenu::_downloadUrl(const char *url, u8 **dl_file, u32 *dl_size) +{ + m_file = NULL; + m_filesize = 0; + url_dl = url; + + m_btnMgr.show(m_downloadPBar); + m_btnMgr.setProgress(m_downloadPBar, 0.f); + m_btnMgr.show(m_downloadBtnCancel); + m_btnMgr.setText(m_downloadBtnCancel, _t("dl1", L"Cancel")); + m_thrdStop = false; + m_thrdMessageAdded = false; + + m_thrdWorking = true; + lwp_t thread = LWP_THREAD_NULL; + LWP_CreateThread(&thread, (void *(*)(void *))CMenu::_downloadUrlAsync, (void *)this, 0, 8192, 40); + + wstringEx prevMsg; + while(m_thrdWorking) + { + _mainLoopCommon(); + if ((BTN_HOME_PRESSED || BTN_B_PRESSED) && !m_thrdWorking) + break; + if (BTN_A_PRESSED && !(m_thrdWorking && m_thrdStop)) + { + if (m_btnMgr.selected(m_downloadBtnCancel)) + { + LockMutex lock(m_mutex); + m_thrdStop = true; + m_thrdMessageAdded = true; + m_thrdMessage = _t("dlmsg6", L"Canceling..."); + } + } + if (Sys_Exiting()) + { + LockMutex lock(m_mutex); + m_thrdStop = true; + m_thrdMessageAdded = true; + m_thrdMessage = _t("dlmsg6", L"Canceling..."); + m_thrdWorking = false; + } + if (m_thrdMessageAdded) + { + LockMutex lock(m_mutex); + m_thrdMessageAdded = false; + m_btnMgr.setProgress(m_downloadPBar, m_thrdProgress); + if (prevMsg != m_thrdMessage) + { + prevMsg = m_thrdMessage; + m_btnMgr.setText(m_downloadLblMessage[0], m_thrdMessage, false); + m_btnMgr.hide(m_downloadLblMessage[0], 0, 0, -1.f, -1.f, true); + m_btnMgr.show(m_downloadLblMessage[0]); + } + } + if (m_thrdStop && !m_thrdWorking) + break; + } + if (thread != LWP_THREAD_NULL) + { + LWP_JoinThread(thread, NULL); + thread = LWP_THREAD_NULL; + } + m_btnMgr.hide(m_downloadLblMessage[0]); + m_btnMgr.hide(m_downloadPBar); + m_btnMgr.hide(m_downloadBtnCancel); + + *dl_file = m_file; + *dl_size = m_filesize; + + m_file = NULL; + m_filesize = 0; + url_dl = url; + + return m_buffer; +} + +u32 CMenu::_downloadUrlAsync(void *obj) +{ + CMenu *m = (CMenu *)obj; + if (!m->m_thrdWorking) + return 0; + + m->m_thrdStop = false; + + LWP_MutexLock(m->m_mutex); + m->_setThrdMsg(m->_t("dlmsg11", L"Downloading..."), 0); + LWP_MutexUnlock(m->m_mutex); + + if(m->_initNetwork() < 0 || url_dl == NULL) + { + m->m_thrdWorking = false; + return -1; + } + + u32 bufferSize = 0x400000; /* 4mb max */ + u8 *buffer = (u8*)MEM2_alloc(bufferSize); + if(buffer == NULL) + { + m->m_thrdWorking = false; + return -2; + } + m_buffer = buffer; + block file = downloadfile(buffer, bufferSize, url_dl, CMenu::_downloadProgress, m); + m->m_file = file.data; + m->m_filesize = file.size; + m->m_thrdWorking = false; + return 0; +} diff --git a/source/menu/menu_game.cpp b/source/menu/menu_game.cpp index eeef7194..831bbdd0 100644 --- a/source/menu/menu_game.cpp +++ b/source/menu/menu_game.cpp @@ -61,32 +61,6 @@ s16 m_gameBtnBackFull; s16 m_gameBtnToogle; s16 m_gameBtnToogleFull; -const string CMenu::_translations[23] = { - "Default", - "Arab", - "Brazilian", - "Chinese_S", - "Chinese_T", - "Danish", - "Dutch", - "English", - "Finnish", - "French", - "Gallego", - "German", - "Hungarian", - "Italian", - "Japanese", - "Norwegian", - "Polish", - "Portuguese", - "Russian", - "Spanish", - "Swedish", - "Tagalog", - "Turkish" -}; - const CMenu::SOption CMenu::_languages[11] = { { "lngdef", L"Default" }, { "lngjap", L"Japanese" }, diff --git a/source/menu/menu_language.cpp b/source/menu/menu_language.cpp new file mode 100644 index 00000000..8e8c7c28 --- /dev/null +++ b/source/menu/menu_language.cpp @@ -0,0 +1,301 @@ +/**************************************************************************** + * Copyright (C) 2013 FIX94 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + ****************************************************************************/ +#include "menu.hpp" +#include + +TexData m_LangSettingsBg; +s16 m_LangSettingsLblUser[4]; + +s16 m_LangSettingsLblTitle; + +s16 m_LangSettingsLblLanguage; +s16 m_LangSettingsLblCurLanguage; +s16 m_LangSettingsBtnCurLanguageM; +s16 m_LangSettingsBtnCurLanguageP; + +s16 m_LangSettingsLblGetLanguages; +s16 m_LangSettingsBtnGetLanguages; + +s16 m_LangSettingsLblDlLang; +s16 m_LangSettingsLblCurDLLang; +s16 m_LangSettingsBtnCurDlLangM; +s16 m_LangSettingsBtnCurDlLangP; + +s16 m_LangSettingsLblDownload; +s16 m_LangSettingsBtnDownload; + +typedef struct { + char lang[32]; +} language_list; + +language_list *lang_list_mem = NULL; +u32 mem_pos = 0; +u32 language_cnt = 0; +wstringEx dl_lang_ex; + +#define LANGUAGE_URL "http://open-wiiflow-mod.googlecode.com/svn/trunk/wii/wiiflow/Languages/" +template static inline T loopNum(T i, T s) +{ + return (i + s) % s; +} + +u32 available_pos = 0; +vector languages_available; +void AddLanguage(char *Path) +{ + char lng[32]; + memset(lng, 0, 32); + char *lang_chr = strrchr(Path, '/')+1; + memcpy(lng, lang_chr, std::min(31u, (u32)(strrchr(lang_chr, '.')-lang_chr))); + languages_available.push_back(lng); +} + +void CMenu::_hideLangSettings(bool instant) +{ + m_btnMgr.hide(m_LangSettingsLblTitle, instant); + + m_btnMgr.hide(m_LangSettingsLblLanguage, instant); + m_btnMgr.hide(m_LangSettingsLblCurLanguage, instant); + m_btnMgr.hide(m_LangSettingsBtnCurLanguageM, instant); + m_btnMgr.hide(m_LangSettingsBtnCurLanguageP, instant); + + m_btnMgr.hide(m_LangSettingsLblGetLanguages, instant); + m_btnMgr.hide(m_LangSettingsBtnGetLanguages, instant); + + m_btnMgr.hide(m_LangSettingsLblDlLang, instant); + m_btnMgr.hide(m_LangSettingsLblCurDLLang, instant); + m_btnMgr.hide(m_LangSettingsBtnCurDlLangM, instant); + m_btnMgr.hide(m_LangSettingsBtnCurDlLangP, instant); + + m_btnMgr.hide(m_LangSettingsLblDownload, instant); + m_btnMgr.hide(m_LangSettingsBtnDownload, instant); + + for(u8 i = 0; i < ARRAY_SIZE(m_LangSettingsLblUser); ++i) + if(m_LangSettingsLblUser[i] != -1) + m_btnMgr.hide(m_LangSettingsLblUser[i], instant); +} + +void CMenu::_showLangSettings(void) +{ + m_btnMgr.show(m_LangSettingsLblTitle); + + m_btnMgr.show(m_LangSettingsLblLanguage); + m_btnMgr.show(m_LangSettingsLblCurLanguage); + m_btnMgr.show(m_LangSettingsBtnCurLanguageM); + m_btnMgr.show(m_LangSettingsBtnCurLanguageP); + + m_btnMgr.show(m_LangSettingsLblGetLanguages); + m_btnMgr.show(m_LangSettingsBtnGetLanguages); + + if(lang_list_mem != NULL) + { + m_btnMgr.show(m_LangSettingsLblDlLang); + m_btnMgr.show(m_LangSettingsLblCurDLLang); + m_btnMgr.show(m_LangSettingsBtnCurDlLangM); + m_btnMgr.show(m_LangSettingsBtnCurDlLangP); + + m_btnMgr.show(m_LangSettingsLblDownload); + m_btnMgr.show(m_LangSettingsBtnDownload); + + dl_lang_ex.fromUTF8(lang_list_mem[mem_pos].lang); + m_btnMgr.setText(m_LangSettingsLblCurDLLang, dl_lang_ex); + } + + for(u32 i = 0; i < ARRAY_SIZE(m_LangSettingsLblUser); ++i) + if(m_LangSettingsLblUser[i] != -1) + m_btnMgr.show(m_LangSettingsLblUser[i]); + + m_btnMgr.setText(m_LangSettingsLblCurLanguage, m_curLanguage); +} + +void CMenu::_refreshLangSettings(void) +{ + languages_available.clear(); + /* Get right Positions first */ + languages_available.push_back("Default"); + GetFiles(m_languagesDir.c_str(), stringToVector(".ini", '|'), AddLanguage, false, 0); + std::sort(languages_available.begin(), languages_available.end()); + + for(u32 i = 0; i < languages_available.size(); ++i) + { + if(m_curLanguage == languages_available[i]) + { + available_pos = i; + break; + } + } + _showLangSettings(); +} + +bool CMenu::_LangSettings(void) +{ + _refreshLangSettings(); + bool lang_changed = false; + + while(!m_exit) + { + _mainLoopCommon(); + if(BTN_HOME_PRESSED || BTN_B_PRESSED) + break; + else if(BTN_A_PRESSED) + { + if(m_btnMgr.selected(m_LangSettingsBtnCurLanguageP) || m_btnMgr.selected(m_LangSettingsBtnCurLanguageM)) + { + s8 direction = m_btnMgr.selected(m_LangSettingsBtnCurLanguageP) ? 1 : -1; + available_pos = loopNum(available_pos + direction, languages_available.size()); + m_curLanguage = languages_available[available_pos]; + if(!m_loc.load(fmt("%s/%s.ini", m_languagesDir.c_str(), m_curLanguage.c_str()))) + { + m_curLanguage = "Default"; + m_cfg.setString("GENERAL", "language", m_curLanguage.c_str()); + m_loc.unload(); + } + else + m_cfg.setString("GENERAL", "language", m_curLanguage.c_str()); + lang_changed = true; + _updateText(); + _showLangSettings(); + } + else if(m_btnMgr.selected(m_LangSettingsBtnGetLanguages)) + { + _hideLangSettings(); + u8 *file = NULL; + u32 filesize = 0; + u8 *buffer = _downloadUrl(LANGUAGE_URL, &file, &filesize); + if(buffer != NULL) + { + const char *search_char = "