-changed the way wiiflow makes a plugin gamelist. on startup if plugin view is enabled wiiflow gets and counts every plugin ini instead of doing it every time we load plugin view. might speed up loding plugin view but adds time to wiiflow boot up.

-other minor code changes.
This commit is contained in:
fledge68 2016-04-03 00:51:40 +00:00
parent 54bc13964d
commit 8678a77eb0
11 changed files with 227 additions and 197 deletions

View File

@ -305,7 +305,7 @@ void CCoverFlow::setHQcover(bool HQ)
void CCoverFlow::setBufferSize(u32 numCovers)
{
if(m_covers != NULL) return;
m_numBufCovers = min(max(4u, numCovers / 2u), 40u);
m_numBufCovers = min(max(4u, numCovers / 2u), 40u);//8 to 80
}
void CCoverFlow::setTextures(const string &loadingPic, const string &loadingPicFlat, const string &noCoverPic, const string &noCoverPicFlat)
@ -2821,7 +2821,7 @@ CCoverFlow::CLRet CCoverFlow::_loadCoverTex(u32 i, bool box, bool hq, bool blank
fp = fopen(full_path, "rb");
MEM2_free(full_path);
}
if(fp != NULL)
if(fp != NULL)//if wfc chache file is found
{
bool success = false;
fseek(fp, 0, SEEK_END);
@ -2831,6 +2831,8 @@ CCoverFlow::CLRet CCoverFlow::_loadCoverTex(u32 i, bool box, bool hq, bool blank
if(fileSize > sizeof(header))
{
fread(&header, 1, sizeof(header), fp);
//ok the cache file might be compressed when you don't want compress or it might be front when you want box
//or it might be old format
// Try to find a matching cache file, otherwise try the PNG file, otherwise try again with the cache file with less constraints
if(header.newFmt != 0 && (((!box || header.full != 0) && (header.cmpr != 0) == m_compressTextures) || (!_loadCoverTexPNG(i, box, hq, blankBoxCover))))
{
@ -2898,7 +2900,7 @@ CCoverFlow::CLRet CCoverFlow::_loadCoverTex(u32 i, bool box, bool hq, bool blank
if(allocFailed)
return CL_NOMEM;
// If not found, load the PNG
// If wfc cache file not found, load the PNG and create a wfc cache file
return _loadCoverTexPNG(i, box, hq, blankBoxCover) ? CL_OK : CL_ERROR;
}

View File

@ -82,6 +82,7 @@ CMenu::CMenu()
m_use_source = true;
m_multisource = false;
m_sourceflow = false;
m_numPlugins = 0;
m_clearCats = true;
m_catStartPage = 1;
m_combined_view = false;
@ -108,6 +109,13 @@ CMenu::CMenu()
m_source_autoboot = false;
}
static vector<string> INI_List;
static void GrabINIFiles(char *FullPath)
{
//Just push back
INI_List.push_back(FullPath);
}
void CMenu::init()
{
SoundHandle.Init();
@ -252,7 +260,7 @@ void CMenu::init()
/* Emu NAND */
m_cfg.getString(CHANNEL_DOMAIN, "path", "");
m_cfg.getInt(CHANNEL_DOMAIN, "partition", 1);
m_cfg.getBool(CHANNEL_DOMAIN, "disable", true);
m_cfg.getBool(CHANNEL_DOMAIN, "disable", true);//emu_nand
/* Load cIOS Map */
_installed_cios.clear();
if(!neek2o() && !Sys_DolphinMode())
@ -363,6 +371,28 @@ void CMenu::init()
m_themeDataDir = fmt("%s/%s", m_themeDir.c_str(), themeName.c_str());
m_theme.load(fmt("%s.ini", m_themeDataDir.c_str()));
m_plugin.init(m_pluginsDir);
// get plugin ini files if plugin view enabled
if(!m_cfg.getBool(PLUGIN_DOMAIN, "disable", false))
{
Config m_plugin_cfg;
INI_List.clear();
GetFiles(m_pluginsDir.c_str(), stringToVector(".ini", '|'), GrabINIFiles, false, 1);
for(vector<string>::const_iterator iniFile = INI_List.begin(); iniFile != INI_List.end(); ++iniFile)
{
if(iniFile->find("scummvm.ini") != string::npos)
continue;
m_plugin_cfg.load(iniFile->c_str());
if(m_plugin_cfg.loaded())
{
m_plugin.AddPlugin(m_plugin_cfg);
m_numPlugins++;
}
m_plugin_cfg.unload();
}
m_plugin.EndAdd();
}
const char *defLang = "Default";
switch (CONF_GetLanguage())
@ -1365,11 +1395,11 @@ vector<TexData> CMenu::_textures(const char *domain, const char *key)
TexSet::iterator i = theme.texSet.find(filename);
if (i != theme.texSet.end())
textures.push_back(i->second);
TexData tex;
if(TexHandle.fromImageFile(tex, fmt("%s/%s", m_themeDataDir.c_str(), filename.c_str())) == TE_OK)
TexData themetex;
if(TexHandle.fromImageFile(themetex, fmt("%s/%s", m_themeDataDir.c_str(), filename.c_str())) == TE_OK)
{
theme.texSet[filename] = tex;
textures.push_back(tex);
theme.texSet[filename] = themetex;
textures.push_back(themetex);
}
}
}
@ -1391,16 +1421,16 @@ TexData CMenu::_texture(const char *domain, const char *key, TexData &def, bool
if(i != theme.texSet.end())
return i->second;
/* Load from image file */
TexData tex;
if(TexHandle.fromImageFile(tex, fmt("%s/%s", m_themeDataDir.c_str(), filename.c_str())) == TE_OK)
TexData themetex;
if(TexHandle.fromImageFile(themetex, fmt("%s/%s", m_themeDataDir.c_str(), filename.c_str())) == TE_OK)
{
if(freeDef && def.data != NULL)
{
free(def.data);
def.data = NULL;
}
theme.texSet[filename] = tex;
return tex;
theme.texSet[filename] = themetex;
return themetex;
}
}
}
@ -1801,8 +1831,8 @@ void CMenu::_initCF(void)
CoverFlow.setBufferSize(m_cfg.getInt("GENERAL", "cover_buffer", 20));
CoverFlow.setSorting((Sorting)m_cfg.getInt(domain, "sort", 0));
CoverFlow.setHQcover(m_cfg.getBool("GENERAL", "cover_use_hq", false));
CoverFlow.start(m_imgsDir);
if(!CoverFlow.empty())
{
u8 view = m_current_view;
@ -2156,7 +2186,7 @@ bool CMenu::_loadList(void)
m_cfg.getBool(PLUGIN_DOMAIN, "source"))
{
m_current_view = COVERFLOW_PLUGIN;
_loadEmuList();
_loadPluginList();
if(m_combined_view)
for(vector<dir_discHdr>::iterator tmp_itr = m_gameList.begin(); tmp_itr != m_gameList.end(); tmp_itr++)
combinedList.push_back(*tmp_itr);
@ -2165,7 +2195,7 @@ bool CMenu::_loadList(void)
m_cfg.getBool(WII_DOMAIN, "source"))
{
m_current_view = COVERFLOW_WII;
_loadGameList();
_loadWiiList();
if(m_combined_view)
for(vector<dir_discHdr>::iterator tmp_itr = m_gameList.begin(); tmp_itr != m_gameList.end(); tmp_itr++)
combinedList.push_back(*tmp_itr);
@ -2183,7 +2213,7 @@ bool CMenu::_loadList(void)
m_cfg.getBool(GC_DOMAIN, "source"))
{
m_current_view = COVERFLOW_GAMECUBE;
_loadGCList();
_loadGamecubeList();
if(m_combined_view)
for(vector<dir_discHdr>::iterator tmp_itr = m_gameList.begin(); tmp_itr != m_gameList.end(); tmp_itr++)
combinedList.push_back(*tmp_itr);
@ -2210,7 +2240,7 @@ bool CMenu::_loadList(void)
return m_gameList.size() > 0 ? true : false;
}
bool CMenu::_loadGameList(void)
bool CMenu::_loadWiiList(void)
{
currentPartition = m_cfg.getInt(WII_DOMAIN, "partition", USB1);
if(!DeviceHandle.IsInserted(currentPartition))
@ -2242,7 +2272,7 @@ bool CMenu::_loadHomebrewList()
return true;
}
bool CMenu::_loadGCList()
bool CMenu::_loadGamecubeList()
{
currentPartition = m_cfg.getInt(GC_DOMAIN, "partition", USB1);
if(!DeviceHandle.IsInserted(currentPartition))
@ -2252,75 +2282,58 @@ bool CMenu::_loadGCList()
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;
}
static vector<string> INI_List;
static void GrabINIFiles(char *FullPath)
{
//Just push back
INI_List.push_back(FullPath);
}
bool CMenu::_loadEmuList()
bool CMenu::_loadPluginList()
{
currentPartition = m_cfg.getInt(PLUGIN_DOMAIN, "partition", SD);
if(!DeviceHandle.IsInserted(currentPartition))
return false;
bool updateCache = m_cfg.getBool(PLUGIN_DOMAIN, "update_cache");
vector<dir_discHdr> emuList;
Config m_plugin_cfg;
vector<dir_discHdr> pluginList;
INI_List.clear();
GetFiles(m_pluginsDir.c_str(), stringToVector(".ini", '|'), GrabINIFiles, false, 1);
for(vector<string>::const_iterator Name = INI_List.begin(); Name != INI_List.end(); ++Name)
for(u8 i = 0; i < m_numPlugins; ++i)
{
m_gameList.clear();
if(Name->find("scummvm.ini") != string::npos)
u32 Magic = m_plugin.getPluginMagic(i);
//memset(m_plugin.PluginMagicWord, 0, sizeof(m_plugin.PluginMagicWord));
strncpy(m_plugin.PluginMagicWord, fmt("%08x", Magic), 8);
if(!m_cfg.getBool(PLUGIN_ENABLED, m_plugin.PluginMagicWord, true))
continue;
m_plugin_cfg.load(Name->c_str());
if(m_plugin_cfg.loaded())
string romDir = m_plugin.GetRomDir(i);
if(romDir.find("scummvm.ini") == string::npos)
{
m_plugin.AddPlugin(m_plugin_cfg);
u32 MagicWord = strtoul(m_plugin_cfg.getString(PLUGIN_INI_DEF,"magic").c_str(), NULL, 16);
if(!m_plugin.GetEnableStatus(m_cfg, MagicWord))
continue;
if(m_plugin_cfg.getString(PLUGIN_INI_DEF,"romDir").find("scummvm.ini") == string::npos)
{
string gameDir(fmt("%s:/%s", DeviceName[currentPartition], m_plugin_cfg.getString(PLUGIN_INI_DEF,"romDir").c_str()));
string cacheDir(fmt("%s/%s_%s.db", m_listCacheDir.c_str(), DeviceName[currentPartition], m_plugin_cfg.getString(PLUGIN_INI_DEF,"magic").c_str()));
vector<string> FileTypes = stringToVector(m_plugin_cfg.getString(PLUGIN_INI_DEF,"fileTypes"), '|');
m_gameList.Color = strtoul(m_plugin_cfg.getString(PLUGIN_INI_DEF,"coverColor").c_str(), NULL, 16);
m_gameList.Magic = MagicWord;
m_gameList.CreateList(COVERFLOW_PLUGIN, currentPartition, gameDir, FileTypes, cacheDir, updateCache);
for(vector<dir_discHdr>::iterator tmp_itr = m_gameList.begin(); tmp_itr != m_gameList.end(); tmp_itr++)
emuList.push_back(*tmp_itr);
}
else
{
Config scummvm;
vector<dir_discHdr> scummvmList;
scummvm.load(fmt("%s/%s", m_pluginsDir.c_str(), "scummvm.ini"));
scummvmList = m_plugin.ParseScummvmINI(scummvm, DeviceName[currentPartition], MagicWord);
for(vector<dir_discHdr>::iterator tmp_itr = scummvmList.begin(); tmp_itr != scummvmList.end(); tmp_itr++)
emuList.push_back(*tmp_itr);
}
string gameDir(fmt("%s:/%s", DeviceName[currentPartition], m_plugin.GetRomDir(i)));
string cacheDir(fmt("%s/%s_%s.db", m_listCacheDir.c_str(), DeviceName[currentPartition], m_plugin.PluginMagicWord));
//string fileTypes = m_plugin.GetFileTypes(i);
vector<string> FileTypes = stringToVector(m_plugin.GetFileTypes(i), '|');
m_gameList.Color = m_plugin.GetCaseColor(i);
m_gameList.Magic = Magic;
m_gameList.CreateList(COVERFLOW_PLUGIN, currentPartition, gameDir, FileTypes, cacheDir, updateCache);
for(vector<dir_discHdr>::iterator tmp_itr = m_gameList.begin(); tmp_itr != m_gameList.end(); tmp_itr++)
pluginList.push_back(*tmp_itr);
}
else
{
Config scummvm;
vector<dir_discHdr> scummvmList;
scummvm.load(fmt("%s/%s", m_pluginsDir.c_str(), "scummvm.ini"));
scummvmList = m_plugin.ParseScummvmINI(scummvm, DeviceName[currentPartition], Magic);
for(vector<dir_discHdr>::iterator tmp_itr = scummvmList.begin(); tmp_itr != scummvmList.end(); tmp_itr++)
pluginList.push_back(*tmp_itr);
}
m_plugin_cfg.unload();
}
m_gameList.clear();
for(vector<dir_discHdr>::iterator tmp_itr = emuList.begin(); tmp_itr != emuList.end(); tmp_itr++)
for(vector<dir_discHdr>::iterator tmp_itr = pluginList.begin(); tmp_itr != pluginList.end(); tmp_itr++)
{
tmp_itr->index = m_gameList.size();
m_gameList.push_back(*tmp_itr);
}
emuList.clear();
//If we return to the coverflow before wiiflow quit we dont need to reload plugins
m_plugin.EndAdd();
pluginList.clear();
m_cfg.remove(PLUGIN_DOMAIN, "update_cache");
return true;
}
@ -2610,10 +2623,10 @@ const char *CMenu::getBlankCoverPath(const dir_discHdr *element)
blankCoverKey = "gamecube";
break;
case TYPE_PLUGIN:
char PluginMagicWord[9];
memset(PluginMagicWord, 0, sizeof(PluginMagicWord));
strncpy(PluginMagicWord, fmt("%08x", element->settings[0]), 8);
blankCoverKey = PluginMagicWord;
//char PluginMagicWord[9];
//memset(PluginMagicWord, 0, sizeof(PluginMagicWord));
strncpy(m_plugin.PluginMagicWord, fmt("%08x", element->settings[0]), 8);
blankCoverKey = m_plugin.PluginMagicWord;
break;
default:
blankCoverKey = "wii";

View File

@ -84,6 +84,7 @@ private:
u8 *m_file;
u8 *m_buffer;
u8 m_aa;
u8 m_numPlugins;
bool m_bnr_settings;
bool m_directLaunch;
bool m_locked;
@ -192,9 +193,9 @@ private:
s16 m_mainBtnWii;
s16 m_mainBtnChannel;
s16 m_mainBtnHomebrew;
s16 m_mainBtnInit;
s16 m_mainBtnInit2;
s16 m_mainLblInit;
s16 m_mainBtnInstall;
s16 m_mainBtnSelPart;
s16 m_mainLblMessage;
s16 m_mainLblUser[6];
bool m_show_gc;
bool m_devo_installed;
@ -851,10 +852,10 @@ private:
};
//
bool _loadList(void);
bool _loadGameList(void);
bool _loadGCList(void);
bool _loadWiiList(void);
bool _loadGamecubeList(void);
bool _loadChannelList(void);
bool _loadEmuList(void);
bool _loadPluginList(void);
bool _loadHomebrewList(void);
void _initCF(void);
void _initBoot(void);

View File

@ -102,9 +102,9 @@ const CMenu::SCFParamDesc CMenu::_cfParams[] = {
{ { -3.f, 0.5f }, { 0.f, 2.f }, { 0.f, 1.f }, { 0.f, 0.f } } }
};
static inline int loopNum(int i, int s)
template <class T> static inline T loopNum(T i, T s)
{
return i < 0 ? (s - (-i % s)) % s : i % s;
return (i + s) % s;
}
static const u16 g_txtStyles[9] = {
@ -145,11 +145,6 @@ static string styleToTxt(u16 s)
return ts;
}
template <class T> static inline T loopNum(T i, T s)
{
return (i + s) % s;
}
void CMenu::_hideCFTheme(bool instant)
{
m_btnMgr.hide(m_cfThemeBtnAlt, instant);
@ -421,7 +416,7 @@ void CMenu::_cfTheme(void)
}
else if (m_btnMgr.selected(m_cfThemeBtnAlt))
{
cfVersion = 1 + loopNum(cfVersion, m_numCFVersions);
cfVersion = 1 + loopNum((u8)cfVersion, m_numCFVersions);
_showCFTheme(curParam, cfVersion, wide);
_loadCFLayout(cfVersion, true, wide != m_vid.wide());
CoverFlow.applySettings();

View File

@ -8,9 +8,9 @@
static const int g_curPage = 4;
static inline int loopNum(int i, int s)
template <class T> static inline T loopNum(T i, T s)
{
return i < 0 ? (s - (-i % s)) % s : i % s;
return (i + s) % s;
}
int currentChannelIndex = -1;

View File

@ -6,9 +6,9 @@
#define ARRAY_SIZE(a) (sizeof a / sizeof a[0])
static inline int loopNum(int i, int s)
template <class T> static inline T loopNum(T i, T s)
{
return i < 0 ? (s - (-i % s)) % s : i % s;
return (i + s) % s;
}
u8 m_gameSettingsMaxPgs = 5;

View File

@ -17,7 +17,7 @@
static inline int loopNum(int i, int s)
{
return i < 0 ? (s - (-i % s)) % s : i % s;
return (i + s) % s;
}
void CMenu::_hideMain(bool instant)
@ -33,9 +33,9 @@ void CMenu::_hideMain(bool instant)
m_btnMgr.hide(m_mainBtnGamecube, instant);
m_btnMgr.hide(m_mainBtnPlugin, instant);
m_btnMgr.hide(m_mainBtnDVD, instant);
m_btnMgr.hide(m_mainBtnInit, instant);
m_btnMgr.hide(m_mainBtnInit2, instant);
m_btnMgr.hide(m_mainLblInit, instant);
m_btnMgr.hide(m_mainBtnInstall, instant);
m_btnMgr.hide(m_mainBtnSelPart, instant);
m_btnMgr.hide(m_mainLblMessage, instant);
m_btnMgr.hide(m_mainBtnFavoritesOn, instant);
m_btnMgr.hide(m_mainBtnFavoritesOff, instant);
m_btnMgr.hide(m_mainLblLetter, instant);
@ -48,7 +48,7 @@ void CMenu::_hideMain(bool instant)
static bool show_homebrew = true;
static bool parental_homebrew = false;
static bool show_channel = true;
static bool show_emu = true;
static bool show_plugin = true;
static bool show_gamecube = true;
void CMenu::_showMain(void)
@ -71,7 +71,7 @@ start_main:
case COVERFLOW_GAMECUBE:
if(show_channel)
m_btnMgr.show(m_mainBtnChannel);
else if(show_emu)
else if(show_plugin)
m_btnMgr.show(m_mainBtnPlugin);
else if(show_homebrew)
m_btnMgr.show(m_mainBtnHomebrew);
@ -79,7 +79,7 @@ start_main:
m_btnMgr.show(m_mainBtnWii);
break;
case COVERFLOW_CHANNEL:
if(show_emu)
if(show_plugin)
m_btnMgr.show(m_mainBtnPlugin);
else if(show_homebrew)
m_btnMgr.show(m_mainBtnHomebrew);
@ -101,7 +101,7 @@ start_main:
m_btnMgr.show(m_mainBtnGamecube);
else if(show_channel)
m_btnMgr.show(m_mainBtnChannel);
else if(show_emu)
else if(show_plugin)
m_btnMgr.show(m_mainBtnPlugin);
else if(show_homebrew)
m_btnMgr.show(m_mainBtnHomebrew);
@ -120,11 +120,11 @@ start_main:
{
case COVERFLOW_WII:
case COVERFLOW_GAMECUBE:
// m_btnMgr.setText(m_mainLblInit, _t("main2", L"No games found! Please select partition to change the device/partition or click Install to install a game."));
m_btnMgr.setText(m_mainLblInit, _t("main2", L"Welcome to WiiFlow. I have not found any games. Click Install to install games, or Select partition to select your partition type."));
m_btnMgr.show(m_mainBtnInit);
m_btnMgr.show(m_mainBtnInit2);
m_btnMgr.show(m_mainLblInit);
m_btnMgr.setText(m_mainLblMessage, _t("main2", L"No games found! Please select partition to change the device/partition or click Install to install a game."));
// m_btnMgr.setText(m_mainLblMessage, _t("main2", L"Welcome to WiiFlow. I have not found any games. Click Install to install games, or Select partition to select your partition type."));
m_btnMgr.show(m_mainBtnInstall);
m_btnMgr.show(m_mainBtnSelPart);
m_btnMgr.show(m_mainLblMessage);
break;
case COVERFLOW_CHANNEL:
if(NANDemuView)
@ -140,16 +140,16 @@ start_main:
}
break;
case COVERFLOW_HOMEBREW:
// m_btnMgr.setText(m_mainLblInit, _t("main4", L"No homebrew apps found! Try changing the partition to select the correct device/partition."));
m_btnMgr.setText(m_mainLblInit, _t("main4", L"Welcome to WiiFlow. I have not found any homebrew apps. Select partition to select your partition type."));
m_btnMgr.show(m_mainBtnInit2);
m_btnMgr.show(m_mainLblInit);
m_btnMgr.setText(m_mainLblMessage, _t("main4", L"No homebrew apps found! Try changing the partition to select the correct device/partition."));
// m_btnMgr.setText(m_mainLblMessage, _t("main4", L"Welcome to WiiFlow. I have not found any homebrew apps. Select partition to select your partition type."));
m_btnMgr.show(m_mainBtnSelPart);
m_btnMgr.show(m_mainLblMessage);
break;
case COVERFLOW_PLUGIN:
// m_btnMgr.setText(m_mainLblInit, _t("main5", L"No roms/items for your plugin found! Try changing the partition to select the correct device/partition."));
m_btnMgr.setText(m_mainLblInit, _t("main5", L"Welcome to WiiFlow. I have not found any plugins. Select partition to select your partition type."));
m_btnMgr.show(m_mainBtnInit2);
m_btnMgr.show(m_mainLblInit);
m_btnMgr.setText(m_mainLblMessage, _t("main5", L"No roms/items for your plugin found! Try changing the partition to select the correct device/partition."));
// m_btnMgr.setText(m_mainLblMessage, _t("main5", L"Welcome to WiiFlow. I have not found any plugins. Select partition to select your partition type."));
m_btnMgr.show(m_mainBtnSelPart);
m_btnMgr.show(m_mainLblMessage);
break;
}
}
@ -248,7 +248,7 @@ int CMenu::main(void)
parental_homebrew = m_cfg.getBool(HOMEBREW_DOMAIN, "parental", false);
show_homebrew = (!m_cfg.getBool(HOMEBREW_DOMAIN, "disable", false) && (parental_homebrew || !m_locked));
show_channel = !m_cfg.getBool("GENERAL", "hidechannel", false);
show_emu = !m_cfg.getBool(PLUGIN_DOMAIN, "disable", false);
show_plugin = !m_cfg.getBool(PLUGIN_DOMAIN, "disable", false);
show_gamecube = m_show_gc;
m_use_source = m_cfg.getBool("GENERAL", "use_source", true);
bool bheld = false;
@ -324,7 +324,7 @@ int CMenu::main(void)
{
if(BTN_B_HELD)
bUsed = true;
_initCF();
//_initCF();may not need this
_showMain();
}
}
@ -373,11 +373,11 @@ int CMenu::main(void)
else if(m_btnMgr.selected(m_mainBtnChannel) || m_btnMgr.selected(m_mainBtnWii) || m_btnMgr.selected(m_mainBtnGamecube) || m_btnMgr.selected(m_mainBtnHomebrew) || m_btnMgr.selected(m_mainBtnPlugin))
{
if(m_current_view == COVERFLOW_WII)
m_current_view = show_gamecube ? COVERFLOW_GAMECUBE : (show_channel ? COVERFLOW_CHANNEL : (show_emu ? COVERFLOW_PLUGIN : (show_homebrew ? COVERFLOW_HOMEBREW : COVERFLOW_WII)));
m_current_view = show_gamecube ? COVERFLOW_GAMECUBE : (show_channel ? COVERFLOW_CHANNEL : (show_plugin ? COVERFLOW_PLUGIN : (show_homebrew ? COVERFLOW_HOMEBREW : COVERFLOW_WII)));
else if(m_current_view == COVERFLOW_GAMECUBE)
m_current_view = show_channel ? COVERFLOW_CHANNEL : (show_emu ? COVERFLOW_PLUGIN : (show_homebrew ? COVERFLOW_HOMEBREW : COVERFLOW_WII));
m_current_view = show_channel ? COVERFLOW_CHANNEL : (show_plugin ? COVERFLOW_PLUGIN : (show_homebrew ? COVERFLOW_HOMEBREW : COVERFLOW_WII));
else if(m_current_view == COVERFLOW_CHANNEL)
m_current_view = show_emu ? COVERFLOW_PLUGIN : (show_homebrew ? COVERFLOW_HOMEBREW : COVERFLOW_WII);
m_current_view = show_plugin ? COVERFLOW_PLUGIN : (show_homebrew ? COVERFLOW_HOMEBREW : COVERFLOW_WII);
else if(m_current_view == COVERFLOW_PLUGIN)
m_current_view = show_homebrew ? COVERFLOW_HOMEBREW : COVERFLOW_WII;
else if(m_current_view == COVERFLOW_HOMEBREW || m_current_view == COVERFLOW_MAX)
@ -388,23 +388,18 @@ int CMenu::main(void)
m_combined_view = false;
LoadView();
}
else if(m_btnMgr.selected(m_mainBtnInit))
else if(m_btnMgr.selected(m_mainBtnInstall))
{
if(!m_locked)
{
_hideMain();
_wbfsOp(CMenu::WO_ADD_GAME);
if(prevTheme != m_cfg.getString("GENERAL", "theme"))
{
m_reload = true;
break;
}
_showMain();
if(BTN_B_HELD)
bUsed = true;
}
}
else if(m_btnMgr.selected(m_mainBtnInit2))
else if(m_btnMgr.selected(m_mainBtnSelPart))
{
_hideMain();
_config(1);
@ -428,6 +423,7 @@ int CMenu::main(void)
}
if(BTN_B_HELD)
bUsed = true;
//update show_homebrew because parental lock might have changed
show_homebrew = (!m_cfg.getBool(HOMEBREW_DOMAIN, "disable", false) && (parental_homebrew || !m_locked));
if(m_load_view)
LoadView();
@ -453,7 +449,7 @@ int CMenu::main(void)
/* Create Fake Header */
dir_discHdr hdr;
memset(&hdr, 0, sizeof(dir_discHdr));
memcpy(&hdr.id, "dvddvd", 6);//only the id is used for a disc and this is changed in _launchGame.
memcpy(&hdr.id, "dvddvd", 6);//only the id is used for a disc and dvddvd is changed in _launchGame.
/* Boot the Disc */
_launchGame(&hdr, true);
_showMain();
@ -519,7 +515,7 @@ int CMenu::main(void)
{
if(BTN_B_HELD)
bUsed = true;
_initCF();
//_initCF();may not need this one either
_showMain();
}
}
@ -592,15 +588,12 @@ int CMenu::main(void)
CoverFlow.left();
else if(BTN_1_PRESSED || BTN_2_PRESSED)
{
if (!m_btnMgr.selected(m_mainBtnQuit))
{
const char *domain = _domainFromView();
s8 direction = BTN_1_PRESSED ? 1 : -1;
int cfVersion = 1+loopNum((m_cfg.getInt(domain, "last_cf_mode", 1)-1) + direction, m_numCFVersions);
_loadCFLayout(cfVersion);
CoverFlow.applySettings();
m_cfg.setInt(domain, "last_cf_mode", cfVersion);
}
const char *domain = _domainFromView();
s8 direction = BTN_1_PRESSED ? 1 : -1;
int cfVersion = 1+loopNum((m_cfg.getInt(domain, "last_cf_mode", 1)-1) + direction, m_numCFVersions);
_loadCFLayout(cfVersion);
CoverFlow.applySettings();
m_cfg.setInt(domain, "last_cf_mode", cfVersion);
}
else if(BTN_MINUS_PRESSED)
CoverFlow.pageUp();
@ -746,7 +739,7 @@ int CMenu::main(void)
case COVERFLOW_GAMECUBE:
if(show_channel)
m_btnMgr.show(m_mainBtnChannel);
else if(show_emu)
else if(show_plugin)
m_btnMgr.show(m_mainBtnPlugin);
else if(show_homebrew)
m_btnMgr.show(m_mainBtnHomebrew);
@ -754,7 +747,7 @@ int CMenu::main(void)
m_btnMgr.show(m_mainBtnWii);
break;
case COVERFLOW_CHANNEL:
if(show_emu)
if(show_plugin)
m_btnMgr.show(m_mainBtnPlugin);
else if(show_homebrew)
m_btnMgr.show(m_mainBtnHomebrew);
@ -776,7 +769,7 @@ int CMenu::main(void)
m_btnMgr.show(m_mainBtnGamecube);
else if(show_channel)
m_btnMgr.show(m_mainBtnChannel);
else if(show_emu)
else if(show_plugin)
m_btnMgr.show(m_mainBtnPlugin);
else if(show_homebrew)
m_btnMgr.show(m_mainBtnHomebrew);
@ -919,9 +912,9 @@ void CMenu::_initMainMenu()
m_mainBtnDVD = _addPicButton("MAIN/DVD_BTN", texDVD, texDVDs, 470, 400, 48, 48);
m_mainBtnNext = _addPicButton("MAIN/NEXT_BTN", texNext, texNextS, 540, 146, 80, 80);
m_mainBtnPrev = _addPicButton("MAIN/PREV_BTN", texPrev, texPrevS, 20, 146, 80, 80);
m_mainBtnInit = _addButton("MAIN/BIG_SETTINGS_BTN", theme.titleFont, L"", 72, 180, 496, 48, theme.titleFontColor);
m_mainBtnInit2 = _addButton("MAIN/BIG_SETTINGS_BTN2", theme.titleFont, L"", 72, 290, 496, 48, theme.titleFontColor);
m_mainLblInit = _addLabel("MAIN/MESSAGE", theme.lblFont, L"", 40, 40, 560, 140, theme.lblFontColor, FTGX_JUSTIFY_LEFT | FTGX_ALIGN_MIDDLE);
m_mainBtnInstall = _addButton("MAIN/BIG_SETTINGS_BTN", theme.titleFont, L"", 72, 180, 496, 48, theme.titleFontColor);
m_mainBtnSelPart = _addButton("MAIN/BIG_SETTINGS_BTN2", theme.titleFont, L"", 72, 290, 496, 48, theme.titleFontColor);
m_mainLblMessage = _addLabel("MAIN/MESSAGE", theme.lblFont, L"", 40, 40, 560, 140, theme.lblFontColor, FTGX_JUSTIFY_LEFT | FTGX_ALIGN_MIDDLE);
m_mainBtnFavoritesOn = _addPicButton("MAIN/FAVORITES_ON", texFavOn, texFavOnS, 288, 400, 64, 64);
m_mainBtnFavoritesOff = _addPicButton("MAIN/FAVORITES_OFF", texFavOff, texFavOffS, 288, 400, 64, 64);
m_mainLblLetter = _addLabel("MAIN/LETTER", theme.titleFont, L"", 540, 40, 80, 80, theme.titleFontColor, FTGX_JUSTIFY_CENTER | FTGX_ALIGN_MIDDLE, emptyTex);
@ -975,9 +968,9 @@ void CMenu::_initMainMenu()
_setHideAnim(m_mainBtnDVD, "MAIN/DVD_BTN", 0, 40, 0.f, 0.f);
_setHideAnim(m_mainBtnFavoritesOn, "MAIN/FAVORITES_ON", 0, 40, 0.f, 0.f);
_setHideAnim(m_mainBtnFavoritesOff, "MAIN/FAVORITES_OFF", 0, 40, 0.f, 0.f);
_setHideAnim(m_mainBtnInit, "MAIN/BIG_SETTINGS_BTN", 0, 0, -2.f, 0.f);
_setHideAnim(m_mainBtnInit2, "MAIN/BIG_SETTINGS_BTN2", 0, 0, -2.f, 0.f);
_setHideAnim(m_mainLblInit, "MAIN/MESSAGE", 0, 0, 0.f, 0.f);
_setHideAnim(m_mainBtnInstall, "MAIN/BIG_SETTINGS_BTN", 0, 0, -2.f, 0.f);
_setHideAnim(m_mainBtnSelPart, "MAIN/BIG_SETTINGS_BTN2", 0, 0, -2.f, 0.f);
_setHideAnim(m_mainLblMessage, "MAIN/MESSAGE", 0, 0, 0.f, 0.f);
_setHideAnim(m_mainLblLetter, "MAIN/LETTER", 0, 0, 0.f, 0.f);
_setHideAnim(m_mainLblNotice, "MAIN/NOTICE", 0, 0, 0.f, 0.f);
_setHideAnim(m_mainLblCurMusic, "MAIN/MUSIC", 0, -100, 0.f, 0.f);
@ -991,8 +984,8 @@ void CMenu::_initMainMenu()
void CMenu::_textMain(void)
{
m_btnMgr.setText(m_mainBtnInit, _t("main1", L"Install Game"));
m_btnMgr.setText(m_mainBtnInit2, _t("main3", L"Select Partition"));
m_btnMgr.setText(m_mainBtnInstall, _t("main1", L"Install Game"));
m_btnMgr.setText(m_mainBtnSelPart, _t("main3", L"Select Partition"));
}
wstringEx CMenu::_getNoticeTranslation(int sorting, wstringEx curLetter)
@ -1137,10 +1130,10 @@ void CMenu::_setPartition(s8 direction)
if(plugin_list[i] == true)
break;
}
char PluginMagicWord[9];
memset(PluginMagicWord, 0, sizeof(PluginMagicWord));
strncpy(PluginMagicWord, fmt("%08x", m_plugin.getPluginMagic(i)), 8);
m_cfg.setInt("PLUGINS_PARTITION", PluginMagicWord, currentPartition);
//char PluginMagicWord[9];
//memset(PluginMagicWord, 0, sizeof(PluginMagicWord));
strncpy(m_plugin.PluginMagicWord, fmt("%08x", m_plugin.getPluginMagic(i)), 8);
m_cfg.setInt("PLUGINS_PARTITION", m_plugin.PluginMagicWord, currentPartition);
}
}
}

View File

@ -54,7 +54,7 @@ bool m_saveall;
static inline int loopNum(int i, int s)
{
return i < 0 ? (s - (-i % s)) % s : i % s;
return (i + s) % s;
}
static bool _saveExists(const char *path)

View File

@ -220,8 +220,9 @@ void CMenu::_createSFList()
void CMenu::_sourceFlow()
{
u8 numPlugins = 0, k;
if(!m_cfg.getBool(PLUGIN_DOMAIN, "disable", false))
//u8 numPlugins = 0, k;
u8 k;
/*if(!m_cfg.getBool(PLUGIN_DOMAIN, "disable", false))
{
Config m_plugin_cfg;
DIR *pdir;
@ -244,7 +245,7 @@ void CMenu::_sourceFlow()
}
closedir(pdir);
m_plugin.EndAdd();
}
}*/
const dir_discHdr *hdr = CoverFlow.getHdr();
if(m_cfg.getBool("SOURCEFLOW", "remember_last_item", true))
m_cfg.setString("SOURCEFLOW", "current_item", strrchr(hdr->path, '/') + 1);
@ -301,7 +302,7 @@ void CMenu::_sourceFlow()
m_current_view = COVERFLOW_PLUGIN;
m_cfg.setBool(PLUGIN_DOMAIN, "source", true);
m_catStartPage = m_source.getInt(btn_selected, "cat_page", 1);
for(k = 0; k < numPlugins; ++k)
for(k = 0; k < m_numPlugins; ++k)
m_plugin.SetEnablePlugin(m_cfg, k, 2); /* force enable */
}
else if(source == "plugin")
@ -313,7 +314,7 @@ void CMenu::_sourceFlow()
{
m_current_view = COVERFLOW_PLUGIN;
m_cfg.setBool(PLUGIN_DOMAIN, "source", true);
for(k = 0; k < numPlugins; ++k)
for(k = 0; k < m_numPlugins; ++k)
m_plugin.SetEnablePlugin(m_cfg, k, 1); /* force disable */
for(vector<string>::iterator itr = magicNums.begin(); itr != magicNums.end(); itr++)
{
@ -391,7 +392,7 @@ bool CMenu::_Source()
bool noChanges = true;
bool updateSource = false;
exitSource = false;
u8 numPlugins = 0;
//u8 numPlugins = 0;
m_showtimer = 0;
source_curPage = 1;
source_Pages = 1;
@ -419,7 +420,7 @@ bool CMenu::_Source()
break;
}
}
if(show_emu)
/*if(show_emu)
{
Config m_plugin_cfg;
DIR *pdir;
@ -442,7 +443,7 @@ bool CMenu::_Source()
}
closedir(pdir);
m_plugin.EndAdd();
}
}*/
_updateSourceBtns();
}
@ -484,10 +485,10 @@ bool CMenu::_Source()
if(plugin_list[i] == true)
break;
}
char PluginMagicWord[9];
memset(PluginMagicWord, 0, sizeof(PluginMagicWord));
strncpy(PluginMagicWord, fmt("%08x", m_plugin.getPluginMagic(i)), 8);
currentPartition = m_cfg.getInt("PLUGINS_PARTITION", PluginMagicWord, 1);
//char PluginMagicWord[9];
//memset(PluginMagicWord, 0, sizeof(PluginMagicWord));
strncpy(m_plugin.PluginMagicWord, fmt("%08x", m_plugin.getPluginMagic(i)), 8);
currentPartition = m_cfg.getInt("PLUGINS_PARTITION", m_plugin.PluginMagicWord, 1);
m_cfg.setInt(PLUGIN_DOMAIN, "partition", currentPartition);
}
u8 sourceCount = 0;
@ -654,7 +655,7 @@ bool CMenu::_Source()
{
m_cfg.setBool(PLUGIN_DOMAIN, "source", true);
m_catStartPage = m_source.getInt(btn_selected, "cat_page", 1);
for(k = 0; k < numPlugins; ++k)
for(k = 0; k < m_numPlugins; ++k)
m_plugin.SetEnablePlugin(m_cfg, k, 2); /* force enable */
}
}
@ -670,7 +671,7 @@ bool CMenu::_Source()
if(plugin_magic_nums != 0)
{
m_cfg.setBool(PLUGIN_DOMAIN, "source", true);
for(k = 0; k < numPlugins; ++k)
for(k = 0; k < m_numPlugins; ++k)
m_plugin.SetEnablePlugin(m_cfg, k, 1); /* force disable */
for(vector<string>::iterator itr = magicNums.begin(); itr != magicNums.end(); itr++)
{

View File

@ -63,21 +63,23 @@ bool Plugin::AddPlugin(Config &plugin)
return false;
PluginOptions NewPlugin;
NewPlugin.DolName = plugin.getString(PLUGIN_INI_DEF, "dolFile");
NewPlugin.coverFolder = plugin.getString(PLUGIN_INI_DEF, "coverFolder");
NewPlugin.magicWord = strtoul(plugin.getString(PLUGIN_INI_DEF, "magic").c_str(), NULL, 16);
NewPlugin.caseColor = strtoul(plugin.getString(PLUGIN_INI_DEF, "coverColor").c_str(), NULL, 16);
NewPlugin.Args = plugin.getStrings(PLUGIN_INI_DEF, "arguments", '|');
string PluginName = plugin.getString(PLUGIN_INI_DEF, "displayname");
NewPlugin.DolName = plugin.getString(PLUGIN, "dolFile");
NewPlugin.coverFolder = plugin.getString(PLUGIN, "coverFolder");
NewPlugin.magic = strtoul(plugin.getString(PLUGIN, "magic").c_str(), NULL, 16);
NewPlugin.caseColor = strtoul(plugin.getString(PLUGIN, "coverColor").c_str(), NULL, 16);
NewPlugin.romDir = plugin.getString(PLUGIN, "romDir");
NewPlugin.fileTypes = plugin.getString(PLUGIN, "fileTypes");
NewPlugin.Args = plugin.getStrings(PLUGIN, "arguments", '|');
string PluginName = plugin.getString(PLUGIN, "displayname");
if(PluginName.size() < 2)
{
PluginName = NewPlugin.DolName;
PluginName.erase(PluginName.end() - 4, PluginName.end());
}
NewPlugin.DisplayName.fromUTF8(PluginName.c_str());
NewPlugin.consoleCoverID = plugin.getString(PLUGIN_INI_DEF,"consoleCoverID");
NewPlugin.consoleCoverID = plugin.getString(PLUGIN,"consoleCoverID");
const string &bannerfilepath = sfmt("%s/%s", pluginsDir.c_str(), plugin.getString(PLUGIN_INI_DEF,"bannerSound").c_str());
const string &bannerfilepath = sfmt("%s/%s", pluginsDir.c_str(), plugin.getString(PLUGIN,"bannerSound").c_str());
fsop_GetFileSizeBytes(bannerfilepath.c_str(), &NewPlugin.BannerSoundSize);
if(NewPlugin.BannerSoundSize > 0)
NewPlugin.BannerSound = bannerfilepath;
@ -89,12 +91,17 @@ s8 Plugin::GetPluginPosition(u32 magic)
{
for(u8 pos = 0; pos < Plugins.size(); pos++)
{
if(magic == Plugins[pos].magicWord)
if(magic == Plugins[pos].magic)
return pos;
}
return -1;
}
u32 Plugin::getPluginMagic(u8 pos)
{
return Plugins[pos].magic;
}
u8* Plugin::GetBannerSound(u32 magic)
{
if((Plugin_Pos = GetPluginPosition(magic)) >= 0)
@ -127,11 +134,19 @@ const char *Plugin::GetCoverFolderName(u32 magic)
return NULL;
}
bool Plugin::PluginExist(u8 pos)
const char *Plugin::GetRomDir(u8 pos)
{
if(pos < Plugins.size())
return true;
return false;
return Plugins[pos].romDir.c_str();
}
const string& Plugin::GetFileTypes(u8 pos)
{
return Plugins[pos].fileTypes;
}
u32 Plugin::GetCaseColor(u8 pos)
{
return Plugins[pos].caseColor;
}
wstringEx Plugin::GetPluginName(u8 pos)
@ -139,11 +154,18 @@ wstringEx Plugin::GetPluginName(u8 pos)
return Plugins[pos].DisplayName;
}
bool Plugin::PluginExist(u8 pos)
{
if(pos < Plugins.size())
return true;
return false;
}
void Plugin::SetEnablePlugin(Config &cfg, u8 pos, u8 ForceMode)
{
if(pos < Plugins.size())
{
strncpy(PluginMagicWord, fmt("%08x", Plugins[pos].magicWord), 8);
strncpy(PluginMagicWord, fmt("%08x", Plugins[pos].magic), 8);
if(ForceMode == 1)
cfg.setBool(PLUGIN_ENABLED, PluginMagicWord, false);
else if(ForceMode == 2)
@ -169,7 +191,7 @@ const vector<bool> &Plugin::GetEnabledPlugins(Config &cfg, u8 *num)
u8 enabledPluginsNumber = 0;
for(u8 i = 0; i < Plugins.size(); i++)
{
strncpy(PluginMagicWord, fmt("%08x", Plugins[i].magicWord), 8);
strncpy(PluginMagicWord, fmt("%08x", Plugins[i].magic), 8);
if(cfg.getBool(PLUGIN_ENABLED, PluginMagicWord, true))
{
enabledPluginsNumber++;
@ -185,12 +207,7 @@ const vector<bool> &Plugin::GetEnabledPlugins(Config &cfg, u8 *num)
return enabledPlugins;
}
u32 Plugin::getPluginMagic(u8 pos)
{
return Plugins[pos].magicWord;
}
vector<dir_discHdr> Plugin::ParseScummvmINI(Config &ini, const char *Device, u32 MagicWord)
vector<dir_discHdr> Plugin::ParseScummvmINI(Config &ini, const char *Device, u32 Magic)
{
gprintf("Parsing scummvm.ini\n");
vector<dir_discHdr> gameHeader;
@ -210,12 +227,12 @@ vector<dir_discHdr> Plugin::ParseScummvmINI(Config &ini, const char *Device, u32
continue;
}
memset((void*)&ListElement, 0, sizeof(dir_discHdr));
strncpy(ListElement.id, PLUGIN_INI_DEF, 6);
strncpy(ListElement.id, PLUGIN, 6);
ListElement.casecolor = Plugins.back().caseColor;
mbstowcs(ListElement.title, GameName, 63);
strncpy(ListElement.path, GameDomain, sizeof(ListElement.path));
gprintf("Found: %s\n", GameDomain);
ListElement.settings[0] = MagicWord;
ListElement.settings[0] = Magic;
ListElement.type = TYPE_PLUGIN;
gameHeader.push_back(ListElement);
GameDomain = ini.nextDomain().c_str();

View File

@ -31,7 +31,7 @@ using namespace std;
#define TAG_LOC "{loc}"
#define TAG_CONSOLE "{console}"
#define PLUGIN_INI_DEF "PLUGIN"
#define PLUGIN "PLUGIN"
#define PLUGIN_ENABLED "PLUGINS_ENABLED"
#define PLUGIN_DEV "{device}"
#define PLUGIN_PATH "{path}"
@ -41,8 +41,10 @@ using namespace std;
struct PluginOptions
{
u32 magicWord;
u32 magic;
u32 caseColor;
string romDir;
string fileTypes;
string DolName;
string coverFolder;
string consoleCoverID;
@ -55,29 +57,35 @@ struct PluginOptions
class Plugin
{
public:
bool AddPlugin(Config &plugin);
u8 *GetBannerSound(u32 magic);
u32 GetBannerSoundSize();
u32 GetCaseColor(u8 pos);
const char *GetDolName(u32 magic);
const char *GetCoverFolderName(u32 magic);
bool GetEnableStatus(Config &cfg, u32 magic);
string GenerateCoverLink(dir_discHdr gameHeader, const string& constURL, Config &Checksums);
const char *GetRomDir(u8 pos);
const string& GetFileTypes(u8 pos);
wstringEx GetPluginName(u8 pos);
u32 getPluginMagic(u8 pos);
bool PluginExist(u8 pos);
void SetEnablePlugin(Config &cfg, u8 pos, u8 ForceMode = 0);
const vector<bool> &GetEnabledPlugins(Config &cfg, u8 *num);
vector<string> CreateArgs(const char *device, const char *path,
const char *title, const char *loader, u32 title_len_no_ext, u32 magic);
s8 GetPluginPosition(u32 magic);
void init(const string& m_pluginsDir);
bool AddPlugin(Config &plugin);
void Cleanup();
void EndAdd();
vector<dir_discHdr> ParseScummvmINI(Config &ini, const char *Device, u32 MagicWord);
s8 GetPluginPosition(u32 magic);
bool GetEnableStatus(Config &cfg, u32 magic);
void SetEnablePlugin(Config &cfg, u8 pos, u8 ForceMode = 0);
const vector<bool> &GetEnabledPlugins(Config &cfg, u8 *num);
bool PluginExist(u8 pos);
vector<string> CreateArgs(const char *device, const char *path,
const char *title, const char *loader, u32 title_len_no_ext, u32 magic);
vector<dir_discHdr> ParseScummvmINI(Config &ini, const char *Device, u32 Magic);
string GenerateCoverLink(dir_discHdr gameHeader, const string& constURL, Config &Checksums);
char PluginMagicWord[9];
private:
vector<PluginOptions> Plugins;
vector<bool> enabledPlugins;
char PluginMagicWord[9];
s8 Plugin_Pos;
string pluginsDir;
bool adding;