-fixed a small bug if a plugin music file is over that the game

banner sounds stopped working
-added plugin subfolder cache file creation to prevent overwriting
on same filenames based on the coverFolder option in plugin inis,
"subfolder_cache" in "EMULATOR" domain, enabled by default (thx
matt0620 for base patches)
This commit is contained in:
fix94.1 2013-04-21 11:59:58 +00:00
parent dad4a16cc1
commit 761ca4bddb
4 changed files with 30 additions and 7 deletions

View File

@ -16,7 +16,9 @@
#include "types.h" #include "types.h"
#include "gecko/gecko.hpp" #include "gecko/gecko.hpp"
#include "menu/menu.hpp" #include "menu/menu.hpp"
#include "plugin/plugin.hpp"
#include "memory/mem2.hpp" #include "memory/mem2.hpp"
#include "fileOps/fileOps.h"
#include "wstringEx/wstringEx.hpp" #include "wstringEx/wstringEx.hpp"
extern const u8 dvdskin_jpg[]; extern const u8 dvdskin_jpg[];
@ -219,6 +221,7 @@ CCoverFlow::CCoverFlow(void)
m_compressTextures = true; m_compressTextures = true;
m_compressCache = false; m_compressCache = false;
m_deletePicsAfterCaching = false; m_deletePicsAfterCaching = false;
m_pluginCacheFolders = false;
m_box = true; m_box = true;
m_useHQcover = false; m_useHQcover = false;
m_rows = 1; m_rows = 1;
@ -280,11 +283,12 @@ CCoverFlow::~CCoverFlow(void)
LWP_MutexDestroy(m_mutex); LWP_MutexDestroy(m_mutex);
} }
void CCoverFlow::setCachePath(const char *path, bool deleteSource, bool compress) void CCoverFlow::setCachePath(const char *path, bool deleteSource, bool compress, bool pluginCacheFolders)
{ {
m_cachePath = path; m_cachePath = path;
m_deletePicsAfterCaching = deleteSource; m_deletePicsAfterCaching = deleteSource;
m_compressCache = compress; m_compressCache = compress;
m_pluginCacheFolders = pluginCacheFolders;
} }
void CCoverFlow::setTextureQuality(float lodBias, int aniso, bool edgeLOD) void CCoverFlow::setTextureQuality(float lodBias, int aniso, bool edgeLOD)
@ -2642,6 +2646,7 @@ bool CCoverFlow::_loadCoverTexPNG(u32 i, bool box, bool hq, bool blankBoxCover)
if(!!zBuffer && (!m_compressCache || compress(zBuffer, &zBufferSize, tex.data, bufSize) == Z_OK)) if(!!zBuffer && (!m_compressCache || compress(zBuffer, &zBufferSize, tex.data, bufSize) == Z_OK))
{ {
const char *gamePath = NULL; const char *gamePath = NULL;
const char *coverDir = NULL;
if(blankBoxCover) if(blankBoxCover)
{ {
const char *menuPath = mainMenu.getBlankCoverPath(m_items[i].hdr); const char *menuPath = mainMenu.getBlankCoverPath(m_items[i].hdr);
@ -2650,6 +2655,8 @@ bool CCoverFlow::_loadCoverTexPNG(u32 i, bool box, bool hq, bool blankBoxCover)
} }
else if(NoGameID(m_items[i].hdr->type)) else if(NoGameID(m_items[i].hdr->type))
{ {
if(m_pluginCacheFolders && m_items[i].hdr->type == TYPE_PLUGIN)
coverDir = m_plugin.GetCoverFolderName(m_items[i].hdr->settings[0]);
if(strrchr(m_items[i].hdr->path, '/') != NULL) if(strrchr(m_items[i].hdr->path, '/') != NULL)
gamePath = strrchr(m_items[i].hdr->path, '/') + 1; gamePath = strrchr(m_items[i].hdr->path, '/') + 1;
else else
@ -2660,7 +2667,15 @@ bool CCoverFlow::_loadCoverTexPNG(u32 i, bool box, bool hq, bool blankBoxCover)
FILE *file = NULL; FILE *file = NULL;
if(gamePath != NULL) if(gamePath != NULL)
file = fopen(fmt("%s/%s.wfc", m_cachePath.c_str(), gamePath), "wb"); {
if(coverDir == NULL || strlen(coverDir) == 0)
file = fopen(fmt("%s/%s.wfc", m_cachePath.c_str(), gamePath), "wb");
else
{
fsop_MakeFolder(fmt("%s/%s", m_cachePath.c_str(), coverDir));
file = fopen(fmt("%s/%s/%s.wfc", m_cachePath.c_str(), coverDir, gamePath), "wb");
}
}
if(file != NULL) if(file != NULL)
{ {
SWFCHeader header(tex, box, m_compressCache); SWFCHeader header(tex, box, m_compressCache);
@ -2731,6 +2746,7 @@ CCoverFlow::CLRet CCoverFlow::_loadCoverTex(u32 i, bool box, bool hq, bool blank
if(!m_cachePath.empty()) if(!m_cachePath.empty())
{ {
const char *gamePath = NULL; const char *gamePath = NULL;
const char *coverDir = NULL;
if(blankBoxCover) if(blankBoxCover)
{ {
const char *menuPath = mainMenu.getBlankCoverPath(m_items[i].hdr); const char *menuPath = mainMenu.getBlankCoverPath(m_items[i].hdr);
@ -2739,6 +2755,8 @@ CCoverFlow::CLRet CCoverFlow::_loadCoverTex(u32 i, bool box, bool hq, bool blank
} }
else if(NoGameID(m_items[i].hdr->type)) else if(NoGameID(m_items[i].hdr->type))
{ {
if(m_pluginCacheFolders && m_items[i].hdr->type == TYPE_PLUGIN)
coverDir = m_plugin.GetCoverFolderName(m_items[i].hdr->settings[0]);
if(strrchr(m_items[i].hdr->path, '/') != NULL) if(strrchr(m_items[i].hdr->path, '/') != NULL)
gamePath = strrchr(m_items[i].hdr->path, '/') + 1; gamePath = strrchr(m_items[i].hdr->path, '/') + 1;
else else
@ -2750,8 +2768,10 @@ CCoverFlow::CLRet CCoverFlow::_loadCoverTex(u32 i, bool box, bool hq, bool blank
FILE *fp = NULL; FILE *fp = NULL;
if(gamePath != NULL) if(gamePath != NULL)
{ {
const char *path = fmt("%s/%s.wfc", m_cachePath.c_str(), gamePath); if(coverDir == NULL || strlen(coverDir) == 0)
fp = fopen(path, "rb"); fp = fopen(fmt("%s/%s.wfc", m_cachePath.c_str(), gamePath), "rb");
else
fp = fopen(fmt("%s/%s/%s.wfc", m_cachePath.c_str(), coverDir, gamePath), "rb");
} }
if(fp != NULL) if(fp != NULL)
{ {

View File

@ -123,7 +123,7 @@ public:
void stopSound(void); void stopSound(void);
// //
void applySettings(void); void applySettings(void);
void setCachePath(const char *path, bool deleteSource, bool compress); void setCachePath(const char *path, bool deleteSource, bool compress, bool pluginCacheFolders);
bool fullCoverCached(const char *id); bool fullCoverCached(const char *id);
bool preCacheCover(const char *id, const u8 *png, bool full); bool preCacheCover(const char *id, const u8 *png, bool full);
// //
@ -288,6 +288,7 @@ private:
bool m_compressCache; bool m_compressCache;
string m_cachePath; string m_cachePath;
bool m_deletePicsAfterCaching; bool m_deletePicsAfterCaching;
bool m_pluginCacheFolders;
bool m_mirrorBlur; bool m_mirrorBlur;
float m_mirrorAlpha; float m_mirrorAlpha;
float m_txtMirrorAlpha; float m_txtMirrorAlpha;

View File

@ -646,7 +646,8 @@ void CMenu::_loadCFCfg()
const char *domain = "_COVERFLOW"; const char *domain = "_COVERFLOW";
//gprintf("Preparing to load sounds from %s\n", m_themeDataDir.c_str()); //gprintf("Preparing to load sounds from %s\n", m_themeDataDir.c_str());
CoverFlow.setCachePath(m_cacheDir.c_str(), !m_cfg.getBool("GENERAL", "keep_png", true), m_cfg.getBool("GENERAL", "compress_cache", false)); CoverFlow.setCachePath(m_cacheDir.c_str(), !m_cfg.getBool("GENERAL", "keep_png", true),
m_cfg.getBool("GENERAL", "compress_cache", false), m_cfg.getBool(PLUGIN_DOMAIN, "subfolder_cache", true));
CoverFlow.setBufferSize(m_cfg.getInt("GENERAL", "cover_buffer", 20)); CoverFlow.setBufferSize(m_cfg.getInt("GENERAL", "cover_buffer", 20));
// Coverflow Sounds // Coverflow Sounds
CoverFlow.setSounds( CoverFlow.setSounds(

View File

@ -150,7 +150,8 @@ void Musicplayer::LoadFile(const char *name, bool display_change)
} }
else if(FileNames.size() == 1 && strcmp(name, PLUGIN_DOMAIN) == 0) else if(FileNames.size() == 1 && strcmp(name, PLUGIN_DOMAIN) == 0)
{ {
Cleanup(); MusicFile.FreeMemory();
MusicStopped = true;
return; return;
} }
MusicFile.Load(name); MusicFile.Load(name);