From 35ae87f89309732f9c593a5841d57f8a2b292e46 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Thu, 4 Dec 2003 21:27:52 +0000 Subject: [PATCH] use SDL_LoadImage in WriteStatsWebPage --- stepmania/src/SongManager.cpp | 77 ++++++++++++++++------------------- 1 file changed, 35 insertions(+), 42 deletions(-) diff --git a/stepmania/src/SongManager.cpp b/stepmania/src/SongManager.cpp index b3732cc2d9..0da3d69f6e 100644 --- a/stepmania/src/SongManager.cpp +++ b/stepmania/src/SongManager.cpp @@ -1430,55 +1430,53 @@ static void SortStepsByTypeAndDifficulty( vector &arraySongPointers ) sort( arraySongPointers.begin(), arraySongPointers.end(), CompareStepsPointersByTypeAndDifficulty ); } -static void HTMLWritePerGameHeader( FILE* fp, Game game ) +static void HTMLWritePerGameHeader( RageFile &f, Game game ) { const GameDef* pGameDef = GAMEMAN->GetGameDefForGame(game); vector aStepsTypes; GAMEMAN->GetNotesTypesForGame( game, aStepsTypes ); - fprintf( fp, "

%s

\n", pGameDef->m_szName ); + f.PutLine( ssprintf("

%s

", pGameDef->m_szName) ); - fprintf( fp, "\n" ); - fprintf( fp, "" ); + f.PutLine( "
title
" ); + f.Write( "" ); unsigned j; for( j=0; j%s\n", NUM_DIFFICULTIES, GAMEMAN->NotesTypeToString(st).c_str() ); + f.PutLine( ssprintf("", NUM_DIFFICULTIES, GAMEMAN->NotesTypeToString(st).c_str()) ); } - fprintf( fp, "\n" ); + f.PutLine( "" ); - fprintf( fp, "" ); + f.Write( "" ); for( j=0; j%s\n", Capitalize(DifficultyToString(d).Left(3)).c_str() ); + f.PutLine( ssprintf("", Capitalize(DifficultyToString(d).Left(3)).c_str()) ); } } - fprintf( fp, "\n" ); + f.PutLine( "" ); } // TODO: Move this to a different file. No need to clutter SongManager. void SongManager::WriteStatsWebPage() { - FILE* fp = fopen( STATS_PATH, "w" ); - if( fp == NULL ) + RageFile f; + if( !f.Open( STATS_PATH, RageFile::WRITE ) ) return; - fprintf( fp, - "\n" - "\n" - "\n" - "%s\n" - "\n" - "\n", - PRODUCT_NAME_VER ); + f.PutLine( "" ); + f.PutLine( "" ); + f.PutLine( "" ); + f.PutLine( ssprintf("%s", PRODUCT_NAME_VER) ); + f.PutLine( "" ); + f.PutLine( "" ); vector vSongs = m_pSongs; SortSongPointerArrayByGroupAndTitle( vSongs ); @@ -1486,11 +1484,11 @@ void SongManager::WriteStatsWebPage() // // Print song list // - fprintf( fp, "
title%s
 
 %s
\n" ); + f.PutLine( "
" ); for( unsigned i=0; i" ); + f.Write( "" ); /* XXX: We can't call pSong->HasBanner on every song; it'll effectively re-traverse the entire * song directory tree checking if each banner file really exists. * @@ -1499,17 +1497,16 @@ void SongManager::WriteStatsWebPage() //CString sImagePath = pSong->HasBanner() ? pSong->GetBannerPath() : (pSong->HasBackground() ? pSong->GetBackgroundPath() : "" ); CString sImagePath = pSong->GetBannerPath(); if( sImagePath.empty() ) - fprintf( fp, "" ); + f.Write( "" ); else - fprintf( fp, "", HTMLQuoteDoubleQuotes(sImagePath).c_str() ); + f.Write( ssprintf("", HTMLQuoteDoubleQuotes(sImagePath).c_str()) ); - fprintf( fp, "", pSong->GetTranslitArtist().c_str() ); - fprintf( fp, "\n" ); - + f.Write( ssprintf("", pSong->GetTranslitArtist().c_str()) ); + f.PutLine( "" ); } - fprintf( fp, "
%s
", pSong->GetTranslitMainTitle().c_str() ); - fprintf( fp, "%s
", pSong->GetTranslitSubTitle().c_str() ); - fprintf( fp, "%s
%s
", pSong->GetTranslitMainTitle().c_str()) ); + f.Write( ssprintf("%s
", pSong->GetTranslitSubTitle().c_str()) ); + f.Write( ssprintf("%s
\n
\n" ); + f.PutLine( "\n
" ); // @@ -1541,14 +1538,14 @@ void SongManager::WriteStatsWebPage() /* We have some steps for this game. Make sure we've written the game header. */ if( !WroteHeader ) { - HTMLWritePerGameHeader( fp, game ); + HTMLWritePerGameHeader( f, game ); WroteHeader = true; } - fprintf( fp, "\n" ); + f.PutLine( "" ); - fprintf( fp, "%s", pSong->GetTranslitMainTitle().c_str() ); + f.Write( ssprintf("%s", pSong->GetTranslitMainTitle().c_str()) ); SortStepsByTypeAndDifficulty( Steps ); @@ -1561,24 +1558,20 @@ void SongManager::WriteStatsWebPage() Steps[CurSteps]->m_StepsType == aStepsTypes[j] && Steps[CurSteps]->GetDifficulty() == k ) { - fprintf( fp, "%d\n", Steps[CurSteps]->GetMeter() ); + f.PutLine( ssprintf("%d", Steps[CurSteps]->GetMeter()) ); ++CurSteps; } else - fprintf( fp, " \n" ); + f.PutLine( " " ); } } - fprintf( fp, "" ); + f.Write( "" ); } if( WroteHeader ) - fprintf( fp, "\n
\n" ); // footer + f.PutLine( "\n
" ); // footer } - fprintf( fp, - "\n" - "\n" - ); - - fclose( fp ); + f.PutLine( "" ); + f.PutLine( "" ); }