use SongCriteria and StepsCriteria to resolve songs for Trail

This commit is contained in:
Chris Danford
2006-07-02 06:04:53 +00:00
parent c2e8e70cf7
commit 97d28100ae
5 changed files with 176 additions and 131 deletions
+64 -3
View File
@@ -15,12 +15,62 @@
#include "LocalizedString.h"
#include "RageLog.h"
bool SongCriteria::Matches( const Song *p ) const
bool SongCriteria::Matches( const Song *pSong ) const
{
if( !m_sGroupName.empty() && m_sGroupName != p->m_sGroupName )
if( !m_sGroupName.empty() && m_sGroupName != pSong->m_sGroupName )
return false;
if( !m_sGenre.empty() && m_sGenre != p->m_sGenre )
if( !m_sGenre.empty() && m_sGenre != pSong->m_sGenre )
return false;
switch( m_Selectable )
{
DEFAULT_FAIL(m_Selectable);
case Selectable_Yes:
if( pSong->m_SelectionDisplay != Song::SHOW_ALWAYS )
return false;
break;
case Selectable_No:
if( pSong->m_SelectionDisplay != Song::SHOW_NEVER )
return false;
break;
case Selectable_DontCare:
break;
}
if( m_bUseSongAllowedList )
{
if( find(m_vpSongAllowedList.begin(),m_vpSongAllowedList.end(),pSong) == m_vpSongAllowedList.end() )
return false;
}
if( m_iStagesForSong != -1 && SONGMAN->GetNumStagesForSong(pSong) != m_iStagesForSong )
return false;
switch( m_Tutorial )
{
DEFAULT_FAIL(m_Tutorial);
case Tutorial_Yes:
if( !pSong->IsTutorial() )
return false;
break;
case Tutorial_No:
if( pSong->IsTutorial() )
return false;
break;
case Tutorial_DontCare:
break;
}
switch( m_Locked )
{
DEFAULT_FAIL(m_Locked);
case Locked_Locked:
if( UNLOCKMAN && !UNLOCKMAN->SongIsLocked(pSong) )
return false;
break;
case Locked_Unlocked:
if( UNLOCKMAN && UNLOCKMAN->SongIsLocked(pSong) )
return false;
break;
case Locked_DontCare:
break;
}
return true;
}
@@ -736,6 +786,17 @@ void SongUtil::GetAllSongGenres( vector<RString> &vsOut )
}
}
void SongUtil::FilterSongs( const SongCriteria &sc, const vector<Song*> &in, vector<Song*> &out )
{
FOREACH_CONST( Song*, in, s )
{
if( sc.Matches( *s ) )
{
out.push_back( *s );
}
}
}
//////////////////////////////////
// SongID