diff --git a/source/menu/menu.cpp b/source/menu/menu.cpp index 48feb78a..ca08e2f8 100644 --- a/source/menu/menu.cpp +++ b/source/menu/menu.cpp @@ -1502,9 +1502,10 @@ void CMenu::_initCF(void) { string tempname(m_gameList[i].path); tempname.assign(&tempname[tempname.find_last_of('/') + 1]); + string coverFolder(m_plugin.GetCoverFolderName(m_gameList[i].hdr.magic)); //if(tempname.find_last_of('.') != string::npos) // tempname.erase(tempname.find_last_of('.'), tempname.size() - tempname.find_last_of('.')); - m_cf.addItem(&m_gameList[i], sfmt("%s/%s.png", m_picDir.c_str(), tempname.c_str()).c_str(), sfmt("%s/%s.png", m_boxPicDir.c_str(), tempname.c_str()).c_str(), playcount, lastPlayed); + m_cf.addItem(&m_gameList[i], sfmt("%s/%s/%s.png", m_picDir.c_str(), coverFolder.c_str(), tempname.c_str()).c_str(), sfmt("%s/%s/%s.png", m_boxPicDir.c_str(), coverFolder.c_str(), tempname.c_str()).c_str(), playcount, lastPlayed); } else if (m_current_view != COVERFLOW_HOMEBREW) m_cf.addItem(&m_gameList[i], sfmt("%s/%s.png", m_picDir.c_str(), id.c_str()).c_str(), sfmt("%s/%s.png", m_boxPicDir.c_str(), id.c_str()).c_str(), playcount, lastPlayed); diff --git a/source/plugin/plugin.cpp b/source/plugin/plugin.cpp index e67076a8..dfab8f4d 100644 --- a/source/plugin/plugin.cpp +++ b/source/plugin/plugin.cpp @@ -29,12 +29,9 @@ void Plugin::EndAdd() void Plugin::Cleanup() { - for(banner_pos = 0; banner_pos < magicWords.size(); banner_pos++) - MEM2_free(BannerSound[banner_pos]); - BannerSound.clear(); - BannerSoundSize.clear(); - magicWords.clear(); - DolName.clear(); + for(banner_pos = 0; banner_pos < Plugins.size(); banner_pos++) + MEM2_free(Plugins[banner_pos].BannerSound); + Plugins.clear(); banner_pos = 0; pluginsDir.erase(0, pluginsDir.size()); } @@ -44,13 +41,12 @@ bool Plugin::AddPlugin(Config &plugin) if(!adding) return false; - DolName.push_back(plugin.getString("PLUGIN","dolFile","")); - u32 magic, caseColor; - sscanf(plugin.getString("PLUGIN","magic","").c_str(), "%08x", &magic); - magicWords.push_back(magic); - sscanf(plugin.getString("PLUGIN","coverColor","").c_str(), "%08x", &caseColor); - caseColors.push_back(caseColor); - ReturnLoader.push_back(plugin.getBool("PLUGIN","ReturnLoader")); + PluginOptions NewPlugin; + NewPlugin.DolName = plugin.getString("PLUGIN","dolFile",""); + NewPlugin.coverFolder = plugin.getString("PLUGIN","coverFolder",""); + sscanf(plugin.getString("PLUGIN","magic","").c_str(), "%08x", &NewPlugin.magicWord); + sscanf(plugin.getString("PLUGIN","coverColor","").c_str(), "%08x", &NewPlugin.caseColor); + NewPlugin.ReturnLoader = plugin.getBool("PLUGIN","ReturnLoader"); string bannerfilepath = sfmt("%s/%s", pluginsDir.c_str(), plugin.getString("PLUGIN","bannerSound","").c_str()); ifstream infile; @@ -64,34 +60,36 @@ bool Plugin::AddPlugin(Config &plugin) //Don't free that, otherwise you would delete the sound char* FileReadBuffer = (char*)MEM2_alloc(size); infile.read(FileReadBuffer, size); - BannerSound.push_back((u8*)FileReadBuffer); - BannerSoundSize.push_back(size); + NewPlugin.BannerSound = (u8*)FileReadBuffer; + NewPlugin.BannerSoundSize = size; + Plugins.push_back(NewPlugin); return true; } else { - BannerSound.push_back(0); - BannerSoundSize.push_back(0); + NewPlugin.BannerSound = 0; + NewPlugin.BannerSoundSize = 0; + Plugins.push_back(NewPlugin); } return false; } bool Plugin::UseReturnLoader(u32 magic) { - for(u8 pos = 0; pos < magicWords.size(); pos++) + for(u8 pos = 0; pos < Plugins.size(); pos++) { - if(magic == magicWords[pos]) - return ReturnLoader[pos]; + if(magic == Plugins[pos].magicWord) + return Plugins[pos].ReturnLoader; } return false; } u8* Plugin::GetBannerSound(u32 magic) { - for(banner_pos = 0; banner_pos < magicWords.size(); banner_pos++) + for(banner_pos = 0; banner_pos < Plugins.size(); banner_pos++) { - if(magic == magicWords[banner_pos]) - return BannerSound[banner_pos]; + if(magic == Plugins[banner_pos].magicWord) + return Plugins[banner_pos].BannerSound; } return NULL; } @@ -99,17 +97,26 @@ u8* Plugin::GetBannerSound(u32 magic) u32 Plugin::GetBannerSoundSize() { //We call that directly after GetBannerSound, so no need to search for the magic again - if(BannerSoundSize[banner_pos] > 0) - return BannerSoundSize[banner_pos]; + if(Plugins[banner_pos].BannerSoundSize > 0) + return Plugins[banner_pos].BannerSoundSize; return 0; } char* Plugin::GetDolName(u32 magic) { char *null = (char*)" "; - for(banner_pos = 0; banner_pos < magicWords.size(); banner_pos++) - if(magic == magicWords[banner_pos]) - return (char*)DolName[banner_pos].c_str(); + for(u8 pos = 0; pos < Plugins.size(); pos++) + if(magic == Plugins[pos].magicWord) + return (char*)Plugins[pos].DolName.c_str(); + return null; +} + +char* Plugin::GetCoverFolderName(u32 magic) +{ + char *null = (char*)" "; + for(u8 pos = 0; pos < Plugins.size(); pos++) + if(magic == Plugins[pos].magicWord) + return (char*)Plugins[pos].coverFolder.c_str(); return null; } @@ -133,13 +140,13 @@ safe_vector Plugin::ParseScummvmINI(Config &ini, string Device) continue; } memset(&tmp, 0, sizeof(dir_discHdr)); - tmp.hdr.casecolor = caseColors.back(); + tmp.hdr.casecolor = Plugins.back().caseColor; wstringEx tmpString; tmpString.fromUTF8(ini.getString(game,"description").c_str()); wcsncpy(tmp.title, tmpString.c_str(), 64); strncpy(tmp.path, game.c_str(), sizeof(tmp.path)); gprintf("Found: %ls\n", tmp.title); - tmp.hdr.magic = magicWords.back(); + tmp.hdr.magic = Plugins.back().magicWord; tmp.hdr.gc_magic = 0x4c4f4c4f; gameHeader.push_back(tmp); game = ini.nextDomain(); diff --git a/source/plugin/plugin.hpp b/source/plugin/plugin.hpp index 0e8aa5ee..a82bbb97 100644 --- a/source/plugin/plugin.hpp +++ b/source/plugin/plugin.hpp @@ -17,6 +17,17 @@ using namespace std; +struct PluginOptions +{ + u8 *BannerSound; + u32 BannerSoundSize; + u32 magicWord; + string DolName; + string coverFolder; + u32 caseColor; + bool ReturnLoader; +}; + class Plugin { public: @@ -24,19 +35,14 @@ public: u8* GetBannerSound(u32 magic); u32 GetBannerSoundSize(); char* GetDolName(u32 magic); + char* GetCoverFolderName(u32 magic); bool UseReturnLoader(u32 magic); void init(string); void Cleanup(); void EndAdd(); safe_vector ParseScummvmINI(Config &ini, string Device); private: - safe_vector BannerSound; - safe_vector BannerSoundSize; - safe_vector magicWords; - safe_vector DolName; - safe_vector caseColors; - safe_vector ReturnLoader; - + safe_vector Plugins; u8 banner_pos; string pluginsDir; bool adding; diff --git a/wiiflow.pnps b/wiiflow.pnps index f276c756..eba498cf 100644 --- a/wiiflow.pnps +++ b/wiiflow.pnps @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file