From 13c1685b2ac3bd997c8079192efcbfc30c0530d9 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Fri, 2 Dec 2005 03:46:27 +0000 Subject: [PATCH] save recordings with sequential file names --- stepmania/src/ScreenGameplay.cpp | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/stepmania/src/ScreenGameplay.cpp b/stepmania/src/ScreenGameplay.cpp index 169a81697d..2c4bbec0e8 100644 --- a/stepmania/src/ScreenGameplay.cpp +++ b/stepmania/src/ScreenGameplay.cpp @@ -2696,7 +2696,34 @@ void ScreenGameplay::SaveRecordedResults() { XNode *p = pi->m_pPlayer->m_NoteData.CreateNode(); DISP_OPT opt; - p->SaveToFile( "Save/LastSongRecording.xml", opt ); + + // + // Find a file name for the screenshot + // + FlushDirCache(); + + vector files; + GetDirListing( "Save/recording*", files, false, false ); + sort( files.begin(), files.end() ); + + /* Files should be of the form "recording######.xxx". */ + int iIndex = 0; + + for( int i = files.size()-1; i >= 0; --i ) + { + static Regex re( "^recording([0-9]{5})\\....$" ); + vector matches; + if( !re.Compare( files[i], matches ) ) + continue; + + ASSERT( matches.size() == 1 ); + iIndex = atoi( matches[0] )+1; + break; + } + + CString sFileName = ssprintf( "recording%05d.xml", iIndex ); + + p->SaveToFile( "Save/"+sFileName, opt ); SAFE_DELETE( p ); return; }