diff --git a/stepmania/src/Course.cpp b/stepmania/src/Course.cpp index 762ef1a0e7..f3e3e5b0dd 100644 --- a/stepmania/src/Course.cpp +++ b/stepmania/src/Course.cpp @@ -433,7 +433,7 @@ void Course::AutogenNonstopFromGroup( CString sGroupName, Difficulty diff ) m_entries.pop_back(); } -void Course::AutogenOniFromArtist( CString sArtistName, vector aSongs, Difficulty dc ) +void Course::AutogenOniFromArtist( CString sArtistName, CString sArtistNameTranslit, vector aSongs, Difficulty dc ) { m_bIsAutogen = true; m_bRepeat = false; @@ -449,6 +449,9 @@ void Course::AutogenOniFromArtist( CString sArtistName, vector 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 diff --git a/stepmania/src/Course.h b/stepmania/src/Course.h index 16c38e0a99..bbd542b277 100644 --- a/stepmania/src/Course.h +++ b/stepmania/src/Course.h @@ -127,7 +127,7 @@ public: void Save(); void AutogenEndlessFromGroup( CString sGroupName, Difficulty dc ); void AutogenNonstopFromGroup( CString sGroupName, Difficulty dc ); - void AutogenOniFromArtist( CString sArtistName, vector aSongs, Difficulty dc ); + void AutogenOniFromArtist( CString sArtistName, CString sArtistNameTranslit, vector aSongs, Difficulty dc ); // sorting values int m_SortOrder_TotalDifficulty; diff --git a/stepmania/src/SongManager.cpp b/stepmania/src/SongManager.cpp index 109220b8ae..ecc3faf92e 100644 --- a/stepmania/src/SongManager.cpp +++ b/stepmania/src/SongManager.cpp @@ -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 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 apSongs = this->GetAllSongs(); - SongUtil::SortSongPointerArrayByArtist( apSongs ); + SongUtil::SortSongPointerArrayByDisplayArtist( apSongs ); CString sCurArtist = ""; + CString sCurArtistTranslit = ""; int iCurArtistCount = 0; + vector 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] ); } diff --git a/stepmania/src/SongUtil.cpp b/stepmania/src/SongUtil.cpp index 078f42e919..7211fd3c93 100644 --- a/stepmania/src/SongUtil.cpp +++ b/stepmania/src/SongUtil.cpp @@ -185,6 +185,15 @@ void SongUtil::SortSongPointerArrayByArtist( vector &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 &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; diff --git a/stepmania/src/SongUtil.h b/stepmania/src/SongUtil.h index 5a2b8f295b..97805efa60 100644 --- a/stepmania/src/SongUtil.h +++ b/stepmania/src/SongUtil.h @@ -25,6 +25,7 @@ namespace SongUtil void SortSongPointerArrayByBPM( vector &arraySongPointers ); void SortSongPointerArrayByGrade( vector &arraySongPointers ); void SortSongPointerArrayByArtist( vector &arraySongPointers ); + void SortSongPointerArrayByDisplayArtist( vector &arraySongPointers ); void SortSongPointerArrayByGroupAndDifficulty( vector &arraySongPointers ); void SortSongPointerArrayByGroupAndTitle( vector &arraySongPointers ); void SortSongPointerArrayByNumPlays( vector &arraySongPointers, ProfileSlot slot, bool bDescending );