Add ability to delete songs from disk at the song selection screen (Ctrl+Backspace)

This commit is contained in:
Colin Wallace
2015-03-27 05:22:55 +00:00
parent bfc24455ae
commit 473974e52f
16 changed files with 130 additions and 8 deletions
+25 -3
View File
@@ -423,16 +423,38 @@ void SongManager::FreeSongs()
for( unsigned i=0; i<m_pSongs.size(); i++ )
SAFE_DELETE( m_pSongs[i] );
m_pSongs.clear();
m_mapSongGroupIndex.clear();
// wait why is it cleared twice? -aj
// also free the songs that have been deleted from disk
for ( unsigned i=0; i<m_pDeletedSongs.size(); ++i )
SAFE_DELETE( m_pDeletedSongs[i] );
m_pDeletedSongs.clear();
m_mapSongGroupIndex.clear();
m_sSongGroupBannerPaths.clear();
//m_sSongGroupBackgroundPaths.clear(); // when in Rome... -aj
m_pPopularSongs.clear();
m_pShuffledSongs.clear();
}
void SongManager::UnlistSong(Song *song)
{
// cannot immediately free song data, as it is needed temporarily for smooth audio transitions, etc.
// Instead, remove it from the m_pSongs list and store it in a special place where it can safely be deleted later.
m_pDeletedSongs.push_back(song);
// remove all occurences of the song in each of our song vectors
vector<Song*>* songVectors[3] = { &m_pSongs, &m_pPopularSongs, &m_pShuffledSongs };
for (int songVecIdx=0; songVecIdx<3; ++songVecIdx) {
vector<Song*>& v = *songVectors[songVecIdx];
for (int i=0; i<v.size(); ++i) {
if (v[i] == song) {
v.erase(v.begin()+i);
--i;
}
}
}
}
RString SongManager::GetSongGroupBannerPath( RString sSongGroup ) const
{
for( unsigned i = 0; i < m_sSongGroupNames.size(); ++i )