diff --git a/src/Profile.cpp b/src/Profile.cpp index 1728500701..20d9236760 100644 --- a/src/Profile.cpp +++ b/src/Profile.cpp @@ -39,6 +39,7 @@ const RString EDIT_COURSES_SUBDIR = "EditCourses/"; //const RString UPLOAD_SUBDIR = "Upload/"; const RString RIVAL_SUBDIR = "Rivals/"; +ThemeMetric SHOW_COIN_DATA( "Profile", "ShowCoinData" ); static Preference g_bProfileDataCompress( "ProfileDataCompress", false ); static ThemeMetric UNLOCK_AUTH_STRING( "Profile", "UnlockAuthString" ); #define GUID_SIZE_BYTES 8 @@ -948,6 +949,8 @@ XNode *Profile::SaveStatsXmlCreateNode() const xml->AppendChild( SaveCategoryScoresCreateNode() ); xml->AppendChild( SaveScreenshotDataCreateNode() ); xml->AppendChild( SaveCalorieDataCreateNode() ); + if( SHOW_COIN_DATA.GetValue() && IsMachine() ) + xml->AppendChild( SaveCoinDataCreateNode() ); return xml; } @@ -1836,6 +1839,48 @@ bool Profile::IsMachine() const return this == PROFILEMAN->GetMachineProfile(); } + +XNode* Profile::SaveCoinDataCreateNode() const +{ + CHECKPOINT; + + const Profile* pProfile = this; + ASSERT( pProfile != NULL ); + + XNode* pNode = new XNode( "CoinData" ); + + { + int coins[NUM_LAST_DAYS]; + BOOKKEEPER->GetCoinsLastDays( coins ); + XNode* p = pNode->AppendChild( "LastDays" ); + for( int i=0; iAppendChild( LastDayToString(i), coins[i] ); + } + { + int coins[NUM_LAST_WEEKS]; + BOOKKEEPER->GetCoinsLastWeeks( coins ); + XNode* p = pNode->AppendChild( "LastWeeks" ); + for( int i=0; iAppendChild( LastWeekToString(i), coins[i] ); + } + { + int coins[DAYS_IN_WEEK]; + BOOKKEEPER->GetCoinsByDayOfWeek( coins ); + XNode* p = pNode->AppendChild( "DayOfWeek" ); + for( int i=0; iAppendChild( DayOfWeekToString(i), coins[i] ); + } + { + int coins[HOURS_IN_DAY]; + BOOKKEEPER->GetCoinsByHour( coins ); + XNode* p = pNode->AppendChild( "Hour" ); + for( int i=0; iAppendChild( HourInDayToString(i), coins[i] ); + } + + return pNode; +} + void Profile::MoveBackupToDir( RString sFromDir, RString sToDir ) { if( FILEMAN->IsAFile(sFromDir + STATS_XML) && diff --git a/src/Profile.h b/src/Profile.h index b791d9dab1..d86941b14c 100644 --- a/src/Profile.h +++ b/src/Profile.h @@ -369,6 +369,8 @@ public: XNode* SaveScreenshotDataCreateNode() const; XNode* SaveCalorieDataCreateNode() const; + XNode* SaveCoinDataCreateNode() const; + void SaveStatsWebPageToDir( RString sDir ) const; void SaveMachinePublicKeyToDir( RString sDir ) const;