cache HasMusic() and HasBanner() results
This commit is contained in:
@@ -216,12 +216,18 @@ bool SMLoader::LoadFromSMFile( CString sPath, Song &out )
|
|||||||
}
|
}
|
||||||
else if( 0==stricmp(sValueName,"SONGFILENAME") )
|
else if( 0==stricmp(sValueName,"SONGFILENAME") )
|
||||||
{
|
{
|
||||||
if(!FromCache)
|
if( FromCache )
|
||||||
{
|
out.m_sSongFileName = sParams[1];
|
||||||
LOG->Trace("Ignored #SONGFILENAME (cache only)");
|
}
|
||||||
continue;
|
else if( 0==stricmp(sValueName,"HASMUSIC") )
|
||||||
}
|
{
|
||||||
out.m_sSongFileName = sParams[1];
|
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") )
|
else if( 0==stricmp(sValueName,"SAMPLESTART") )
|
||||||
|
|||||||
@@ -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( "#FIRSTBEAT:%.3f;\n", out.m_fFirstBeat ) );
|
||||||
f.PutLine( ssprintf( "#LASTBEAT:%.3f;\n", out.m_fLastBeat ) );
|
f.PutLine( ssprintf( "#LASTBEAT:%.3f;\n", out.m_fLastBeat ) );
|
||||||
f.PutLine( ssprintf( "#SONGFILENAME:%s;\n", out.m_sSongFileName.c_str() ) );
|
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/"
|
#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;
|
const float DEFAULT_MUSIC_SAMPLE_LENGTH = 12.f;
|
||||||
|
|
||||||
@@ -83,6 +83,8 @@ Song::Song()
|
|||||||
m_fSpecifiedBPMMin = 0;
|
m_fSpecifiedBPMMin = 0;
|
||||||
m_fSpecifiedBPMMax = 0;
|
m_fSpecifiedBPMMax = 0;
|
||||||
m_bIsSymLink = false;
|
m_bIsSymLink = false;
|
||||||
|
m_bHasMusic = false;
|
||||||
|
m_bHasBanner = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Song::~Song()
|
Song::~Song()
|
||||||
@@ -246,13 +248,13 @@ bool Song::LoadFromSongDir( CString sDir, bool bAllowCache )
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Load the cached banners, if it's not loaded already. */
|
/* Load the cached banners, if it's not loaded already. */
|
||||||
if( HasBanner() )
|
if( m_bHasBanner )
|
||||||
BANNERCACHE->LoadBanner( GetBannerPath() );
|
BANNERCACHE->LoadBanner( GetBannerPath() );
|
||||||
|
|
||||||
/* Add AutoGen pointers. (These aren't cached.) */
|
/* Add AutoGen pointers. (These aren't cached.) */
|
||||||
AddAutoGenNotes();
|
AddAutoGenNotes();
|
||||||
|
|
||||||
if( !HasMusic() )
|
if( !m_bHasMusic )
|
||||||
return false; // don't load this song
|
return false; // don't load this song
|
||||||
else
|
else
|
||||||
return true; // do load this song
|
return true; // do load this song
|
||||||
@@ -538,6 +540,8 @@ void Song::TidyUpData()
|
|||||||
//
|
//
|
||||||
if( !HasBanner() )
|
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 = "";
|
// m_sBannerFile = "";
|
||||||
|
|
||||||
// find an image with "banner" in the file name
|
// 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() )
|
if( HasBanner() )
|
||||||
BANNERCACHE->CacheBanner( GetBannerPath() );
|
BANNERCACHE->CacheBanner( GetBannerPath() );
|
||||||
|
|
||||||
|
|||||||
@@ -140,6 +140,8 @@ public:
|
|||||||
CString GetBackgroundPath() const;
|
CString GetBackgroundPath() const;
|
||||||
CString GetCDTitlePath() const;
|
CString GetCDTitlePath() const;
|
||||||
|
|
||||||
|
/* For loading only: */
|
||||||
|
bool m_bHasMusic, m_bHasBanner;
|
||||||
|
|
||||||
bool HasMusic() const;
|
bool HasMusic() const;
|
||||||
bool HasBanner() const;
|
bool HasBanner() const;
|
||||||
|
|||||||
Reference in New Issue
Block a user