#include "stdafx.h" #include "NotesLoaderSM.h" #include "GameManager.h" #include "RageException.h" #include "MsdFile.h" #include "RageLog.h" #include "RageUtil.h" void SMLoader::LoadFromSMTokens( CString sNotesType, CString sDescription, CString sDifficulty, CString sMeter, CString sRadarValues, CString sNoteData, Notes &out ) { sNotesType.TrimLeft(); sNotesType.TrimRight(); sDescription.TrimLeft(); sDescription.TrimRight(); sDifficulty.TrimLeft(); sDifficulty.TrimRight(); // LOG->Trace( "Notes::LoadFromSMTokens()" ); out.m_NotesType = GameManager::StringToNotesType(sNotesType); out.m_sDescription = sDescription; out.m_Difficulty = StringToDifficulty( sDifficulty ); out.m_iMeter = atoi(sMeter); CStringArray saValues; split( sRadarValues, ",", saValues, true ); if( saValues.GetSize() == NUM_RADAR_VALUES ) for( int r=0; rTrace( "Song::LoadFromSMDir(%s)", sPath ); out.m_BPMSegments.RemoveAll(); out.m_StopSegments.RemoveAll(); int i; MsdFile msd; bool bResult = msd.ReadFile( sPath ); if( !bResult ) throw RageException( "Error opening file '%s'.", sPath ); for( i=0; iWarn( "The song file '%s' has an unknown #SELECTABLE value, \"%s\"; ignored.", sPath, sParams[1]); } else if( 0==stricmp(sValueName,"STOPS") || 0==stricmp(sValueName,"FREEZES") ) { CStringArray arrayFreezeExpressions; split( sParams[1], ",", arrayFreezeExpressions ); for( int f=0; fTrace( "The song file '%s' is has %d fields in a #NOTES tag, but should have %d.", sPath, iNumParams, 7 ); } else { LoadFromSMTokens( sParams[1], sParams[2], sParams[3], sParams[4], sParams[5], sParams[6], *pNewNotes); } } else LOG->Trace( "Unexpected value named '%s'", sValueName ); } return true; } bool SMLoader::LoadFromDir( CString sPath, Song &out ) { CStringArray aFileNames; GetApplicableFiles( sPath, aFileNames ); if( aFileNames.GetSize() > 1 ) throw RageException( "There is more than one SM file in '%s'. There should be only one!", sPath ); /* We should have exactly one; if we had none, we shouldn't have been * called to begin with. */ ASSERT( aFileNames.GetSize() == 1 ); return LoadFromSMFile( sPath + aFileNames[0], out ); }