-added proper texture, font and sound cleanup (should fix most

game booting problems when using a theme)
This commit is contained in:
fix94.1 2012-07-17 23:14:05 +00:00
parent c3c02ac862
commit f606df9b2d
2 changed files with 24 additions and 4 deletions

View File

@ -521,6 +521,25 @@ void CMenu::cleanup()
ClearLogBuffer(); ClearLogBuffer();
Close_Inputs(); Close_Inputs();
for(TexSet::iterator texture = theme.texSet.begin(); texture != theme.texSet.end(); texture++)
{
if(texture->second.data.get())
texture->second.data.release();
}
theme.texSet.clear();
for(FontSet::iterator font = theme.fontSet.begin(); font != theme.fontSet.end(); font++)
{
if(font->second.data.get())
font->second.data.release();
}
theme.fontSet.clear();
for(SoundSet::iterator sound = theme.soundSet.begin(); sound != theme.soundSet.end(); sound++)
{
if(sound->second.get())
sound->second.release();
}
theme.soundSet.clear();
cleaned_up = true; cleaned_up = true;
gprintf(" \nMemory cleaned up\n"); gprintf(" \nMemory cleaned up\n");
} }
@ -859,9 +878,8 @@ void CMenu::_loadCFLayout(int version, bool forceAA, bool otherScrnFmt)
void CMenu::_buildMenus(void) void CMenu::_buildMenus(void)
{ {
SThemeData theme; if(!m_base_font.get())
_loadDefaultFont(CONF_GetLanguage() == CONF_LANG_KOREAN);
if(!m_base_font.get()) _loadDefaultFont(CONF_GetLanguage() == CONF_LANG_KOREAN);
// Default fonts // Default fonts
theme.btnFont = _font(theme.fontSet, "GENERAL", "button_font", BUTTONFONT); theme.btnFont = _font(theme.fontSet, "GENERAL", "button_font", BUTTONFONT);
@ -1186,6 +1204,7 @@ STexture CMenu::_texture(CMenu::TexSet &texSet, const char *domain, const char *
STexture tex; STexture tex;
if (STexture::TE_OK == tex.fromPNGFile(fmt("%s/%s", m_themeDataDir.c_str(), filename.c_str()), GX_TF_RGBA8, ALLOC_MEM2)) if (STexture::TE_OK == tex.fromPNGFile(fmt("%s/%s", m_themeDataDir.c_str(), filename.c_str()), GX_TF_RGBA8, ALLOC_MEM2))
{ {
def.data.release();
texSet[filename] = tex; texSet[filename] = tex;
return tex; return tex;
} }

View File

@ -696,7 +696,7 @@ private:
typedef pair<string, u32> FontDesc; typedef pair<string, u32> FontDesc;
typedef map<FontDesc, SFont> FontSet; typedef map<FontDesc, SFont> FontSet;
typedef map<string, STexture> TexSet; typedef map<string, STexture> TexSet;
typedef map<string, SmartGuiSound > SoundSet; typedef map<string, SmartGuiSound> SoundSet;
struct SThemeData struct SThemeData
{ {
TexSet texSet; TexSet texSet;
@ -791,6 +791,7 @@ private:
SmartGuiSound hoverSound; SmartGuiSound hoverSound;
SmartGuiSound cameraSound; SmartGuiSound cameraSound;
}; };
SThemeData theme;
struct SCFParamDesc struct SCFParamDesc
{ {
enum enum