mirror of
https://github.com/Fledge68/WiiFlow_Lite.git
synced 2024-11-01 00:55:06 +01:00
-added dynamic emulator plugin support, wiiflow will now read the emulator
dol name, rom path and everything else needed from a ini in the wiiflow/plugins folder, see http://www.mediafire.com/?kj6dalp2ly3y35j for the currently 4 emulator mod inis.
This commit is contained in:
parent
f937fb5092
commit
72a7106fad
@ -13,7 +13,7 @@ void CachedList<T>::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<T>::Load(string path, string containing, string m_lastLanguage)
|
||||
|
||||
safe_vector<string> 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");
|
||||
|
@ -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<T>
|
||||
string m_lastLanguage;
|
||||
string m_discinf;
|
||||
string m_DMLgameDir;
|
||||
public:
|
||||
Config m_plugin;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -83,7 +83,7 @@ void CList<T>::GetPaths(safe_vector<string> &pathlist, string containing, string
|
||||
}
|
||||
|
||||
template <>
|
||||
void CList<string>::GetHeaders(safe_vector<string> pathlist, safe_vector<string> &headerlist, string, string, string)
|
||||
void CList<string>::GetHeaders(safe_vector<string> pathlist, safe_vector<string> &headerlist, string, string, string, Config&)
|
||||
{
|
||||
//gprintf("Getting headers for CList<string>\n");
|
||||
|
||||
@ -95,7 +95,7 @@ void CList<string>::GetHeaders(safe_vector<string> pathlist, safe_vector<string>
|
||||
}
|
||||
|
||||
template <>
|
||||
void CList<dir_discHdr>::GetHeaders(safe_vector<string> pathlist, safe_vector<dir_discHdr> &headerlist, string settingsDir, string curLanguage, string DMLgameUSBDir)
|
||||
void CList<dir_discHdr>::GetHeaders(safe_vector<string> pathlist, safe_vector<dir_discHdr> &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<dir_discHdr>::GetHeaders(safe_vector<string> pathlist, safe_vector<di
|
||||
}
|
||||
continue;
|
||||
}
|
||||
else if(lowerCase(*itr).rfind(".nes") != string::npos || lowerCase(*itr).rfind(".fds") != string::npos
|
||||
|| lowerCase(*itr).rfind(".nsf") != string::npos || lowerCase(*itr).rfind(".unf") != string::npos
|
||||
|| lowerCase(*itr).rfind(".nez") != string::npos || lowerCase(*itr).rfind(".unif") != string::npos)
|
||||
else if(plugin.loaded())
|
||||
{
|
||||
strncpy(tmp.path, (*itr).c_str(), sizeof(tmp.path));
|
||||
|
||||
(*itr).assign(&(*itr)[(*itr).find_last_of('/') + 1]);
|
||||
|
||||
char filename[64];
|
||||
strncpy(filename, (*itr).c_str(), sizeof(filename));
|
||||
|
||||
int ccolor = custom_titles.getColor("COVERS", (const char *) tmp.hdr.id, 0xff0000).intVal();
|
||||
tmp.hdr.casecolor = ccolor != 0xff0000 ? ccolor : 0xff0000;
|
||||
|
||||
mbstowcs(tmp.title, filename, sizeof(tmp.title));
|
||||
Asciify(tmp.title);
|
||||
gprintf("Found: %s\n", tmp.path);
|
||||
tmp.hdr.magic = 0x46434555 ; //FCEU
|
||||
tmp.hdr.gc_magic = 0x4c4f4c4f; //Abusing gc_magic for general emu detection ;)
|
||||
headerlist.push_back(tmp);
|
||||
continue;
|
||||
}
|
||||
else if(lowerCase(*itr).rfind(".smc") != string::npos || lowerCase(*itr).rfind(".fig") != string::npos
|
||||
|| lowerCase(*itr).rfind(".sfc") != string::npos || lowerCase(*itr).rfind(".swc") != string::npos)
|
||||
{
|
||||
strncpy(tmp.path, (*itr).c_str(), sizeof(tmp.path));
|
||||
|
||||
(*itr).assign(&(*itr)[(*itr).find_last_of('/') + 1]);
|
||||
|
||||
char filename[64];
|
||||
strncpy(filename, (*itr).c_str(), sizeof(filename));
|
||||
|
||||
int ccolor = custom_titles.getColor("COVERS", (const char *) tmp.hdr.id, 0x01A300).intVal();
|
||||
tmp.hdr.casecolor = ccolor != 0x01A300 ? ccolor : 0x01A300;
|
||||
|
||||
mbstowcs(tmp.title, filename, sizeof(tmp.title));
|
||||
Asciify(tmp.title);
|
||||
gprintf("Found: %s\n", tmp.path);
|
||||
tmp.hdr.magic = 0x534e4553; //SNES
|
||||
tmp.hdr.gc_magic = 0x4c4f4c4f; //Abusing gc_magic for general emu detection ;)
|
||||
headerlist.push_back(tmp);
|
||||
continue;
|
||||
}
|
||||
else if(lowerCase(*itr).rfind(".agb") != string::npos || lowerCase(*itr).rfind(".gba") != string::npos
|
||||
|| lowerCase(*itr).rfind(".bin") != string::npos || lowerCase(*itr).rfind(".elf") != string::npos
|
||||
|| lowerCase(*itr).rfind(".mb") != string::npos || lowerCase(*itr).rfind(".dmg") != string::npos
|
||||
|| lowerCase(*itr).rfind(".gb") != string::npos || lowerCase(*itr).rfind(".gbc") != string::npos
|
||||
|| lowerCase(*itr).rfind(".cgb") != string::npos || lowerCase(*itr).rfind(".sgb") != string::npos)
|
||||
{
|
||||
strncpy(tmp.path, (*itr).c_str(), sizeof(tmp.path));
|
||||
|
||||
(*itr).assign(&(*itr)[(*itr).find_last_of('/') + 1]);
|
||||
|
||||
char filename[64];
|
||||
strncpy(filename, (*itr).c_str(), sizeof(filename));
|
||||
|
||||
int ccolor = custom_titles.getColor("COVERS", (const char *) tmp.hdr.id, 0xfcff00).intVal();
|
||||
tmp.hdr.casecolor = ccolor != 0xfcff00 ? ccolor : 0xfcff00;
|
||||
|
||||
mbstowcs(tmp.title, filename, sizeof(tmp.title));
|
||||
Asciify(tmp.title);
|
||||
gprintf("Found: %s\n", tmp.path);
|
||||
tmp.hdr.magic = 0x56424158 ; //VBAX
|
||||
tmp.hdr.gc_magic = 0x4c4f4c4f; //Abusing gc_magic for general emu detection ;)
|
||||
headerlist.push_back(tmp);
|
||||
continue;
|
||||
}
|
||||
else if(lowerCase(*itr).rfind(".zip") != string::npos || lowerCase(*itr).rfind(".7z") != string::npos)
|
||||
{
|
||||
strncpy(tmp.path, (*itr).c_str(), sizeof(tmp.path));
|
||||
|
||||
(*itr).assign(&(*itr)[(*itr).find_last_of('/') + 1]);
|
||||
|
||||
char filename[64];
|
||||
strncpy(filename, (*itr).c_str(), sizeof(filename));
|
||||
|
||||
if(lowerCase(tmp.path).rfind("fceugx") != string::npos)
|
||||
safe_vector<string> 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<string>::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;
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "disc.h"
|
||||
#include "text.hpp"
|
||||
#include "cache.hpp"
|
||||
#include "config/config.hpp"
|
||||
|
||||
using namespace std;
|
||||
template <typename T>
|
||||
@ -24,7 +25,7 @@ class CList
|
||||
CList(){};
|
||||
~CList(){};
|
||||
void GetPaths(safe_vector<string> &pathlist, string containing, string directory, bool wbfs_fs = false);
|
||||
void GetHeaders(safe_vector<string> pathlist, safe_vector<T> &headerlist, string, string, string);
|
||||
void GetHeaders(safe_vector<string> pathlist, safe_vector<T> &headerlist, string, string, string, Config &plugin);
|
||||
void GetChannels(safe_vector<T> &headerlist, string, u32, string);
|
||||
private:
|
||||
void Check_For_ID(u8 *id, string path, string one, string two);
|
||||
|
@ -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();
|
||||
|
||||
|
@ -66,6 +66,7 @@ private:
|
||||
Config m_theme;
|
||||
Config m_titles;
|
||||
Config m_version;
|
||||
Config m_plugin;
|
||||
Channels m_channels;
|
||||
safe_vector<std::string> m_homebrewArgs;
|
||||
SmartBuf m_base_font;
|
||||
|
@ -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<std::string> arguments)
|
||||
{
|
||||
gprintf("Filepath of homebrew: %s\n",filepath);
|
||||
if(LoadHomebrew(filepath))
|
||||
{
|
||||
m_gcfg1.save(true);
|
||||
|
Loading…
Reference in New Issue
Block a user