combine all profile score data to one file

move user-editable data to a separate, unsigned file
This commit is contained in:
Chris Danford
2004-02-19 03:19:41 +00:00
parent 1d32921e1f
commit c2c0970a40
8 changed files with 96 additions and 70 deletions
+4 -4
View File
@@ -1185,7 +1185,7 @@ StyleDef g_StyleDefs[NUM_STYLES] =
GAME_DANCE, // m_Game GAME_DANCE, // m_Game
false, // m_bUsedForGameplay false, // m_bUsedForGameplay
true, // m_bUsedForEdit true, // m_bUsedForEdit
"couple (edit)", // m_szName "couple-edit", // m_szName
STEPS_TYPE_DANCE_COUPLE, // m_StepsType STEPS_TYPE_DANCE_COUPLE, // m_StepsType
StyleDef::ONE_PLAYER_ONE_CREDIT, // m_StyleType StyleDef::ONE_PLAYER_ONE_CREDIT, // m_StyleType
{ 160, 480 }, // m_iCenterX { 160, 480 }, // m_iCenterX
@@ -1405,7 +1405,7 @@ StyleDef g_StyleDefs[NUM_STYLES] =
GAME_PUMP, // m_Game GAME_PUMP, // m_Game
false, // m_bUsedForGameplay false, // m_bUsedForGameplay
true, // m_bUsedForEdit true, // m_bUsedForEdit
"couple (edit)", // m_szName "couple-edit", // m_szName
STEPS_TYPE_PUMP_COUPLE, // m_StepsType STEPS_TYPE_PUMP_COUPLE, // m_StepsType
StyleDef::ONE_PLAYER_ONE_CREDIT, // m_StyleType StyleDef::ONE_PLAYER_ONE_CREDIT, // m_StyleType
{ 160, 480 }, // m_iCenterX { 160, 480 }, // m_iCenterX
@@ -1912,7 +1912,7 @@ StyleDef g_StyleDefs[NUM_STYLES] =
GAME_IIDX, // m_Game GAME_IIDX, // m_Game
false, // m_bUsedForGameplay false, // m_bUsedForGameplay
true, // m_bUsedForEdit true, // m_bUsedForEdit
"single5 (edit)", // m_szName "single5-edit", // m_szName
STEPS_TYPE_IIDX_SINGLE5, // m_StepsType STEPS_TYPE_IIDX_SINGLE5, // m_StepsType
StyleDef::ONE_PLAYER_ONE_CREDIT, // m_StyleType StyleDef::ONE_PLAYER_ONE_CREDIT, // m_StyleType
{ 160, 480 }, // m_iCenterX { 160, 480 }, // m_iCenterX
@@ -1947,7 +1947,7 @@ StyleDef g_StyleDefs[NUM_STYLES] =
GAME_IIDX, // m_Game GAME_IIDX, // m_Game
false, // m_bUsedForGameplay false, // m_bUsedForGameplay
true, // m_bUsedForEdit true, // m_bUsedForEdit
"double5 (edit)", // m_szName "double5-edit", // m_szName
STEPS_TYPE_IIDX_DOUBLE5, // m_StepsType STEPS_TYPE_IIDX_DOUBLE5, // m_StepsType
StyleDef::ONE_PLAYER_TWO_CREDITS, // m_StyleType StyleDef::ONE_PLAYER_TWO_CREDITS, // m_StyleType
{ 320, 320 }, // m_iCenterX { 320, 320 }, // m_iCenterX
+12 -12
View File
@@ -54,19 +54,19 @@ XNode* HighScore::CreateNode() const
return pNode; return pNode;
} }
void HighScore::LoadFromNode( XNode* pNode ) void HighScore::LoadFromNode( const XNode* pNode )
{ {
ASSERT( pNode->name == "HighScore" ); ASSERT( pNode->name == "HighScore" );
XNodes childs = pNode->GetChilds(); for( XNodes::const_iterator child = pNode->childs.begin();
for( unsigned i = 0 ; i < childs.size(); i++) child != pNode->childs.end();
child++ )
{ {
XNode* pChild = childs[i]; if( (*child)->name == "Name" ) (*child)->GetValue( sName );
if( pChild->name == "Name" ) pChild->GetValue( sName ); else if( (*child)->name == "Grade" ) (*child)->GetValue( (int&)grade );
else if( pChild->name == "Grade" ) pChild->GetValue( (int&)grade ); else if( (*child)->name == "Score" ) (*child)->GetValue( iScore );
else if( pChild->name == "Score" ) pChild->GetValue( iScore ); else if( (*child)->name == "PercentDP" ) (*child)->GetValue( fPercentDP );
else if( pChild->name == "PercentDP" ) pChild->GetValue( fPercentDP ); else if( (*child)->name == "SurviveSeconds" ) (*child)->GetValue( fSurviveSeconds );
else if( pChild->name == "SurviveSeconds" ) pChild->GetValue( fSurviveSeconds ); else if( (*child)->name == "Modifiers" ) (*child)->GetValue( sModifiers );
else if( pChild->name == "Modifiers" ) pChild->GetValue( sModifiers );
} }
} }
@@ -124,12 +124,12 @@ XNode* HighScoreList::CreateNode() const
return pNode; return pNode;
} }
void HighScoreList::LoadFromNode( XNode* pNode ) void HighScoreList::LoadFromNode( const XNode* pNode )
{ {
Init(); Init();
ASSERT( pNode->name == "HighScoreList" ); ASSERT( pNode->name == "HighScoreList" );
for( XNodes::iterator child = pNode->childs.begin(); for( XNodes::const_iterator child = pNode->childs.begin();
child != pNode->childs.end(); child != pNode->childs.end();
child++) child++)
{ {
+2 -2
View File
@@ -35,7 +35,7 @@ struct HighScore
bool operator>=( const HighScore& other ) const; bool operator>=( const HighScore& other ) const;
XNode* CreateNode() const; XNode* CreateNode() const;
void LoadFromNode( XNode* pNode ); void LoadFromNode( const XNode* pNode );
}; };
struct HighScoreList struct HighScoreList
@@ -56,7 +56,7 @@ struct HighScoreList
const HighScore& GetTopScore() const; const HighScore& GetTopScore() const;
XNode* CreateNode() const; XNode* CreateNode() const;
void LoadFromNode( XNode* pNode ); void LoadFromNode( const XNode* pNode );
}; };
+28 -20
View File
@@ -40,10 +40,15 @@ public:
static CString GetProfileDisplayNameFromDir( CString sDir ); static CString GetProfileDisplayNameFromDir( CString sDir );
int GetSongNumTimesPlayed( const Song* pSong ) const; int GetSongNumTimesPlayed( const Song* pSong ) const;
//
// Editable data
//
CString m_sDisplayName;
float m_fWeightPounds;
// //
// General data // General data
// //
CString m_sName;
CString m_sLastUsedHighScoreName; CString m_sLastUsedHighScoreName;
bool m_bUsingProfileDefaultModifiers; bool m_bUsingProfileDefaultModifiers;
CString m_sDefaultModifiers; CString m_sDefaultModifiers;
@@ -51,7 +56,6 @@ public:
int m_iTotalPlaySeconds; int m_iTotalPlaySeconds;
int m_iTotalGameplaySeconds; int m_iTotalGameplaySeconds;
int m_iCurrentCombo; int m_iCurrentCombo;
float m_fWeightPounds;
int m_fCaloriesBurned; int m_fCaloriesBurned;
mutable CString m_sLastMachinePlayed; // mutable because we overwrite this on save, and I don't want to remove const from the whole save chain. -Chris mutable CString m_sLastMachinePlayed; // mutable because we overwrite this on save, and I don't want to remove const from the whole save chain. -Chris
int m_iNumSongsPlayedByPlayMode[NUM_PLAY_MODES]; int m_iNumSongsPlayedByPlayMode[NUM_PLAY_MODES];
@@ -124,12 +128,14 @@ public:
// //
void InitAll() void InitAll()
{ {
InitEditableData();
InitGeneralData(); InitGeneralData();
InitSongScores(); InitSongScores();
InitCourseScores(); InitCourseScores();
InitCategoryScores(); InitCategoryScores();
InitScreenshotData(); InitScreenshotData();
} }
void InitEditableData();
void InitGeneralData(); void InitGeneralData();
void InitSongScores(); void InitSongScores();
void InitCourseScores(); void InitCourseScores();
@@ -139,32 +145,34 @@ public:
// //
// Loading and saving // Loading and saving
// //
bool LoadAllFromDir( CString sDir ); bool LoadAllFromDir( CString sDir ); // return false on
bool SaveAllToDir( CString sDir ) const; bool SaveAllToDir( CString sDir ) const;
bool LoadGeneralDataFromDir( CString sDir ); void LoadProfileDataFromDirSM390a12( CString sDir );
bool SaveGeneralDataToDir( CString sDir ) const;
void LoadSongScoresFromDirSM390a12( CString sDir ); void LoadSongScoresFromDirSM390a12( CString sDir );
void LoadSongScoresFromDir( CString sDir );
void SaveSongScoresToDir( CString sDir ) const;
void DeleteSongScoresFromDirSM390a12( CString sDir ) const;
void LoadCourseScoresFromDirSM390a12( CString sDir ); void LoadCourseScoresFromDirSM390a12( CString sDir );
void LoadCourseScoresFromDir( CString sDir );
void SaveCourseScoresToDir( CString sDir ) const;
void DeleteCourseScoresFromDirSM390a12( CString sDir ) const;
void LoadCategoryScoresFromDirSM390a12( CString sDir ); void LoadCategoryScoresFromDirSM390a12( CString sDir );
void LoadCategoryScoresFromDir( CString sDir );
void SaveCategoryScoresToDir( CString sDir ) const; void LoadEditableDataFromNode( const XNode* pNode );
void LoadGeneralDataFromNode( const XNode* pNode );
void LoadSongScoresFromNode( const XNode* pNode );
void LoadCourseScoresFromNode( const XNode* pNode );
void LoadCategoryScoresFromNode( const XNode* pNode );
void LoadScreenshotDataFromNode( const XNode* pNode );
XNode* SaveEditableDataCreateNode() const;
XNode* SaveGeneralDataCreateNode() const;
XNode* SaveSongScoresCreateNode() const;
XNode* SaveCourseScoresCreateNode() const;
XNode* SaveCategoryScoresCreateNode() const;
XNode* SaveScreenshotDataCreateNode() const;
void DeleteProfileDataFromDirSM390a12( CString sDir ) const;
void DeleteSongScoresFromDirSM390a12( CString sDir ) const;
void DeleteCourseScoresFromDirSM390a12( CString sDir ) const;
void DeleteCategoryScoresFromDirSM390a12( CString sDir ) const; void DeleteCategoryScoresFromDirSM390a12( CString sDir ) const;
void LoadScreenshotDataFromDir( CString sDir );
void SaveScreenshotDataToDir( CString sDir ) const;
void SaveStatsWebPageToDir( CString sDir ) const; void SaveStatsWebPageToDir( CString sDir ) const;
void SaveMachinePublicKeyToDir( CString sDir ) const; void SaveMachinePublicKeyToDir( CString sDir ) const;
}; };
+22 -13
View File
@@ -150,7 +150,7 @@ void PrintStatistics( RageFile &f, const Profile *pProfile, CString sTitle, vect
PRINT_OPEN(f,"General Info",true); PRINT_OPEN(f,"General Info",true);
{ {
BEGIN_TABLE(2); BEGIN_TABLE(2);
TABLE_LINE2( "Name", pProfile->m_sName ); TABLE_LINE2( "DisplayName", pProfile->m_sDisplayName );
TABLE_LINE2( "LastUsedHighScoreName", pProfile->m_sLastUsedHighScoreName ); TABLE_LINE2( "LastUsedHighScoreName", pProfile->m_sLastUsedHighScoreName );
TABLE_LINE2( "UsingProfileDefaultModifiers", pProfile->m_bUsingProfileDefaultModifiers ); TABLE_LINE2( "UsingProfileDefaultModifiers", pProfile->m_bUsingProfileDefaultModifiers );
TABLE_LINE2( "DefaultModifiers", pProfile->m_sDefaultModifiers ); TABLE_LINE2( "DefaultModifiers", pProfile->m_sDefaultModifiers );
@@ -653,23 +653,32 @@ void PrintBookkeeping( RageFile &f, const Profile *pProfile, CString sTitle, vec
PRINT_CLOSE(f); PRINT_CLOSE(f);
} }
void PrintScreenshot( RageFile &f, const Profile::Screenshot &ss )
{
CString sHtmlPath = "Screenshots/"+ss.sFileName;
CString sImgTag = ssprintf("<a href='%s' target='_new'><img class='screenshot' src='%s' width='160' height='120'></a>", sHtmlPath.c_str(), sHtmlPath.c_str() );
CString sDetails = "<p>This is a screenshot</p>\n<p>We have no idea where it came from</p>";
BEGIN_TABLE(1);
TABLE_LINE2( sImgTag, sDetails );
END_TABLE;
}
void PrintScreenshots( RageFile &f, const Profile *pProfile, CString sTitle, CString sProfileDir ) void PrintScreenshots( RageFile &f, const Profile *pProfile, CString sTitle, CString sProfileDir )
{ {
PRINT_OPEN(f, sTitle ); PRINT_OPEN(f, sTitle );
{ {
CStringArray asFiles; PRINT_OPEN(f, "Less Than 1 Month Old" );
GetDirListing( sProfileDir+"Screenshots/*.jpg", asFiles );
BEGIN_TABLE(2);
for( unsigned i=0; i<asFiles.size(); i++ )
{ {
CString sFile = "Screenshots/"+asFiles[i]; for( int i=0; i<pProfile->m_vScreenshots.size(); i++ )
{
CString sImgTag = ssprintf("<a href='%s' target='_new'><img class='screenshot' src='%s' width='160' height='120'></a>", sFile.c_str(), sFile.c_str() ); const Profile::Screenshot &ss = pProfile->m_vScreenshots[i];
PrintScreenshot( f, ss );
TABLE_LINE1( sImgTag ); }
} }
END_TABLE; PRINT_CLOSE(f);
} }
PRINT_CLOSE(f); PRINT_CLOSE(f);
} }
@@ -793,7 +802,7 @@ TITLE.c_str(), STYLE_CSS ) );
CString sName = CString sName =
pProfile->m_sLastUsedHighScoreName.empty() ? pProfile->m_sLastUsedHighScoreName.empty() ?
pProfile->m_sName : pProfile->m_sDisplayName :
pProfile->m_sLastUsedHighScoreName; pProfile->m_sLastUsedHighScoreName;
time_t ltime = time( NULL ); time_t ltime = time( NULL );
CString sTime = ctime( &ltime ); CString sTime = ctime( &ltime );
+5 -13
View File
@@ -116,7 +116,7 @@ bool ProfileManager::CreateProfile( CString sProfileDir, CString sName )
bool bResult; bool bResult;
Profile pro; Profile pro;
pro.m_sName = sName; pro.m_sDisplayName = sName;
bResult = pro.SaveAllToDir( sProfileDir ); bResult = pro.SaveAllToDir( sProfileDir );
if( !bResult ) if( !bResult )
return false; return false;
@@ -249,15 +249,7 @@ bool ProfileManager::CreateLocalProfile( CString sName )
return false; return false;
sProfileDir += "/"; sProfileDir += "/";
Profile pro; return CreateProfile( sProfileDir, sName );
pro.m_sName = sName;
bool bResult = pro.SaveAllToDir( sProfileDir );
if( !bResult )
return false;
FlushDirCache();
return true;
} }
bool ProfileManager::RenameLocalProfile( CString sProfileID, CString sNewName ) bool ProfileManager::RenameLocalProfile( CString sProfileID, CString sNewName )
@@ -271,7 +263,7 @@ bool ProfileManager::RenameLocalProfile( CString sProfileID, CString sNewName )
bResult = pro.LoadAllFromDir( sProfileDir ); bResult = pro.LoadAllFromDir( sProfileDir );
if( !bResult ) if( !bResult )
return false; return false;
pro.m_sName = sNewName; pro.m_sDisplayName = sNewName;
bResult = pro.SaveAllToDir( sProfileDir ); bResult = pro.SaveAllToDir( sProfileDir );
if( !bResult ) if( !bResult )
return false; return false;
@@ -297,7 +289,7 @@ void ProfileManager::SaveMachineProfile()
// If the machine name has changed, make sure we use the new name. // If the machine name has changed, make sure we use the new name.
// It's important that this name be applied before the Player profiles // It's important that this name be applied before the Player profiles
// are saved, so that the Player's profiles show the right machine name. // are saved, so that the Player's profiles show the right machine name.
m_MachineProfile.m_sName = PREFSMAN->m_sMachineName; m_MachineProfile.m_sDisplayName = PREFSMAN->m_sMachineName;
m_MachineProfile.SaveAllToDir( MACHINE_PROFILE_DIR ); m_MachineProfile.SaveAllToDir( MACHINE_PROFILE_DIR );
} }
@@ -317,7 +309,7 @@ void ProfileManager::LoadMachineProfile()
} }
// If the machine name has changed, make sure we use the new name // If the machine name has changed, make sure we use the new name
m_MachineProfile.m_sName = PREFSMAN->m_sMachineName; m_MachineProfile.m_sDisplayName = PREFSMAN->m_sMachineName;
} }
/* /*
+14
View File
@@ -785,6 +785,20 @@ LPXNode _tagXMLNode::GetChild( LPCTSTR name )
return NULL; return NULL;
} }
const LPXNode _tagXMLNode::GetChild( LPCTSTR name ) const
{
for( unsigned i = 0 ; i < childs.size(); i++ )
{
LPXNode node = childs[i];
if( node )
{
if( node->name == name )
return node;
}
}
return NULL;
}
//======================================================== //========================================================
// Name : GetChildValue // Name : GetChildValue
// Desc : Find child with name and return child's value // Desc : Find child with name and return child's value
+9 -6
View File
@@ -123,9 +123,10 @@ typedef struct _tagXMLNode
// name and value // name and value
CString name; CString name;
CString value; CString value;
void GetValue(CString &out) { out = value; } void GetValue(CString &out) const { out = value; }
void GetValue(int &out) { out = atoi(value); } void GetValue(int &out) const { out = atoi(value); }
void GetValue(float &out) { out = (float) atof(value); } void GetValue(float &out) const { out = (float) atof(value); }
void GetValue(bool &out) const { out = atoi(value) != 0; }
// internal variables // internal variables
LPXNode parent; // parent node LPXNode parent; // parent node
@@ -146,11 +147,13 @@ typedef struct _tagXMLNode
XAttrs GetAttrs( LPCTSTR name ); XAttrs GetAttrs( LPCTSTR name );
// in one level child nodes // in one level child nodes
const LPXNode GetChild( LPCTSTR name ) const;
LPXNode GetChild( LPCTSTR name ); LPXNode GetChild( LPCTSTR name );
LPCTSTR GetChildValue( 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,CString &out) const { const 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,int &out) const { const 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; } bool GetChildValue(LPCTSTR name,float &out) const { const XNode* pChild=GetChild(name); if(pChild==NULL) return false; pChild->GetValue(out); return true; }
bool GetChildValue(LPCTSTR name,bool &out) const { const XNode* pChild=GetChild(name); if(pChild==NULL) return false; pChild->GetValue(out); return true; }
XNodes GetChilds( LPCTSTR name ); XNodes GetChilds( LPCTSTR name );
XNodes GetChilds(); XNodes GetChilds();