cache HasMusic() and HasBanner() results
This commit is contained in:
@@ -216,14 +216,20 @@ bool SMLoader::LoadFromSMFile( CString sPath, Song &out )
|
||||
}
|
||||
else if( 0==stricmp(sValueName,"SONGFILENAME") )
|
||||
{
|
||||
if(!FromCache)
|
||||
{
|
||||
LOG->Trace("Ignored #SONGFILENAME (cache only)");
|
||||
continue;
|
||||
}
|
||||
out.m_sSongFileName = sParams[1];
|
||||
if( FromCache )
|
||||
out.m_sSongFileName = sParams[1];
|
||||
}
|
||||
|
||||
else if( 0==stricmp(sValueName,"HASMUSIC") )
|
||||
{
|
||||
if( FromCache )
|
||||
out.m_bHasMusic = atoi( sParams[1] ) != 0;
|
||||
}
|
||||
else if( 0==stricmp(sValueName,"HASBANNER") )
|
||||
{
|
||||
if( FromCache )
|
||||
out.m_bHasBanner = atoi( sParams[1] ) != 0;
|
||||
}
|
||||
|
||||
else if( 0==stricmp(sValueName,"SAMPLESTART") )
|
||||
out.m_fMusicSampleStartSeconds = TimeToSeconds( sParams[1] );
|
||||
|
||||
|
||||
@@ -172,6 +172,8 @@ bool NotesWriterSM::Write(CString sPath, const Song &out, bool bSavingCache)
|
||||
f.PutLine( ssprintf( "#FIRSTBEAT:%.3f;\n", out.m_fFirstBeat ) );
|
||||
f.PutLine( ssprintf( "#LASTBEAT:%.3f;\n", out.m_fLastBeat ) );
|
||||
f.PutLine( ssprintf( "#SONGFILENAME:%s;\n", out.m_sSongFileName.c_str() ) );
|
||||
f.PutLine( ssprintf( "#HASMUSIC:%i;\n", out.m_bHasMusic ) );
|
||||
f.PutLine( ssprintf( "#HASBANNER:%i;\n", out.m_bHasBanner ) );
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
+11
-3
@@ -50,7 +50,7 @@
|
||||
|
||||
#define CACHE_DIR "Cache/"
|
||||
|
||||
const int FILE_CACHE_VERSION = 132; // increment this when Song or Steps changes to invalidate cache
|
||||
const int FILE_CACHE_VERSION = 133; // increment this when Song or Steps changes to invalidate cache
|
||||
|
||||
const float DEFAULT_MUSIC_SAMPLE_LENGTH = 12.f;
|
||||
|
||||
@@ -83,6 +83,8 @@ Song::Song()
|
||||
m_fSpecifiedBPMMin = 0;
|
||||
m_fSpecifiedBPMMax = 0;
|
||||
m_bIsSymLink = false;
|
||||
m_bHasMusic = false;
|
||||
m_bHasBanner = false;
|
||||
}
|
||||
|
||||
Song::~Song()
|
||||
@@ -246,13 +248,13 @@ bool Song::LoadFromSongDir( CString sDir, bool bAllowCache )
|
||||
}
|
||||
|
||||
/* Load the cached banners, if it's not loaded already. */
|
||||
if( HasBanner() )
|
||||
if( m_bHasBanner )
|
||||
BANNERCACHE->LoadBanner( GetBannerPath() );
|
||||
|
||||
/* Add AutoGen pointers. (These aren't cached.) */
|
||||
AddAutoGenNotes();
|
||||
|
||||
if( !HasMusic() )
|
||||
if( !m_bHasMusic )
|
||||
return false; // don't load this song
|
||||
else
|
||||
return true; // do load this song
|
||||
@@ -538,6 +540,8 @@ void Song::TidyUpData()
|
||||
//
|
||||
if( !HasBanner() )
|
||||
{
|
||||
/* If a nonexistant banner file is specified, and we can't find a replacement,
|
||||
* don't wipe out the old value. */
|
||||
// m_sBannerFile = "";
|
||||
|
||||
// find an image with "banner" in the file name
|
||||
@@ -672,6 +676,10 @@ void Song::TidyUpData()
|
||||
}
|
||||
}
|
||||
|
||||
/* These will be written to cache, for Song::LoadFromSongDir to use later. */
|
||||
m_bHasMusic = HasMusic();
|
||||
m_bHasBanner = HasBanner();
|
||||
|
||||
if( HasBanner() )
|
||||
BANNERCACHE->CacheBanner( GetBannerPath() );
|
||||
|
||||
|
||||
@@ -140,6 +140,8 @@ public:
|
||||
CString GetBackgroundPath() const;
|
||||
CString GetCDTitlePath() const;
|
||||
|
||||
/* For loading only: */
|
||||
bool m_bHasMusic, m_bHasBanner;
|
||||
|
||||
bool HasMusic() const;
|
||||
bool HasBanner() const;
|
||||
|
||||
Reference in New Issue
Block a user