- code cleanup for themeName.

This commit is contained in:
Fledge68 2019-07-24 12:35:51 -05:00
parent a0cbc70f7a
commit 85020b1f03
7 changed files with 28 additions and 31 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 MiB

After

Width:  |  Height:  |  Size: 3.4 MiB

View File

@ -291,10 +291,10 @@ bool CMenu::init()
/* Load categories and theme INI files */
m_cat.load(fmt("%s/" CAT_FILENAME, m_settingsDir.c_str()));
m_gcfg1.load(fmt("%s/" GAME_SETTINGS1_FILENAME, m_settingsDir.c_str()));
string themeName = m_cfg.getString("GENERAL", "theme", "default");
m_themeDataDir = fmt("%s/%s", m_themeDir.c_str(), themeName.c_str());
m_themeName = m_cfg.getString("GENERAL", "theme", "default");
m_themeDataDir = fmt("%s/%s", m_themeDir.c_str(), m_themeName.c_str());
m_theme.load(fmt("%s.ini", m_themeDataDir.c_str()));
m_coverflow.load(fmt("%s/%s.ini", m_coverflowsDir.c_str(), themeName.c_str()));
m_coverflow.load(fmt("%s/%s.ini", m_coverflowsDir.c_str(), m_themeName.c_str()));
if(!m_coverflow.loaded())
m_coverflow.load(fmt("%s/default.ini", m_coverflowsDir.c_str()));
m_platform.load(fmt("%s/platform.ini", m_pluginDataDir.c_str()));

View File

@ -119,6 +119,7 @@ private:
s16 m_showtimer;
s16 m_musicTimer;
string m_curLanguage;
string m_themeName;
/* Dir strings */
string m_appDir;

View File

@ -335,7 +335,7 @@ void CMenu::_cfTheme(void)
{
m_coverflow.clear();
m_coverflow.unload();
m_coverflow.load(fmt("%s/%s.ini", m_coverflowsDir.c_str(), m_cfg.getString("GENERAL", "theme", "default").c_str()));
m_coverflow.load(fmt("%s/%s.ini", m_coverflowsDir.c_str(), m_themeName.c_str()));
if(!m_coverflow.loaded())
m_coverflow.load(fmt("%s/default.ini", m_coverflowsDir.c_str()));
break;
@ -428,7 +428,7 @@ void CMenu::_cfTheme(void)
{
m_coverflow.clear();
m_coverflow.unload();
m_coverflow.load(fmt("%s/%s.ini", m_coverflowsDir.c_str(), m_cfg.getString("GENERAL", "theme", "default").c_str()));
m_coverflow.load(fmt("%s/%s.ini", m_coverflowsDir.c_str(), m_themeName.c_str()));
if(!m_coverflow.loaded())
m_coverflow.load(fmt("%s/default.ini", m_coverflowsDir.c_str()));
break;

View File

@ -10,7 +10,6 @@ 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)
{
@ -66,7 +65,7 @@ void CMenu::_showConfigAdv(void)
if(m_configAdvLblUser[i] != -1)
m_btnMgr.show(m_configAdvLblUser[i]);
m_btnMgr.setText(m_configAdvLblCurTheme, m_cfg.getString("GENERAL", "theme"));
m_btnMgr.setText(m_configAdvLblCurTheme, m_themeName);
m_btnMgr.setText(m_configAdvLblCurLanguage, m_curLanguage);
}
@ -101,11 +100,10 @@ int CMenu::_configAdv(void)
int change = CONFIG_PAGE_NO_CHANGE;
vector<string> themes;
string prevTheme = m_cfg.getString("GENERAL", "theme");
listThemes(m_themeDir.c_str(), themes);
int curTheme = 0;
u32 curTheme = 0;
for (u32 i = 0; i < themes.size(); ++i)
if (themes[i] == prevTheme)
if (themes[i] == m_themeName)
{
curTheme = i;
break;
@ -116,15 +114,16 @@ int CMenu::_configAdv(void)
GetFiles(m_languagesDir.c_str(), stringToVector(".ini", '|'), AddLanguage, false, 0);
sort(languages_available.begin(), languages_available.end());
u32 curLang = 0;
for(u32 i = 0; i < languages_available.size(); ++i)
{
if(m_curLanguage == languages_available[i])
{
available_pos = i;
curLang = i;
break;
}
}
string prevLanguage = languages_available[available_pos];
string prevLanguage = m_curLanguage;
_showConfigAdv();
while(!m_exit)
@ -144,23 +143,24 @@ int CMenu::_configAdv(void)
else if(m_btnMgr.selected(m_configAdvBtnCurThemeP) || m_btnMgr.selected(m_configAdvBtnCurThemeM))
{
s8 direction = m_btnMgr.selected(m_configAdvBtnCurThemeP) ? 1 : -1;
curTheme = loopNum(curTheme + direction, (int)themes.size());
m_cfg.setString("GENERAL", "theme", themes[curTheme]);
curTheme = loopNum(curTheme + direction, (u32)themes.size());
m_themeName = themes[curTheme];
m_cfg.setString("GENERAL", "theme", m_themeName);
_showConfigAdv();
}
else if(m_btnMgr.selected(m_configAdvBtnCurLanguageP) || m_btnMgr.selected(m_configAdvBtnCurLanguageM))
{
s8 direction = m_btnMgr.selected(m_configAdvBtnCurLanguageP) ? 1 : -1;
available_pos = loopNum(available_pos + direction, (u32)languages_available.size());
m_curLanguage = languages_available[available_pos];
curLang = loopNum(curLang + direction, (u32)languages_available.size());
m_curLanguage = languages_available[curLang];
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_cfg.setString("GENERAL", "language", m_curLanguage);
m_loc.unload();
}
else
m_cfg.setString("GENERAL", "language", m_curLanguage.c_str());
m_cfg.setString("GENERAL", "language", m_curLanguage);
_updateText();
_showConfigAdv();
}

View File

@ -82,10 +82,9 @@ void CMenu::_setMainBg()
}
if(fn.length() > 0)
{
string themeName = m_cfg.getString("GENERAL", "theme", "default");
if(TexHandle.fromImageFile(m_mainAltBg, fmt("%s/%s/%s.png", m_bckgrndsDir.c_str(), themeName.c_str(), fn.c_str())) != TE_OK)
if(TexHandle.fromImageFile(m_mainAltBg, fmt("%s/%s/%s.png", m_bckgrndsDir.c_str(), m_themeName.c_str(), fn.c_str())) != TE_OK)
{
if(TexHandle.fromImageFile(m_mainAltBg, fmt("%s/%s/%s.jpg", m_bckgrndsDir.c_str(), themeName.c_str(), fn.c_str())) != TE_OK)
if(TexHandle.fromImageFile(m_mainAltBg, fmt("%s/%s/%s.jpg", m_bckgrndsDir.c_str(), m_themeName.c_str(), fn.c_str())) != TE_OK)
{
if(TexHandle.fromImageFile(m_mainAltBg, fmt("%s/%s.png", m_bckgrndsDir.c_str(), fn.c_str())) != TE_OK)
{
@ -332,7 +331,7 @@ void CMenu::_showCF(bool refreshList)
int CMenu::main(void)
{
wstringEx curLetter;
string prevTheme = m_cfg.getString("GENERAL", "theme", "default");
string prevTheme = m_themeName;
bool show_channel = !m_cfg.getBool(CHANNEL_DOMAIN, "disable", false);
bool show_plugin = !m_cfg.getBool(PLUGIN_DOMAIN, "disable", false);
bool show_gamecube = !m_cfg.getBool(GC_DOMAIN, "disable", false);
@ -488,7 +487,7 @@ int CMenu::main(void)
/* main menu global settings */
_hideMain();
_config(1);
if(prevTheme != m_cfg.getString("GENERAL", "theme"))
if(prevTheme != m_themeName)
{
/* new theme - exit wiiflow and reload */
fsop_deleteFolder(fmt("%s/sourceflow", m_cacheDir.c_str()));

View File

@ -14,7 +14,6 @@ s16 m_sourceLblUser[4];
TexData m_sourceBg;
string source;
const char *themeName = NULL;
bool exitSource = false;
u8 sourceBtn;
u8 selectedBtns;
@ -197,8 +196,7 @@ void CMenu::_setSrcFlowBg(void)
string fn = m_source.getString("general", "background", "");
if(fn.length() > 0)
{
string themeName = m_cfg.getString("GENERAL", "theme", "default");
if(TexHandle.fromImageFile(sfbgimg, fmt("%s/backgrounds/%s/%s", m_sourceDir.c_str(), themeName.c_str(), fn.c_str())) != TE_OK)
if(TexHandle.fromImageFile(sfbgimg, fmt("%s/backgrounds/%s/%s", m_sourceDir.c_str(), m_themeName.c_str(), fn.c_str())) != TE_OK)
{
if(TexHandle.fromImageFile(sfbgimg, fmt("%s/backgrounds/%s", m_sourceDir.c_str(), fn.c_str())) != TE_OK)
{
@ -347,12 +345,12 @@ void CMenu::_updateSourceBtns(void)
TexData texConsoleImg;
TexData texConsoleImgs;
if(TexHandle.fromImageFile(texConsoleImg, fmt("%s/%s/%s", m_sourceDir.c_str(), themeName, btn_image)) != TE_OK)
if(TexHandle.fromImageFile(texConsoleImg, fmt("%s/%s/%s", m_sourceDir.c_str(), m_themeName.c_str(), btn_image)) != TE_OK)
{
if(TexHandle.fromImageFile(texConsoleImg, fmt("%s/%s", m_sourceDir.c_str(), btn_image)) != TE_OK)
TexHandle.fromImageFile(texConsoleImg, fmt("%s/favoriteson.png", m_imgsDir.c_str()));
}
if(TexHandle.fromImageFile(texConsoleImgs, fmt("%s/%s/%s", m_sourceDir.c_str(), themeName, btn_image)) != TE_OK)
if(TexHandle.fromImageFile(texConsoleImgs, fmt("%s/%s/%s", m_sourceDir.c_str(), m_themeName.c_str(), btn_image)) != TE_OK)
{
if(TexHandle.fromImageFile(texConsoleImgs, fmt("%s/%s", m_sourceDir.c_str(), btn_image)) != TE_OK)
TexHandle.fromImageFile(texConsoleImgs, fmt("%s/favoritesons.png", m_imgsDir.c_str()));
@ -769,14 +767,13 @@ void CMenu::_initSourceMenu()
memset(single_sourcebtn, 0, 16);
m_use_source = false;
themeName = m_cfg.getString("GENERAL", "theme", "default").c_str();
if(!m_source.load(fmt("%s/%s/%s", m_sourceDir.c_str(), themeName, SOURCE_FILENAME)))// check for source_menu/theme/source_menu.ini
if(!m_source.load(fmt("%s/%s/%s", m_sourceDir.c_str(), m_themeName.c_str(), SOURCE_FILENAME)))// check for source_menu/theme/source_menu.ini
{
if(!m_source.load(fmt("%s/%s", m_sourceDir.c_str(), SOURCE_FILENAME)))// check for source_menu/source_menu.ini
return;// no source_menu.ini so we dont init nor use source menu, just return.
}
else // if source_menu/theme/source_menu.ini found then change m_sourceDir to source_menu/theme/
m_sourceDir = fmt("%s/%s", m_sourceDir.c_str(), themeName);
m_sourceDir = fmt("%s/%s", m_sourceDir.c_str(), m_themeName.c_str());
/* let wiiflow know source_menu.ini found and we will be using it */
m_use_source = true;