implement color loading

This commit is contained in:
Glenn Maynard
2003-03-19 21:30:12 +00:00
parent 7053ddf17e
commit c950a7327d
2 changed files with 22 additions and 13 deletions
+21 -10
View File
@@ -15,12 +15,12 @@ using namespace std;
bool LyricsLoader::LoadFromLRCFile( CString sPath, Song &out ) bool LyricsLoader::LoadFromLRCFile( CString sPath, Song &out )
{ {
LOG->Trace( "Song::LoadFromLRCFile(%s)", sPath.GetString() ); LOG->Trace( "LyricsLoader::LoadFromLRCFile(%s)", sPath.GetString() );
LRCFile lrc; LRCFile lrc;
bool bResult = lrc.ReadFile( sPath ); bool bResult = lrc.ReadFile( sPath );
CString m_sLastFoundColor = "0x00ff00"; RageColor m_LastFoundColor(0,1,0,1);
if( !bResult ) if( !bResult )
RageException::Throw( "Error opening file '%s' for reading.", sPath.GetString() ); RageException::Throw( "Error opening file '%s' for reading.", sPath.GetString() );
@@ -44,7 +44,16 @@ bool LyricsLoader::LoadFromLRCFile( CString sPath, Song &out )
if( 0==stricmp(sValueName,"COLOUR") || 0==stricmp(sValueName,"COLOR") ) if( 0==stricmp(sValueName,"COLOUR") || 0==stricmp(sValueName,"COLOR") )
{ {
// set color var here for this segment // set color var here for this segment
m_sLastFoundColor = sValueData; float r=1,b=1,g=1; // initialize in case sscanf fails
int result = sscanf( sValueData.GetString(), "0x%2x%2x%2x", &r, &g, &b );
if(result != 3)
{
LOG->Trace( "The color value '%s' in '%s' is invalid.",
sValueData.GetString(), sPath.GetString() );
continue;
}
m_LastFoundColor = RageColor(r,g,b,1);
continue; continue;
} }
@@ -53,17 +62,19 @@ bool LyricsLoader::LoadFromLRCFile( CString sPath, Song &out )
/* If we've gotten this far, and no other statement caught /* If we've gotten this far, and no other statement caught
this value before this does, assume it's a time value. */ this value before this does, assume it's a time value. */
LyricSegment LYRICSTRING; LyricSegment seg;
LYRICSTRING.m_sColor = m_sLastFoundColor; seg.m_Color = m_LastFoundColor;
LYRICSTRING.m_fStartTime = TimeToSeconds(sValueName); seg.m_fStartTime = TimeToSeconds(sValueName);
LYRICSTRING.m_sLyric = sValueData; seg.m_sLyric = sValueData;
LYRICSTRING.m_sLyric.Replace( "\\", "\\" ); // to avoid possible screw-ups /* Er, huh? This won't do anything (replace \ with \). What's wrong
* with using \ in lyrics? */
seg.m_sLyric.Replace( "\\", "\\" ); // to avoid possible screw-ups
// if someone uses a \ for whatever // if someone uses a \ for whatever
// reason in their lyrics -- Miryokuteki // reason in their lyrics -- Miryokuteki
LYRICSTRING.m_sLyric.Replace( "|","\n" ); // Pipe symbols denote a new line in LRC files seg.m_sLyric.Replace( "|","\n" ); // Pipe symbols denote a new line in LRC files
out.AddLyricSegment( LYRICSTRING ); out.AddLyricSegment( seg );
} }
} }
+1 -3
View File
@@ -53,9 +53,7 @@ struct LyricSegment
{ {
float m_fStartTime; float m_fStartTime;
CString m_sLyric; CString m_sLyric;
CString m_sColor; /* This will eventually be a RAGECOLOR, but until a function RageColor m_Color;
is made to convert a hex color to RAGECOLOR, it's a CString.
This allows for multiple colors of lyric blocks. -- Miryokuteki */
}; };