[notesloader] Some refactoring done.
This commit is contained in:
+19
-4
@@ -16,7 +16,22 @@
|
||||
/** @brief The maximum file size for edits. */
|
||||
const int MAX_EDIT_STEPS_SIZE_BYTES = 60*1024; // 60KB
|
||||
|
||||
void SMLoader::LoadFromSMTokens(
|
||||
float SMLoader::RowToBeat( RString line, const int rowsPerBeat )
|
||||
{
|
||||
RString backup = line;
|
||||
Trim(line, "r");
|
||||
Trim(line, "R");
|
||||
if( backup != line )
|
||||
{
|
||||
return StringToFloat( line ) / rowsPerBeat;
|
||||
}
|
||||
else
|
||||
{
|
||||
return StringToFloat( line );
|
||||
}
|
||||
}
|
||||
|
||||
void SMLoader::LoadFromTokens(
|
||||
RString sStepsType,
|
||||
RString sDescription,
|
||||
RString sDifficulty,
|
||||
@@ -34,7 +49,7 @@ void SMLoader::LoadFromSMTokens(
|
||||
Trim( sDifficulty );
|
||||
Trim( sNoteData );
|
||||
|
||||
// LOG->Trace( "Steps::LoadFromSMTokens()" );
|
||||
// LOG->Trace( "Steps::LoadFromTokens()" );
|
||||
|
||||
// insert stepstype hacks from GameManager.cpp here? -aj
|
||||
out.m_StepsType = GAMEMAN->StringToStepsType( sStepsType );
|
||||
@@ -719,7 +734,7 @@ bool SMLoader::LoadFromSMFile( const RString &sPath, Song &out, bool bFromCache
|
||||
}
|
||||
|
||||
Steps* pNewNotes = out.CreateSteps();
|
||||
LoadFromSMTokens(
|
||||
LoadFromTokens(
|
||||
sParams[1],
|
||||
sParams[2],
|
||||
sParams[3],
|
||||
@@ -853,7 +868,7 @@ bool SMLoader::LoadEditFromMsd( const MsdFile &msd, const RString &sEditFilePath
|
||||
return true;
|
||||
|
||||
Steps* pNewNotes = pSong->CreateSteps();
|
||||
LoadFromSMTokens(
|
||||
LoadFromTokens(
|
||||
sParams[1], sParams[2], sParams[3], sParams[4], sParams[5], sParams[6],
|
||||
*pNewNotes);
|
||||
|
||||
|
||||
+27
-2
@@ -19,8 +19,6 @@ const float FAST_BPM_WARP = 9999999.f;
|
||||
struct SMLoader
|
||||
{
|
||||
virtual ~SMLoader() {}
|
||||
void LoadFromSMTokens( RString sStepsType, RString sDescription, RString sDifficulty,
|
||||
RString sMeter, RString sRadarValues, RString sNoteData, Steps &out );
|
||||
|
||||
bool LoadFromDir( const RString &sPath, Song &out );
|
||||
void TidyUpData( Song &song, bool bFromCache );
|
||||
@@ -43,6 +41,33 @@ struct SMLoader
|
||||
const RString &sPath, const RString &sParam );
|
||||
void ProcessAttacks( Song &out, MsdFile::value_t sParams );
|
||||
void ProcessInstrumentTracks( Song &out, const RString &sParam );
|
||||
|
||||
/**
|
||||
* @brief Convert a row value to the proper beat value.
|
||||
*
|
||||
* This is primarily used for assistance with converting SMA files.
|
||||
* @param line The line that contains the value.
|
||||
* @param rowsPerBeat the number of rows per beat according to the original file.
|
||||
* @return the converted beat value. */
|
||||
float RowToBeat(RString line, const int rowsPerBeat);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* @brief Process the different tokens we have available to get NoteData.
|
||||
* @param stepsType The current StepsType.
|
||||
* @param description The description of the chart.
|
||||
* @param difficulty The difficulty (in words) of the chart.
|
||||
* @param meter the difficulty (in numbers) of the chart.
|
||||
* @param radarValues the calculated radar values.
|
||||
* @param noteData the note data itself.
|
||||
* @param out the Steps getting the data. */
|
||||
virtual void LoadFromTokens(RString sStepsType,
|
||||
RString sDescription,
|
||||
RString sDifficulty,
|
||||
RString sMeter,
|
||||
RString sRadarValues,
|
||||
RString sNoteData,
|
||||
Steps &out);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
+2
-31
@@ -39,19 +39,6 @@ bool SMALoader::LoadFromDir( const RString &sPath, Song &out )
|
||||
return LoadFromSMAFile( sPath + aFileNames[0], out );
|
||||
}
|
||||
|
||||
float SMALoader::RowToBeat( RString sLine, const int iRowsPerBeat )
|
||||
{
|
||||
if( sLine.find("R") || sLine.find("r") )
|
||||
{
|
||||
sLine = sLine.Left(sLine.size()-1);
|
||||
return StringToFloat( sLine ) / iRowsPerBeat;
|
||||
}
|
||||
else
|
||||
{
|
||||
return StringToFloat( sLine );
|
||||
}
|
||||
}
|
||||
|
||||
bool SMALoader::ProcessBPMs( TimingData &out, const int iRowsPerBeat, const RString sParam )
|
||||
{
|
||||
vector<RString> arrayBPMChangeExpressions;
|
||||
@@ -391,22 +378,6 @@ void SMALoader::ProcessFakes( TimingData &out, const int iRowsPerBeat, const RSt
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SMALoader::LoadFromSMATokens(
|
||||
RString sStepsType,
|
||||
RString sDescription,
|
||||
RString sDifficulty,
|
||||
RString sMeter,
|
||||
RString sRadarValues,
|
||||
RString sNoteData,
|
||||
Steps &out
|
||||
)
|
||||
{
|
||||
SMLoader::LoadFromSMTokens( sStepsType, sDescription,
|
||||
sDifficulty, sMeter, sRadarValues,
|
||||
sNoteData, out );
|
||||
}
|
||||
|
||||
void SMALoader::TidyUpData( Song &song, bool bFromCache )
|
||||
{
|
||||
SMLoader::TidyUpData( song, bFromCache );
|
||||
@@ -706,7 +677,7 @@ bool SMALoader::LoadFromSMAFile( const RString &sPath, Song &out )
|
||||
continue;
|
||||
}
|
||||
|
||||
LoadFromSMATokens(
|
||||
LoadFromTokens(
|
||||
sParams[1],
|
||||
sParams[2],
|
||||
sParams[3],
|
||||
@@ -815,7 +786,7 @@ bool SMALoader::LoadEditFromMsd( const MsdFile &msd, const RString &sEditFilePat
|
||||
return true;
|
||||
|
||||
Steps* pNewNotes = pSong->CreateSteps();
|
||||
LoadFromSMATokens(
|
||||
LoadFromTokens(
|
||||
sParams[1], sParams[2], sParams[3], sParams[4], sParams[5], sParams[6],
|
||||
*pNewNotes);
|
||||
|
||||
|
||||
+1
-11
@@ -22,15 +22,7 @@ enum SMALoadingStates
|
||||
|
||||
/** @brief Reads a Song from a .SMA file. */
|
||||
struct SMALoader : public SMLoader
|
||||
{
|
||||
void LoadFromSMATokens( RString sStepsType,
|
||||
RString sDescription,
|
||||
RString sDifficulty,
|
||||
RString sMeter,
|
||||
RString sRadarValues,
|
||||
RString sNoteData,
|
||||
Steps &out );
|
||||
|
||||
{
|
||||
bool LoadFromDir( const RString &sPath, Song &out );
|
||||
void TidyUpData( Song &song, bool bFromCache );
|
||||
|
||||
@@ -50,8 +42,6 @@ struct SMALoader : public SMLoader
|
||||
void ProcessMultipliers( TimingData &out, const int iRowsPerBeat, const RString sParam );
|
||||
void ProcessSpeeds( TimingData &out, const int iRowsPerBeat, const RString sParam );
|
||||
void ProcessFakes( TimingData &out, const int iRowsPerBeat, const RString sParam );
|
||||
|
||||
float RowToBeat( RString sLine, const int iRowsPerBeat );
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -872,9 +872,13 @@ bool SSCLoader::LoadEditFromMsd( const MsdFile &msd, const RString &sEditFilePat
|
||||
else
|
||||
{
|
||||
pNewNotes = pSong->CreateSteps();
|
||||
SMLoader::LoadFromSMTokens(
|
||||
sParams[1], sParams[2], sParams[3], sParams[4], sParams[5], sParams[6],
|
||||
*pNewNotes);
|
||||
LoadFromTokens(sParams[1],
|
||||
sParams[2],
|
||||
sParams[3],
|
||||
sParams[4],
|
||||
sParams[5],
|
||||
sParams[6],
|
||||
*pNewNotes);
|
||||
}
|
||||
|
||||
pNewNotes->SetLoadedFromProfile( slot );
|
||||
|
||||
Reference in New Issue
Block a user