mirror of
https://github.com/Fledge68/WiiFlow_Lite.git
synced 2024-12-25 11:21:55 +01:00
-hopefully fixed theme memory issues completely now, there was a font bug left which didnt cache in fonts properly so they got written over and over again filling up nearly the whole memory
This commit is contained in:
parent
d1dbfef055
commit
51f5860dd9
@ -1198,24 +1198,28 @@ SFont CMenu::_font(CMenu::FontSet &fontSet, const char *domain, const char *key,
|
|||||||
fonts[i].res = min(max(fonts[i].min, fonts[i].res <= 0 ? fonts[i].def : fonts[i].res), fonts[i].max);
|
fonts[i].res = min(max(fonts[i].min, fonts[i].res <= 0 ? fonts[i].def : fonts[i].res), fonts[i].max);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try to find the same font with the same size
|
|
||||||
CMenu::FontSet::iterator i = fontSet.find(CMenu::FontDesc(upperCase(filename.c_str()), fonts[0].res));
|
|
||||||
/* ONLY return the font if spacing and weight are the same */
|
/* ONLY return the font if spacing and weight are the same */
|
||||||
if (i != fontSet.end() && i->second.lineSpacing == fonts[1].res && i->second.weight == fonts[2].res) return i->second;
|
fnt_type font_req;
|
||||||
|
font_req.name = upperCase(filename.c_str());
|
||||||
|
font_req.t1 = fonts[0].res;
|
||||||
|
font_req.t2 = fonts[1].res;
|
||||||
|
font_req.t3 = fonts[2].res;
|
||||||
|
FontSet::iterator i = fontSet.find(font_req);
|
||||||
|
if (i != fontSet.end()) return i->second;
|
||||||
|
|
||||||
// TTF not found in memory, load it to create a new font
|
// TTF not found in memory, load it to create a new font
|
||||||
SFont retFont;
|
SFont retFont;
|
||||||
if (!useDefault && retFont.fromFile(fmt("%s/%s", m_themeDataDir.c_str(), filename.c_str()), fonts[0].res, fonts[1].res, fonts[2].res, index))
|
if (!useDefault && retFont.fromFile(fmt("%s/%s", m_themeDataDir.c_str(), filename.c_str()), fonts[0].res, fonts[1].res, fonts[2].res, index))
|
||||||
{
|
{
|
||||||
// Theme Font
|
// Theme Font
|
||||||
fontSet[CMenu::FontDesc(upperCase(filename.c_str()), fonts[0].res)] = retFont;
|
fontSet[font_req] = retFont;
|
||||||
return retFont;
|
return retFont;
|
||||||
}
|
}
|
||||||
/* Fallback to default font */
|
/* Fallback to default font */
|
||||||
if(retFont.fromBuffer(m_base_font, m_base_font_size, fonts[0].res, fonts[1].res, fonts[2].res, index))
|
if(retFont.fromBuffer(m_base_font, m_base_font_size, fonts[0].res, fonts[1].res, fonts[2].res, index))
|
||||||
{
|
{
|
||||||
// Default font
|
// Default font
|
||||||
fontSet[CMenu::FontDesc(upperCase(filename.c_str()), fonts[0].res)] = retFont;
|
fontSet[font_req] = retFont;
|
||||||
return retFont;
|
return retFont;
|
||||||
}
|
}
|
||||||
return retFont;
|
return retFont;
|
||||||
|
@ -695,8 +695,27 @@ private:
|
|||||||
WO_FORMAT,
|
WO_FORMAT,
|
||||||
WO_COPY_GAME,
|
WO_COPY_GAME,
|
||||||
};
|
};
|
||||||
typedef pair<string, u32> FontDesc;
|
struct fnt_type {
|
||||||
typedef map<FontDesc, SFont> FontSet;
|
string name;
|
||||||
|
u32 t1;
|
||||||
|
u32 t2;
|
||||||
|
u32 t3;
|
||||||
|
};
|
||||||
|
struct cmp_fnt_type {
|
||||||
|
bool operator()(const fnt_type& l, const fnt_type& r)
|
||||||
|
{
|
||||||
|
if (l.name < r.name) return true;
|
||||||
|
if (l.name > r.name) return false;
|
||||||
|
if (l.t1 < r.t1) return true;
|
||||||
|
if (l.t1 > r.t1) return false;
|
||||||
|
if (l.t2 < r.t2) return true;
|
||||||
|
if (l.t2 > r.t2) return false;
|
||||||
|
if (l.t3 < r.t3) return true;
|
||||||
|
if (l.t3 > r.t3) return false;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
typedef map<fnt_type, SFont, cmp_fnt_type> FontSet;
|
||||||
typedef map<string, TexData> TexSet;
|
typedef map<string, TexData> TexSet;
|
||||||
typedef map<string, GuiSound*> SoundSet;
|
typedef map<string, GuiSound*> SoundSet;
|
||||||
struct SThemeData
|
struct SThemeData
|
||||||
|
Loading…
Reference in New Issue
Block a user