-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);
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);

View File

@ -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<dir_discHdr> 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();

View File

@ -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<dir_discHdr> ParseScummvmINI(Config &ini, string Device);
private:
safe_vector<u8*> BannerSound;
safe_vector<u32> BannerSoundSize;
safe_vector<u32> magicWords;
safe_vector<string> DolName;
safe_vector<u32> caseColors;
safe_vector<bool> ReturnLoader;
safe_vector<PluginOptions> Plugins;
u8 banner_pos;
string pluginsDir;
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>