-added scummvm ini parser, that means if scummvm plugin

detected, wiiflow will scan the scummvm.ini for games
This commit is contained in:
fix94.1 2012-04-11 22:01:41 +00:00
parent fc1c81d601
commit b2cef2a34e
4 changed files with 73 additions and 13 deletions

View File

@ -1965,18 +1965,31 @@ bool CMenu::_loadEmuList()
while ((pent = readdir(pdir)) != NULL)
{
// Skip it
if (strcmp(pent->d_name, ".") == 0 || strcmp(pent->d_name, "..") == 0 || strcasecmp(pent->d_name, "plugins.ini") == 0)
if (strcmp(pent->d_name, ".") == 0 || strcmp(pent->d_name, "..") == 0
|| strcasecmp(pent->d_name, "plugins.ini") == 0 || strcasecmp(pent->d_name, "scummvm.ini") == 0)
continue;
if(strcasestr(pent->d_name, ".ini") != NULL)
{
m_gameList.m_plugin.load(fmt("%s/%s", m_pluginsDir.c_str(), pent->d_name));
if(m_gameList.m_plugin.loaded())
{
m_gameList.clear();
m_gameList.Load(sfmt("%s:/%s", DeviceName[currentPartition], m_gameList.m_plugin.getString("PLUGIN","romDir","").c_str()), m_gameList.m_plugin.getString("PLUGIN","fileTypes","").c_str(), m_cfg.getString("EMULATOR", "lastlanguage", "EN").c_str());
for(safe_vector<dir_discHdr>::iterator tmp_itr = m_gameList.begin(); tmp_itr != m_gameList.end(); tmp_itr++)
emuList.push_back(*tmp_itr);
m_plugin.AddPlugin(m_gameList.m_plugin);
m_gameList.clear();
if(strcasestr(m_gameList.m_plugin.getString("PLUGIN","romDir","").c_str(), "scummvm.ini") == NULL)
{
m_gameList.Load(sfmt("%s:/%s", DeviceName[currentPartition], m_gameList.m_plugin.getString("PLUGIN","romDir","").c_str()), m_gameList.m_plugin.getString("PLUGIN","fileTypes","").c_str(), m_cfg.getString("EMULATOR", "lastlanguage", "EN").c_str());
for(safe_vector<dir_discHdr>::iterator tmp_itr = m_gameList.begin(); tmp_itr != m_gameList.end(); tmp_itr++)
emuList.push_back(*tmp_itr);
}
else
{
Config scummvm;
safe_vector<dir_discHdr> scummvmList;
scummvm.load(fmt("%s/%s", m_pluginsDir.c_str(), "scummvm.ini"));
scummvmList = m_plugin.ParseScummvmINI(scummvm, DeviceName[currentPartition]);
for(safe_vector<dir_discHdr>::iterator tmp_itr = scummvmList.begin(); tmp_itr != scummvmList.end(); tmp_itr++)
emuList.push_back(*tmp_itr);
}
}
m_gameList.m_plugin.unload();
}

View File

@ -630,19 +630,28 @@ void CMenu::_launch(dir_discHdr *hdr)
m_gcfg2.load(sfmt("%s/gameconfig2.ini", m_settingsDir.c_str()).c_str());
if(hdr->hdr.gc_magic == 0x4c4f4c4f)
{
m_cfg.setString("EMULATOR", "current_item", &hdr->path[std::string(hdr->path).find_last_of("/")]);
string title(&hdr->path[std::string(hdr->path).find_last_of("/")+1]);
string wiiflow_dol(m_dol);
if(strstr(wiiflow_dol.c_str(), "sd:/") == NULL)
wiiflow_dol.erase(3,1);
string path((char*)hdr->path, size_t(strlen((char*)hdr->path) - title.size()));
safe_vector<std::string> arguments;
if(strstr(path.c_str(), "sd:/") == NULL)
path.erase(3,1);
gprintf("Game title: %s\n", title.c_str());
arguments.push_back(path);
arguments.push_back(title);
arguments.push_back(wiiflow_dol);
if(strstr(path.c_str(), "sd:/") == NULL && strstr(path.c_str(), ":/") != NULL)
{
path.erase(3,1);
arguments.push_back(path);
arguments.push_back(title);
arguments.push_back(wiiflow_dol);
m_cfg.setString("EMULATOR", "current_item", &hdr->path[std::string(hdr->path).find_last_of("/")]);
}
else
{
arguments.push_back(title);
char gametitle[64];
wcstombs(gametitle, hdr->title, sizeof(gametitle));
m_cfg.setString("EMULATOR", "current_item", gametitle);
}
_launchHomebrew(fmt("%s/%s", m_pluginsDir.c_str(), m_plugin.GetDolName(hdr->hdr.magic)), arguments);
return;
}

View File

@ -11,6 +11,9 @@
#include "plugin.hpp"
#include "memory/mem2.hpp"
#include "gui/text.hpp"
#include "gecko/gecko.h"
static const std::string emptyString;
void Plugin::init(string m_pluginsDir)
{
@ -40,10 +43,13 @@ bool Plugin::AddPlugin(Config &plugin)
{
if(!adding)
return false;
u32 magic;
DolName.push_back(plugin.getString("PLUGIN","dolFile",""));
u32 magic, caseColor;
sscanf(plugin.getString("PLUGIN","magic","").c_str(), "%08x", &magic);
magicWords.push_back(magic);
DolName.push_back(plugin.getString("PLUGIN","dolFile",""));
sscanf(plugin.getString("PLUGIN","coverColor","").c_str(), "%08x", &caseColor);
caseColors.push_back(caseColor);
string bannerfilepath = sfmt("%s/%s", pluginsDir.c_str(), plugin.getString("PLUGIN","bannerSound","").c_str());
ifstream infile;
@ -95,3 +101,32 @@ char* Plugin::GetDolName(u32 magic)
return (char*)DolName[banner_pos].c_str();
return null;
}
safe_vector<dir_discHdr> Plugin::ParseScummvmINI(Config &ini, const char* Device)
{
gprintf("Parsing scummvm.ini\n");
safe_vector<dir_discHdr> gameHeader;
string game = ini.firstDomain().c_str();
dir_discHdr tmp;
while(1)
{
if(game != emptyString && (lowerCase(game).rfind("scummvm") != string::npos
|| lowerCase(ini.getString(game, "path")).rfind(Device) == string::npos))
{
game = ini.nextDomain();
continue;
}
if(game == emptyString)
break;
memset(&tmp, 0, sizeof(dir_discHdr));
tmp.hdr.casecolor = caseColors.back();
mbstowcs(tmp.title, ini.getString(game,"description").c_str(), sizeof(tmp.title));
strncpy(tmp.path, game.c_str(), sizeof(tmp.path));
gprintf("Found: %s\n", ini.getString(game,"description").c_str());
tmp.hdr.magic = magicWords.back();
tmp.hdr.gc_magic = 0x4c4f4c4f;
gameHeader.push_back(tmp);
game = ini.nextDomain();
}
return gameHeader;
}

View File

@ -13,6 +13,7 @@
#include "config/config.hpp"
#include "safe_vector.hpp"
#include "loader/disc.h"
using namespace std;
@ -26,11 +27,13 @@ public:
void init(string);
void Cleanup();
void EndAdd();
safe_vector<dir_discHdr> ParseScummvmINI(Config &ini, const char* Device);
private:
safe_vector<u8*> BannerSound;
safe_vector<u32> BannerSoundSize;
safe_vector<u32> magicWords;
safe_vector<string> DolName;
safe_vector<u32> caseColors;
u8 banner_pos;
string pluginsDir;
bool adding;