add SONGMAN->FindSong

This commit is contained in:
Glenn Maynard
2003-07-09 04:09:35 +00:00
parent a43296fef9
commit 361a2b58a9
5 changed files with 39 additions and 23 deletions
+3 -23
View File
@@ -79,29 +79,9 @@ void Course::SetDefaultScore()
Song *Course::FindSong(CString sGroup, CString sSong) const
{
const vector<Song*> &apSongs = SONGMAN->GetAllSongs();
// foreach song
for( unsigned i = 0; i < apSongs.size(); i++ )
{
Song* pSong = apSongs[i];
if( sGroup.size() && sGroup.CompareNoCase(pSong->m_sGroupName) != 0)
continue; /* wrong group */
CString sDir = pSong->GetSongDir();
sDir.Replace("\\","/");
CStringArray bits;
split( sDir, "/", bits );
ASSERT(bits.size() >= 2); /* should always have at least two parts */
CString sLastBit = bits[bits.size()-1];
// match on song dir or title (ala DWI)
if( sSong.CompareNoCase(sLastBit)==0 )
return pSong;
if( sSong.CompareNoCase(pSong->GetFullTranslitTitle())==0 )
return pSong;
}
Song *pSong = SONGMAN->FindSong( sGroup, sSong );
if( pSong )
return pSong;
LOG->Trace( "Course file '%s' contains a song '%s%s%s' that is not present",
m_sPath.c_str(), sGroup.c_str(), sGroup.size()? "/":"", sSong.c_str());
+22
View File
@@ -1570,3 +1570,25 @@ int Song::GetNumNotesWithGrade( Grade g ) const
iCount++;
return iCount;
}
bool Song::Matches(CString sGroup, CString sSong) const
{
if( sGroup.size() && sGroup.CompareNoCase(this->m_sGroupName) != 0)
return false;
CString sDir = this->GetSongDir();
sDir.Replace("\\","/");
CStringArray bits;
split( sDir, "/", bits );
ASSERT(bits.size() >= 2); /* should always have at least two parts */
CString sLastBit = bits[bits.size()-1];
// match on song dir or title (ala DWI)
if( !sSong.CompareNoCase(sLastBit) )
return true;
if( !sSong.CompareNoCase(this->GetFullTranslitTitle()) )
return true;
return false;
}
+11
View File
@@ -1067,4 +1067,15 @@ void SongManager::AddScores( NotesType nt, bool bPlayerEnabled[NUM_PLAYERS],
}
}
Song *SongManager::FindSong( CString sGroup, CString sSong )
{
// foreach song
for( unsigned i = 0; i < m_pSongs.size(); i++ )
{
if( m_pSongs[i]->Matches(sGroup, sSong) )
return m_pSongs[i];
}
return NULL;
}
+1
View File
@@ -60,6 +60,7 @@ public:
void GetSongs( vector<Song*> &AddTo, CString sGroupName, int iMaxStages = 100000 /*inf*/ ) const;
void GetSongs( vector<Song*> &AddTo, int iMaxStages ) const { GetSongs(AddTo,"",iMaxStages); }
void GetSongs( vector<Song*> &AddTo ) const { GetSongs(AddTo,"",100000 /*inf*/ ); }
Song *FindSong( CString sGroup, CString sSong );
int GetNumSongs() const;
int GetNumGroups() const;
int GetNumCourses() const;
+2
View File
@@ -170,6 +170,8 @@ public:
bool HasLyrics() const;
bool m_bIsLocked;
bool Matches(CString sGroup, CString sSong) const;
vector<BPMSegment> m_BPMSegments; // this must be sorted before gameplay
vector<StopSegment> m_StopSegments; // this must be sorted before gameplay
vector<BackgroundChange> m_BackgroundChanges; // this must be sorted before gameplay