#include "global.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 )); // HACK: We used to store SMANIAC as DIFFICULTY_HARD with special description. // Now, it has it's own DIFFICULTY_CHALLENGE if( sDescription.CompareNoCase("smaniac") == 0 ) out.SetDifficulty( DIFFICULTY_CHALLENGE ); // HACK: We used to store CHALLENGE as DIFFICULTY_HARD with special description. // Now, it has it's own DIFFICULTY_CHALLENGE if( sDescription.CompareNoCase("challenge") == 0 ) out.SetDifficulty( DIFFICULTY_CHALLENGE ); out.SetMeter(atoi(sMeter)); CStringArray saValues; split( sRadarValues, ",", saValues, true ); if( saValues.size() == NUM_RADAR_CATEGORIES ) 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; iTrace("Ignored #FIRSTBEAT (cache only)"); continue; } out.m_fFirstBeat = (float)atof( sParams[1] ); } else if( 0==stricmp(sValueName,"LASTBEAT") ) { if(!FromCache) { LOG->Trace("Ignored #LASTBEAT (cache only)"); continue; } out.m_fLastBeat = (float)atof( sParams[1] ); } else if( 0==stricmp(sValueName,"SAMPLESTART") ) out.m_fMusicSampleStartSeconds = TimeToSeconds( sParams[1] ); else if( 0==stricmp(sValueName,"SAMPLELENGTH") ) out.m_fMusicSampleLengthSeconds = TimeToSeconds( sParams[1] ); else if( 0==stricmp(sValueName,"OFFSET") ) out.m_fBeat0OffsetInSeconds = (float)atof( sParams[1] ); else if( 0==stricmp(sValueName,"SELECTABLE") ) { if(!stricmp(sParams[1],"YES")) out.m_SelectionDisplay = out.SHOW_ALWAYS; else if(!stricmp(sParams[1],"NO")) out.m_SelectionDisplay = out.SHOW_NEVER; else if(!stricmp(sParams[1],"ROULETTE")) out.m_SelectionDisplay = out.SHOW_ROULETTE; else LOG->Warn( "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( "Unexpected value named '%s'", sValueName.GetString() ); } out.m_sBannerFile.Replace("\\", "/"); out.m_sBackgroundFile.Replace("\\", "/"); out.m_sCDTitleFile.Replace("\\", "/"); out.m_sMusicFile.Replace("\\", "/"); 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 ); }