diff --git a/src/NotesLoaderSM.cpp b/src/NotesLoaderSM.cpp index bb465057d4..bdb8a332ea 100644 --- a/src/NotesLoaderSM.cpp +++ b/src/NotesLoaderSM.cpp @@ -16,6 +16,33 @@ /** @brief The maximum file size for edits. */ const int MAX_EDIT_STEPS_SIZE_BYTES = 60*1024; // 60KB +bool SMLoader::LoadFromDir( const RString &sPath, Song &out ) +{ + vector aFileNames; + GetApplicableFiles( sPath, aFileNames ); + + if( aFileNames.size() > 1 ) + { + LOG->UserLog( "Song", sPath, "has more than one SM file. There can be only one (unless you are using TougaKiryuu's AnimeMix files somehow, which assume a different version of StepMania)!" ); + return false; + /* + for( unsigned i=0; i= 1 ); + + return LoadFromSMFile( sPath + aFileNames[0], out ); +} + float SMLoader::RowToBeat( RString line, const int rowsPerBeat ) { RString backup = line; @@ -419,6 +446,52 @@ void SMLoader::ProcessTickcounts( TimingData &out, const RString line, const int } } +void SMLoader::ProcessSpeeds( TimingData &out, const RString line, const int rowsPerBeat ) +{ + vector vs1; + split( line, ",", vs1 ); + + FOREACH_CONST( RString, vs1, s1 ) + { + vector vs2; + split( *s1, "=", vs2 ); + + if( vs2[0] == 0 && vs2.size() == 2 ) // First one always seems to have 2. + { + vs2.push_back("0"); + } + + if( vs2.size() == 3 ) // use beats by default. + { + vs2.push_back("0"); + } + + if( vs2.size() < 4 ) + { + LOG->UserLog( "Song file", "(UNKNOWN)", "has an speed change with %i values.", (int)vs2.size() ); + continue; + } + + const float fBeat = RowToBeat( vs2[0], rowsPerBeat ); + + SpeedSegment seg( fBeat, StringToFloat( vs2[1] ), StringToFloat( vs2[2] )); + seg.SetUnit(StringToInt(vs2[3])); + + if( fBeat < 0 ) + { + LOG->UserLog( "Song file", "(UNKNOWN)", "has an speed change with beat %f.", fBeat ); + continue; + } + + if( seg.GetLength() < 0 ) + { + LOG->UserLog( "Song file", "(UNKNOWN)", "has an speed change with beat %f, length %f.", fBeat, seg.GetLength() ); + continue; + } + + out.AddSpeedSegment( seg ); + } +} bool SMLoader::LoadFromBGChangesString( BackgroundChange &change, const RString &sBGChangeExpression ) { @@ -754,33 +827,6 @@ bool SMLoader::LoadFromSMFile( const RString &sPath, Song &out, bool bFromCache return true; } -bool SMLoader::LoadFromDir( const RString &sPath, Song &out ) -{ - vector aFileNames; - GetApplicableFiles( sPath, aFileNames ); - - if( aFileNames.size() > 1 ) - { - LOG->UserLog( "Song", sPath, "has more than one SM file. There can be only one (unless you are using TougaKiryuu's AnimeMix files somehow, which assume a different version of StepMania)!" ); - return false; - /* - for( unsigned i=0; i= 1 ); - - return LoadFromSMFile( sPath + aFileNames[0], out ); -} - bool SMLoader::LoadEditFromFile( RString sEditFilePath, ProfileSlot slot, bool bAddStepsToSong ) { LOG->Trace( "SMLoader::LoadEditFromFile(%s)", sEditFilePath.c_str() ); diff --git a/src/NotesLoaderSM.h b/src/NotesLoaderSM.h index a3da6ecde1..e63e80acdb 100644 --- a/src/NotesLoaderSM.h +++ b/src/NotesLoaderSM.h @@ -21,6 +21,11 @@ struct SMLoader virtual ~SMLoader() {} bool LoadFromDir( const RString &sPath, Song &out ); + /** + * @brief Perform some cleanup on the loaded song. + * @param song a reference to the song that may need cleaning up. + * @param bFromCache a flag to determine if this song is loaded from a cache file. + */ virtual void TidyUpData( Song &song, bool bFromCache ); bool LoadFromSMFile( const RString &sPath, Song &out, bool bFromCache = false ); @@ -72,7 +77,21 @@ struct SMLoader void ProcessTickcounts(TimingData & out, const RString line, const int rowsPerBeat = -1); - void ProcessBGChanges( Song &out, const RString &sValueName, + + /** + * @brief Process the Speed Segments from the string. + * @param out the TimingData being modified. + * @param line the string in question. + * @param rowsPerBeat the number of rows per beat for this purpose. */ + virtual void ProcessSpeeds(TimingData & out, + const RString line, + const int rowsPerBeat = -1); + + virtual void ProcessCombos(TimingData & out, + const RString line, + const int rowsPerBeat = -1) {} + + virtual void ProcessBGChanges( Song &out, const RString &sValueName, const RString &sPath, const RString &sParam ); void ProcessAttacks( Song &out, MsdFile::value_t sParams ); void ProcessInstrumentTracks( Song &out, const RString &sParam ); diff --git a/src/NotesLoaderSMA.cpp b/src/NotesLoaderSMA.cpp index c5cf98952d..f5b726626f 100644 --- a/src/NotesLoaderSMA.cpp +++ b/src/NotesLoaderSMA.cpp @@ -91,15 +91,10 @@ void SMALoader::ProcessBeatsPerMeasure( TimingData &out, const RString sParam ) } } -float BeatToSeconds(float fromBeat, RString toSomething) -{ - return 0; -} - -void SMALoader::ProcessSpeeds( TimingData &out, const int iRowsPerBeat, const RString sParam ) +void SMALoader::ProcessSpeeds( TimingData &out, const RString line, const int rowsPerBeat ) { vector vs1; - split( sParam, ",", vs1 ); + split( line, ",", vs1 ); FOREACH_CONST( RString, vs1, s1 ) { @@ -120,7 +115,7 @@ void SMALoader::ProcessSpeeds( TimingData &out, const int iRowsPerBeat, const RS continue; } - const float fBeat = RowToBeat( vs2[0], iRowsPerBeat ); + const float fBeat = RowToBeat( vs2[0], rowsPerBeat ); RString backup = vs2[2]; Trim(vs2[2], "s"); @@ -429,7 +424,7 @@ bool SMALoader::LoadFromSMAFile( const RString &sPath, Song &out ) ? pNewNotes->m_Timing : out.m_SongTiming); RString tmp = sParams[1]; Trim( tmp ); - ProcessSpeeds( timing, iRowsPerBeat, tmp ); + ProcessSpeeds( timing, tmp, iRowsPerBeat ); } else if( sValueName=="MULTIPLIER" ) diff --git a/src/NotesLoaderSMA.h b/src/NotesLoaderSMA.h index 494646026e..a38a07752f 100644 --- a/src/NotesLoaderSMA.h +++ b/src/NotesLoaderSMA.h @@ -30,7 +30,7 @@ struct SMALoader : public SMLoader void ProcessBeatsPerMeasure( TimingData &out, const RString sParam ); void ProcessMultipliers( TimingData &out, const int iRowsPerBeat, const RString sParam ); - void ProcessSpeeds( TimingData &out, const int iRowsPerBeat, const RString sParam ); + virtual void ProcessSpeeds( TimingData &out, const RString line, const int rowsPerBeat ); void ProcessFakes( TimingData &out, const int iRowsPerBeat, const RString sParam ); }; diff --git a/src/NotesLoaderSSC.cpp b/src/NotesLoaderSSC.cpp index 54c7e208b5..1482054bb9 100644 --- a/src/NotesLoaderSSC.cpp +++ b/src/NotesLoaderSSC.cpp @@ -97,10 +97,10 @@ void SSCLoader::ProcessLabels( TimingData &out, const RString sParam ) } } -void SSCLoader::ProcessCombos( TimingData &out, const RString sParam ) +void SSCLoader::ProcessCombos( TimingData &out, const RString line, const int rowsPerBeat ) { vector arrayComboExpressions; - split( sParam, ",", arrayComboExpressions ); + split( line, ",", arrayComboExpressions ); for( unsigned f=0; f vs1; - split( sParam, ",", vs1 ); - - FOREACH_CONST( RString, vs1, s1 ) - { - vector vs2; - split( *s1, "=", vs2 ); - - if( vs2[0] == 0 && vs2.size() == 2 ) // First one always seems to have 2. - { - vs2.push_back("0"); - } - - if( vs2.size() == 3 ) // use beats by default. - { - vs2.push_back("0"); - } - - if( vs2.size() < 4 ) - { - LOG->UserLog( "Song file", "(UNKNOWN)", "has an speed change with %i values.", (int)vs2.size() ); - continue; - } - - const float fBeat = StringToFloat( vs2[0] ); - - SpeedSegment seg( fBeat, StringToFloat( vs2[1] ), StringToFloat( vs2[2] )); - seg.SetUnit(StringToInt(vs2[3])); - - if( fBeat < 0 ) - { - LOG->UserLog( "Song file", "(UNKNOWN)", "has an speed change with beat %f.", fBeat ); - continue; - } - - if( seg.GetLength() < 0 ) - { - LOG->UserLog( "Song file", "(UNKNOWN)", "has an speed change with beat %f, length %f.", fBeat, seg.GetLength() ); - continue; - } - - out.AddSpeedSegment( seg ); - } -} - void SSCLoader::ProcessScrolls( TimingData &out, const RString sParam ) { vector vs1; @@ -906,11 +859,6 @@ bool SSCLoader::LoadEditFromMsd( const MsdFile &msd, const RString &sEditFilePat return bSSCFormat; } -void SSCLoader::TidyUpData( Song &song, bool bFromCache ) -{ - SMLoader::TidyUpData(song, bFromCache); -} - /* * (c) 2011 Jason Felds * All rights reserved. diff --git a/src/NotesLoaderSSC.h b/src/NotesLoaderSSC.h index d3ffe6c12c..29cf560458 100644 --- a/src/NotesLoaderSSC.h +++ b/src/NotesLoaderSSC.h @@ -70,18 +70,11 @@ struct SSCLoader : public SMLoader * @return its success or failure. */ bool LoadEditFromMsd( const MsdFile &msd, const RString &sEditFilePath, ProfileSlot slot, bool bAddStepsToSong ); - /** - * @brief Perform some cleanup on the loaded song. - * @param song a reference to the song that may need cleaning up. - * @param bFromCache a flag to determine if this song is loaded from a cache file. - */ - void TidyUpData( Song &song, bool bFromCache ); void ProcessWarps( TimingData &, const RString, const float ); void ProcessLabels( TimingData &, const RString ); - void ProcessCombos( TimingData &, const RString ); - void ProcessSpeeds( TimingData &, const RString ); + virtual void ProcessCombos( TimingData &, const RString, const int = -1 ); void ProcessScrolls( TimingData &, const RString ); void ProcessFakes( TimingData &, const RString ); };