From 3d93c11e218f39fbdfb821d7f2b76f51f465696d Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Sun, 17 Aug 2003 18:03:02 +0000 Subject: [PATCH] generate an HTML page with a list of all songs and difficulties on exit --- stepmania/src/SongManager.cpp | 119 +++++++++++++++++++++++++++++++++- stepmania/src/SongManager.h | 2 + 2 files changed, 120 insertions(+), 1 deletion(-) diff --git a/stepmania/src/SongManager.cpp b/stepmania/src/SongManager.cpp index 4e6f546e3d..6482dbb168 100644 --- a/stepmania/src/SongManager.cpp +++ b/stepmania/src/SongManager.cpp @@ -26,13 +26,14 @@ #include "AnnouncerManager.h" #include "ThemeManager.h" #include "GameManager.h" - #include "RageFile.h" +#include "ProductInfo.h" SongManager* SONGMAN = NULL; // global and accessable from anywhere in our program #define SONGS_DIR BASE_PATH "Songs" SLASH #define COURSES_DIR BASE_PATH "Courses" SLASH +#define STATS_PATH BASE_PATH "stats.html" const CString CATEGORY_RANKING_FILE = BASE_PATH "Data" SLASH "CategoryRanking.dat"; const CString COURSE_RANKING_FILE = BASE_PATH "Data" SLASH "CourseRanking.dat"; const CString NOTES_SCORES_FILE[NUM_MEMORY_CARDS] = { BASE_PATH "Data" SLASH "Player1NotesScores.dat", BASE_PATH "Data" SLASH "Player2NotesScores.dat", BASE_PATH "Data" SLASH "MachineNotesScores.dat" }; @@ -91,6 +92,8 @@ SongManager::~SongManager() { SaveMachineScoresToDisk(); + WriteStatsWebPage(); + FreeSongs(); } @@ -1223,3 +1226,117 @@ void SongManager::UpdateRankingCourses() m_pCourses[i]->SortOrder_Ranking = 1; } } + +// TODO: Move this to a different file. No need to clutter SongManager. +void SongManager::WriteStatsWebPage() +{ + FILE* fp = fopen( STATS_PATH, "w" ); + if( fp == NULL ) + return; + + fprintf( fp, + "\n" + "\n" + "%s\n" + "\n" + "\n", + PRODUCT_NAME_VER ); + + vector vSongs = m_pSongs; + SortSongPointerArrayByGroupAndTitle( vSongs ); + + // + // Print song list + // + fprintf( fp, "\n" ); + fprintf( fp, " " ); + for( unsigned i=0; i" ); + CString sImagePath = pSong->HasBanner() ? pSong->GetBannerPath() : (pSong->HasBackground() ? pSong->GetBackgroundPath() : "" ); + if( sImagePath.empty() ) + fprintf( fp, "" ); + else + fprintf( fp, "", sImagePath.c_str() ); + + fprintf( fp, "", pSong->GetTranslitArtist().c_str() ); + fprintf( fp, "\n" ); + + } + fprintf( fp, "
imagetitle
%s
", pSong->GetTranslitMainTitle().c_str() ); + fprintf( fp, "%s
", pSong->GetTranslitSubTitle().c_str() ); + fprintf( fp, "%s
\n
\n" ); + + + // + // Print steps tables + // + for( int g=0; gGetGameDefForGame(game); + + vector aStepsTypes; + GAMEMAN->GetNotesTypesForGame( game, aStepsTypes ); + + + fprintf( fp, "

%s

\n", pGameDef->m_szName ); + + + fprintf( fp, "\n" ); + fprintf( fp, "" ); + unsigned j; + for( j=0; j%s\n", NUM_DIFFICULTIES, GAMEMAN->NotesTypeToString(st).c_str() ); + } + fprintf( fp, "\n" ); + + fprintf( fp, "" ); + for( j=0; j%s\n", Capitalize(DifficultyToString(d).Left(3)).c_str() ); + } + } + fprintf( fp, "\n" ); + for( unsigned i=0; i\n" ); + + fprintf( fp, "", pSong->GetTranslitMainTitle().c_str() ); + + for( unsigned j=0; jGetStepsByDifficulty( st, d, false ); + if( pSteps ) + fprintf( fp, "\n", pSteps->GetMeter() ); + else + fprintf( fp, "\n" ); + } + } + + fprintf( fp, "" ); + + } + fprintf( fp, "
title
 
%s%d 
\n
\n" ); + } + + fprintf( fp, + "\n" + "\n" + ); +} diff --git a/stepmania/src/SongManager.h b/stepmania/src/SongManager.h index 59a5d97fb5..57fa436857 100644 --- a/stepmania/src/SongManager.h +++ b/stepmania/src/SongManager.h @@ -122,6 +122,8 @@ protected: void SaveCategoryRankingsToFile( CString fn ); void SaveCourseRankingsToFile( CString fn ); + void WriteStatsWebPage(); + vector m_pSongs; // all songs that can be played vector m_pBestSongs; CStringArray m_sGroupNames;