diff --git a/stepmania/src/CatalogXml.cpp b/stepmania/src/CatalogXml.cpp index 6541755155..6355eae9ec 100644 --- a/stepmania/src/CatalogXml.cpp +++ b/stepmania/src/CatalogXml.cpp @@ -22,6 +22,7 @@ #include "UnlockManager.h" #include "arch/LoadingWindow/LoadingWindow.h" #include "LocalizedString.h" +#include "RageTimer.h" #define SHOW_PLAY_MODE(pm) THEME->GetMetricB("CatalogXml",ssprintf("ShowPlayMode%s",PlayModeToString(pm).c_str())) #define SHOW_STYLE(ps) THEME->GetMetricB("CatalogXml",ssprintf("ShowStyle%s",Capitalize((ps)->m_szName).c_str())) @@ -49,11 +50,17 @@ void CatalogXml::Save( LoadingWindow *loading_window ) RString fn = CATALOG_XML_FILE; LOG->Trace( "Writing %s ...", fn.c_str() ); - + RageTimer timer; + float f; +#define TIME(x) {f = timer.Ago(); LOG->Trace( "Writing " #x " took %f seconds.", f ); timer.Touch();} XNode xml( "Catalog" ); const vector &vStepsTypesToShow = CommonMetrics::STEPS_TYPES_TO_SHOW.GetValue(); - + const vector &vDifficultiesToShow = CommonMetrics::DIFFICULTIES_TO_SHOW.GetValue(); + const vector &vCourseDifficultiesToShow = CommonMetrics::COURSE_DIFFICULTIES_TO_SHOW.GetValue(); + const bool bWriteSimpleValues = THEME->GetMetricB( "RadarValues", "WriteSimpleValues" ); + const bool bWriteComplexValues = THEME->GetMetricB( "RadarValues", "WriteComplexValues" ); + { XNode* pNode = xml.AppendChild( "Totals" ); XNode* pNumSongsByGroup = pNode->AppendChild( "NumSongsByGroup" ); @@ -97,7 +104,7 @@ void CatalogXml::Save( LoadingWindow *loading_window ) continue; // skip: Locked song. iTotalSongs++; iNumSongsInGroup++; - FOREACH_CONST( Difficulty, CommonMetrics::DIFFICULTIES_TO_SHOW.GetValue(), dc ) + FOREACH_CONST( Difficulty, vDifficultiesToShow, dc ) { Steps* pSteps = SongUtil::GetStepsByDifficulty( pSong, *st, *dc, false ); // no autogen @@ -158,14 +165,15 @@ void CatalogXml::Save( LoadingWindow *loading_window ) pNode->AppendChild( "NumUnlockedSteps", iNumUnlockedSteps ); pNode->AppendChild( "NumUnlockedCourses", iNumUnlockedCourses ); } - + TIME(Totals) { XNode* pNode = xml.AppendChild( "Songs" ); - vector vpSongs = SONGMAN->GetAllSongs(); + const vector& vpSongs = SONGMAN->GetAllSongs(); + for( unsigned i=0; iAppendChild( pStepsIDNode ); pStepsIDNode->AppendChild( "Meter", pSteps->GetMeter() ); - pStepsIDNode->AppendChild( pSteps->GetRadarValues(PLAYER_1).CreateNode() ); + pStepsIDNode->AppendChild( pSteps->GetRadarValues(PLAYER_1).CreateNode(bWriteSimpleValues, bWriteComplexValues) ); } } } } - + TIME(Songs) { XNode* pNode = xml.AppendChild( "Courses" ); @@ -240,11 +248,10 @@ void CatalogXml::Save( LoadingWindow *loading_window ) pCourseNode->AppendChild( "SubTitle", pCourse->GetDisplaySubTitle() ); pCourseNode->AppendChild( "HasMods", pCourse->HasMods() ); - const vector &vDiffs = CommonMetrics::COURSE_DIFFICULTIES_TO_SHOW.GetValue(); FOREACH_CONST( StepsType, vStepsTypesToShow, st ) { - FOREACH_CONST( CourseDifficulty, vDiffs, dc ) + FOREACH_CONST( CourseDifficulty, vCourseDifficultiesToShow, dc ) { Trail *pTrail = pCourse->GetTrail( *st, *dc ); if( pTrail == NULL ) @@ -259,18 +266,18 @@ void CatalogXml::Save( LoadingWindow *loading_window ) pCourseNode->AppendChild( pTrailIDNode ); pTrailIDNode->AppendChild( "Meter", pTrail->GetMeter() ); - pTrailIDNode->AppendChild( pTrail->GetRadarValues().CreateNode() ); + pTrailIDNode->AppendChild( pTrail->GetRadarValues().CreateNode(bWriteSimpleValues, bWriteComplexValues) ); } } } } - + TIME(Courses) { XNode* pNode = xml.AppendChild( "Types" ); { XNode* pNode2 = pNode->AppendChild( "Difficulty" ); - FOREACH_CONST( Difficulty, CommonMetrics::DIFFICULTIES_TO_SHOW.GetValue(), iter ) + FOREACH_CONST( Difficulty, vDifficultiesToShow, iter ) { XNode* pNode3 = pNode2->AppendChild( "Difficulty", DifficultyToString(*iter) ); pNode3->AppendAttr( "DisplayAs", DifficultyToLocalizedString(*iter) ); @@ -279,7 +286,7 @@ void CatalogXml::Save( LoadingWindow *loading_window ) { XNode* pNode2 = pNode->AppendChild( "CourseDifficulty" ); - FOREACH_CONST( CourseDifficulty, CommonMetrics::COURSE_DIFFICULTIES_TO_SHOW.GetValue(), iter ) + FOREACH_CONST( CourseDifficulty, vCourseDifficultiesToShow, iter ) { XNode* pNode3 = pNode2->AppendChild( "CourseDifficulty", DifficultyToString(*iter) ); pNode3->AppendAttr( "DisplayAs", CourseDifficultyToLocalizedString(*iter) ); @@ -384,16 +391,17 @@ void CatalogXml::Save( LoadingWindow *loading_window ) } } } - + TIME(Types) xml.AppendChild( "InternetRankingHomeUrl", INTERNET_RANKING_HOME_URL ); xml.AppendChild( "InternetRankingUploadUrl", INTERNET_RANKING_UPLOAD_URL ); xml.AppendChild( "InternetRankingViewGuidUrl", INTERNET_RANKING_VIEW_GUID_URL ); xml.AppendChild( "ProductTitle", PRODUCT_TITLE ); xml.AppendChild( "FooterText", FOOTER_TEXT ); xml.AppendChild( "FooterLink", FOOTER_LINK ); - + TIME(Misc) XmlFileUtil::SaveToFile( &xml, fn, CATALOG_XSL, false ); - + TIME(to disk) +#undef TIME LOG->Trace( "Done." ); } diff --git a/stepmania/src/HighScore.cpp b/stepmania/src/HighScore.cpp index cb73cf411f..0b6ea7b729 100644 --- a/stepmania/src/HighScore.cpp +++ b/stepmania/src/HighScore.cpp @@ -80,6 +80,8 @@ HighScoreImpl::HighScoreImpl() XNode *HighScoreImpl::CreateNode() const { XNode *pNode = new XNode( "HighScore" ); + const bool bWriteSimpleValues = THEME->GetMetricB( "RadarValues", "WriteSimpleValues" ); + const bool bWriteComplexValues = THEME->GetMetricB( "RadarValues", "WriteComplexValues" ); // TRICKY: Don't write "name to fill in" markers. pNode->AppendChild( "Name", IsRankingToFillIn(sName) ? RString("") : sName ); @@ -100,7 +102,7 @@ XNode *HighScoreImpl::CreateNode() const FOREACH_HoldNoteScore( hns ) if( hns != HNS_None ) // HACK: don't save meaningless "none" count pHoldNoteScores->AppendChild( HoldNoteScoreToString(hns), iHoldNoteScores[hns] ); - pNode->AppendChild( radarValues.CreateNode() ); + pNode->AppendChild( radarValues.CreateNode(bWriteSimpleValues, bWriteComplexValues) ); pNode->AppendChild( "LifeRemainingSeconds", fLifeRemainingSeconds ); return pNode; diff --git a/stepmania/src/RadarValues.cpp b/stepmania/src/RadarValues.cpp index 0b97aa7bde..aa6a955101 100644 --- a/stepmania/src/RadarValues.cpp +++ b/stepmania/src/RadarValues.cpp @@ -5,9 +5,6 @@ #include "XmlFile.h" #include "ThemeManager.h" -#define WRITE_COMPLEX_VALUES THEME->GetMetricB("RadarValues","WriteComplexValues") -#define WRITE_SIMPLE_VALUES THEME->GetMetricB("RadarValues","WriteSimpleValues") - RadarValues::RadarValues() { MakeUnknown(); @@ -25,7 +22,7 @@ void RadarValues::Zero() m_Values.f[rc] = 0; } -XNode* RadarValues::CreateNode() const +XNode* RadarValues::CreateNode( bool bIncludeSimpleValues, bool bIncludeComplexValues ) const { XNode* pNode = new XNode( "RadarValues" ); @@ -34,12 +31,12 @@ XNode* RadarValues::CreateNode() const { if( rc >= RadarCategory_TapsAndHolds ) { - if( WRITE_SIMPLE_VALUES ) + if( bIncludeSimpleValues ) pNode->AppendChild( RadarCategoryToString(rc), (int)m_Values.f[rc] ); } else { - if( WRITE_COMPLEX_VALUES ) + if( bIncludeComplexValues ) pNode->AppendChild( RadarCategoryToString(rc), m_Values.f[rc] ); } } diff --git a/stepmania/src/RadarValues.h b/stepmania/src/RadarValues.h index cba2a01ab3..fafbb867b9 100644 --- a/stepmania/src/RadarValues.h +++ b/stepmania/src/RadarValues.h @@ -59,7 +59,7 @@ struct RadarValues return !operator==( other ); } - XNode* CreateNode() const; + XNode* CreateNode( bool bIncludeSimpleValues, bool bIncludeComplexValues ) const; void LoadFromNode( const XNode* pNode ); RString ToString( int iMaxValues = -1 ) const; // default = all