pull the translations into a separate function

This commit is contained in:
Glenn Maynard
2003-01-22 02:07:27 +00:00
parent b7abc4b9f8
commit 4914fa6f9e
2 changed files with 42 additions and 37 deletions
+40 -36
View File
@@ -407,12 +407,13 @@ void Song::TidyUpData()
/* Generate these before we autogen notes, so the new notes can inherit /* Generate these before we autogen notes, so the new notes can inherit
* their source's values. */ * their source's values. */
ReCalulateRadarValuesAndLastBeat(); ReCalculateRadarValuesAndLastBeat();
TrimRight(m_sMainTitle); TrimRight(m_sMainTitle);
if( m_sMainTitle == "" ) m_sMainTitle = "Untitled song"; if( m_sMainTitle == "" ) m_sMainTitle = "Untitled song";
TrimRight(m_sSubTitle); TrimRight(m_sSubTitle);
if( m_sArtist == "" ) m_sArtist = "Unknown artist"; if( m_sArtist == "" ) m_sArtist = "Unknown artist";
TranslateTitles();
/* XXX don't throw due to broken songs */ /* XXX don't throw due to broken songs */
if( m_BPMSegments.empty() ) if( m_BPMSegments.empty() )
@@ -578,39 +579,8 @@ struct TitleTrans
} }
}; };
void Song::ReCalulateRadarValuesAndLastBeat() void Song::TranslateTitles()
{ {
//
// calculate radar values and first/last beat
//
unsigned int i;
for( i=0; i<m_apNotes.size(); i++ )
{
Notes* pNotes = m_apNotes[i];
NoteData tempNoteData;
pNotes->GetNoteData( &tempNoteData );
for( int r=0; r<NUM_RADAR_VALUES; r++ )
{
/* If it's autogen, radar vals come from the parent. */
if(pNotes->IsAutogen())
continue;
pNotes->SetRadarValue(r, NoteDataUtil::GetRadarValue( tempNoteData, (RadarCategory)r, m_fMusicLengthSeconds ));
}
float fFirstBeat = tempNoteData.GetFirstBeat();
float fLastBeat = tempNoteData.GetLastBeat();
if( m_fFirstBeat == -1 )
m_fFirstBeat = fFirstBeat;
else
m_fFirstBeat = min( m_fFirstBeat, fFirstBeat );
if( m_fLastBeat == -1 )
m_fLastBeat = fLastBeat;
else
m_fLastBeat = max( m_fLastBeat, fLastBeat );
}
/* XXX make theme metrics for these or something. Candy makes it /* XXX make theme metrics for these or something. Candy makes it
* a little annoying ...*/ * a little annoying ...*/
@@ -691,7 +661,7 @@ void Song::ReCalulateRadarValuesAndLastBeat()
/* 桜 */ /* 桜 */
ttab.push_back(TitleTrans("^Sakura$", "", "", "&sakura;", "", "") ); ttab.push_back(TitleTrans("^Sakura$", "", "", "&sakura;", "", "") );
/* XXX: "door of magic" (tobira no mahou) -> 魔法の扉 */ /* 魔法の扉 */
ttab.push_back(TitleTrans("^Door of Magic$", "", "", "&mahou1;&mahou2;&hno;&tobira;", "", "") ); ttab.push_back(TitleTrans("^Door of Magic$", "", "", "&mahou1;&mahou2;&hno;&tobira;", "", "") );
ttab.push_back(TitleTrans("^mahou no tobira$", "", "", "&mahou1;&mahou2;&hno;&tobira;", "", "") ); ttab.push_back(TitleTrans("^mahou no tobira$", "", "", "&mahou1;&mahou2;&hno;&tobira;", "", "") );
@@ -719,7 +689,7 @@ void Song::ReCalulateRadarValuesAndLastBeat()
// ttab.push_back(TitleTrans(".*Legend.*", "", "ZZ", "", "", "&zz;") ); // ttab.push_back(TitleTrans(".*Legend.*", "", "ZZ", "", "", "&zz;") );
} }
for(i = 0; i < ttab.size(); ++i) for(unsigned i = 0; i < ttab.size(); ++i)
{ {
if(!ttab[i].Matches(m_sMainTitle, m_sSubTitle, m_sArtist)) if(!ttab[i].Matches(m_sMainTitle, m_sSubTitle, m_sArtist))
continue; continue;
@@ -746,6 +716,39 @@ void Song::ReCalulateRadarValuesAndLastBeat()
} }
} }
void Song::ReCalculateRadarValuesAndLastBeat()
{
//
// calculate radar values and first/last beat
//
for( unsigned i=0; i<m_apNotes.size(); i++ )
{
Notes* pNotes = m_apNotes[i];
NoteData tempNoteData;
pNotes->GetNoteData( &tempNoteData );
for( int r=0; r<NUM_RADAR_VALUES; r++ )
{
/* If it's autogen, radar vals come from the parent. */
if(pNotes->IsAutogen())
continue;
pNotes->SetRadarValue(r, NoteDataUtil::GetRadarValue( tempNoteData, (RadarCategory)r, m_fMusicLengthSeconds ));
}
float fFirstBeat = tempNoteData.GetFirstBeat();
float fLastBeat = tempNoteData.GetLastBeat();
if( m_fFirstBeat == -1 )
m_fFirstBeat = fFirstBeat;
else
m_fFirstBeat = min( m_fFirstBeat, fFirstBeat );
if( m_fLastBeat == -1 )
m_fLastBeat = fLastBeat;
else
m_fLastBeat = max( m_fLastBeat, fLastBeat );
}
}
void Song::GetNotesThatMatch( NotesType nt, vector<Notes*>& arrayAddTo ) const void Song::GetNotesThatMatch( NotesType nt, vector<Notes*>& arrayAddTo ) const
{ {
for( unsigned i=0; i<m_apNotes.size(); i++ ) // for each of the Song's Notes for( unsigned i=0; i<m_apNotes.size(); i++ ) // for each of the Song's Notes
@@ -813,7 +816,8 @@ void Song::Save()
MoveFile( sOldPath, sNewPath ); MoveFile( sOldPath, sNewPath );
} }
ReCalulateRadarValuesAndLastBeat(); ReCalculateRadarValuesAndLastBeat();
TranslateTitles();
SaveToSMFile( GetSongFilePath(), false ); SaveToSMFile( GetSongFilePath(), false );
SaveToDWIFile(); SaveToDWIFile();
+2 -1
View File
@@ -65,7 +65,8 @@ public:
bool LoadFromSongDir( CString sDir ); bool LoadFromSongDir( CString sDir );
void TidyUpData(); // call after loading to clean up invalid data void TidyUpData(); // call after loading to clean up invalid data
void ReCalulateRadarValuesAndLastBeat(); // called by TidyUpData, and after saving void ReCalculateRadarValuesAndLastBeat(); // called by TidyUpData, and after saving
void TranslateTitles(); // called by TidyUpData
void SaveToSMFile( CString sPath, bool bSavingCache ); void SaveToSMFile( CString sPath, bool bSavingCache );
void Save(); // saves SM and DWI void Save(); // saves SM and DWI