diff --git a/stepmania/src/NotesLoaderKSF.cpp b/stepmania/src/NotesLoaderKSF.cpp index 198eb0e354..f1bbdbc16c 100644 --- a/stepmania/src/NotesLoaderKSF.cpp +++ b/stepmania/src/NotesLoaderKSF.cpp @@ -156,35 +156,8 @@ void KSFLoader::GetApplicableFiles( CString sPath, CStringArray &out ) GetDirListing( sPath + CString("*.ksf"), out ); } -bool KSFLoader::LoadFromDir( CString sDir, Song &out ) +bool KSFLoader::LoadGlobalData( const CString &sPath, Song &out ) { - LOG->Trace( "Song::LoadFromKSFDir(%s)", sDir.c_str() ); - - CStringArray arrayKSFFileNames; - GetDirListing( sDir + CString("*.ksf"), arrayKSFFileNames ); - - /* We shouldn't have been called to begin with if there were no KSFs. */ - if( arrayKSFFileNames.empty() ) - RageException::Throw( "Couldn't find any KSF files in '%s'", sDir.c_str() ); - - // load the Notes from the rest of the KSF files - unsigned i; - for( i=0; i 0); - - CString sSongFolderName = asBits.back(); - - asBits.clear(); - split( sSongFolderName, " - ", asBits, false ); - if( asBits.size() == 2 ) - { - out.m_sArtist = asBits[0]; - out.m_sMainTitle = asBits[1]; - } - else - { - out.m_sMainTitle = asBits[0]; - } - break; - } } else if( 0==stricmp(sValueName,"BPM") ) @@ -280,6 +227,32 @@ bool KSFLoader::LoadFromDir( CString sDir, Song &out ) out.AddBPMSegment( BPMSegment(beat, BPM2) ); } + + /* XXX: Once we use iconv, this can be more intelligent. */ + if(out.m_sMainTitle == "" || !utf8_is_valid(out.m_sMainTitle)) + { + CString SongDir = sPath; + SongDir.Replace("\\", "/"); + + CStringArray asBits; + split( SongDir, "/", asBits, true); + ASSERT(asBits.size() > 1); + + CString sSongFolderName = asBits[asBits.size()-2]; + + asBits.clear(); + split( sSongFolderName, " - ", asBits, false ); + if( asBits.size() == 2 ) + { + out.m_sArtist = asBits[0]; + out.m_sMainTitle = asBits[1]; + } + else + { + out.m_sMainTitle = asBits[0]; + } + } + // search for music with song in the file name CStringArray arrayPossibleMusic; GetDirListing( out.GetSongDir() + CString("song.mp3"), arrayPossibleMusic ); @@ -292,4 +265,35 @@ bool KSFLoader::LoadFromDir( CString sDir, Song &out ) return true; } +bool KSFLoader::LoadFromDir( CString sDir, Song &out ) +{ + LOG->Trace( "Song::LoadFromKSFDir(%s)", sDir.c_str() ); + + CStringArray arrayKSFFileNames; + GetDirListing( sDir + CString("*.ksf"), arrayKSFFileNames ); + + /* We shouldn't have been called to begin with if there were no KSFs. */ + if( arrayKSFFileNames.empty() ) + RageException::Throw( "Couldn't find any KSF files in '%s'", sDir.c_str() ); + + // load the Notes from the rest of the KSF files + unsigned i; + for( i=0; i