-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

@ -1,53 +1,55 @@
/****************************************************************************
* Copyright (C) 2012 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/>.
****************************************************************************/
#ifndef _LISTGENERATOR_HPP_
#define _LISTGENERATOR_HPP_
#include <string>
#include <vector>
#include <stdio.h>
#include "types.h"
#include "config/config.hpp"
#include "loader/wbfs.h"
#include "loader/disc.h"
#include "gui/GameTDB.hpp"
using namespace std;
class ListGenerator : public vector<dir_discHdr>
{
public:
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);
u32 Color;
u32 Magic;
private:
void OpenConfigs();
void CloseConfigs();
string gameTDB_Path;
string CustomTitlesPath;
string gameTDB_Language;
};
typedef void (*FileAdder)(char *Path);
void GetFiles(const char *Path, const vector<string>& FileTypes,
FileAdder AddFile, bool CompareFolders, u32 max_depth = 2, u32 depth = 1);
extern ListGenerator m_gameList;
#endif /*_LISTGENERATOR_HPP_*/
/****************************************************************************
* Copyright (C) 2012 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/>.
****************************************************************************/
#ifndef _LISTGENERATOR_HPP_
#define _LISTGENERATOR_HPP_
#include <string>
#include <vector>
#include <stdio.h>
#include "types.h"
#include "config/config.hpp"
#include "loader/wbfs.h"
#include "loader/disc.h"
#include "gui/GameTDB.hpp"
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);
u32 Color;
u32 Magic;
private:
void OpenConfigs();
void CloseConfigs();
string gameTDB_Path;
string CustomTitlesPath;
string gameTDB_Language;
};
typedef void (*FileAdder)(char *Path);
void GetFiles(const char *Path, const vector<string>& FileTypes,
FileAdder AddFile, bool CompareFolders, u32 max_depth = 2, u32 depth = 1);
extern ListGenerator m_gameList;
#endif /*_LISTGENERATOR_HPP_*/

View File

@ -2236,7 +2236,7 @@ bool CMenu::_loadGamecubeList()
string gameDir(fmt(gc_games_dir, DeviceName[currentPartition]));
string cacheDir(fmt("%s/%s_gamecube.db", m_listCacheDir.c_str(), DeviceName[currentPartition]));
bool updateCache = m_cfg.getBool(GC_DOMAIN, "update_cache");
m_gameList.CreateList(COVERFLOW_GAMECUBE, currentPartition, gameDir, stringToVector(".iso|root", '|'),cacheDir, updateCache);
m_gameList.CreateList(COVERFLOW_GAMECUBE, currentPartition, gameDir, stringToVector(".iso|root", '|'), cacheDir, updateCache);
m_cfg.remove(GC_DOMAIN, "update_cache");
return true;
}

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;