Changed preview length setting to occur when the special preview file is set in edit mode.

This commit is contained in:
Kyzentun
2015-03-11 18:55:06 -06:00
parent bd53ae2e81
commit 3140c4f30f
3 changed files with 23 additions and 18 deletions
+3 -1
View File
@@ -1075,6 +1075,7 @@ bool SSCLoader::LoadEditFromMsd(const MsdFile &msd,
StepsTagInfo reused_steps_info(&*this, pSong, sEditFilePath, false);
reused_steps_info.for_load_edit= true;
reused_steps_info.timing= &stepsTiming;
for(unsigned int i = 0; i < msd.GetNumValues(); ++i)
{
@@ -1088,7 +1089,7 @@ bool SSCLoader::LoadEditFromMsd(const MsdFile &msd,
reused_steps_info.params= &sParams;
steps_handler_map_t::iterator handler=
parser_helper.steps_tag_handlers.find(sValueName);
if(handler != parser_helper.steps_tag_handlers.end())
if(pNewNotes != NULL && handler != parser_helper.steps_tag_handlers.end())
{
handler->second(reused_steps_info);
}
@@ -1180,6 +1181,7 @@ bool SSCLoader::LoadEditFromMsd(const MsdFile &msd,
this->SetSongTitle(sParams[1]);
sSongFullTitle.Replace('\\', '/');
pSong = SONGMAN->FindSong(sSongFullTitle);
reused_steps_info.song= pSong;
if(pSong == NULL)
{
LOG->UserLog("Edit file", sEditFilePath,
+20 -1
View File
@@ -20,6 +20,7 @@
#include "NotesWriterSM.h"
#include "PrefsManager.h"
#include "RageSoundManager.h"
#include "RageSoundReader_FileReader.h"
#include "RageInput.h"
#include "RageLog.h"
#include "ScreenDimensions.h"
@@ -4457,7 +4458,25 @@ static void ChangeCredit( const RString &sNew )
static void ChangePreview(const RString& sNew)
{
Song* pSong = GAMESTATE->m_pCurSong;
pSong->m_PreviewFile= sNew;
if(!sNew.empty())
{
RString error;
RageSoundReader* sample= RageSoundReader_FileReader::OpenFile(pSong->GetPreviewMusicPath(), error);
if(sample == NULL)
{
LOG->UserLog( "Preview file", pSong->GetPreviewMusicPath(), "couldn't be opened: %s", error.c_str() );
}
else
{
pSong->m_fMusicSampleLengthSeconds= sample->GetLength() / 1000.0f;
pSong->m_PreviewFile= sNew;
delete sample;
}
}
else
{
pSong->m_PreviewFile= sNew;
}
}
static void ChangeMainTitleTranslit( const RString &sNew )
-16
View File
@@ -627,22 +627,6 @@ void Song::TidyUpData( bool fromCache, bool /* duringCache */ )
m_fMusicLengthSeconds);
}
if(!m_PreviewFile.empty() && m_fMusicSampleStartSeconds == -1)
{
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",