diff --git a/source/menu/menu.cpp b/source/menu/menu.cpp index 33a9eb25..90d6cbc0 100644 --- a/source/menu/menu.cpp +++ b/source/menu/menu.cpp @@ -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::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::iterator tmp_itr = m_gameList.begin(); tmp_itr != m_gameList.end(); tmp_itr++) + emuList.push_back(*tmp_itr); + } + else + { + Config scummvm; + safe_vector scummvmList; + scummvm.load(fmt("%s/%s", m_pluginsDir.c_str(), "scummvm.ini")); + scummvmList = m_plugin.ParseScummvmINI(scummvm, DeviceName[currentPartition]); + for(safe_vector::iterator tmp_itr = scummvmList.begin(); tmp_itr != scummvmList.end(); tmp_itr++) + emuList.push_back(*tmp_itr); + } } m_gameList.m_plugin.unload(); } diff --git a/source/menu/menu_game.cpp b/source/menu/menu_game.cpp index d0118fdc..ed03f5ff 100644 --- a/source/menu/menu_game.cpp +++ b/source/menu/menu_game.cpp @@ -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 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; } diff --git a/source/plugin/plugin.cpp b/source/plugin/plugin.cpp index 89d1aca4..84af2fc1 100644 --- a/source/plugin/plugin.cpp +++ b/source/plugin/plugin.cpp @@ -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 Plugin::ParseScummvmINI(Config &ini, const char* Device) +{ + gprintf("Parsing scummvm.ini\n"); + safe_vector 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; +} diff --git a/source/plugin/plugin.hpp b/source/plugin/plugin.hpp index aa6ebfaf..4d4f1b21 100644 --- a/source/plugin/plugin.hpp +++ b/source/plugin/plugin.hpp @@ -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 ParseScummvmINI(Config &ini, const char* Device); private: safe_vector BannerSound; safe_vector BannerSoundSize; safe_vector magicWords; safe_vector DolName; + safe_vector caseColors; u8 banner_pos; string pluginsDir; bool adding;