save disabled songs

This commit is contained in:
Glenn Maynard
2007-08-15 20:27:11 +00:00
parent c3400fce68
commit 6f68b3fbaa
2 changed files with 38 additions and 0 deletions
+36
View File
@@ -52,6 +52,8 @@ static const ThemeMetric<RageColor> UNLOCK_COLOR ( "SongManager", "UnlockColor
static const ThemeMetric<bool> MOVE_UNLOCKS_TO_BOTTOM_OF_PREFERRED_SORT ( "SongManager", "MoveUnlocksToBottomOfPreferredSort" );
static const ThemeMetric<int> EXTRA_STAGE2_DIFFICULTY_MAX ( "SongManager", "ExtraStage2DifficultyMax" );
static Preference<RString> g_sDisabledSongs( "DisabledSongs", "" );
RString SONG_GROUP_COLOR_NAME( size_t i ) { return ssprintf( "SongGroupColor%i", (int) i+1 ); }
RString COURSE_GROUP_COLOR_NAME( size_t i ) { return ssprintf( "CourseGroupColor%i", (int) i+1 ); }
@@ -259,6 +261,8 @@ void SongManager::LoadStepManiaSongDir( RString sDir, LoadingWindow *ld )
/* Load the group sym links (if any)*/
LoadGroupSymLinks(sDir, sGroupDirName);
}
SetEnabledSongs();
}
// Instead of "symlinks", songs should have membership in multiple groups.
@@ -902,6 +906,38 @@ void SongManager::SetPreferences()
}
}
void SongManager::EnableSong( Song *pSong, bool bEnable )
{
vector<RString> asDisabledSongs;
split( g_sDisabledSongs, ";", asDisabledSongs, true );
vector<RString>::iterator it = find( asDisabledSongs.begin(), asDisabledSongs.end(), pSong->GetSongDir() );
if( bEnable && it == asDisabledSongs.end() )
asDisabledSongs.push_back( pSong->GetSongDir() );
else if( !bEnable && it != asDisabledSongs.end() )
asDisabledSongs.erase( it );
g_sDisabledSongs.Set( join(";", asDisabledSongs) );
pSong->SetEnabled( bEnable );
}
void SongManager::SetEnabledSongs()
{
FOREACH( Song *, m_pSongs, s )
(*s)->SetEnabled( true );
vector<RString> asDisabledSongs;
split( g_sDisabledSongs, ";", asDisabledSongs, true );
FOREACH_CONST( RString, asDisabledSongs, s )
{
Song *pSong = this->FindSong( *s );
if( pSong )
pSong->SetEnabled( false );
}
}
void SongManager::GetStepsLoadedFromProfile( vector<Steps*> &AddTo, ProfileSlot slot ) const
{
const vector<Song*> &vSongs = GetSongs();
+2
View File
@@ -38,6 +38,8 @@ public:
void RegenerateNonFixedCourses();
void SetPreferences();
void EnableSong( Song *pSong, bool bEnable );
void SetEnabledSongs();
void LoadStepEditsFromProfileDir( const RString &sProfileDir, ProfileSlot slot );
void LoadCourseEditsFromProfileDir( const RString &sProfileDir, ProfileSlot slot );