From ffbf54c263592533da620780fe0bca1f6e5098ba Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Sun, 6 Nov 2005 12:52:19 +0000 Subject: [PATCH] Loading a blank Song if a mp3/ogg file is present and no SM/KSF/DWI is present --- stepmania/src/Song.cpp | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/stepmania/src/Song.cpp b/stepmania/src/Song.cpp index e2b4614ab3..f4afc999ec 100644 --- a/stepmania/src/Song.cpp +++ b/stepmania/src/Song.cpp @@ -249,25 +249,40 @@ bool Song::LoadFromSongDir( CString sDir ) // NotesLoader *ld = MakeLoader( sDir ); - if(!ld) + if( ld ) { - LOG->Warn( "Couldn't find any SM, DWI, BMS, or KSF files in '%s'. This is not a valid song directory.", sDir.c_str() ); - return false; - } + bool success = ld->LoadFromDir( sDir, *this ); + BlacklistedImages = ld->GetBlacklistedImages(); - bool success = ld->LoadFromDir( sDir, *this ); - BlacklistedImages = ld->GetBlacklistedImages(); + if(!success) + { + delete ld; + return false; + } + + TidyUpData(); + ld->TidyUpData( *this, false ); - if(!success) - { delete ld; - return false; } + else + { + LOG->Warn( "Couldn't find any SM, DWI, BMS, or KSF files in '%s'.", sDir.c_str() ); - TidyUpData(); - ld->TidyUpData( *this, false ); + vector vs; + GetDirListing( sDir + "*.mp3", vs, false, false ); + GetDirListing( sDir + "*.ogg", vs, false, false ); + bool bHasMusic = !vs.empty(); - delete ld; + if( !bHasMusic ) + { + LOG->Warn( "No music file in this directory either. Ignoring this song directory." ); + return false; + } + + // Continue on with a blank Song so that people can make adjustments using the editor. + TidyUpData(); + } // save a cache file so we don't have to parse it all over again next time SaveToCacheFile();