artist course fixes
support translit fallbacks with artist courses
This commit is contained in:
@@ -433,7 +433,7 @@ void Course::AutogenNonstopFromGroup( CString sGroupName, Difficulty diff )
|
||||
m_entries.pop_back();
|
||||
}
|
||||
|
||||
void Course::AutogenOniFromArtist( CString sArtistName, vector<Song*> aSongs, Difficulty dc )
|
||||
void Course::AutogenOniFromArtist( CString sArtistName, CString sArtistNameTranslit, vector<Song*> aSongs, Difficulty dc )
|
||||
{
|
||||
m_bIsAutogen = true;
|
||||
m_bRepeat = false;
|
||||
@@ -449,6 +449,9 @@ void Course::AutogenOniFromArtist( CString sArtistName, vector<Song*> aSongs, Di
|
||||
/* "Artist Oni" is a little repetitive; "by Artist" stands out less, and lowercasing
|
||||
* "by" puts more emphasis on the artist's name. It also sorts them together. */
|
||||
m_sName = "by " + sArtistName;
|
||||
if( sArtistNameTranslit != sArtistName )
|
||||
m_sNameTranslit = "by " + sArtistNameTranslit;
|
||||
|
||||
|
||||
// m_sBannerPath = ""; // XXX
|
||||
|
||||
|
||||
@@ -127,7 +127,7 @@ public:
|
||||
void Save();
|
||||
void AutogenEndlessFromGroup( CString sGroupName, Difficulty dc );
|
||||
void AutogenNonstopFromGroup( CString sGroupName, Difficulty dc );
|
||||
void AutogenOniFromArtist( CString sArtistName, vector<Song*> aSongs, Difficulty dc );
|
||||
void AutogenOniFromArtist( CString sArtistName, CString sArtistNameTranslit, vector<Song*> aSongs, Difficulty dc );
|
||||
|
||||
// sorting values
|
||||
int m_SortOrder_TotalDifficulty;
|
||||
|
||||
@@ -592,17 +592,25 @@ void SongManager::InitAutogenCourses()
|
||||
|
||||
/* Generate Oni courses from artists. Only create courses if we have at least
|
||||
* four songs from an artist; create 3- and 4-song courses. */
|
||||
vector<Song *> aSongs;
|
||||
{
|
||||
/* We normally sort by translit artist. However, display artist is more
|
||||
* consistent. For example, transliterated Japanese names are alternately
|
||||
* spelled given- and family-name first, but display titles are more consistent. */
|
||||
vector<Song*> apSongs = this->GetAllSongs();
|
||||
SongUtil::SortSongPointerArrayByArtist( apSongs );
|
||||
SongUtil::SortSongPointerArrayByDisplayArtist( apSongs );
|
||||
|
||||
CString sCurArtist = "";
|
||||
CString sCurArtistTranslit = "";
|
||||
int iCurArtistCount = 0;
|
||||
|
||||
vector<Song *> aSongs;
|
||||
unsigned i = 0;
|
||||
do {
|
||||
CString sArtist = i >= apSongs.size()? "": apSongs[i]->GetTranslitArtist();
|
||||
CString sArtist = i >= apSongs.size()? "": apSongs[i]->GetDisplayArtist();
|
||||
CString sTranslitArtist = i >= apSongs.size()? "": apSongs[i]->GetTranslitArtist();
|
||||
LOG->Trace("foo '%s' '%s'",
|
||||
sArtist.c_str(),
|
||||
sTranslitArtist.c_str() );
|
||||
if( i < apSongs.size() && !sCurArtist.CompareNoCase(sArtist) )
|
||||
{
|
||||
aSongs.push_back( apSongs[i] );
|
||||
@@ -612,11 +620,11 @@ void SongManager::InitAutogenCourses()
|
||||
|
||||
/* Different artist, or we're at the end. If we have enough entries for
|
||||
* the last artist, add it. Skip blanks and "Unknown artist". */
|
||||
if( iCurArtistCount >= 3 && sCurArtist != "" &&
|
||||
sCurArtist.CompareNoCase("Unknown artist") )
|
||||
if( iCurArtistCount >= 3 && sCurArtistTranslit != "" &&
|
||||
sCurArtistTranslit.CompareNoCase("Unknown artist") )
|
||||
{
|
||||
pCourse = new Course;
|
||||
pCourse->AutogenOniFromArtist( sCurArtist, aSongs, DIFFICULTY_HARD );
|
||||
pCourse->AutogenOniFromArtist( sCurArtist, sCurArtistTranslit, aSongs, DIFFICULTY_HARD );
|
||||
m_pCourses.push_back( pCourse );
|
||||
}
|
||||
|
||||
@@ -625,6 +633,7 @@ void SongManager::InitAutogenCourses()
|
||||
if( i < apSongs.size() )
|
||||
{
|
||||
sCurArtist = sArtist;
|
||||
sCurArtistTranslit = sTranslitArtist;
|
||||
iCurArtistCount = 1;
|
||||
aSongs.push_back( apSongs[i] );
|
||||
}
|
||||
|
||||
@@ -185,6 +185,15 @@ void SongUtil::SortSongPointerArrayByArtist( vector<Song*> &arraySongPointers )
|
||||
stable_sort( arraySongPointers.begin(), arraySongPointers.end(), CompareSongPointersBySortValueAscending );
|
||||
}
|
||||
|
||||
/* This is for internal use, not display; sorting by Unicode codepoints isn't very
|
||||
* interesting for display. */
|
||||
void SongUtil::SortSongPointerArrayByDisplayArtist( vector<Song*> &arraySongPointers )
|
||||
{
|
||||
for( unsigned i = 0; i < arraySongPointers.size(); ++i )
|
||||
song_sort_val[arraySongPointers[i]] = MakeSortString( arraySongPointers[i]->GetDisplayArtist() );
|
||||
stable_sort( arraySongPointers.begin(), arraySongPointers.end(), CompareSongPointersBySortValueAscending );
|
||||
}
|
||||
|
||||
static int CompareSongPointersByGroup(const Song *pSong1, const Song *pSong2)
|
||||
{
|
||||
return pSong1->m_sGroupName < pSong2->m_sGroupName;
|
||||
|
||||
@@ -25,6 +25,7 @@ namespace SongUtil
|
||||
void SortSongPointerArrayByBPM( vector<Song*> &arraySongPointers );
|
||||
void SortSongPointerArrayByGrade( vector<Song*> &arraySongPointers );
|
||||
void SortSongPointerArrayByArtist( vector<Song*> &arraySongPointers );
|
||||
void SortSongPointerArrayByDisplayArtist( vector<Song*> &arraySongPointers );
|
||||
void SortSongPointerArrayByGroupAndDifficulty( vector<Song*> &arraySongPointers );
|
||||
void SortSongPointerArrayByGroupAndTitle( vector<Song*> &arraySongPointers );
|
||||
void SortSongPointerArrayByNumPlays( vector<Song*> &arraySongPointers, ProfileSlot slot, bool bDescending );
|
||||
|
||||
Reference in New Issue
Block a user