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:
@@ -8,7 +8,7 @@ ________________________________________________________________________________
|
|||||||
----------
|
----------
|
||||||
* [SelectMusic] Select Music now plays music file named by #PREVIEW tag if
|
* [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
|
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]
|
0. [kyzentun]
|
||||||
* [Song] GetPreviewMusicPath added. [kyzentun]
|
* [Song] GetPreviewMusicPath added. [kyzentun]
|
||||||
* [foreach] foreach_ordered lua function now works on tables that have both
|
* [foreach] foreach_ordered lua function now works on tables that have both
|
||||||
|
|||||||
@@ -773,6 +773,7 @@ struct BMSChartInfo {
|
|||||||
RString stageFile;
|
RString stageFile;
|
||||||
RString musicFile;
|
RString musicFile;
|
||||||
RString overrideMusicFile;
|
RString overrideMusicFile;
|
||||||
|
RString previewFile;
|
||||||
|
|
||||||
map<int, RString> backgroundChanges;
|
map<int, RString> backgroundChanges;
|
||||||
};
|
};
|
||||||
@@ -894,6 +895,10 @@ void BMSChartReader::ReadHeaders()
|
|||||||
{
|
{
|
||||||
info.overrideMusicFile = it->second;
|
info.overrideMusicFile = it->second;
|
||||||
}
|
}
|
||||||
|
else if (it->first == "#preview")
|
||||||
|
{
|
||||||
|
info.previewFile = it->second;
|
||||||
|
}
|
||||||
else if (it->first == "#offset")
|
else if (it->first == "#offset")
|
||||||
{
|
{
|
||||||
out->m_Timing.m_fBeat0OffsetInSeconds = -StringToFloat(it->second);
|
out->m_Timing.m_fBeat0OffsetInSeconds = -StringToFloat(it->second);
|
||||||
@@ -1572,6 +1577,7 @@ void BMSSongLoader::AddToSong()
|
|||||||
}
|
}
|
||||||
|
|
||||||
out->m_sMusicFile = main.info.musicFile;
|
out->m_sMusicFile = main.info.musicFile;
|
||||||
|
out->m_PreviewFile= main.info.previewFile;
|
||||||
out->m_SongTiming = main.steps->m_Timing;
|
out->m_SongTiming = main.steps->m_Timing;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -575,6 +575,22 @@ void Song::TidyUpData( bool fromCache, bool /* duringCache */ )
|
|||||||
m_fMusicLengthSeconds);
|
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 )
|
if( m_fMusicLengthSeconds < 0 )
|
||||||
{
|
{
|
||||||
LOG->UserLog("Sound file",
|
LOG->UserLog("Sound file",
|
||||||
|
|||||||
Reference in New Issue
Block a user