split HighScore to separate file

move score data from ProfileManager to Profile
store score data in XML for easier forward/backward compatibility
This commit is contained in:
Chris Danford
2004-02-10 09:42:01 +00:00
parent 0196abe99b
commit 4f439be739
25 changed files with 1727 additions and 1337 deletions
+5
View File
@@ -1047,7 +1047,12 @@ void SortCoursePointerArrayByMostPlayed( vector<Course*> &arrayCoursePointers, P
Profile* pProfile = PROFILEMAN->GetProfile(slot);
if( pProfile == NULL )
return; // nothing to do since we don't have data
SortCoursePointerArrayByMostPlayed( arrayCoursePointers, pProfile );
}
void SortCoursePointerArrayByMostPlayed( vector<Course*> &arrayCoursePointers, Profile* pProfile )
{
ASSERT( pProfile );
for(unsigned i = 0; i < arrayCoursePointers.size(); ++i)
course_sort_val[arrayCoursePointers[i]] = (float) pProfile->GetCourseNumTimesPlayed(arrayCoursePointers[i]);
stable_sort( arrayCoursePointers.begin(), arrayCoursePointers.end(), CompareCoursePointersBySortValueDescending );
+2
View File
@@ -20,6 +20,7 @@ struct PlayerOptions;
struct SongOptions;
class Song;
class Steps;
class Profile;
enum CourseEntryType
{
@@ -165,6 +166,7 @@ void SortCoursePointerArrayByAvgDifficulty( vector<Course*> &apCourses );
void SortCoursePointerArrayByTotalDifficulty( vector<Course*> &apCourses );
void SortCoursePointerArrayByRanking( vector<Course*> &apCourses );
void SortCoursePointerArrayByMostPlayed( vector<Course*> &arrayCoursePointers, ProfileSlot slot );
void SortCoursePointerArrayByMostPlayed( vector<Course*> &arrayCoursePointers, Profile* pProfile );
void MoveRandomToEnd( vector<Course*> &apCourses );
+1 -1
View File
@@ -14,7 +14,7 @@
#include "GameState.h"
CString CategoryToString( RadarCategory cat )
CString RadarCategoryToString( RadarCategory cat )
{
switch( cat )
{
+18 -1
View File
@@ -34,6 +34,10 @@
#define ARROW_SIZE (64)
#define FOREACH_ENUM( e, max, var ) for( e var=(e)0; var<max; ((int&)var)++ )
//
// Note definitions
//
@@ -56,8 +60,10 @@ enum RadarCategory
RADAR_NUM_HANDS,
NUM_RADAR_CATEGORIES // leave this at the end
};
#define FOREACH_RadarCategory( rc ) FOREACH_ENUM( RadarCategory, NUM_RADAR_CATEGORIES, rc )
CString RadarCategoryToString( RadarCategory cat );
CString CategoryToString( RadarCategory cat );
enum Difficulty
{
@@ -70,6 +76,7 @@ enum Difficulty
NUM_DIFFICULTIES,
DIFFICULTY_INVALID
};
#define FOREACH_Difficulty( dc ) FOREACH_ENUM( Difficulty, NUM_DIFFICULTIES, dc )
CString DifficultyToString( Difficulty dc );
Difficulty StringToDifficulty( CString sDC );
@@ -82,6 +89,7 @@ enum CourseDifficulty
NUM_COURSE_DIFFICULTIES,
COURSE_DIFFICULTY_INVALID
};
#define FOREACH_CourseDifficulty( cd ) FOREACH_ENUM( CourseDifficulty, NUM_COURSE_DIFFICULTIES, cd )
CString CourseDifficultyToString( CourseDifficulty dc );
CourseDifficulty StringToCourseDifficulty( CString sDC );
@@ -116,6 +124,7 @@ enum StepsType
NUM_STEPS_TYPES, // leave this at the end
STEPS_TYPE_INVALID,
};
#define FOREACH_StepsType( st ) FOREACH_ENUM( StepsType, NUM_STEPS_TYPES, st )
//
// Play mode stuff
@@ -131,6 +140,7 @@ enum PlayMode
NUM_PLAY_MODES,
PLAY_MODE_INVALID
};
#define FOREACH_PlayMode( pm ) FOREACH_ENUM( PlayMode, NUM_PLAY_MODES, pm )
CString PlayModeToString( PlayMode pm );
PlayMode StringToPlayMode( CString s );
@@ -162,6 +172,8 @@ enum SongSortOrder {
};
const SongSortOrder MAX_SELECTABLE_SORT = (SongSortOrder)(SORT_ROULETTE-1);
#define FOREACH_SongSortOrder( so ) FOREACH_ENUM( SongSortOrder, NUM_SORT_ORDERS, so )
CString SongSortOrderToString( SongSortOrder so );
SongSortOrder StringToSongSortOrder( CString str );
@@ -181,6 +193,7 @@ enum TapNoteScore {
TNS_MARVELOUS,
NUM_TAP_NOTE_SCORES
};
#define FOREACH_TapNoteScore( tns ) FOREACH_ENUM( TapNoteScore, NUM_TAP_NOTE_SCORES, tns )
CString TapNoteScoreToString( TapNoteScore tns );
@@ -198,6 +211,7 @@ enum HoldNoteScore
HNS_NG, // the HoldNote has passed and they missed it
NUM_HOLD_NOTE_SCORES
};
#define FOREACH_HoldNoteScore( hns ) FOREACH_ENUM( HoldNoteScore, NUM_HOLD_NOTE_SCORES, hns )
//
@@ -211,6 +225,8 @@ enum ProfileSlot
NUM_PROFILE_SLOTS,
PROFILE_SLOT_INVALID
};
#define FOREACH_ProfileSlot( slot ) FOREACH_ENUM( ProfileSlot, NUM_PROFILE_SLOTS, slot )
enum MemoryCardState
{
@@ -236,6 +252,7 @@ enum RankingCategory
RANKING_D, // 10+ meter per song avg. // doesn't count extra stage!
NUM_RANKING_CATEGORIES
};
#define FOREACH_RankingCategory( rc ) FOREACH_ENUM( RankingCategory, NUM_RANKING_CATEGORIES, rc )
#define DEFAULT_RANKING_NAME CString("")
const CString RANKING_TO_FILL_IN_MARKER[NUM_PLAYERS] = {"#P1#","#P2#"};
+2 -2
View File
@@ -28,8 +28,8 @@ const float GRAPH_EDGE_WIDTH = 2;
#define EDGE_WIDTH THEME->GetMetricF("GrooveGraph","EdgeWidth")
#define DIFFICULTY_COLORS(dc) THEME->GetMetricC("GrooveGraph",Capitalize(DifficultyToString(dc))+"Color")
#define SHOW_CATEGORY(cat) THEME->GetMetricB("GrooveGraph","Show"+Capitalize(CategoryToString(cat)))
#define CATEGORY_X(cat) THEME->GetMetricF("GrooveGraph",Capitalize(CategoryToString(cat))+"X")
#define SHOW_CATEGORY(cat) THEME->GetMetricB("GrooveGraph","Show"+Capitalize(RadarCategoryToString(cat)))
#define CATEGORY_X(cat) THEME->GetMetricF("GrooveGraph",Capitalize(RadarCategoryToString(cat))+"X")
#define MOUNTAINS_BASE_Y THEME->GetMetricF("GrooveGraph","MountainsBaseY")
CachedThemeMetricF MOUNTAIN_WIDTH ("GrooveGraph","MountainWidth");
CachedThemeMetricF MOUNTAIN_HEIGHT ("GrooveGraph","MountainHeight");
+155
View File
@@ -0,0 +1,155 @@
#include "global.h"
/*
-----------------------------------------------------------------------------
Class: HighScore
Desc: See header.
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
Chris Danford
-----------------------------------------------------------------------------
*/
#include "HighScore.h"
#include "PrefsManager.h"
#include "GameConstantsAndTypes.h"
bool HighScore::operator>=( const HighScore& other ) const
{
/* Make sure we treat AAAA as higher than AAA, even though the score
* is the same.
*
* XXX: Isn't it possible to beat the grade but not beat the score, since
* grading and scores are on completely different systems? Should we be
* checking for these completely separately? */
if( PREFSMAN->m_bPercentageScoring )
{
if( fPercentDP == other.fPercentDP )
return grade >= other.grade;
else
return fPercentDP >= other.fPercentDP;
}
else
{
if( iScore == other.iScore )
return grade >= other.grade;
else
return iScore >= other.iScore;
}
}
XNode* HighScore::CreateNode() const
{
XNode* pNode = new XNode;
pNode->name = "HighScore";
if( IsRankingToFillIn(sName) )
{
// TRICKY: Don't write "name to fill in" markers.
pNode->AppendChild( "Name", IsRankingToFillIn(sName) ? "" : sName );
}
pNode->AppendChild( "Grade", grade );
pNode->AppendChild( "Score", iScore );
pNode->AppendChild( "PercentDP", fPercentDP );
pNode->AppendChild( "SurviveSeconds", fSurviveSeconds );
pNode->AppendChild( "Modifiers", sModifiers );
return pNode;
}
void HighScore::LoadFromNode( XNode* pNode )
{
ASSERT( pNode->name == "HighScore" );
XNodes childs = pNode->GetChilds();
for( int i = 0 ; i < childs.size(); i++)
{
XNode* pChild = childs[i];
if( pChild->name == "Name" ) pChild->GetValue( sName );
else if( pChild->name == "Grade" ) pChild->GetValue( (int&)grade );
else if( pChild->name == "Score" ) pChild->GetValue( iScore );
else if( pChild->name == "PercentDP" ) pChild->GetValue( fPercentDP );
else if( pChild->name == "SurviveSeconds" ) pChild->GetValue( fSurviveSeconds );
else if( pChild->name == "Modifiers" ) pChild->GetValue( sModifiers );
}
}
void HighScoreList::Init()
{
iNumTimesPlayed = 0;
vHighScores.clear();
}
void HighScoreList::AddHighScore( HighScore hs, int &iIndexOut )
{
int i;
for( i=0; i<(int)vHighScores.size(); i++ )
{
if( hs >= vHighScores[i] )
break;
}
if( i < NUM_RANKING_LINES )
{
vHighScores.insert( vHighScores.begin()+i, hs );
iIndexOut = i;
if( vHighScores.size() > unsigned(NUM_RANKING_LINES) )
vHighScores.erase( vHighScores.begin()+NUM_RANKING_LINES, vHighScores.end() );
}
}
const HighScore& HighScoreList::GetTopScore() const
{
if( vHighScores.empty() )
{
static HighScore hs;
hs = HighScore();
return hs;
}
else
{
return vHighScores[0];
}
}
XNode* HighScoreList::CreateNode() const
{
XNode* pNode = new XNode;
pNode->name = "HighScoreList";
pNode->AppendChild( "NumTimesPlayed", iNumTimesPlayed );
for( int i=0; i<vHighScores.size(); i++ )
{
const HighScore &hs = vHighScores[i];
pNode->AppendChild( hs.CreateNode() );
}
return pNode;
}
void HighScoreList::LoadFromNode( XNode* pNode )
{
Init();
ASSERT( pNode->name == "HighScoreList" );
for( XNodes::iterator child = pNode->childs.begin();
child != pNode->childs.end();
child++)
{
if( (*child)->name == "NumTimesPlayed" )
{
(*child)->GetValue( iNumTimesPlayed );
}
else if( (*child)->name == "HighScore" )
{
vHighScores.resize( vHighScores.size()+1 );
vHighScores.back().LoadFromNode( (*child) );
// ignore all high scores that are 0
if( vHighScores.back().iScore == 0 )
vHighScores.pop_back();
}
}
}
+63
View File
@@ -0,0 +1,63 @@
#ifndef HighScore_H
#define HighScore_H
/*
-----------------------------------------------------------------------------
Class: HighScore
Desc: Player data that persists between sessions. Can be stored on a local
disk or on a memory card.
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
Chris Danford
-----------------------------------------------------------------------------
*/
#include "Grade.h"
#include "XmlFile.h"
struct HighScore
{
CString sName;
Grade grade;
int iScore;
float fPercentDP;
float fSurviveSeconds;
CString sModifiers;
HighScore()
{
grade = GRADE_NO_DATA;
iScore = 0;
fPercentDP = 0;
fSurviveSeconds = 0;
}
bool operator>=( const HighScore& other ) const;
XNode* CreateNode() const;
void LoadFromNode( XNode* pNode );
};
struct HighScoreList
{
int iNumTimesPlayed;
vector<HighScore> vHighScores;
HighScoreList()
{
iNumTimesPlayed = 0;
}
void Init();
void AddHighScore( HighScore hs, int &iIndexOut );
const HighScore& GetTopScore() const;
XNode* CreateNode() const;
void LoadFromNode( XNode* pNode );
};
#endif
+3 -2
View File
@@ -85,14 +85,14 @@ bool IniFile::ReadFile()
}
// writes data stored in class to ini file
void IniFile::WriteFile()
bool IniFile::WriteFile()
{
RageFile f;
if( !f.Open( path, RageFile::WRITE ) )
{
LOG->Trace( "Writing '%s' failed: %s", path.c_str(), f.GetError().c_str() );
error = f.GetError();
return;
return false;
}
for (keymap::const_iterator k = keys.begin(); k != keys.end(); ++k)
@@ -107,6 +107,7 @@ void IniFile::WriteFile()
f.PutLine( "" );
}
return true;
}
// deletes all stored ini data
+1 -1
View File
@@ -56,7 +56,7 @@ public:
bool ReadFile();
//writes data stored in class to ini file
void WriteFile();
bool WriteFile();
//deletes all stored ini data
void Reset();
+1 -1
View File
@@ -57,7 +57,7 @@ DataStructures = \
Attack.h Attack.cpp BannerCache.cpp BannerCache.h Character.cpp Character.h CharacterHead.cpp CharacterHead.h CodeDetector.cpp CodeDetector.h \
Course.cpp Course.h Font.cpp Font.h FontCharAliases.cpp FontCharAliases.h FontCharmaps.cpp FontCharmaps.h Game.h \
GameConstantsAndTypes.cpp GameConstantsAndTypes.h GameDef.cpp GameDef.h GameInput.cpp GameInput.h \
Grade.cpp Grade.h Inventory.cpp Inventory.h LyricsLoader.cpp LyricsLoader.h MenuInput.h ModeChoice.cpp ModeChoice.h \
Grade.cpp Grade.h HighScore.cpp HighScore.h Inventory.cpp Inventory.h LyricsLoader.cpp LyricsLoader.h MenuInput.h ModeChoice.cpp ModeChoice.h \
NoteData.cpp NoteData.h NoteDataUtil.cpp NoteDataUtil.h NoteDataWithScoring.cpp NoteDataWithScoring.h \
NoteFieldPositioning.cpp NoteFieldPositioning.h NoteTypes.cpp NoteTypes.h NotesLoader.cpp NotesLoader.h \
NotesLoaderBMS.cpp NotesLoaderBMS.h NotesLoaderDWI.cpp NotesLoaderDWI.h NotesLoaderKSF.cpp NotesLoaderKSF.h \
+2
View File
@@ -15,6 +15,7 @@
#include "RageTypes.h" // for RageColor
#define FOREACH_ENUM( e, max, var ) for( e var=(e)0; var<max; ((int&)var)++ )
//
@@ -26,6 +27,7 @@ enum PlayerNumber {
NUM_PLAYERS, // leave this at the end
PLAYER_INVALID
};
#define FOREACH_PlayerNumber( pn ) FOREACH_ENUM( PlayerNumber, NUM_PLAYERS, pn )
const PlayerNumber OPPOSITE_PLAYER[NUM_PLAYERS] = { PLAYER_2, PLAYER_1 };
+1272 -49
View File
File diff suppressed because it is too large Load Diff
+83 -62
View File
@@ -16,79 +16,33 @@
#include "Style.h"
#include "Grade.h"
#include <map>
#include "XmlFile.h"
#include "HighScore.h"
class Song;
class Steps;
class Course;
struct HighScore
class Profile
{
CString sName;
Grade grade;
int iScore;
float fPercentDP;
float fSurviveTime;
HighScore()
public:
Profile()
{
grade = GRADE_NO_DATA;
iScore = 0;
fPercentDP = 0;
fSurviveTime = 0;
}
bool operator>=( const HighScore& other ) const;
};
struct HighScoreList
{
int iNumTimesPlayed;
vector<HighScore> vHighScores;
HighScoreList()
{
iNumTimesPlayed = 0;
}
void AddHighScore( HighScore hs, int &iIndexOut );
const HighScore& GetTopScore() const;
};
struct Profile
{
Profile() { Init(); }
void Init()
{
m_sName = "";
m_sLastUsedHighScoreName = "";
m_bUsingProfileDefaultModifiers = false;
m_sDefaultModifiers = "";
m_iTotalPlays = 0;
m_iTotalPlaySeconds = 0;
m_iTotalGameplaySeconds = 0;
m_iCurrentCombo = 0;
m_fWeightPounds = 0;
m_fCaloriesBurned = 0;
int i;
for( i=0; i<NUM_PLAY_MODES; i++ )
m_iNumSongsPlayedByPlayMode[i] = 0;
for( i=0; i<NUM_STYLES; i++ )
m_iNumSongsPlayedByStyle[i] = 0;
for( i=0; i<NUM_DIFFICULTIES; i++ )
m_iNumSongsPlayedByDifficulty[i] = 0;
for( i=0; i<MAX_METER+1; i++ )
m_iNumSongsPlayedByMeter[i] = 0;
InitAll();
}
//
// smart accessors
//
CString GetDisplayName();
CString GetDisplayCaloriesBurned();
int GetTotalNumSongsPlayed();
static CString GetProfileDisplayNameFromDir( CString sDir );
int GetSongNumTimesPlayed( Song* pSong );
bool LoadFromIni( CString sIniPath );
bool SaveToIni( CString sIniPath );
//
// General data
//
CString m_sName;
CString m_sLastUsedHighScoreName;
bool m_bUsingProfileDefaultModifiers;
@@ -144,8 +98,75 @@ struct Profile
void AddCategoryHighScore( StepsType st, RankingCategory rc, HighScore hs, int &iIndexOut );
HighScoreList& GetCategoryHighScoreList( StepsType st, RankingCategory rc );
int GetCategoryNumTimesPlayed( RankingCategory rc ) const;
int GetCategoryNumTimesPlayed( StepsType st ) const;
void IncrementCategoryPlayCount( StepsType st, RankingCategory rc );
//
// Init'ing
//
void InitAll()
{
InitGeneralData();
InitSongScores();
InitCourseScores();
InitCategoryScores();
}
void InitGeneralData();
void InitSongScores();
void InitCourseScores();
void InitCategoryScores();
//
// Loading and saving
//
bool LoadAllFromDir( CString sDir )
{
InitAll();
bool bResult = LoadGeneralDataFromDir( sDir );
LoadSongScoresFromDirSM390a12( sDir );
LoadSongScoresFromDir( sDir );
LoadCourseScoresFromDirSM390a12( sDir );
LoadCourseScoresFromDir( sDir );
LoadCategoryScoresFromDirSM390a12( sDir );
LoadCategoryScoresFromDir( sDir );
return bResult;
}
bool SaveAllToDir( CString sDir )
{
// Delete old files after saving new ones so we don't try to load old
// and make duplicate records.
// If the save fails, the delete will fail too... probably :-)
bool bResult = SaveGeneralDataToDir( sDir );
SaveSongScoresToDir( sDir );
DeleteSongScoresFromDirSM390a12( sDir );
SaveCourseScoresToDir( sDir );
DeleteCourseScoresFromDirSM390a12( sDir );
SaveCategoryScoresToDir( sDir );
DeleteCategoryScoresFromDirSM390a12( sDir );
SaveStatsWebPageToDir( sDir );
return bResult;
}
bool LoadGeneralDataFromDir( CString sDir );
bool SaveGeneralDataToDir( CString sDir );
void LoadSongScoresFromDirSM390a12( CString sDir );
void LoadSongScoresFromDir( CString sDir );
void SaveSongScoresToDir( CString sDir );
void DeleteSongScoresFromDirSM390a12( CString sDir );
void LoadCourseScoresFromDirSM390a12( CString sDir );
void LoadCourseScoresFromDir( CString sDir );
void SaveCourseScoresToDir( CString sDir );
void DeleteCourseScoresFromDirSM390a12( CString sDir );
void LoadCategoryScoresFromDirSM390a12( CString sDir );
void LoadCategoryScoresFromDir( CString sDir );
void SaveCategoryScoresToDir( CString sDir );
void DeleteCategoryScoresFromDirSM390a12( CString sDir );
void SaveStatsWebPageToDir( CString sDir );
};
File diff suppressed because it is too large Load Diff
+3 -12
View File
@@ -34,7 +34,7 @@ public:
void GetLocalProfileNames( vector<CString> &asNamesOut );
bool LoadProfileFromMemoryCard( PlayerNumber pn );
bool LoadFirstAvailableProfile( PlayerNumber pn ); // memory card or local profile
// bool LoadFirstAvailableProfile( PlayerNumber pn ); // memory card or local profile
bool SaveProfile( PlayerNumber pn );
void UnloadProfile( PlayerNumber pn );
@@ -74,8 +74,8 @@ public:
//
// Song stats
//
int GetSongNumTimesPlayed( Song* pSong, ProfileSlot card ) const;
bool IsSongNew( Song* pSong ) const { return GetSongNumTimesPlayed(pSong,PROFILE_SLOT_MACHINE)==0; }
int GetSongNumTimesPlayed( Song* pSong, ProfileSlot card );
bool IsSongNew( Song* pSong ) { return GetSongNumTimesPlayed(pSong,PROFILE_SLOT_MACHINE)==0; }
void AddStepsHighScore( const Steps* pSteps, PlayerNumber pn, HighScore hs, int &iPersonalIndexOut, int &iMachineIndexOut );
void IncrementStepsPlayCount( const Steps* pSteps, PlayerNumber pn );
HighScore GetHighScoreForDifficulty( const Song *s, const StyleDef *st, ProfileSlot slot, Difficulty dc );
@@ -94,15 +94,6 @@ public:
// void ReadSM300NoteScores();
void ReadSongScoresFromDir( CString sDir, ProfileSlot slot );
void ReadCourseScoresFromDir( CString sDir, ProfileSlot slot );
void ReadCategoryScoresFromDir( CString sDir, ProfileSlot slot );
void SaveSongScoresToDirXml( CString sDir, ProfileSlot slot );
void SaveSongScoresToDir( CString sDir, ProfileSlot slot );
void SaveCourseScoresToDir( CString sDir, ProfileSlot slot );
void SaveCategoryScoresToDir( CString sDir, ProfileSlot slot );
void SaveStatsWebPageToDir( CString sDir, ProfileSlot slot );
private:
bool LoadDefaultProfileFromMachine( PlayerNumber pn );
+5 -1
View File
@@ -864,7 +864,8 @@ void ScreenEvaluation::CommitScores( const StageStats &stageStats, int iPersonal
hs.grade = stageStats.GetGrade( (PlayerNumber)p );
hs.iScore = stageStats.iScore[p];
hs.fPercentDP = stageStats.GetPercentDancePoints( (PlayerNumber)p );
hs.fSurviveTime = stageStats.fAliveSeconds[p];
hs.fSurviveSeconds = stageStats.fAliveSeconds[p];
hs.sModifiers = GAMESTATE->m_PlayerOptions[p].GetString();
StepsType nt = GAMESTATE->GetCurrentStyleDef()->m_StepsType;
@@ -894,6 +895,9 @@ void ScreenEvaluation::CommitScores( const StageStats &stageStats, int iPersonal
if( hs.fPercentDP > PREFSMAN->m_fMinPercentageForHighScore )
PROFILEMAN->AddCategoryHighScore( nt, rc[p], (PlayerNumber)p, hs, iPersonalHighScoreIndex[p], iMachineHighScoreIndex[p] );
// TRICKY: Increment play count here, and not on ScreenGameplay like the others.
PROFILEMAN->IncrementCategoryPlayCount( nt, rc[p], (PlayerNumber)p );
}
break;
+1 -1
View File
@@ -734,7 +734,7 @@ float ScreenRanking::SetPage( PageToShow pts )
if( pts.pCourse->IsOni() )
{
m_textPoints[l].SetText( ssprintf("%04d",hs.iScore) );
m_textTime[l].SetText( SecondsToTime(hs.fSurviveTime) );
m_textTime[l].SetText( SecondsToTime(hs.fSurviveSeconds) );
m_textScores[l].SetText( "" );
} else {
m_textPoints[l].SetText( "" );
+2 -2
View File
@@ -432,8 +432,8 @@ void ScreenSelectCourse::AfterCourseChange()
if ( pCourse->IsOni() || pCourse->IsEndless() )
{
/* use survive time */
float fSurviveTime = hsl.GetTopScore().fSurviveTime;
CString s = SecondsToTime(fSurviveTime);
float fSurviveSeconds = hsl.GetTopScore().fSurviveSeconds;
CString s = SecondsToTime(fSurviveSeconds);
/* dim the inital unsignificant digits */
/*XXX we'd like to have a dimmed ':' and '.', but
+10 -1
View File
@@ -1369,8 +1369,17 @@ bool CompareSongPointersBySortValueDescending(const Song *pSong1, const Song *pS
void SortSongPointerArrayByMostPlayed( vector<Song*> &arraySongPointers, ProfileSlot slot )
{
Profile* pProfile = PROFILEMAN->GetProfile(slot);
if( pProfile == NULL )
return; // nothing to do since we don't have data
SortSongPointerArrayByMostPlayed( arraySongPointers, pProfile );
}
void SortSongPointerArrayByMostPlayed( vector<Song*> &arraySongPointers, Profile* pProfile )
{
ASSERT( pProfile );
for(unsigned i = 0; i < arraySongPointers.size(); ++i)
song_sort_val[arraySongPointers[i]] = ssprintf("%9i", PROFILEMAN->GetSongNumTimesPlayed(arraySongPointers[i],slot));
song_sort_val[arraySongPointers[i]] = ssprintf("%9i", pProfile->GetSongNumTimesPlayed(arraySongPointers[i]));
stable_sort( arraySongPointers.begin(), arraySongPointers.end(), CompareSongPointersBySortValueDescending );
song_sort_val.clear();
}
+25 -6
View File
@@ -65,7 +65,7 @@ IntDir=.\../Debug6
TargetDir=\stepmania\stepmania\Program
TargetName=StepMania-debug
SOURCE="$(InputPath)"
PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
PostBuild_Cmds=disasm\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi
# End Special Build Tool
@@ -103,8 +103,8 @@ IntDir=.\../Debug_Xbox
TargetDir=\stepmania\stepmania
TargetName=default
SOURCE="$(InputPath)"
PreLink_Cmds=disasm\verinc cl /Zl /nologo /c \
verstub.cpp /Fo$(IntDir)\
PreLink_Cmds=disasm\verinc cl /Zl /nologo /c \
verstub.cpp /Fo$(IntDir)\
PostBuild_Cmds=disasm\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi ia32.vdi
# End Special Build Tool
@@ -144,7 +144,7 @@ IntDir=.\../Release6
TargetDir=\stepmania\stepmania\Program
TargetName=StepMania
SOURCE="$(InputPath)"
PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
PostBuild_Cmds=disasm\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi
# End Special Build Tool
@@ -184,8 +184,8 @@ IntDir=.\../Release_Xbox
TargetDir=\stepmania\stepmania
TargetName=default
SOURCE="$(InputPath)"
PreLink_Cmds=disasm\verinc cl /Zl /nologo /c \
verstub.cpp /Fo$(IntDir)\
PreLink_Cmds=disasm\verinc cl /Zl /nologo /c \
verstub.cpp /Fo$(IntDir)\
PostBuild_Cmds=disasm\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi ia32.vdi
# End Special Build Tool
@@ -1291,6 +1291,25 @@ SOURCE=.\Grade.h
# End Source File
# Begin Source File
SOURCE=.\HighScore.cpp
!IF "$(CFG)" == "StepMania - Win32 Debug"
!ELSEIF "$(CFG)" == "StepMania - Xbox Debug"
!ELSEIF "$(CFG)" == "StepMania - Win32 Release"
!ELSEIF "$(CFG)" == "StepMania - Xbox Release"
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\HighScore.h
# End Source File
# Begin Source File
SOURCE=.\Inventory.cpp
!IF "$(CFG)" == "StepMania - Win32 Debug"
+7 -1
View File
@@ -330,8 +330,14 @@ bool CompareStepsPointersBySortValueDescending(const Steps *pSteps1, const Steps
void SortStepsPointerArrayByMostPlayed( vector<Steps*> &vStepsPointers, ProfileSlot slot )
{
Profile* pProfile = PROFILEMAN->GetProfile(slot);
ASSERT( pProfile ); // we shouldn't be requesting this sort unless there's a Profile in this slot
if( pProfile == NULL )
return; // nothing to do since we don't have data
SortStepsPointerArrayByMostPlayed( vStepsPointers, pProfile );
}
void SortStepsPointerArrayByMostPlayed( vector<Steps*> &vStepsPointers, Profile* pProfile )
{
ASSERT( pProfile );
for(unsigned i = 0; i < vStepsPointers.size(); ++i)
steps_sort_val[vStepsPointers[i]] = ssprintf("%9i", pProfile->GetStepsNumTimesPlayed(vStepsPointers[i]));
stable_sort( vStepsPointers.begin(), vStepsPointers.end(), CompareStepsPointersBySortValueDescending );
+2
View File
@@ -17,6 +17,7 @@
#include "PlayerNumber.h"
#include "Grade.h"
class NoteData;
class Profile;
class Steps
{
@@ -90,5 +91,6 @@ void SortNotesArrayByDifficulty( vector<Steps*> &arrayNotess );
bool CompareStepsPointersByTypeAndDifficulty(const Steps *pStep1, const Steps *pStep2);
void SortStepsByTypeAndDifficulty( vector<Steps*> &arraySongPointers );
void SortStepsPointerArrayByMostPlayed( vector<Steps*> &vStepsPointers, ProfileSlot slot );
void SortStepsPointerArrayByMostPlayed( vector<Steps*> &vStepsPointers, Profile* pProfile );
#endif
+21
View File
@@ -7,6 +7,7 @@
#include <iostream>
#include <sstream>
#include <string>
#include "RageFile.h"
static const TCHAR chXMLTagOpen = '<';
@@ -1185,3 +1186,23 @@ CString XEntity2Ref( LPCTSTR str )
{
return entityDefault.Entity2Ref( str );
}
bool _tagXMLNode::LoadFromFile( CString sFile, LPPARSEINFO pi )
{
RageFile f;
if( !f.Open(sFile, RageFile::READ) )
return false;
CString s;
f.Read( s );
this->Load( s, pi );
return true;
}
bool _tagXMLNode::SaveToFile( CString sFile, LPDISP_OPT opt )
{
RageFile f;
if( !f.Open(sFile, RageFile::WRITE) )
return false;
f.Write( this->GetXML(opt) );
return true;
}
+15 -3
View File
@@ -1,8 +1,10 @@
#ifndef XmlFile_H
#define XmlFile_H
// XmlFile.h: interface for the XmlFile class.
//
// Adapted from http://www.codeproject.com/cpp/xmlite.asp
// by Chris. The CodeProject FAQ says "all developers may freely
// use the code in their own applications".
// Adapted from http://www.codeproject.com/cpp/xmlite.asp.
// On 2004-02-09 Cho,Kyung Min gave us permission to use and modify this
// library.
//
// XmlFile : XML Lite Parser Library
// by bro ( Cho,Kyung Min: bro@shinbiro.com ) 2002-10-30
@@ -121,6 +123,9 @@ typedef struct _tagXMLNode
// name and value
CString name;
CString value;
void GetValue(CString &out) { out = value; }
void GetValue(int &out) { out = atoi(value); }
void GetValue(float &out) { out = atof(value); }
// internal variables
LPXNode parent; // parent node
@@ -132,6 +137,9 @@ typedef struct _tagXMLNode
LPTSTR LoadAttributes( LPCTSTR pszAttrs, LPPARSEINFO pi = &piDefault );
CString GetXML( LPDISP_OPT opt = &optDefault );
bool LoadFromFile( CString sFile, LPPARSEINFO pi = &piDefault );
bool SaveToFile( CString sFile, LPDISP_OPT opt = &optDefault );
// in own attribute list
LPXAttr GetAttr( LPCTSTR attrname );
LPCTSTR GetAttrValue( LPCTSTR attrname );
@@ -140,6 +148,9 @@ typedef struct _tagXMLNode
// in one level child nodes
LPXNode GetChild( LPCTSTR name );
LPCTSTR GetChildValue( LPCTSTR name );
bool GetChildValue(LPCTSTR name,CString &out) { XNode* pChild=GetChild(name); if(pChild==NULL) return false; pChild->GetValue(out); return true; }
bool GetChildValue(LPCTSTR name,int &out) { XNode* pChild=GetChild(name); if(pChild==NULL) return false; pChild->GetValue(out); return true; }
bool GetChildValue(LPCTSTR name,float &out) { XNode* pChild=GetChild(name); if(pChild==NULL) return false; pChild->GetValue(out); return true; }
XNodes GetChilds( LPCTSTR name );
XNodes GetChilds();
@@ -191,3 +202,4 @@ inline bool XIsEmptyString( LPCTSTR str )
return ( s.empty() || s == "" );
}
#endif
+2
View File
@@ -20,6 +20,7 @@ class Steps;
class StyleDef;
class NotesLoader;
class LyricsLoader;
class Profile;
extern const int FILE_CACHE_VERSION;
@@ -210,6 +211,7 @@ void SortSongPointerArrayByArtist( vector<Song*> &arraySongPointers );
void SortSongPointerArrayByGroupAndDifficulty( vector<Song*> &arraySongPointers );
void SortSongPointerArrayByGroupAndTitle( vector<Song*> &arraySongPointers );
void SortSongPointerArrayByMostPlayed( vector<Song*> &arraySongPointers, ProfileSlot slot );
void SortSongPointerArrayByMostPlayed( vector<Song*> &arraySongPointers, Profile* pProfile );
void SortSongPointerArrayByMeter( vector<Song*> &arraySongPointers, Difficulty dc );
CString GetSectionNameFromSongAndSort( const Song* pSong, SongSortOrder so );
void SortSongPointerArrayBySectionName( vector<Song*> &arraySongPointers, SongSortOrder so );