diff --git a/source/gui/gui.cpp b/source/gui/gui.cpp index 620e14ac..a29631b9 100644 --- a/source/gui/gui.cpp +++ b/source/gui/gui.cpp @@ -526,15 +526,26 @@ void CButtonsMgr::setText(s16 id, const wstringEx &text, u32 startline,bool unwr void CButtonsMgr::setBtnTexture(s16 id, STexture &texNormal, STexture &texSelected) { if (id == -1) return; - SButtonTextureSet texSet; - - texSet.center = texNormal; - texSet.centerSel = texSelected; - if (id < (s32)m_elts.size()) { SButton *b = (SButton*)m_elts[id]; - b->tex = texSet;//change texture + /* free old textures */ + b->tex.center.Cleanup(); + b->tex.centerSel.Cleanup(); + /*change textures */ + b->tex.center = texNormal; + b->tex.centerSel = texSelected; + } +} + +void CButtonsMgr::freeBtnTexture(s16 id) +{ + if(id == -1) return; + if(id < (s32)m_elts.size()) + { + SButton *b = (SButton*)m_elts[id]; + b->tex.center.Cleanup(); + b->tex.centerSel.Cleanup(); } } diff --git a/source/gui/gui.hpp b/source/gui/gui.hpp index 9de5ff10..0ceba37a 100644 --- a/source/gui/gui.hpp +++ b/source/gui/gui.hpp @@ -40,6 +40,7 @@ public: void setText(s16 id, const wstringEx &text, bool unwrap = false); void setText(s16 id, const wstringEx &text, u32 startline, bool unwrap = false); void setBtnTexture(s16 id, STexture &texNormal, STexture &texSelected); + void freeBtnTexture(s16 id); void setTexture(s16 id ,STexture &bg); void setTexture(s16 id, STexture &bg, int width, int height); void setProgress(s16 id, float f, bool instant = false); diff --git a/source/menu/menu_source.cpp b/source/menu/menu_source.cpp index c51966c9..f7ad4cdc 100644 --- a/source/menu/menu_source.cpp +++ b/source/menu/menu_source.cpp @@ -60,7 +60,10 @@ void CMenu::_hideSource(bool instant) } for(i = 0; i < 12; ++i) + { m_btnMgr.hide(m_sourceBtnSource[i], instant); + m_btnMgr.freeBtnTexture(m_sourceBtnSource[i]); + } } void CMenu::_showSource(void) @@ -100,30 +103,30 @@ void CMenu::_updateSourceBtns(void) for (u8 i = 0; i < 12; ++i) m_btnMgr.hide(m_sourceBtnSource[i], true); - string ImgName; + const char *ImgName = NULL; u8 j = (Source_curPage - 1) * 12; for(u8 i = 0; i < 12; ++i) { STexture texConsoleImg; STexture texConsoleImgs; - - ImgName = m_source.getString(fmt("BUTTON_%i", i + j),"image", ""); - if(texConsoleImg.fromImageFile(fmt("%s/%s", m_themeDataDir.c_str(), ImgName.c_str())) != TE_OK) + + ImgName = m_source.getString(fmt("BUTTON_%i", i + j),"image", "").c_str(); + if(texConsoleImg.fromImageFile(fmt("%s/%s", m_themeDataDir.c_str(), ImgName)) != TE_OK) { - if(texConsoleImg.fromImageFile(fmt("%s/%s", m_sourceDir.c_str(), ImgName.c_str())) != TE_OK) + if(texConsoleImg.fromImageFile(fmt("%s/%s", m_sourceDir.c_str(), ImgName)) != TE_OK) texConsoleImg.fromPNG(favoriteson_png); } - ImgName = m_source.getString(fmt("BUTTON_%i", i + j),"image_s", ""); - if(texConsoleImgs.fromImageFile(fmt("%s/%s", m_themeDataDir.c_str(), ImgName.c_str())) != TE_OK) + ImgName = m_source.getString(fmt("BUTTON_%i", i + j),"image_s", "").c_str(); + if(texConsoleImgs.fromImageFile(fmt("%s/%s", m_themeDataDir.c_str(), ImgName)) != TE_OK) { - if(texConsoleImgs.fromImageFile(fmt("%s/%s", m_sourceDir.c_str(), ImgName.c_str())) != TE_OK) + if(texConsoleImgs.fromImageFile(fmt("%s/%s", m_sourceDir.c_str(), ImgName)) != TE_OK) texConsoleImgs.fromPNG(favoritesons_png); } m_btnMgr.setBtnTexture(m_sourceBtnSource[i], texConsoleImg, texConsoleImgs); - string source = m_source.getString(fmt("BUTTON_%i", i + j), "source", ""); - if (!source.empty()) + const char *source = m_source.getString(fmt("BUTTON_%i", i + j), "source", "").c_str(); + if(source != NULL && source[0] != '\0') m_btnMgr.show(m_sourceBtnSource[i]); } }