revert change that disallowed reloading of fonts via F2
This commit is contained in:
@@ -728,7 +728,6 @@ void Font::Load( const RString &sIniPath, RString sChars )
|
|||||||
Font subfont;
|
Font subfont;
|
||||||
subfont.Load(fPath,"");
|
subfont.Load(fPath,"");
|
||||||
MergeFont(subfont);
|
MergeFont(subfont);
|
||||||
//FONT->UnloadFont(subfont);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+14
-8
@@ -22,7 +22,7 @@ FontManager::~FontManager()
|
|||||||
{
|
{
|
||||||
const FontName &fn = i->first;
|
const FontName &fn = i->first;
|
||||||
Font* pFont = i->second;
|
Font* pFont = i->second;
|
||||||
if(pFont->m_iRefCount>0) {
|
if(pFont->m_iRefCount > 0) {
|
||||||
LOG->Trace( "FONT LEAK: '%s', RefCount = %d.", fn.first.c_str(), pFont->m_iRefCount );
|
LOG->Trace( "FONT LEAK: '%s', RefCount = %d.", fn.first.c_str(), pFont->m_iRefCount );
|
||||||
}
|
}
|
||||||
delete pFont;
|
delete pFont;
|
||||||
@@ -53,14 +53,13 @@ Font* FontManager::LoadFont( const RString &sFontOrTextureFilePath, RString sCha
|
|||||||
{
|
{
|
||||||
pFont=p->second;
|
pFont=p->second;
|
||||||
pFont->m_iRefCount++;
|
pFont->m_iRefCount++;
|
||||||
}
|
return pFont;
|
||||||
else {
|
|
||||||
pFont= new Font;
|
|
||||||
pFont->Load(sFontOrTextureFilePath, sChars);
|
|
||||||
g_mapPathToFont[NewName] = pFont;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return pFont;
|
Font *f = new Font;
|
||||||
|
f->Load(sFontOrTextureFilePath, sChars);
|
||||||
|
g_mapPathToFont[NewName] = f;
|
||||||
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
Font *FontManager::CopyFont( Font *pFont )
|
Font *FontManager::CopyFont( Font *pFont )
|
||||||
@@ -79,16 +78,22 @@ void FontManager::UnloadFont( Font *fp )
|
|||||||
if(i->second != fp)
|
if(i->second != fp)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
ASSERT_M(fp->m_iRefCount>0,"Attempting to unload a font with zero ref count!");
|
ASSERT_M(fp->m_iRefCount > 0,"Attempting to unload a font with zero ref count!");
|
||||||
|
|
||||||
i->second->m_iRefCount--;
|
i->second->m_iRefCount--;
|
||||||
|
|
||||||
|
if( fp->m_iRefCount == 0 )
|
||||||
|
{
|
||||||
|
delete i->second; // free the texture
|
||||||
|
g_mapPathToFont.erase( i ); // and remove the key in the map
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
FAIL_M( ssprintf("Unloaded an unknown font (%p)", fp) );
|
FAIL_M( ssprintf("Unloaded an unknown font (%p)", fp) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
void FontManager::PruneFonts() {
|
void FontManager::PruneFonts() {
|
||||||
for( std::map<FontName, Font*>::iterator i = g_mapPathToFont.begin();i != g_mapPathToFont.end();) {
|
for( std::map<FontName, Font*>::iterator i = g_mapPathToFont.begin();i != g_mapPathToFont.end();) {
|
||||||
Font *fp=i->second;
|
Font *fp=i->second;
|
||||||
@@ -101,6 +106,7 @@ void FontManager::PruneFonts() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (c) 2001-2003 Chris Danford, Glenn Maynard
|
* (c) 2001-2003 Chris Danford, Glenn Maynard
|
||||||
|
|||||||
+1
-1
@@ -15,7 +15,7 @@ public:
|
|||||||
Font* LoadFont( const RString &sFontOrTextureFilePath, RString sChars = "" );
|
Font* LoadFont( const RString &sFontOrTextureFilePath, RString sChars = "" );
|
||||||
Font *CopyFont( Font *pFont );
|
Font *CopyFont( Font *pFont );
|
||||||
void UnloadFont( Font *fp );
|
void UnloadFont( Font *fp );
|
||||||
void PruneFonts();
|
//void PruneFonts();
|
||||||
|
|
||||||
/* Warning: This reloads fonts completely, so all BitmapTexts need to be
|
/* Warning: This reloads fonts completely, so all BitmapTexts need to be
|
||||||
* reset, too. If this isn't done, best case they end up with old font
|
* reset, too. If this isn't done, best case they end up with old font
|
||||||
|
|||||||
+21
-14
@@ -76,7 +76,7 @@
|
|||||||
ScreenManager* SCREENMAN = NULL; // global and accessable from anywhere in our program
|
ScreenManager* SCREENMAN = NULL; // global and accessable from anywhere in our program
|
||||||
|
|
||||||
static Preference<bool> g_bDelayedScreenLoad( "DelayedScreenLoad", false );
|
static Preference<bool> g_bDelayedScreenLoad( "DelayedScreenLoad", false );
|
||||||
static Preference<bool> g_bPruneFonts( "PruneFonts", true );
|
//static Preference<bool> g_bPruneFonts( "PruneFonts", true );
|
||||||
|
|
||||||
// Screen registration
|
// Screen registration
|
||||||
static map<RString,CreateScreenFn> *g_pmapRegistrees = NULL;
|
static map<RString,CreateScreenFn> *g_pmapRegistrees = NULL;
|
||||||
@@ -592,9 +592,11 @@ void ScreenManager::PrepareScreen( const RString &sScreenName )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Prune any unused fonts now that we have had a chance to reference the fonts
|
// Prune any unused fonts now that we have had a chance to reference the fonts
|
||||||
|
/*
|
||||||
if(g_bPruneFonts) {
|
if(g_bPruneFonts) {
|
||||||
FONT->PruneFonts();
|
FONT->PruneFonts();
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
TEXTUREMAN->DiagnosticOutput();
|
TEXTUREMAN->DiagnosticOutput();
|
||||||
}
|
}
|
||||||
@@ -690,17 +692,19 @@ void ScreenManager::LoadDelayedScreen()
|
|||||||
* cleanup, so it doesn't get deleted by cleanup. */
|
* cleanup, so it doesn't get deleted by cleanup. */
|
||||||
bool bLoaded = ActivatePreparedScreenAndBackground( sScreenName );
|
bool bLoaded = ActivatePreparedScreenAndBackground( sScreenName );
|
||||||
|
|
||||||
bool deletePrepared=g_setGroupedScreens.find(sScreenName) == g_setGroupedScreens.end();
|
vector<Actor*> apActorsToDelete;
|
||||||
|
if( g_setGroupedScreens.find(sScreenName) == g_setGroupedScreens.end() )
|
||||||
/* It's time to delete all old prepared screens. Depending on DelayedScreenLoad,
|
{
|
||||||
* we can either delete the screens before or after we load the new screen.
|
/* It's time to delete all old prepared screens. Depending on
|
||||||
* Either way, we must remove them from the prepared list before we prepare
|
* DelayedScreenLoad, we can either delete the screens before or after
|
||||||
* new screens.
|
* we load the new screen. Either way, we must remove them from the
|
||||||
* If DelayedScreenLoad is true, delete them now; this lowers memory
|
* prepared list before we prepare new screens.
|
||||||
* requirements, but results in redundant loads as we unload common data. */
|
* If DelayedScreenLoad is true, delete them now; this lowers memory
|
||||||
if( deletePrepared && g_bDelayedScreenLoad ) {
|
* requirements, but results in redundant loads as we unload common data. */
|
||||||
DeletePreparedScreens();
|
if( g_bDelayedScreenLoad )
|
||||||
deletePrepared=false;
|
DeletePreparedScreens();
|
||||||
|
else
|
||||||
|
GrabPreparedActors( apActorsToDelete );
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the screen wasn't already prepared, load it.
|
// If the screen wasn't already prepared, load it.
|
||||||
@@ -717,9 +721,12 @@ void ScreenManager::LoadDelayedScreen()
|
|||||||
ASSERT( bLoaded );
|
ASSERT( bLoaded );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( deletePrepared )
|
if( !apActorsToDelete.empty() )
|
||||||
{
|
{
|
||||||
DeletePreparedScreens();
|
BeforeDeleteScreen();
|
||||||
|
FOREACH( Actor*, apActorsToDelete, a )
|
||||||
|
SAFE_DELETE( *a );
|
||||||
|
AfterDeleteScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
MESSAGEMAN->Broadcast( Message_ScreenChanged );
|
MESSAGEMAN->Broadcast( Message_ScreenChanged );
|
||||||
|
|||||||
Reference in New Issue
Block a user