From: <sag...@us...> - 2014-11-20 19:30:44
|
Revision: 4606 http://sourceforge.net/p/modplug/code/4606 Author: saga-games Date: 2014-11-20 19:30:23 +0000 (Thu, 20 Nov 2014) Log Message: ----------- [Mod] Also set sample path when batch-saving samples (to ease the use case described in http://bugs.openmpt.org/view.php?id=608) [Fix] Tree view: Call the proper function when saving all samples. Modified Paths: -------------- trunk/OpenMPT/mptrack/Ctrl_smp.cpp trunk/OpenMPT/mptrack/View_tre.cpp Modified: trunk/OpenMPT/mptrack/Ctrl_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2014-11-20 19:13:17 UTC (rev 4605) +++ trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2014-11-20 19:30:23 UTC (rev 4606) @@ -1108,12 +1108,12 @@ const mpt::PathString ext = dlg.GetExtension(); SAMPLEINDEX minSmp = m_nSample, maxSmp = m_nSample; - CString sNumberFormat; + CStringW sNumberFormat; if(doBatchSave) { minSmp = 1; maxSmp = m_sndFile.GetNumSamples(); - sNumberFormat.Format("%s%d%s", "%.", ((int)log10((float)maxSmp)) + 1, "d"); + sNumberFormat.Format(L"%s%d%s", L"%.", ((int)log10((float)maxSmp)) + 1, L"d"); } bool ok = false; @@ -1124,7 +1124,7 @@ mpt::PathString fileName = dlg.GetFirstFile(); if(doBatchSave) { - CString sSampleNumber; + CStringW sSampleNumber; CString sSampleName; CString sSampleFilename; sSampleNumber.Format(sNumberFormat, smp); @@ -1134,9 +1134,11 @@ SanitizeFilename(sSampleName); SanitizeFilename(sSampleFilename); - fileName = mpt::PathString::FromWide(mpt::String::Replace(fileName.ToWide(), L"%sample_number%", mpt::ToWide(sSampleNumber))); - fileName = mpt::PathString::FromWide(mpt::String::Replace(fileName.ToWide(), L"%sample_filename%", mpt::ToWide(sSampleFilename))); - fileName = mpt::PathString::FromWide(mpt::String::Replace(fileName.ToWide(), L"%sample_name%", mpt::ToWide(sSampleName))); + std::wstring fileNameW = fileName.ToWide(); + fileNameW = mpt::String::Replace(fileNameW, L"%sample_number%", sSampleNumber); + fileNameW = mpt::String::Replace(fileNameW, L"%sample_filename%", mpt::ToWide(sSampleFilename)); + fileNameW = mpt::String::Replace(fileNameW, L"%sample_name%", mpt::ToWide(sSampleName)); + fileName = mpt::PathString::FromWide(fileNameW); } if(!mpt::PathString::CompareNoCase(ext, MPT_PATHSTRING("raw"))) ok = m_sndFile.SaveRAWSample(smp, fileName); @@ -1145,7 +1147,7 @@ else ok = m_sndFile.SaveWAVSample(smp, fileName); - if(ok && !doBatchSave) + if(ok) { m_sndFile.SetSamplePath(smp, fileName); ModSample &sample = m_sndFile.GetSample(smp); Modified: trunk/OpenMPT/mptrack/View_tre.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_tre.cpp 2014-11-20 19:13:17 UTC (rev 4605) +++ trunk/OpenMPT/mptrack/View_tre.cpp 2014-11-20 19:30:23 UTC (rev 4606) @@ -3195,7 +3195,7 @@ CModDoc *pModDoc = GetDocumentFromItem(GetSelectedItem()); if(pModDoc != nullptr) { - pModDoc->SaveModified(); + pModDoc->SaveAllSamples(); if(pModDoc) pModDoc->UpdateAllViews(NULL, HINT_SAMPLEINFO); OnRefreshTree(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |