-fixed fanart usage

This commit is contained in:
fix94.1 2012-09-29 17:32:31 +00:00
parent 12d8f86ced
commit bdf2850b20
2 changed files with 82 additions and 69 deletions

View File

@ -24,6 +24,10 @@ void CFanart::unload()
m_cfg.unload();
m_loaded = false;
m_elms.clear();
if(m_bg.data.get() != NULL)
m_bg.data.release();
if(m_bglq.data.get() != NULL)
m_bglq.data.release();
}
bool CFanart::load(Config &m_globalConfig, const char *path, const char *id)
@ -35,29 +39,37 @@ bool CFanart::load(Config &m_globalConfig, const char *path, const char *id)
unload();
const char *dir = fmt("%s/%s", path, id);
char dir[64];
memset(dir,0, 64);
strncpy(dir, fmt("%s/%s", path, id), 63);
STexture fanBg, fanBgLq;
STexture::TexErr texErr = fanBg.fromImageFile(fmt("%s/background.png", dir));
if(texErr == STexture::TE_ERROR)
{
dir = fmt("%s/%.3s", path, id);
memset(dir,0, 64);
strncpy(dir, fmt("%s/%.3s", path, id), 63);
texErr = fanBg.fromImageFile(fmt("%s/background.png", dir));
}
if (texErr == STexture::TE_OK)
{
m_cfg.load(fmt("%s/%s.ini", dir, id));
if (!m_cfg.loaded()) m_cfg.load(fmt("%s/%.3s.ini", dir, id));
char cfg_char[64];
memset(cfg_char,0, 64);
strncpy(cfg_char, fmt("%s/%s.ini", dir, id), 63);
m_cfg.load(cfg_char);
if(!m_cfg.loaded())
{
memset(cfg_char,0, 64);
strncpy(cfg_char, fmt("%s/%.3s.ini", dir, id), 63);
m_cfg.load(cfg_char);
}
fanBgLq.fromImageFile(fmt("%s/background_lq.png", dir));
for(int i = 1; i <= 6; i++)
{
CFanartElement elm(m_cfg, dir, i);
if (elm.IsValid()) m_elms.push_back(elm);
}
m_loaded = true;
retval = true;
m_defaultDelay = m_globalConfig.getInt("FANART", "delay_after_animation", 200);
@ -89,7 +101,7 @@ CColor CFanart::getTextColor(CColor themeTxtColor)
bool CFanart::hideCover()
{
if (!isLoaded())
if(!m_loaded)
return false; // If no fanart is loaded, return false
/*
@ -148,6 +160,7 @@ void CFanart::tick()
void CFanart::draw(bool front)
{
if(!m_loaded) return; //derp
if(!m_allowArtworkOnTop && front)
return; // It's not allowed to draw fanart on top, it has already been drawn
@ -209,6 +222,8 @@ CFanartElement::CFanartElement(Config &cfg, const char *dir, int artwork)
CFanartElement::~CFanartElement(void)
{
if(m_art.data.get() != NULL)
m_art.data.release();
}
bool CFanartElement::IsValid()
@ -248,10 +263,8 @@ void CFanartElement::tick()
m_event_angle = (int) (m_event_angle + m_step_angle);
if(m_event_duration > 0)
{
m_event_duration--;
}
}
void CFanartElement::draw()
{

View File

@ -1883,9 +1883,9 @@ void CMenu::_mainLoopCommon(bool withCF, bool adjusting)
m_cf.drawText(adjusting);
}
}
if(m_fa.isLoaded())
m_fa.draw();
if(m_banner->GetSelectedGame() && (!m_banner->GetInGameSettings() || (m_banner->GetInGameSettings() && m_bnr_settings)))
else if(m_banner->GetSelectedGame() && (!m_banner->GetInGameSettings() || (m_banner->GetInGameSettings() && m_bnr_settings)))
m_banner->Draw();
m_btnMgr.draw();