2016-11-07 16:06:00 +01:00
|
|
|
|
2012-08-05 15:48:15 +02:00
|
|
|
#include <dirent.h>
|
2012-11-03 20:16:03 +01:00
|
|
|
#include <algorithm>
|
2012-01-21 21:57:41 +01:00
|
|
|
#include "menu.hpp"
|
|
|
|
|
|
|
|
template <class T> static inline T loopNum(T i, T s)
|
|
|
|
{
|
|
|
|
return (i + s) % s;
|
|
|
|
}
|
|
|
|
|
2016-11-07 16:06:00 +01:00
|
|
|
vector<string> languages_available;
|
|
|
|
void AddLanguage(char *Path)
|
|
|
|
{
|
|
|
|
char lng[32];
|
|
|
|
memset(lng, 0, 32);
|
|
|
|
char *lang_chr = strrchr(Path, '/')+1;
|
2021-09-01 22:51:09 +02:00
|
|
|
memcpy(lng, lang_chr, min(31u, (u32)(strrchr(lang_chr, '.')-lang_chr)));
|
2016-11-07 16:06:00 +01:00
|
|
|
languages_available.push_back(lng);
|
|
|
|
}
|
2013-08-08 20:21:11 +02:00
|
|
|
|
2012-01-21 21:57:41 +01:00
|
|
|
void CMenu::_hideConfigAdv(bool instant)
|
|
|
|
{
|
2012-05-04 05:46:18 +02:00
|
|
|
_hideConfigCommon(instant);
|
2012-02-17 17:46:05 +01:00
|
|
|
|
2012-12-21 20:51:22 +01:00
|
|
|
m_btnMgr.hide(m_configAdvLblBootChange, instant);
|
|
|
|
m_btnMgr.hide(m_configAdvBtnBootChange, instant);
|
2012-01-21 21:57:41 +01:00
|
|
|
m_btnMgr.hide(m_configAdvLblTheme, instant);
|
|
|
|
m_btnMgr.hide(m_configAdvLblCurTheme, instant);
|
|
|
|
m_btnMgr.hide(m_configAdvBtnCurThemeM, instant);
|
|
|
|
m_btnMgr.hide(m_configAdvBtnCurThemeP, instant);
|
|
|
|
m_btnMgr.hide(m_configAdvLblLanguage, instant);
|
2016-11-07 16:06:00 +01:00
|
|
|
m_btnMgr.hide(m_configAdvLblCurLanguage, instant);
|
|
|
|
m_btnMgr.hide(m_configAdvBtnCurLanguageM, instant);
|
|
|
|
m_btnMgr.hide(m_configAdvBtnCurLanguageP, instant);
|
2012-01-21 21:57:41 +01:00
|
|
|
m_btnMgr.hide(m_configAdvLblCFTheme, instant);
|
|
|
|
m_btnMgr.hide(m_configAdvBtnCFTheme, instant);
|
2012-07-05 15:15:23 +02:00
|
|
|
for(u8 i = 0; i < ARRAY_SIZE(m_configAdvLblUser); ++i)
|
2012-09-13 16:54:17 +02:00
|
|
|
if(m_configAdvLblUser[i] != -1)
|
2012-01-21 21:57:41 +01:00
|
|
|
m_btnMgr.hide(m_configAdvLblUser[i], instant);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMenu::_showConfigAdv(void)
|
|
|
|
{
|
2018-10-31 20:51:15 +01:00
|
|
|
_showConfigCommon(m_configAdvBg, 2);
|
2012-02-17 17:46:05 +01:00
|
|
|
|
2012-01-21 21:57:41 +01:00
|
|
|
m_btnMgr.show(m_configAdvLblCurTheme);
|
|
|
|
m_btnMgr.show(m_configAdvBtnCurThemeM);
|
|
|
|
m_btnMgr.show(m_configAdvBtnCurThemeP);
|
|
|
|
m_btnMgr.show(m_configAdvLblTheme);
|
2016-11-07 16:06:00 +01:00
|
|
|
|
|
|
|
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_configAdvLblCFTheme);
|
|
|
|
m_btnMgr.show(m_configAdvBtnCFTheme);
|
|
|
|
|
2012-07-05 15:15:23 +02:00
|
|
|
for(u32 i = 0; i < ARRAY_SIZE(m_configAdvLblUser); ++i)
|
2012-09-13 16:54:17 +02:00
|
|
|
if(m_configAdvLblUser[i] != -1)
|
2012-01-21 21:57:41 +01:00
|
|
|
m_btnMgr.show(m_configAdvLblUser[i]);
|
2012-02-17 17:46:05 +01:00
|
|
|
|
2019-07-24 19:35:51 +02:00
|
|
|
m_btnMgr.setText(m_configAdvLblCurTheme, m_themeName);
|
2016-11-07 16:06:00 +01:00
|
|
|
m_btnMgr.setText(m_configAdvLblCurLanguage, m_curLanguage);
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
|
|
|
|
2012-05-06 14:03:43 +02:00
|
|
|
static void listThemes(const char * path, vector<string> &themes)
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
|
|
|
DIR *d;
|
|
|
|
struct dirent *dir;
|
|
|
|
bool def = false;
|
|
|
|
|
|
|
|
themes.clear();
|
|
|
|
d = opendir(path);
|
|
|
|
if (d != 0)
|
|
|
|
{
|
|
|
|
dir = readdir(d);
|
|
|
|
while (dir != 0)
|
|
|
|
{
|
2012-06-27 14:31:48 +02:00
|
|
|
string fileName = dir->d_name;
|
|
|
|
def = def || (upperCase(fileName) == "DEFAULT.INI");
|
|
|
|
if (fileName.size() > 4 && fileName.substr(fileName.size() - 4, 4) == ".ini")
|
2012-01-21 21:57:41 +01:00
|
|
|
themes.push_back(fileName.substr(0, fileName.size() - 4));
|
|
|
|
dir = readdir(d);
|
|
|
|
}
|
|
|
|
closedir(d);
|
|
|
|
}
|
|
|
|
if (!def)
|
2018-12-13 01:16:42 +01:00
|
|
|
themes.push_back("Default");
|
2012-01-21 21:57:41 +01:00
|
|
|
sort(themes.begin(), themes.end());
|
|
|
|
}
|
|
|
|
|
|
|
|
int CMenu::_configAdv(void)
|
|
|
|
{
|
2012-05-04 05:46:18 +02:00
|
|
|
int change = CONFIG_PAGE_NO_CHANGE;
|
2016-11-07 16:06:00 +01:00
|
|
|
|
2012-05-06 14:03:43 +02:00
|
|
|
vector<string> themes;
|
2012-01-21 21:57:41 +01:00
|
|
|
listThemes(m_themeDir.c_str(), themes);
|
2019-07-24 19:35:51 +02:00
|
|
|
u32 curTheme = 0;
|
2012-01-21 21:57:41 +01:00
|
|
|
for (u32 i = 0; i < themes.size(); ++i)
|
2019-07-24 19:35:51 +02:00
|
|
|
if (themes[i] == m_themeName)
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
|
|
|
curTheme = i;
|
|
|
|
break;
|
|
|
|
}
|
2016-11-07 16:06:00 +01:00
|
|
|
|
|
|
|
languages_available.clear();
|
|
|
|
languages_available.push_back("Default");
|
|
|
|
GetFiles(m_languagesDir.c_str(), stringToVector(".ini", '|'), AddLanguage, false, 0);
|
|
|
|
sort(languages_available.begin(), languages_available.end());
|
|
|
|
|
2019-07-24 19:35:51 +02:00
|
|
|
u32 curLang = 0;
|
2016-11-07 16:06:00 +01:00
|
|
|
for(u32 i = 0; i < languages_available.size(); ++i)
|
|
|
|
{
|
|
|
|
if(m_curLanguage == languages_available[i])
|
|
|
|
{
|
2019-07-24 19:35:51 +02:00
|
|
|
curLang = i;
|
2016-11-07 16:06:00 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2019-07-24 19:35:51 +02:00
|
|
|
string prevLanguage = m_curLanguage;
|
2016-11-07 16:06:00 +01:00
|
|
|
|
2012-01-21 21:57:41 +01:00
|
|
|
_showConfigAdv();
|
2012-09-09 20:35:15 +02:00
|
|
|
while(!m_exit)
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2012-05-04 05:46:18 +02:00
|
|
|
change = _configCommon();
|
|
|
|
if (change != CONFIG_PAGE_NO_CHANGE)
|
2012-01-21 21:57:41 +01:00
|
|
|
break;
|
|
|
|
if (BTN_A_PRESSED)
|
|
|
|
{
|
2012-12-21 20:51:22 +01:00
|
|
|
if(m_btnMgr.selected(m_configAdvBtnBootChange))
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2012-05-04 05:46:18 +02:00
|
|
|
_hideConfigAdv();
|
2022-01-17 21:50:40 +01:00
|
|
|
_Boot();
|
2012-05-04 05:46:18 +02:00
|
|
|
_showConfigAdv();
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
2013-08-09 15:58:06 +02:00
|
|
|
else if(m_btnMgr.selected(m_configAdvBtnCurThemeP) || m_btnMgr.selected(m_configAdvBtnCurThemeM))
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
|
|
|
s8 direction = m_btnMgr.selected(m_configAdvBtnCurThemeP) ? 1 : -1;
|
2019-07-24 19:35:51 +02:00
|
|
|
curTheme = loopNum(curTheme + direction, (u32)themes.size());
|
|
|
|
m_themeName = themes[curTheme];
|
|
|
|
m_cfg.setString("GENERAL", "theme", m_themeName);
|
2012-01-21 21:57:41 +01:00
|
|
|
_showConfigAdv();
|
|
|
|
}
|
2016-11-07 16:06:00 +01:00
|
|
|
else if(m_btnMgr.selected(m_configAdvBtnCurLanguageP) || m_btnMgr.selected(m_configAdvBtnCurLanguageM))
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2016-11-07 16:06:00 +01:00
|
|
|
s8 direction = m_btnMgr.selected(m_configAdvBtnCurLanguageP) ? 1 : -1;
|
2019-07-24 19:35:51 +02:00
|
|
|
curLang = loopNum(curLang + direction, (u32)languages_available.size());
|
|
|
|
m_curLanguage = languages_available[curLang];
|
2016-11-07 16:06:00 +01:00
|
|
|
if(!m_loc.load(fmt("%s/%s.ini", m_languagesDir.c_str(), m_curLanguage.c_str())))
|
|
|
|
{
|
|
|
|
m_curLanguage = "Default";
|
2019-07-24 19:35:51 +02:00
|
|
|
m_cfg.setString("GENERAL", "language", m_curLanguage);
|
2016-11-07 16:06:00 +01:00
|
|
|
m_loc.unload();
|
|
|
|
}
|
|
|
|
else
|
2019-07-24 19:35:51 +02:00
|
|
|
m_cfg.setString("GENERAL", "language", m_curLanguage);
|
2016-11-07 16:06:00 +01:00
|
|
|
_updateText();
|
2012-01-21 21:57:41 +01:00
|
|
|
_showConfigAdv();
|
|
|
|
}
|
2013-08-09 15:58:06 +02:00
|
|
|
else if(m_btnMgr.selected(m_configAdvBtnCFTheme))
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2016-11-07 16:06:00 +01:00
|
|
|
m_refreshGameList = true;
|
2012-01-21 21:57:41 +01:00
|
|
|
_hideConfigAdv();
|
|
|
|
_cfTheme();
|
|
|
|
_showConfigAdv();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_hideConfigAdv();
|
2018-12-09 22:16:54 +01:00
|
|
|
if(m_curLanguage != prevLanguage)
|
|
|
|
{
|
2021-09-20 15:30:12 +02:00
|
|
|
m_cacheList.Init(m_settingsDir.c_str(), m_loc.getString(m_curLanguage, "gametdb_code", "EN").c_str(), m_pluginDataDir.c_str(),
|
|
|
|
m_cfg.getString(CONFIG_FILENAME_SKIP_DOMAIN,CONFIG_FILENAME_SKIP_KEY,CONFIG_FILENAME_SKIP_DEFAULT));
|
2018-12-09 22:16:54 +01:00
|
|
|
fsop_deleteFolder(m_listCacheDir.c_str());// delete cache lists folder and remake it so all lists update.
|
|
|
|
fsop_MakeFolder(m_listCacheDir.c_str());
|
2016-11-07 16:06:00 +01:00
|
|
|
m_refreshGameList = true;
|
2018-12-09 22:16:54 +01:00
|
|
|
}
|
2012-01-21 21:57:41 +01:00
|
|
|
|
2012-05-04 05:46:18 +02:00
|
|
|
return change;
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
|
|
|
|
2012-11-03 20:16:03 +01:00
|
|
|
void CMenu::_initConfigAdvMenu()
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2012-11-03 20:16:03 +01:00
|
|
|
_addUserLabels(m_configAdvLblUser, ARRAY_SIZE(m_configAdvLblUser), "CONFIG_ADV");
|
|
|
|
m_configAdvBg = _texture("CONFIG_ADV/BG", "texture", theme.bg, false);
|
2016-11-07 16:06:00 +01:00
|
|
|
|
2013-11-04 20:46:23 +01:00
|
|
|
m_configAdvLblTheme = _addLabel("CONFIG_ADV/THEME", theme.lblFont, L"", 20, 125, 290, 56, theme.lblFontColor, FTGX_JUSTIFY_LEFT | FTGX_ALIGN_MIDDLE);
|
|
|
|
m_configAdvLblCurTheme = _addLabel("CONFIG_ADV/THEME_BTN", theme.btnFont, L"", 468, 130, 104, 48, theme.btnFontColor, FTGX_JUSTIFY_CENTER | FTGX_ALIGN_MIDDLE, theme.btnTexC);
|
|
|
|
m_configAdvBtnCurThemeM = _addPicButton("CONFIG_ADV/THEME_MINUS", theme.btnTexMinus, theme.btnTexMinusS, 420, 130, 48, 48);
|
|
|
|
m_configAdvBtnCurThemeP = _addPicButton("CONFIG_ADV/THEME_PLUS", theme.btnTexPlus, theme.btnTexPlusS, 572, 130, 48, 48);
|
|
|
|
m_configAdvLblLanguage = _addLabel("CONFIG_ADV/LANGUAGE", theme.lblFont, L"", 20, 185, 290, 56, theme.lblFontColor, FTGX_JUSTIFY_LEFT | FTGX_ALIGN_MIDDLE);
|
2016-11-07 16:06:00 +01:00
|
|
|
m_configAdvLblCurLanguage = _addLabel("CONFIG_ADV/LANGUAGE_BTN", theme.btnFont, L"", 468, 190, 104, 48, theme.btnFontColor, FTGX_JUSTIFY_CENTER | FTGX_ALIGN_MIDDLE, theme.btnTexC);
|
|
|
|
m_configAdvBtnCurLanguageM = _addPicButton("CONFIG_ADV/LANGUAGE_MINUS", theme.btnTexMinus, theme.btnTexMinusS, 420, 190, 48, 48);
|
|
|
|
m_configAdvBtnCurLanguageP = _addPicButton("CONFIG_ADV/LANGUAGE_PLUS", theme.btnTexPlus, theme.btnTexPlusS, 572, 190, 48, 48);
|
2013-11-04 20:46:23 +01:00
|
|
|
m_configAdvLblCFTheme = _addLabel("CONFIG_ADV/CUSTOMIZE_CF", theme.lblFont, L"", 20, 245, 290, 56, theme.lblFontColor, FTGX_JUSTIFY_LEFT | FTGX_ALIGN_MIDDLE);
|
|
|
|
m_configAdvBtnCFTheme = _addButton("CONFIG_ADV/CUSTOMIZE_CF_BTN", theme.btnFont, L"", 420, 250, 200, 48, theme.btnFontColor);
|
|
|
|
m_configAdvLblBootChange = _addLabel("CONFIG_ADV/BOOT_CHANGE", theme.lblFont, L"", 20, 305, 290, 56, theme.lblFontColor, FTGX_JUSTIFY_LEFT | FTGX_ALIGN_MIDDLE);
|
|
|
|
m_configAdvBtnBootChange = _addButton("CONFIG_ADV/BOOT_CHANGE_BTN", theme.btnFont, L"", 420, 310, 200, 48, theme.btnFontColor);
|
|
|
|
|
|
|
|
_setHideAnim(m_configAdvLblTheme, "CONFIG_ADV/THEME", 50, 0, -2.f, 0.f);
|
|
|
|
_setHideAnim(m_configAdvLblCurTheme, "CONFIG_ADV/THEME_BTN", -50, 0, 1.f, 0.f);
|
|
|
|
_setHideAnim(m_configAdvBtnCurThemeM, "CONFIG_ADV/THEME_MINUS", -50, 0, 1.f, 0.f);
|
|
|
|
_setHideAnim(m_configAdvBtnCurThemeP, "CONFIG_ADV/THEME_PLUS", -50, 0, 1.f, 0.f);
|
|
|
|
_setHideAnim(m_configAdvLblLanguage, "CONFIG_ADV/LANGUAGE", 50, 0, -2.f, 0.f);
|
2016-11-07 16:06:00 +01:00
|
|
|
_setHideAnim(m_configAdvLblCurLanguage, "CONFIG_ADV/LANGUAGE_BTN", -50, 0, 1.f, 0.f);
|
|
|
|
_setHideAnim(m_configAdvBtnCurLanguageM, "CONFIG_ADV/LANGUAGE_MINUS", -50, 0, 1.f, 0.f);
|
|
|
|
_setHideAnim(m_configAdvBtnCurLanguageP, "CONFIG_ADV/LANGUAGE_PLUS", -50, 0, 1.f, 0.f);
|
2013-11-04 20:46:23 +01:00
|
|
|
_setHideAnim(m_configAdvLblCFTheme, "CONFIG_ADV/CUSTOMIZE_CF", 50, 0, -2.f, 0.f);
|
|
|
|
_setHideAnim(m_configAdvBtnCFTheme, "CONFIG_ADV/CUSTOMIZE_CF_BTN", -50, 0, 1.f, 0.f);
|
|
|
|
_setHideAnim(m_configAdvLblBootChange, "CONFIG_ADV/BOOT_CHANGE", 50, 0, -2.f, 0.f);
|
|
|
|
_setHideAnim(m_configAdvBtnBootChange, "CONFIG_ADV/BOOT_CHANGE_BTN", -50, 0, 1.f, 0.f);
|
2012-01-21 21:57:41 +01:00
|
|
|
_hideConfigAdv(true);
|
|
|
|
_textConfigAdv();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMenu::_textConfigAdv(void)
|
|
|
|
{
|
|
|
|
m_btnMgr.setText(m_configAdvLblTheme, _t("cfga7", L"Theme"));
|
2016-11-07 16:06:00 +01:00
|
|
|
m_btnMgr.setText(m_configAdvLblLanguage, _t("cfgc9", L"WiiFlow Language"));// manage wiiflow languages
|
|
|
|
//m_btnMgr.setText(m_configAdvBtnLanguage, _t("cfgc5", L"Go"));
|
2012-01-21 21:57:41 +01:00
|
|
|
m_btnMgr.setText(m_configAdvLblCFTheme, _t("cfgc4", L"Adjust Coverflow"));
|
|
|
|
m_btnMgr.setText(m_configAdvBtnCFTheme, _t("cfgc5", L"Go"));
|
2012-12-21 20:51:22 +01:00
|
|
|
m_btnMgr.setText(m_configAdvLblBootChange, _t("cfgc8", L"Startup Settings"));
|
|
|
|
m_btnMgr.setText(m_configAdvBtnBootChange, _t("cfgc5", L"Go"));
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|