#include "stdafx.h" #include "NotesLoaderKSF.h" #include "RageException.h" #include "MsdFile.h" #include "RageLog.h" #include "RageUtil.h" #include "NoteData.h" #include "NoteTypes.h" bool KSFLoader::LoadFromKSFFile( const CString &sPath, Notes &out ) { LOG->Trace( "Notes::LoadFromKSFFile( '%s' )", sPath ); MsdFile msd; bool bResult = msd.ReadFile( sPath ); if( !bResult ) throw RageException( "Error opening file '%s'.", sPath ); int iTickCount = -1; // this is the value we read for TICKCOUNT CString iStep; // this is the value we read for STEP for( int i=0; iWarn( "%s:\nTICKCOUNT not found; defaulting to %i", sPath, iTickCount ); } NoteData notedata; // read it into here CStringArray asRows; iStep.TrimLeft(); split( iStep, "\n", asRows, true ); int iHoldStartRow[13]; for( int t=0; t<13; t++ ) iHoldStartRow[t] = -1; for( int r=0; rTrace( "Song::LoadFromKSFDir(%s)", sDir ); CStringArray arrayKSFFileNames; GetDirListing( sDir + CString("*.ksf"), arrayKSFFileNames ); if( arrayKSFFileNames.GetSize() == 0 ) throw RageException( "Couldn't find any KSF files in '%s'", sDir ); // load the Notes from the rest of the KSF files for( int i=0; iTrace( "Unexpected value named '%s'", sValueName ); } // search for music with song in the file name CStringArray arrayPossibleMusic; GetDirListing( out.m_sSongDir + CString("song.mp3"), arrayPossibleMusic ); GetDirListing( out.m_sSongDir + CString("song.ogg"), arrayPossibleMusic ); GetDirListing( out.m_sSongDir + CString("song.wav"), arrayPossibleMusic ); if( arrayPossibleMusic.GetSize() > 0 ) // we found a match out.m_sMusicFile = arrayPossibleMusic[0]; return TRUE; }