diff --git a/stepmania/src/Notes.cpp b/stepmania/src/Notes.cpp index c071d1d7ad..b6d0c444c5 100644 --- a/stepmania/src/Notes.cpp +++ b/stepmania/src/Notes.cpp @@ -65,179 +65,6 @@ void Notes::WriteSMNotesTag( FILE* fp ) fprintf( fp, "%s;\n", m_sSMNoteData ); } -struct DWICharLookup { - char c; - bool bCol[6]; -}; - -char NotesToDWIChar( bool bCol1, bool bCol2, bool bCol3, bool bCol4, bool bCol5, bool bCol6 ) -{ - const DWICharLookup lookup[] = { - { '0', 0, 0, 0, 0, 0, 0 }, - { '1', 0, 1, 1, 0, 0, 0 }, - { '2', 0, 0, 1, 0, 0, 0 }, - { '3', 0, 0, 1, 0, 1, 0 }, - { '4', 0, 1, 0, 0, 0, 0 }, - { '6', 0, 0, 0, 0, 1, 0 }, - { '7', 0, 1, 0, 1, 0, 0 }, - { '8', 0, 0, 0, 1, 0, 0 }, - { '9', 0, 0, 0, 1, 1, 0 }, - { 'A', 0, 0, 1, 1, 0, 0 }, - { 'B', 0, 1, 0, 0, 1, 0 }, - { 'C', 0, 1, 0, 0, 0, 0 }, - { 'D', 0, 0, 0, 0, 1, 0 }, - { 'E', 1, 1, 0, 0, 0, 0 }, - { 'F', 0, 1, 1, 0, 0, 0 }, - { 'G', 0, 1, 0, 1, 0, 0 }, - { 'H', 0, 1, 0, 0, 0, 1 }, - { 'I', 1, 0, 0, 0, 1, 0 }, - { 'J', 0, 0, 1, 0, 1, 0 }, - { 'K', 0, 0, 0, 1, 1, 0 }, - { 'L', 0, 0, 0, 0, 1, 1 }, - { 'M', 0, 1, 0, 0, 1, 0 }, - }; - const int iNumLookups = sizeof(lookup) / sizeof(DWICharLookup); - - for( int i=0; iTrace( "Notes::WriteDWINotesTag" ); - - switch( m_NotesType ) - { - case NOTES_TYPE_DANCE_SINGLE: fprintf( fp, "#SINGLE:" ); break; - 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 - } - - switch( m_DifficultyClass ) - { - 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; - } - - fprintf( fp, "%d:\n", m_iMeter ); - - NoteData notedata; - this->GetNoteData( ¬edata ); - notedata.ConvertHoldNotesTo2sAnd3s(); - - const int iNumPads = (m_NotesType==NOTES_TYPE_DANCE_COUPLE_1 || 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" ); -} - void Notes::SetNoteData( NoteData* pNewNoteData ) { ASSERT( pNewNoteData->m_iNumTracks == GameManager::NotesTypeToNumTracks(m_NotesType) ); diff --git a/stepmania/src/Notes.h b/stepmania/src/Notes.h index a67d38a095..719e86b534 100644 --- a/stepmania/src/Notes.h +++ b/stepmania/src/Notes.h @@ -26,7 +26,6 @@ public: // Loading bool LoadFromNotesFile( const CString &sPath ); void WriteSMNotesTag( FILE* fp ); - void WriteDWINotesTag( FILE* fp ); public: NotesType m_NotesType; diff --git a/stepmania/src/NotesWriterDWI.cpp b/stepmania/src/NotesWriterDWI.cpp new file mode 100644 index 0000000000..520792184f --- /dev/null +++ b/stepmania/src/NotesWriterDWI.cpp @@ -0,0 +1,221 @@ +#include "stdafx.h" +#include "NotesWriterDWI.h" +#include "NoteTypes.h" +#include "NoteData.h" +#include "RageUtil.h" +#include "RageLog.h" + +char NotesWriterDWI::NotesToDWIChar( bool bCol1, bool bCol2, bool bCol3, bool bCol4, bool bCol5, bool bCol6 ) +{ + struct DWICharLookup { + char c; + bool bCol[6]; + } const lookup[] = { + { '0', 0, 0, 0, 0, 0, 0 }, + { '1', 0, 1, 1, 0, 0, 0 }, + { '2', 0, 0, 1, 0, 0, 0 }, + { '3', 0, 0, 1, 0, 1, 0 }, + { '4', 0, 1, 0, 0, 0, 0 }, + { '6', 0, 0, 0, 0, 1, 0 }, + { '7', 0, 1, 0, 1, 0, 0 }, + { '8', 0, 0, 0, 1, 0, 0 }, + { '9', 0, 0, 0, 1, 1, 0 }, + { 'A', 0, 0, 1, 1, 0, 0 }, + { 'B', 0, 1, 0, 0, 1, 0 }, + { 'C', 0, 1, 0, 0, 0, 0 }, + { 'D', 0, 0, 0, 0, 1, 0 }, + { 'E', 1, 1, 0, 0, 0, 0 }, + { 'F', 0, 1, 1, 0, 0, 0 }, + { 'G', 0, 1, 0, 1, 0, 0 }, + { 'H', 0, 1, 0, 0, 0, 1 }, + { 'I', 1, 0, 0, 0, 1, 0 }, + { 'J', 0, 0, 1, 0, 1, 0 }, + { 'K', 0, 0, 0, 1, 1, 0 }, + { 'L', 0, 0, 0, 0, 1, 1 }, + { 'M', 0, 1, 0, 0, 1, 0 }, + }; + const int iNumLookups = sizeof(lookup) / sizeof(*lookup); + + for( int i=0; iTrace( "Notes::WriteDWINotesTag" ); + + switch( out.m_NotesType ) + { + case NOTES_TYPE_DANCE_SINGLE: fprintf( fp, "#SINGLE:" ); break; + 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 + } + + switch( out.m_DifficultyClass ) + { + 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; + } + + 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" ); +} + + +bool NotesWriterDWI::Write( CString sPath, const Song &out ) +{ + FILE* fp = fopen( sPath, "w" ); + if( fp == NULL ) + throw RageException( "Error opening song file '%s' for writing.", sPath ); + + fprintf( fp, "#TITLE:%s;\n", out.GetFullTitle() ); + fprintf( fp, "#ARTIST:%s;\n", out.m_sArtist ); + ASSERT( out.m_BPMSegments[0].m_fStartBeat == 0 ); + fprintf( fp, "#BPM:%.2f;\n", out.m_BPMSegments[0].m_fBPM ); + fprintf( fp, "#GAP:%d;\n", -roundf( out.m_fBeat0OffsetInSeconds*1000 ) ); + + fprintf( fp, "#FREEZE:" ); + for( int i=0; iWriteDWINotesTag( fp ); - - fclose( fp ); + NotesWriterDWI wr; + wr.Write(sPath, *this); } struct AutoGenMapping