Fix #DISPLAYBPM in DWIs for real.
This commit is contained in:
@@ -316,14 +316,20 @@ bool DWILoader::LoadFromDWIFile( CString sPath, Song &out )
|
|||||||
else if( 0==stricmp(sValueName,"DISPLAYBPM") )
|
else if( 0==stricmp(sValueName,"DISPLAYBPM") )
|
||||||
{
|
{
|
||||||
// #DISPLAYBPM:[xxx..xxx]|[xxx]|[*];
|
// #DISPLAYBPM:[xxx..xxx]|[xxx]|[*];
|
||||||
if( sscanf( sParams[1], "%f..%f", &out.m_fDisplayBPMMin, &out.m_fDisplayBPMMax ) == 2 )
|
int iMin, iMax;
|
||||||
|
/* We can't parse this as a float with sscanf, since '.' is a valid
|
||||||
|
* character in a float. (We could do it with a regex, but it's not
|
||||||
|
* worth bothering with since we don't display fractional BPM anyway.) */
|
||||||
|
if( sscanf( sParams[1], "%i..%i", &iMin, &iMax ) == 2 )
|
||||||
{
|
{
|
||||||
out.m_DisplayBPMType = Song::DISPLAY_SPECIFIED;
|
out.m_DisplayBPMType = Song::DISPLAY_SPECIFIED;
|
||||||
|
out.m_fDisplayBPMMin = (float) iMin;
|
||||||
|
out.m_fDisplayBPMMax = (float) iMax;
|
||||||
}
|
}
|
||||||
else if( sscanf( sParams[1], "%f", &out.m_fDisplayBPMMin ) == 1 )
|
else if( sscanf( sParams[1], "%i", &iMin ) == 1 )
|
||||||
{
|
{
|
||||||
out.m_DisplayBPMType = Song::DISPLAY_SPECIFIED;
|
out.m_DisplayBPMType = Song::DISPLAY_SPECIFIED;
|
||||||
out.m_fDisplayBPMMax = out.m_fDisplayBPMMin;
|
out.m_fDisplayBPMMin = out.m_fDisplayBPMMax = (float) iMin;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -236,9 +236,9 @@ bool NotesWriterDWI::Write( CString sPath, const Song &out )
|
|||||||
break;
|
break;
|
||||||
case Song::DISPLAY_SPECIFIED:
|
case Song::DISPLAY_SPECIFIED:
|
||||||
if( out.m_fDisplayBPMMin == out.m_fDisplayBPMMax )
|
if( out.m_fDisplayBPMMin == out.m_fDisplayBPMMax )
|
||||||
fprintf( fp, "#DISPLAYBPM:%.3f;\n", out.m_fDisplayBPMMin );
|
fprintf( fp, "#DISPLAYBPM:%i;\n", (int) out.m_fDisplayBPMMin );
|
||||||
else
|
else
|
||||||
fprintf( fp, "#DISPLAYBPM:%.3f..%.3f;\n", out.m_fDisplayBPMMin, out.m_fDisplayBPMMax );
|
fprintf( fp, "#DISPLAYBPM:%i..%i;\n", (int) out.m_fDisplayBPMMin, (int) out.m_fDisplayBPMMax );
|
||||||
break;
|
break;
|
||||||
case Song::DISPLAY_RANDOM:
|
case Song::DISPLAY_RANDOM:
|
||||||
fprintf( fp, "#DISPLAYBPM:*" );
|
fprintf( fp, "#DISPLAYBPM:*" );
|
||||||
|
|||||||
Reference in New Issue
Block a user