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