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