mirror of
https://github.com/Fledge68/WiiFlow_Lite.git
synced 2024-12-28 12:51:52 +01:00
-homebrew coverflow view now uses folder names instead of
small and uppercase IDs for cover name and cache (issue 72)
This commit is contained in:
parent
ec69ecb55f
commit
5457c30a83
@ -53,4 +53,5 @@ Triiforce"
|
||||
|
||||
#define WII_MAGIC 0x5D1C9EA3
|
||||
#define GC_MAGIC 0xC2339F3D
|
||||
#define EMU_MAGIC 0x4C4F4C4F
|
||||
#define PLUGIN_MAGIC 0x4C4F4C4F
|
||||
#define HB_MAGIC 0x484F4D45
|
||||
|
@ -2555,14 +2555,14 @@ bool CCoverFlow::_loadCoverTexPNG(u32 i, bool box, bool hq)
|
||||
if (!!zBuffer && (!m_compressCache || compress(zBuffer.get(), &zBufferSize, tex.data.get(), bufSize) == Z_OK))
|
||||
{
|
||||
char gamePath[256];
|
||||
if(m_items[i].hdr->hdr.gc_magic == EMU_MAGIC)
|
||||
if(NoGameID(m_items[i].hdr->hdr.gc_magic))
|
||||
{
|
||||
if(string(m_items[i].hdr->path).find_last_of("/") != string::npos)
|
||||
strncpy(gamePath, &m_items[i].hdr->path[string(m_items[i].hdr->path).find_last_of("/")], sizeof(gamePath));
|
||||
else
|
||||
strncpy(gamePath, m_items[i].hdr->path, sizeof(gamePath));
|
||||
}
|
||||
FILE *file = fopen(fmt("%s/%s.wfc", m_cachePath.c_str(), (m_items[i].hdr->hdr.gc_magic == EMU_MAGIC ? gamePath : (char*)m_items[i].hdr->hdr.id)), "wb");
|
||||
FILE *file = fopen(fmt("%s/%s.wfc", m_cachePath.c_str(), (NoGameID(m_items[i].hdr->hdr.gc_magic) ? gamePath : (char*)m_items[i].hdr->hdr.id)), "wb");
|
||||
if (file != 0)
|
||||
{
|
||||
SWFCHeader header(tex, box, m_compressCache);
|
||||
@ -2627,29 +2627,29 @@ CCoverFlow::CLRet CCoverFlow::_loadCoverTex(u32 i, bool box, bool hq)
|
||||
bool allocFailed = false;
|
||||
|
||||
// Try to find the texture in the cache
|
||||
if (!m_cachePath.empty())
|
||||
if(!m_cachePath.empty())
|
||||
{
|
||||
char gamePath[256];
|
||||
if(m_items[i].hdr->hdr.gc_magic == EMU_MAGIC)
|
||||
if(NoGameID(m_items[i].hdr->hdr.gc_magic))
|
||||
{
|
||||
if(string(m_items[i].hdr->path).find_last_of("/") != string::npos)
|
||||
strncpy(gamePath, &m_items[i].hdr->path[string(m_items[i].hdr->path).find_last_of("/")], sizeof(gamePath));
|
||||
else
|
||||
strncpy(gamePath, m_items[i].hdr->path, sizeof(gamePath));
|
||||
}
|
||||
FILE *file = fopen(fmt("%s/%s.wfc", m_cachePath.c_str(), (m_items[i].hdr->hdr.gc_magic == EMU_MAGIC ? gamePath : (char*)m_items[i].hdr->hdr.id)), "rb");
|
||||
if (file != 0)
|
||||
FILE *file = fopen(fmt("%s/%s.wfc", m_cachePath.c_str(), (NoGameID(m_items[i].hdr->hdr.gc_magic) ? gamePath : (char*)m_items[i].hdr->hdr.id)), "rb");
|
||||
if(file != 0)
|
||||
{
|
||||
bool success = false;
|
||||
fseek(file, 0, SEEK_END);
|
||||
u32 fileSize = ftell(file);
|
||||
SWFCHeader header;
|
||||
if (fileSize > sizeof header)
|
||||
if(fileSize > sizeof header)
|
||||
{
|
||||
fseek(file, 0, SEEK_SET);
|
||||
fread(&header, 1, sizeof header, file);
|
||||
// Try to find a matching cache file, otherwise try the PNG file, otherwise try again with the cache file with less constraints
|
||||
if (header.newFmt != 0 && (((!box || header.full != 0) && (header.cmpr != 0) == m_compressTextures) || (!_loadCoverTexPNG(i, box, hq))))
|
||||
if(header.newFmt != 0 && (((!box || header.full != 0) && (header.cmpr != 0) == m_compressTextures) || (!_loadCoverTexPNG(i, box, hq))))
|
||||
{
|
||||
STexture tex;
|
||||
tex.format = header.cmpr != 0 ? GX_TF_CMPR : GX_TF_RGB565;
|
||||
|
@ -180,7 +180,7 @@ void CList<dir_discHdr>::GetHeaders(vector<string> pathlist, vector<dir_discHdr>
|
||||
|
||||
gprintf("Found: %s\n", tmp.path);
|
||||
sscanf(plugin.getString("PLUGIN","magic","").c_str(), "%08x", &tmp.hdr.magic); //Plugin magic
|
||||
tmp.hdr.gc_magic = EMU_MAGIC; //Abusing gc_magic for general emu detection ;)
|
||||
tmp.hdr.gc_magic = PLUGIN_MAGIC; //Abusing gc_magic for general emu detection ;)
|
||||
headerlist.push_back(tmp);
|
||||
break;
|
||||
}
|
||||
@ -330,54 +330,34 @@ void CList<dir_discHdr>::GetHeaders(vector<string> pathlist, vector<dir_discHdr>
|
||||
headerlist.push_back(tmp);
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
else if((*itr).rfind(".dol") != string::npos || (*itr).rfind(".DOL") != string::npos
|
||||
|| (*itr).rfind(".elf") != string::npos || (*itr).rfind(".ELF") != string::npos)
|
||||
{
|
||||
char *filename = &(*itr)[(*itr).find_last_of('/')+1];
|
||||
strncpy((char*)tmp.hdr.id, "HB_APP", sizeof(tmp.hdr.id));
|
||||
|
||||
if(strcasecmp(filename, "boot.dol") != 0 && strcasecmp(filename, "boot.elf") != 0) continue;
|
||||
|
||||
(*itr)[(*itr).find_last_of('/')] = 0;
|
||||
strncpy(tmp.path, (*itr).c_str(), sizeof(tmp.path));
|
||||
|
||||
(*itr).assign(&(*itr)[(*itr).find_last_of('/') + 1]);
|
||||
|
||||
(*itr)[0] = toupper((*itr)[0]);
|
||||
for (u32 i = 1; i < (*itr).size(); ++i)
|
||||
{
|
||||
if((*itr)[i] == '_' || (*itr)[i] == '-')
|
||||
(*itr)[i] = ' ';
|
||||
|
||||
if((*itr)[i] == ' ')
|
||||
{
|
||||
(*itr)[i + 1] = toupper((*itr)[i + 1]);
|
||||
i++;
|
||||
}
|
||||
else (*itr)[i] = tolower((*itr)[i]);
|
||||
}
|
||||
|
||||
memcpy(tmp.hdr.id, (*itr).c_str(), 6);
|
||||
for (u32 i = 0; i < 6; ++i)
|
||||
{
|
||||
tmp.hdr.id[i] = toupper(tmp.hdr.id[i]);
|
||||
if(!isalnum(tmp.hdr.id[i]) || tmp.hdr.id[i] == ' ' || tmp.hdr.id[i] == '\0')
|
||||
tmp.hdr.id[i] = '_';
|
||||
}
|
||||
char foldername[64];
|
||||
strncpy(foldername, (*itr).c_str(), sizeof(foldername));
|
||||
gprintf("Found: %s\n", foldername);
|
||||
|
||||
// Get info from custom titles
|
||||
wstringEx tmpString;
|
||||
GTitle = custom_titles.getString("TITLES", (const char *) tmp.hdr.id);
|
||||
int ccolor = custom_titles.getColor("COVERS", (const char *) tmp.hdr.id, tmp.hdr.casecolor).intVal();
|
||||
if(GTitle.size() > 0 || (gameTDB.GetTitle((char *)tmp.hdr.id, GTitle)))
|
||||
{
|
||||
GTitle = custom_titles.getString("TITLES", (const char *)foldername);
|
||||
int ccolor = custom_titles.getColor("COVERS", (const char *)foldername, tmp.hdr.casecolor).intVal();
|
||||
if(GTitle.size() > 0)
|
||||
tmpString.fromUTF8(GTitle.c_str());
|
||||
tmp.hdr.casecolor = ccolor != 1 ? ccolor : gameTDB.GetCaseColor((char *)tmp.hdr.id);
|
||||
}
|
||||
else
|
||||
{
|
||||
tmpString.fromUTF8((*itr).c_str());
|
||||
tmp.hdr.casecolor = ccolor != 1 ? ccolor : 1;
|
||||
}
|
||||
tmpString.fromUTF8(foldername);
|
||||
|
||||
tmp.hdr.casecolor = ccolor;
|
||||
tmp.hdr.gc_magic = HB_MAGIC;
|
||||
wcsncpy(tmp.title, tmpString.c_str(), 64);
|
||||
headerlist.push_back(tmp);
|
||||
continue;
|
||||
|
@ -3,6 +3,7 @@
|
||||
#define _UTILS_H_
|
||||
|
||||
#include <gctypes.h>
|
||||
#include "defines.h"
|
||||
|
||||
#define KB_SIZE 1024.0
|
||||
#define MB_SIZE 1048576.0
|
||||
@ -24,6 +25,8 @@
|
||||
#define Write16(addr, val) *(u16 *)addr = val; DCFlushRange((void *)addr, sizeof(u16));
|
||||
#define Write32(addr, val) *(u32 *)addr = val; DCFlushRange((void *)addr, sizeof(u32));
|
||||
|
||||
#define NoGameID(x) (x == PLUGIN_MAGIC || x == HB_MAGIC)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
@ -1508,14 +1508,19 @@ void CMenu::_initCF(void)
|
||||
for (u32 i = 0; i < m_gameList.size(); ++i)
|
||||
{
|
||||
u64 chantitle = m_gameList[i].hdr.chantitle;
|
||||
if (m_current_view == COVERFLOW_CHANNEL && chantitle == HBC_108)
|
||||
if(m_current_view == COVERFLOW_CHANNEL && chantitle == HBC_108)
|
||||
strncpy((char *) m_gameList[i].hdr.id, "JODI", 6);
|
||||
if(m_current_view == COVERFLOW_EMU)
|
||||
if(NoGameID(m_gameList[i].hdr.gc_magic))
|
||||
{
|
||||
string tempname(m_gameList[i].path);
|
||||
if(!m_plugin.isScummVM(m_gameList[i].hdr.magic))
|
||||
if(m_gameList[i].hdr.gc_magic == HB_MAGIC)
|
||||
{
|
||||
if(tempname.empty() || tempname.find_first_of('/') == string::npos)
|
||||
tempname.assign(&tempname[tempname.find_last_of('/') + 1]);
|
||||
id = tempname;
|
||||
}
|
||||
else if(!m_plugin.isScummVM(m_gameList[i].hdr.magic))
|
||||
{
|
||||
if(tempname.empty() || tempname.find_first_of('/') == string::npos)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -1648,7 +1653,7 @@ void CMenu::_initCF(void)
|
||||
if(dumpGameLst)
|
||||
dump.setWString(domain, id, m_gameList[i].title);
|
||||
|
||||
if (m_current_view == COVERFLOW_EMU)
|
||||
if(m_gameList[i].hdr.gc_magic == PLUGIN_MAGIC)
|
||||
{
|
||||
string tempname(m_gameList[i].path);
|
||||
if(tempname.find_last_of("/") != string::npos)
|
||||
@ -1670,15 +1675,10 @@ void CMenu::_initCF(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (m_current_view != COVERFLOW_HOMEBREW)
|
||||
else if(m_gameList[i].hdr.gc_magic == HB_MAGIC)
|
||||
m_cf.addItem(&m_gameList[i], fmt("%s/icon.png", m_gameList[i].path), fmt("%s/%s.png", m_boxPicDir.c_str(), id.c_str()), playcount, lastPlayed);
|
||||
else
|
||||
m_cf.addItem(&m_gameList[i], fmt("%s/%s.png", m_picDir.c_str(), id.c_str()), fmt("%s/%s.png", m_boxPicDir.c_str(), id.c_str()), playcount, lastPlayed);
|
||||
else
|
||||
{
|
||||
string s = sfmt("%s", m_gameList[i].path);
|
||||
string f = s.substr(0, s.find_last_of("/"));
|
||||
m_cf.addItem(&m_gameList[i], fmt("%s/icon.png", f.c_str()), fmt("%s/%s.png", m_boxPicDir.c_str(), id.c_str()), playcount, lastPlayed);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
m_gcfg1.unload();
|
||||
@ -2074,7 +2074,7 @@ bool CMenu::_loadList(void)
|
||||
retval = _loadGameList();
|
||||
break;
|
||||
}
|
||||
|
||||
gprintf("Games found: %i\n", m_gameList.size());
|
||||
m_cfg.remove(_domainFromView(), "update_cache");
|
||||
|
||||
return retval;
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include "homebrew.h"
|
||||
#include "defines.h"
|
||||
#include "gc/gc.h"
|
||||
#include "gc/fileOps.h"
|
||||
#include "Gekko.h"
|
||||
|
||||
extern const u8 btngamecfg_png[];
|
||||
@ -632,7 +633,7 @@ void CMenu::_directlaunch(const string &id)
|
||||
void CMenu::_launch(dir_discHdr *hdr)
|
||||
{
|
||||
m_gcfg2.load(fmt("%s/" GAME_SETTINGS2_FILENAME, m_settingsDir.c_str()));
|
||||
if(hdr->hdr.gc_magic == EMU_MAGIC)
|
||||
if(hdr->hdr.gc_magic == PLUGIN_MAGIC)
|
||||
{
|
||||
string title(&hdr->path[string(hdr->path).find_last_of("/")+1]);
|
||||
string wiiflow_dol(m_dol);
|
||||
@ -665,30 +666,26 @@ void CMenu::_launch(dir_discHdr *hdr)
|
||||
_launchHomebrew(fmt("%s/%s", m_pluginsDir.c_str(), m_plugin.GetDolName(hdr->hdr.magic)), arguments);
|
||||
return;
|
||||
}
|
||||
else if(hdr->hdr.gc_magic == HB_MAGIC)
|
||||
{
|
||||
char gamepath[128];
|
||||
snprintf(gamepath, sizeof(gamepath), "%s/boot.dol", hdr->path);
|
||||
if(!fsop_FileExist((const char*)gamepath))
|
||||
snprintf(gamepath, sizeof(gamepath), "%s/boot.elf", hdr->path);
|
||||
_launchHomebrew(gamepath, m_homebrewArgs);
|
||||
return;
|
||||
}
|
||||
else if(hdr->hdr.gc_magic == GC_MAGIC)
|
||||
{
|
||||
_launchGC(hdr, true);
|
||||
return;
|
||||
}
|
||||
switch(m_current_view)
|
||||
else if(m_current_view == COVERFLOW_CHANNEL)
|
||||
{
|
||||
case COVERFLOW_HOMEBREW:
|
||||
_launchHomebrew((char *)hdr->path, m_homebrewArgs);
|
||||
break;
|
||||
case COVERFLOW_CHANNEL:
|
||||
_launchChannel(hdr);
|
||||
break;
|
||||
case COVERFLOW_DML:
|
||||
_launchGC(hdr, true);
|
||||
break;
|
||||
case COVERFLOW_EMU:
|
||||
_launchHomebrew((char *)hdr->path, m_homebrewArgs);
|
||||
break;
|
||||
case COVERFLOW_USB:
|
||||
default:
|
||||
_launchGame(hdr, false);
|
||||
break;
|
||||
_launchChannel(hdr);
|
||||
return;
|
||||
}
|
||||
_launchGame(hdr, false);
|
||||
}
|
||||
|
||||
extern "C" {extern void USBStorage_Deinit(void);}
|
||||
@ -1439,7 +1436,7 @@ void CMenu::_gameSoundThread(CMenu *m)
|
||||
m->m_gamesound_changed = true;
|
||||
return;
|
||||
}
|
||||
else if(m->m_cf.getHdr()->hdr.gc_magic == EMU_MAGIC)
|
||||
else if(m->m_cf.getHdr()->hdr.gc_magic == PLUGIN_MAGIC)
|
||||
{
|
||||
m->m_gameSound.Load(m->m_plugin.GetBannerSound(m->m_cf.getHdr()->hdr.magic), m->m_plugin.GetBannerSoundSize(), false);
|
||||
m->m_gamesound_changed = true;
|
||||
|
@ -372,7 +372,7 @@ bool CMenu::_wbfsOp(CMenu::WBFS_OP op)
|
||||
fsop_deleteFolder(source);
|
||||
upd_dml = true;
|
||||
}
|
||||
else if(m_cf.getHdr()->hdr.gc_magic == EMU_MAGIC)
|
||||
else if(m_cf.getHdr()->hdr.gc_magic == PLUGIN_MAGIC)
|
||||
{
|
||||
fsop_deleteFile((char*)m_cf.getHdr()->path);
|
||||
upd_emu = true;
|
||||
|
@ -214,6 +214,7 @@ vector<dir_discHdr> Plugin::ParseScummvmINI(Config &ini, string Device)
|
||||
continue;
|
||||
}
|
||||
memset(&tmp, 0, sizeof(dir_discHdr));
|
||||
strncpy((char*)tmp.hdr.id, "PLUGIN", sizeof(tmp.hdr.id));
|
||||
tmp.hdr.casecolor = Plugins.back().caseColor;
|
||||
wstringEx tmpString;
|
||||
tmpString.fromUTF8(GameName.c_str());
|
||||
@ -221,7 +222,7 @@ vector<dir_discHdr> Plugin::ParseScummvmINI(Config &ini, string Device)
|
||||
strncpy(tmp.path, game.c_str(), sizeof(tmp.path));
|
||||
gprintf("Found: %ls\n", tmp.title);
|
||||
tmp.hdr.magic = Plugins.back().magicWord;
|
||||
tmp.hdr.gc_magic = EMU_MAGIC;
|
||||
tmp.hdr.gc_magic = PLUGIN_MAGIC;
|
||||
gameHeader.push_back(tmp);
|
||||
game = ini.nextDomain();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user