diff --git a/source/list/cachedlist.cpp b/source/list/cachedlist.cpp index da54fdeb..8cd64c4c 100644 --- a/source/list/cachedlist.cpp +++ b/source/list/cachedlist.cpp @@ -13,7 +13,7 @@ void CachedList::Load(string path, string containing, string m_lastLanguage) bool update_games = false; bool update_homebrew = false; bool update_dml = false; - bool update_emu = strcasestr(containing.c_str(), ".zip") != NULL; + bool update_emu = strcasestr(path.c_str(), m_plugin.getString("PLUGIN","romDir","").c_str()) != NULL; bool ditimes = false; bool music = typeid(T) == typeid(std::string); if(music) @@ -80,7 +80,7 @@ void CachedList::Load(string path, string containing, string m_lastLanguage) safe_vector pathlist; list.GetPaths(pathlist, containing, path, m_wbfsFS); - list.GetHeaders(pathlist, *this, m_settingsDir, m_curLanguage, m_DMLgameDir); + list.GetHeaders(pathlist, *this, m_settingsDir, m_curLanguage, m_DMLgameDir, m_plugin); path.append("/touch.db"); FILE *file = fopen(path.c_str(), "wb"); diff --git a/source/list/cachedlist.hpp b/source/list/cachedlist.hpp index 35a78eca..6b0a1f30 100644 --- a/source/list/cachedlist.hpp +++ b/source/list/cachedlist.hpp @@ -5,6 +5,7 @@ #include "cache.hpp" #include "safe_vector.hpp" #include "gecko.h" +#include "config/config.hpp" using namespace std; @@ -79,6 +80,8 @@ class CachedList : public safe_vector string m_lastLanguage; string m_discinf; string m_DMLgameDir; +public: + Config m_plugin; }; #endif diff --git a/source/list/list.cpp b/source/list/list.cpp index 387f2c82..2534d8bd 100644 --- a/source/list/list.cpp +++ b/source/list/list.cpp @@ -83,7 +83,7 @@ void CList::GetPaths(safe_vector &pathlist, string containing, string } template <> -void CList::GetHeaders(safe_vector pathlist, safe_vector &headerlist, string, string, string) +void CList::GetHeaders(safe_vector pathlist, safe_vector &headerlist, string, string, string, Config&) { //gprintf("Getting headers for CList\n"); @@ -95,7 +95,7 @@ void CList::GetHeaders(safe_vector pathlist, safe_vector } template <> -void CList::GetHeaders(safe_vector pathlist, safe_vector &headerlist, string settingsDir, string curLanguage, string DMLgameUSBDir) +void CList::GetHeaders(safe_vector pathlist, safe_vector &headerlist, string settingsDir, string curLanguage, string DMLgameUSBDir, Config &plugin) { if(pathlist.size() < 1) return; headerlist.reserve(pathlist.size() + headerlist.size()); @@ -370,106 +370,37 @@ void CList::GetHeaders(safe_vector pathlist, safe_vector types = plugin.getStrings("PLUGIN","fileTypes",'|'); + if (types.size() > 0) { - int ccolor = custom_titles.getColor("COVERS", (const char *) tmp.hdr.id, 0xff0000).intVal(); - tmp.hdr.casecolor = ccolor != 0xff0000 ? ccolor : 0xff0000; - tmp.hdr.magic = 0x46434555 ; //FCEU - } - else if(lowerCase(tmp.path).rfind("snes9xgx") != string::npos) - { - int ccolor = custom_titles.getColor("COVERS", (const char *) tmp.hdr.id, 0x01A300).intVal(); - tmp.hdr.casecolor = ccolor != 0x01A300 ? ccolor : 0x01A300; - tmp.hdr.magic = 0x534e4553; //SNES - } - else if(lowerCase(tmp.path).rfind("vbagx") != string::npos) - { - int ccolor = custom_titles.getColor("COVERS", (const char *) tmp.hdr.id, 0xfcff00).intVal(); - tmp.hdr.casecolor = ccolor != 0xfcff00 ? ccolor : 0xfcff00; - tmp.hdr.magic = 0x56424158; //VBAX - } - mbstowcs(tmp.title, filename, sizeof(tmp.title)); - Asciify(tmp.title); - gprintf("Found: %s\n", tmp.path); + for(safe_vector::iterator type_itr = types.begin(); type_itr != types.end(); type_itr++) + { + if(lowerCase(*itr).rfind((*type_itr).c_str()) != string::npos) + { + strncpy(tmp.path, (*itr).c_str(), sizeof(tmp.path)); - tmp.hdr.gc_magic = 0x4c4f4c4f; //Abusing gc_magic for general emu detection ;) - headerlist.push_back(tmp); + (*itr).assign(&(*itr)[(*itr).find_last_of('/') + 1]); + + char filename[64]; + strncpy(filename, (*itr).c_str(), sizeof(filename)); + + int plugin_ccolor; + sscanf(plugin.getString("PLUGIN","coverColor","").c_str(), "%08x", &plugin_ccolor); + int ccolor = custom_titles.getColor("COVERS", (const char *) tmp.hdr.id, plugin_ccolor).intVal(); + tmp.hdr.casecolor = ccolor != plugin_ccolor ? ccolor : plugin_ccolor; + + mbstowcs(tmp.title, filename, sizeof(tmp.title)); + Asciify(tmp.title); + gprintf("Found: %s\n", tmp.path); + sscanf(plugin.getString("PLUGIN","magic","").c_str(), "%08x", &tmp.hdr.magic); //Plugin magic + tmp.hdr.gc_magic = 0x4c4f4c4f; //Abusing gc_magic for general emu detection ;) + headerlist.push_back(tmp); + break; + } + } + } continue; } } diff --git a/source/list/list.hpp b/source/list/list.hpp index d2ef02b8..24681978 100644 --- a/source/list/list.hpp +++ b/source/list/list.hpp @@ -15,6 +15,7 @@ #include "disc.h" #include "text.hpp" #include "cache.hpp" +#include "config/config.hpp" using namespace std; template @@ -24,7 +25,7 @@ class CList CList(){}; ~CList(){}; void GetPaths(safe_vector &pathlist, string containing, string directory, bool wbfs_fs = false); - void GetHeaders(safe_vector pathlist, safe_vector &headerlist, string, string, string); + void GetHeaders(safe_vector pathlist, safe_vector &headerlist, string, string, string, Config &plugin); void GetChannels(safe_vector &headerlist, string, u32, string); private: void Check_For_ID(u8 *id, string path, string one, string two); diff --git a/source/menu/menu.cpp b/source/menu/menu.cpp index f74aacb3..3d9351fa 100644 --- a/source/menu/menu.cpp +++ b/source/menu/menu.cpp @@ -1950,12 +1950,31 @@ bool CMenu::_loadEmuList() gprintf("%s\n", DeviceName[currentPartition]); DeviceHandler::Instance()->Open_WBFS(currentPartition); - if(fsop_FileExist(fmt("%s/fceugx.dol", m_pluginsDir.c_str()))) - m_gameList.Load(sfmt("%s:/fceugx/roms", DeviceName[currentPartition]), ".nes|.fds|.nsf|.unf|.nez|.unif|.zip|.7z", "EN"); - if(fsop_FileExist(fmt("%s/snes9x-gx.dol", m_pluginsDir.c_str()))) - m_gameList.Load(sfmt("%s:/snes9xgx/roms", DeviceName[currentPartition]), ".smc|.fig|.sfc|.swc|.zip|.7z", "EN"); - if(fsop_FileExist(fmt("%s/vbagx.dol", m_pluginsDir.c_str()))) - m_gameList.Load(sfmt("%s:/vbagx/roms", DeviceName[currentPartition]), ".agb|.gba|.bin|.elf|.mb|.dmg||.gb|.gbc|.cgb|.sgb|.zip|.7z", "EN"); + + DIR *pdir; + struct dirent *pent; + + m_plugin.load(fmt("%s/plugins.ini", m_pluginsDir.c_str())); + pdir = opendir(m_pluginsDir.c_str()); + + while ((pent = readdir(pdir)) != NULL) + { + // Skip it + if (strcmp (pent->d_name, ".") == 0 || strcmp (pent->d_name, "..") == 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.Load(sfmt("%s:/%s", DeviceName[currentPartition], m_gameList.m_plugin.getString("PLUGIN","romDir","").c_str()), m_gameList.m_plugin.getString("PLUGIN","fileTypes","").c_str(), "EN"); + m_plugin.setString("GENERAL",m_gameList.m_plugin.getString("PLUGIN","magic","").c_str(),m_gameList.m_plugin.getString("PLUGIN","dolFile","").c_str()); + } + m_gameList.m_plugin.unload(); + } + } + closedir(pdir); + m_plugin.save(true); m_cfg.setString("EMULATOR", "lastlanguage", m_loc.getString(m_curLanguage, "gametdb_code", "EN")); m_cfg.save(); diff --git a/source/menu/menu.hpp b/source/menu/menu.hpp index b98c7d3c..02b35b20 100644 --- a/source/menu/menu.hpp +++ b/source/menu/menu.hpp @@ -66,6 +66,7 @@ private: Config m_theme; Config m_titles; Config m_version; + Config m_plugin; Channels m_channels; safe_vector m_homebrewArgs; SmartBuf m_base_font; diff --git a/source/menu/menu_game.cpp b/source/menu/menu_game.cpp index 23b06c64..0d89061c 100644 --- a/source/menu/menu_game.cpp +++ b/source/menu/menu_game.cpp @@ -623,7 +623,7 @@ void CMenu::_directlaunch(const string &id) strncasecmp(DeviceHandler::Instance()->PathToFSName(path.c_str()), "WBFS", 4) == 0); m_gameList.clear(); - list.GetHeaders(pathlist, m_gameList, m_settingsDir, m_curLanguage, m_DMLgameDir); + list.GetHeaders(pathlist, m_gameList, m_settingsDir, m_curLanguage, m_DMLgameDir, m_plugin); if(m_gameList.size() > 0) { gprintf("Game found on partition #%i\n", i); @@ -651,12 +651,11 @@ void CMenu::_launch(dir_discHdr *hdr) arguments.push_back(path); arguments.push_back(title); arguments.push_back(wiiflow_dol); - if(hdr->hdr.magic == 0x534e4553) - _launchHomebrew(fmt("%s/snes9x-gx.dol", m_pluginsDir.c_str()), arguments); - else if(hdr->hdr.magic == 0x46434555) - _launchHomebrew(fmt("%s/fceugx.dol", m_pluginsDir.c_str()), arguments); - else if(hdr->hdr.magic == 0x56424158) - _launchHomebrew(fmt("%s/vbagx.dol", m_pluginsDir.c_str()), arguments); + char magic[10]; + snprintf(magic,sizeof(magic),"%08x",hdr->hdr.magic); + m_plugin.load(fmt("%s/plugins.ini", m_pluginsDir.c_str())); + _launchHomebrew(fmt("%s/%s", m_pluginsDir.c_str(), m_plugin.getString("GENERAL",magic,"").c_str()), arguments); + m_plugin.save(true); return; } else if(hdr->hdr.gc_magic == 0xc2339f3d) @@ -763,6 +762,7 @@ void CMenu::_launchGC(dir_discHdr *hdr, bool DML) void CMenu::_launchHomebrew(const char *filepath, safe_vector arguments) { + gprintf("Filepath of homebrew: %s\n",filepath); if(LoadHomebrew(filepath)) { m_gcfg1.save(true);