From 771889d948ea0aeedec1682153663a310a3df7bc Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Mon, 23 Feb 2004 01:44:04 +0000 Subject: [PATCH] clean up calorie table --- stepmania/src/Profile.cpp | 7 +++---- stepmania/src/ProfileHtml.cpp | 27 ++++++++++++++++----------- stepmania/src/TimeConstants.cpp | 8 ++++++-- stepmania/src/TimeConstants.h | 1 + 4 files changed, 26 insertions(+), 17 deletions(-) diff --git a/stepmania/src/Profile.cpp b/stepmania/src/Profile.cpp index 5bdbfa8160..b56c3dfb98 100644 --- a/stepmania/src/Profile.cpp +++ b/stepmania/src/Profile.cpp @@ -139,7 +139,7 @@ CString Profile::GetDisplayTotalCaloriesBurned() const if( m_fWeightPounds == 0 ) // weight not entered return "N/A"; else - return ssprintf("%0.3f Cal",m_fTotalCaloriesBurned); + return Commify(m_fTotalCaloriesBurned) + " Cal"; } int Profile::GetTotalNumSongsPlayed() const @@ -742,9 +742,8 @@ void Profile::AddStepTotals( int iTotalTapsAndHolds, int iTotalJumps, int iTotal SCALE( m_fWeightPounds, 100.f, 200.f, 0.222f, 0.386f ) * iTotalHands; m_fTotalCaloriesBurned += fCals; - time_t cur_time = time(NULL); - tm *cur_tm = localtime( &cur_time ); - Day day = { cur_tm->tm_yday, cur_tm->tm_year+1900 }; + tm cur_tm = GetLocalTime(); + Day day = { cur_tm.tm_yday, cur_tm.tm_year+1900 }; m_mapDayToCaloriesBurned[day] += fCals; } } diff --git a/stepmania/src/ProfileHtml.cpp b/stepmania/src/ProfileHtml.cpp index 84f6d50819..6c0f8aa79f 100644 --- a/stepmania/src/ProfileHtml.cpp +++ b/stepmania/src/ProfileHtml.cpp @@ -654,6 +654,8 @@ bool PrintHighScoresForSong( RageFile &f, const Profile *pProfile, Song* pSong ) bool PrintHighScoresForCourse( RageFile &f, const Profile *pProfile, Course* pCourse ) { + bool bPrintedAny = false; + for( StepsType st=(StepsType)0; stNotesTypeToString(st)+" - "+CourseDifficultyToString(cd) ); { PrintHighScoreListTable( f, hsl ); @@ -670,7 +674,7 @@ bool PrintHighScoresForCourse( RageFile &f, const Profile *pProfile, Course* pCo } } - return true; + return bPrintedAny; } bool PrintHighScoresForGroup(RageFile &f, const Profile *pProfile, CString sGroup ) @@ -936,9 +940,10 @@ void PrintScreenshots( RageFile &f, const Profile *pProfile, CString sTitle, CSt for( int i = (int)pProfile->m_vScreenshots.size()-1; i >= 0; i-- ) { Profile::Screenshot ss = pProfile->m_vScreenshots[i]; - tm* new_time = localtime( &ss.time ); - int iYear = new_time->tm_year+1900; - int iMonth = new_time->tm_mon+1; + tm new_time; + localtime_r( &ss.time, &new_time ); + int iYear = new_time.tm_year+1900; + int iMonth = new_time.tm_mon+1; CString sNewMonth = ssprintf("%02d/%d", iMonth, iYear ); if( sNewMonth != sCurrentMonth ) @@ -971,21 +976,20 @@ void PrintCaloriesBurned( RageFile &f, const Profile *pProfile, CString sTitle, { PRINT_OPEN(f, sTitle ); { - f.Write("\n"); + f.Write("
\n"); // header row f.Write(""); f.Write(""); { for( int i=0; i"+DayOfWeekToString(i)+""); + f.Write(""); } f.Write(""); f.Write(""); // row for each week - time_t now = time( NULL ); - tm when = *localtime( &now ); + tm when = GetLocalTime(); when = GetNextSunday( when ); when = AddDays( when, -DAYS_IN_WEEK ); { @@ -999,10 +1003,10 @@ void PrintCaloriesBurned( RageFile &f, const Profile *pProfile, CString sTitle, Profile::Day day = { when.tm_yday, when.tm_year+1900 }; float fDayCals = pProfile->GetCaloriesBurnedForDay( day ); fWeekCals += fDayCals; - f.Write(""); + f.Write(""); when = AddDays( when, +1 ); } - f.Write(""); + f.Write(""); f.Write(""); when = AddDays( when, -DAYS_IN_WEEK*2 ); } @@ -1167,7 +1171,8 @@ TITLE.c_str(), STYLE_CSS.c_str() ) ); PrintCaloriesBurned( f, pProfile, "My Calories Burned", sDir ); PrintGradeTable( f, pProfile, "My Grade Table", vpSongs, vpAllSteps, vStepsTypesToShow, mapStepsToSong, vpCourses ); PrintPopularity( f, pProfile, "Last Machine Popularity", vpSongs, vpAllSteps, vStepsTypesToShow, mapStepsToSong, vpCourses ); - PrintSongHighScores( f, pProfile, "Last Machine High Scores", vpSongs, vpAllSteps, vStepsTypesToShow, mapStepsToSong, vpCourses ); + PrintSongHighScores( f, pProfile, "Last Machine Song High Scores", vpSongs, vpAllSteps, vStepsTypesToShow, mapStepsToSong, vpCourses ); + PrintCourseHighScores( f, pProfile, "Last Machine Course High Scores", vpSongs, vpAllSteps, vStepsTypesToShow, mapStepsToSong, vpCourses ); break; case HTML_TYPE_MACHINE: PrintStatistics( f, pProfile, "Statistics", vpSongs, vpAllSteps, vStepsTypesToShow, mapStepsToSong, vpCourses ); diff --git a/stepmania/src/TimeConstants.cpp b/stepmania/src/TimeConstants.cpp index 23295686d8..c46535109a 100644 --- a/stepmania/src/TimeConstants.cpp +++ b/stepmania/src/TimeConstants.cpp @@ -58,6 +58,11 @@ CString DayOfWeekToString( int iDayOfWeekIndex ) return DAY_OF_WEEK_TO_NAME[iDayOfWeekIndex]; } +CString DayOfWeekToShortString( int iDayOfWeekIndex ) +{ + return DayOfWeekToString(iDayOfWeekIndex).Left(3); +} + CString HourInDayToString( int iHourInDayIndex ) { return ssprintf("%02d:00", iHourInDayIndex); @@ -124,8 +129,7 @@ tm GetNextSunday( tm start ) tm GetDayInYearAndYear( int iDayInYearIndex, int iYear ) { - time_t now = time( NULL ); - tm when = *localtime( &now ); + tm when = GetLocalTime(); when.tm_mday = iDayInYearIndex; when.tm_year = iYear - 1900; diff --git a/stepmania/src/TimeConstants.h b/stepmania/src/TimeConstants.h index 940279d4b0..5c7a0a169c 100644 --- a/stepmania/src/TimeConstants.h +++ b/stepmania/src/TimeConstants.h @@ -24,6 +24,7 @@ const int MONTHS_IN_YEAR = 12; CString DayInYearToString( int iDayInYearIndex ); CString LastDayToString( int iLastDayIndex ); CString DayOfWeekToString( int iDayOfWeekIndex ); +CString DayOfWeekToShortString( int iDayOfWeekIndex ); CString HourInDayToString( int iHourIndex ); CString MonthToString( int iMonthIndex ); CString LastWeekToString( int iLastWeekIndex );
"+DayOfWeekToShortString(i)+"Total
"+ssprintf("%0.3f",fDayCals)+""+((fDayCals==0)?"":Commify(fDayCals))+""+ssprintf("%0.3f",fWeekCals)+""+Commify(fWeekCals)+"