diff --git a/stepmania/src/NotesWriterDWI.cpp b/stepmania/src/NotesWriterDWI.cpp index 520792184f..b85b93e9df 100644 --- a/stepmania/src/NotesWriterDWI.cpp +++ b/stepmania/src/NotesWriterDWI.cpp @@ -67,7 +67,89 @@ CString NotesWriterDWI::NotesToDWIString( char cNoteCol1, char cNoteCol2, char c return NotesToDWIString( '0', cNoteCol1, cNoteCol2, cNoteCol3, cNoteCol4, '0' ); } -void NotesWriterDWI::WriteDWINotesTag( FILE* fp, const Notes &out ) +void NotesWriterDWI::WriteDWINotesField( FILE* fp, const Notes &out, int start ) +{ + NoteData notedata; + out.GetNoteData( ¬edata ); + notedata.ConvertHoldNotesTo2sAnd3s(); + + const int iLastMeasure = int( notedata.GetLastBeat()/BEATS_PER_MEASURE ); + for( int m=0; m<=iLastMeasure; m++ ) // foreach measure + { + NoteType nt = notedata.GetSmallestNoteTypeForMeasure( m ); + + double fCurrentIncrementer; + switch( nt ) + { + case NOTE_TYPE_4TH: + case NOTE_TYPE_8TH: + fCurrentIncrementer = 1.0/8 * BEATS_PER_MEASURE; + break; + case NOTE_TYPE_12TH: + fprintf( fp, "[" ); + fCurrentIncrementer = 1.0/24 * BEATS_PER_MEASURE; + break; + case NOTE_TYPE_16TH: + fprintf( fp, "(" ); + fCurrentIncrementer = 1.0/16 * BEATS_PER_MEASURE; + break; + default: + ASSERT(0); + // fall though + case NOTE_TYPE_INVALID: + fprintf( fp, "<" ); + fCurrentIncrementer = 1.0/192 * BEATS_PER_MEASURE; + break; + } + + double fFirstBeatInMeasure = m * BEATS_PER_MEASURE; + double fLastBeatInMeasure = (m+1) * BEATS_PER_MEASURE; + + for( double b=fFirstBeatInMeasure; b" ); + break; + } + fprintf( fp, "\n" ); + } +} + +bool NotesWriterDWI::WriteDWINotesTag( FILE* fp, const Notes &out ) { LOG->Trace( "Notes::WriteDWINotesTag" ); @@ -77,7 +159,7 @@ void NotesWriterDWI::WriteDWINotesTag( FILE* fp, const Notes &out ) case NOTES_TYPE_DANCE_COUPLE_1: fprintf( fp, "#COUPLE:" ); break; case NOTES_TYPE_DANCE_DOUBLE: fprintf( fp, "#DOUBLE:" ); break; case NOTES_TYPE_DANCE_SOLO: fprintf( fp, "#SOLO:" ); break; - default: return; // not a type supported by DWI + default: return false; // not a type supported by DWI } switch( out.m_DifficultyClass ) @@ -85,98 +167,13 @@ void NotesWriterDWI::WriteDWINotesTag( FILE* fp, const Notes &out ) case CLASS_EASY: fprintf( fp, "BASIC:" ); break; case CLASS_MEDIUM: fprintf( fp, "ANOTHER:" ); break; case CLASS_HARD: fprintf( fp, "MANIAC:" ); break; - default: ASSERT(0); return; + default: ASSERT(0); return false; } fprintf( fp, "%d:\n", out.m_iMeter ); - - NoteData notedata; - out.GetNoteData( ¬edata ); - notedata.ConvertHoldNotesTo2sAnd3s(); - - const int iNumPads = (out.m_NotesType==NOTES_TYPE_DANCE_COUPLE_1 || out.m_NotesType==NOTES_TYPE_DANCE_DOUBLE) ? 2 : 1; - const int iLastMeasure = int( notedata.GetLastBeat()/BEATS_PER_MEASURE ); - - for( int pad=0; pad" ); - break; - } - fprintf( fp, "\n" ); - } - } - - fprintf( fp, ";\n" ); + return true; } - bool NotesWriterDWI::Write( CString sPath, const Song &out ) { FILE* fp = fopen( sPath, "w" ); @@ -209,12 +206,61 @@ bool NotesWriterDWI::Write( CString sPath, const Song &out ) } fprintf( fp, ";\n" ); - // - // Save all Notes for this file - // - for( i=0; im_NotesType == NOTES_TYPE_DANCE_COUPLE_1) { + c[out.m_apNotes[i]->m_DifficultyClass][0] = out.m_apNotes[i]; + continue; + } + if(out.m_apNotes[i]->m_NotesType == NOTES_TYPE_DANCE_COUPLE_2) { + c[out.m_apNotes[i]->m_DifficultyClass][1] = out.m_apNotes[i]; + continue; + } + + if(!WriteDWINotesTag( fp, *out.m_apNotes[i] )) + continue; + + WriteDWINotesField( fp, *out.m_apNotes[i], 0 ); + if(out.m_apNotes[i]->m_NotesType==NOTES_TYPE_DANCE_DOUBLE) + { + fprintf( fp, ":\n" ); + WriteDWINotesField( fp, *out.m_apNotes[i], 4 ); + } + + fprintf( fp, ";\n" ); + } + + for( i=0; i < NUM_DIFFICULTY_CLASSES; ++i ) + { + /* Skip if we don't have both sides for this couples. */ + if( !c[i][0] || !c[i][1] ) continue; + + WriteDWINotesTag( fp, *c[i][0] ); + WriteDWINotesField( fp, *c[i][0], 0 ); + fprintf( fp, ":\n" ); + WriteDWINotesField( fp, *c[i][1], 0 ); + fprintf( fp, ";\n" ); + } + fclose( fp ); return true; diff --git a/stepmania/src/NotesWriterDWI.h b/stepmania/src/NotesWriterDWI.h index cbb0bfa8fb..aab930e807 100644 --- a/stepmania/src/NotesWriterDWI.h +++ b/stepmania/src/NotesWriterDWI.h @@ -9,8 +9,8 @@ class NotesWriterDWI { char NotesToDWIChar( bool bCol1, bool bCol2, bool bCol3, bool bCol4 ); CString NotesToDWIString( char cNoteCol1, char cNoteCol2, char cNoteCol3, char cNoteCol4, char cNoteCol5, char cNoteCol6 ); CString NotesToDWIString( char cNoteCol1, char cNoteCol2, char cNoteCol3, char cNoteCol4 ); - - void WriteDWINotesTag( FILE* fp, const Notes &out ); + void WriteDWINotesField( FILE* fp, const Notes &out, int start ); + bool WriteDWINotesTag( FILE* fp, const Notes &out ); public: bool Write( CString sPath, const Song &out );