diff --git a/stepmania/src/Profile.cpp b/stepmania/src/Profile.cpp index 71f8e7902f..ff9b8a5370 100644 --- a/stepmania/src/Profile.cpp +++ b/stepmania/src/Profile.cpp @@ -1253,12 +1253,8 @@ void Profile::LoadScreenshotDataFromNode( const XNode* pNode ) if( !(*screenshot)->GetChildValue("MD5",ss.sMD5) ) WARN_AND_CONTINUE; - XNode *pHighScoreNode = (*screenshot)->GetChild("HighScore"); - if( pHighScoreNode == NULL ) + if( !(*screenshot)->GetChildValue("Time",(int&)ss.time) ) // time_t is a signed long on Win32. Is this ok on other platforms? WARN_AND_CONTINUE; - - HighScore &hs = ss.highScore; - hs.LoadFromNode( pHighScoreNode ); m_vScreenshots.push_back( ss ); } @@ -1282,7 +1278,7 @@ XNode* Profile::SaveScreenshotDataCreateNode() const pScreenshotNode->AppendChild( "FileName", ss.sFileName ); pScreenshotNode->AppendChild( "MD5", ss.sMD5); - pScreenshotNode->AppendChild( ss.highScore.CreateNode() ); + pScreenshotNode->AppendChild( "Time", ss.time); } return pNode; diff --git a/stepmania/src/Profile.h b/stepmania/src/Profile.h index ce21437e17..b3569aba25 100644 --- a/stepmania/src/Profile.h +++ b/stepmania/src/Profile.h @@ -147,10 +147,11 @@ public: { CString sFileName; // no directory part - just the file name CString sMD5; // MD5 hash of the screenshot file - HighScore highScore; // high score that the screenshot is taken of + time_t time; // return value of time() when screenshot was taken }; vector m_vScreenshots; void AddScreenshot( Screenshot screenshot ); + int GetNextScreenshotIndex() { return m_vScreenshots.size(); } // diff --git a/stepmania/src/ProfileHtml.cpp b/stepmania/src/ProfileHtml.cpp index 7e35cc35c8..cac133b979 100644 --- a/stepmania/src/ProfileHtml.cpp +++ b/stepmania/src/ProfileHtml.cpp @@ -828,15 +828,26 @@ void PrintBookkeeping( RageFile &f, const Profile *pProfile, CString sTitle, vec void PrintScreenshot( RageFile &f, const Profile::Screenshot &ss ) { - CString sHtmlPath = "Screenshots/"+ss.sFileName; - CString sImgTag = ssprintf("", sHtmlPath.c_str(), sHtmlPath.c_str() ); - CString sDetails = "

This is a screenshot

\n

We have no idea where it came from

"; + CString sImagePath = SCREENSHOTS_SUBDIR+ss.sFileName; + CString sImgHtml = ssprintf("", sImagePath.c_str(), sImagePath.c_str() ); + + + f.Write("\n"); + f.Write("\n"); + f.Write("\n"); + f.Write("\n"); + + f.Write("
"+sImgHtml+"\n"); BEGIN_TABLE(1); - TABLE_LINE2( sImgTag, sDetails ); + TABLE_LINE2( "File", ss.sFileName ); + TABLE_LINE2( "MD5", ss.sMD5 ); + TABLE_LINE2( "Time", (CString)ctime(&ss.time) ); END_TABLE; + + f.Write("
\n"); } void PrintScreenshots( RageFile &f, const Profile *pProfile, CString sTitle, CString sProfileDir ) diff --git a/stepmania/src/ScreenEvaluation.cpp b/stepmania/src/ScreenEvaluation.cpp index 6cf43c13d0..738d26fffa 100644 --- a/stepmania/src/ScreenEvaluation.cpp +++ b/stepmania/src/ScreenEvaluation.cpp @@ -37,6 +37,7 @@ #include "RageDisplay.h" #include "StepMania.h" #include "CryptManager.h" +#include const int NUM_SCORE_DIGITS = 9; @@ -1298,17 +1299,18 @@ void ScreenEvaluation::Input( const DeviceInput& DeviceI, const InputEventType t if( !m_bSavedScreenshot[pn] && // only allow one screenshot PROFILEMAN->IsUsingProfile(pn) ) { + Profile* pProfile = PROFILEMAN->GetProfile(pn); CString sDir = PROFILEMAN->GetProfileDir((ProfileSlot)pn) + "Screenshots/"; - CString sFileName = SaveScreenshot( sDir, true, true ); + int iScreenshotIndex = pProfile->GetNextScreenshotIndex(); + CString sFileName = SaveScreenshot( sDir, true, true, iScreenshotIndex ); CString sPath = sDir+sFileName; if( !sFileName.empty() ) { - Profile* pProfile = PROFILEMAN->GetProfile(pn); Profile::Screenshot screenshot; screenshot.sFileName = sFileName; screenshot.sMD5 = CRYPTMAN->GetMD5( sPath ); - screenshot.highScore = m_HighScore[pn]; + screenshot.time = time(NULL); pProfile->AddScreenshot( screenshot ); } diff --git a/stepmania/src/StepMania.cpp b/stepmania/src/StepMania.cpp index f1c7e0a9ae..fa7fd61db2 100644 --- a/stepmania/src/StepMania.cpp +++ b/stepmania/src/StepMania.cpp @@ -1110,7 +1110,7 @@ int main(int argc, char* argv[]) return 0; } -CString SaveScreenshot( CString sDir, bool bSaveCompressed, bool bMakeSignature ) +CString SaveScreenshot( CString sDir, bool bSaveCompressed, bool bMakeSignature, int iIndex ) { // // Find a file name for the screenshot @@ -1123,23 +1123,25 @@ CString SaveScreenshot( CString sDir, bool bSaveCompressed, bool bMakeSignature /* Files should be of the form "screen######.xxx". Ignore the extension; find * the last file of this form, and use the next number. This way, we don't - * write the same screenshot number for different formats (screen0011.bmp, - * screen0011.jpg), and we always increase from the end, so if screen0003.jpg + * write the same screenshot number for different formats (screen00011.bmp, + * screen00011.jpg), and we always increase from the end, so if screen00003.jpg * is deleted, we won't fill in the hole (which makes screenshots hard to find). */ - int fileno = -1; - for( int i = files.size()-1; i >= 0; --i ) - if( sscanf( files[i], "screen%d.%*s", &fileno ) == 1 ) - break; + if( iIndex == -1 ) + { + for( int i = files.size()-1; i >= 0; --i ) + if( sscanf( files[i], "screen%d.%*s", &iIndex ) == 1 ) + break; - if( fileno == -1 ) - fileno = 0; - else - ++fileno; + if( iIndex == -1 ) + iIndex = 0; + else + ++iIndex; + } // // Save the screenshot // - CString sFileName = ssprintf( "screen%04d.%s",fileno,bSaveCompressed ? "jpg" : "bmp" ); + CString sFileName = ssprintf( "screen%05d.%s",iIndex,bSaveCompressed ? "jpg" : "bmp" ); CString sPath = sDir+sFileName; bool bResult = DISPLAY->SaveScreenshot( sPath, bSaveCompressed ? RageDisplay::jpg : RageDisplay::bmp ); if( !bResult ) diff --git a/stepmania/src/StepMania.h b/stepmania/src/StepMania.h index a44175ae05..7768634daf 100644 --- a/stepmania/src/StepMania.h +++ b/stepmania/src/StepMania.h @@ -22,7 +22,7 @@ void SaveGamePrefsToDisk(); void ChangeCurrentGame( Game g ); // If successful, return filename of screenshot in sDir, else return "" -CString SaveScreenshot( CString sDir, bool bSaveCompressed, bool bMakeSignature ); +CString SaveScreenshot( CString sDir, bool bSaveCompressed, bool bMakeSignature, int iIndex = -1 ); #if defined(_WINDOWS) #include "windows.h"