fix category feats show wrong score on ScreenNameEntryTraditional

store both iScore and fPercentDP for courses and categories
This commit is contained in:
Chris Danford
2003-12-10 11:35:34 +00:00
parent c34c2c5aec
commit ea8c87c46f
8 changed files with 80 additions and 47 deletions
+9
View File
@@ -36,6 +36,7 @@ const int DIFFICULT_METER_CHANGE = 2;
/* Maximum lower value of ranges when difficult: */
const int MAX_BOTTOM_RANGE = 10;
/* -1 is the default parameter of a few Course calls; leaving it out indicates
* to use GAMESTATE->m_bDifficultCourses. */
static bool IsDifficult( int Difficult )
@@ -1035,3 +1036,11 @@ void SortCoursePointerArrayByMostPlayed( vector<Course*> &arrayCoursePointers, M
stable_sort( arrayCoursePointers.begin(), arrayCoursePointers.end(), CompareCoursePointersBySortValueDescending );
course_sort_val.clear();
}
bool Course::MemCardData::HighScore::operator>=( const HighScore& other ) const
{
if( PREFSMAN->m_bPercentageScoring )
return fPercentDP >= other.fPercentDP;
else
return iScore >= other.iScore;
}
+5 -6
View File
@@ -147,20 +147,19 @@ public:
struct HighScore
{
int iScore;
float fSurviveTime;
CString sName;
int iScore;
float fPercentDP;
float fSurviveTime;
HighScore()
{
iScore = 0;
fPercentDP = 0;
fSurviveTime = 0;
}
bool operator>=( const HighScore& other ) const
{
return iScore >= other.iScore;
}
bool operator>=( const HighScore& other ) const;
};
vector<HighScore> vHighScores;
+17 -15
View File
@@ -1000,11 +1000,9 @@ void GameState::GetRankingFeats( PlayerNumber pn, vector<RankingFeats> &asFeatsO
feat.Type = RankingFeats::SONG;
feat.Feat = ssprintf("MR #%d in %s %s", j+1, pSong->GetTranslitMainTitle().c_str(), DifficultyToString(pSteps->GetDifficulty()).c_str() );
feat.pStringToFill = &vMachineHighScores[j].sName;
feat.g = vMachineHighScores[j].grade;
if( PREFSMAN->m_bPercentageScoring )
feat.Score = vMachineHighScores[j].fPercentDP;
else
feat.Score = (float) vMachineHighScores[j].iScore;
feat.grade = vMachineHighScores[j].grade;
feat.fPercentDP = vMachineHighScores[j].fPercentDP;
feat.iScore = vMachineHighScores[j].iScore;
if( pSong->HasBanner() )
feat.Banner = pSong->GetBannerPath();
@@ -1023,8 +1021,9 @@ void GameState::GetRankingFeats( PlayerNumber pn, vector<RankingFeats> &asFeatsO
feat.Type = RankingFeats::SONG;
feat.Feat = ssprintf("PR #%d in %s %s", j+1, pSong->GetTranslitMainTitle().c_str(), DifficultyToString(pSteps->GetDifficulty()).c_str() );
feat.pStringToFill = &vPersonalHighScores[j].sName;
feat.g = vPersonalHighScores[j].grade;
feat.Score = (float) vPersonalHighScores[j].iScore;
feat.grade = vPersonalHighScores[j].grade;
feat.fPercentDP = vMachineHighScores[j].fPercentDP;
feat.iScore = vMachineHighScores[j].iScore;
// XXX: temporary hack
if( pSong->HasBackground() )
@@ -1052,11 +1051,12 @@ void GameState::GetRankingFeats( PlayerNumber pn, vector<RankingFeats> &asFeatsO
continue;
RankingFeats feat;
feat.Type = RankingFeats::RANKING;
feat.Type = RankingFeats::CATEGORY;
feat.Feat = ssprintf("MR #%d in Type %c (%d)", j+1, 'A'+i, stats.iMeter[pn] );
feat.pStringToFill = &vHighScores[j].sName;
feat.g = GRADE_NO_DATA;
feat.Score = (float) vHighScores[j].iScore;
feat.grade = GRADE_NO_DATA;
feat.iScore = (float) vHighScores[j].iScore;
feat.fPercentDP = (float) vHighScores[j].fPercentDP;
asFeatsOut.push_back( feat );
}
}
@@ -1071,11 +1071,12 @@ void GameState::GetRankingFeats( PlayerNumber pn, vector<RankingFeats> &asFeatsO
continue;
RankingFeats feat;
feat.Type = RankingFeats::RANKING;
feat.Type = RankingFeats::CATEGORY;
feat.Feat = ssprintf("PR #%d in Type %c (%d)", j+1, 'A'+i, stats.iMeter[pn] );
feat.pStringToFill = &vHighScores[j].sName;
feat.g = GRADE_NO_DATA;
feat.Score = (float) vHighScores[j].iScore;
feat.grade = GRADE_NO_DATA;
feat.iScore = (float) vHighScores[j].iScore;
feat.fPercentDP = (float) vHighScores[j].fPercentDP;
asFeatsOut.push_back( feat );
}
}
@@ -1102,8 +1103,9 @@ void GameState::GetRankingFeats( PlayerNumber pn, vector<RankingFeats> &asFeatsO
feat.Type = RankingFeats::COURSE;
feat.Feat = ssprintf("No. %d in %s", i+1, pCourse->m_sName.c_str() );
feat.pStringToFill = &vHighScores[i].sName;
feat.g = GRADE_NO_DATA;
feat.Score = (float) vHighScores[i].iScore;
feat.grade = GRADE_NO_DATA;
feat.iScore = vHighScores[i].iScore;
feat.fPercentDP = vHighScores[i].fPercentDP;
if( pCourse->HasBanner() )
feat.Banner = pCourse->m_sBannerPath;
asFeatsOut.push_back( feat );
+4 -3
View File
@@ -247,10 +247,11 @@ public:
//
struct RankingFeats
{
enum { SONG, COURSE, RANKING } Type;
enum { SONG, COURSE, CATEGORY } Type;
float Score;
Grade g;
Grade grade;
int iScore;
float fPercentDP;
CString Banner;
CString Feat;
CString *pStringToFill;
+25 -3
View File
@@ -49,11 +49,11 @@ ProfileManager* PROFILEMAN = NULL; // global and accessable from anywhere in our
#define USER_PROFILES_DIR "Data/LocalProfiles/"
#define MACHINE_PROFILE_DIR "Data/MachineProfile/"
const int CATEGORY_RANKING_VERSION = 5;
const int CATEGORY_RANKING_VERSION = 6;
const int SONG_SCORES_VERSION = 9;
const int COURSE_SCORES_VERSION = 7;
const int COURSE_SCORES_VERSION = 8;
#define STATS_TITLE THEME->GetMetric("ProfileManager","StatsTitle")
#define STATS_TITLE THEME->GetMetric("ProfileManager","StatsTitle")
static const char *MemCardDirs[NUM_PLAYERS] =
{
@@ -547,11 +547,18 @@ void ProfileManager::ReadCategoryScoresFromDir( CString sDir, MemoryCard mc )
CString sName;
if( !FileRead(f, sName) )
WARN_AND_RETURN;
int iScore;
if( !FileRead(f, iScore) )
WARN_AND_RETURN;
float fPercentDP;
if( !FileRead(f, fPercentDP) )
WARN_AND_RETURN;
m_CategoryDatas[mc][st][rc].vHighScores[l].sName = sName;
m_CategoryDatas[mc][st][rc].vHighScores[l].iScore = iScore;
m_CategoryDatas[mc][st][rc].vHighScores[l].fPercentDP = fPercentDP;
}
}
}
@@ -624,6 +631,10 @@ void ProfileManager::ReadCourseScoresFromDir( CString sDir, MemoryCard mc )
if( !FileRead(f, iScore) )
WARN_AND_RETURN;
float fPercentDP;
if( !FileRead(f, fPercentDP) )
WARN_AND_RETURN;
float fSurviveTime;
if( !FileRead(f, fSurviveTime) )
WARN_AND_RETURN;
@@ -632,6 +643,7 @@ void ProfileManager::ReadCourseScoresFromDir( CString sDir, MemoryCard mc )
{
pCourse->m_MemCardDatas[st][mc].vHighScores[l].sName = sName;
pCourse->m_MemCardDatas[st][mc].vHighScores[l].iScore = iScore;
pCourse->m_MemCardDatas[st][mc].vHighScores[l].fPercentDP = fPercentDP;
pCourse->m_MemCardDatas[st][mc].vHighScores[l].fSurviveTime = fSurviveTime;
}
}
@@ -754,6 +766,7 @@ void ProfileManager::SaveCategoryScoresToDir( CString sDir, MemoryCard mc )
FileWrite( f, m_CategoryDatas[mc][st][rc].vHighScores[l].sName );
FileWrite( f, m_CategoryDatas[mc][st][rc].vHighScores[l].iScore );
FileWrite( f, m_CategoryDatas[mc][st][rc].vHighScores[l].fPercentDP );
}
}
}
@@ -813,6 +826,7 @@ void ProfileManager::SaveCourseScoresToDir( CString sDir, MemoryCard mc )
FileWrite( f, pCourse->m_MemCardDatas[st][mc].vHighScores[l].sName );
FileWrite( f, pCourse->m_MemCardDatas[st][mc].vHighScores[l].iScore );
FileWrite( f, pCourse->m_MemCardDatas[st][mc].vHighScores[l].fPercentDP );
FileWrite( f, pCourse->m_MemCardDatas[st][mc].vHighScores[l].fSurviveTime );
}
}
@@ -1333,3 +1347,11 @@ void ProfileManager::SaveStatsWebPageToDir( CString sDir, MemoryCard mc )
CopyFile2( sStyleFile, sDir+STYLE_CSS_FILE );
}
bool ProfileManager::CategoryData::HighScore::operator>=( const HighScore& other ) const
{
if( PREFSMAN->m_bPercentageScoring )
return fPercentDP >= other.fPercentDP;
else
return iScore >= other.iScore;
}
+4 -5
View File
@@ -98,18 +98,17 @@ public:
{
struct HighScore
{
int iScore;
CString sName;
int iScore;
float fPercentDP;
HighScore()
{
iScore = 0;
fPercentDP = 0;
}
bool operator>=( const HighScore& other ) const
{
return iScore >= other.iScore;
}
bool operator>=( const HighScore& other ) const;
};
vector<HighScore> vHighScores;
+10 -13
View File
@@ -227,26 +227,23 @@ ScreenNameEntryTraditional::ScreenNameEntryTraditional( CString sClassName ) : S
this->AddChild( &m_sprBanner[p][i] );
}
if( feat.g != GRADE_NO_DATA )
if( feat.grade != GRADE_NO_DATA )
{
m_Grade[p][i].SetName( ssprintf("GradeP%i",p+1) );
m_Grade[p][i].Load( THEME->GetPathToG("ScreenNameEntryTraditional grades") );
m_Grade[p][i].SetGrade( (PlayerNumber)p, feat.g );
m_Grade[p][i].SetGrade( (PlayerNumber)p, feat.grade );
SET_ON( m_Grade[p][i] );
this->AddChild( &m_Grade[p][i] );
}
if( feat.Score != 0 )
{
m_textScore[p][i].SetName( ssprintf("ScoreP%i",p+1) );
m_textScore[p][i].LoadFromFont( THEME->GetPathToF("ScreenNameEntryTraditional score") );
if( PREFSMAN->m_bPercentageScoring )
m_textScore[p][i].SetText( ssprintf("%.2f%%", feat.Score*100) );
else
m_textScore[p][i].SetText( ssprintf("%.0f", feat.Score) );
SET_ON( m_textScore[p][i] );
this->AddChild( &m_textScore[p][i] );
}
m_textScore[p][i].SetName( ssprintf("ScoreP%i",p+1) );
m_textScore[p][i].LoadFromFont( THEME->GetPathToF("ScreenNameEntryTraditional score") );
if( PREFSMAN->m_bPercentageScoring )
m_textScore[p][i].SetText( ssprintf("%.2f%%", feat.fPercentDP*100) );
else
m_textScore[p][i].SetText( ssprintf("%.0f", feat.iScore) );
SET_ON( m_textScore[p][i] );
this->AddChild( &m_textScore[p][i] );
if( feat.Feat != "" )
{
+6 -2
View File
@@ -25,7 +25,7 @@
#include "GameManager.h"
#include "NoteDataUtil.h"
#include "ProfileManager.h"
#include "PrefsManager.h"
Steps::Steps()
{
@@ -349,7 +349,10 @@ void SortStepsByTypeAndDifficulty( vector<Steps*> &arraySongPointers )
bool Steps::MemCardData::HighScore::operator>=( const Steps::MemCardData::HighScore& other ) const
{
return iScore >= other.iScore;
if( PREFSMAN->m_bPercentageScoring )
return fPercentDP >= other.fPercentDP;
else
return iScore >= other.iScore;
/* Make sure we treat AAAA as higher than AAA, even though the score
* is the same.
*
@@ -391,3 +394,4 @@ void Steps::AddHighScore( PlayerNumber pn, MemCardData::HighScore hs, int &iPers
iPersonalIndexOut = -1;
m_MemCardDatas[MEMORY_CARD_MACHINE].AddHighScore( hs, iMachineIndexOut );
}