From 5a827e48fcc9be88d6bce8090188f6867fcf2e3c Mon Sep 17 00:00:00 2001 From: "fix94.1" Date: Fri, 16 Nov 2012 22:40:20 +0000 Subject: [PATCH] -fixed fanart backgrounds and codedumps --- source/gui/coverflow.cpp | 9 +++++---- source/gui/coverflow.hpp | 4 ++-- source/gui/fanart.cpp | 8 +++++--- source/gui/fanart.hpp | 2 +- source/gui/texture.cpp | 20 ++++++++++---------- source/gui/texture.hpp | 2 +- source/gui/video.cpp | 2 +- source/gui/video.hpp | 2 +- source/menu/menu.cpp | 15 ++++++++------- source/menu/menu.hpp | 4 ++-- source/menu/menu_game.cpp | 7 ++++--- 11 files changed, 40 insertions(+), 35 deletions(-) diff --git a/source/gui/coverflow.cpp b/source/gui/coverflow.cpp index 20d27776..23779269 100644 --- a/source/gui/coverflow.cpp +++ b/source/gui/coverflow.cpp @@ -725,11 +725,12 @@ void CCoverFlow::_drawMirrorZ(void) GX_SetColorUpdate(GX_TRUE); } -void CCoverFlow::_effectBg(const STexture &tex) +void CCoverFlow::_effectBg(const STexture * &tex) { Mtx modelViewMtx; GXTexObj texObj; - + if(tex == NULL || tex->data == NULL) + return; GX_ClearVtxDesc(); GX_SetNumTevStages(1); GX_SetNumChans(0); @@ -750,7 +751,7 @@ void CCoverFlow::_effectBg(const STexture &tex) GX_SetZMode(GX_DISABLE, GX_ALWAYS, GX_FALSE); guMtxIdentity(modelViewMtx); GX_LoadPosMtxImm(modelViewMtx, GX_PNMTX0); - GX_InitTexObj(&texObj, tex.data, tex.width, tex.height, tex.format, GX_CLAMP, GX_CLAMP, GX_FALSE); + GX_InitTexObj(&texObj, tex->data, tex->width, tex->height, tex->format, GX_CLAMP, GX_CLAMP, GX_FALSE); GX_LoadTexObj(&texObj, GX_TEXMAP0); GX_Begin(GX_QUADS, GX_VTXFMT0, 4); GX_Position3f32(0.f, 0.f, 0.f); @@ -907,7 +908,7 @@ bool CCoverFlow::_effectVisible(void) || lo.shadowColorEnd.a > 0 || lo.shadowColorOff.a > 0; } -void CCoverFlow::makeEffectTexture(const STexture &bg) +void CCoverFlow::makeEffectTexture(const STexture * &bg) { if (!_effectVisible()) return; int aa = 8; diff --git a/source/gui/coverflow.hpp b/source/gui/coverflow.hpp index 5ecc8e90..e10a4ef7 100644 --- a/source/gui/coverflow.hpp +++ b/source/gui/coverflow.hpp @@ -71,7 +71,7 @@ public: void flip(bool force = false, bool f = true); void cancel(void); bool selected(void) const { return m_selected; } - void makeEffectTexture(const STexture &bg); + void makeEffectTexture(const STexture * &bg); void drawText(bool withRectangle = false); void draw(void); void drawEffect(void); @@ -306,7 +306,7 @@ private: private: void _draw(DrawMode dm = CFDR_NORMAL, bool mirror = false, bool blend = true); u32 _currentPos(void) const; - void _effectBg(const STexture &tex); + void _effectBg(const STexture * &tex); void _effectBlur(bool vertical); bool _effectVisible(void); void _drawMirrorZ(void); diff --git a/source/gui/fanart.cpp b/source/gui/fanart.cpp index bac4cccd..b6208fa8 100644 --- a/source/gui/fanart.cpp +++ b/source/gui/fanart.cpp @@ -77,13 +77,15 @@ bool CFanart::load(Config &m_globalConfig, const char *path, const char *id) return retval; } -void CFanart::getBackground(STexture &hq, STexture &lq) +void CFanart::getBackground(const STexture * &hq, const STexture * &lq) { if(m_loaded) { - hq = m_bg; - lq = m_bglq; + hq = &m_bg; + lq = &m_bglq; } + if(lq == NULL || lq->data == NULL) + lq = hq; } CColor CFanart::getTextColor(CColor themeTxtColor) diff --git a/source/gui/fanart.hpp b/source/gui/fanart.hpp index e7f81efd..5f7e4423 100644 --- a/source/gui/fanart.hpp +++ b/source/gui/fanart.hpp @@ -66,7 +66,7 @@ public: bool isAnimationComplete(); bool isLoaded(); - void getBackground(STexture &hq, STexture &lq); + void getBackground(const STexture * &hq, const STexture * &lq); CColor getTextColor(CColor themeTxtColor = CColor(0xFFFFFFFF)); bool hideCover(); void draw(bool front = true); diff --git a/source/gui/texture.cpp b/source/gui/texture.cpp index 514d0fa7..d4adffd4 100644 --- a/source/gui/texture.cpp +++ b/source/gui/texture.cpp @@ -213,23 +213,23 @@ void STexture::Cleanup(void) maxLOD = 0; } -bool STexture::CopyTexture(const STexture *tex) +bool STexture::CopyTexture(const STexture &tex) { - if(tex == this || tex == NULL || tex->data == NULL || tex->dataSize == 0) + if(tex.data == NULL || tex.dataSize == 0 || tex.data == data) return false; - if(dataSize != tex->dataSize) + if(dataSize != tex.dataSize) Cleanup(); if(data == NULL) - data = (u8*)MEM2_alloc(tex->dataSize); + data = (u8*)MEM2_alloc(tex.dataSize); if(data == NULL) return false; - dataSize = tex->dataSize; - memcpy(data, tex->data, dataSize); + dataSize = tex.dataSize; + memcpy(data, tex.data, dataSize); DCFlushRange(data, dataSize); - width = tex->width; - height = tex->height; - format = tex->format; - maxLOD = tex->maxLOD; + width = tex.width; + height = tex.height; + format = tex.format; + maxLOD = tex.maxLOD; return true; } diff --git a/source/gui/texture.hpp b/source/gui/texture.hpp index 3a7fc291..3facc2da 100644 --- a/source/gui/texture.hpp +++ b/source/gui/texture.hpp @@ -16,7 +16,7 @@ class STexture public: STexture(void) : data(NULL), dataSize(0), width(0), height(0), format(-1), maxLOD(0), thread(false) { } void Cleanup(); - bool CopyTexture(const STexture *tex); + bool CopyTexture(const STexture &tex); u8 *data; u32 dataSize; u32 width; diff --git a/source/gui/video.cpp b/source/gui/video.cpp index 5117042f..8ea2cb22 100644 --- a/source/gui/video.cpp +++ b/source/gui/video.cpp @@ -654,7 +654,7 @@ s32 CVideo::TakeScreenshot(const char *path) return ret; } -void DrawTexture(const STexture *tex) +void DrawTexture(STexture * &tex) { if(tex == NULL) return; diff --git a/source/gui/video.hpp b/source/gui/video.hpp index dce790f0..74f3b47f 100644 --- a/source/gui/video.hpp +++ b/source/gui/video.hpp @@ -119,7 +119,7 @@ private: CVideo(const CVideo &); }; -void DrawTexture(const STexture *tex); +void DrawTexture(STexture * &tex); void DrawRectangle(f32 x, f32 y, f32 width, f32 height, GXColor color); extern CVideo m_vid; diff --git a/source/menu/menu.cpp b/source/menu/menu.cpp index 18c4b0d1..bf86acbe 100644 --- a/source/menu/menu.cpp +++ b/source/menu/menu.cpp @@ -145,6 +145,7 @@ CMenu::CMenu() m_Emulator_boot = false; m_music_info = true; m_nextBg = NULL; + m_lqBg = NULL; } void CMenu::init() @@ -529,7 +530,7 @@ void CMenu::_Theme_Cleanup(void) m_prevBg.Cleanup(); m_nextBg = NULL; m_curBg.Cleanup(); - m_lqBg.Cleanup(); + m_lqBg = NULL; /* Buttons */ theme.btnTexL.Cleanup(); theme.btnTexR.Cleanup(); @@ -2053,10 +2054,10 @@ void CMenu::_mainLoopCommon(bool withCF, bool adjusting) void CMenu::_setBg(const STexture &tex, const STexture &lqTex) { - m_lqBg = lqTex; + m_lqBg = &lqTex; if(m_nextBg == &tex) return; - m_prevBg.CopyTexture(&m_curBg); + m_prevBg.CopyTexture(m_curBg); m_curBg.Cleanup(); m_nextBg = &tex; m_bgCrossFade = 0xFF; @@ -2070,9 +2071,9 @@ void CMenu::_updateBg(void) if (m_bgCrossFade == 0) return; m_bgCrossFade = max(0, (int)m_bgCrossFade - 14); - if(m_bgCrossFade == 0) + if(m_bgCrossFade == 0 && m_nextBg != NULL) { - m_curBg.CopyTexture(m_nextBg); + m_curBg.CopyTexture(*m_nextBg); return; } GX_ClearVtxDesc(); @@ -2130,9 +2131,9 @@ void CMenu::_updateBg(void) m_curBg.format = GX_TF_RGBA8; m_curBg.maxLOD = 0; m_vid.renderToTexture(m_curBg, true); - if(m_curBg.data == NULL) + if(m_curBg.data == NULL && m_nextBg != NULL) { - m_curBg.CopyTexture(m_nextBg); + m_curBg.CopyTexture(*m_nextBg); m_bgCrossFade = 0; } } diff --git a/source/menu/menu.hpp b/source/menu/menu.hpp index f0e099ae..c5a36934 100644 --- a/source/menu/menu.hpp +++ b/source/menu/menu.hpp @@ -117,9 +117,9 @@ private: /* End Updates */ // STexture m_prevBg; - const STexture *m_nextBg; STexture m_curBg; - STexture m_lqBg; + const STexture *m_nextBg; + const STexture *m_lqBg; u8 m_bgCrossFade; // STexture m_errorBg; diff --git a/source/menu/menu_game.cpp b/source/menu/menu_game.cpp index 96c726df..e7d89bed 100644 --- a/source/menu/menu_game.cpp +++ b/source/menu/menu_game.cpp @@ -334,10 +334,11 @@ void CMenu::_showGame(void) if (m_fa.load(m_cfg, m_fanartDir.c_str(), CoverFlow.getId().c_str())) { - STexture bg, bglq; + const STexture *bg = NULL; + const STexture *bglq = NULL; m_fa.getBackground(bg, bglq); - _setBg(bg, bglq); - + if(bg != NULL && bglq != NULL) + _setBg(*bg, *bglq); if (m_fa.hideCover()) CoverFlow.hideCover(); }