diff --git a/stepmania/src/SongManager.cpp b/stepmania/src/SongManager.cpp index 2a4460424b..bcd32706b0 100644 --- a/stepmania/src/SongManager.cpp +++ b/stepmania/src/SongManager.cpp @@ -113,12 +113,26 @@ void SongManager::LoadStepManiaSongDir( CString sDir, void(*callback)() ) 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 ) { - m_mapGroupToBannerPath[sGroupDirName] = ssprintf("%s\\%s\\%s", sDir, sGroupDirName, arrayGroupBanners[0] ); - LOG->Trace( ssprintf("Group banner for '%s' is '%s'.", sGroupDirName, m_mapGroupToBannerPath[sGroupDirName]) ); + sBannerPath = ssprintf("%s\\%s\\%s", sDir, sGroupDirName, arrayGroupBanners[0] ); + LOG->Trace( ssprintf("Group banner for '%s' is '%s'.", sGroupDirName, sBannerPath) ); } + /* Add this group to the group array. */ + int j; + 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); + } + + // Find all Song folders in this group directory CStringArray arraySongDirs; GetDirListing( ssprintf("%s\\%s\\*.*", sDir, sGroupDirName), arraySongDirs, true ); @@ -206,7 +220,7 @@ void SongManager::FreeSongArray() SAFE_DELETE( m_pSongs[i] ); m_pSongs.RemoveAll(); - m_mapGroupToBannerPath.RemoveAll(); + m_GroupBannerPaths.RemoveAll(); } @@ -334,12 +348,14 @@ void SongManager::SaveStatisticsToDisk() CString SongManager::GetGroupBannerPath( CString sGroupName ) { - CString sPath; + int i; + for(i = 0; i < m_arrayGroupNames.GetSize(); ++i) + if( sGroupName == m_arrayGroupNames[i] ) break; - if( m_mapGroupToBannerPath.Lookup( sGroupName, sPath ) ) - return sPath; - else + if( i == m_arrayGroupNames.GetSize() ) return ""; + + return m_GroupBannerPaths[i]; } void SongManager::GetGroupNames( CStringArray &AddTo ) diff --git a/stepmania/src/SongManager.h b/stepmania/src/SongManager.h index bb4dd77600..4dd2ee0bcd 100644 --- a/stepmania/src/SongManager.h +++ b/stepmania/src/SongManager.h @@ -69,8 +69,8 @@ protected: bool GetExtraStageInfoFromCourse( bool bExtra2, CString sPreferredGroup, Song*& pSongOut, Notes*& pNotesOut, PlayerOptions& po_out, SongOptions& so_out ); - CMapStringToString m_mapGroupToBannerPath; // each song group has a banner associated with it CStringArray m_arrayGroupNames; + CStringArray m_GroupBannerPaths; // each song group has a banner associated with it };