add calorie tracking

clean up time formatting functions
This commit is contained in:
Chris Danford
2004-02-22 19:51:46 +00:00
parent e8347d25e4
commit 6154c14f86
18 changed files with 139 additions and 49 deletions
+1 -1
View File
@@ -85,7 +85,7 @@ bool LyricsLoader::LoadFromLRCFile(const CString& sPath, Song& out)
LyricSegment seg; LyricSegment seg;
seg.m_Color = CurrentColor; seg.m_Color = CurrentColor;
seg.m_fStartTime = TimeToSeconds(sValueName); seg.m_fStartTime = HHMMSSToSeconds(sValueName);
seg.m_sLyric = sValueData; seg.m_sLyric = sValueData;
seg.m_sLyric.Replace( "|","\n" ); // Pipe symbols denote a new line in LRC files seg.m_sLyric.Replace( "|","\n" ); // Pipe symbols denote a new line in LRC files
+2 -2
View File
@@ -310,10 +310,10 @@ float DWILoader::ParseBrokenDWITimestamp(const CString &arg1, const CString &arg
/* 2+ args */ /* 2+ args */
if(arg3.empty()) if(arg3.empty())
return TimeToSeconds( arg1+":"+arg2 ); return HHMMSSToSeconds( arg1+":"+arg2 );
/* 3+ args */ /* 3+ args */
return TimeToSeconds( arg1+":"+arg2+":"+arg3 ); return HHMMSSToSeconds( arg1+":"+arg2+":"+arg3 );
} }
bool DWILoader::LoadFromDWIFile( CString sPath, Song &out ) bool DWILoader::LoadFromDWIFile( CString sPath, Song &out )
+2 -2
View File
@@ -269,10 +269,10 @@ bool SMLoader::LoadFromSMFile( CString sPath, Song &out )
} }
else if( 0==stricmp(sValueName,"SAMPLESTART") ) else if( 0==stricmp(sValueName,"SAMPLESTART") )
out.m_fMusicSampleStartSeconds = TimeToSeconds( sParams[1] ); out.m_fMusicSampleStartSeconds = HHMMSSToSeconds( sParams[1] );
else if( 0==stricmp(sValueName,"SAMPLELENGTH") ) else if( 0==stricmp(sValueName,"SAMPLELENGTH") )
out.m_fMusicSampleLengthSeconds = TimeToSeconds( sParams[1] ); out.m_fMusicSampleLengthSeconds = HHMMSSToSeconds( sParams[1] );
else if( 0==stricmp(sValueName,"DISPLAYBPM") ) else if( 0==stricmp(sValueName,"DISPLAYBPM") )
{ {
+38 -3
View File
@@ -78,6 +78,11 @@ void Profile::InitGeneralData()
m_iNumToasties = 0; m_iNumToasties = 0;
m_UnlockedSongs.clear(); m_UnlockedSongs.clear();
m_sLastMachinePlayed = ""; m_sLastMachinePlayed = "";
m_iNumTapsAndHolds = 0;
m_iNumJumps = 0;
m_iNumHolds = 0;
m_iNumMines = 0;
m_iNumHands = 0;
int i; int i;
for( i=0; i<NUM_PLAY_MODES; i++ ) for( i=0; i<NUM_PLAY_MODES; i++ )
@@ -124,12 +129,12 @@ CString Profile::GetDisplayName() const
return "NoName"; return "NoName";
} }
CString Profile::GetDisplayCaloriesBurned() CString Profile::GetDisplayCaloriesBurned() const
{ {
if( m_fWeightPounds == 0 ) // weight not entered if( m_fWeightPounds == 0 ) // weight not entered
return "N/A"; return "N/A";
else else
return ssprintf("%iCal",m_fCaloriesBurned); return ssprintf("%0.3fCal",m_fCaloriesBurned);
} }
int Profile::GetTotalNumSongsPlayed() const int Profile::GetTotalNumSongsPlayed() const
@@ -497,6 +502,11 @@ XNode* Profile::SaveGeneralDataCreateNode() const
pGeneralDataNode->AppendChild( "NumExtraStagesPassed", m_iNumExtraStagesPassed ); pGeneralDataNode->AppendChild( "NumExtraStagesPassed", m_iNumExtraStagesPassed );
pGeneralDataNode->AppendChild( "NumExtraStagesFailed", m_iNumExtraStagesFailed ); pGeneralDataNode->AppendChild( "NumExtraStagesFailed", m_iNumExtraStagesFailed );
pGeneralDataNode->AppendChild( "NumToasties", m_iNumToasties ); pGeneralDataNode->AppendChild( "NumToasties", m_iNumToasties );
pGeneralDataNode->AppendChild( "NumTapsAndHolds", m_iNumTapsAndHolds );
pGeneralDataNode->AppendChild( "NumJumps", m_iNumJumps );
pGeneralDataNode->AppendChild( "NumHolds", m_iNumHolds );
pGeneralDataNode->AppendChild( "NumMines", m_iNumMines );
pGeneralDataNode->AppendChild( "NumHands", m_iNumHands );
{ {
XNode* pUnlockedSongs = pGeneralDataNode->AppendChild("UnlockedSongs"); XNode* pUnlockedSongs = pGeneralDataNode->AppendChild("UnlockedSongs");
@@ -605,7 +615,8 @@ void Profile::LoadEditableDataFromDir( CString sDir )
wstr = wstr.substr(0, 12); wstr = wstr.substr(0, 12);
m_sDisplayName = WStringToCString(wstr); m_sDisplayName = WStringToCString(wstr);
// TODO: strip invalid chars? // TODO: strip invalid chars?
CLAMP( m_fWeightPounds, 0, 500 ); if( m_fWeightPounds != 0 )
CLAMP( m_fWeightPounds, 50, 500 );
} }
void Profile::LoadGeneralDataFromNode( const XNode* pNode ) void Profile::LoadGeneralDataFromNode( const XNode* pNode )
@@ -624,6 +635,11 @@ void Profile::LoadGeneralDataFromNode( const XNode* pNode )
pNode->GetChildValue( "NumExtraStagesPassed", m_iNumExtraStagesPassed ); pNode->GetChildValue( "NumExtraStagesPassed", m_iNumExtraStagesPassed );
pNode->GetChildValue( "NumExtraStagesFailed", m_iNumExtraStagesFailed ); pNode->GetChildValue( "NumExtraStagesFailed", m_iNumExtraStagesFailed );
pNode->GetChildValue( "NumToasties", m_iNumToasties ); pNode->GetChildValue( "NumToasties", m_iNumToasties );
pNode->GetChildValue( "NumTapsAndHolds", m_iNumTapsAndHolds );
pNode->GetChildValue( "NumJumps", m_iNumJumps );
pNode->GetChildValue( "NumHolds", m_iNumHolds );
pNode->GetChildValue( "NumMines", m_iNumMines );
pNode->GetChildValue( "NumHands", m_iNumHands );
{ {
XNode* pUnlockedSongs = pNode->GetChild("UnlockedSongs"); XNode* pUnlockedSongs = pNode->GetChild("UnlockedSongs");
@@ -699,6 +715,25 @@ void Profile::LoadGeneralDataFromNode( const XNode* pNode )
} }
} }
void Profile::AddStepTotals( int iNumTapsAndHolds, int iNumJumps, int iNumHolds, int iNumMines, int iNumHands )
{
m_iNumTapsAndHolds += iNumTapsAndHolds;
m_iNumJumps += iNumJumps;
m_iNumHolds += iNumHolds;
m_iNumMines += iNumMines;
m_iNumHands += iNumHands;
if( m_fWeightPounds != 0 )
{
float fCals =
SCALE( m_fWeightPounds, 100.f, 200.f, 0.029f, 0.052f ) * iNumTapsAndHolds +
SCALE( m_fWeightPounds, 100.f, 200.f, 0.111f, 0.193f ) * iNumJumps +
SCALE( m_fWeightPounds, 100.f, 200.f, 0.029f, 0.052f ) * iNumHolds +
SCALE( m_fWeightPounds, 100.f, 200.f, 0.000f, 0.000f ) * iNumMines +
SCALE( m_fWeightPounds, 100.f, 200.f, 0.222f, 0.386f ) * iNumHands;
m_fCaloriesBurned += fCals;
}
}
XNode* Profile::SaveSongScoresCreateNode() const XNode* Profile::SaveSongScoresCreateNode() const
{ {
+7 -1
View File
@@ -66,7 +66,7 @@ public:
// smart accessors // smart accessors
// //
CString GetDisplayName() const; CString GetDisplayName() const;
CString GetDisplayCaloriesBurned(); CString GetDisplayCaloriesBurned() const;
int GetTotalNumSongsPlayed() const; int GetTotalNumSongsPlayed() const;
int GetTotalNumSongsPassed() const; int GetTotalNumSongsPassed() const;
static CString GetProfileDisplayNameFromDir( CString sDir ); static CString GetProfileDisplayNameFromDir( CString sDir );
@@ -93,6 +93,11 @@ public:
int m_iNumExtraStagesPassed; int m_iNumExtraStagesPassed;
int m_iNumExtraStagesFailed; int m_iNumExtraStagesFailed;
int m_iNumToasties; int m_iNumToasties;
int m_iNumTapsAndHolds;
int m_iNumJumps;
int m_iNumHolds;
int m_iNumMines;
int m_iNumHands;
set<int> m_UnlockedSongs; set<int> m_UnlockedSongs;
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];
@@ -102,6 +107,7 @@ public:
int m_iNumSongsPassedByPlayMode[NUM_PLAY_MODES]; int m_iNumSongsPassedByPlayMode[NUM_PLAY_MODES];
int m_iNumSongsPassedByGrade[NUM_GRADES]; int m_iNumSongsPassedByGrade[NUM_GRADES];
void AddStepTotals( int iNumTapsAndHolds, int iNumJumps, int iNumHolds, int iNumMines, int iNumHands );
// //
// Steps high scores // Steps high scores
+15 -10
View File
@@ -23,6 +23,7 @@
#include "Bookkeeper.h" #include "Bookkeeper.h"
#include "PrefsManager.h" #include "PrefsManager.h"
#include "CryptManager.h" #include "CryptManager.h"
#include "RageUtil.h"
const CString STATS_HTML = "Stats.html"; const CString STATS_HTML = "Stats.html";
@@ -40,7 +41,6 @@ inline void PRINT_OPEN(RageFile &f,CString sName,bool bExpanded,CString sID){ g_
inline void PRINT_OPEN(RageFile &f,CString sName,bool bExpanded=false) { PRINT_OPEN(f,sName,bExpanded,MakeUniqueId()); } inline void PRINT_OPEN(RageFile &f,CString sName,bool bExpanded=false) { PRINT_OPEN(f,sName,bExpanded,MakeUniqueId()); }
inline void PRINT_CLOSE(RageFile &f) { f.Write( "</div>\n" "</div>\n" ); g_Level--; ASSERT(g_Level>=0); } inline void PRINT_CLOSE(RageFile &f) { f.Write( "</div>\n" "</div>\n" ); g_Level--; ASSERT(g_Level>=0); }
#define PRETTY_PERCENT(numerator,denominator) ssprintf("%0.2f%%",(float)numerator/(float)denominator*100)
struct Table struct Table
{ {
@@ -52,7 +52,7 @@ struct Table
Line(CString n) { sName = n; } Line(CString n) { sName = n; }
Line(CString n,CString v) { sName = n; sValue = v; } Line(CString n,CString v) { sName = n; sValue = v; }
Line(CString n,bool v) { sName = n; sValue = ssprintf("%s",v?"yes":"no"); } Line(CString n,bool v) { sName = n; sValue = ssprintf("%s",v?"yes":"no"); }
Line(CString n,int v) { sName = n; sValue = ssprintf("%d",v); } Line(CString n,int v) { sName = n; sValue = Commify(v); }
Line(int r,CString n,int v) { sRank = ssprintf("%d",r); sName = n; sValue = ssprintf("%d",v); } Line(int r,CString n,int v) { sRank = ssprintf("%d",r); sName = n; sValue = ssprintf("%d",v); }
Line(int r,CString n,CString sn,int v) { sRank = ssprintf("%d",r); sName = n; sSubName = sn; sValue = ssprintf("%d",v); } Line(int r,CString n,CString sn,int v) { sRank = ssprintf("%d",r); sName = n; sSubName = sn; sValue = ssprintf("%d",v); }
Line(int r,CString n,CString sn,CString ssn,int v) { sRank = ssprintf("%d",r); sName = n; sSubName = sn; sSubSubName = ssn; sValue = ssprintf("%d",v); } Line(int r,CString n,CString sn,CString ssn,int v) { sRank = ssprintf("%d",r); sName = n; sSubName = sn; sSubSubName = ssn; sValue = ssprintf("%d",v); }
@@ -274,11 +274,16 @@ void PrintStatistics( RageFile &f, const Profile *pProfile, CString sTitle, vect
TABLE_LINE2( "UsingProfileDefaultModifiers", pProfile->m_bUsingProfileDefaultModifiers ); TABLE_LINE2( "UsingProfileDefaultModifiers", pProfile->m_bUsingProfileDefaultModifiers );
TABLE_LINE2( "DefaultModifiers", pProfile->m_sDefaultModifiers ); TABLE_LINE2( "DefaultModifiers", pProfile->m_sDefaultModifiers );
TABLE_LINE2( "TotalPlays", pProfile->m_iTotalPlays ); TABLE_LINE2( "TotalPlays", pProfile->m_iTotalPlays );
TABLE_LINE2( "TotalPlaySeconds", pProfile->m_iTotalPlaySeconds ); TABLE_LINE2( "TotalPlay", SecondsToHHMMSS(pProfile->m_iTotalPlaySeconds) );
TABLE_LINE2( "TotalGameplaySeconds", pProfile->m_iTotalGameplaySeconds ); TABLE_LINE2( "TotalGameplay", SecondsToHHMMSS(pProfile->m_iTotalGameplaySeconds) );
TABLE_LINE2( "CurrentCombo", pProfile->m_iCurrentCombo ); TABLE_LINE2( "CurrentCombo", pProfile->m_iCurrentCombo );
TABLE_LINE2( "CaloriesBurned", pProfile->m_fCaloriesBurned ); TABLE_LINE2( "CaloriesBurned", pProfile->GetDisplayCaloriesBurned() );
TABLE_LINE2( "LastMachinePlayed", pProfile->m_sLastMachinePlayed ); TABLE_LINE2( "LastMachinePlayed", pProfile->m_sLastMachinePlayed );
TABLE_LINE2( "NumTapsAndHolds", pProfile->m_iNumTapsAndHolds );
TABLE_LINE2( "NumJumps", pProfile->m_iNumJumps );
TABLE_LINE2( "NumHolds", pProfile->m_iNumHolds );
TABLE_LINE2( "NumMines", pProfile->m_iNumMines );
TABLE_LINE2( "NumHands", pProfile->m_iNumHands );
END_TABLE; END_TABLE;
} }
PRINT_CLOSE(f); PRINT_CLOSE(f);
@@ -393,7 +398,7 @@ void PrintPopularity( RageFile &f, const Profile *pProfile, CString sTitle, vect
int iNumTimesPlayed = pProfile->GetSongNumTimesPlayed(pSong); int iNumTimesPlayed = pProfile->GetSongNumTimesPlayed(pSong);
if( iNumTimesPlayed == 0 || iNumTimesPlayed < iPopularNumPlaysThreshold ) // not popular if( iNumTimesPlayed == 0 || iNumTimesPlayed < iPopularNumPlaysThreshold ) // not popular
break; // done searching break; // done searching
TABLE_LINE4(i+1, pSong->GetDisplayMainTitle(), pSong->GetDisplaySubTitle(), PRETTY_PERCENT(iNumTimesPlayed,iTotalPlays) ); TABLE_LINE4(i+1, pSong->GetDisplayMainTitle(), pSong->GetDisplaySubTitle(), PrettyPercent(iNumTimesPlayed,iTotalPlays) );
} }
if( i == 0 ) if( i == 0 )
TABLE_LINE1("empty"); TABLE_LINE1("empty");
@@ -414,7 +419,7 @@ void PrintPopularity( RageFile &f, const Profile *pProfile, CString sTitle, vect
int iNumTimesPlayed = pProfile->GetSongNumTimesPlayed(pSong); int iNumTimesPlayed = pProfile->GetSongNumTimesPlayed(pSong);
if( iNumTimesPlayed >= iPopularNumPlaysThreshold ) // not unpopular if( iNumTimesPlayed >= iPopularNumPlaysThreshold ) // not unpopular
break; // done searching break; // done searching
TABLE_LINE4(i+1, pSong->GetDisplayMainTitle(), pSong->GetDisplaySubTitle(), PRETTY_PERCENT(iNumTimesPlayed,iTotalPlays) ); TABLE_LINE4(i+1, pSong->GetDisplayMainTitle(), pSong->GetDisplaySubTitle(), PrettyPercent(iNumTimesPlayed,iTotalPlays) );
} }
if( i == 0 ) if( i == 0 )
TABLE_LINE1("empty"); TABLE_LINE1("empty");
@@ -442,7 +447,7 @@ void PrintPopularity( RageFile &f, const Profile *pProfile, CString sTitle, vect
s += GAMEMAN->NotesTypeToString(pSteps->m_StepsType); s += GAMEMAN->NotesTypeToString(pSteps->m_StepsType);
s += " "; s += " ";
s += DifficultyToString(pSteps->GetDifficulty()); s += DifficultyToString(pSteps->GetDifficulty());
TABLE_LINE5(i+1, pSong->GetDisplayMainTitle(), pSong->GetDisplaySubTitle(), s, PRETTY_PERCENT(iNumTimesPlayed,iTotalPlays) ); TABLE_LINE5(i+1, pSong->GetDisplayMainTitle(), pSong->GetDisplaySubTitle(), s, PrettyPercent(iNumTimesPlayed,iTotalPlays) );
} }
if( i == 0 ) if( i == 0 )
TABLE_LINE1("empty"); TABLE_LINE1("empty");
@@ -463,7 +468,7 @@ void PrintPopularity( RageFile &f, const Profile *pProfile, CString sTitle, vect
{ {
Course* pCourse = vpCourses[i]; Course* pCourse = vpCourses[i];
int iNumTimesPlayed = pProfile->GetCourseNumTimesPlayed(pCourse); int iNumTimesPlayed = pProfile->GetCourseNumTimesPlayed(pCourse);
TABLE_LINE3(i+1, pCourse->m_sName, PRETTY_PERCENT(iNumTimesPlayed,iTotalPlays) ); TABLE_LINE3(i+1, pCourse->m_sName, PrettyPercent(iNumTimesPlayed,iTotalPlays) );
} }
if( i == 0 ) if( i == 0 )
TABLE_LINE1("empty"); TABLE_LINE1("empty");
@@ -761,7 +766,7 @@ bool PrintInventoryForSong( RageFile &f, const Profile *pProfile, Song* pSong )
CString sBPM = (fMinBPM==fMaxBPM) ? ssprintf("%.1f",fMinBPM) : ssprintf("%.1f - %.1f",fMinBPM,fMaxBPM); CString sBPM = (fMinBPM==fMaxBPM) ? ssprintf("%.1f",fMinBPM) : ssprintf("%.1f - %.1f",fMinBPM,fMaxBPM);
TABLE_LINE2( "BPM", sBPM ); TABLE_LINE2( "BPM", sBPM );
TABLE_LINE2( "Credit", pSong->m_sCredit ); TABLE_LINE2( "Credit", pSong->m_sCredit );
TABLE_LINE2( "MusicLength", SecondsToTime(pSong->m_fMusicLengthSeconds) ); TABLE_LINE2( "MusicLength", SecondsToMMSSMsMs(pSong->m_fMusicLengthSeconds) );
TABLE_LINE2( "Lyrics", !pSong->m_sLyricsFile.empty() ); TABLE_LINE2( "Lyrics", !pSong->m_sLyricsFile.empty() );
TABLE_LINE2( "NumTimesPlayed", pProfile->GetSongNumTimesPlayed(pSong) ); TABLE_LINE2( "NumTimesPlayed", pProfile->GetSongNumTimesPlayed(pSong) );
END_TABLE; END_TABLE;
+7
View File
@@ -436,6 +436,13 @@ void ProfileManager::IncrementToastiesCount( PlayerNumber pn )
++PROFILEMAN->GetMachineProfile()->m_iNumToasties; ++PROFILEMAN->GetMachineProfile()->m_iNumToasties;
} }
void ProfileManager::AddStepTotals( PlayerNumber pn, int iNumTapsAndHolds, int iNumJumps, int iNumHolds, int iNumMines, int iNumHands )
{
if( PROFILEMAN->IsUsingProfile(pn) )
PROFILEMAN->GetProfile(pn)->AddStepTotals( iNumTapsAndHolds, iNumJumps, iNumHolds, iNumMines, iNumHands );
PROFILEMAN->GetMachineProfile()->AddStepTotals( iNumTapsAndHolds, iNumJumps, iNumHolds, iNumMines, iNumHands );
}
// //
// Song stats // Song stats
// //
+1 -1
View File
@@ -42,6 +42,7 @@ public:
// General data // General data
// //
void IncrementToastiesCount( PlayerNumber pn ); void IncrementToastiesCount( PlayerNumber pn );
void AddStepTotals( PlayerNumber pn, int iNumTapsAndHolds, int iNumJumps, int iNumHolds, int iNumMines, int iNumHands );
// //
@@ -77,7 +78,6 @@ public:
bool ProfileWasLoadedFromMemoryCard( PlayerNumber pn ) const; bool ProfileWasLoadedFromMemoryCard( PlayerNumber pn ) const;
// //
// Song stats // Song stats
// //
+1 -1
View File
@@ -251,7 +251,7 @@ void RageLog::Write( int where, const CString &line )
CString LineHeader; CString LineHeader;
if( m_bTimestamping ) if( m_bTimestamping )
LineHeader += SecondsToTime(RageTimer::GetTimeSinceStart()) + ": "; LineHeader += SecondsToMMSSMsMs(RageTimer::GetTimeSinceStart()) + ": ";
if( where & WRITE_LOUD ) if( where & WRITE_LOUD )
LineHeader += "WARNING: "; LineHeader += "WARNING: ";
+31 -14
View File
@@ -94,10 +94,10 @@ bool IsHexVal( const CString &s )
return true; return true;
} }
float TimeToSeconds( const CString &sHMS ) float HHMMSSToSeconds( const CString &sHHMMSS )
{ {
CStringArray arrayBits; CStringArray arrayBits;
split( sHMS, ":", arrayBits, false ); split( sHHMMSS, ":", arrayBits, false );
while( arrayBits.size() < 3 ) while( arrayBits.size() < 3 )
arrayBits.insert(arrayBits.begin(), "0" ); // pad missing bits arrayBits.insert(arrayBits.begin(), "0" ); // pad missing bits
@@ -110,23 +110,40 @@ float TimeToSeconds( const CString &sHMS )
return fSeconds; return fSeconds;
} }
CString SecondsToTime( float fSecs ) CString SecondsToHHMMSS( float fSecs )
{ {
const int iMinsDisplay = (int)fSecs/60; const int iMinsDisplay = (int)fSecs/60;
const int iSecsDisplay = (int)fSecs - iMinsDisplay*60; const int iSecsDisplay = (int)fSecs - iMinsDisplay*60;
const float fLeftoverDisplay = (fSecs - iMinsDisplay*60 - iSecsDisplay) * 100; const float fLeftoverDisplay = (fSecs - iMinsDisplay*60 - iSecsDisplay) * 100;
CString sReturn = ssprintf( "%02d:%02d:%02.0f", iMinsDisplay, iSecsDisplay, min(99.0f,fLeftoverDisplay) ); CString sReturn = ssprintf( "%02d:%02d:%02d", iMinsDisplay/60, iMinsDisplay%60, iSecsDisplay );
if( iMinsDisplay >= 60 ) return sReturn;
{ }
/* Oops. Probably a really long endless course. Do "hh:mm.ss"; use a period
* to differentiate between "mm:ss:ms". I'd much prefer reversing those, since
* it makes much more sense to do "mm:ss.ms", but people would probably complain
* about "arcade accuracy" ...
*/
sReturn = ssprintf( "%02d:%02d.%02d", iMinsDisplay/60, iMinsDisplay%60, iSecsDisplay );
}
ASSERT( sReturn.GetLength() <= 8 ); CString SecondsToMMSSMsMs( float fSecs )
{
const int iMinsDisplay = (int)fSecs/60;
const int iSecsDisplay = (int)fSecs - iMinsDisplay*60;
const float fLeftoverDisplay = (fSecs - iMinsDisplay*60 - iSecsDisplay) * 100;
CString sReturn = ssprintf( "%02d:%02d.%02.0f", iMinsDisplay, iSecsDisplay, min(99.0f,fLeftoverDisplay) );
return sReturn;
}
CString PrettyPercent( float fNumerator, float fDenominator)
{
return ssprintf("%0.2f%%",(float)fNumerator/(float)fDenominator*100);
}
CString Commify( int iNum )
{
CString sNum = ssprintf("%d",iNum);
CString sReturn;
for( int i=0; i<sNum.length(); i++ )
{
char cDigit = sNum[sNum.length()-1-i];
if( i!=0 && i%3 == 0 )
sReturn = ',' + sReturn;
sReturn = cDigit + sReturn;
}
return sReturn; return sReturn;
} }
+6 -2
View File
@@ -137,8 +137,12 @@ float fmodfp(float x, float y);
int power_of_two(int input); int power_of_two(int input);
bool IsAnInt( const CString &s ); bool IsAnInt( const CString &s );
bool IsHexVal( const CString &s ); bool IsHexVal( const CString &s );
float TimeToSeconds( const CString &sHMS ); float HHMMSSToSeconds( const CString &sHMS );
CString SecondsToTime( float fSecs ); CString SecondsToHHMMSS( float fSecs );
CString SecondsToMMSSMsMs( float fSecs );
CString PrettyPercent( float fNumerator, float fDenominator );
CString Commify( int iNum );
struct tm GetLocalTime(); struct tm GetLocalTime();
+1 -1
View File
@@ -48,5 +48,5 @@ void ScoreDisplayOni::Update( float fDelta )
if( GAMESTATE->IsPlayerEnabled(m_PlayerNumber) ) if( GAMESTATE->IsPlayerEnabled(m_PlayerNumber) )
fSecsIntoPlay = g_CurStageStats.fAliveSeconds[m_PlayerNumber]; fSecsIntoPlay = g_CurStageStats.fAliveSeconds[m_PlayerNumber];
m_text.SetText( SecondsToTime(fSecsIntoPlay) ); m_text.SetText( SecondsToMMSSMsMs(fSecsIntoPlay) );
} }
+2 -2
View File
@@ -59,7 +59,7 @@ ScreenEndlessBreak::ScreenEndlessBreak( CString sName ) : Screen( sName )
//BitmapText stuff //BitmapText stuff
m_textTimeRemaining.LoadFromFont( THEME->GetPathToF("Common Normal") ); m_textTimeRemaining.LoadFromFont( THEME->GetPathToF("Common Normal") );
m_textTimeRemaining.SetText( SecondsToTime(m_fCountdownSecs) ); m_textTimeRemaining.SetText( SecondsToMMSSMsMs(m_fCountdownSecs) );
m_textTimeRemaining.SetX( CENTER_X ); m_textTimeRemaining.SetX( CENTER_X );
m_textTimeRemaining.SetY( CENTER_Y ); m_textTimeRemaining.SetY( CENTER_Y );
@@ -74,7 +74,7 @@ ScreenEndlessBreak::ScreenEndlessBreak( CString sName ) : Screen( sName )
void ScreenEndlessBreak::Update(float fDeltaTime) void ScreenEndlessBreak::Update(float fDeltaTime)
{ {
m_textTimeRemaining.SetText( SecondsToTime(m_fCountdownSecs) ); m_textTimeRemaining.SetText( SecondsToMMSSMsMs(m_fCountdownSecs) );
if( !m_bExiting ) if( !m_bExiting )
if(m_fCountdownSecs <= 0) if(m_fCountdownSecs <= 0)
{ {
+13 -1
View File
@@ -740,7 +740,7 @@ void ScreenEvaluation::Init()
m_textTime[p].SetDiffuse( PlayerToColor(p) ); m_textTime[p].SetDiffuse( PlayerToColor(p) );
m_textTime[p].SetName( ssprintf("TimeNumberP%d",p+1) ); m_textTime[p].SetName( ssprintf("TimeNumberP%d",p+1) );
SET_XY_AND_ON_COMMAND( m_textTime[p] ); SET_XY_AND_ON_COMMAND( m_textTime[p] );
m_textTime[p].SetText( SecondsToTime(stageStats.fAliveSeconds[p]) ); m_textTime[p].SetText( SecondsToMMSSMsMs(stageStats.fAliveSeconds[p]) );
this->AddChild( &m_textTime[p] ); this->AddChild( &m_textTime[p] );
} }
} }
@@ -873,6 +873,18 @@ void ScreenEvaluation::CommitScores( const StageStats &stageStats, int iPersonal
if( !GAMESTATE->IsHumanPlayer(p) ) if( !GAMESTATE->IsHumanPlayer(p) )
continue; continue;
//
// Add step totals
//
int iNumTapsAndHolds = stageStats.fRadarPossible[p][RADAR_NUM_TAPS_AND_HOLDS];
int iNumJumps = stageStats.fRadarPossible[p][RADAR_NUM_JUMPS];
int iNumHolds = stageStats.fRadarPossible[p][RADAR_NUM_HOLDS];
int iNumMines = stageStats.fRadarPossible[p][RADAR_NUM_MINES];
int iNumHands = stageStats.fRadarPossible[p][RADAR_NUM_HANDS];
PROFILEMAN->AddStepTotals( (PlayerNumber)p, iNumTapsAndHolds, iNumJumps, iNumHolds, iNumMines, iNumHands );
// whether or not to save scores when the stage was failed // whether or not to save scores when the stage was failed
// depends on if this is a course or not ... it's handled // depends on if this is a course or not ... it's handled
// below in the switch // below in the switch
+1 -1
View File
@@ -2133,7 +2133,7 @@ void ScreenGameplay::HandleScreenMessage( const ScreenMessage SM )
if( GAMESTATE->IsPlayerEnabled(p) ) if( GAMESTATE->IsPlayerEnabled(p) )
fMaxSurviveSeconds = max( fMaxSurviveSeconds, g_CurStageStats.fAliveSeconds[p] ); fMaxSurviveSeconds = max( fMaxSurviveSeconds, g_CurStageStats.fAliveSeconds[p] );
ASSERT( fMaxSurviveSeconds > 0 ); ASSERT( fMaxSurviveSeconds > 0 );
m_textSurviveTime.SetText( "TIME: " + SecondsToTime(fMaxSurviveSeconds) ); m_textSurviveTime.SetText( "TIME: " + SecondsToMMSSMsMs(fMaxSurviveSeconds) );
SET_XY_AND_ON_COMMAND( m_textSurviveTime ); SET_XY_AND_ON_COMMAND( m_textSurviveTime );
} }
+7 -3
View File
@@ -266,8 +266,6 @@ void ScreenSystemLayer::UpdateTimestampAndSkips()
m_SkipBackground.SetDiffuse(RageColor(0,0,0,0.4f)); m_SkipBackground.SetDiffuse(RageColor(0,0,0,0.4f));
} }
CString time(SecondsToTime(RageTimer::GetTimeSinceStart()));
/* Use our own timer, so we ignore `/tab. */ /* Use our own timer, so we ignore `/tab. */
const float UpdateTime = SkipTimer.GetDeltaTime(); const float UpdateTime = SkipTimer.GetDeltaTime();
@@ -291,6 +289,8 @@ void ScreenSystemLayer::UpdateTimestampAndSkips()
if(skip) if(skip)
{ {
CString time(SecondsToMMSSMsMs(RageTimer::GetTimeSinceStart()));
static const RageColor colors[] = { static const RageColor colors[] = {
RageColor(0,0,0,0), /* unused */ RageColor(0,0,0,0), /* unused */
RageColor(0.2f,0.2f,1,1), /* light blue */ RageColor(0.2f,0.2f,1,1), /* light blue */
@@ -306,7 +306,11 @@ void ScreenSystemLayer::UpdateTimestampAndSkips()
} }
} }
m_textTime.SetText( time ); if(PREFSMAN->m_bTimestamping)
{
CString time(SecondsToMMSSMsMs(RageTimer::GetTimeSinceStart()));
m_textTime.SetText( time );
}
} }
void ScreenSystemLayer::Update( float fDeltaTime ) void ScreenSystemLayer::Update( float fDeltaTime )
+1 -1
View File
@@ -736,7 +736,7 @@ float ScreenRanking::SetPage( PageToShow pts )
if( pts.pCourse->IsOni() ) if( pts.pCourse->IsOni() )
{ {
m_textPoints[l].SetText( ssprintf("%04d",hs.iScore) ); m_textPoints[l].SetText( ssprintf("%04d",hs.iScore) );
m_textTime[l].SetText( SecondsToTime(hs.fSurviveSeconds) ); m_textTime[l].SetText( SecondsToMMSSMsMs(hs.fSurviveSeconds) );
m_textScores[l].SetText( "" ); m_textScores[l].SetText( "" );
} else { } else {
m_textPoints[l].SetText( "" ); m_textPoints[l].SetText( "" );
+3 -3
View File
@@ -403,9 +403,9 @@ void ScreenSelectCourse::AfterCourseChange()
m_textNumSongs.SetText( ssprintf("%d", pCourse->GetEstimatedNumStages()) ); m_textNumSongs.SetText( ssprintf("%d", pCourse->GetEstimatedNumStages()) );
float fTotalSeconds; float fTotalSeconds;
if( pCourse->GetTotalSeconds(fTotalSeconds) ) if( pCourse->GetTotalSeconds(fTotalSeconds) )
m_textTime.SetText( SecondsToTime(fTotalSeconds) ); m_textTime.SetText( SecondsToMMSSMsMs(fTotalSeconds) );
else else
m_textTime.SetText( "xx:xx:xx" ); // The numbers format doesn't have a '?'. Is there a better solution? m_textTime.SetText( "xx:xx.xx" ); // The numbers format doesn't have a '?'. Is there a better solution?
m_Banner.LoadFromCourse( pCourse ); m_Banner.LoadFromCourse( pCourse );
@@ -434,7 +434,7 @@ void ScreenSelectCourse::AfterCourseChange()
{ {
/* use survive time */ /* use survive time */
float fSurviveSeconds = hsl.GetTopScore().fSurviveSeconds; float fSurviveSeconds = hsl.GetTopScore().fSurviveSeconds;
CString s = SecondsToTime(fSurviveSeconds); CString s = SecondsToMMSSMsMs(fSurviveSeconds);
/* dim the inital unsignificant digits */ /* dim the inital unsignificant digits */
/*XXX we'd like to have a dimmed ':' and '.', but /*XXX we'd like to have a dimmed ':' and '.', but