From 8d6b19ad7af8a9b3c393352166948137436e8168 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Tue, 9 Dec 2003 10:20:18 +0000 Subject: [PATCH] more stats.html categories --- stepmania/src/GameConstantsAndTypes.h | 1 + stepmania/src/GameState.cpp | 64 ++++++++++------ stepmania/src/ProfileManager.cpp | 103 +++++++++++++++++++++----- stepmania/src/ProfileManager.h | 15 ++++ stepmania/src/ScreenGameplay.cpp | 5 ++ stepmania/src/StageStats.cpp | 4 +- stepmania/src/StageStats.h | 6 +- 7 files changed, 154 insertions(+), 44 deletions(-) diff --git a/stepmania/src/GameConstantsAndTypes.h b/stepmania/src/GameConstantsAndTypes.h index c0bff26d73..a49828e784 100644 --- a/stepmania/src/GameConstantsAndTypes.h +++ b/stepmania/src/GameConstantsAndTypes.h @@ -38,6 +38,7 @@ // Note definitions // const int MAX_METER = 12; +const int MIN_METER = 1; /* This is just cached song data. Not all of it may actually be displayed * in the radar. */ diff --git a/stepmania/src/GameState.cpp b/stepmania/src/GameState.cpp index 49a44cc68d..81652fd4e1 100644 --- a/stepmania/src/GameState.cpp +++ b/stepmania/src/GameState.cpp @@ -169,34 +169,50 @@ void GameState::EndGame() Profile* pMachineProfile = PROFILEMAN->GetMachineProfile(); - for( int p=0; pGetProfile( (PlayerNumber)p ); - - pMachineProfile->m_iTotalPlaySeconds += iPlaySeconds; - pMachineProfile->m_iTotalGameplaySeconds += iGameplaySeconds; - - if( pPlayerProfile ) - pPlayerProfile->m_iTotalPlaySeconds += iPlaySeconds; - if( pPlayerProfile ) - pPlayerProfile->m_iTotalGameplaySeconds += iGameplaySeconds; - if( pPlayerProfile ) - pPlayerProfile->m_iTotalPlays++; - if( pPlayerProfile ) - pPlayerProfile->m_iCurrentCombo = - PREFSMAN->m_bComboContinuesBetweenSongs ? - GAMESTATE->m_CurStageStats.iCurCombo[p] : - 0; - } + int iGameplaySeconds = 0; + for( int i=0; im_iTotalPlaySeconds += iPlaySeconds; + pMachineProfile->m_iTotalGameplaySeconds += iGameplaySeconds; pMachineProfile->m_iTotalPlays++; pMachineProfile->m_iCurrentCombo = 0; + for( int p=0; pm_iNumSongsPlayedByPlayMode[ss.playMode]++; + pMachineProfile->m_iNumSongsPlayedByStyle[ss.style]++; + pMachineProfile->m_iNumSongsPlayedByDifficulty[ss.pSteps[p]->GetDifficulty()]++; + pMachineProfile->m_iNumSongsPlayedByMeter[ss.iMeter[p]]++; + } + + Profile* pPlayerProfile = PROFILEMAN->GetProfile( (PlayerNumber)p ); + if( pPlayerProfile ) + { + pPlayerProfile->m_iTotalPlaySeconds += iPlaySeconds; + pPlayerProfile->m_iTotalGameplaySeconds += iGameplaySeconds; + pPlayerProfile->m_iTotalPlays++; + pPlayerProfile->m_iCurrentCombo = + PREFSMAN->m_bComboContinuesBetweenSongs ? + GAMESTATE->m_CurStageStats.iCurCombo[p] : + 0; + + for( int i=0; im_iNumSongsPlayedByPlayMode[ss.playMode]++; + pPlayerProfile->m_iNumSongsPlayedByStyle[ss.style]++; + pPlayerProfile->m_iNumSongsPlayedByDifficulty[ss.pSteps[p]->GetDifficulty()]++; + pPlayerProfile->m_iNumSongsPlayedByMeter[ss.iMeter[p]]++; + } + } + } BOOKKEEPER->WriteToDisk(); PROFILEMAN->SaveMachineScoresToDisk(); diff --git a/stepmania/src/ProfileManager.cpp b/stepmania/src/ProfileManager.cpp index f7607e913c..da9e61a5a6 100644 --- a/stepmania/src/ProfileManager.cpp +++ b/stepmania/src/ProfileManager.cpp @@ -257,6 +257,16 @@ bool Profile::LoadFromIni( CString sIniPath ) ini.GetValue( "Profile", "TotalPlaySeconds", m_iTotalPlaySeconds ); ini.GetValue( "Profile", "TotalGameplaySeconds", m_iTotalGameplaySeconds ); ini.GetValue( "Profile", "CurrentCombo", m_iCurrentCombo ); + + unsigned i; + for( i=0; iGetStyleDefForStyle((Style)i)->m_szName), m_iNumSongsPlayedByStyle[i] ); + for( i=0; iGetStyleDefForStyle((Style)i)->m_szName), m_iNumSongsPlayedByDifficulty[i] ); + for( i=0; iGetStyleDefForStyle((Style)i)->m_szName), m_iNumSongsPlayedByMeter[i] ); return true; } @@ -271,6 +281,17 @@ bool Profile::SaveToIni( CString sIniPath ) ini.SetValue( "Profile", "TotalPlaySeconds", m_iTotalPlaySeconds ); ini.SetValue( "Profile", "TotalGameplaySeconds", m_iTotalGameplaySeconds ); ini.SetValue( "Profile", "CurrentCombo", m_iCurrentCombo ); + + unsigned i; + for( i=0; iGetStyleDefForStyle((Style)i)->m_szName), m_iNumSongsPlayedByStyle[i] ); + for( i=0; iGetStyleDefForStyle((Style)i)->m_szName), m_iNumSongsPlayedByDifficulty[i] ); + for( i=0; iGetStyleDefForStyle((Style)i)->m_szName), m_iNumSongsPlayedByMeter[i] ); + ini.WriteFile(); return true; } @@ -933,7 +954,7 @@ void ProfileManager::SaveStatsWebPageToDir( CString sDir, MemoryCard mc ) f.PutLine( "" ); } -#define PRINT_SECTION_START(szName) f.Write( ssprintf("

"szName" (top)

\n", szName) ) +#define PRINT_SECTION_START(szName) f.Write( ssprintf("

"szName" (top)

\n", szName) ) #define PRINT_SECTION_END f.Write( "\n" ) #define PRINT_DIV_START(szName) f.Write( ssprintf("
\n" "

%s

\n", szName) ) #define PRINT_DIV_START_ANCHOR(uAnchor,szName) f.Write( ssprintf("
\n" "

%s

\n", uAnchor, szName) ) @@ -951,33 +972,78 @@ void ProfileManager::SaveStatsWebPageToDir( CString sDir, MemoryCard mc ) // Print table of contents // { + f.Write( "

" PRODUCT_NAME_VER "

\n" ); PRINT_SECTION_START( "Table of Contents" ); - PRINT_DIV_START("Sections"); - PRINT_LINK( "My Statistics", "#My Statistics" ); + PRINT_DIV_START("Table of Contents"); + PRINT_LINK( "Statistics", "#Statistics" ); PRINT_LINK( "Popularity Lists", "#Popularity Lists" ); PRINT_LINK( "Difficulty Table", "#Difficulty Table" ); PRINT_LINK( "Song/Steps List", "#Song/Steps List" ); PRINT_DIV_END; - PRINT_SECTION_END; } // - // Print My Statistics + // Print Statistics // { - PRINT_SECTION_START( "My Statistics" ); - CString sName = pProfile->m_sLastUsedHighScoreName.empty() ? - pProfile->m_sName : - pProfile->m_sLastUsedHighScoreName; - PRINT_DIV_START( sName.c_str() ); - PRINT_LINE_S( "LastUsedHighScoreName", pProfile->m_sLastUsedHighScoreName ); - PRINT_LINE_B( "UsingProfileDefaultModifiers", pProfile->m_bUsingProfileDefaultModifiers ); - PRINT_LINE_S( "DefaultModifiers", pProfile->m_sDefaultModifiers ); - PRINT_LINE_I( "TotalPlays", pProfile->m_iTotalPlays ); - PRINT_LINE_I( "TotalPlaySeconds", pProfile->m_iTotalPlaySeconds ); - PRINT_LINE_I( "TotalGameplaySeconds", pProfile->m_iTotalGameplaySeconds ); - PRINT_LINE_I( "CurrentCombo", pProfile->m_iCurrentCombo ); - PRINT_DIV_END; + PRINT_SECTION_START( "Statistics" ); + + // Memory card stats + { + PRINT_DIV_START( "Memory Card" ); + PRINT_LINE_S( "Name", pProfile->m_sName ); + PRINT_LINE_S( "LastUsedHighScoreName", pProfile->m_sLastUsedHighScoreName ); + PRINT_LINE_B( "UsingProfileDefaultModifiers", pProfile->m_bUsingProfileDefaultModifiers ); + PRINT_LINE_S( "DefaultModifiers", pProfile->m_sDefaultModifiers ); + PRINT_LINE_I( "TotalPlays", pProfile->m_iTotalPlays ); + PRINT_LINE_I( "TotalPlaySeconds", pProfile->m_iTotalPlaySeconds ); + PRINT_LINE_I( "TotalGameplaySeconds", pProfile->m_iTotalGameplaySeconds ); + PRINT_LINE_I( "CurrentCombo", pProfile->m_iCurrentCombo ); + PRINT_DIV_END; + } + + // Num Songs Played by PlayMode + { + PRINT_DIV_START( "Num Songs Played by PlayMode" ); + for( int i=0; im_iNumSongsPlayedByPlayMode[i] ); + PRINT_DIV_END; + } + + // Num Songs Played by Style + { + PRINT_DIV_START( "Num Songs Played by Style" ); + for( int i=0; iGetStyleDefForStyle(style); + StepsType st = pStyleDef->m_StepsType; + if( !pStyleDef->m_bUsedForGameplay ) + continue; // skip + // only show if this style plays a StepsType that we're showing + if( find(vStepsTypesToShow.begin(),vStepsTypesToShow.end(),st) == vStepsTypesToShow.end() ) + continue; // skip + PRINT_LINE_I( pStyleDef->m_szName, pProfile->m_iNumSongsPlayedByStyle[i] ); + } + PRINT_DIV_END; + } + + // Num Songs Played by Difficulty + { + PRINT_DIV_START( "Num Songs Played by Difficulty" ); + for( int i=0; im_iNumSongsPlayedByDifficulty[i] ); + PRINT_DIV_END; + } + + // Num Songs Played by Meter + { + PRINT_DIV_START( "Num Songs Played by Meter" ); + for( int i=MAX_METER; i>=MIN_METER; i-- ) + PRINT_LINE_I( ssprintf("%d",i).c_str(), pProfile->m_iNumSongsPlayedByMeter[i] ); + PRINT_DIV_END; + } + PRINT_SECTION_END; } @@ -1035,6 +1101,7 @@ void ProfileManager::SaveStatsWebPageToDir( CString sDir, MemoryCard mc ) } PRINT_DIV_END; } + PRINT_SECTION_END; } diff --git a/stepmania/src/ProfileManager.h b/stepmania/src/ProfileManager.h index f67284ad91..f45b0fadeb 100644 --- a/stepmania/src/ProfileManager.h +++ b/stepmania/src/ProfileManager.h @@ -15,6 +15,7 @@ #include "PlayerNumber.h" #include "GameConstantsAndTypes.h" +#include "Style.h" struct Profile { @@ -29,6 +30,16 @@ struct Profile m_iTotalPlaySeconds = 0; m_iTotalGameplaySeconds = 0; m_iCurrentCombo = 0; + + int i; + for( i=0; im_CurStageStats.pSong = GAMESTATE->m_pCurSong; else GAMESTATE->m_CurStageStats.pSong = NULL; + GAMESTATE->m_CurStageStats.playMode = GAMESTATE->m_PlayMode; + GAMESTATE->m_CurStageStats.style = GAMESTATE->m_CurStyle; for( p=0; pIsPlayerEnabled(pn) && !GAMESTATE->m_CurStageStats.bFailed[pn]) GAMESTATE->m_CurStageStats.fAliveSeconds [pn] += fDeltaTime * GAMESTATE->m_SongOptions.m_fMusicRate; + // update fGameplaySeconds + GAMESTATE->m_CurStageStats.fGameplaySeconds += fDeltaTime; + // // Check for end of song // diff --git a/stepmania/src/StageStats.cpp b/stepmania/src/StageStats.cpp index aac8953e2d..5732323cd8 100644 --- a/stepmania/src/StageStats.cpp +++ b/stepmania/src/StageStats.cpp @@ -33,12 +33,14 @@ void StageStats::AddStats( const StageStats& other ) { pSong = NULL; // meaningless StageType = STAGE_INVALID; // meaningless - memset( fAliveSeconds, 0, sizeof(fAliveSeconds) ); + memset( fAliveSeconds, 0, sizeof(fAliveSeconds) ); // why? -Chris // weight long and marathon songs ASSERT( other.pSong ); const int iLengthMultiplier = SongManager::GetNumStagesForSong( other.pSong ); + fGameplaySeconds += other.fGameplaySeconds; + for( int p=0; p