hidden HighScore::sName
This commit is contained in:
@@ -611,7 +611,7 @@ void GameCommand::Apply( PlayerNumber pn ) const
|
||||
static HighScore MakeRandomHighScore( float fPercentDP )
|
||||
{
|
||||
HighScore hs;
|
||||
hs.sName = "FAKE";
|
||||
hs.SetName( "FAKE" );
|
||||
hs.grade = (Grade)SCALE( rand()%5, 0, 4, GRADE_TIER01, GRADE_TIER05 );
|
||||
hs.iScore = rand()%100*1000;
|
||||
hs.fPercentDP = fPercentDP;
|
||||
|
||||
+12
-12
@@ -1382,7 +1382,7 @@ void GameState::GetRankingFeats( PlayerNumber pn, vector<RankingFeat> &asFeatsOu
|
||||
{
|
||||
HighScore &hs = hsl.vHighScores[j];
|
||||
|
||||
if( hs.sName != RANKING_TO_FILL_IN_MARKER[pn] )
|
||||
if( hs.GetName() != RANKING_TO_FILL_IN_MARKER[pn] )
|
||||
continue;
|
||||
|
||||
RankingFeat feat;
|
||||
@@ -1390,7 +1390,7 @@ void GameState::GetRankingFeats( PlayerNumber pn, vector<RankingFeat> &asFeatsOu
|
||||
feat.pSong = pSong;
|
||||
feat.pSteps = pSteps;
|
||||
feat.Feat = ssprintf("MR #%d in %s %s", j+1, pSong->GetTranslitMainTitle().c_str(), DifficultyToString(pSteps->GetDifficulty()).c_str() );
|
||||
feat.pStringToFill = &hs.sName;
|
||||
feat.pStringToFill = hs.GetNameMutable();
|
||||
feat.grade = hs.grade;
|
||||
feat.fPercentDP = hs.fPercentDP;
|
||||
feat.iScore = hs.iScore;
|
||||
@@ -1410,7 +1410,7 @@ void GameState::GetRankingFeats( PlayerNumber pn, vector<RankingFeat> &asFeatsOu
|
||||
{
|
||||
HighScore &hs = hsl.vHighScores[j];
|
||||
|
||||
if( hs.sName != RANKING_TO_FILL_IN_MARKER[pn] )
|
||||
if( hs.GetName() != RANKING_TO_FILL_IN_MARKER[pn] )
|
||||
continue;
|
||||
|
||||
RankingFeat feat;
|
||||
@@ -1418,7 +1418,7 @@ void GameState::GetRankingFeats( PlayerNumber pn, vector<RankingFeat> &asFeatsOu
|
||||
feat.pSteps = pSteps;
|
||||
feat.Type = RankingFeat::SONG;
|
||||
feat.Feat = ssprintf("PR #%d in %s %s", j+1, pSong->GetTranslitMainTitle().c_str(), DifficultyToString(pSteps->GetDifficulty()).c_str() );
|
||||
feat.pStringToFill = &hs.sName;
|
||||
feat.pStringToFill = hs.GetNameMutable();
|
||||
feat.grade = hs.grade;
|
||||
feat.fPercentDP = hs.fPercentDP;
|
||||
feat.iScore = hs.iScore;
|
||||
@@ -1446,13 +1446,13 @@ void GameState::GetRankingFeats( PlayerNumber pn, vector<RankingFeat> &asFeatsOu
|
||||
for( unsigned j=0; j<hsl.vHighScores.size(); j++ )
|
||||
{
|
||||
HighScore &hs = hsl.vHighScores[j];
|
||||
if( hs.sName != RANKING_TO_FILL_IN_MARKER[pn] )
|
||||
if( hs.GetName() != RANKING_TO_FILL_IN_MARKER[pn] )
|
||||
continue;
|
||||
|
||||
RankingFeat feat;
|
||||
feat.Type = RankingFeat::CATEGORY;
|
||||
feat.Feat = ssprintf("MR #%d in Type %c (%d)", j+1, 'A'+rc, stats.GetAverageMeter(pn) );
|
||||
feat.pStringToFill = &hs.sName;
|
||||
feat.pStringToFill = hs.GetNameMutable();
|
||||
feat.grade = GRADE_NO_DATA;
|
||||
feat.iScore = hs.iScore;
|
||||
feat.fPercentDP = hs.fPercentDP;
|
||||
@@ -1469,13 +1469,13 @@ void GameState::GetRankingFeats( PlayerNumber pn, vector<RankingFeat> &asFeatsOu
|
||||
for( unsigned j=0; j<hsl.vHighScores.size(); j++ )
|
||||
{
|
||||
HighScore &hs = hsl.vHighScores[j];
|
||||
if( hs.sName != RANKING_TO_FILL_IN_MARKER[pn] )
|
||||
if( hs.GetName() != RANKING_TO_FILL_IN_MARKER[pn] )
|
||||
continue;
|
||||
|
||||
RankingFeat feat;
|
||||
feat.Type = RankingFeat::CATEGORY;
|
||||
feat.Feat = ssprintf("PR #%d in Type %c (%d)", j+1, 'A'+rc, stats.GetAverageMeter(pn) );
|
||||
feat.pStringToFill = &hs.sName;
|
||||
feat.pStringToFill = hs.GetNameMutable();
|
||||
feat.grade = GRADE_NO_DATA;
|
||||
feat.iScore = hs.iScore;
|
||||
feat.fPercentDP = hs.fPercentDP;
|
||||
@@ -1503,7 +1503,7 @@ void GameState::GetRankingFeats( PlayerNumber pn, vector<RankingFeat> &asFeatsOu
|
||||
for( unsigned i=0; i<hsl.vHighScores.size(); i++ )
|
||||
{
|
||||
HighScore &hs = hsl.vHighScores[i];
|
||||
if( hs.sName != RANKING_TO_FILL_IN_MARKER[pn] )
|
||||
if( hs.GetName() != RANKING_TO_FILL_IN_MARKER[pn] )
|
||||
continue;
|
||||
|
||||
RankingFeat feat;
|
||||
@@ -1512,7 +1512,7 @@ void GameState::GetRankingFeats( PlayerNumber pn, vector<RankingFeat> &asFeatsOu
|
||||
feat.Feat = ssprintf("MR #%d in %s", i+1, pCourse->GetDisplayFullTitle().c_str() );
|
||||
if( cd != DIFFICULTY_MEDIUM )
|
||||
feat.Feat += " " + CourseDifficultyToThemedString(cd);
|
||||
feat.pStringToFill = &hs.sName;
|
||||
feat.pStringToFill = hs.GetNameMutable();
|
||||
feat.grade = GRADE_NO_DATA;
|
||||
feat.iScore = hs.iScore;
|
||||
feat.fPercentDP = hs.fPercentDP;
|
||||
@@ -1529,14 +1529,14 @@ void GameState::GetRankingFeats( PlayerNumber pn, vector<RankingFeat> &asFeatsOu
|
||||
for( unsigned i=0; i<hsl.vHighScores.size(); i++ )
|
||||
{
|
||||
HighScore& hs = hsl.vHighScores[i];
|
||||
if( hs.sName != RANKING_TO_FILL_IN_MARKER[pn] )
|
||||
if( hs.GetName() != RANKING_TO_FILL_IN_MARKER[pn] )
|
||||
continue;
|
||||
|
||||
RankingFeat feat;
|
||||
feat.Type = RankingFeat::COURSE;
|
||||
feat.pCourse = pCourse;
|
||||
feat.Feat = ssprintf("PR #%d in %s", i+1, pCourse->GetDisplayFullTitle().c_str() );
|
||||
feat.pStringToFill = &hs.sName;
|
||||
feat.pStringToFill = hs.GetNameMutable();
|
||||
feat.grade = GRADE_NO_DATA;
|
||||
feat.iScore = hs.iScore;
|
||||
feat.fPercentDP = hs.fPercentDP;
|
||||
|
||||
@@ -11,8 +11,41 @@
|
||||
|
||||
struct HighScoreImpl
|
||||
{
|
||||
CString sName; // name that shows in the machine's ranking screen
|
||||
|
||||
void Unset();
|
||||
void AppendChildren( XNode *pNode ) const;
|
||||
void LoadFromNode( const XNode *pNode );
|
||||
|
||||
bool operator==( const HighScoreImpl& other ) const;
|
||||
bool operator!=( const HighScoreImpl& other ) const { return !(*this == other); }
|
||||
};
|
||||
|
||||
bool HighScoreImpl::operator==( const HighScoreImpl& other ) const
|
||||
{
|
||||
#define COMPARE(x) if( x!=other.x ) return false;
|
||||
COMPARE( sName );
|
||||
#undef COMPARE
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void HighScoreImpl::Unset()
|
||||
{
|
||||
sName = "";
|
||||
|
||||
}
|
||||
|
||||
void HighScoreImpl::AppendChildren( XNode *pNode ) const
|
||||
{
|
||||
pNode->AppendChild( "Name", IsRankingToFillIn(sName) ? CString("") : sName );
|
||||
}
|
||||
|
||||
void HighScoreImpl::LoadFromNode( const XNode *pNode )
|
||||
{
|
||||
pNode->GetChildValue( "Name", sName );
|
||||
}
|
||||
|
||||
REGISTER_CLASS_TRAITS( HighScoreImpl, new HighScoreImpl(*pCopy) )
|
||||
|
||||
HighScore::HighScore()
|
||||
@@ -23,7 +56,7 @@ HighScore::HighScore()
|
||||
|
||||
void HighScore::Unset()
|
||||
{
|
||||
sName = "";
|
||||
m_Impl->Unset();
|
||||
grade = GRADE_NO_DATA;
|
||||
iScore = 0;
|
||||
fPercentDP = 0;
|
||||
@@ -39,6 +72,14 @@ void HighScore::Unset()
|
||||
fLifeRemainingSeconds = 0;
|
||||
}
|
||||
|
||||
CString HighScore::GetName() const { return m_Impl->sName; }
|
||||
void HighScore::SetName( const CString &sName ) { m_Impl->sName = sName; }
|
||||
|
||||
/* 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
|
||||
* is used. */
|
||||
CString *HighScore::GetNameMutable() { return &m_Impl->sName; }
|
||||
|
||||
bool HighScore::operator>=( const HighScore& other ) const
|
||||
{
|
||||
/* Make sure we treat AAAA as higher than AAA, even though the score
|
||||
@@ -61,8 +102,9 @@ bool HighScore::operator>=( const HighScore& other ) const
|
||||
|
||||
bool HighScore::operator==( const HighScore& other ) const
|
||||
{
|
||||
if( *m_Impl != *other.m_Impl )
|
||||
return false;
|
||||
#define COMPARE(x) if( x!=other.x ) return false;
|
||||
COMPARE( sName );
|
||||
COMPARE( grade );
|
||||
COMPARE( iScore );
|
||||
COMPARE( fPercentDP );
|
||||
@@ -88,7 +130,7 @@ XNode* HighScore::CreateNode() const
|
||||
pNode->m_sName = "HighScore";
|
||||
|
||||
// TRICKY: Don't write "name to fill in" markers.
|
||||
pNode->AppendChild( "Name", IsRankingToFillIn(sName) ? CString("") : sName );
|
||||
m_Impl->AppendChildren( pNode );
|
||||
pNode->AppendChild( "Grade", GradeToString(grade) );
|
||||
pNode->AppendChild( "Score", iScore );
|
||||
pNode->AppendChild( "PercentDP", fPercentDP );
|
||||
@@ -117,7 +159,7 @@ void HighScore::LoadFromNode( const XNode* pNode )
|
||||
|
||||
CString s;
|
||||
|
||||
pNode->GetChildValue( "Name", sName );
|
||||
m_Impl->LoadFromNode( pNode );
|
||||
pNode->GetChildValue( "Grade", s );
|
||||
/* Pre-a19 compatibility; remove eventually */
|
||||
if( IsAnInt(s) )
|
||||
@@ -151,10 +193,10 @@ void HighScore::LoadFromNode( const XNode* pNode )
|
||||
|
||||
CString HighScore::GetDisplayName() const
|
||||
{
|
||||
if( sName.empty() )
|
||||
if( GetName().empty() )
|
||||
return EMPTY_NAME;
|
||||
else
|
||||
return sName;
|
||||
return GetName();
|
||||
}
|
||||
|
||||
|
||||
@@ -259,7 +301,7 @@ void HighScoreList::RemoveAllButOneOfEachName()
|
||||
{
|
||||
for( vector<HighScore>::iterator j = i+1; j != vHighScores.end(); j++ )
|
||||
{
|
||||
if( i->sName == j->sName )
|
||||
if( i->GetName() == j->GetName() )
|
||||
{
|
||||
j--;
|
||||
vHighScores.erase( j+1 );
|
||||
|
||||
@@ -14,7 +14,11 @@ struct XNode;
|
||||
struct HighScoreImpl;
|
||||
struct HighScore
|
||||
{
|
||||
CString sName; // name that shows in the machine's ranking screen
|
||||
CString GetName() const;
|
||||
void SetName( const CString &sName );
|
||||
CString *GetNameMutable();
|
||||
const CString *GetNameMutable() const { return const_cast<CString *> (const_cast<HighScore *>(this)->GetNameMutable()); }
|
||||
|
||||
Grade grade;
|
||||
int iScore;
|
||||
float fPercentDP;
|
||||
|
||||
@@ -212,7 +212,7 @@ void PaneDisplay::SetContent( PaneContents c )
|
||||
}
|
||||
else
|
||||
{
|
||||
str = PROFILEMAN->GetMachineProfile()->GetStepsHighScoreList(pSong,pSteps).GetTopScore().sName;
|
||||
str = PROFILEMAN->GetMachineProfile()->GetStepsHighScoreList(pSong,pSteps).GetTopScore().GetName();
|
||||
if( str.empty() )
|
||||
str = "????";
|
||||
}
|
||||
@@ -224,7 +224,7 @@ void PaneDisplay::SetContent( PaneContents c )
|
||||
}
|
||||
else
|
||||
{
|
||||
str = PROFILEMAN->GetMachineProfile()->GetCourseHighScoreList(pCourse,pTrail).GetTopScore().sName;
|
||||
str = PROFILEMAN->GetMachineProfile()->GetCourseHighScoreList(pCourse,pTrail).GetTopScore().GetName();
|
||||
if( str.empty() )
|
||||
str = "????";
|
||||
}
|
||||
|
||||
@@ -541,13 +541,13 @@ void ProfileManager::AddStepsScore( const Song* pSong, const Steps* pSteps, Play
|
||||
{
|
||||
Profile* pProfile = PROFILEMAN->GetProfile(pn);
|
||||
if( pProfile && !pProfile->m_sLastUsedHighScoreName.empty() )
|
||||
hs.sName = pProfile->m_sLastUsedHighScoreName;
|
||||
hs.SetName( pProfile->m_sLastUsedHighScoreName );
|
||||
else
|
||||
hs.sName = "EVNT";
|
||||
hs.SetName( "EVNT" );
|
||||
}
|
||||
else
|
||||
{
|
||||
hs.sName = RANKING_TO_FILL_IN_MARKER[pn];
|
||||
hs.SetName( RANKING_TO_FILL_IN_MARKER[pn] );
|
||||
}
|
||||
|
||||
//
|
||||
@@ -611,13 +611,13 @@ void ProfileManager::AddCourseScore( const Course* pCourse, const Trail* pTrail,
|
||||
{
|
||||
Profile* pProfile = PROFILEMAN->GetProfile(pn);
|
||||
if( pProfile && !pProfile->m_sLastUsedHighScoreName.empty() )
|
||||
hs.sName = pProfile->m_sLastUsedHighScoreName;
|
||||
hs.SetName( pProfile->m_sLastUsedHighScoreName );
|
||||
else
|
||||
hs.sName = "EVNT";
|
||||
hs.SetName( "EVNT" );
|
||||
}
|
||||
else
|
||||
{
|
||||
hs.sName = RANKING_TO_FILL_IN_MARKER[pn];
|
||||
hs.SetName( RANKING_TO_FILL_IN_MARKER[pn] );
|
||||
}
|
||||
|
||||
|
||||
@@ -651,7 +651,7 @@ void ProfileManager::IncrementCoursePlayCount( const Course* pCourse, const Trai
|
||||
void ProfileManager::AddCategoryScore( StepsType st, RankingCategory rc, PlayerNumber pn, const HighScore &hs_, int &iPersonalIndexOut, int &iMachineIndexOut )
|
||||
{
|
||||
HighScore hs = hs_;
|
||||
hs.sName = RANKING_TO_FILL_IN_MARKER[pn];
|
||||
hs.SetName( RANKING_TO_FILL_IN_MARKER[pn] );
|
||||
if( PROFILEMAN->IsPersistentProfile(pn) )
|
||||
PROFILEMAN->GetProfile(pn)->AddCategoryHighScore( st, rc, hs, iPersonalIndexOut );
|
||||
if( hs.fPercentDP > PREFSMAN->m_fMinPercentageForMachineSongHighScore )
|
||||
|
||||
@@ -896,7 +896,7 @@ void ScreenEvaluation::CommitScores(
|
||||
// below in the switch
|
||||
|
||||
HighScore &hs = m_HighScore[p];
|
||||
hs.sName = RANKING_TO_FILL_IN_MARKER[p];
|
||||
hs.SetName( RANKING_TO_FILL_IN_MARKER[p] );
|
||||
hs.grade = stageStats.m_player[p].GetGrade();
|
||||
hs.iScore = stageStats.m_player[p].iScore;
|
||||
hs.fPercentDP = stageStats.m_player[p].GetPercentDancePoints();
|
||||
|
||||
@@ -359,7 +359,7 @@ void ScreenNameEntryTraditional::Init()
|
||||
for( int h=0; h<(int)hsl.vHighScores.size() && h<PREFSMAN->m_iMaxHighScoresPerListForMachine; h++ )
|
||||
{
|
||||
const HighScore &hs = hsl.vHighScores[h];
|
||||
if( hs.sName == RANKING_TO_FILL_IN_MARKER[p] &&
|
||||
if( hs.GetName() == RANKING_TO_FILL_IN_MARKER[p] &&
|
||||
hs.fPercentDP == fPercentDP &&
|
||||
hs.iScore == iScore )
|
||||
{
|
||||
|
||||
@@ -760,12 +760,12 @@ float ScreenRanking::SetPage( PageToShow pts )
|
||||
if( l < (int)hsl.vHighScores.size() )
|
||||
{
|
||||
hs = hsl.vHighScores[l];
|
||||
CString *psName = &hsl.vHighScores[l].sName;
|
||||
CString *psName = hsl.vHighScores[l].GetNameMutable();
|
||||
bRecentHighScore = find( GAMESTATE->m_vpsNamesThatWereFilled.begin(), GAMESTATE->m_vpsNamesThatWereFilled.end(), psName ) != GAMESTATE->m_vpsNamesThatWereFilled.end();
|
||||
}
|
||||
else
|
||||
{
|
||||
hs.sName = NO_SCORE_NAME;
|
||||
hs.SetName( NO_SCORE_NAME );
|
||||
}
|
||||
|
||||
m_textNames[l].SetText( hs.GetDisplayName() );
|
||||
@@ -800,12 +800,12 @@ float ScreenRanking::SetPage( PageToShow pts )
|
||||
if( l < (int)hsl.vHighScores.size() )
|
||||
{
|
||||
hs = hsl.vHighScores[l];
|
||||
const CString *psName = &hsl.vHighScores[l].sName;
|
||||
const CString *psName = hsl.vHighScores[l].GetNameMutable();
|
||||
bRecentHighScore = find( GAMESTATE->m_vpsNamesThatWereFilled.begin(), GAMESTATE->m_vpsNamesThatWereFilled.end(), psName ) != GAMESTATE->m_vpsNamesThatWereFilled.end();
|
||||
}
|
||||
else
|
||||
{
|
||||
hs.sName = NO_SCORE_NAME;
|
||||
hs.SetName( NO_SCORE_NAME );
|
||||
}
|
||||
|
||||
m_textNames[l].SetText( hs.GetDisplayName() );
|
||||
@@ -868,12 +868,12 @@ float ScreenRanking::SetPage( PageToShow pts )
|
||||
if( !hsl.vHighScores.empty() )
|
||||
{
|
||||
hs = hsl.GetTopScore();
|
||||
const CString *psName = &hsl.GetTopScore().sName;
|
||||
const CString *psName = hsl.GetTopScore().GetNameMutable();
|
||||
bRecentHighScore = find( GAMESTATE->m_vpsNamesThatWereFilled.begin(), GAMESTATE->m_vpsNamesThatWereFilled.end(), psName ) != GAMESTATE->m_vpsNamesThatWereFilled.end();
|
||||
}
|
||||
else
|
||||
{
|
||||
hs.sName = NO_SCORE_NAME;
|
||||
hs.SetName( NO_SCORE_NAME );
|
||||
}
|
||||
|
||||
CString s = hs.GetDisplayName() + "\n" + PercentageDisplay::FormatPercentScore( hs.fPercentDP );
|
||||
@@ -915,12 +915,12 @@ float ScreenRanking::SetPage( PageToShow pts )
|
||||
if( !hsl.vHighScores.empty() )
|
||||
{
|
||||
hs = hsl.vHighScores[0];
|
||||
const CString *psName = &hsl.GetTopScore().sName;
|
||||
const CString *psName = hsl.GetTopScore().GetNameMutable();
|
||||
bRecentHighScore = find( GAMESTATE->m_vpsNamesThatWereFilled.begin(), GAMESTATE->m_vpsNamesThatWereFilled.end(), psName ) != GAMESTATE->m_vpsNamesThatWereFilled.end();
|
||||
}
|
||||
else
|
||||
{
|
||||
hs.sName = NO_SCORE_NAME;
|
||||
hs.SetName( NO_SCORE_NAME );
|
||||
}
|
||||
|
||||
CString s = hs.GetDisplayName() + "\n" + PercentageDisplay::FormatPercentScore( hs.fPercentDP );
|
||||
|
||||
Reference in New Issue
Block a user