hide iScore

This commit is contained in:
Glenn Maynard
2005-08-12 02:37:04 +00:00
parent aa04fe60dd
commit d3bd7a7723
8 changed files with 45 additions and 41 deletions
+1 -1
View File
@@ -613,7 +613,7 @@ static HighScore MakeRandomHighScore( float fPercentDP )
HighScore hs; HighScore hs;
hs.SetName( "FAKE" ); hs.SetName( "FAKE" );
hs.SetGrade( (Grade)SCALE( rand()%5, 0, 4, GRADE_TIER01, GRADE_TIER05 ) ); hs.SetGrade( (Grade)SCALE( rand()%5, 0, 4, GRADE_TIER01, GRADE_TIER05 ) );
hs.iScore = rand()%100*1000; hs.SetScore( rand()%100*1000 );
hs.fPercentDP = fPercentDP; hs.fPercentDP = fPercentDP;
hs.fSurviveSeconds = randomf( 30.0f, 100.0f ); hs.fSurviveSeconds = randomf( 30.0f, 100.0f );
PlayerOptions po; PlayerOptions po;
+6 -6
View File
@@ -1393,7 +1393,7 @@ void GameState::GetRankingFeats( PlayerNumber pn, vector<RankingFeat> &asFeatsOu
feat.pStringToFill = hs.GetNameMutable(); feat.pStringToFill = hs.GetNameMutable();
feat.grade = hs.GetGrade(); feat.grade = hs.GetGrade();
feat.fPercentDP = hs.fPercentDP; feat.fPercentDP = hs.fPercentDP;
feat.iScore = hs.iScore; feat.iScore = hs.GetScore();
if( pSong->HasBanner() ) if( pSong->HasBanner() )
feat.Banner = pSong->GetBannerPath(); feat.Banner = pSong->GetBannerPath();
@@ -1421,7 +1421,7 @@ void GameState::GetRankingFeats( PlayerNumber pn, vector<RankingFeat> &asFeatsOu
feat.pStringToFill = hs.GetNameMutable(); feat.pStringToFill = hs.GetNameMutable();
feat.grade = hs.GetGrade(); feat.grade = hs.GetGrade();
feat.fPercentDP = hs.fPercentDP; feat.fPercentDP = hs.fPercentDP;
feat.iScore = hs.iScore; feat.iScore = hs.GetScore();
// XXX: temporary hack // XXX: temporary hack
if( pSong->HasBackground() ) if( pSong->HasBackground() )
@@ -1454,7 +1454,7 @@ void GameState::GetRankingFeats( PlayerNumber pn, vector<RankingFeat> &asFeatsOu
feat.Feat = ssprintf("MR #%d in Type %c (%d)", j+1, 'A'+rc, stats.GetAverageMeter(pn) ); feat.Feat = ssprintf("MR #%d in Type %c (%d)", j+1, 'A'+rc, stats.GetAverageMeter(pn) );
feat.pStringToFill = hs.GetNameMutable(); feat.pStringToFill = hs.GetNameMutable();
feat.grade = GRADE_NO_DATA; feat.grade = GRADE_NO_DATA;
feat.iScore = hs.iScore; feat.iScore = hs.GetScore();
feat.fPercentDP = hs.fPercentDP; feat.fPercentDP = hs.fPercentDP;
asFeatsOut.push_back( feat ); asFeatsOut.push_back( feat );
} }
@@ -1477,7 +1477,7 @@ void GameState::GetRankingFeats( PlayerNumber pn, vector<RankingFeat> &asFeatsOu
feat.Feat = ssprintf("PR #%d in Type %c (%d)", j+1, 'A'+rc, stats.GetAverageMeter(pn) ); feat.Feat = ssprintf("PR #%d in Type %c (%d)", j+1, 'A'+rc, stats.GetAverageMeter(pn) );
feat.pStringToFill = hs.GetNameMutable(); feat.pStringToFill = hs.GetNameMutable();
feat.grade = GRADE_NO_DATA; feat.grade = GRADE_NO_DATA;
feat.iScore = hs.iScore; feat.iScore = hs.GetScore();
feat.fPercentDP = hs.fPercentDP; feat.fPercentDP = hs.fPercentDP;
asFeatsOut.push_back( feat ); asFeatsOut.push_back( feat );
} }
@@ -1514,7 +1514,7 @@ void GameState::GetRankingFeats( PlayerNumber pn, vector<RankingFeat> &asFeatsOu
feat.Feat += " " + CourseDifficultyToThemedString(cd); feat.Feat += " " + CourseDifficultyToThemedString(cd);
feat.pStringToFill = hs.GetNameMutable(); feat.pStringToFill = hs.GetNameMutable();
feat.grade = GRADE_NO_DATA; feat.grade = GRADE_NO_DATA;
feat.iScore = hs.iScore; feat.iScore = hs.GetScore();
feat.fPercentDP = hs.fPercentDP; feat.fPercentDP = hs.fPercentDP;
if( pCourse->HasBanner() ) if( pCourse->HasBanner() )
feat.Banner = pCourse->m_sBannerPath; feat.Banner = pCourse->m_sBannerPath;
@@ -1538,7 +1538,7 @@ void GameState::GetRankingFeats( PlayerNumber pn, vector<RankingFeat> &asFeatsOu
feat.Feat = ssprintf("PR #%d in %s", i+1, pCourse->GetDisplayFullTitle().c_str() ); feat.Feat = ssprintf("PR #%d in %s", i+1, pCourse->GetDisplayFullTitle().c_str() );
feat.pStringToFill = hs.GetNameMutable(); feat.pStringToFill = hs.GetNameMutable();
feat.grade = GRADE_NO_DATA; feat.grade = GRADE_NO_DATA;
feat.iScore = hs.iScore; feat.iScore = hs.GetScore();
feat.fPercentDP = hs.fPercentDP; feat.fPercentDP = hs.fPercentDP;
if( pCourse->HasBanner() ) if( pCourse->HasBanner() )
feat.Banner = pCourse->m_sBannerPath; feat.Banner = pCourse->m_sBannerPath;
+25 -23
View File
@@ -12,6 +12,8 @@
struct HighScoreImpl struct HighScoreImpl
{ {
CString sName; // name that shows in the machine's ranking screen CString sName; // name that shows in the machine's ranking screen
Grade grade;
int iScore;
void Unset(); void Unset();
void AppendChildren( XNode *pNode ) const; void AppendChildren( XNode *pNode ) const;
@@ -25,6 +27,8 @@ bool HighScoreImpl::operator==( const HighScoreImpl& other ) const
{ {
#define COMPARE(x) if( x!=other.x ) return false; #define COMPARE(x) if( x!=other.x ) return false;
COMPARE( sName ); COMPARE( sName );
COMPARE( grade );
COMPARE( iScore );
#undef COMPARE #undef COMPARE
return true; return true;
@@ -33,17 +37,29 @@ bool HighScoreImpl::operator==( const HighScoreImpl& other ) const
void HighScoreImpl::Unset() void HighScoreImpl::Unset()
{ {
sName = ""; sName = "";
grade = GRADE_NO_DATA;
iScore = 0;
} }
void HighScoreImpl::AppendChildren( XNode *pNode ) const void HighScoreImpl::AppendChildren( XNode *pNode ) const
{ {
pNode->AppendChild( "Name", IsRankingToFillIn(sName) ? CString("") : sName ); pNode->AppendChild( "Name", IsRankingToFillIn(sName) ? CString("") : sName );
pNode->AppendChild( "Grade", GradeToString(grade) );
pNode->AppendChild( "Score", iScore );
} }
void HighScoreImpl::LoadFromNode( const XNode *pNode ) void HighScoreImpl::LoadFromNode( const XNode *pNode )
{ {
CString s;
pNode->GetChildValue( "Name", sName ); pNode->GetChildValue( "Name", sName );
pNode->GetChildValue( "Grade", s );
grade = StringToGrade( s );
pNode->GetChildValue( "Score", iScore );
/* Validate input. */
grade = clamp( grade, GRADE_TIER01, GRADE_FAILED );
} }
REGISTER_CLASS_TRAITS( HighScoreImpl, new HighScoreImpl(*pCopy) ) REGISTER_CLASS_TRAITS( HighScoreImpl, new HighScoreImpl(*pCopy) )
@@ -57,8 +73,6 @@ HighScore::HighScore()
void HighScore::Unset() void HighScore::Unset()
{ {
m_Impl->Unset(); m_Impl->Unset();
grade = GRADE_NO_DATA;
iScore = 0;
fPercentDP = 0; fPercentDP = 0;
fSurviveSeconds = 0; fSurviveSeconds = 0;
sModifiers = ""; sModifiers = "";
@@ -74,6 +88,10 @@ void HighScore::Unset()
CString HighScore::GetName() const { return m_Impl->sName; } CString HighScore::GetName() const { return m_Impl->sName; }
void HighScore::SetName( const CString &sName ) { m_Impl->sName = sName; } void HighScore::SetName( const CString &sName ) { m_Impl->sName = sName; }
Grade HighScore::GetGrade() const { return m_Impl->grade; }
void HighScore::SetGrade( Grade g ) { m_Impl->grade = g; }
int HighScore::GetScore() const { return m_Impl->iScore; }
void HighScore::SetScore( int iScore ) { m_Impl->iScore = iScore; }
/* We normally don't give direct access to the members. We need this one /* We normally don't give direct access to the members. We need this one
* for NameToFillIn; use a special accessor so it's easy to find where this * for NameToFillIn; use a special accessor so it's easy to find where this
@@ -87,16 +105,16 @@ bool HighScore::operator>=( const HighScore& other ) const
if( PREFSMAN->m_bPercentageScoring ) if( PREFSMAN->m_bPercentageScoring )
{ {
if( fPercentDP == other.fPercentDP ) if( fPercentDP == other.fPercentDP )
return grade >= other.grade; return GetGrade() >= other.GetGrade();
else else
return fPercentDP >= other.fPercentDP; return fPercentDP >= other.fPercentDP;
} }
else else
{ {
if( iScore == other.iScore ) if( GetScore() == other.GetScore() )
return grade >= other.grade; return GetGrade() >= other.GetGrade();
else else
return iScore >= other.iScore; return GetScore() >= other.GetScore();
} }
} }
@@ -105,8 +123,6 @@ bool HighScore::operator==( const HighScore& other ) const
if( *m_Impl != *other.m_Impl ) if( *m_Impl != *other.m_Impl )
return false; return false;
#define COMPARE(x) if( x!=other.x ) return false; #define COMPARE(x) if( x!=other.x ) return false;
COMPARE( grade );
COMPARE( iScore );
COMPARE( fPercentDP ); COMPARE( fPercentDP );
COMPARE( fSurviveSeconds ); COMPARE( fSurviveSeconds );
COMPARE( sModifiers ); COMPARE( sModifiers );
@@ -131,8 +147,6 @@ XNode* HighScore::CreateNode() const
// TRICKY: Don't write "name to fill in" markers. // TRICKY: Don't write "name to fill in" markers.
m_Impl->AppendChildren( pNode ); m_Impl->AppendChildren( pNode );
pNode->AppendChild( "Grade", GradeToString(grade) );
pNode->AppendChild( "Score", iScore );
pNode->AppendChild( "PercentDP", fPercentDP ); pNode->AppendChild( "PercentDP", fPercentDP );
pNode->AppendChild( "SurviveSeconds", fSurviveSeconds ); pNode->AppendChild( "SurviveSeconds", fSurviveSeconds );
pNode->AppendChild( "Modifiers", sModifiers ); pNode->AppendChild( "Modifiers", sModifiers );
@@ -157,16 +171,7 @@ void HighScore::LoadFromNode( const XNode* pNode )
{ {
ASSERT( pNode->m_sName == "HighScore" ); ASSERT( pNode->m_sName == "HighScore" );
CString s;
m_Impl->LoadFromNode( pNode ); m_Impl->LoadFromNode( pNode );
pNode->GetChildValue( "Grade", s );
/* Pre-a19 compatibility; remove eventually */
if( IsAnInt(s) )
grade = (Grade) atoi( s );
else
grade = StringToGrade( s );
pNode->GetChildValue( "Score", iScore );
pNode->GetChildValue( "PercentDP", fPercentDP ); pNode->GetChildValue( "PercentDP", fPercentDP );
pNode->GetChildValue( "SurviveSeconds", fSurviveSeconds ); pNode->GetChildValue( "SurviveSeconds", fSurviveSeconds );
pNode->GetChildValue( "Modifiers", sModifiers ); pNode->GetChildValue( "Modifiers", sModifiers );
@@ -186,9 +191,6 @@ void HighScore::LoadFromNode( const XNode* pNode )
if( pRadarValues ) if( pRadarValues )
radarValues.LoadFromNode( pRadarValues ); radarValues.LoadFromNode( pRadarValues );
pNode->GetChildValue( "LifeRemainingSeconds", fLifeRemainingSeconds ); pNode->GetChildValue( "LifeRemainingSeconds", fLifeRemainingSeconds );
/* Validate input. */
grade = clamp( grade, GRADE_TIER01, GRADE_FAILED );
} }
CString HighScore::GetDisplayName() const CString HighScore::GetDisplayName() const
@@ -289,7 +291,7 @@ void HighScoreList::LoadFromNode( const XNode* pHighScoreList )
vHighScores.back().LoadFromNode( p ); vHighScores.back().LoadFromNode( p );
// ignore all high scores that are 0 // ignore all high scores that are 0
if( vHighScores.back().iScore == 0 ) if( vHighScores.back().GetScore() == 0 )
vHighScores.pop_back(); vHighScores.pop_back();
} }
} }
+4 -2
View File
@@ -19,8 +19,10 @@ struct HighScore
CString *GetNameMutable(); CString *GetNameMutable();
const CString *GetNameMutable() const { return const_cast<CString *> (const_cast<HighScore *>(this)->GetNameMutable()); } const CString *GetNameMutable() const { return const_cast<CString *> (const_cast<HighScore *>(this)->GetNameMutable()); }
Grade grade; Grade GetGrade() const;
int iScore; void SetGrade( Grade g );
int GetScore() const;
void SetScore( int iScore );
float fPercentDP; float fPercentDP;
float fSurviveSeconds; float fSurviveSeconds;
CString sModifiers; CString sModifiers;
+1 -1
View File
@@ -898,7 +898,7 @@ void ScreenEvaluation::CommitScores(
HighScore &hs = m_HighScore[p]; HighScore &hs = m_HighScore[p];
hs.SetName( RANKING_TO_FILL_IN_MARKER[p] ); hs.SetName( RANKING_TO_FILL_IN_MARKER[p] );
hs.SetGrade( stageStats.m_player[p].GetGrade() ); hs.SetGrade( stageStats.m_player[p].GetGrade() );
hs.iScore = stageStats.m_player[p].iScore; hs.SetScore( stageStats.m_player[p].iScore );
hs.fPercentDP = stageStats.m_player[p].GetPercentDancePoints(); hs.fPercentDP = stageStats.m_player[p].GetPercentDancePoints();
hs.fSurviveSeconds = stageStats.m_player[p].fAliveSeconds; hs.fSurviveSeconds = stageStats.m_player[p].fAliveSeconds;
hs.sModifiers = GAMESTATE->m_pPlayerState[p]->m_PlayerOptions.GetString(); hs.sModifiers = GAMESTATE->m_pPlayerState[p]->m_PlayerOptions.GetString();
+3 -3
View File
@@ -63,7 +63,7 @@ void HighScoreWheelItem::Load( int iRankIndex, const HighScore& hs )
if( PREFSMAN->m_bPercentageScoring ) if( PREFSMAN->m_bPercentageScoring )
m_textScore.SetText( PercentageDisplay::FormatPercentScore(hs.fPercentDP) ); m_textScore.SetText( PercentageDisplay::FormatPercentScore(hs.fPercentDP) );
else else
m_textScore.SetText( ssprintf("%i", hs.iScore) ); m_textScore.SetText( ssprintf("%i", hs.GetScore()) );
m_textScore.SetShadowLength( 2 ); m_textScore.SetShadowLength( 2 );
this->AddChild( &m_textScore ); this->AddChild( &m_textScore );
SET_XY_AND_ON_COMMAND( m_textScore ); SET_XY_AND_ON_COMMAND( m_textScore );
@@ -171,7 +171,7 @@ ScreenNameEntryTraditional::ScreenNameEntryTraditional( CString sClassName ) : S
HighScore hs; HighScore hs;
hs.SetGrade( GRADE_TIER03 ); hs.SetGrade( GRADE_TIER03 );
hs.fPercentDP = ss.m_player[p].GetPercentDancePoints(); hs.fPercentDP = ss.m_player[p].GetPercentDancePoints();
hs.iScore = ss.m_player[p].iScore; hs.SetScore( ss.m_player[p].iScore );
hs.dateTime = DateTime::GetNowDateTime(); hs.dateTime = DateTime::GetNowDateTime();
int a, b; int a, b;
PROFILEMAN->AddStepsScore( ss.vpPlayedSongs[0], pSteps, p, hs, a, b ); PROFILEMAN->AddStepsScore( ss.vpPlayedSongs[0], pSteps, p, hs, a, b );
@@ -361,7 +361,7 @@ void ScreenNameEntryTraditional::Init()
const HighScore &hs = hsl.vHighScores[h]; const HighScore &hs = hsl.vHighScores[h];
if( hs.GetName() == RANKING_TO_FILL_IN_MARKER[p] && if( hs.GetName() == RANKING_TO_FILL_IN_MARKER[p] &&
hs.fPercentDP == fPercentDP && hs.fPercentDP == fPercentDP &&
hs.iScore == iScore ) hs.GetScore() == iScore )
{ {
iHighScoreIndex = h; iHighScoreIndex = h;
break; break;
+3 -3
View File
@@ -769,7 +769,7 @@ float ScreenRanking::SetPage( PageToShow pts )
} }
m_textNames[l].SetText( hs.GetDisplayName() ); m_textNames[l].SetText( hs.GetDisplayName() );
m_textScores[l].SetText( ssprintf("%09i",hs.iScore) ); m_textScores[l].SetText( ssprintf("%09i",hs.GetScore()) );
m_textNames[l].SetDiffuse( STEPS_TYPE_COLOR.GetValue(pts.colorIndex) ); m_textNames[l].SetDiffuse( STEPS_TYPE_COLOR.GetValue(pts.colorIndex) );
m_textScores[l].SetDiffuse( STEPS_TYPE_COLOR.GetValue(pts.colorIndex) ); m_textScores[l].SetDiffuse( STEPS_TYPE_COLOR.GetValue(pts.colorIndex) );
@@ -811,13 +811,13 @@ float ScreenRanking::SetPage( PageToShow pts )
m_textNames[l].SetText( hs.GetDisplayName() ); m_textNames[l].SetText( hs.GetDisplayName() );
if( pts.pCourse->IsOni() ) if( pts.pCourse->IsOni() )
{ {
m_textPoints[l].SetText( ssprintf("%04d",hs.iScore) ); m_textPoints[l].SetText( ssprintf("%04d",hs.GetScore()) );
m_textTime[l].SetText( SecondsToMMSSMsMs(hs.fSurviveSeconds) ); m_textTime[l].SetText( SecondsToMMSSMsMs(hs.fSurviveSeconds) );
m_textScores[l].SetText( "" ); m_textScores[l].SetText( "" );
} else { } else {
m_textPoints[l].SetText( "" ); m_textPoints[l].SetText( "" );
m_textTime[l].SetText( "" ); m_textTime[l].SetText( "" );
m_textScores[l].SetText( ssprintf("%09d",hs.iScore) ); m_textScores[l].SetText( ssprintf("%09d",hs.GetScore()) );
} }
m_textNames[l].SetDiffuse( STEPS_TYPE_COLOR.GetValue(pts.colorIndex) ); m_textNames[l].SetDiffuse( STEPS_TYPE_COLOR.GetValue(pts.colorIndex) );
m_textPoints[l].SetDiffuse( STEPS_TYPE_COLOR.GetValue(pts.colorIndex) ); m_textPoints[l].SetDiffuse( STEPS_TYPE_COLOR.GetValue(pts.colorIndex) );
+2 -2
View File
@@ -1301,7 +1301,7 @@ void ScreenSelectMusic::AfterStepsChange( const vector<PlayerNumber> &vpns )
if( pSteps ) if( pSteps )
{ {
Profile* pProfile = PROFILEMAN->IsPersistentProfile(pn) ? PROFILEMAN->GetProfile(pn) : PROFILEMAN->GetMachineProfile(); Profile* pProfile = PROFILEMAN->IsPersistentProfile(pn) ? PROFILEMAN->GetProfile(pn) : PROFILEMAN->GetMachineProfile();
iScore = pProfile->GetStepsHighScoreList(pSong,pSteps).GetTopScore().iScore; iScore = pProfile->GetStepsHighScoreList(pSong,pSteps).GetTopScore().GetScore();
} }
m_textHighScore[pn].SetText( ssprintf("%*i", NUM_SCORE_DIGITS, iScore) ); m_textHighScore[pn].SetText( ssprintf("%*i", NUM_SCORE_DIGITS, iScore) );
@@ -1346,7 +1346,7 @@ void ScreenSelectMusic::AfterTrailChange( const vector<PlayerNumber> &vpns )
if( pTrail ) if( pTrail )
{ {
Profile* pProfile = PROFILEMAN->IsPersistentProfile(pn) ? PROFILEMAN->GetProfile(pn) : PROFILEMAN->GetMachineProfile(); Profile* pProfile = PROFILEMAN->IsPersistentProfile(pn) ? PROFILEMAN->GetProfile(pn) : PROFILEMAN->GetMachineProfile();
iScore = pProfile->GetCourseHighScoreList(pCourse,pTrail).GetTopScore().iScore; iScore = pProfile->GetCourseHighScoreList(pCourse,pTrail).GetTopScore().GetScore();
} }
m_textHighScore[pn].SetText( ssprintf("%*i", NUM_SCORE_DIGITS, iScore) ); m_textHighScore[pn].SetText( ssprintf("%*i", NUM_SCORE_DIGITS, iScore) );