[notesloader] Some refactoring done.
This commit is contained in:
+19
-4
@@ -16,7 +16,22 @@
|
|||||||
/** @brief The maximum file size for edits. */
|
/** @brief The maximum file size for edits. */
|
||||||
const int MAX_EDIT_STEPS_SIZE_BYTES = 60*1024; // 60KB
|
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 sStepsType,
|
||||||
RString sDescription,
|
RString sDescription,
|
||||||
RString sDifficulty,
|
RString sDifficulty,
|
||||||
@@ -34,7 +49,7 @@ void SMLoader::LoadFromSMTokens(
|
|||||||
Trim( sDifficulty );
|
Trim( sDifficulty );
|
||||||
Trim( sNoteData );
|
Trim( sNoteData );
|
||||||
|
|
||||||
// LOG->Trace( "Steps::LoadFromSMTokens()" );
|
// LOG->Trace( "Steps::LoadFromTokens()" );
|
||||||
|
|
||||||
// insert stepstype hacks from GameManager.cpp here? -aj
|
// insert stepstype hacks from GameManager.cpp here? -aj
|
||||||
out.m_StepsType = GAMEMAN->StringToStepsType( sStepsType );
|
out.m_StepsType = GAMEMAN->StringToStepsType( sStepsType );
|
||||||
@@ -719,7 +734,7 @@ bool SMLoader::LoadFromSMFile( const RString &sPath, Song &out, bool bFromCache
|
|||||||
}
|
}
|
||||||
|
|
||||||
Steps* pNewNotes = out.CreateSteps();
|
Steps* pNewNotes = out.CreateSteps();
|
||||||
LoadFromSMTokens(
|
LoadFromTokens(
|
||||||
sParams[1],
|
sParams[1],
|
||||||
sParams[2],
|
sParams[2],
|
||||||
sParams[3],
|
sParams[3],
|
||||||
@@ -853,7 +868,7 @@ bool SMLoader::LoadEditFromMsd( const MsdFile &msd, const RString &sEditFilePath
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
Steps* pNewNotes = pSong->CreateSteps();
|
Steps* pNewNotes = pSong->CreateSteps();
|
||||||
LoadFromSMTokens(
|
LoadFromTokens(
|
||||||
sParams[1], sParams[2], sParams[3], sParams[4], sParams[5], sParams[6],
|
sParams[1], sParams[2], sParams[3], sParams[4], sParams[5], sParams[6],
|
||||||
*pNewNotes);
|
*pNewNotes);
|
||||||
|
|
||||||
|
|||||||
+27
-2
@@ -19,8 +19,6 @@ const float FAST_BPM_WARP = 9999999.f;
|
|||||||
struct SMLoader
|
struct SMLoader
|
||||||
{
|
{
|
||||||
virtual ~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 );
|
bool LoadFromDir( const RString &sPath, Song &out );
|
||||||
void TidyUpData( Song &song, bool bFromCache );
|
void TidyUpData( Song &song, bool bFromCache );
|
||||||
@@ -43,6 +41,33 @@ struct SMLoader
|
|||||||
const RString &sPath, const RString &sParam );
|
const RString &sPath, const RString &sParam );
|
||||||
void ProcessAttacks( Song &out, MsdFile::value_t sParams );
|
void ProcessAttacks( Song &out, MsdFile::value_t sParams );
|
||||||
void ProcessInstrumentTracks( Song &out, const RString &sParam );
|
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
|
#endif
|
||||||
|
|||||||
+2
-31
@@ -39,19 +39,6 @@ bool SMALoader::LoadFromDir( const RString &sPath, Song &out )
|
|||||||
return LoadFromSMAFile( sPath + aFileNames[0], 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 )
|
bool SMALoader::ProcessBPMs( TimingData &out, const int iRowsPerBeat, const RString sParam )
|
||||||
{
|
{
|
||||||
vector<RString> arrayBPMChangeExpressions;
|
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 )
|
void SMALoader::TidyUpData( Song &song, bool bFromCache )
|
||||||
{
|
{
|
||||||
SMLoader::TidyUpData( song, bFromCache );
|
SMLoader::TidyUpData( song, bFromCache );
|
||||||
@@ -706,7 +677,7 @@ bool SMALoader::LoadFromSMAFile( const RString &sPath, Song &out )
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
LoadFromSMATokens(
|
LoadFromTokens(
|
||||||
sParams[1],
|
sParams[1],
|
||||||
sParams[2],
|
sParams[2],
|
||||||
sParams[3],
|
sParams[3],
|
||||||
@@ -815,7 +786,7 @@ bool SMALoader::LoadEditFromMsd( const MsdFile &msd, const RString &sEditFilePat
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
Steps* pNewNotes = pSong->CreateSteps();
|
Steps* pNewNotes = pSong->CreateSteps();
|
||||||
LoadFromSMATokens(
|
LoadFromTokens(
|
||||||
sParams[1], sParams[2], sParams[3], sParams[4], sParams[5], sParams[6],
|
sParams[1], sParams[2], sParams[3], sParams[4], sParams[5], sParams[6],
|
||||||
*pNewNotes);
|
*pNewNotes);
|
||||||
|
|
||||||
|
|||||||
@@ -23,14 +23,6 @@ enum SMALoadingStates
|
|||||||
/** @brief Reads a Song from a .SMA file. */
|
/** @brief Reads a Song from a .SMA file. */
|
||||||
struct SMALoader : public SMLoader
|
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 );
|
bool LoadFromDir( const RString &sPath, Song &out );
|
||||||
void TidyUpData( Song &song, bool bFromCache );
|
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 ProcessMultipliers( TimingData &out, const int iRowsPerBeat, const RString sParam );
|
||||||
void ProcessSpeeds( 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 );
|
void ProcessFakes( TimingData &out, const int iRowsPerBeat, const RString sParam );
|
||||||
|
|
||||||
float RowToBeat( RString sLine, const int iRowsPerBeat );
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -872,9 +872,13 @@ bool SSCLoader::LoadEditFromMsd( const MsdFile &msd, const RString &sEditFilePat
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
pNewNotes = pSong->CreateSteps();
|
pNewNotes = pSong->CreateSteps();
|
||||||
SMLoader::LoadFromSMTokens(
|
LoadFromTokens(sParams[1],
|
||||||
sParams[1], sParams[2], sParams[3], sParams[4], sParams[5], sParams[6],
|
sParams[2],
|
||||||
*pNewNotes);
|
sParams[3],
|
||||||
|
sParams[4],
|
||||||
|
sParams[5],
|
||||||
|
sParams[6],
|
||||||
|
*pNewNotes);
|
||||||
}
|
}
|
||||||
|
|
||||||
pNewNotes->SetLoadedFromProfile( slot );
|
pNewNotes->SetLoadedFromProfile( slot );
|
||||||
|
|||||||
Reference in New Issue
Block a user