Added preview tag to NotesLoaderBMS. Changed Song to check the preview file for sample length instead of the simfile if the preview file is set.

This commit is contained in:
Kyzentun
2015-03-04 13:10:51 -07:00
parent 0318f07d2d
commit 46d215aed3
3 changed files with 23 additions and 1 deletions
+1 -1
View File
@@ -8,7 +8,7 @@ ________________________________________________________________________________
----------
* [SelectMusic] Select Music now plays music file named by #PREVIEW tag if
it's not blank, instead of using the song file for the sample music. The
sample length from the simfile is used and the sample start is treated as
sample length is read from the preview file. The sample start is treated as
0. [kyzentun]
* [Song] GetPreviewMusicPath added. [kyzentun]
* [foreach] foreach_ordered lua function now works on tables that have both
+6
View File
@@ -773,6 +773,7 @@ struct BMSChartInfo {
RString stageFile;
RString musicFile;
RString overrideMusicFile;
RString previewFile;
map<int, RString> backgroundChanges;
};
@@ -894,6 +895,10 @@ void BMSChartReader::ReadHeaders()
{
info.overrideMusicFile = it->second;
}
else if (it->first == "#preview")
{
info.previewFile = it->second;
}
else if (it->first == "#offset")
{
out->m_Timing.m_fBeat0OffsetInSeconds = -StringToFloat(it->second);
@@ -1572,6 +1577,7 @@ void BMSSongLoader::AddToSong()
}
out->m_sMusicFile = main.info.musicFile;
out->m_PreviewFile= main.info.previewFile;
out->m_SongTiming = main.steps->m_Timing;
}
+16
View File
@@ -575,6 +575,22 @@ void Song::TidyUpData( bool fromCache, bool /* duringCache */ )
m_fMusicLengthSeconds);
}
if(!m_PreviewFile.empty())
{
RString error;
RageSoundReader* sample= RageSoundReader_FileReader::OpenFile(GetPreviewMusicPath(), error);
if(sample == NULL)
{
LOG->UserLog( "Preview file", GetPreviewMusicPath(), "couldn't be opened: %s", error.c_str() );
m_PreviewFile= "";
}
else
{
m_fMusicSampleLengthSeconds= sample->GetLength() / 1000.0f;
delete sample;
}
}
if( m_fMusicLengthSeconds < 0 )
{
LOG->UserLog("Sound file",