#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', 1, 0, 1, 0, 0, 0 }, { '2', 0, 0, 1, 0, 0, 0 }, { '3', 0, 0, 1, 0, 0, 1 }, { '4', 1, 0, 0, 0, 0, 0 }, { '6', 0, 0, 0, 0, 0, 1 }, { '7', 1, 0, 0, 1, 0, 0 }, { '8', 0, 0, 0, 1, 0, 0 }, { '9', 0, 0, 0, 1, 0, 1 }, { 'A', 0, 0, 1, 1, 0, 0 }, { 'B', 1, 0, 0, 0, 0, 1 }, { '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: fprintf( fp, "#COUPLE:" ); break; case NOTES_TYPE_DANCE_DOUBLE: fprintf( fp, "#DOUBLE:" ); break; case NOTES_TYPE_DANCE_SOLO: fprintf( fp, "#SOLO:" ); break; default: return false; // not a type supported by DWI } if( 0==out.m_sDescription.CompareNoCase("challenge") ) fprintf( fp, "SMANIAC:" ); else if( 0==out.m_sDescription.CompareNoCase("smaniac") ) fprintf( fp, "SMANIAC:" ); else { switch( out.m_Difficulty ) { case DIFFICULTY_EASY: fprintf( fp, "BASIC:" ); break; case DIFFICULTY_MEDIUM: fprintf( fp, "ANOTHER:" ); break; case DIFFICULTY_HARD: fprintf( fp, "MANIAC:" ); break; default: ASSERT(0); return false; } } fprintf( fp, "%d:\n", out.m_iMeter ); return true; } 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 ); if(out.GetFullTitle().GetLength() != 0) fprintf( fp, "#TITLE:%s;\n", out.GetFullTitle() ); if(out.m_sArtist.GetLength() != 0) 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", int(-roundf( out.m_fBeat0OffsetInSeconds*1000 )) ); if( out.m_StopSegments.GetSize() ) { fprintf( fp, "#FREEZE:" ); for( int i=0; i 1) { fprintf( fp, "#CHANGEBPM:" ); for( int i=1; im_sDescription.Find("autogen") ) continue; // don't save autogen notes 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 || out.m_apNotes[i]->m_NotesType==NOTES_TYPE_DANCE_COUPLE) { fprintf( fp, ":\n" ); WriteDWINotesField( fp, *out.m_apNotes[i], 4 ); } fprintf( fp, ";\n" ); } fclose( fp ); return true; }