#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.GetString() ); MsdFile msd; bool bResult = msd.ReadFile( sPath ); if( !bResult ) throw RageException( "Error opening file '%s'.", sPath.GetString() ); int iTickCount = -1; // this is the value we read for TICKCOUNT CString iStep; // this is the value we read for STEP for( unsigned i=0; iWarn( "%s:\nTICKCOUNT not found; defaulting to %i", sPath.GetString(), iTickCount ); } NoteData notedata; // read it into here CStringArray asRows; TrimLeft(iStep); split( iStep, "\n", asRows, true ); { CString sDir, sFName, sExt; splitrelpath( sPath, sDir, sFName, sExt ); sFName.MakeLower(); out.m_sDescription = sFName; if( sFName.Find("crazy")!=-1 ) { out.m_Difficulty = DIFFICULTY_HARD; if(!out.m_iMeter) out.m_iMeter = 8; } else if( sFName.Find("hard")!=-1 ) { out.m_Difficulty = DIFFICULTY_MEDIUM; if(!out.m_iMeter) out.m_iMeter = 5; } else if( sFName.Find("easy")!=-1 ) { out.m_Difficulty = DIFFICULTY_EASY; if(!out.m_iMeter) out.m_iMeter = 2; } else { out.m_Difficulty = DIFFICULTY_MEDIUM; if(!out.m_iMeter) out.m_iMeter = 5; } notedata.m_iNumTracks = 5; out.m_NotesType = NOTES_TYPE_PUMP_SINGLE; if( sFName.Find("double") != -1 ) { notedata.m_iNumTracks = 10; out.m_NotesType = NOTES_TYPE_PUMP_DOUBLE; } else if( sFName.Find("_2") != -1 ) { notedata.m_iNumTracks = 10; out.m_NotesType = NOTES_TYPE_PUMP_COUPLE; } } int iHoldStartRow[13]; for( int t=0; t<13; t++ ) iHoldStartRow[t] = -1; for( unsigned r=0; rTrace( "Song::LoadFromKSFDir(%s)", sDir.GetString() ); CStringArray arrayKSFFileNames; GetDirListing( sDir + CString("*.ksf"), arrayKSFFileNames ); if( arrayKSFFileNames.empty() ) throw RageException( "Couldn't find any KSF files in '%s'", sDir.GetString() ); // load the Notes from the rest of the KSF files for( unsigned i=0; iTrace( "Unexpected value named '%s'", sValueName.GetString() ); } // 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.empty() ) // we found a match out.m_sMusicFile = arrayPossibleMusic[0]; return TRUE; }