-moved create sourceflow list to listgenerator and rewrote the code a little to include a sourceflow.db list cache file. may speed up loading sourceflow.

This commit is contained in:
fledge68 2016-04-03 01:12:11 +00:00
parent abcd42885b
commit 070612c161
6 changed files with 112 additions and 94 deletions

View File

@ -332,3 +332,51 @@ void GetFiles(const char *Path, const vector<string>& FileTypes,
GetFiles(p->c_str(), FileTypes, AddFile, CompareFolders, max_depth, depth + 1);
SubPaths.clear();
}
void ListGenerator::createSFList(u8 maxBtns, Config &m_sourceMenuCfg, bool show_homebrew, bool show_channel, bool show_plugin, bool show_gc,
const string& sourceDir, const string& DBName, bool UpdateCache)
{
if(!DBName.empty())
{
if(UpdateCache)
fsop_deleteFile(DBName.c_str());
else
{
CCache(*this, DBName, LOAD);
if(!this->empty())
return;
fsop_deleteFile(DBName.c_str());
}
}
char btn_selected[256];
for(u8 i = 0; i < maxBtns; i++)
{
memset(btn_selected, 0, 256);
strncpy(btn_selected, fmt("BUTTON_%i", i), 255);
string source = m_sourceMenuCfg.getString(btn_selected, "source","");
if(source == "")
continue;
if(source == "dml" && !show_gc)
continue;
else if(source == "emunand" && !show_channel)
continue;
else if(source == "homebrew" && (!show_homebrew))
continue;
else if((source == "plugin" || source == "allplugins") && !show_plugin)
continue;
const char *path = fmt("%s/%s", sourceDir.c_str(), m_sourceMenuCfg.getString(btn_selected, "image", "").c_str());
memset((void*)&ListElement, 0, sizeof(dir_discHdr));
ListElement.index = m_gameList.size();
strncpy(ListElement.id, "SOURCE", 6);
strncpy(ListElement.path, path, sizeof(ListElement.path) - 1);
ListElement.casecolor = 0xFFFFFF;
ListElement.type = TYPE_SOURCE;
ListElement.settings[0] = i;
const char *title = m_sourceMenuCfg.getString(btn_selected, "title", fmt("title_%i", i)).c_str();
mbstowcs(ListElement.title, title, 63);
Asciify(ListElement.title);
m_gameList.push_back(ListElement);
}
if(!this->empty() && !DBName.empty()) /* Write a new Cache */
CCache(*this, DBName, SAVE);
}

View File

@ -32,6 +32,8 @@ using namespace std;
class ListGenerator : public vector<dir_discHdr>
{
public:
void createSFList(u8 maxBtns, Config &m_sourceMenuCfg, bool show_homebrew, bool show_channel, bool show_plugin, bool show_gc, const string& sourceDir,
const string& DBName, bool UpdateCache);
void Init(const char *settingsDir, const char *Language);
void CreateList(u32 Flow, u32 Device, const string& Path, const vector<string>& FileTypes,
const string& DBName, bool UpdateCache);

View File

@ -1061,7 +1061,6 @@ private:
bool _Boot();
void _Paths();
void _sourceFlow();
void _createSFList();
void _mainLoopCommon(bool withCF = false, bool adjusting = false);
public:
void directlaunch(const char *GameID);

View File

@ -172,7 +172,14 @@ void CMenu::LoadView(void)
if(m_cfg.getBool("GENERAL", "save_favorites_mode", false))
m_favorites = m_cfg.getBool(_domainFromView(), "favorites", false);
if(m_sourceflow)
_createSFList();
{
m_gameList.clear();
string cacheDir(fmt("%s/sourceflow.db", m_listCacheDir.c_str()));
bool updateCache = m_cfg.getBool("SOURCEFLOW", "update_cache");
u8 maxBtns = m_cfg.getInt("GENERAL", "max_source_buttons", 71);
m_gameList.createSFList(maxBtns, m_source, show_homebrew, show_channel, show_plugin, show_gamecube, m_sourceDir, cacheDir, updateCache);
m_cfg.remove("SOURCEFLOW", "update_cache");
}
else
_loadList();

View File

@ -180,44 +180,6 @@ void CMenu::_showSourceNotice(void)
exitSource = false;
}
dir_discHdr sourceList;
void CMenu::_createSFList()
{
bool show_homebrew = !m_cfg.getBool(HOMEBREW_DOMAIN, "disable", false);
bool show_channel = !m_cfg.getBool("GENERAL", "hidechannel", false);
bool show_emu = !m_cfg.getBool(PLUGIN_DOMAIN, "disable", false);
bool parental_homebrew = m_cfg.getBool(HOMEBREW_DOMAIN, "parental", false);
m_gameList.clear();
for(u8 i = 0; i < m_cfg.getInt("GENERAL", "max_source_buttons", 71); i++)
{
memset(btn_selected, 0, 256);
strncpy(btn_selected, fmt("BUTTON_%i", i), 255);
string source = m_source.getString(btn_selected, "source","");
if(source == "")
continue;
if(source == "dml" && !m_show_gc)
continue;
else if(source == "emunand" && !show_channel)
continue;
else if(source == "homebrew" && (!show_homebrew || (!parental_homebrew && m_locked)))
continue;
else if((source == "plugin" || source == "allplugins") && !show_emu)
continue;
const char *path = fmt("%s/%s", m_sourceDir.c_str(), m_source.getString(btn_selected, "image", "").c_str());
memset((void*)&sourceList, 0, sizeof(dir_discHdr));
sourceList.index = m_gameList.size();
strncpy(sourceList.id, "SOURCE", 6);
strncpy(sourceList.path, path, sizeof(sourceList.path) - 1);
sourceList.casecolor = 0xFFFFFF;
sourceList.type = TYPE_SOURCE;
sourceList.settings[0] = i;
const char *title = m_source.getString(btn_selected, "title", fmt("title_%i", i)).c_str();
mbstowcs(sourceList.title, title, 63);
Asciify(sourceList.title);
m_gameList.push_back(sourceList);
}
}
void CMenu::_sourceFlow()
{
u8 k;