From fcff80559afa7b33052f8b9767b2526d2e11348d Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sat, 22 May 2004 20:42:28 +0000 Subject: [PATCH] keep a list of styles and StepsTypes to show, instead of toggles for each, since that causes ProfileHtml metrics to become out of date each time a style or StepsType is added --- stepmania/src/ProfileHtml.cpp | 52 +++++++++++++++++++++++++++++------ 1 file changed, 43 insertions(+), 9 deletions(-) diff --git a/stepmania/src/ProfileHtml.cpp b/stepmania/src/ProfileHtml.cpp index b2a3e24b39..fd2412c57d 100644 --- a/stepmania/src/ProfileHtml.cpp +++ b/stepmania/src/ProfileHtml.cpp @@ -39,9 +39,9 @@ const CString STYLE_CSS = "Style.css"; #define VERIFICATION_TEXT THEME->GetMetric("ProfileHtml","VerificationText") #define SHOW_PLAY_MODE(pm) THEME->GetMetricB("ProfileHtml","ShowPlayMode"+PlayModeToString(pm)) #define SHOW_RADAR_CATEGORY(rc) THEME->GetMetricB("ProfileHtml","ShowRadarCategory"+RadarCategoryToString(rc)) -#define SHOW_STYLE(s) THEME->GetMetricB("ProfileHtml","ShowStyle"+Capitalize(GAMEMAN->GetStyleDefForStyle(s)->m_szName)) #define SHOW_DIFFICULTY(dc) THEME->GetMetricB("ProfileHtml","ShowDifficulty"+DifficultyToString(dc)) -#define SHOW_STEPS_TYPE(st) THEME->GetMetricB("ProfileHtml","ShowStepsType"+Capitalize(GAMEMAN->NotesTypeToString(st))) +#define STYLES_TO_SHOW THEME->GetMetric ("ProfileHtml","StylesToShow") +#define STEPS_TYPES_TO_SHOW THEME->GetMetric ("ProfileHtml","StepsTypesToShow") #define SHOW_HIGH_SCORE_SCORE THEME->GetMetricB("ProfileHtml","ShowHighScoreScore") #define SHOW_HIGH_SCORE_GRADE THEME->GetMetricB("ProfileHtml","ShowHighScoreGrade") #define SHOW_HIGH_SCORE_PERCENT THEME->GetMetricB("ProfileHtml","ShowHighScorePercent") @@ -311,6 +311,20 @@ void PrintInstructions( RageFile &f, const Profile *pProfile, CString sTitle ) void PrintStatistics( RageFile &f, const Profile *pProfile, CString sTitle, vector &vpSongs, vector &vpAllSteps, vector &vStepsTypesToShow, map mapStepsToSong, vector vpCourses ) { + /* We don't convert these to Style, because Style is game-specific and these strings + * affect all styles with the same name. */ + set StylesToShow; + { + CString sStyles = STYLES_TO_SHOW; + vector vStyles; + split( sStyles, ",", vStyles, true ); + for( unsigned i = 0; i < vStyles.size(); ++i ) + { + vStyles[i].MakeLower(); + StylesToShow.insert(vStyles[i]); + } + } + PRINT_OPEN(f,sTitle,true); { PRINT_OPEN(f,"General Info",true); @@ -365,7 +379,7 @@ void PrintStatistics( RageFile &f, const Profile *pProfile, CString sTitle, vect // only show if this style plays a StepsType that we're showing if( find(vStepsTypesToShow.begin(),vStepsTypesToShow.end(),st) == vStepsTypesToShow.end() ) continue; // skip - if( !SHOW_STYLE(style) ) + if( StylesToShow.find(pStyleDef->m_szName) == StylesToShow.end() ) continue; CString s = GAMEMAN->StyleToThemedString(style); TABLE_LINE2( s, pProfile->m_iNumSongsPlayedByStyle[style] ); @@ -1330,13 +1344,32 @@ void SaveStatsWebPage( // Calculate which StepTypes to show // vector vStepsTypesToShow; - for( StepsType st=(StepsType)0; st vTypes; + split( sShow, ",", vTypes, true ); + for( unsigned i = 0; i < vTypes.size(); ++i ) + { + StepsType st = GAMEMAN->StringToNotesType( vTypes[i] ); + if( st == STEPS_TYPE_INVALID ) + { + LOG->Warn( "ProfileHtml::StepsTypesToShow: unknown steps type \"%s\"", vTypes[i].c_str() ); + continue; + } + + vStepsTypesToShow.push_back( st ); + } + } + + for( unsigned i = 0; i < vStepsTypesToShow.size(); ++i ) + { + StepsType st = vStepsTypesToShow[i]; + // don't show if there are no Steps of this StepsType bool bOneSongHasStepsForThisStepsType = false; - for( unsigned i=0; i vpSteps; pSong->GetSteps( vpSteps, st, DIFFICULTY_INVALID, -1, -1, "", false ); if( !vpSteps.empty() ) @@ -1346,10 +1379,11 @@ void SaveStatsWebPage( } } if( !bOneSongHasStepsForThisStepsType ) + { + vStepsTypesToShow.erase( vStepsTypesToShow.begin()+i ); + --i; continue; - if( !SHOW_STEPS_TYPE(st) ) - continue; - vStepsTypesToShow.push_back( st ); + } } //