- fix for categories crashing in emuflow

This commit is contained in:
fledge68 2012-05-16 11:48:27 +00:00
parent 4ccb9e08cf
commit 678dc5ac0d
2 changed files with 48 additions and 45 deletions

View File

@ -1470,7 +1470,6 @@ void CMenu::_initCF(void)
Config dump, gameAgeList; Config dump, gameAgeList;
GameTDB gametdb; GameTDB gametdb;
const char *domain = _domainFromView(); const char *domain = _domainFromView();
const char *catviews = m_cat.getString(domain, "categories", "100000000000000000000").c_str();
m_cf.clear(); m_cf.clear();
m_cf.reserve(m_gameList.size()); m_cf.reserve(m_gameList.size());
vector<bool> EnabledPlugins; vector<bool> EnabledPlugins;
@ -1494,7 +1493,7 @@ void CMenu::_initCF(void)
gametdb.SetLanguageCode(m_loc.getString(m_curLanguage, "gametdb_code", "EN").c_str()); gametdb.SetLanguageCode(m_loc.getString(m_curLanguage, "gametdb_code", "EN").c_str());
} }
} }
const char *catviews = m_cat.getString(domain, "categories", "100000000000000000000").c_str();
string id; string id;
for (u32 i = 0; i < m_gameList.size(); ++i) for (u32 i = 0; i < m_gameList.size(); ++i)
{ {

View File

@ -24,7 +24,8 @@ void CMenu::_hideCategorySettings(bool instant)
for(int i = 0; i < 21; ++i) for(int i = 0; i < 21; ++i)
{ {
m_btnMgr.hide(m_categoryLblCat[i]); m_btnMgr.hide(m_categoryLblCat[i]);
m_btnMgr.hide(m_categoryBtn[i]); m_btnMgr.hide(m_categoryBtnCat[i]);
m_btnMgr.hide(m_categoryBtnCats[i]);
} }
} }
@ -52,9 +53,13 @@ void CMenu::_updateCheckboxes(void)
} }
for(int i = 0; i < 21; ++i) for(int i = 0; i < 21; ++i)
{ {
m_btnMgr.hide(m_categoryBtn[i]); m_btnMgr.hide(m_categoryBtnCat[i]);
m_btnMgr.hide(m_categoryBtnCats[i]);
m_btnMgr.hide(m_categoryLblCat[i]); m_btnMgr.hide(m_categoryLblCat[i]);
} }
const char *catflags;
if (gameSet)
{
string id; string id;
if(m_current_view != COVERFLOW_EMU) if(m_current_view != COVERFLOW_EMU)
id = m_cf.getId(); id = m_cf.getId();
@ -69,9 +74,8 @@ void CMenu::_updateCheckboxes(void)
tempname.erase(tempname.find_last_of('.'), tempname.size() - tempname.find_last_of('.')); tempname.erase(tempname.find_last_of('.'), tempname.size() - tempname.find_last_of('.'));
id = dirName+tempname; id = dirName+tempname;
} }
const char *catflags;
if(gameSet)
catflags = m_cat.getString("CATEGORIES", id, "").c_str(); catflags = m_cat.getString("CATEGORIES", id, "").c_str();
}
else else
catflags = m_cat.getString(_domainFromView(), "categories", "100000000000000000000").c_str(); catflags = m_cat.getString(_domainFromView(), "categories", "100000000000000000000").c_str();
memset(&m_categories, '0', sizeof(m_categories)); memset(&m_categories, '0', sizeof(m_categories));
@ -89,10 +93,9 @@ void CMenu::_updateCheckboxes(void)
continue; continue;
m_btnMgr.show(m_categoryLblCat[i]); m_btnMgr.show(m_categoryLblCat[i]);
if(catflags[i] == '1') if(catflags[i] == '1')
m_categoryBtn[i] = m_categoryBtnCats[i]; m_btnMgr.show(m_categoryBtnCats[i]);
else else
m_categoryBtn[i] = m_categoryBtnCat[i]; m_btnMgr.show(m_categoryBtnCat[i]);
m_btnMgr.show(m_categoryBtn[i]);
} }
} }
else else
@ -101,10 +104,9 @@ void CMenu::_updateCheckboxes(void)
{ {
m_btnMgr.show(m_categoryLblCat[i]); m_btnMgr.show(m_categoryLblCat[i]);
if(catflags[i] == '1') if(catflags[i] == '1')
m_categoryBtn[i] = m_categoryBtnCats[i]; m_btnMgr.show(m_categoryBtnCats[i]);
else else
m_categoryBtn[i] = m_categoryBtnCat[i]; m_btnMgr.show(m_categoryBtnCat[i]);
m_btnMgr.show(m_categoryBtn[i]);
} }
} }
} }
@ -156,9 +158,11 @@ void CMenu::_CategorySettings(bool fromGameSet)
} }
for(int i = 0; i < 21; ++i) for(int i = 0; i < 21; ++i)
{ {
if(m_btnMgr.selected(m_categoryBtn[i])) if(m_btnMgr.selected(m_categoryBtnCat[i]) || m_btnMgr.selected(m_categoryBtnCats[i]))
{ {
lastBtn = m_categoryBtn[i]; lastBtn = m_categoryBtnCat[i];
if(m_btnMgr.selected(m_categoryBtnCats[i]))
lastBtn = m_categoryBtnCats[i];
m_btnMgr.noHover(true); m_btnMgr.noHover(true);
m_categories[i] = m_categories[i] == '1' ? '0' : '1'; m_categories[i] = m_categories[i] == '1' ? '0' : '1';
if(i == 0 && m_categories[i] == '1') if(i == 0 && m_categories[i] == '1')
@ -171,6 +175,10 @@ void CMenu::_CategorySettings(bool fromGameSet)
char catflags[22]; char catflags[22];
memset(&catflags, 0, sizeof(catflags)); memset(&catflags, 0, sizeof(catflags));
memcpy(&catflags, &m_categories, sizeof(m_categories)); memcpy(&catflags, &m_categories, sizeof(m_categories));
if(string (catflags) == "000000000000000000000")
catflags[0] = '1';
if (gameSet)
{
string id; string id;
if(m_current_view != COVERFLOW_EMU) if(m_current_view != COVERFLOW_EMU)
id = m_cf.getId(); id = m_cf.getId();
@ -185,10 +193,8 @@ void CMenu::_CategorySettings(bool fromGameSet)
tempname.erase(tempname.find_last_of('.'), tempname.size() - tempname.find_last_of('.')); tempname.erase(tempname.find_last_of('.'), tempname.size() - tempname.find_last_of('.'));
id = dirName+tempname; id = dirName+tempname;
} }
if(string (catflags) == "000000000000000000000")
catflags[0] = '1';
if(gameSet)
m_cat.setString("CATEGORIES", id, catflags); m_cat.setString("CATEGORIES", id, catflags);
}
else else
m_cat.setString(_domainFromView(), "categories", catflags); m_cat.setString(_domainFromView(), "categories", catflags);
_updateCheckboxes(); _updateCheckboxes();
@ -239,8 +245,6 @@ void CMenu::_initCategorySettingsMenu(CMenu::SThemeData &theme)
{ {
_setHideAnim(m_categoryBtnCat[i], fmt("CATEGORY/CAT_%i_BTN", i), 0, 0, 1.f, 0.f); _setHideAnim(m_categoryBtnCat[i], fmt("CATEGORY/CAT_%i_BTN", i), 0, 0, 1.f, 0.f);
_setHideAnim(m_categoryBtnCats[i], fmt("CATEGORY/CAT_%i_BTNS", i), 0, 0, 1.f, 0.f); _setHideAnim(m_categoryBtnCats[i], fmt("CATEGORY/CAT_%i_BTNS", i), 0, 0, 1.f, 0.f);
_setHideAnim(m_categoryLblCat[i], fmt("CATEGORY/CAT_%i", i), 0, 0, 1.f, 0.f);
m_categoryBtn[i] = m_categoryBtnCat[i];
} }
_hideCategorySettings(true); _hideCategorySettings(true);
_textCategorySettings(); _textCategorySettings();