fix -stroke pages showing up in .ini

This commit is contained in:
Chris Danford
2008-07-04 23:48:06 +00:00
parent 0165286d76
commit 674dfe3a8a
3 changed files with 34 additions and 32 deletions
@@ -172,22 +172,6 @@ void CTextureFontGeneratorDlg::UpdateFont( bool bSavingDoubleRes )
g_pTextureFont->m_PagesToGenerate.push_back( desc ); g_pTextureFont->m_PagesToGenerate.push_back( desc );
//
// Save duplicate imnages of each page with "-stroke" appended to the page name.
//
bool bExportStrokeTemplates = !!( pMenu->GetMenuState(ID_OPTIONS_EXPORTSTROKETEMPLATES, 0) & MF_CHECKED );
if( bExportStrokeTemplates )
{
int iNumPages = (int)g_pTextureFont->m_PagesToGenerate.size();
for( int i=0; i<iNumPages; i++ )
{
FontPageDescription desc = g_pTextureFont->m_PagesToGenerate[i];
desc.name += "-stroke";
g_pTextureFont->m_PagesToGenerate.push_back( desc );
}
}
/* Go: */ /* Go: */
g_pTextureFont->FormatFontPages(); g_pTextureFont->FormatFontPages();
@@ -609,12 +593,13 @@ void CTextureFontGeneratorDlg::OnFileSave()
*/ */
CMenu *pMenu = GetMenu(); CMenu *pMenu = GetMenu();
bool bExportStrokeTemplates = !!( pMenu->GetMenuState(ID_OPTIONS_EXPORTSTROKETEMPLATES, 0) & MF_CHECKED );
bool bDoubleRes = !!( pMenu->GetMenuState(ID_OPTIONS_DOUBLERES, 0) & MF_CHECKED ); bool bDoubleRes = !!( pMenu->GetMenuState(ID_OPTIONS_DOUBLERES, 0) & MF_CHECKED );
if( bDoubleRes ) if( bDoubleRes )
{ {
g_pTextureFont->Save( szFile, "", true, false ); // save metrics g_pTextureFont->Save( szFile, "", true, false, bExportStrokeTemplates ); // save metrics
UpdateFont( true ); // generate DoubleRes bitmaps UpdateFont( true ); // generate DoubleRes bitmaps
g_pTextureFont->Save( szFile, " (doubleres)", false, true ); // save bitmaps g_pTextureFont->Save( szFile, " (doubleres)", false, true, bExportStrokeTemplates ); // save bitmaps
// reset to normal, non-DoubleRes font // reset to normal, non-DoubleRes font
m_bUpdateFontNeeded = true; m_bUpdateFontNeeded = true;
Invalidate( FALSE ); Invalidate( FALSE );
@@ -622,7 +607,7 @@ void CTextureFontGeneratorDlg::OnFileSave()
} }
else // normal res else // normal res
{ {
g_pTextureFont->Save( szFile, "", true, true ); // save metrics and bitmaps g_pTextureFont->Save( szFile, "", true, true, bExportStrokeTemplates ); // save metrics and bitmaps
} }
} }
@@ -371,7 +371,7 @@ void wchar_to_utf8( wchar_t ch, string &out )
#include <iomanip> #include <iomanip>
void TextureFont::Save( CString sBasePath, CString sBitmapAppendBeforeExtension, bool bSaveMetrics, bool bSaveBitmaps ) void TextureFont::Save( CString sBasePath, CString sBitmapAppendBeforeExtension, bool bSaveMetrics, bool bSaveBitmaps, bool bExportStrokeTemplates )
{ {
if( m_sError != "" ) if( m_sError != "" )
return; return;
@@ -447,18 +447,35 @@ void TextureFont::Save( CString sBasePath, CString sBitmapAppendBeforeExtension,
GrayScaleToAlpha( &surf ); GrayScaleToAlpha( &surf );
CString sFile; for( int j=0; j<2; j++ )
sFile.Format( "%s [%s] %ix%i%s.png", {
sBasePath.GetString(), CString sPageName = m_PagesToGenerate[i].name.GetString();
m_PagesToGenerate[i].name.GetString(), switch( j )
m_apPages[i]->m_iNumFramesX, {
m_apPages[i]->m_iNumFramesY, case 0:
sBitmapAppendBeforeExtension.GetString() ); break;
case 1:
if( !bExportStrokeTemplates )
continue;
sPageName += "-stroke";
break;
default:
ASSERT(0);
}
FILE *f = fopen( sFile, "w+b" ); CString sFile;
char szErrorbuf[1024]; sFile.Format( "%s [%s] %ix%i%s.png",
SavePNG( f, szErrorbuf, &surf ); sBasePath.GetString(),
fclose( f ); sPageName.GetString(),
m_apPages[i]->m_iNumFramesX,
m_apPages[i]->m_iNumFramesY,
sBitmapAppendBeforeExtension.GetString() );
FILE *f = fopen( sFile, "w+b" );
char szErrorbuf[1024];
SavePNG( f, szErrorbuf, &surf );
fclose( f );
}
} }
} }
} }
@@ -37,7 +37,7 @@ public:
vector<FontPageDescription> m_PagesToGenerate; vector<FontPageDescription> m_PagesToGenerate;
void FormatFontPage( int iPage, HDC hDC ); void FormatFontPage( int iPage, HDC hDC );
void FormatFontPages(); void FormatFontPages();
void Save( CString sPath, CString sBitmapAppendBeforeExtension, bool bSaveMetrics, bool bSaveBitmaps ); void Save( CString sPath, CString sBitmapAppendBeforeExtension, bool bSaveMetrics, bool bSaveBitmaps, bool bExportStrokeTemplates );
map<wchar_t, HBITMAP> m_Characters; map<wchar_t, HBITMAP> m_Characters;