-added possibility to select the cover folder in

emulator coverflow, for example in the fceugx.ini
set "coverFolder=fceugx", then wiiflow will look
into "wiiflow/boxcovers/fceugx" for covers instead
of "wiiflow/boxcovers", same goes for "wiiflow/covers"
This commit is contained in:
fix94.1 2012-05-01 13:30:16 +00:00
parent f75ac72826
commit 068d45dbf6
4 changed files with 53 additions and 39 deletions

View File

@ -1502,9 +1502,10 @@ void CMenu::_initCF(void)
{ {
string tempname(m_gameList[i].path); string tempname(m_gameList[i].path);
tempname.assign(&tempname[tempname.find_last_of('/') + 1]); 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) //if(tempname.find_last_of('.') != string::npos)
// tempname.erase(tempname.find_last_of('.'), tempname.size() - tempname.find_last_of('.')); // 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) 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); 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);

View File

@ -29,12 +29,9 @@ void Plugin::EndAdd()
void Plugin::Cleanup() void Plugin::Cleanup()
{ {
for(banner_pos = 0; banner_pos < magicWords.size(); banner_pos++) for(banner_pos = 0; banner_pos < Plugins.size(); banner_pos++)
MEM2_free(BannerSound[banner_pos]); MEM2_free(Plugins[banner_pos].BannerSound);
BannerSound.clear(); Plugins.clear();
BannerSoundSize.clear();
magicWords.clear();
DolName.clear();
banner_pos = 0; banner_pos = 0;
pluginsDir.erase(0, pluginsDir.size()); pluginsDir.erase(0, pluginsDir.size());
} }
@ -44,13 +41,12 @@ bool Plugin::AddPlugin(Config &plugin)
if(!adding) if(!adding)
return false; return false;
DolName.push_back(plugin.getString("PLUGIN","dolFile","")); PluginOptions NewPlugin;
u32 magic, caseColor; NewPlugin.DolName = plugin.getString("PLUGIN","dolFile","");
sscanf(plugin.getString("PLUGIN","magic","").c_str(), "%08x", &magic); NewPlugin.coverFolder = plugin.getString("PLUGIN","coverFolder","");
magicWords.push_back(magic); sscanf(plugin.getString("PLUGIN","magic","").c_str(), "%08x", &NewPlugin.magicWord);
sscanf(plugin.getString("PLUGIN","coverColor","").c_str(), "%08x", &caseColor); sscanf(plugin.getString("PLUGIN","coverColor","").c_str(), "%08x", &NewPlugin.caseColor);
caseColors.push_back(caseColor); NewPlugin.ReturnLoader = plugin.getBool("PLUGIN","ReturnLoader");
ReturnLoader.push_back(plugin.getBool("PLUGIN","ReturnLoader"));
string bannerfilepath = sfmt("%s/%s", pluginsDir.c_str(), plugin.getString("PLUGIN","bannerSound","").c_str()); string bannerfilepath = sfmt("%s/%s", pluginsDir.c_str(), plugin.getString("PLUGIN","bannerSound","").c_str());
ifstream infile; ifstream infile;
@ -64,34 +60,36 @@ bool Plugin::AddPlugin(Config &plugin)
//Don't free that, otherwise you would delete the sound //Don't free that, otherwise you would delete the sound
char* FileReadBuffer = (char*)MEM2_alloc(size); char* FileReadBuffer = (char*)MEM2_alloc(size);
infile.read(FileReadBuffer, size); infile.read(FileReadBuffer, size);
BannerSound.push_back((u8*)FileReadBuffer); NewPlugin.BannerSound = (u8*)FileReadBuffer;
BannerSoundSize.push_back(size); NewPlugin.BannerSoundSize = size;
Plugins.push_back(NewPlugin);
return true; return true;
} }
else else
{ {
BannerSound.push_back(0); NewPlugin.BannerSound = 0;
BannerSoundSize.push_back(0); NewPlugin.BannerSoundSize = 0;
Plugins.push_back(NewPlugin);
} }
return false; return false;
} }
bool Plugin::UseReturnLoader(u32 magic) 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]) if(magic == Plugins[pos].magicWord)
return ReturnLoader[pos]; return Plugins[pos].ReturnLoader;
} }
return false; return false;
} }
u8* Plugin::GetBannerSound(u32 magic) 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]) if(magic == Plugins[banner_pos].magicWord)
return BannerSound[banner_pos]; return Plugins[banner_pos].BannerSound;
} }
return NULL; return NULL;
} }
@ -99,17 +97,26 @@ u8* Plugin::GetBannerSound(u32 magic)
u32 Plugin::GetBannerSoundSize() u32 Plugin::GetBannerSoundSize()
{ {
//We call that directly after GetBannerSound, so no need to search for the magic again //We call that directly after GetBannerSound, so no need to search for the magic again
if(BannerSoundSize[banner_pos] > 0) if(Plugins[banner_pos].BannerSoundSize > 0)
return BannerSoundSize[banner_pos]; return Plugins[banner_pos].BannerSoundSize;
return 0; return 0;
} }
char* Plugin::GetDolName(u32 magic) char* Plugin::GetDolName(u32 magic)
{ {
char *null = (char*)" "; char *null = (char*)" ";
for(banner_pos = 0; banner_pos < magicWords.size(); banner_pos++) for(u8 pos = 0; pos < Plugins.size(); pos++)
if(magic == magicWords[banner_pos]) if(magic == Plugins[pos].magicWord)
return (char*)DolName[banner_pos].c_str(); 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; return null;
} }
@ -133,13 +140,13 @@ safe_vector<dir_discHdr> Plugin::ParseScummvmINI(Config &ini, string Device)
continue; continue;
} }
memset(&tmp, 0, sizeof(dir_discHdr)); memset(&tmp, 0, sizeof(dir_discHdr));
tmp.hdr.casecolor = caseColors.back(); tmp.hdr.casecolor = Plugins.back().caseColor;
wstringEx tmpString; wstringEx tmpString;
tmpString.fromUTF8(ini.getString(game,"description").c_str()); tmpString.fromUTF8(ini.getString(game,"description").c_str());
wcsncpy(tmp.title, tmpString.c_str(), 64); wcsncpy(tmp.title, tmpString.c_str(), 64);
strncpy(tmp.path, game.c_str(), sizeof(tmp.path)); strncpy(tmp.path, game.c_str(), sizeof(tmp.path));
gprintf("Found: %ls\n", tmp.title); gprintf("Found: %ls\n", tmp.title);
tmp.hdr.magic = magicWords.back(); tmp.hdr.magic = Plugins.back().magicWord;
tmp.hdr.gc_magic = 0x4c4f4c4f; tmp.hdr.gc_magic = 0x4c4f4c4f;
gameHeader.push_back(tmp); gameHeader.push_back(tmp);
game = ini.nextDomain(); game = ini.nextDomain();

View File

@ -17,6 +17,17 @@
using namespace std; using namespace std;
struct PluginOptions
{
u8 *BannerSound;
u32 BannerSoundSize;
u32 magicWord;
string DolName;
string coverFolder;
u32 caseColor;
bool ReturnLoader;
};
class Plugin class Plugin
{ {
public: public:
@ -24,19 +35,14 @@ public:
u8* GetBannerSound(u32 magic); u8* GetBannerSound(u32 magic);
u32 GetBannerSoundSize(); u32 GetBannerSoundSize();
char* GetDolName(u32 magic); char* GetDolName(u32 magic);
char* GetCoverFolderName(u32 magic);
bool UseReturnLoader(u32 magic); bool UseReturnLoader(u32 magic);
void init(string); void init(string);
void Cleanup(); void Cleanup();
void EndAdd(); void EndAdd();
safe_vector<dir_discHdr> ParseScummvmINI(Config &ini, string Device); safe_vector<dir_discHdr> ParseScummvmINI(Config &ini, string Device);
private: private:
safe_vector<u8*> BannerSound; safe_vector<PluginOptions> Plugins;
safe_vector<u32> BannerSoundSize;
safe_vector<u32> magicWords;
safe_vector<string> DolName;
safe_vector<u32> caseColors;
safe_vector<bool> ReturnLoader;
u8 banner_pos; u8 banner_pos;
string pluginsDir; string pluginsDir;
bool adding; bool adding;

View File

@ -1 +1 @@
<pd><ViewState><e p="Wiiflow" x="true"></e><e p="Wiiflow\resources" x="false"></e><e p="Wiiflow\source\devicemounter\libwbfs" x="false"></e><e p="Wiiflow\data" x="false"></e><e p="Wiiflow\scripts" x="false"></e><e p="Wiiflow\source" x="true"></e><e p="Wiiflow\source\network" x="false"></e><e p="Wiiflow\source\channel" x="true"></e><e p="Wiiflow\source\menu" x="true"></e><e p="Wiiflow\docs" x="false"></e><e p="Wiiflow\source\cheats" x="true"></e><e p="Wiiflow\portlibs" x="false"></e><e p="Wiiflow\source\config" x="true"></e><e p="Wiiflow\source\devicemounter" x="true"></e><e p="Wiiflow\source\gc" x="true"></e><e p="Wiiflow\source\gecko" x="true"></e><e p="Wiiflow\source\gui" x="true"></e><e p="Wiiflow\source\homebrew" x="true"></e><e p="Wiiflow\source\list" x="true"></e><e p="Wiiflow\source\loader" x="true"></e><e p="Wiiflow\source\memory" x="false"></e><e p="Wiiflow\source\music" x="false"></e><e p="Wiiflow\source\plugin" x="false"></e><e p="Wiiflow\source\unzip" x="false"></e><e p="Wiiflow\source\wstringEx" x="false"></e><e p="Wiiflow\wii" x="false"></e></ViewState></pd> <pd><ViewState><e p="Wiiflow" x="true"></e><e p="Wiiflow\resources" x="false"></e><e p="Wiiflow\data" x="false"></e><e p="Wiiflow\scripts" x="false"></e><e p="Wiiflow\source" x="false"></e><e p="Wiiflow\wii" x="false"></e><e p="Wiiflow\docs" x="false"></e><e p="Wiiflow\portlibs" x="false"></e></ViewState></pd>