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:
@@ -56,7 +56,7 @@ void MusicList::AddSongsToGroup(const vector<Song*> &Songs)
|
||||
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
|
||||
if( sTitle.GetLength() > 40 )
|
||||
{
|
||||
|
||||
@@ -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 )
|
||||
{
|
||||
unsigned i;
|
||||
@@ -322,7 +333,6 @@ void MusicWheel::BuildWheelItemDatas( vector<WheelItemData> &arrayWheelItemDatas
|
||||
bool bUseSections = false;
|
||||
switch( so )
|
||||
{
|
||||
// case SORT_GROUP_NOHEADER: bUseSections = false; break;
|
||||
case SORT_MOST_PLAYED: bUseSections = false; break;
|
||||
case SORT_BPM: bUseSections = false; break;
|
||||
case SORT_GROUP: bUseSections = GAMESTATE->m_sPreferredGroup == "ALL MUSIC"; break;
|
||||
@@ -336,6 +346,11 @@ void MusicWheel::BuildWheelItemDatas( vector<WheelItemData> &arrayWheelItemDatas
|
||||
|
||||
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
|
||||
CString sLastSection = "";
|
||||
RageColor colorSection;
|
||||
@@ -347,6 +362,7 @@ void MusicWheel::BuildWheelItemDatas( vector<WheelItemData> &arrayWheelItemDatas
|
||||
|
||||
if( GAMESTATE->m_sPreferredGroup != "ALL MUSIC" && pSong->m_sGroupName != GAMESTATE->m_sPreferredGroup )
|
||||
continue;
|
||||
|
||||
if( sThisSection != sLastSection) // new section, make a section item
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
CString MusicWheel::GetSectionNameFromSongAndSort( Song* pSong, SongSortOrder so )
|
||||
CString MusicWheel::GetSectionNameFromSongAndSort( const Song* pSong, SongSortOrder so )
|
||||
{
|
||||
if( pSong == NULL )
|
||||
return "";
|
||||
@@ -1093,7 +1109,7 @@ CString MusicWheel::GetSectionNameFromSongAndSort( Song* pSong, SongSortOrder so
|
||||
// sTemp = "NUM";
|
||||
// return sTemp;
|
||||
case SORT_TITLE:
|
||||
sTemp = pSong->GetSortTitle();
|
||||
sTemp = pSong->GetTranslitSubTitle();
|
||||
sTemp.MakeUpper();
|
||||
if(sTemp.empty()) return "";
|
||||
|
||||
|
||||
@@ -41,8 +41,12 @@ const ScreenMessage SM_SortOrderChanged = ScreenMessage(SM_User+48);
|
||||
|
||||
enum { SORT_ROULETTE = NUM_SORT_ORDERS+1 };
|
||||
|
||||
struct CompareSongPointerArrayBySectionName;
|
||||
|
||||
class MusicWheel : public ActorFrame
|
||||
{
|
||||
friend struct CompareSongPointerArrayBySectionName;
|
||||
|
||||
public:
|
||||
MusicWheel();
|
||||
~MusicWheel();
|
||||
@@ -76,11 +80,11 @@ public:
|
||||
CString GetSelectedSection(){ return m_CurWheelItemData[m_iSelection]->m_sSectionName; };
|
||||
|
||||
bool WheelIsLocked() { return (m_WheelState == STATE_LOCKED ? true : false); }
|
||||
void RebuildWheelItemDisplays();
|
||||
|
||||
protected:
|
||||
void GetSongList(vector<Song*> &arraySongs, bool bRoulette );
|
||||
void BuildWheelItemDatas( vector<WheelItemData> &arrayWheelItems, SongSortOrder so );
|
||||
void RebuildWheelItemDisplays();
|
||||
void SetOpenGroup(CString group, SongSortOrder so = NUM_SORT_ORDERS);
|
||||
bool SelectSong(const Song *p);
|
||||
bool SelectCourse(const Course *p);
|
||||
@@ -128,7 +132,7 @@ protected:
|
||||
RageSound m_soundStart;
|
||||
RageSound m_soundLocked;
|
||||
|
||||
CString GetSectionNameFromSongAndSort( Song* pSong, SongSortOrder so );
|
||||
static CString GetSectionNameFromSongAndSort( const Song* pSong, SongSortOrder so );
|
||||
bool WheelItemIsVisible(int n);
|
||||
void UpdateScrollbar();
|
||||
};
|
||||
|
||||
@@ -219,14 +219,9 @@ bool NotesWriterDWI::Write( CString sPath, const Song &out )
|
||||
if( fp == NULL )
|
||||
RageException::Throw( "Error opening song file '%s' for writing.", sPath.GetString() );
|
||||
|
||||
/* If we have transliterations, write them instead of the real title, since
|
||||
* DWI doesn't support UTF-8. */
|
||||
if(!out.GetSortTitle().empty())
|
||||
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() );
|
||||
/* Write transliterations, if we have them, since DWI doesn't support UTF-8. */
|
||||
fprintf( fp, "#TITLE:%s;\n", out.GetTranslitMainTitle().GetString() );
|
||||
fprintf( fp, "#ARTIST:%s;\n", out.GetTranslitArtist().GetString() );
|
||||
ASSERT( out.m_BPMSegments[0].m_fStartBeat == 0 );
|
||||
fprintf( fp, "#BPM:%.3f;\n", out.m_BPMSegments[0].m_fBPM );
|
||||
fprintf( fp, "#GAP:%d;\n", int(-roundf( out.m_fBeat0OffsetInSeconds*1000 )) );
|
||||
|
||||
@@ -68,6 +68,7 @@ PrefsManager::PrefsManager()
|
||||
m_bInstructions = true;
|
||||
m_bShowDontDie = true;
|
||||
m_bShowSelectGroup = true;
|
||||
m_bShowTranslations = true;
|
||||
m_bArcadeOptionsNavigation = false;
|
||||
m_iUnloadTextureDelaySeconds = 0; // disabled 60*30; // 30 mins
|
||||
m_bCoinOpMode = false;
|
||||
@@ -144,6 +145,7 @@ void PrefsManager::ReadGlobalPrefsFromDisk( bool bSwitchToLastPlayedGame )
|
||||
ini.GetValueB( "Options", "HowToPlay", m_bInstructions );
|
||||
ini.GetValueB( "Options", "Caution", m_bShowDontDie );
|
||||
ini.GetValueB( "Options", "SelectGroup", m_bShowSelectGroup );
|
||||
ini.GetValueB( "Options", "ShowTranslations", m_bShowTranslations );
|
||||
ini.GetValueB( "Options", "ArcadeOptionsNavigation", m_bArcadeOptionsNavigation );
|
||||
ini.GetValue ( "Options", "DWIPath", m_DWIPath );
|
||||
ini.GetValueI( "Options", "UnloadTextureDelaySeconds", m_iUnloadTextureDelaySeconds );
|
||||
@@ -216,6 +218,7 @@ void PrefsManager::SaveGlobalPrefsToDisk()
|
||||
ini.SetValueB( "Options", "HowToPlay", m_bInstructions );
|
||||
ini.SetValueB( "Options", "Caution", m_bShowDontDie );
|
||||
ini.SetValueB( "Options", "SelectGroup", m_bShowSelectGroup );
|
||||
ini.SetValueB( "Options", "ShowTranslations", m_bShowTranslations );
|
||||
ini.SetValueB( "Options", "ArcadeOptionsNavigation", m_bArcadeOptionsNavigation );
|
||||
ini.SetValue ( "Options", "DWIPath", m_DWIPath );
|
||||
ini.SetValueI( "Options", "UnloadTextureDelaySeconds", m_iUnloadTextureDelaySeconds );
|
||||
|
||||
@@ -52,6 +52,7 @@ public:
|
||||
bool m_bAutoPlay;
|
||||
bool m_bDelayedEscape;
|
||||
bool m_bInstructions, m_bShowDontDie, m_bShowSelectGroup;
|
||||
bool m_bShowTranslations;
|
||||
bool m_bArcadeOptionsNavigation;
|
||||
bool m_bCoinOpMode;
|
||||
enum { NEVER, ALWAYS, ABC_ONLY } m_MusicWheelUsesSections;
|
||||
|
||||
@@ -1129,7 +1129,7 @@ void ShowSavePrompt( ScreenMessage SM_SendWhenDone )
|
||||
"Would you like to save these changes back\n"
|
||||
"to the song file?\n"
|
||||
"Choosing NO will discard your changes.",
|
||||
GAMESTATE->m_pCurSong->GetFullTitle().GetString() );
|
||||
GAMESTATE->m_pCurSong->GetFullDisplayTitle().GetString() );
|
||||
break;
|
||||
case PLAY_MODE_NONSTOP:
|
||||
case PLAY_MODE_ONI:
|
||||
|
||||
@@ -159,7 +159,7 @@ ScreenMusicScroll::ScreenMusicScroll()
|
||||
{
|
||||
Song* pSong = arraySongs[i];
|
||||
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].SetZoom( TEXT_ZOOM );
|
||||
|
||||
|
||||
@@ -410,6 +410,14 @@ void ScreenSelectMusic::Input( const DeviceInput& DeviceI, InputEventType type,
|
||||
{
|
||||
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.IsValid() ) return;
|
||||
|
||||
+32
-11
@@ -857,8 +857,8 @@ bool Song::HasEdits( NotesType nt ) const
|
||||
int CompareSongPointersByTitle(const Song *pSong1, const Song *pSong2)
|
||||
{
|
||||
//Prefer transliterations to full titles
|
||||
CString sTitle1 = pSong1->GetSortTitle();
|
||||
CString sTitle2 = pSong2->GetSortTitle();
|
||||
CString sTitle1 = pSong1->GetFullTranslitTitle();
|
||||
CString sTitle2 = pSong2->GetFullTranslitTitle();
|
||||
|
||||
int ret = sTitle1.CompareNoCase(sTitle2);
|
||||
if(ret < 0) return true;
|
||||
@@ -1078,19 +1078,40 @@ CString Song::GetBackgroundPath() const
|
||||
return m_sSongDir+m_sBackgroundFile;
|
||||
}
|
||||
|
||||
CString Song::GetSortTitle() const
|
||||
CString Song::GetDisplayMainTitle() const
|
||||
{
|
||||
CString Title = m_sMainTitleTranslit.empty()?
|
||||
m_sMainTitle: m_sMainTitleTranslit;
|
||||
if(!PREFSMAN->m_bShowTranslations) return GetTranslitMainTitle();
|
||||
return m_sMainTitle;
|
||||
}
|
||||
|
||||
CString SubTitle = m_sSubTitleTranslit.empty()?
|
||||
m_sSubTitle:m_sSubTitleTranslit;
|
||||
CString Song::GetDisplaySubTitle() const
|
||||
{
|
||||
if(!PREFSMAN->m_bShowTranslations) return GetTranslitSubTitle();
|
||||
return m_sSubTitle;
|
||||
}
|
||||
|
||||
if(!SubTitle.empty())
|
||||
{
|
||||
Title += " " + SubTitle;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -99,9 +99,9 @@ bool TextBanner::LoadFromSong( const Song* pSong )
|
||||
return true;
|
||||
}
|
||||
|
||||
m_textTitle.SetText( pSong->m_sMainTitle );
|
||||
m_textSubTitle.SetText( pSong->m_sSubTitle );
|
||||
m_textArtist.SetText( g_sArtistPrependString + pSong->m_sArtist );
|
||||
m_textTitle.SetText( pSong->GetDisplayMainTitle() );
|
||||
m_textSubTitle.SetText( pSong->GetDisplaySubTitle() );
|
||||
m_textArtist.SetText( g_sArtistPrependString + pSong->GetDisplayArtist() );
|
||||
|
||||
bool bTwoLines = pSong->m_sSubTitle.length() == 0;
|
||||
|
||||
|
||||
@@ -104,6 +104,6 @@ void TransitionOniFade::UpdateSongText()
|
||||
{
|
||||
Song* pSong = GAMESTATE->m_pCurSong;
|
||||
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 );
|
||||
}
|
||||
|
||||
+19
-9
@@ -94,17 +94,27 @@ public:
|
||||
|
||||
bool m_bChangedSinceSave;
|
||||
|
||||
CString m_sMainTitle;
|
||||
CString m_sSubTitle;
|
||||
CString m_sArtist;
|
||||
CString m_sMainTitleTranslit;
|
||||
CString m_sSubTitleTranslit;
|
||||
CString m_sArtistTranslit;
|
||||
CString m_sMainTitle, m_sSubTitle, m_sArtist;
|
||||
CString m_sMainTitleTranslit, m_sSubTitleTranslit, m_sArtistTranslit;
|
||||
|
||||
/* If PREFSMAN->m_bShowTranslations is off, these are the same as GetTranslit* below.
|
||||
* 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 GetFullTitle() const { return m_sMainTitle + (m_sSubTitle.GetLength()? (" " + m_sSubTitle):""); }
|
||||
CString GetSortTitle() const;
|
||||
|
||||
CString m_sMusicFile;
|
||||
unsigned m_iMusicBytes;
|
||||
float m_fBeat0OffsetInSeconds;
|
||||
|
||||
Reference in New Issue
Block a user