From ba8415f9493d3cf226dee5db1586154b1925a551 Mon Sep 17 00:00:00 2001 From: "fix94.1" Date: Thu, 29 Nov 2012 20:30:05 +0000 Subject: [PATCH] -changed a few more things about the changing background, now it should be safe --- source/menu/menu.cpp | 41 +++++++++++++++++++-------------------- source/menu/menu.hpp | 2 +- source/menu/menu_home.cpp | 2 +- 3 files changed, 22 insertions(+), 23 deletions(-) diff --git a/source/menu/menu.cpp b/source/menu/menu.cpp index 2d568c3a..cfbb008d 100644 --- a/source/menu/menu.cpp +++ b/source/menu/menu.cpp @@ -143,6 +143,7 @@ CMenu::CMenu() m_current_view = COVERFLOW_USB; m_Emulator_boot = false; m_music_info = true; + m_prevBg = NULL; m_nextBg = NULL; m_lqBg = NULL; } @@ -533,7 +534,7 @@ void CMenu::_Theme_Cleanup(void) { /* Backgrounds */ theme.bg.Cleanup(); - m_prevBg.Cleanup(); + m_prevBg = NULL; m_nextBg = NULL; m_curBg.Cleanup(); m_lqBg = NULL; @@ -1950,7 +1951,7 @@ void CMenu::_mainLoopCommon(bool withCF, bool adjusting) _updateBg(); if(CoverFlow.getRenderTex()) CoverFlow.RenderTex(); - if(withCF) + if(withCF && m_lqBg != NULL) CoverFlow.makeEffectTexture(m_lqBg); if(withCF && m_aa > 0) { @@ -2060,36 +2061,39 @@ void CMenu::_mainLoopCommon(bool withCF, bool adjusting) void CMenu::_setBg(const STexture &tex, const STexture &lqTex) { - m_lqBg = &lqTex; + /* Not setting same bg again */ if(m_nextBg == &tex) return; - m_prevBg.CopyTexture(m_curBg); - m_curBg.Cleanup(); + m_lqBg = &lqTex; + /* before setting new next bg set previous */ + if(m_nextBg != NULL) + m_prevBg = m_nextBg; m_nextBg = &tex; m_bgCrossFade = 0xFF; } void CMenu::_updateBg(void) { + if(m_bgCrossFade == 0) + return; + m_bgCrossFade = max(0, (int)m_bgCrossFade - 14); + Mtx modelViewMtx; GXTexObj texObj; GXTexObj texObj2; - if (m_bgCrossFade == 0) return; - m_bgCrossFade = max(0, (int)m_bgCrossFade - 14); - if(m_bgCrossFade == 0 && m_nextBg != NULL) - { - m_curBg.CopyTexture(*m_nextBg); - return; - } + /* last pass so remove previous bg */ + if(m_bgCrossFade == 0) + m_prevBg = NULL; + GX_ClearVtxDesc(); - GX_SetNumTevStages(m_prevBg.data == NULL ? 1 : 2); + GX_SetNumTevStages(m_prevBg == NULL ? 1 : 2); GX_SetNumChans(0); GX_SetVtxDesc(GX_VA_POS, GX_DIRECT); GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0); GX_SetVtxDesc(GX_VA_TEX0, GX_DIRECT); GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_F32, 0); - GX_SetNumTexGens(m_prevBg.data == NULL ? 1 : 2); + GX_SetNumTexGens(m_prevBg == NULL ? 1 : 2); GX_SetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY); GX_SetTexCoordGen(GX_TEXCOORD1, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY); GX_SetTevKColor(GX_KCOLOR0, CColor(m_bgCrossFade, 0xFF - m_bgCrossFade, 0, 0)); @@ -2116,9 +2120,9 @@ void CMenu::_updateBg(void) GX_InitTexObj(&texObj, m_nextBg->data, m_nextBg->width, m_nextBg->height, m_nextBg->format, GX_CLAMP, GX_CLAMP, GX_FALSE); GX_LoadTexObj(&texObj, GX_TEXMAP0); } - if(m_prevBg.data != NULL) + if(m_prevBg != NULL && m_prevBg->data != NULL) { - GX_InitTexObj(&texObj2, m_prevBg.data, m_prevBg.width, m_prevBg.height, m_prevBg.format, GX_CLAMP, GX_CLAMP, GX_FALSE); + GX_InitTexObj(&texObj2, m_prevBg->data, m_prevBg->width, m_prevBg->height, m_prevBg->format, GX_CLAMP, GX_CLAMP, GX_FALSE); GX_LoadTexObj(&texObj2, GX_TEXMAP1); } GX_Begin(GX_QUADS, GX_VTXFMT0, 4); @@ -2137,11 +2141,6 @@ 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 && m_nextBg != NULL) - { - m_curBg.CopyTexture(*m_nextBg); - m_bgCrossFade = 0; - } } void CMenu::_drawBg(void) diff --git a/source/menu/menu.hpp b/source/menu/menu.hpp index f7e375d6..615fe48d 100644 --- a/source/menu/menu.hpp +++ b/source/menu/menu.hpp @@ -115,8 +115,8 @@ private: string m_ver; /* End Updates */ // - STexture m_prevBg; STexture m_curBg; + const STexture *m_prevBg; const STexture *m_nextBg; const STexture *m_lqBg; u8 m_bgCrossFade; diff --git a/source/menu/menu_home.cpp b/source/menu/menu_home.cpp index d5162d72..0fb63cfc 100644 --- a/source/menu/menu_home.cpp +++ b/source/menu/menu_home.cpp @@ -241,7 +241,7 @@ void CMenu::_initHomeAndExitToMenu() m_homeBtnHelp = _addButton("HOME/HELP", theme.btnFont, L"", 330, 120, 250, 56, theme.btnFontColor); m_homeBtnAbout = _addButton("HOME/ABOUT", theme.btnFont, L"", 330, 230, 250, 56, theme.btnFontColor); m_homeBtnExitTo = _addButton("HOME/EXIT_TO", theme.btnFont, L"", 330, 340, 250, 56, theme.btnFontColor); - m_homeLblBattery = _addLabel("HOME/BATTERY", theme.btnFont, L"", 60, 420, 520, 56, theme.btnFontColor, FTGX_JUSTIFY_CENTER | FTGX_ALIGN_MIDDLE, theme.btnTexC); + m_homeLblBattery = _addLabel("HOME/BATTERY", theme.btnFont, L"", 0, 420, 640, 56, theme.btnFontColor, FTGX_JUSTIFY_CENTER | FTGX_ALIGN_MIDDLE, theme.btnTexC); _setHideAnim(m_homeBtnSettings, "HOME/SETTINGS", 0, 0, -2.f, 0.f); _setHideAnim(m_homeBtnReloadCache, "HOME/RELOAD_CACHE", 0, 0, -2.f, 0.f);