diff --git a/stepmania/src/GameManager.cpp b/stepmania/src/GameManager.cpp index fe3015ee01..e4ca3199cc 100644 --- a/stepmania/src/GameManager.cpp +++ b/stepmania/src/GameManager.cpp @@ -20,6 +20,7 @@ #include "RageUtil.h" #include "NoteSkinManager.h" #include "SDL_keysym.h" // for SDLKeys +#include "ThemeManager.h" GameManager* GAMEMAN = NULL; // global and accessable from anywhere in our program @@ -2319,6 +2320,11 @@ CString GameManager::NotesTypeToString( StepsType nt ) return NotesTypes[nt].name; } +CString GameManager::NotesTypeToThemedString( StepsType nt ) +{ + return THEME->GetMetric( "StepsType", NotesTypeToString(nt) ); +} + Game GameManager::StringToGameType( CString sGameType ) { for( int i=0; i::const_iterator iter = m_StepsHighScores.begin(); + iter != m_StepsHighScores.end(); + iter++ ) + { + const Steps* pSteps = iter->first; + ASSERT( pSteps ); + const HighScoresForASteps& h = iter->second; + if( pSteps->m_StepsType == st ) + { + const float* fRadars = pSteps->GetRadarValues(); + int iPossibleDP = ScoreKeeperMAX2::GetPossibleDancePoints( fRadars ); + iTotal += (int)truncf( h.hs.GetTopScore().fPercentDP * iPossibleDP ); + } + } + + return iTotal; +} + CString Profile::GetProfileDisplayNameFromDir( CString sDir ) { Profile profile; @@ -197,6 +219,7 @@ int Profile::GetSongNumTimesPlayed( const Song* pSong ) const // void Profile::AddStepsHighScore( const Steps* pSteps, HighScore hs, int &iIndexOut ) { + ASSERT(pSteps); std::map::iterator iter = m_StepsHighScores.find( pSteps ); if( iter == m_StepsHighScores.end() ) m_StepsHighScores[pSteps].hs.AddHighScore( hs, iIndexOut ); // operator[] inserts into map @@ -206,12 +229,14 @@ void Profile::AddStepsHighScore( const Steps* pSteps, HighScore hs, int &iIndexO const HighScoreList& Profile::GetStepsHighScoreList( const Steps* pSteps ) const { + ASSERT(pSteps); /* We're const, but insert a blank entry anyway if the requested pointer doesn't exist. */ return ((Profile *) this)->m_StepsHighScores[pSteps].hs; } HighScoreList& Profile::GetStepsHighScoreList( const Steps* pSteps ) { + ASSERT(pSteps); std::map::iterator iter = m_StepsHighScores.find( pSteps ); if( iter == m_StepsHighScores.end() ) return m_StepsHighScores[pSteps].hs; // operator[] inserts into map @@ -221,6 +246,7 @@ HighScoreList& Profile::GetStepsHighScoreList( const Steps* pSteps ) int Profile::GetStepsNumTimesPlayed( const Steps* pSteps ) const { + ASSERT(pSteps); std::map::const_iterator iter = m_StepsHighScores.find( pSteps ); if( iter == m_StepsHighScores.end() ) return 0; diff --git a/stepmania/src/Profile.h b/stepmania/src/Profile.h index cee586ae5a..753369bb8c 100644 --- a/stepmania/src/Profile.h +++ b/stepmania/src/Profile.h @@ -70,6 +70,7 @@ public: CString GetDisplayTotalCaloriesBurned() const; int GetTotalNumSongsPlayed() const; int GetTotalNumSongsPassed() const; + int GetTotalHighScoreDancePointsForStepsType( StepsType st ) const; static CString GetProfileDisplayNameFromDir( CString sDir ); int GetSongNumTimesPlayed( const Song* pSong ) const; diff --git a/stepmania/src/ProfileManager.cpp b/stepmania/src/ProfileManager.cpp index ab83b62064..b373157bc6 100644 --- a/stepmania/src/ProfileManager.cpp +++ b/stepmania/src/ProfileManager.cpp @@ -485,7 +485,7 @@ HighScore ProfileManager::GetHighScoreForDifficulty( const Song *s, const StyleD const Steps* pSteps = s->GetStepsByDifficulty( st->m_StepsType, dc ); - if( PROFILEMAN->IsUsingProfile(slot) ) + if( pSteps && PROFILEMAN->IsUsingProfile(slot) ) return PROFILEMAN->GetProfile(slot)->GetStepsHighScoreList(pSteps).GetTopScore(); else return HighScore(); diff --git a/stepmania/src/ScoreKeeperMAX2.cpp b/stepmania/src/ScoreKeeperMAX2.cpp index 3f3bd1b3a9..cac1d36faf 100644 --- a/stepmania/src/ScoreKeeperMAX2.cpp +++ b/stepmania/src/ScoreKeeperMAX2.cpp @@ -37,6 +37,7 @@ ScoreKeeperMAX2::ScoreKeeperMAX2( const vector& apSongs, const vectorGetNoteData( ¬edata ); @@ -65,12 +66,16 @@ ScoreKeeperMAX2::ScoreKeeperMAX2( const vector& apSongs, const vectorGetCurrentStyleDef()->m_StepsType, fStartBeat, fEndBeat ); } + + float fRadarValuesPostModifiers[NUM_RADAR_CATEGORIES]; + FOREACH_RadarCategory( rc ) + fRadarValuesPostModifiers[rc] += NoteDataUtil::GetRadarValue( playerNoteDataPostModifiers, rc, pSong->m_fMusicLengthSeconds ); - iTotalPossibleDancePoints += this->GetPossibleDancePoints( playerNoteData, playerNoteDataPostModifiers ); + iTotalPossibleDancePoints += this->GetPossibleDancePoints( pSteps->GetRadarValues(), fRadarValuesPostModifiers ); } g_CurStageStats.iPossibleDancePoints[pn_] = iTotalPossibleDancePoints; @@ -413,19 +418,26 @@ void ScoreKeeperMAX2::HandleHoldScore( HoldNoteScore holdScore, TapNoteScore tap } -int ScoreKeeperMAX2::GetPossibleDancePoints( const NoteData &preNoteData, const NoteData &postNoteData ) +int ScoreKeeperMAX2::GetPossibleDancePoints( const float* fRadars ) { /* Note that, if Marvelous timing is disabled or not active (not course mode), * PERFECT will be used instead. */ + int NumTaps = fRadars[RADAR_NUM_TAPS_AND_HOLDS]; + int NumHolds = fRadars[RADAR_NUM_HOLDS]; + return NumTaps*TapNoteScoreToDancePoints(TNS_MARVELOUS)+ + NumHolds*HoldNoteScoreToDancePoints(HNS_OK); +} + +int ScoreKeeperMAX2::GetPossibleDancePoints( const float* fOriginalRadars, const float* fPostRadars ) +{ /* * The logic here is that if you use a modifier that adds notes, you should have to * hit the new notes to get a high grade. However, if you use one that removes notes, * they should simply be counted as misses. */ - int NumTaps = max( preNoteData.GetNumRowsWithTapOrHoldHead(), postNoteData.GetNumRowsWithTapOrHoldHead() ); - int NumHolds = max( preNoteData.GetNumHoldNotes(), postNoteData.GetNumHoldNotes() ); - return NumTaps*TapNoteScoreToDancePoints(TNS_MARVELOUS)+ - NumHolds*HoldNoteScoreToDancePoints(HNS_OK); + return max( + GetPossibleDancePoints(fOriginalRadars), + GetPossibleDancePoints(fPostRadars) ); } diff --git a/stepmania/src/ScoreKeeperMAX2.h b/stepmania/src/ScoreKeeperMAX2.h index e9f18d64d4..3560bfc4d8 100644 --- a/stepmania/src/ScoreKeeperMAX2.h +++ b/stepmania/src/ScoreKeeperMAX2.h @@ -47,10 +47,15 @@ public: void HandleTapRowScore( TapNoteScore scoreOfLastTap, int iNumTapsInRow ); void HandleHoldScore( HoldNoteScore holdScore, TapNoteScore tapScore ); + // This must be calculated using only cached radar values so that we can + // do it quickly. + static int GetPossibleDancePoints( const float* fRadars ); + static int GetPossibleDancePoints( const float* fOriginalRadars, const float* fPostRadars ); + private: - int TapNoteScoreToDancePoints( TapNoteScore tns ); - int HoldNoteScoreToDancePoints( HoldNoteScore hns ); - int GetPossibleDancePoints( const NoteData &preNoteData, const NoteData &postNoteData ); + static int TapNoteScoreToDancePoints( TapNoteScore tns ); + static int HoldNoteScoreToDancePoints( HoldNoteScore hns ); + }; #endif diff --git a/stepmania/src/ScreenEnding.cpp b/stepmania/src/ScreenEnding.cpp index fa03ee62cf..307fa824f3 100644 --- a/stepmania/src/ScreenEnding.cpp +++ b/stepmania/src/ScreenEnding.cpp @@ -23,6 +23,8 @@ #include "GameState.h" #include "MemoryCardManager.h" #include "RageLog.h" +#include "StyleDef.h" +#include "GameManager.h" #define SCROLL_DELAY THEME->GetMetricF("ScreenEnding","ScrollDelay") @@ -30,28 +32,32 @@ #define TEXT_ZOOM THEME->GetMetricF("ScreenEnding","TextZoom") -CString STATS_LINE_TITLE[NUM_ENDING_STATS_LINES] = { - "Total Calories", - "Total Songs Played", - "Current Combo", -}; + +CString GetStatsLineTitle( PlayerNumber pn, int iLine ) +{ + static const CString s[NUM_ENDING_STATS_LINES] = { + "Total %s Points", + "Total Calories", + "Total Songs Played", + "Current Combo", + }; + StepsType st = GAMESTATE->GetCurrentStyleDef()->m_StepsType; + return ssprintf( s[iLine], GAMEMAN->NotesTypeToThemedString(st).c_str() ); +} CString GetStatsLineValue( PlayerNumber pn, int iLine ) { Profile* pProfile = PROFILEMAN->GetProfile( pn ); ASSERT( pProfile ); + StepsType st = GAMESTATE->GetCurrentStyleDef()->m_StepsType; switch( iLine ) { - case 0: - return pProfile->GetDisplayTotalCaloriesBurned(); - case 1: - return ssprintf( "%d", pProfile->GetTotalNumSongsPlayed() ); // fixme - case 2: - return ssprintf( "%d", pProfile->m_iCurrentCombo ); - default: - ASSERT(0); - return ""; + case 0: return Commify( pProfile->GetTotalHighScoreDancePointsForStepsType(st) ); + case 1: return pProfile->GetDisplayTotalCaloriesBurned(); + case 2: return Commify( pProfile->GetTotalNumSongsPlayed() ); + case 3: return Commify( pProfile->m_iCurrentCombo ); + default: ASSERT(0); return ""; } } @@ -85,7 +91,7 @@ ScreenEnding::ScreenEnding( CString sClassName ) : ScreenAttract( sClassName, fa for( int i=0; iGetPathToF("ScreenEnding stats title") ); - m_textStatsTitle[p][i].SetText( STATS_LINE_TITLE[i] ); + m_textStatsTitle[p][i].SetText( GetStatsLineTitle((PlayerNumber)p, i) ); m_textStatsTitle[p][i].SetName( ssprintf("StatsTitleP%dLine%d",p+1,i+1) ); SET_XY_AND_ON_COMMAND( m_textStatsTitle[p][i] ); this->AddChild( &m_textStatsTitle[p][i] ); diff --git a/stepmania/src/ScreenEnding.h b/stepmania/src/ScreenEnding.h index a5fbcbcfe2..4abc179ed0 100644 --- a/stepmania/src/ScreenEnding.h +++ b/stepmania/src/ScreenEnding.h @@ -24,7 +24,7 @@ public: private: BitmapText m_textPlayerName[NUM_PLAYERS]; -#define NUM_ENDING_STATS_LINES 3 // Total calories burned, total songs played, current combo +#define NUM_ENDING_STATS_LINES 4 BitmapText m_textStatsTitle[NUM_PLAYERS][NUM_ENDING_STATS_LINES]; BitmapText m_textStatsValue[NUM_PLAYERS][NUM_ENDING_STATS_LINES];