mirror of
https://github.com/Fledge68/WiiFlow_Lite.git
synced 2024-12-24 02:41:55 +01:00
-added ability to cache covers. just select your source then go to home menu and click cache covers. it will go thru your current game list and convert the covers to wfc cache files. needed mainly for if you add a bunch of roms and cover pngs for a plugin. or if you for some reason need to remake the wfc files for all your wii or gc games. note using wiimpathy's wfc conv 0.1 on your pc is still a faster option.
This commit is contained in:
parent
db38a8b9ab
commit
6782d87f3a
BIN
out/boot.dol
BIN
out/boot.dol
Binary file not shown.
Before Width: | Height: | Size: 3.3 MiB After Width: | Height: | Size: 3.3 MiB |
@ -2570,6 +2570,40 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
bool CCoverFlow::cacheCover(const char *wfcPath, const char *coverPath, bool full)
|
||||
{
|
||||
if(m_cachePath.empty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
TexData tex;
|
||||
u8 textureFmt = m_compressTextures ? GX_TF_CMPR : GX_TF_RGB565;
|
||||
if(TexHandle.fromImageFile(tex, coverPath, textureFmt, 32) != TE_OK)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
u32 bufSize = fixGX_GetTexBufferSize(tex.width, tex.height, tex.format, tex.maxLOD > 0 ? GX_TRUE : GX_FALSE, tex.maxLOD);
|
||||
uLongf zBufferSize = m_compressCache ? bufSize + bufSize / 100 + 12 : bufSize;
|
||||
u8 *zBuffer = m_compressCache ? (u8*)MEM2_alloc(zBufferSize) : tex.data;
|
||||
if(zBuffer != NULL && (!m_compressCache || compress(zBuffer, &zBufferSize, tex.data, bufSize) == Z_OK))
|
||||
{
|
||||
FILE *file = fopen(wfcPath, "wb");
|
||||
if(file != NULL)
|
||||
{
|
||||
SWFCHeader header(tex, full, m_compressCache);
|
||||
fwrite(&header, 1, sizeof(header), file);
|
||||
fwrite(zBuffer, 1, zBufferSize, file);
|
||||
fclose(file);
|
||||
}
|
||||
}
|
||||
TexHandle.Cleanup(tex);
|
||||
if(zBuffer != NULL && m_compressCache)
|
||||
MEM2_free(zBuffer);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CCoverFlow::preCacheCover(const char *id, const u8 *png, bool full)
|
||||
{
|
||||
if(m_cachePath.empty())
|
||||
@ -2600,11 +2634,11 @@ bool CCoverFlow::preCacheCover(const char *id, const u8 *png, bool full)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CCoverFlow::fullCoverCached(const char *id)
|
||||
bool CCoverFlow::fullCoverCached(const char *wfcPath)
|
||||
{
|
||||
bool found = false;
|
||||
|
||||
FILE *file = fopen(fmt("%s/%s.wfc", m_cachePath.c_str(), id), "rb");
|
||||
FILE *file = fopen(wfcPath, "rb");
|
||||
if(file != NULL)
|
||||
{
|
||||
SWFCHeader header;
|
||||
|
@ -125,8 +125,9 @@ public:
|
||||
//
|
||||
void applySettings(void);
|
||||
void setCachePath(const char *path, bool deleteSource, bool compress, bool pluginCacheFolders);
|
||||
bool fullCoverCached(const char *id);
|
||||
bool fullCoverCached(const char *wfcPath);
|
||||
bool preCacheCover(const char *id, const u8 *png, bool full);
|
||||
bool cacheCover(const char *wfcPath, const char *coverPath, bool full);
|
||||
//
|
||||
const char *getId(void) const;
|
||||
const char *getNextId(void) const;
|
||||
|
@ -1063,6 +1063,7 @@ private:
|
||||
void _gameinfo(void);
|
||||
void _gameSettings(const dir_discHdr *GameHdr, bool disc = false);
|
||||
void _CoverBanner(void);
|
||||
int _cacheCovers(void);
|
||||
void _Explorer(void);
|
||||
const char *_FolderExplorer(const char *startPath);
|
||||
void _wadExplorer(void);
|
||||
|
@ -1385,7 +1385,7 @@ int CMenu::_coverDownloader(bool download_all)
|
||||
update_pThread(1);
|
||||
m_thrdMessage = wfmt(_fmt("dlmsg10", L"Making %s"), sfmt("%s.wfc", coverID.c_str()));
|
||||
m_thrdMessageAdded = true;
|
||||
CoverFlow.preCacheCover(coverID.c_str(), download.data, true);//it may fail
|
||||
CoverFlow.preCacheCover(coverID.c_str(), download.data, false);//it may fail
|
||||
|
||||
++countFlat;
|
||||
update_pThread(1);
|
||||
@ -1524,7 +1524,7 @@ int CMenu::_coverDownloader(bool download_all)
|
||||
update_pThread(1);
|
||||
m_thrdMessage = wfmt(_fmt("dlmsg10", L"Making %s"), sfmt("%s.wfc", coverID.c_str()));
|
||||
m_thrdMessageAdded = true;
|
||||
CoverFlow.preCacheCover(coverID.c_str(), download.data, true);//it may fail
|
||||
CoverFlow.preCacheCover(coverID.c_str(), download.data, false);//it may fail
|
||||
|
||||
++countFlat;
|
||||
update_pThread(1);
|
||||
|
@ -19,13 +19,13 @@
|
||||
#include "loader/nk.h"
|
||||
#include "const_str.hpp"
|
||||
|
||||
/* home menu */
|
||||
s16 m_homeLblTitle;
|
||||
s16 m_exittoLblTitle;
|
||||
s16 m_exittoLblUser[4];
|
||||
s16 m_homeLblUser[4];
|
||||
|
||||
s16 m_homeBtnSettings;
|
||||
s16 m_homeBtnReloadCache;
|
||||
//s16 m_homeBtnUpdate;
|
||||
s16 m_homeBtnUpdate;
|
||||
s16 m_homeBtnExplorer;
|
||||
|
||||
s16 m_homeBtnInstall;
|
||||
@ -33,15 +33,17 @@ s16 m_homeBtnAbout;
|
||||
s16 m_homeBtnExitTo;
|
||||
s16 m_homeBtnSelPlugin;
|
||||
|
||||
s16 m_homeLblBattery;
|
||||
|
||||
/* exit to menu */
|
||||
s16 m_exittoLblTitle;
|
||||
s16 m_exittoLblUser[4];
|
||||
s16 m_homeBtnExitToHBC;
|
||||
s16 m_homeBtnExitToMenu;
|
||||
s16 m_homeBtnExitToPriiloader;
|
||||
s16 m_homeBtnExitToBootmii;
|
||||
s16 m_homeBtnExitToNeek;
|
||||
|
||||
s16 m_homeLblBattery;
|
||||
s16 m_homeLblUser[4];
|
||||
|
||||
TexData m_homeBg;
|
||||
|
||||
bool CMenu::_Home(void)
|
||||
@ -89,20 +91,32 @@ bool CMenu::_Home(void)
|
||||
m_refreshGameList = true;
|
||||
break;
|
||||
}
|
||||
/*else if(m_btnMgr.selected(m_homeBtnUpdate) && !m_locked)
|
||||
else if(m_btnMgr.selected(m_homeBtnUpdate))
|
||||
{
|
||||
CoverFlow.stopCoverLoader(true);
|
||||
_hideHome();
|
||||
_system();
|
||||
remove(m_ver.c_str());
|
||||
if(m_exit)
|
||||
_launchHomebrew(m_dol.c_str(), m_homebrewArgs);
|
||||
else
|
||||
m_btnMgr.setProgress(m_wbfsPBar, 0.f, true);
|
||||
m_btnMgr.setText(m_wbfsLblMessage, L"0%");
|
||||
m_btnMgr.setText(m_wbfsLblDialog, L"");
|
||||
m_btnMgr.show(m_wbfsPBar);
|
||||
m_btnMgr.show(m_wbfsLblMessage);
|
||||
m_btnMgr.show(m_wbfsLblDialog);
|
||||
|
||||
_start_pThread();
|
||||
_cacheCovers();
|
||||
_stop_pThread();
|
||||
m_btnMgr.setText(m_wbfsLblDialog, _t("dlmsg14", L"Done."));
|
||||
while(!m_exit)
|
||||
{
|
||||
_showHome();
|
||||
CoverFlow.startCoverLoader();
|
||||
_mainLoopCommon();
|
||||
if(BTN_HOME_PRESSED || BTN_B_PRESSED)
|
||||
{
|
||||
m_btnMgr.hide(m_wbfsPBar);
|
||||
m_btnMgr.hide(m_wbfsLblMessage);
|
||||
m_btnMgr.hide(m_wbfsLblDialog);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
_showHome();
|
||||
}
|
||||
else if(m_btnMgr.selected(m_homeBtnInstall))
|
||||
{
|
||||
_hideHome();
|
||||
@ -226,7 +240,7 @@ void CMenu::_showHome(void)
|
||||
|
||||
m_btnMgr.show(m_homeBtnSettings);
|
||||
m_btnMgr.show(m_homeBtnReloadCache);
|
||||
//m_btnMgr.show(m_homeBtnUpdate);
|
||||
m_btnMgr.show(m_homeBtnUpdate);
|
||||
m_btnMgr.show(m_homeBtnExplorer);
|
||||
|
||||
m_btnMgr.show(m_homeBtnInstall);
|
||||
@ -264,7 +278,7 @@ void CMenu::_hideHome(bool instant)
|
||||
|
||||
m_btnMgr.hide(m_homeBtnSettings, instant);
|
||||
m_btnMgr.hide(m_homeBtnReloadCache, instant);
|
||||
//m_btnMgr.hide(m_homeBtnUpdate, instant);
|
||||
m_btnMgr.hide(m_homeBtnUpdate, instant);
|
||||
m_btnMgr.hide(m_homeBtnExplorer, instant);
|
||||
|
||||
m_btnMgr.hide(m_homeBtnInstall, instant);
|
||||
@ -296,13 +310,11 @@ void CMenu::_hideExitTo(bool instant)
|
||||
|
||||
void CMenu::_initHomeAndExitToMenu()
|
||||
{
|
||||
_addUserLabels(m_homeLblUser, ARRAY_SIZE(m_homeLblUser), "HOME");
|
||||
|
||||
//Home Menu
|
||||
m_homeBg = _texture("HOME/BG", "texture", theme.bg, false);
|
||||
|
||||
|
||||
//Home Menu
|
||||
_addUserLabels(m_homeLblUser, ARRAY_SIZE(m_homeLblUser), "HOME");
|
||||
m_homeLblTitle = _addTitle("HOME/TITLE", theme.titleFont, L"", 0, 10, 640, 60, theme.titleFontColor, FTGX_JUSTIFY_CENTER | FTGX_ALIGN_MIDDLE);
|
||||
_setHideAnim(m_homeLblTitle, "HOME/TITLE", 0, 0, -2.f, 0.f);
|
||||
|
||||
m_homeBtnSettings = _addButton("HOME/SETTINGS", theme.btnFont, L"", 60, 100, 250, 48, theme.btnFontColor);
|
||||
m_homeBtnReloadCache = _addButton("HOME/RELOAD_CACHE", theme.btnFont, L"", 60, 180, 250, 48, theme.btnFontColor);
|
||||
@ -312,10 +324,12 @@ void CMenu::_initHomeAndExitToMenu()
|
||||
m_homeBtnAbout = _addButton("HOME/ABOUT", theme.btnFont, L"", 330, 100, 250, 48, theme.btnFontColor);
|
||||
m_homeBtnInstall = _addButton("HOME/INSTALL", theme.btnFont, L"", 330, 180, 250, 48, theme.btnFontColor);
|
||||
m_homeBtnExitTo = _addButton("HOME/EXIT_TO", theme.btnFont, L"", 330, 260, 250, 48, theme.btnFontColor);
|
||||
//m_homeBtnUpdate = _addButton("HOME/UPDATE", theme.btnFont, L"", 330, 340, 250, 48, theme.btnFontColor);
|
||||
m_homeBtnUpdate = _addButton("HOME/UPDATE", theme.btnFont, L"", 330, 340, 250, 48, theme.btnFontColor);
|
||||
|
||||
m_homeLblBattery = _addLabel("HOME/BATTERY", theme.btnFont, L"", 0, 420, 640, 48, theme.btnFontColor, FTGX_JUSTIFY_CENTER | FTGX_ALIGN_MIDDLE, theme.btnTexC);
|
||||
|
||||
_setHideAnim(m_homeLblTitle, "HOME/TITLE", 0, 0, -2.f, 0.f);
|
||||
|
||||
_setHideAnim(m_homeBtnSettings, "HOME/SETTINGS", 50, 0, 1.f, 0.f);
|
||||
_setHideAnim(m_homeBtnReloadCache, "HOME/RELOAD_CACHE", 50, 0, 1.f, 0.f);
|
||||
_setHideAnim(m_homeBtnSelPlugin, "HOME/FTP", 50, 0, 1.f, 0.f);
|
||||
@ -324,7 +338,7 @@ void CMenu::_initHomeAndExitToMenu()
|
||||
_setHideAnim(m_homeBtnInstall, "HOME/INSTALL", -50, 0, 1.f, 0.f);
|
||||
_setHideAnim(m_homeBtnAbout, "HOME/ABOUT", -50, 0, 1.f, 0.f);
|
||||
_setHideAnim(m_homeBtnExitTo, "HOME/EXIT_TO", -50, 0, 1.f, 0.f);
|
||||
//_setHideAnim(m_homeBtnUpdate, "HOME/UPDATE", -50, 0, 1.f, 0.f);
|
||||
_setHideAnim(m_homeBtnUpdate, "HOME/UPDATE", -50, 0, 1.f, 0.f);
|
||||
|
||||
_setHideAnim(m_homeLblBattery, "HOME/BATTERY", 0, 0, -2.f, 0.f);
|
||||
|
||||
@ -335,14 +349,14 @@ void CMenu::_initHomeAndExitToMenu()
|
||||
_addUserLabels(m_exittoLblUser, ARRAY_SIZE(m_exittoLblUser), "EXIT_TO");
|
||||
m_exittoLblTitle = _addTitle("EXIT_TO/TITLE", theme.titleFont, L"", 0, 10, 640, 60, theme.titleFontColor, FTGX_JUSTIFY_CENTER | FTGX_ALIGN_MIDDLE);
|
||||
|
||||
_setHideAnim(m_exittoLblTitle, "EXIT_TO/TITLE", 0, 0, -2.f, 0.f);
|
||||
|
||||
m_homeBtnExitToHBC = _addButton("EXIT_TO/HBC", theme.btnFont, L"", 185, 120, 270, 48, theme.btnFontColor);
|
||||
m_homeBtnExitToMenu = _addButton("EXIT_TO/MENU", theme.btnFont, L"", 185, 180, 270, 48, theme.btnFontColor);
|
||||
m_homeBtnExitToNeek = _addButton("EXIT_TO/NEEK", theme.btnFont, L"", 185, 240, 270, 48, theme.btnFontColor);
|
||||
m_homeBtnExitToPriiloader = _addButton("EXIT_TO/PRIILOADER", theme.btnFont, L"", 185, 300, 270, 48, theme.btnFontColor);
|
||||
m_homeBtnExitToBootmii = _addButton("EXIT_TO/BOOTMII", theme.btnFont, L"", 185, 360, 270, 48, theme.btnFontColor);
|
||||
|
||||
_setHideAnim(m_exittoLblTitle, "EXIT_TO/TITLE", 0, 0, -2.f, 0.f);
|
||||
|
||||
_setHideAnim(m_homeBtnExitToHBC, "EXIT_TO/HBC", 0, 0, -4.f, 0.f);
|
||||
_setHideAnim(m_homeBtnExitToMenu, "EXIT_TO/MENU", 0, 0, -4.f, 0.f);
|
||||
_setHideAnim(m_homeBtnExitToPriiloader, "EXIT_TO/PRIILOADER", 0, 0, -4.f, 0.f);
|
||||
@ -358,7 +372,7 @@ void CMenu::_textHome(void)
|
||||
m_btnMgr.setText(m_homeLblTitle, VERSION_STRING);
|
||||
m_btnMgr.setText(m_homeBtnSettings, _t("about10", L"Help Guide"));
|
||||
m_btnMgr.setText(m_homeBtnReloadCache, _t("home2", L"Reload Cache"));
|
||||
//m_btnMgr.setText(m_homeBtnUpdate, _t("home3", L"Update"));
|
||||
m_btnMgr.setText(m_homeBtnUpdate, _t("home11", L"Cache Covers"));
|
||||
m_btnMgr.setText(m_homeBtnExplorer, _t("home8", L"File Explorer"));
|
||||
|
||||
m_btnMgr.setText(m_homeBtnInstall, _t("home7", L"Install Game"));
|
||||
@ -382,3 +396,68 @@ void CMenu::_textExitTo(void)
|
||||
else
|
||||
m_btnMgr.setText(m_homeBtnExitToNeek, _t("real", L"Real Nand"));
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
|
||||
int CMenu::_cacheCovers()
|
||||
{
|
||||
CoverFlow.stopCoverLoader(true);
|
||||
bool m_pluginCacheFolders = m_cfg.getBool(PLUGIN_DOMAIN, "subfolder_cache", true);
|
||||
|
||||
char coverPath[MAX_FAT_PATH];
|
||||
char wfcPath[MAX_FAT_PATH+5];
|
||||
char cachePath[MAX_FAT_PATH];
|
||||
|
||||
u32 total = m_gameList.size();
|
||||
m_thrdTotal = total;
|
||||
u32 index = 0;
|
||||
|
||||
for(vector<dir_discHdr>::iterator hdr = m_gameList.begin(); hdr != m_gameList.end(); ++hdr)
|
||||
{
|
||||
index++;
|
||||
update_pThread(1);
|
||||
m_thrdMessage = wfmt(_fmt("dlmsg31", L"converting cover %i of %i"), index, total);
|
||||
m_thrdMessageAdded = true;
|
||||
|
||||
bool fullCover = true;
|
||||
memset(&coverPath, 0, sizeof(coverPath));
|
||||
memset(&wfcPath, 0, sizeof(wfcPath));
|
||||
memset(&cachePath, 0, sizeof(cachePath));
|
||||
|
||||
/* get game name or ID */
|
||||
const char *gameNameOrID = CoverFlow.getFilenameId(&(*hdr));
|
||||
|
||||
/* get cover png path */
|
||||
strncpy(coverPath, getBoxPath(&(*hdr)), sizeof(coverPath));
|
||||
if(!fsop_FileExist(coverPath))
|
||||
{
|
||||
fullCover = false;
|
||||
strncpy(coverPath, getFrontPath(&(*hdr)), sizeof(coverPath));
|
||||
if(!fsop_FileExist(coverPath))
|
||||
continue;
|
||||
}
|
||||
|
||||
/* get cover wfc path */
|
||||
if(hdr->type == TYPE_PLUGIN && m_pluginCacheFolders)
|
||||
{
|
||||
snprintf(cachePath, sizeof(cachePath), "%s/%s", m_cacheDir.c_str(), m_plugin.GetCoverFolderName(hdr->settings[0]));
|
||||
}
|
||||
else
|
||||
snprintf(cachePath, sizeof(cachePath), "%s", m_cacheDir.c_str());
|
||||
|
||||
snprintf(wfcPath, sizeof(wfcPath), "%s/%s.wfc", cachePath, gameNameOrID);
|
||||
|
||||
/* if wfc doesn't exist or is flat and have full cover */
|
||||
if(!fsop_FileExist(wfcPath) || (!CoverFlow.fullCoverCached(wfcPath) && fullCover))
|
||||
{
|
||||
/* create cache subfolders if needed */
|
||||
if(!fsop_FolderExist(cachePath))
|
||||
fsop_MakeFolder(cachePath);
|
||||
|
||||
/* create cover texture */
|
||||
CoverFlow.cacheCover(wfcPath, coverPath, fullCover);
|
||||
}
|
||||
}
|
||||
CoverFlow.startCoverLoader();
|
||||
return 0;
|
||||
}
|
@ -256,6 +256,7 @@ dlmsg28=Running FTP Server on %s:%u
|
||||
dlmsg29=FTP Server is currently stopped.
|
||||
dlmsg3=Downloading %i/%i from %s
|
||||
dlmsg30=No covers missing.
|
||||
dlmsg31=converting cover %i of %i
|
||||
dlmsg4=Saving %s
|
||||
dlmsg5=%i/%i files downloaded
|
||||
dlmsg6=Canceling...
|
||||
@ -323,6 +324,7 @@ home7=Install Game
|
||||
home8=File Explorer
|
||||
home9=Source Menu
|
||||
home10=FTP Server
|
||||
home11=Cache Covers
|
||||
hooktype1=VBI
|
||||
hooktype2=KPAD Read
|
||||
hooktype3=Joypad
|
||||
|
Loading…
Reference in New Issue
Block a user