-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
This commit is contained in:
fix94.1 2013-08-08 18:21:11 +00:00
parent 43b6f44341
commit 51625a7507
7 changed files with 459 additions and 87 deletions

View File

@ -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();

View File

@ -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);
@ -1101,6 +1107,7 @@ private:
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];

View File

@ -16,6 +16,8 @@ template <class T> 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"));

View File

@ -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;
}

View File

@ -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" },

View File

@ -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 <http://www.gnu.org/licenses/>.
****************************************************************************/
#include "menu.hpp"
#include <algorithm>
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 <class T> static inline T loopNum(T i, T s)
{
return (i + s) % s;
}
u32 available_pos = 0;
vector<string> 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 = "<li><a href=";
/* getting count */
char *start = (strstr((char*)file, search_char)); /* skipping the .. */
char *tmp = strstr(start, "\n")+1;
while((tmp = strstr(tmp, search_char)) != NULL)
{
language_cnt++;
tmp = strstr(tmp, "\n")+1;
}
/* creating list */
tmp = strstr(start, "\n")+1;
lang_list_mem = (language_list*)MEM2_alloc(language_cnt*sizeof(language_list));
memset(lang_list_mem, 0, language_cnt*sizeof(language_list));
for(u32 i = 0; i < language_cnt; ++i)
{
tmp = strstr(tmp, search_char);
char *lang_chr = strchr(tmp, 0x22)+1;
memcpy(lang_list_mem[i].lang, lang_chr, std::min(31u, (u32)(strchr(lang_chr, '.')-lang_chr)));
tmp = strchr(tmp, '\n')+1;
}
free(buffer);
}
_showLangSettings();
}
else if(m_btnMgr.selected(m_LangSettingsBtnCurDlLangP) || m_btnMgr.selected(m_LangSettingsBtnCurDlLangM))
{
s8 direction = m_btnMgr.selected(m_LangSettingsBtnCurDlLangP) ? 1 : -1;
mem_pos = loopNum(mem_pos + direction, language_cnt);
_showLangSettings();
}
else if(m_btnMgr.selected(m_LangSettingsBtnDownload))
{
_hideLangSettings();
u8 *file = NULL;
u32 filesize = 0;
const char *language_sel = lang_list_mem[mem_pos].lang;
const char *language_url_sel = fmt("%s%s.ini", LANGUAGE_URL, language_sel);
u8 *buffer = _downloadUrl(language_url_sel, &file, &filesize);
if(buffer != NULL)
{
const char *language_ini = fmt("%s/%s.ini", m_languagesDir.c_str(), language_sel);
fsop_deleteFile(language_ini);
fsop_WriteFile(language_ini, file, filesize);
free(buffer);
}
m_loc.load(fmt("%s/%s.ini", m_languagesDir.c_str(), m_curLanguage.c_str()));
_updateText();
_refreshLangSettings();
}
}
}
_hideLangSettings();
if(lang_changed)
_cfNeedsUpdate();
if(lang_list_mem != NULL)
free(lang_list_mem);
lang_list_mem = NULL;
return lang_changed;
}
void CMenu::_initLangSettingsMenu()
{
_addUserLabels(m_LangSettingsLblUser, ARRAY_SIZE(m_LangSettingsLblUser), "LANGUAGE");
m_LangSettingsLblTitle = _addTitle("LANGUAGE/TITLE", theme.titleFont, L"", 20, 30, 600, 60, theme.titleFontColor, FTGX_JUSTIFY_CENTER | FTGX_ALIGN_MIDDLE);
m_LangSettingsBg = _texture("LANGUAGE/BG", "texture", theme.bg, false);
m_LangSettingsLblLanguage = _addLabel("LANGUAGE/LANGUAGE", theme.lblFont, L"", 40, 130, 290, 56, theme.lblFontColor, FTGX_JUSTIFY_LEFT | FTGX_ALIGN_MIDDLE);
m_LangSettingsLblCurLanguage = _addLabel("LANGUAGE/LANGUAGE_BTN", theme.btnFont, L"", 386, 130, 158, 56, theme.btnFontColor, FTGX_JUSTIFY_CENTER | FTGX_ALIGN_MIDDLE, theme.btnTexC);
m_LangSettingsBtnCurLanguageM = _addPicButton("LANGUAGE/LANGUAGE_MINUS", theme.btnTexMinus, theme.btnTexMinusS, 330, 130, 56, 56);
m_LangSettingsBtnCurLanguageP = _addPicButton("LANGUAGE/LANGUAGE_PLUS", theme.btnTexPlus, theme.btnTexPlusS, 544, 130, 56, 56);
m_LangSettingsLblGetLanguages = _addLabel("LANGUAGE/GET_LANG", theme.lblFont, L"", 40, 190, 290, 56, theme.lblFontColor, FTGX_JUSTIFY_LEFT | FTGX_ALIGN_MIDDLE);
m_LangSettingsBtnGetLanguages = _addButton("LANGUAGE/GET_LANG_BTN", theme.btnFont, L"", 330, 190, 270, 56, theme.btnFontColor);
m_LangSettingsLblDlLang = _addLabel("LANGUAGE/DL_LANG", theme.lblFont, L"", 40, 250, 290, 56, theme.lblFontColor, FTGX_JUSTIFY_LEFT | FTGX_ALIGN_MIDDLE);
m_LangSettingsLblCurDLLang = _addLabel("LANGUAGE/DL_LANG_BTN", theme.btnFont, L"", 386, 250, 158, 56, theme.btnFontColor, FTGX_JUSTIFY_CENTER | FTGX_ALIGN_MIDDLE, theme.btnTexC);
m_LangSettingsBtnCurDlLangM = _addPicButton("LANGUAGE/DL_LANG_MINUS", theme.btnTexMinus, theme.btnTexMinusS, 330, 250, 56, 56);
m_LangSettingsBtnCurDlLangP = _addPicButton("LANGUAGE/DL_LANG_PLUS", theme.btnTexPlus, theme.btnTexPlusS, 544, 250, 56, 56);
m_LangSettingsLblDownload = _addLabel("LANGUAGE/DOWNLOAD", theme.lblFont, L"", 40, 310, 290, 56, theme.lblFontColor, FTGX_JUSTIFY_LEFT | FTGX_ALIGN_MIDDLE);
m_LangSettingsBtnDownload = _addButton("LANGUAGE/DOWNLOAD_BTN", theme.btnFont, L"", 330, 310, 270, 56, theme.btnFontColor);
_setHideAnim(m_LangSettingsLblTitle, "LANGUAGE/TITLE", 0, -200, 0.f, 1.f);
_setHideAnim(m_LangSettingsLblLanguage, "LANGUAGE/LANGUAGE", 100, 0, -2.f, 0.f);
_setHideAnim(m_LangSettingsLblCurLanguage, "LANGUAGE/LANGUAGE_BTN", 0, 0, 1.f, -1.f);
_setHideAnim(m_LangSettingsBtnCurLanguageM, "LANGUAGE/LANGUAGE_MINUS", 0, 0, 1.f, -1.f);
_setHideAnim(m_LangSettingsBtnCurLanguageP, "LANGUAGE/LANGUAGE_PLUS", 0, 0, 1.f, -1.f);
_setHideAnim(m_LangSettingsLblGetLanguages, "LANGUAGE/GET_LANG", 100, 0, -2.f, 0.f);
_setHideAnim(m_LangSettingsBtnGetLanguages, "LANGUAGE/GET_LANG_BTN", 0, 0, 1.f, -1.f);
_setHideAnim(m_LangSettingsLblDlLang, "LANGUAGE/DL_LANG", 100, 0, -2.f, 0.f);
_setHideAnim(m_LangSettingsLblCurDLLang, "LANGUAGE/DL_LANG_BTN", 0, 0, 1.f, -1.f);
_setHideAnim(m_LangSettingsBtnCurDlLangM, "LANGUAGE/DL_LANG_MINUS", 0, 0, 1.f, -1.f);
_setHideAnim(m_LangSettingsBtnCurDlLangP, "LANGUAGE/DL_LANG_PLUS", 0, 0, 1.f, -1.f);
_setHideAnim(m_LangSettingsLblDownload, "LANGUAGE/DOWNLOAD", 100, 0, -2.f, 0.f);
_setHideAnim(m_LangSettingsBtnDownload, "LANGUAGE/DOWNLOAD_BTN", 0, 0, 1.f, -1.f);
_hideLangSettings(true);
_textLangSettings();
}
void CMenu::_textLangSettings(void)
{
m_btnMgr.setText(m_LangSettingsLblLanguage, _t("cfga6", L"Language"));
m_btnMgr.setText(m_LangSettingsLblTitle, _t("cfglng1", L"Manage Languages"));
m_btnMgr.setText(m_LangSettingsLblGetLanguages, _t("cfglng2", L"Get Languages"));
m_btnMgr.setText(m_LangSettingsBtnGetLanguages, _t("cfgc5", L"Go"));
m_btnMgr.setText(m_LangSettingsLblDlLang, _t("cfglng3", L"Select File"));
m_btnMgr.setText(m_LangSettingsLblDownload, _t("cfglng4", L"Download selected File"));
m_btnMgr.setText(m_LangSettingsBtnDownload, _t("cfgc5", L"Go"));
}

View File

@ -66,6 +66,7 @@ cfgc5=Go
cfgc6=Horizontal offset
cfgc7=Vertical offset
cfgc8=Startup Settings
cfgc9=Manage Languages
cfgd5=Save favorite mode state
cfgd7=Show categories on boot
cfgg1=Settings
@ -104,6 +105,10 @@ cfgg4=Patch country strings
cfgg5=Ocarina
cfgg7=Vipatch
cfgg8=Back
cfglng1=Manage Languages
cfglng2=Get Languages
cfglng3=Select File
cfglng4=Download selected File
cfgne1=NAND Emulation
cfgne2=Extract Game Saves
cfgne3=All