From edc886ecdc3936c483ec6b680a5ee95936924b8d Mon Sep 17 00:00:00 2001 From: fledge68 Date: Thu, 1 Nov 2012 18:38:22 +0000 Subject: [PATCH] - changed source menu pages max to 6 for 72 buttons max. - added custom missing covers support. Totally optional - without them wiiflow will display the usual blank question marks or theme related ones just like normal. Does not affect downloading covers or manually putting covers in wiiflow's cover folder. Wiiflow still checks for the cached cover first, then the box cover and flat cover, but before displaying the usual blank question mark ones wiiflow now looks for these custom missing covers. Put your custom missing covers in your normal wiiflow boxcovers folder with all the other wii game covers. Rename them to the magicnumber.jpg and for non plugins - wii.jpg, channels.jpg, gamecube.jpg, and homebrew.jpg. You have to use jpg's when using this default method. For theme related cover images still put them in your normal wiiflow boxcovers folder and rename them if necessary. I recommend adding the theme name and underscore as a prefix to the image name. Then add the following to your theme.ini modifying it to your liking. Note when using theme related cover images they can be png's. [BLANK_COVERS] wii=carbonik_wii.jpg gamecube=carbonik_gamecube.jpg channels=carbonik_channels.jpg homebrew=carbonik_homebrew.jpg 53454741=carbonik_53454741.jpg 4D504345=carbonik_4D504345.jpg 534e4553=carbonik_534e4553.jpg 57493634=carbonik_57493634.jpg 56424158=carbonik_56424158.jpg 5343564D=carbonik_5343564D.jpg --- source/gui/coverflow.cpp | 44 +++++++++++++++++++++++++------------ source/gui/coverflow.hpp | 9 ++++---- source/menu/menu.cpp | 36 +++++++++++++++++++++++++----- source/menu/menu_source.cpp | 2 +- 4 files changed, 66 insertions(+), 25 deletions(-) diff --git a/source/gui/coverflow.cpp b/source/gui/coverflow.cpp index 2020a057..ea73403e 100644 --- a/source/gui/coverflow.cpp +++ b/source/gui/coverflow.cpp @@ -73,10 +73,11 @@ CCoverFlow::CCover::CCover(void) targetScale = Vector3D(1.f, 1.f, 1.f); } -CCoverFlow::CItem::CItem(dir_discHdr *itemHdr, const char *itemPic, const char *itemBoxPic, int playcount, unsigned int lastPlayed) : +CCoverFlow::CItem::CItem(dir_discHdr *itemHdr, const char *itemPic, const char *itemBoxPic, const char *itemBlankBoxPic, int playcount, unsigned int lastPlayed) : hdr(itemHdr), picPath(itemPic), boxPicPath(itemBoxPic), + blankBoxPicPath(itemBlankBoxPic), playcount(playcount), lastPlayed(lastPlayed) { @@ -686,10 +687,10 @@ void CCoverFlow::reserve(u32 capacity) m_items.reserve(capacity); } -void CCoverFlow::addItem(dir_discHdr *hdr, const char *picPath, const char *boxPicPath, int playcount, unsigned int lastPlayed) +void CCoverFlow::addItem(dir_discHdr *hdr, const char *picPath, const char *boxPicPath, const char *blankBoxPicPath, int playcount, unsigned int lastPlayed) { if (!m_covers.empty()) return; - m_items.push_back(CCoverFlow::CItem(hdr, picPath, boxPicPath, playcount, lastPlayed)); + m_items.push_back(CCoverFlow::CItem(hdr, picPath, boxPicPath, blankBoxPicPath, playcount, lastPlayed)); } // Draws a plane in the Z-Buffer only. @@ -2571,14 +2572,14 @@ bool CCoverFlow::fullCoverCached(const char *id) return found; } -bool CCoverFlow::_loadCoverTexPNG(u32 i, bool box, bool hq) +bool CCoverFlow::_loadCoverTexPNG(u32 i, bool box, bool hq, bool blankBoxCover) { if (!m_loadingCovers) return false; u8 textureFmt = m_compressTextures ? GX_TF_CMPR : GX_TF_RGB565; STexture tex; - - const char *path = box ? m_items[i].boxPicPath.c_str() : m_items[i].picPath.c_str(); + + const char *path = box ? (blankBoxCover ? m_items[i].blankBoxPicPath.c_str() : m_items[i].boxPicPath.c_str()) : m_items[i].picPath.c_str(); if (STexture::TE_OK != tex.fromImageFile(path, textureFmt, ALLOC_MEM2, 32)) return false; if (!m_loadingCovers) return false; @@ -2598,7 +2599,13 @@ 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(NoGameID(m_items[i].hdr->type)) + if(blankBoxCover) + { + string tempName = m_items[i].blankBoxPicPath.c_str(); + tempName.assign(&tempName[tempName.find_last_of('/') + 1]); + strncpy(gamePath, tempName.c_str(), sizeof(gamePath)); + } + else if(NoGameID(m_items[i].hdr->type)) { 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("/")+1], sizeof(gamePath)); @@ -2664,7 +2671,7 @@ void CCoverFlow::_dropHQLOD(int i) prevTex = newTex; } -CCoverFlow::CLRet CCoverFlow::_loadCoverTex(u32 i, bool box, bool hq) +CCoverFlow::CLRet CCoverFlow::_loadCoverTex(u32 i, bool box, bool hq, bool blankBoxCover) { if (!m_loadingCovers) return CL_ERROR; @@ -2675,7 +2682,13 @@ CCoverFlow::CLRet CCoverFlow::_loadCoverTex(u32 i, bool box, bool hq) if(!m_cachePath.empty()) { char gamePath[256]; - if(NoGameID(m_items[i].hdr->type)) + if(blankBoxCover) + { + string tempName = m_items[i].blankBoxPicPath.c_str(); + tempName.assign(&tempName[tempName.find_last_of('/') + 1]); + strncpy(gamePath, tempName.c_str(), sizeof(gamePath)); + } + else if(NoGameID(m_items[i].hdr->type)) { 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("/")+1], sizeof(gamePath)); @@ -2696,7 +2709,7 @@ CCoverFlow::CLRet CCoverFlow::_loadCoverTex(u32 i, bool box, bool hq) 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, blankBoxCover)))) { STexture tex; tex.format = header.cmpr != 0 ? GX_TF_CMPR : GX_TF_RGB565; @@ -2750,7 +2763,7 @@ CCoverFlow::CLRet CCoverFlow::_loadCoverTex(u32 i, bool box, bool hq) return CCoverFlow::CL_NOMEM; // If not found, load the PNG - return _loadCoverTexPNG(i, box, hq) ? CCoverFlow::CL_OK : CCoverFlow::CL_ERROR; + return _loadCoverTexPNG(i, box, hq, blankBoxCover) ? CCoverFlow::CL_OK : CCoverFlow::CL_ERROR; } int CCoverFlow::_coverLoader(CCoverFlow *cf) @@ -2786,10 +2799,13 @@ int CCoverFlow::_coverLoader(CCoverFlow *cf) continue; else if(cf->m_useHQcover && firstItem == (u32)cf->m_hqCover && cf->m_items[i].state != CCoverFlow::STATE_Loading) continue; - if((ret = cf->_loadCoverTex(i, cf->m_box, i == (u32)firstItem)) == CCoverFlow::CL_ERROR) + if((ret = cf->_loadCoverTex(i, cf->m_box, i == (u32)firstItem, false)) == CCoverFlow::CL_ERROR) { - if ((ret = cf->_loadCoverTex(i, !cf->m_box, i == (u32)firstItem)) == CCoverFlow::CL_ERROR) - cf->m_items[i].state = CCoverFlow::STATE_NoCover; + if ((ret = cf->_loadCoverTex(i, !cf->m_box, i == (u32)firstItem, false)) == CCoverFlow::CL_ERROR) + { + if((ret = cf->_loadCoverTex(i, cf->m_box, i == (u32)firstItem, true)) == CCoverFlow::CL_ERROR) + cf->m_items[i].state = CCoverFlow::STATE_NoCover; + } } } if(ret == CCoverFlow::CL_NOMEM && bufferSize > 3) diff --git a/source/gui/coverflow.hpp b/source/gui/coverflow.hpp index 8dbadc2e..473e062e 100644 --- a/source/gui/coverflow.hpp +++ b/source/gui/coverflow.hpp @@ -45,7 +45,7 @@ public: void clear(void); void shutdown(void); void reserve(u32 capacity); - void addItem(dir_discHdr *hdr, const char *picPath, const char *boxPicPath, int playcount = 0, unsigned int lastPlayed = 0); + void addItem(dir_discHdr *hdr, const char *picPath, const char *boxPicPath, const char *blankBoxPicPath, int playcount = 0, unsigned int lastPlayed = 0); bool empty(void) const { return m_items.empty(); } // bool start(const char *id = 0); @@ -190,13 +190,14 @@ private: dir_discHdr *hdr; string picPath; string boxPicPath; + string blankBoxPicPath; int playcount; unsigned int lastPlayed; STexture texture; volatile bool boxTexture; volatile enum TexState state; // - CItem(dir_discHdr *itemHdr, const char *itemPic, const char *itemBoxPic, int playcount, unsigned int lastPlayed); + CItem(dir_discHdr *itemHdr, const char *itemPic, const char *itemBoxPic, const char *itemBlankBoxPic, int playcount, unsigned int lastPlayed); }; struct CCover { @@ -324,8 +325,8 @@ private: void _loadAllCovers(int i); static bool _calcTexLQLOD(STexture &tex); void _dropHQLOD(int i); - bool _loadCoverTexPNG(u32 i, bool box, bool hq); - CLRet _loadCoverTex(u32 i, bool box, bool hq); + bool _loadCoverTexPNG(u32 i, bool box, bool hq, bool blankBoxCover); + CLRet _loadCoverTex(u32 i, bool box, bool hq, bool blankBoxCover); bool _invisibleCover(u32 x, u32 y); void _instantTarget(int i); void _transposeCover(vector &dst, u32 rows, u32 columns, int pos); diff --git a/source/menu/menu.cpp b/source/menu/menu.cpp index 597afe84..70d0e25c 100644 --- a/source/menu/menu.cpp +++ b/source/menu/menu.cpp @@ -1775,6 +1775,30 @@ void CMenu::_initCF(void) if(dumpGameLst) dump.setWString(domain, id, m_gameList[i].title); + + string blankCoverKey; + switch(m_gameList[i].type) + { + case TYPE_CHANNEL: + blankCoverKey = "channels"; + break; + case TYPE_HOMEBREW: + blankCoverKey = "homebrew"; + break; + case TYPE_GC_GAME: + blankCoverKey = "gamecube"; + break; + case TYPE_PLUGIN: + char PluginMagicWord[9]; + memset(PluginMagicWord, 0, sizeof(PluginMagicWord)); + strncpy(PluginMagicWord, fmt("%08x", m_gameList[i].settings[0]), 8); + blankCoverKey = PluginMagicWord; + break; + default: + blankCoverKey = "wii"; + } + + string blankCoverName = m_theme.getString("BLANK_COVERS", blankCoverKey.c_str(), fmt("%s.jpg", blankCoverKey.c_str())); if(m_gameList[i].type == TYPE_PLUGIN) { @@ -1785,9 +1809,9 @@ void CMenu::_initCF(void) if(EnabledPlugins.size() == 0) //all plugins { if(coverFolder.size() > 0) - m_cf.addItem(&m_gameList[i], fmt("%s/%s/%s.png", m_picDir.c_str(), coverFolder.c_str(), tempname.c_str()), fmt("%s/%s/%s.png", m_boxPicDir.c_str(), coverFolder.c_str(), tempname.c_str()), playcount, lastPlayed); + m_cf.addItem(&m_gameList[i], fmt("%s/%s/%s.png", m_picDir.c_str(), coverFolder.c_str(), tempname.c_str()), fmt("%s/%s/%s.png", m_boxPicDir.c_str(), coverFolder.c_str(), tempname.c_str()), fmt("%s/%s", m_boxPicDir.c_str(), blankCoverName.c_str()), playcount, lastPlayed); else - m_cf.addItem(&m_gameList[i], fmt("%s/%s.png", m_picDir.c_str(), tempname.c_str()), fmt("%s/%s.png", m_boxPicDir.c_str(), tempname.c_str()), playcount, lastPlayed); + m_cf.addItem(&m_gameList[i], fmt("%s/%s.png", m_picDir.c_str(), tempname.c_str()), fmt("%s/%s.png", m_boxPicDir.c_str(), tempname.c_str()), fmt("%s/%s", m_boxPicDir.c_str(), blankCoverName.c_str()), playcount, lastPlayed); } else { @@ -1796,18 +1820,18 @@ void CMenu::_initCF(void) if(EnabledPlugins.at(j) == true && m_gameList[i].settings[0] == m_plugin.getPluginMagic(j)) { if(coverFolder.size() > 0) - m_cf.addItem(&m_gameList[i], fmt("%s/%s/%s.png", m_picDir.c_str(), coverFolder.c_str(), tempname.c_str()), fmt("%s/%s/%s.png", m_boxPicDir.c_str(), coverFolder.c_str(), tempname.c_str()), playcount, lastPlayed); + m_cf.addItem(&m_gameList[i], fmt("%s/%s/%s.png", m_picDir.c_str(), coverFolder.c_str(), tempname.c_str()), fmt("%s/%s/%s.png", m_boxPicDir.c_str(), coverFolder.c_str(), tempname.c_str()), fmt("%s/%s", m_boxPicDir.c_str(), blankCoverName.c_str()), playcount, lastPlayed); else - m_cf.addItem(&m_gameList[i], fmt("%s/%s.png", m_picDir.c_str(), tempname.c_str()), fmt("%s/%s.png", m_boxPicDir.c_str(), tempname.c_str()), playcount, lastPlayed); + m_cf.addItem(&m_gameList[i], fmt("%s/%s.png", m_picDir.c_str(), tempname.c_str()), fmt("%s/%s.png", m_boxPicDir.c_str(), tempname.c_str()), fmt("%s/%s", m_boxPicDir.c_str(), blankCoverName.c_str()), playcount, lastPlayed); break; } } } } else if(m_gameList[i].type == TYPE_HOMEBREW) - 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); + 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()), fmt("%s/%s", m_boxPicDir.c_str(), blankCoverName.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); + 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()), fmt("%s/%s", m_boxPicDir.c_str(), blankCoverName.c_str()), playcount, lastPlayed); } } m_gcfg1.unload(); diff --git a/source/menu/menu_source.cpp b/source/menu/menu_source.cpp index 59862a25..9f86e5c2 100644 --- a/source/menu/menu_source.cpp +++ b/source/menu/menu_source.cpp @@ -20,7 +20,7 @@ extern const u8 favoritesons_png[]; int Source_curPage; int pages; u8 numPlugins; -u8 maxBtns = 47; +u8 maxBtns = 71; string m_sourceDir; Config m_source;