New branch: [notesloader]

Time to better unify our files and refactor properly.
This commit is contained in:
Jason Felds
2011-06-09 13:46:30 -04:00
parent 0fa0d42549
commit b6bf776716
12 changed files with 53 additions and 42 deletions
+6 -4
View File
@@ -142,8 +142,10 @@ static void StartMusic( MusicToPlay &ToPlay )
{
LOG->Trace( "Found '%s'", ToPlay.m_sTimingFile.c_str() );
Song song;
if( GetExtension(ToPlay.m_sTimingFile) == ".ssc" &&
SSCLoader::LoadFromSSCFile(ToPlay.m_sTimingFile, song) )
SSCLoader loaderSSC;
SMLoader loaderSM;
if(GetExtension(ToPlay.m_sTimingFile) == ".ssc" &&
loaderSSC.LoadFromSSCFile(ToPlay.m_sTimingFile, song) )
{
ToPlay.HasTiming = true;
ToPlay.m_TimingData = song.m_SongTiming;
@@ -152,8 +154,8 @@ static void StartMusic( MusicToPlay &ToPlay )
if( pStepsCabinetLights )
pStepsCabinetLights->GetNoteData( ToPlay.m_LightsData );
}
else if( GetExtension(ToPlay.m_sTimingFile) == ".sm" &&
SMLoader::LoadFromSMFile(ToPlay.m_sTimingFile, song) )
else if(GetExtension(ToPlay.m_sTimingFile) == ".sm" &&
loaderSM.LoadFromSMFile(ToPlay.m_sTimingFile, song) )
{
ToPlay.HasTiming = true;
ToPlay.m_TimingData = song.m_SongTiming;
+10 -7
View File
@@ -32,20 +32,23 @@ bool NotesLoader::LoadFromDir( const RString &sPath, Song &out, set<RString> &Bl
vector<RString> list;
BlacklistedImages.clear();
SSCLoader::GetApplicableFiles( sPath, list );
SSCLoader loaderSSC;
loaderSSC.GetApplicableFiles( sPath, list );
if( !list.empty() )
{
if( !SSCLoader::LoadFromDir( sPath, out ) )
if( !loaderSSC.LoadFromDir( sPath, out ) )
return false;
SSCLoader::TidyUpData( out, false );
loaderSSC.TidyUpData( out, false );
return true;
}
SMALoader::GetApplicableFiles( sPath, list );
SMALoader loaderSMA;
loaderSMA.GetApplicableFiles( sPath, list );
if (!list.empty() )
return SMALoader::LoadFromDir( sPath, out );
SMLoader::GetApplicableFiles( sPath, list );
return loaderSMA.LoadFromDir( sPath, out );
SMLoader loaderSM;
loaderSM.GetApplicableFiles( sPath, list );
if (!list.empty() )
return SMLoader::LoadFromDir( sPath, out );
return loaderSM.LoadFromDir( sPath, out );
DWILoader::GetApplicableFiles( sPath, list );
if( !list.empty() )
return DWILoader::LoadFromDir( sPath, out, BlacklistedImages );
+5 -3
View File
@@ -16,8 +16,9 @@ class TimingData;
const float FAST_BPM_WARP = 9999999.f;
/** @brief Reads a Song from an .SM file. */
namespace SMLoader
struct SMLoader
{
virtual ~SMLoader() {}
void LoadFromSMTokens( RString sStepsType, RString sDescription, RString sDifficulty,
RString sMeter, RString sRadarValues, RString sNoteData, Steps &out );
@@ -29,7 +30,8 @@ namespace SMLoader
bool LoadEditFromFile( RString sEditFilePath, ProfileSlot slot, bool bAddStepsToSong );
bool LoadEditFromBuffer( const RString &sBuffer, const RString &sEditFilePath, ProfileSlot slot );
bool LoadEditFromMsd( const MsdFile &msd, const RString &sEditFilePath, ProfileSlot slot, bool bAddStepsToSong );
bool LoadFromBGChangesString( BackgroundChange &change, const RString &sBGChangeExpression );
virtual bool LoadFromBGChangesString(BackgroundChange &change,
const RString &sBGChangeExpression );
bool ProcessBPMs( TimingData &, const RString );
@@ -41,7 +43,7 @@ namespace SMLoader
const RString &sPath, const RString &sParam );
void ProcessAttacks( Song &out, MsdFile::value_t sParams );
void ProcessInstrumentTracks( Song &out, const RString &sParam );
}
};
#endif
+2 -1
View File
@@ -2,6 +2,7 @@
#define NOTES_LOADER_SMA_H
#include "GameConstantsAndTypes.h"
#include "NotesLoaderSM.h"
#include "BackgroundUtil.h"
class MsdFile;
@@ -20,7 +21,7 @@ enum SMALoadingStates
};
/** @brief Reads a Song from a .SMA file. */
namespace SMALoader
struct SMALoader : public SMLoader
{
void LoadFromSMATokens( RString sStepsType,
RString sDescription,
+1 -12
View File
@@ -19,17 +19,6 @@
*/
const int MAX_EDIT_STEPS_SIZE_BYTES = 60*1024; // 60 KB
/**
* @brief Attempt to load any background changes in use by this song.
* @param change a reference to the background change.
* @param sBGChangeExpression a reference to the list of changes to be made.
* @return its success or failure.
*/
bool LoadFromBGSSCChangesString( BackgroundChange &change, const RString &sBGChangeExpression )
{
return SMLoader::LoadFromBGChangesString( change, sBGChangeExpression );
}
bool SSCLoader::LoadFromDir( const RString &sPath, Song &out )
{
vector<RString> aFileNames;
@@ -421,7 +410,7 @@ bool SSCLoader::LoadFromSSCFile( const RString &sPath, Song &out, bool bFromCach
for( unsigned b=0; b<aFGChangeExpressions.size(); b++ )
{
BackgroundChange change;
if( LoadFromBGSSCChangesString( change, aFGChangeExpressions[b] ) )
if( LoadFromBGChangesString( change, aFGChangeExpressions[b] ) )
out.AddForegroundChange( change );
}
}
+4 -2
View File
@@ -3,6 +3,7 @@
#define NotesLoaderSSC_H
#include "GameConstantsAndTypes.h"
#include "NotesLoaderSM.h"
class MsdFile;
class Song;
@@ -29,7 +30,7 @@ const float VERSION_SPLIT_TIMING = 0.7f;
/**
* @brief The SSCLoader handles all of the parsing needed for .ssc files.
*/
namespace SSCLoader
struct SSCLoader : public SMLoader
{
/**
* @brief Attempt to load a song from a specified path.
@@ -83,7 +84,8 @@ namespace SSCLoader
void ProcessSpeeds( TimingData &, const RString );
void ProcessScrolls( TimingData &, const RString );
void ProcessFakes( TimingData &, const RString );
}
};
#endif
/**
* @file
+4 -2
View File
@@ -21,10 +21,12 @@ void ScreenGameplaySyncMachine::Init()
RString sFile = THEME->GetPathO("ScreenGameplaySyncMachine","music");
// Allow themers to use either a .ssc or .sm file for this. -aj
SSCLoader loaderSSC;
SMLoader loaderSM;
if(sFile.Right(4) == ".ssc")
SSCLoader::LoadFromSSCFile( sFile, m_Song );
loaderSSC.LoadFromSSCFile( sFile, m_Song );
else
SMLoader::LoadFromSMFile( sFile, m_Song );
loaderSM.LoadFromSMFile( sFile, m_Song );
m_Song.SetSongDir( Dirname(sFile) );
m_Song.TidyUpData();
+4 -2
View File
@@ -135,10 +135,12 @@ void ScreenHowToPlay::Init()
// Allow themers to use either a .ssc or .sm file for this. -aj
RString sStepsPath = THEME->GetPathO(m_sName, "steps");
SSCLoader loaderSSC;
SMLoader loaderSM;
if( sStepsPath.Right(4) == ".ssc" )
SSCLoader::LoadFromSSCFile( sStepsPath, m_Song, false );
loaderSSC.LoadFromSSCFile( sStepsPath, m_Song, false );
else
SMLoader::LoadFromSMFile( sStepsPath, m_Song, false );
loaderSM.LoadFromSMFile( sStepsPath, m_Song, false );
m_Song.AddAutoGenNotes();
const Style* pStyle = GAMESTATE->GetCurrentStyle();
+2 -1
View File
@@ -197,7 +197,8 @@ static void CopyEdits( const RString &sFromProfileDir, const RString &sToProfile
iNumErrored++;
// Test whether the song we need for this edit is present and ignore this edit if not present.
if( !SSCLoader::LoadEditFromFile( sFromDir+*i, ProfileSlot_Machine, false ) )
SSCLoader loaderSSC;
if( !loaderSSC.LoadEditFromFile( sFromDir+*i, ProfileSlot_Machine, false ) )
{
iNumIgnored++;
continue;
+5 -3
View File
@@ -235,12 +235,14 @@ bool Song::LoadFromSongDir( RString sDir )
if( bUseCache )
{
// LOG->Trace( "Loading '%s' from cache file '%s'.", m_sSongDir.c_str(), GetCacheFilePath().c_str() );
bool bLoadedFromSSC = SSCLoader::LoadFromSSCFile( sCacheFilePath, *this, true );
SSCLoader loaderSSC;
bool bLoadedFromSSC = loaderSSC.LoadFromSSCFile( sCacheFilePath, *this, true );
if( !bLoadedFromSSC )
{
// load from .sm
SMLoader::LoadFromSMFile( sCacheFilePath, *this, true );
SMLoader::TidyUpData( *this, true );
SMLoader loaderSM;
loaderSM.LoadFromSMFile( sCacheFilePath, *this, true );
loaderSM.TidyUpData( *this, true );
}
}
else
+6 -3
View File
@@ -1655,12 +1655,15 @@ void SongManager::LoadStepEditsFromProfileDir( const RString &sProfileDir, Profi
for( int i=0; i<size; i++ )
{
RString fn = vsFiles[i];
bool bLoadedFromSSC = SSCLoader::LoadEditFromFile( fn, slot, true );
SSCLoader loaderSSC;
bool bLoadedFromSSC = loaderSSC.LoadEditFromFile( fn, slot, true );
// If we don't load the edit from a .ssc-style .edit, then we should
// also try the .sm-style edit file. -aj
if( !bLoadedFromSSC )
SMLoader::LoadEditFromFile( fn, slot, true );
{
SMLoader loaderSM;
loaderSM.LoadEditFromFile( fn, slot, true );
}
}
}
}
+4 -2
View File
@@ -242,11 +242,13 @@ void Steps::Decompress() const
{
// We have data on disk and not in memory. Load it.
Song s;
bool bLoadedFromSSC = SSCLoader::LoadFromSSCFile(m_sFilename, s, true);
SSCLoader loaderSSC;
bool bLoadedFromSSC = loaderSSC.LoadFromSSCFile(m_sFilename, s, true);
if( !bLoadedFromSSC )
{
// try reading from .sm instead
if( !SMLoader::LoadFromSMFile(m_sFilename, s, true) )
SMLoader loaderSM;
if( !loaderSM.LoadFromSMFile(m_sFilename, s, true) )
{
LOG->Warn( "Couldn't load \"%s\"", m_sFilename.c_str() );
return;