add SONGMAN->FindSong
This commit is contained in:
@@ -79,29 +79,9 @@ void Course::SetDefaultScore()
|
|||||||
|
|
||||||
Song *Course::FindSong(CString sGroup, CString sSong) const
|
Song *Course::FindSong(CString sGroup, CString sSong) const
|
||||||
{
|
{
|
||||||
const vector<Song*> &apSongs = SONGMAN->GetAllSongs();
|
Song *pSong = SONGMAN->FindSong( sGroup, sSong );
|
||||||
|
if( pSong )
|
||||||
// foreach song
|
return pSong;
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
LOG->Trace( "Course file '%s' contains a song '%s%s%s' that is not present",
|
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());
|
m_sPath.c_str(), sGroup.c_str(), sGroup.size()? "/":"", sSong.c_str());
|
||||||
|
|||||||
@@ -1570,3 +1570,25 @@ int Song::GetNumNotesWithGrade( Grade g ) const
|
|||||||
iCount++;
|
iCount++;
|
||||||
return 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ public:
|
|||||||
void GetSongs( vector<Song*> &AddTo, CString sGroupName, int iMaxStages = 100000 /*inf*/ ) const;
|
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, int iMaxStages ) const { GetSongs(AddTo,"",iMaxStages); }
|
||||||
void GetSongs( vector<Song*> &AddTo ) const { GetSongs(AddTo,"",100000 /*inf*/ ); }
|
void GetSongs( vector<Song*> &AddTo ) const { GetSongs(AddTo,"",100000 /*inf*/ ); }
|
||||||
|
Song *FindSong( CString sGroup, CString sSong );
|
||||||
int GetNumSongs() const;
|
int GetNumSongs() const;
|
||||||
int GetNumGroups() const;
|
int GetNumGroups() const;
|
||||||
int GetNumCourses() const;
|
int GetNumCourses() const;
|
||||||
|
|||||||
@@ -170,6 +170,8 @@ public:
|
|||||||
bool HasLyrics() const;
|
bool HasLyrics() const;
|
||||||
bool m_bIsLocked;
|
bool m_bIsLocked;
|
||||||
|
|
||||||
|
bool Matches(CString sGroup, CString sSong) const;
|
||||||
|
|
||||||
vector<BPMSegment> m_BPMSegments; // this must be sorted before gameplay
|
vector<BPMSegment> m_BPMSegments; // this must be sorted before gameplay
|
||||||
vector<StopSegment> m_StopSegments; // 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
|
vector<BackgroundChange> m_BackgroundChanges; // this must be sorted before gameplay
|
||||||
|
|||||||
Reference in New Issue
Block a user