Store the highest song grade in the HighScoreList.

This commit is contained in:
Steve Checkoway
2007-02-25 06:59:27 +00:00
parent 0f58d743f9
commit bf77a61057
2 changed files with 18 additions and 4 deletions
+16 -3
View File
@@ -236,6 +236,7 @@ void HighScoreList::Init()
{ {
iNumTimesPlayed = 0; iNumTimesPlayed = 0;
vHighScores.clear(); vHighScores.clear();
HighGrade = Grade_NoData;
} }
void HighScoreList::AddHighScore( HighScore hs, int &iIndexOut, bool bIsMachine ) void HighScoreList::AddHighScore( HighScore hs, int &iIndexOut, bool bIsMachine )
@@ -261,6 +262,7 @@ void HighScoreList::AddHighScore( HighScore hs, int &iIndexOut, bool bIsMachine
if( !bIsMachine ) if( !bIsMachine )
ClampSize( bIsMachine ); ClampSize( bIsMachine );
} }
HighGrade = min( hs.GetGrade(), HighGrade );
} }
void HighScoreList::IncrementPlayCount( DateTime _dtLastPlayed ) void HighScoreList::IncrementPlayCount( DateTime _dtLastPlayed )
@@ -289,6 +291,8 @@ XNode* HighScoreList::CreateNode() const
pNode->AppendChild( "NumTimesPlayed", iNumTimesPlayed ); pNode->AppendChild( "NumTimesPlayed", iNumTimesPlayed );
pNode->AppendChild( "LastPlayed", dtLastPlayed.GetString() ); pNode->AppendChild( "LastPlayed", dtLastPlayed.GetString() );
if( HighGrade != Grade_NoData )
pNode->AppendChild( "HighGrade", GradeToString(HighGrade) );
for( unsigned i=0; i<vHighScores.size(); i++ ) for( unsigned i=0; i<vHighScores.size(); i++ )
{ {
@@ -306,17 +310,24 @@ void HighScoreList::LoadFromNode( const XNode* pHighScoreList )
ASSERT( pHighScoreList->GetName() == "HighScoreList" ); ASSERT( pHighScoreList->GetName() == "HighScoreList" );
FOREACH_CONST_Child( pHighScoreList, p ) FOREACH_CONST_Child( pHighScoreList, p )
{ {
if( p->GetName() == "NumTimesPlayed" ) const RString &name = p->GetName();
if( name == "NumTimesPlayed" )
{ {
p->GetTextValue( iNumTimesPlayed ); p->GetTextValue( iNumTimesPlayed );
} }
else if( p->GetName() == "LastPlayed" ) else if( name == "LastPlayed" )
{ {
RString s; RString s;
p->GetTextValue( s ); p->GetTextValue( s );
dtLastPlayed.FromString( s ); dtLastPlayed.FromString( s );
} }
else if( p->GetName() == "HighScore" ) else if( name == "HighGrade" )
{
RString s;
p->GetTextValue( s );
HighGrade = StringToGrade( s );
}
else if( name == "HighScore" )
{ {
vHighScores.resize( vHighScores.size()+1 ); vHighScores.resize( vHighScores.size()+1 );
vHighScores.back().LoadFromNode( p ); vHighScores.back().LoadFromNode( p );
@@ -324,6 +335,8 @@ void HighScoreList::LoadFromNode( const XNode* pHighScoreList )
// ignore all high scores that are 0 // ignore all high scores that are 0
if( vHighScores.back().GetScore() == 0 ) if( vHighScores.back().GetScore() == 0 )
vHighScores.pop_back(); vHighScores.pop_back();
else
HighGrade = min( vHighScores.back().GetGrade(), HighGrade );
} }
} }
} }
+2 -1
View File
@@ -72,7 +72,7 @@ struct HighScoreList
public: public:
HighScoreList() HighScoreList()
{ {
iNumTimesPlayed = 0; Init();
} }
void Init(); void Init();
@@ -96,6 +96,7 @@ public:
void LoadFromNode( const XNode* pNode ); void LoadFromNode( const XNode* pNode );
vector<HighScore> vHighScores; vector<HighScore> vHighScores;
Grade HighGrade;
private: private:
int iNumTimesPlayed; int iNumTimesPlayed;
DateTime dtLastPlayed; // meaningless if iNumTimesPlayed == 0 DateTime dtLastPlayed; // meaningless if iNumTimesPlayed == 0