Rename title accessors in Song.

Add a preference to prefer transliterations. Press F9 in the music
select screen to toggle it ("what's that kanji again?"); appearance
options entry forthcoming.

Hopefully fix wheel sections; we were assuming that sections were
always sorted the same as the songs in them, but this isn't true
with "OTHER".
This commit is contained in:
Glenn Maynard
2003-02-11 23:52:18 +00:00
parent ee9f4d99a5
commit bcf4d2f604
13 changed files with 98 additions and 40 deletions
+1 -1
View File
@@ -56,7 +56,7 @@ void MusicList::AddSongsToGroup(const vector<Song*> &Songs)
continue; continue;
} }
CString sTitle = Songs[iIndex]->GetFullTitle(); CString sTitle = Songs[iIndex]->GetFullDisplayTitle();
// TODO: Move this crop threshold into a theme metric or make automatic based on column width // TODO: Move this crop threshold into a theme metric or make automatic based on column width
if( sTitle.GetLength() > 40 ) if( sTitle.GetLength() > 40 )
{ {
+19 -3
View File
@@ -269,6 +269,17 @@ void MusicWheel::GetSongList(vector<Song*> &arraySongs, bool bRoulette )
} }
} }
struct CompareSongPointerArrayBySectionName
{
SongSortOrder so;
CompareSongPointerArrayBySectionName( SongSortOrder so_ ): so(so_) { }
bool operator() (const Song *p1, const Song *p2) const
{
return MusicWheel::GetSectionNameFromSongAndSort( p1, so ) <
MusicWheel::GetSectionNameFromSongAndSort( p2, so );
}
};
void MusicWheel::BuildWheelItemDatas( vector<WheelItemData> &arrayWheelItemDatas, SongSortOrder so ) void MusicWheel::BuildWheelItemDatas( vector<WheelItemData> &arrayWheelItemDatas, SongSortOrder so )
{ {
unsigned i; unsigned i;
@@ -322,7 +333,6 @@ void MusicWheel::BuildWheelItemDatas( vector<WheelItemData> &arrayWheelItemDatas
bool bUseSections = false; bool bUseSections = false;
switch( so ) switch( so )
{ {
// case SORT_GROUP_NOHEADER: bUseSections = false; break;
case SORT_MOST_PLAYED: bUseSections = false; break; case SORT_MOST_PLAYED: bUseSections = false; break;
case SORT_BPM: bUseSections = false; break; case SORT_BPM: bUseSections = false; break;
case SORT_GROUP: bUseSections = GAMESTATE->m_sPreferredGroup == "ALL MUSIC"; break; case SORT_GROUP: bUseSections = GAMESTATE->m_sPreferredGroup == "ALL MUSIC"; break;
@@ -336,6 +346,11 @@ void MusicWheel::BuildWheelItemDatas( vector<WheelItemData> &arrayWheelItemDatas
if( bUseSections ) if( bUseSections )
{ {
/* We're using sections, so use the section name as the top-levle
* sort. */
stable_sort(arraySongs.begin(), arraySongs.end(),
CompareSongPointerArrayBySectionName(so));
// make WheelItemDatas with sections // make WheelItemDatas with sections
CString sLastSection = ""; CString sLastSection = "";
RageColor colorSection; RageColor colorSection;
@@ -347,6 +362,7 @@ void MusicWheel::BuildWheelItemDatas( vector<WheelItemData> &arrayWheelItemDatas
if( GAMESTATE->m_sPreferredGroup != "ALL MUSIC" && pSong->m_sGroupName != GAMESTATE->m_sPreferredGroup ) if( GAMESTATE->m_sPreferredGroup != "ALL MUSIC" && pSong->m_sGroupName != GAMESTATE->m_sPreferredGroup )
continue; continue;
if( sThisSection != sLastSection) // new section, make a section item if( sThisSection != sLastSection) // new section, make a section item
{ {
colorSection = (so==SORT_GROUP) ? SONGMAN->GetGroupColor(pSong->m_sGroupName) : SECTION_COLORS(iSectionColorIndex); colorSection = (so==SORT_GROUP) ? SONGMAN->GetGroupColor(pSong->m_sGroupName) : SECTION_COLORS(iSectionColorIndex);
@@ -1073,7 +1089,7 @@ void MusicWheel::TweenOffScreen(bool changing_sort)
m_fTimeLeftInState = TweenTime() + 0.100f; m_fTimeLeftInState = TweenTime() + 0.100f;
} }
CString MusicWheel::GetSectionNameFromSongAndSort( Song* pSong, SongSortOrder so ) CString MusicWheel::GetSectionNameFromSongAndSort( const Song* pSong, SongSortOrder so )
{ {
if( pSong == NULL ) if( pSong == NULL )
return ""; return "";
@@ -1093,7 +1109,7 @@ CString MusicWheel::GetSectionNameFromSongAndSort( Song* pSong, SongSortOrder so
// sTemp = "NUM"; // sTemp = "NUM";
// return sTemp; // return sTemp;
case SORT_TITLE: case SORT_TITLE:
sTemp = pSong->GetSortTitle(); sTemp = pSong->GetTranslitSubTitle();
sTemp.MakeUpper(); sTemp.MakeUpper();
if(sTemp.empty()) return ""; if(sTemp.empty()) return "";
+6 -2
View File
@@ -41,8 +41,12 @@ const ScreenMessage SM_SortOrderChanged = ScreenMessage(SM_User+48);
enum { SORT_ROULETTE = NUM_SORT_ORDERS+1 }; enum { SORT_ROULETTE = NUM_SORT_ORDERS+1 };
struct CompareSongPointerArrayBySectionName;
class MusicWheel : public ActorFrame class MusicWheel : public ActorFrame
{ {
friend struct CompareSongPointerArrayBySectionName;
public: public:
MusicWheel(); MusicWheel();
~MusicWheel(); ~MusicWheel();
@@ -76,11 +80,11 @@ public:
CString GetSelectedSection(){ return m_CurWheelItemData[m_iSelection]->m_sSectionName; }; CString GetSelectedSection(){ return m_CurWheelItemData[m_iSelection]->m_sSectionName; };
bool WheelIsLocked() { return (m_WheelState == STATE_LOCKED ? true : false); } bool WheelIsLocked() { return (m_WheelState == STATE_LOCKED ? true : false); }
void RebuildWheelItemDisplays();
protected: protected:
void GetSongList(vector<Song*> &arraySongs, bool bRoulette ); void GetSongList(vector<Song*> &arraySongs, bool bRoulette );
void BuildWheelItemDatas( vector<WheelItemData> &arrayWheelItems, SongSortOrder so ); void BuildWheelItemDatas( vector<WheelItemData> &arrayWheelItems, SongSortOrder so );
void RebuildWheelItemDisplays();
void SetOpenGroup(CString group, SongSortOrder so = NUM_SORT_ORDERS); void SetOpenGroup(CString group, SongSortOrder so = NUM_SORT_ORDERS);
bool SelectSong(const Song *p); bool SelectSong(const Song *p);
bool SelectCourse(const Course *p); bool SelectCourse(const Course *p);
@@ -128,7 +132,7 @@ protected:
RageSound m_soundStart; RageSound m_soundStart;
RageSound m_soundLocked; RageSound m_soundLocked;
CString GetSectionNameFromSongAndSort( Song* pSong, SongSortOrder so ); static CString GetSectionNameFromSongAndSort( const Song* pSong, SongSortOrder so );
bool WheelItemIsVisible(int n); bool WheelItemIsVisible(int n);
void UpdateScrollbar(); void UpdateScrollbar();
}; };
+3 -8
View File
@@ -219,14 +219,9 @@ bool NotesWriterDWI::Write( CString sPath, const Song &out )
if( fp == NULL ) if( fp == NULL )
RageException::Throw( "Error opening song file '%s' for writing.", sPath.GetString() ); RageException::Throw( "Error opening song file '%s' for writing.", sPath.GetString() );
/* If we have transliterations, write them instead of the real title, since /* Write transliterations, if we have them, since DWI doesn't support UTF-8. */
* DWI doesn't support UTF-8. */ fprintf( fp, "#TITLE:%s;\n", out.GetTranslitMainTitle().GetString() );
if(!out.GetSortTitle().empty()) fprintf( fp, "#ARTIST:%s;\n", out.GetTranslitArtist().GetString() );
fprintf( fp, "#TITLE:%s;\n", out.GetSortTitle().GetString() );
if(!out.m_sArtistTranslit.empty())
fprintf( fp, "#ARTIST:%s;\n", out.m_sArtistTranslit.GetString() );
else if(!out.m_sArtist.empty())
fprintf( fp, "#ARTIST:%s;\n", out.m_sArtist.GetString() );
ASSERT( out.m_BPMSegments[0].m_fStartBeat == 0 ); ASSERT( out.m_BPMSegments[0].m_fStartBeat == 0 );
fprintf( fp, "#BPM:%.3f;\n", out.m_BPMSegments[0].m_fBPM ); fprintf( fp, "#BPM:%.3f;\n", out.m_BPMSegments[0].m_fBPM );
fprintf( fp, "#GAP:%d;\n", int(-roundf( out.m_fBeat0OffsetInSeconds*1000 )) ); fprintf( fp, "#GAP:%d;\n", int(-roundf( out.m_fBeat0OffsetInSeconds*1000 )) );
+3
View File
@@ -68,6 +68,7 @@ PrefsManager::PrefsManager()
m_bInstructions = true; m_bInstructions = true;
m_bShowDontDie = true; m_bShowDontDie = true;
m_bShowSelectGroup = true; m_bShowSelectGroup = true;
m_bShowTranslations = true;
m_bArcadeOptionsNavigation = false; m_bArcadeOptionsNavigation = false;
m_iUnloadTextureDelaySeconds = 0; // disabled 60*30; // 30 mins m_iUnloadTextureDelaySeconds = 0; // disabled 60*30; // 30 mins
m_bCoinOpMode = false; m_bCoinOpMode = false;
@@ -144,6 +145,7 @@ void PrefsManager::ReadGlobalPrefsFromDisk( bool bSwitchToLastPlayedGame )
ini.GetValueB( "Options", "HowToPlay", m_bInstructions ); ini.GetValueB( "Options", "HowToPlay", m_bInstructions );
ini.GetValueB( "Options", "Caution", m_bShowDontDie ); ini.GetValueB( "Options", "Caution", m_bShowDontDie );
ini.GetValueB( "Options", "SelectGroup", m_bShowSelectGroup ); ini.GetValueB( "Options", "SelectGroup", m_bShowSelectGroup );
ini.GetValueB( "Options", "ShowTranslations", m_bShowTranslations );
ini.GetValueB( "Options", "ArcadeOptionsNavigation", m_bArcadeOptionsNavigation ); ini.GetValueB( "Options", "ArcadeOptionsNavigation", m_bArcadeOptionsNavigation );
ini.GetValue ( "Options", "DWIPath", m_DWIPath ); ini.GetValue ( "Options", "DWIPath", m_DWIPath );
ini.GetValueI( "Options", "UnloadTextureDelaySeconds", m_iUnloadTextureDelaySeconds ); ini.GetValueI( "Options", "UnloadTextureDelaySeconds", m_iUnloadTextureDelaySeconds );
@@ -216,6 +218,7 @@ void PrefsManager::SaveGlobalPrefsToDisk()
ini.SetValueB( "Options", "HowToPlay", m_bInstructions ); ini.SetValueB( "Options", "HowToPlay", m_bInstructions );
ini.SetValueB( "Options", "Caution", m_bShowDontDie ); ini.SetValueB( "Options", "Caution", m_bShowDontDie );
ini.SetValueB( "Options", "SelectGroup", m_bShowSelectGroup ); ini.SetValueB( "Options", "SelectGroup", m_bShowSelectGroup );
ini.SetValueB( "Options", "ShowTranslations", m_bShowTranslations );
ini.SetValueB( "Options", "ArcadeOptionsNavigation", m_bArcadeOptionsNavigation ); ini.SetValueB( "Options", "ArcadeOptionsNavigation", m_bArcadeOptionsNavigation );
ini.SetValue ( "Options", "DWIPath", m_DWIPath ); ini.SetValue ( "Options", "DWIPath", m_DWIPath );
ini.SetValueI( "Options", "UnloadTextureDelaySeconds", m_iUnloadTextureDelaySeconds ); ini.SetValueI( "Options", "UnloadTextureDelaySeconds", m_iUnloadTextureDelaySeconds );
+1
View File
@@ -52,6 +52,7 @@ public:
bool m_bAutoPlay; bool m_bAutoPlay;
bool m_bDelayedEscape; bool m_bDelayedEscape;
bool m_bInstructions, m_bShowDontDie, m_bShowSelectGroup; bool m_bInstructions, m_bShowDontDie, m_bShowSelectGroup;
bool m_bShowTranslations;
bool m_bArcadeOptionsNavigation; bool m_bArcadeOptionsNavigation;
bool m_bCoinOpMode; bool m_bCoinOpMode;
enum { NEVER, ALWAYS, ABC_ONLY } m_MusicWheelUsesSections; enum { NEVER, ALWAYS, ABC_ONLY } m_MusicWheelUsesSections;
+1 -1
View File
@@ -1129,7 +1129,7 @@ void ShowSavePrompt( ScreenMessage SM_SendWhenDone )
"Would you like to save these changes back\n" "Would you like to save these changes back\n"
"to the song file?\n" "to the song file?\n"
"Choosing NO will discard your changes.", "Choosing NO will discard your changes.",
GAMESTATE->m_pCurSong->GetFullTitle().GetString() ); GAMESTATE->m_pCurSong->GetFullDisplayTitle().GetString() );
break; break;
case PLAY_MODE_NONSTOP: case PLAY_MODE_NONSTOP:
case PLAY_MODE_ONI: case PLAY_MODE_ONI:
+1 -1
View File
@@ -159,7 +159,7 @@ ScreenMusicScroll::ScreenMusicScroll()
{ {
Song* pSong = arraySongs[i]; Song* pSong = arraySongs[i];
m_textLines[m_iNumLines].LoadFromFont( THEME->GetPathTo("Fonts","music scroll") ); m_textLines[m_iNumLines].LoadFromFont( THEME->GetPathTo("Fonts","music scroll") );
m_textLines[m_iNumLines].SetText( pSong->GetFullTitle() ); m_textLines[m_iNumLines].SetText( pSong->GetFullDisplayTitle() );
m_textLines[m_iNumLines].SetDiffuse( SONGMAN->GetSongColor(pSong) ); m_textLines[m_iNumLines].SetDiffuse( SONGMAN->GetSongColor(pSong) );
m_textLines[m_iNumLines].SetZoom( TEXT_ZOOM ); m_textLines[m_iNumLines].SetZoom( TEXT_ZOOM );
+8
View File
@@ -410,6 +410,14 @@ void ScreenSelectMusic::Input( const DeviceInput& DeviceI, InputEventType type,
{ {
LOG->Trace( "ScreenSelectMusic::Input()" ); LOG->Trace( "ScreenSelectMusic::Input()" );
if( DeviceI.device == DEVICE_KEYBOARD && DeviceI.button == SDLK_F9 )
{
if( type != IET_FIRST_PRESS ) return;
PREFSMAN->m_bShowTranslations ^= 1;
m_MusicWheel.RebuildWheelItemDisplays();
return;
}
if( MenuI.button == MENU_BUTTON_RIGHT || MenuI.button == MENU_BUTTON_LEFT ) if( MenuI.button == MENU_BUTTON_RIGHT || MenuI.button == MENU_BUTTON_LEFT )
{ {
if( !MenuI.IsValid() ) return; if( !MenuI.IsValid() ) return;
+33 -12
View File
@@ -857,8 +857,8 @@ bool Song::HasEdits( NotesType nt ) const
int CompareSongPointersByTitle(const Song *pSong1, const Song *pSong2) int CompareSongPointersByTitle(const Song *pSong1, const Song *pSong2)
{ {
//Prefer transliterations to full titles //Prefer transliterations to full titles
CString sTitle1 = pSong1->GetSortTitle(); CString sTitle1 = pSong1->GetFullTranslitTitle();
CString sTitle2 = pSong2->GetSortTitle(); CString sTitle2 = pSong2->GetFullTranslitTitle();
int ret = sTitle1.CompareNoCase(sTitle2); int ret = sTitle1.CompareNoCase(sTitle2);
if(ret < 0) return true; if(ret < 0) return true;
@@ -1078,19 +1078,40 @@ CString Song::GetBackgroundPath() const
return m_sSongDir+m_sBackgroundFile; return m_sSongDir+m_sBackgroundFile;
} }
CString Song::GetSortTitle() const CString Song::GetDisplayMainTitle() const
{ {
CString Title = m_sMainTitleTranslit.empty()? if(!PREFSMAN->m_bShowTranslations) return GetTranslitMainTitle();
m_sMainTitle: m_sMainTitleTranslit; return m_sMainTitle;
CString SubTitle = m_sSubTitleTranslit.empty()?
m_sSubTitle:m_sSubTitleTranslit;
if(!SubTitle.empty())
{
Title += " " + SubTitle;
} }
CString Song::GetDisplaySubTitle() const
{
if(!PREFSMAN->m_bShowTranslations) return GetTranslitSubTitle();
return m_sSubTitle;
}
CString Song::GetDisplayArtist() const
{
if(!PREFSMAN->m_bShowTranslations) return GetTranslitArtist();
return m_sArtist;
}
CString Song::GetFullDisplayTitle() const
{
CString Title = GetDisplayMainTitle();
CString SubTitle = GetDisplaySubTitle();
if(!SubTitle.empty()) Title += " " + SubTitle;
return Title;
}
CString Song::GetFullTranslitTitle() const
{
CString Title = GetTranslitMainTitle();
CString SubTitle = GetTranslitSubTitle();
if(!SubTitle.empty()) Title += " " + SubTitle;
return Title; return Title;
} }
+3 -3
View File
@@ -99,9 +99,9 @@ bool TextBanner::LoadFromSong( const Song* pSong )
return true; return true;
} }
m_textTitle.SetText( pSong->m_sMainTitle ); m_textTitle.SetText( pSong->GetDisplayMainTitle() );
m_textSubTitle.SetText( pSong->m_sSubTitle ); m_textSubTitle.SetText( pSong->GetDisplaySubTitle() );
m_textArtist.SetText( g_sArtistPrependString + pSong->m_sArtist ); m_textArtist.SetText( g_sArtistPrependString + pSong->GetDisplayArtist() );
bool bTwoLines = pSong->m_sSubTitle.length() == 0; bool bTwoLines = pSong->m_sSubTitle.length() == 0;
+1 -1
View File
@@ -104,6 +104,6 @@ void TransitionOniFade::UpdateSongText()
{ {
Song* pSong = GAMESTATE->m_pCurSong; Song* pSong = GAMESTATE->m_pCurSong;
ASSERT( pSong ); ASSERT( pSong );
m_textSongInfo.SetText( pSong->GetFullTitle() + "\n" + pSong->m_sArtist + "\n"); m_textSongInfo.SetText( pSong->GetFullDisplayTitle() + "\n" + pSong->m_sArtist + "\n");
m_Banner.LoadFromSong( pSong ); m_Banner.LoadFromSong( pSong );
} }
+19 -9
View File
@@ -94,16 +94,26 @@ public:
bool m_bChangedSinceSave; bool m_bChangedSinceSave;
CString m_sMainTitle; CString m_sMainTitle, m_sSubTitle, m_sArtist;
CString m_sSubTitle; CString m_sMainTitleTranslit, m_sSubTitleTranslit, m_sArtistTranslit;
CString m_sArtist;
CString m_sMainTitleTranslit;
CString m_sSubTitleTranslit;
CString m_sArtistTranslit;
CString m_sCredit;
CString GetFullTitle() const { return m_sMainTitle + (m_sSubTitle.GetLength()? (" " + m_sSubTitle):""); } /* If PREFSMAN->m_bShowTranslations is off, these are the same as GetTranslit* below.
CString GetSortTitle() const; * Otherwise, they return the main titles. */
CString GetDisplayMainTitle() const;
CString GetDisplaySubTitle() const;
CString GetDisplayArtist() const;
/* Returns the transliterated titles, if any; otherwise returns the main titles. */
CString GetTranslitMainTitle() const { return m_sMainTitleTranslit.size()? m_sMainTitleTranslit: m_sMainTitle; }
CString GetTranslitSubTitle() const { return m_sSubTitleTranslit.size()? m_sSubTitleTranslit: m_sSubTitle; }
CString GetTranslitArtist() const { return m_sArtistTranslit.size()? m_sArtistTranslit:m_sArtist; }
/* "title subtitle" */
CString GetFullDisplayTitle() const;
CString GetFullTranslitTitle() const;
/* This is read and saved, but never actually used. */
CString m_sCredit;
CString m_sMusicFile; CString m_sMusicFile;
unsigned m_iMusicBytes; unsigned m_iMusicBytes;