Get SSCLoader used when appropriate.

This commit is contained in:
Jason Felds
2011-02-11 00:10:57 -05:00
parent dbcfcd0cfc
commit 565b9f9306
10 changed files with 52 additions and 32 deletions
+2 -2
View File
@@ -6,7 +6,7 @@
#include "RageUtil.h"
#include "GameState.h"
#include "TimingData.h"
#include "NotesLoaderSM.h"
#include "NotesLoaderSSC.h"
#include "PrefsManager.h"
#include "RageDisplay.h"
#include "AnnouncerManager.h"
@@ -141,7 +141,7 @@ static void StartMusic( MusicToPlay &ToPlay )
{
LOG->Trace( "Found '%s'", ToPlay.m_sTimingFile.c_str() );
Song song;
if( SMLoader::LoadFromSMFile(ToPlay.m_sTimingFile, song) )
if( SSCLoader::LoadFromSSCFile(ToPlay.m_sTimingFile, song) )
{
ToPlay.HasTiming = true;
ToPlay.m_TimingData = song.m_Timing;
+7 -3
View File
@@ -1,6 +1,7 @@
#include "global.h"
#include "NotesLoader.h"
#include "NotesLoaderSM.h"
#include "NotesLoaderSSC.h"
#include "NotesLoaderDWI.h"
#include "NotesLoaderBMS.h"
#include "NotesLoaderPMS.h"
@@ -30,14 +31,17 @@ bool NotesLoader::LoadFromDir( const RString &sPath, Song &out, set<RString> &Bl
vector<RString> list;
BlacklistedImages.clear();
SMLoader::GetApplicableFiles( sPath, list );
SSCLoader::GetApplicableFiles( sPath, list );
if( !list.empty() )
{
if( !SMLoader::LoadFromDir(sPath, out) )
if( !SSCLoader::LoadFromDir( sPath, out ) )
return false;
SMLoader::TidyUpData( out, false );
SSCLoader::TidyUpData( out, false );
return true;
}
SMLoader::GetApplicableFiles( sPath, list );
if (!list.empty() )
return SMLoader::LoadFromDir( sPath, out );
DWILoader::GetApplicableFiles( sPath, list );
if( !list.empty() )
return DWILoader::LoadFromDir( sPath, out, BlacklistedImages );
+1 -1
View File
@@ -1,4 +1,4 @@
/* NotesWriterSM - Writes a Song to an .SSC file. */
/* NotesWriterSSC - Writes a Song to an .SSC file. */
#ifndef NOTES_WRITER_SSC_H
#define NOTES_WRITER_SSC_H
+2 -2
View File
@@ -1,6 +1,6 @@
#include "global.h"
#include "ScreenGameplaySyncMachine.h"
#include "NotesLoaderSM.h"
#include "NotesLoaderSSC.h"
#include "GameState.h"
#include "GameManager.h"
#include "PrefsManager.h"
@@ -19,7 +19,7 @@ void ScreenGameplaySyncMachine::Init()
AdjustSync::ResetOriginalSyncData();
RString sFile = THEME->GetPathO("ScreenGameplaySyncMachine","music.sm");
SMLoader::LoadFromSMFile( sFile, m_Song );
SSCLoader::LoadFromSSCFile( sFile, m_Song );
m_Song.SetSongDir( Dirname(sFile) );
m_Song.TidyUpData();
+2 -2
View File
@@ -4,7 +4,7 @@
#include "GameState.h"
#include "Steps.h"
#include "GameManager.h"
#include "NotesLoaderSM.h"
#include "NotesLoaderSSC.h"
#include "GameSoundManager.h"
#include "Model.h"
#include "ThemeMetric.h"
@@ -132,7 +132,7 @@ void ScreenHowToPlay::Init()
ActorUtil::LoadAllCommandsAndSetXY( m_pLifeMeterBar, m_sName );
m_pLifeMeterBar->FillForHowToPlay( NUM_W2S, NUM_MISSES );
SMLoader::LoadFromSMFile( THEME->GetPathO(m_sName, "steps"), m_Song, false );
SSCLoader::LoadFromSSCFile( THEME->GetPathO(m_sName, "steps"), m_Song, false );
m_Song.AddAutoGenNotes();
const Style* pStyle = GAMESTATE->GetCurrentStyle();
+2 -2
View File
@@ -15,7 +15,7 @@
#include "PlayerState.h"
#include "LocalizedString.h"
#include "StepMania.h"
#include "NotesLoaderSM.h"
#include "NotesLoaderSSC.h"
static LocalizedString BOOKKEEPING_DATA_CLEARED( "ScreenServiceAction", "Bookkeeping data cleared." );
static RString ClearBookkeepingData()
@@ -197,7 +197,7 @@ 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( !SMLoader::LoadEditFromFile( sFromDir+*i, ProfileSlot_Machine, false ) )
if( !SSCLoader::LoadEditFromFile( sFromDir+*i, ProfileSlot_Machine, false ) )
{
iNumIgnored++;
continue;
+24 -10
View File
@@ -25,8 +25,10 @@
#include "SpecialFiles.h"
#include "NotesLoader.h"
#include "NotesLoaderSM.h"
#include "NotesLoaderSSC.h"
#include "NotesWriterDWI.h"
#include "NotesWriterSM.h"
#include "NotesWriterSSC.h"
#include "UnlockManager.h"
#include "LyricsLoader.h"
@@ -34,7 +36,7 @@
#include <set>
#include <float.h>
const int FILE_CACHE_VERSION = 162; // increment this to invalidate cache
const int FILE_CACHE_VERSION = 163; // increment this to invalidate cache
const float DEFAULT_MUSIC_SAMPLE_LENGTH = 12.f;
@@ -214,8 +216,8 @@ bool Song::LoadFromSongDir( RString sDir )
if( bUseCache )
{
// LOG->Trace( "Loading '%s' from cache file '%s'.", m_sSongDir.c_str(), GetCacheFilePath().c_str() );
SMLoader::LoadFromSMFile( sCacheFilePath, *this, true );
SMLoader::TidyUpData( *this, true );
SSCLoader::LoadFromSSCFile( sCacheFilePath, *this, true );
SSCLoader::TidyUpData( *this, true );
}
else
{
@@ -844,9 +846,10 @@ void Song::Save()
TranslateTitles();
// Save the new files. These calls make backups on their own.
if( !SaveToSMFile(GetSongFilePath(), false) )
if( !SaveToSSCFile(GetSongFilePath(), false) )
return;
SaveToDWIFile();
SaveToSMFile();
//SaveToDWIFile();
SaveToCacheFile();
/* We've safely written our files and created backups. Rename non-SM and
@@ -871,10 +874,21 @@ void Song::Save()
}
}
bool Song::SaveToSMFile( RString sPath, bool bSavingCache )
bool Song::SaveToSMFile()
{
LOG->Trace( "Song::SaveToSMFile('%s')", sPath.c_str() );
const RString sPath = SetExtension( GetSongFilePath(), "sm" );
LOG->Trace( "Song::SaveToSMFile(%s)", sPath.c_str() );
// If the file exists, make a backup.
if( IsAFile(sPath) )
FileCopy( sPath, sPath + ".old" );
return NotesWriterSM::Write( sPath, *this );
}
bool Song::SaveToSSCFile( RString sPath, bool bSavingCache )
{
LOG->Trace( "Song::SaveToSSCFile('%s')", sPath.c_str() );
// If the file exists, make a backup.
if( !bSavingCache && IsAFile(sPath) )
@@ -894,7 +908,7 @@ bool Song::SaveToSMFile( RString sPath, bool bSavingCache )
vpStepsToSave.push_back( pSteps );
}
if( !NotesWriterSM::Write(sPath, *this, vpStepsToSave, bSavingCache) )
if( !NotesWriterSSC::Write(sPath, *this, vpStepsToSave, bSavingCache) )
return false;
if( !bSavingCache && g_BackUpAllSongSaves.Get() )
@@ -932,7 +946,7 @@ bool Song::SaveToCacheFile()
{
SONGINDEX->AddCacheIndex(m_sSongDir, GetHashForDirectory(m_sSongDir));
const RString sPath = GetCacheFilePath();
if( !SaveToSMFile(sPath, true) )
if( !SaveToSSCFile(sPath, true) )
return false;
FOREACH( Steps*, m_vpSteps, pSteps )
+8 -6
View File
@@ -61,7 +61,7 @@ public:
enum SelectionDisplay
{
SHOW_ALWAYS, // always
SHOW_NEVER // never (unless song hiding is turned off)
SHOW_NEVER // never (unless song hiding is turned off)
} m_SelectionDisplay;
Song();
@@ -78,9 +78,10 @@ public:
void ReCalculateRadarValuesAndLastBeat(); // called by TidyUpData, and after saving
void TranslateTitles(); // called by TidyUpData
bool SaveToSMFile( RString sPath, bool bSavingCache );
void Save(); // saves SM and DWI
bool SaveToSSCFile( RString sPath, bool bSavingCache );
void Save(); // saves SSC and SM guaranteed.
bool SaveToCacheFile();
bool SaveToSMFile();
bool SaveToDWIFile();
const RString &GetSongFilePath() const;
@@ -93,9 +94,10 @@ public:
// Directory this song data came from:
const RString &GetSongDir() const { return m_sSongDir; }
/* Filename associated with this file. This will always have an .SM extension.
* If we loaded an .SM, this will point to it, but if we loaded any other
* type, this will point to a generated .SM filename. */
/* Filename associated with this file. This will always have a
* .SSC extension. If we loaded a .SSC, this will point to it,
* but if we loaded any other type, this will point to a
* generated .SSC filename. */
RString m_sSongFileName;
RString m_sGroupName;
+2 -2
View File
@@ -15,7 +15,7 @@
#include "MsdFile.h"
#include "NoteSkinManager.h"
#include "NotesLoaderDWI.h"
#include "NotesLoaderSM.h"
#include "NotesLoaderSSC.h"
#include "PrefsManager.h"
#include "Profile.h"
#include "ProfileManager.h"
@@ -1653,7 +1653,7 @@ void SongManager::LoadStepEditsFromProfileDir( const RString &sProfileDir, Profi
{
RString fn = vsFiles[i];
SMLoader::LoadEditFromFile( fn, slot, true );
SSCLoader::LoadEditFromFile( fn, slot, true );
}
}
}
+2 -2
View File
@@ -20,7 +20,7 @@
#include "NoteData.h"
#include "GameManager.h"
#include "NoteDataUtil.h"
#include "NotesLoaderSM.h"
#include "NotesLoaderSSC.h"
#include <algorithm>
@@ -231,7 +231,7 @@ void Steps::Decompress() const
{
/* We have data on disk and not in memory. Load it. */
Song s;
if( !SMLoader::LoadFromSMFile(m_sFilename, s, true) )
if( !SSCLoader::LoadFromSSCFile(m_sFilename, s, true) )
{
LOG->Warn( "Couldn't load \"%s\"", m_sFilename.c_str() );
return;