diff --git a/stepmania/src/Course.cpp b/stepmania/src/Course.cpp index b3b3ed3f10..902af73488 100644 --- a/stepmania/src/Course.cpp +++ b/stepmania/src/Course.cpp @@ -242,6 +242,60 @@ void Course::LoadFromCRSFile( CString sPath ) } +void Course::Save() +{ + ASSERT( !m_bIsAutogen ); + + FILE* fp = fopen( m_sPath, "w" ); + if( fp == NULL ) + { + LOG->Warn( "Could not write course file '%s'.", m_sPath.GetString() ); + return; + } + + fprintf( fp, "#COURSE:%s;\n", m_sName.GetString() ); + fprintf( fp, "#REPEAT:%s;\n", m_bRepeat ? "YES" : "NO" ); + fprintf( fp, "#LIVES:%i;\n", m_iLives ); + fprintf( fp, "#EXTRA:%i;\n", m_iExtra ); + + for( unsigned i=0; iGetSongDir().GetString() ); + break; + case Entry::random: + fprintf( fp, "#SONG:*" ); + break; + case Entry::random_within_group: + fprintf( fp, "#SONG:%s/*", entry.group_name.GetString() ); + break; + case Entry::players_best: + fprintf( fp, "#SONG:PlayersBest%d", entry.players_index+1 ); + break; + case Entry::players_worst: + fprintf( fp, "#SONG:PlayersWorst%d", entry.players_index+1 ); + break; + default: + ASSERT(0); + } + + if( entry.difficulty != DIFFICULTY_INVALID ) + fprintf( fp, ":%s", DifficultyToString(entry.difficulty).GetString() ); + + if( entry.low_meter != -1 && entry.high_meter != -1 ) + fprintf( fp, ":%d..%d", entry.low_meter, entry.high_meter ); + + fprintf( fp, ";\n" ); + } + + fclose( fp ); +} + + void Course::AutogenEndlessFromGroup( CString sGroupName, vector &apSongsInGroup ) { m_bIsAutogen = true; diff --git a/stepmania/src/Course.h b/stepmania/src/Course.h index 61b206d0f5..ee94d6524d 100644 --- a/stepmania/src/Course.h +++ b/stepmania/src/Course.h @@ -79,6 +79,7 @@ public: void LoadFromCRSFile( CString sPath ); + void Save(); void AutogenEndlessFromGroup( CString sGroupName, vector &apSongsInGroup ); void AutogenNonstopFromGroup( CString sGroupName, vector &apSongsInGroup );