diff --git a/stepmania/src/SongManager.cpp b/stepmania/src/SongManager.cpp index 70e772525d..1ac32f0c68 100644 --- a/stepmania/src/SongManager.cpp +++ b/stepmania/src/SongManager.cpp @@ -81,6 +81,33 @@ void SongManager::SanityCheckGroupDir( CString sDir ) const } +void SongManager::AddGroup( CString sDir, CString sGroupDirName ) +{ + int j; + for(j = 0; j < m_arrayGroupNames.GetSize(); ++j) + if( sGroupDirName == m_arrayGroupNames[j] ) break; + + if( j != m_arrayGroupNames.GetSize() ) + return; /* the group is already added */ + + // Look for a group banner in this group folder + CStringArray arrayGroupBanners; + GetDirListing( ssprintf("%s\\%s\\*.png", sDir, sGroupDirName), arrayGroupBanners ); + GetDirListing( ssprintf("%s\\%s\\*.jpg", sDir, sGroupDirName), arrayGroupBanners ); + GetDirListing( ssprintf("%s\\%s\\*.gif", sDir, sGroupDirName), arrayGroupBanners ); + GetDirListing( ssprintf("%s\\%s\\*.bmp", sDir, sGroupDirName), arrayGroupBanners ); + CString sBannerPath; + + if( arrayGroupBanners.GetSize() > 0 ) + { + sBannerPath = ssprintf("%s\\%s\\%s", sDir, sGroupDirName, arrayGroupBanners[0] ); + LOG->Trace( ssprintf("Group banner for '%s' is '%s'.", sGroupDirName, sBannerPath) ); + } + + m_arrayGroupNames.Add( sGroupDirName ); + m_GroupBannerPaths.Add(sBannerPath); +} + void SongManager::LoadStepManiaSongDir( CString sDir, void(*callback)() ) { // trim off the trailing slash if any @@ -100,20 +127,6 @@ void SongManager::LoadStepManiaSongDir( CString sDir, void(*callback)() ) SanityCheckGroupDir(sDir+"\\"+sGroupDirName); - // Look for a group banner in this group folder - CStringArray arrayGroupBanners; - GetDirListing( ssprintf("%s\\%s\\*.png", sDir, sGroupDirName), arrayGroupBanners ); - GetDirListing( ssprintf("%s\\%s\\*.jpg", sDir, sGroupDirName), arrayGroupBanners ); - GetDirListing( ssprintf("%s\\%s\\*.gif", sDir, sGroupDirName), arrayGroupBanners ); - GetDirListing( ssprintf("%s\\%s\\*.bmp", sDir, sGroupDirName), arrayGroupBanners ); - CString sBannerPath; - - if( arrayGroupBanners.GetSize() > 0 ) - { - sBannerPath = ssprintf("%s\\%s\\%s", sDir, sGroupDirName, arrayGroupBanners[0] ); - LOG->Trace( ssprintf("Group banner for '%s' is '%s'.", sGroupDirName, sBannerPath) ); - } - // Find all Song folders in this group directory CStringArray arraySongDirs; GetDirListing( ssprintf("%s\\%s\\*.*", sDir, sGroupDirName), arraySongDirs, true ); @@ -143,14 +156,7 @@ void SongManager::LoadStepManiaSongDir( CString sDir, void(*callback)() ) if(!loaded) continue; /* Add this group to the group array. */ - for(j = 0; j < m_arrayGroupNames.GetSize(); ++j) - if( sGroupDirName == m_arrayGroupNames[j] ) break; - - if( j == m_arrayGroupNames.GetSize() ) - { - m_arrayGroupNames.Add( sGroupDirName ); - m_GroupBannerPaths.Add(sBannerPath); - } + AddGroup(sDir, sGroupDirName); } GAMESTATE->m_sLoadingMessage = "Done loading songs."; diff --git a/stepmania/src/SongManager.h b/stepmania/src/SongManager.h index e8a8734030..b03d3dee4d 100644 --- a/stepmania/src/SongManager.h +++ b/stepmania/src/SongManager.h @@ -69,6 +69,7 @@ protected: bool GetExtraStageInfoFromCourse( bool bExtra2, CString sPreferredGroup, Song*& pSongOut, Notes*& pNotesOut, PlayerOptions& po_out, SongOptions& so_out ); void SanityCheckGroupDir( CString sDir ) const; + void AddGroup( CString sDir, CString sGroupDirName ); CStringArray m_arrayGroupNames; CStringArray m_GroupBannerPaths; // each song group has a banner associated with it