From: <sag...@us...> - 2014-11-30 20:14:53
|
Revision: 4619 http://sourceforge.net/p/modplug/code/4619 Author: saga-games Date: 2014-11-30 20:14:43 +0000 (Sun, 30 Nov 2014) Log Message: ----------- [New] When loading a module with missing samples, a dialog with all missing samples, including the functionality to relocate them, is now shown. [Mod] OpenMPT: Version is now 1.24.00.19 Modified Paths: -------------- trunk/OpenMPT/common/versionNumber.h trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/View_tre.cpp trunk/OpenMPT/mptrack/mptrack.rc trunk/OpenMPT/mptrack/mptrack_08.vcproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters trunk/OpenMPT/mptrack/resource.h trunk/OpenMPT/soundlib/Load_it.cpp trunk/OpenMPT/soundlib/Load_mt2.cpp trunk/OpenMPT/soundlib/Sndfile.h Added Paths: ----------- trunk/OpenMPT/mptrack/CListCtrl.h trunk/OpenMPT/mptrack/ExternalSamples.cpp trunk/OpenMPT/mptrack/ExternalSamples.h Modified: trunk/OpenMPT/common/versionNumber.h =================================================================== --- trunk/OpenMPT/common/versionNumber.h 2014-11-30 02:02:03 UTC (rev 4618) +++ trunk/OpenMPT/common/versionNumber.h 2014-11-30 20:14:43 UTC (rev 4619) @@ -19,7 +19,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 24 #define VER_MINOR 00 -#define VER_MINORMINOR 18 +#define VER_MINORMINOR 19 //Version string. For example "1.17.02.28" #define MPT_VERSION_STR VER_STRINGIZE(VER_MAJORMAJOR) "." VER_STRINGIZE(VER_MAJOR) "." VER_STRINGIZE(VER_MINOR) "." VER_STRINGIZE(VER_MINORMINOR) Added: trunk/OpenMPT/mptrack/CListCtrl.h =================================================================== --- trunk/OpenMPT/mptrack/CListCtrl.h (rev 0) +++ trunk/OpenMPT/mptrack/CListCtrl.h 2014-11-30 20:14:43 UTC (rev 4619) @@ -0,0 +1,37 @@ +/* + * CListCtrl.h + * ----------- + * Purpose: A class that extends MFC's CListCtrl to handle unicode strings in ANSI builds. + * Notes : (currently none) + * Authors: OpenMPT Devs + * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. + */ + + +#pragma once + + +OPENMPT_NAMESPACE_BEGIN + + +class CListCtrlW : public CListCtrl +{ +public: + +#ifndef UNICODE + BOOL SetItemText(int nItem, int nSubItem, const WCHAR *lpszText) + { + ASSERT(::IsWindow(m_hWnd)); + ASSERT((GetStyle() & LVS_OWNERDATA)==0); + LVITEMW lvi; + lvi.iSubItem = nSubItem; + lvi.pszText = (LPWSTR) lpszText; + return (BOOL) ::SendMessage(m_hWnd, LVM_SETITEMTEXTW, nItem, (LPARAM)&lvi); + } + + using CListCtrl::SetItemText; +#endif +}; + + +OPENMPT_NAMESPACE_END Property changes on: trunk/OpenMPT/mptrack/CListCtrl.h ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/x-chdr \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: trunk/OpenMPT/mptrack/ExternalSamples.cpp =================================================================== --- trunk/OpenMPT/mptrack/ExternalSamples.cpp (rev 0) +++ trunk/OpenMPT/mptrack/ExternalSamples.cpp 2014-11-30 20:14:43 UTC (rev 4619) @@ -0,0 +1,223 @@ +/* + * ExternalSamples.cpp + * ------------------- + * Purpose: Dialog for locating missing external samples + * Notes : (currently none) + * Authors: OpenMPT Devs + * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. + */ + + +#include "stdafx.h" +#include "Moddoc.h" +#include "ExternalSamples.h" +#include "FileDialog.h" +#include "FolderScanner.h" +#include "TrackerSettings.h" +#include "Reporting.h" +#include "resource.h" + +OPENMPT_NAMESPACE_BEGIN + +BEGIN_MESSAGE_MAP(ExternalSamplesDlg, CDialog) + //{{AFX_MSG_MAP(ExternalSamplesDlg) + ON_NOTIFY(NM_DBLCLK, IDC_LIST1, OnSetPath) + ON_COMMAND(IDC_BUTTON1, OnScanFolder) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +void ExternalSamplesDlg::DoDataExchange(CDataExchange* pDX) +//--------------------------------------------------------- +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CModTypeDlg) + DDX_Control(pDX, IDC_LIST1, m_List); + //}}AFX_DATA_MAP +} + + +ExternalSamplesDlg::ExternalSamplesDlg(CModDoc &modDoc, CWnd *parent) : CDialog(IDD_MISSINGSAMPLES, parent), modDoc(modDoc), sndFile(modDoc.GetrSoundFile()), isScanning(false) +//----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +{ +} + + +BOOL ExternalSamplesDlg::OnInitDialog() +//------------------------------------- +{ + CDialog::OnInitDialog(); + + // Initialize table + const struct + { + const TCHAR *text; + int width; + } labels[] = + { + { _T("Sample"), 128 }, + { _T("External Filename"), 308 }, + }; + for(int i = 0; i < CountOf(labels); i++) + { + m_List.InsertColumn(i, labels[i].text, LVCFMT_LEFT, labels[i].width); + } + m_List.SetExtendedStyle(m_List.GetExtendedStyle() | LVS_EX_FULLROWSELECT); + + GenerateList(); + SetWindowTextW(m_hWnd, (L"Missing External Samples - " + modDoc.GetPathNameMpt().GetFullFileName().AsNative()).c_str()); + + return TRUE; +} + + +void ExternalSamplesDlg::GenerateList() +//------------------------------------- +{ + m_List.SetRedraw(FALSE); + m_List.DeleteAllItems(); + CString s; + for(SAMPLEINDEX smp = 1; smp <= sndFile.GetNumSamples(); smp++) + { + if(sndFile.IsExternalSampleMissing(smp)) + { + s.Format("%02u: ", smp); + s += sndFile.GetSampleName(smp); + int insertAt = m_List.InsertItem(m_List.GetItemCount(), s); + if(insertAt == -1) + continue; + m_List.SetItemText(insertAt, 1, sndFile.GetSamplePath(smp).AsNative().c_str()); + m_List.SetItemData(insertAt, smp); + } + } + m_List.SetRedraw(TRUE); + + // Yay, we managed to find all samples! + if(!m_List.GetItemCount()) + { + OnOK(); + } +} + + +void ExternalSamplesDlg::OnSetPath(NMHDR *, LRESULT *) +//---------------------------------------------------- +{ + const int item = m_List.GetSelectionMark(); + if(item == -1) return; + const SAMPLEINDEX smp = static_cast<SAMPLEINDEX>(m_List.GetItemData(item)); + + const mpt::PathString path = modDoc.GetrSoundFile().GetSamplePath(smp); + FileDialog dlg = OpenFileDialog() + .ExtensionFilter("All Samples|*.wav;*.flac|All files(*.*)|*.*||"); // Only show samples that we actually can save as well. + if(TrackerSettings::Instance().previewInFileDialogs) + dlg.EnableAudioPreview(); + if(path.empty()) + dlg.WorkingDirectory(TrackerDirectories::Instance().GetWorkingDirectory(DIR_SAMPLES)); + else + dlg.DefaultFilename(path); + if(!dlg.Show()) return; + TrackerDirectories::Instance().SetWorkingDirectory(dlg.GetWorkingDirectory(), DIR_SAMPLES); + + SetSample(smp, dlg.GetFirstFile()); + modDoc.UpdateAllViews(NULL, HINT_SAMPLEINFO | HINT_SMPNAMES | HINT_SAMPLEDATA | (smp << HINT_SHIFT_SMP)); + GenerateList(); +} + + +void ExternalSamplesDlg::OnScanFolder() +//------------------------------------- +{ + if(isScanning) + { + isScanning = false; + return; + } + + BrowseForFolder dlg(TrackerDirectories::Instance().GetWorkingDirectory(DIR_SAMPLES), _T("Select a folder to search for missing samples...")); + if(dlg.Show()) + { + TrackerDirectories::Instance().SetWorkingDirectory(dlg.GetDirectory(), DIR_SAMPLES); + + FolderScanner scan(dlg.GetDirectory(), true); + mpt::PathString fileName; + + isScanning = true; + SetDlgItemText(IDC_BUTTON1, "&Cancel"); + GetDlgItem(IDOK)->EnableWindow(FALSE); + BeginWaitCursor(); + + DWORD lastTick = GetTickCount(); + int foundFiles = 0; + + bool anyMissing = true; + while(scan.NextFile(fileName) && isScanning && anyMissing) + { + anyMissing = false; + for(SAMPLEINDEX smp = 1; smp <= sndFile.GetNumSamples(); smp++) + { + if(sndFile.IsExternalSampleMissing(smp)) + { + if(!mpt::PathString::CompareNoCase(sndFile.GetSamplePath(smp).GetFullFileName(), fileName.GetFullFileName())) + { + if(SetSample(smp, fileName)) + { + foundFiles++; + } + } else + { + anyMissing = true; + } + } + } + + const DWORD tick = GetTickCount(); + if(tick < lastTick || tick > lastTick + 100) + { + lastTick = tick; + ::SetDlgItemTextW(m_hWnd, IDC_STATIC1, fileName.AsNative().c_str()); + MSG msg; + while(::PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) + { + ::TranslateMessage(&msg); + ::DispatchMessage(&msg); + } + } + } + EndWaitCursor(); + GetDlgItem(IDOK)->EnableWindow(TRUE); + SetDlgItemText(IDC_BUTTON1, "&Scan Folder..."); + SetDlgItemText(IDC_STATIC1, ""); + + modDoc.UpdateAllViews(NULL, HINT_SAMPLEINFO | HINT_SMPNAMES | HINT_SAMPLEDATA); + + if(foundFiles) + { + Reporting::Information(mpt::String::Print("%1 sample paths were relocated.", foundFiles)); + } else if(isScanning) + { + Reporting::Information("No matching sample names found."); + } + isScanning = false; + GenerateList(); + } + +} + + +bool ExternalSamplesDlg::SetSample(SAMPLEINDEX smp, const mpt::PathString &fileName) +//---------------------------------------------------------------------------------- +{ + modDoc.GetSampleUndo().PrepareUndo(smp, sundo_replace, "Replace"); + if(!sndFile.LoadExternalSample(smp, fileName)) + { + Reporting::Information(L"Unable to load sample:\n" + fileName.AsNative()); + modDoc.GetSampleUndo().RemoveLastUndoStep(smp); + return false; + } else + { + modDoc.SetModified(); + return true; + } +} + +OPENMPT_NAMESPACE_END Property changes on: trunk/OpenMPT/mptrack/ExternalSamples.cpp ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/x-c++src \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: trunk/OpenMPT/mptrack/ExternalSamples.h =================================================================== --- trunk/OpenMPT/mptrack/ExternalSamples.h (rev 0) +++ trunk/OpenMPT/mptrack/ExternalSamples.h 2014-11-30 20:14:43 UTC (rev 4619) @@ -0,0 +1,45 @@ +/* + * ExternalSamples.h + * ----------------- + * Purpose: Dialog for locating missing external samples + * Notes : (currently none) + * Authors: OpenMPT Devs + * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. + */ + + +#include "CListCtrl.h" +#include "../common/thread.h" + +OPENMPT_NAMESPACE_BEGIN + +class CModDoc; +class CSoundFile; + +//======================================= +class ExternalSamplesDlg : public CDialog +//======================================= +{ +protected: + CModDoc &modDoc; + CSoundFile &sndFile; + CListCtrlW m_List; + bool isScanning; + +public: + ExternalSamplesDlg(CModDoc &modDoc, CWnd *parent); + +protected: + void GenerateList(); + bool SetSample(SAMPLEINDEX smp, const mpt::PathString &fileName); + + virtual void DoDataExchange(CDataExchange* pDX); + virtual BOOL OnInitDialog(); + + afx_msg void OnSetPath(NMHDR *, LRESULT *); + afx_msg void OnScanFolder(); + + DECLARE_MESSAGE_MAP() +}; + +OPENMPT_NAMESPACE_END Property changes on: trunk/OpenMPT/mptrack/ExternalSamples.h ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/x-chdr \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2014-11-30 02:02:03 UTC (rev 4618) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2014-11-30 20:14:43 UTC (rev 4619) @@ -33,6 +33,7 @@ #include "../soundlib/FileReader.h" #include <shlwapi.h> #include "FileDialog.h" +#include "ExternalSamples.h" #ifdef _DEBUG #define new DEBUG_NEW @@ -130,15 +131,16 @@ ///////////////////////////////////////////////////////////////////////////// // CModDoc construction/destruction -CModDoc::CModDoc() : m_LogMode(LogModeInstantReporting), m_PatternUndo(*this), m_SampleUndo(*this) -//------------------------------------------------------------------------------------------------ +CModDoc::CModDoc() + : m_LogMode(LogModeInstantReporting) + , m_hWndFollow(nullptr) + , m_bHasValidPath(false) + , m_notifyType(Notification::Default) + , m_notifyItem(0) + , m_PatternUndo(*this) + , m_SampleUndo(*this) +//--------------------------------------- { - m_bHasValidPath = false; - m_hWndFollow = NULL; - - m_notifyType = Notification::Default; - m_notifyItem = 0; - // Set the creation date of this file (or the load time if we're loading an existing file) time(&m_creationTime); @@ -386,6 +388,17 @@ SetModifiedFlag(FALSE); // (bModified); m_bHasValidPath=true; + // Check if there are any missing samples, and if there are, show a dialog to relocate them. + for(SAMPLEINDEX smp = 1; smp <= GetNumSamples(); smp++) + { + if(m_SndFile.IsExternalSampleMissing(smp)) + { + ExternalSamplesDlg dlg(*this, CMainFrame::GetMainFrame()); + dlg.DoModal(); + break; + } + } + return TRUE; } @@ -519,7 +532,7 @@ //----------------------------- { CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); - if (pMainFrm) pMainFrm->OnDocumentClosed(this); + if(pMainFrm) pMainFrm->OnDocumentClosed(this); CDocument::OnCloseDocument(); } Modified: trunk/OpenMPT/mptrack/View_tre.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_tre.cpp 2014-11-30 02:02:03 UTC (rev 4618) +++ trunk/OpenMPT/mptrack/View_tre.cpp 2014-11-30 20:14:43 UTC (rev 4619) @@ -22,7 +22,7 @@ #include "../soundlib/FileReader.h" #include "FileDialog.h" #include "Globals.h" -#include "FolderScanner.h" +#include "ExternalSamples.h" OPENMPT_NAMESPACE_BEGIN @@ -2582,17 +2582,17 @@ anyModified = true; } } - if(sample.uFlags[SMP_KEEPONDISK] && sample.pSample == nullptr) + if(sndFile->IsExternalSampleMissing(smp)) { anyMissing = true; } if(anyPath && anyModified && anyMissing) break; } - if(menuForThisSample || anyPath || anyModified || anyMissing) + if(menuForThisSample || anyPath || anyModified) { AppendMenu(hMenu, MF_SEPARATOR, NULL, _T("")); - if(menuForThisSample) AppendMenu(hMenu, MF_STRING | (sndFile->GetType() == MOD_TYPE_MPT ? 0 : MF_GRAYED), ID_MODTREE_SETPATH, _T("Set P&ath")); + if(menuForThisSample) AppendMenu(hMenu, MF_STRING | ((sndFile->GetType() == MOD_TYPE_MPT || hasPath) ? 0 : MF_GRAYED), ID_MODTREE_SETPATH, _T("Set P&ath")); if(menuForThisSample) AppendMenu(hMenu, MF_STRING | ((hasPath && sample.HasSampleData() && sample.uFlags[SMP_MODIFIED]) ? 0 : MF_GRAYED), ID_MODTREE_SAVEITEM, _T("&Save")); if(anyModified) AppendMenu(hMenu, MF_STRING, ID_MODTREE_SAVEALL, _T("&Save All")); if(menuForThisSample) AppendMenu(hMenu, MF_STRING | (hasPath ? 0 : MF_GRAYED), ID_MODTREE_RELOADITEM, _T("&Reload")); @@ -3280,46 +3280,8 @@ { return; } - BrowseForFolder dlg(TrackerDirectories::Instance().GetWorkingDirectory(DIR_SAMPLES), _T("Select a folder to search for missing samples...")); - int foundFiles = 0; - if(dlg.Show()) - { - FolderScanner scan(dlg.GetDirectory(), true); - mpt::PathString fileName; - CSoundFile &sndFile = pModDoc->GetrSoundFile(); - - BeginWaitCursor(); - while(scan.NextFile(fileName)) - { - for(SAMPLEINDEX smp = 1; smp <= sndFile.GetNumSamples(); smp++) - { - ModSample &sample = sndFile.GetSample(smp); - if(sample.uFlags[SMP_KEEPONDISK] && sample.pSample == nullptr && !mpt::PathString::CompareNoCase(sndFile.GetSamplePath(smp).GetFullFileName(), fileName.GetFullFileName())) - { - pModDoc->GetSampleUndo().PrepareUndo(smp, sundo_replace, "Replace"); - if(!sndFile.LoadExternalSample(smp, fileName)) - { - pModDoc->GetSampleUndo().RemoveLastUndoStep(smp); - } else - { - pModDoc->SetModified(); - foundFiles++; - } - } - } - } - EndWaitCursor(); - } - pModDoc->UpdateAllViews(NULL, HINT_SAMPLEINFO | HINT_SMPNAMES | HINT_SAMPLEDATA); - OnRefreshTree(); - - if(foundFiles) - { - Reporting::Information(mpt::String::Print("%1 sample paths were relocated.", foundFiles)); - } else - { - Reporting::Information("No matching sample names found."); - } + ExternalSamplesDlg dlg(*pModDoc, CMainFrame::GetMainFrame()); + dlg.DoModal(); } Modified: trunk/OpenMPT/mptrack/mptrack.rc =================================================================== --- trunk/OpenMPT/mptrack/mptrack.rc 2014-11-30 02:02:03 UTC (rev 4618) +++ trunk/OpenMPT/mptrack/mptrack.rc 2014-11-30 20:14:43 UTC (rev 4619) @@ -24,6 +24,17 @@ // Dialog // +IDD_MISSINGSAMPLES DIALOGEX 0, 0, 316, 185 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + DEFPUSHBUTTON "&OK",IDOK,262,164,50,14 + LTEXT "The following external samples could not be found.\nDouble-click an entry to set its new file location.\nClick ""Scan Folder"" to search for matching filenames of all missing samples in a folder.",IDC_STATIC,6,6,306,24 + CONTROL "",IDC_LIST1,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,6,36,306,120 + PUSHBUTTON "&Scan Folder...",IDC_BUTTON1,7,164,60,14 + LTEXT "",IDC_STATIC1,72,167,186,8,SS_PATHELLIPSIS +END + IDD_CLEANUP_SONG DIALOGEX 0, 0, 394, 154 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Cleanup" @@ -335,6 +346,14 @@ #ifdef APSTUDIO_INVOKED GUIDELINES DESIGNINFO BEGIN + IDD_MISSINGSAMPLES, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 312 + TOPMARGIN, 7 + BOTTOMMARGIN, 178 + END + IDD_CLEANUP_SONG, DIALOG BEGIN LEFTMARGIN, 7 Modified: trunk/OpenMPT/mptrack/mptrack_08.vcproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_08.vcproj 2014-11-30 02:02:03 UTC (rev 4618) +++ trunk/OpenMPT/mptrack/mptrack_08.vcproj 2014-11-30 20:14:43 UTC (rev 4619) @@ -540,6 +540,10 @@ > </File> <File + RelativePath=".\ExternalSamples.cpp" + > + </File> + <File RelativePath="..\soundlib\Fastmix.cpp" > </File> @@ -1158,6 +1162,10 @@ > </File> <File + RelativePath=".\CListCtrl.h" + > + </File> + <File RelativePath=".\ColourEdit.h" > </File> @@ -1238,6 +1246,10 @@ > </File> <File + RelativePath=".\ExternalSamples.h" + > + </File> + <File RelativePath=".\FileDialog.h" > </File> Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2014-11-30 02:02:03 UTC (rev 4618) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2014-11-30 20:14:43 UTC (rev 4619) @@ -828,6 +828,7 @@ <ClCompile Include="EffectInfo.cpp" /> <ClCompile Include="EffectVis.cpp" /> <ClCompile Include="ExceptionHandler.cpp" /> + <ClCompile Include="ExternalSamples.cpp" /> <ClCompile Include="FileDialog.cpp" /> <ClCompile Include="FolderScanner.cpp" /> <ClCompile Include="Globals.cpp" /> @@ -1030,6 +1031,7 @@ <ClInclude Include="Childfrm.h" /> <ClInclude Include="CImageListEx.h" /> <ClInclude Include="CleanupSong.h" /> + <ClInclude Include="CListCtrl.h" /> <ClInclude Include="ColourEdit.h" /> <ClInclude Include="CommandSet.h" /> <ClInclude Include="CreditStatic.h" /> @@ -1042,6 +1044,7 @@ <ClInclude Include="DefaultVstEditor.h" /> <ClInclude Include="EffectInfo.h" /> <ClInclude Include="ExceptionHandler.h" /> + <ClInclude Include="ExternalSamples.h" /> <ClInclude Include="FileDialog.h" /> <ClInclude Include="FolderScanner.h" /> <ClInclude Include="Globals.h" /> Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2014-11-30 02:02:03 UTC (rev 4618) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2014-11-30 20:14:43 UTC (rev 4619) @@ -535,6 +535,9 @@ <ClCompile Include="FolderScanner.cpp"> <Filter>Source Files\mptrack</Filter> </ClCompile> + <ClCompile Include="ExternalSamples.cpp"> + <Filter>Source Files\mptrack\Dialogs</Filter> + </ClCompile> </ItemGroup> <ItemGroup> <ClInclude Include="..\soundlib\Loaders.h"> @@ -1041,6 +1044,12 @@ <ClInclude Include="FolderScanner.h"> <Filter>Header Files\mptrack</Filter> </ClInclude> + <ClInclude Include="ExternalSamples.h"> + <Filter>Header Files\mptrack\Dialogs</Filter> + </ClInclude> + <ClInclude Include="CListCtrl.h"> + <Filter>Header Files\mptrack</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <None Include="res\bitmap1.bmp"> Modified: trunk/OpenMPT/mptrack/resource.h =================================================================== --- trunk/OpenMPT/mptrack/resource.h 2014-11-30 02:02:03 UTC (rev 4618) +++ trunk/OpenMPT/mptrack/resource.h 2014-11-30 20:14:43 UTC (rev 4619) @@ -135,6 +135,7 @@ #define IDD_OPTIONS_SAMPLEEDITOR 535 #define IDD_SCANPLUGINS 536 #define IDD_RESAMPLE 537 +#define IDD_MISSINGSAMPLES 538 #define IDC_BUTTON1 1001 #define IDC_BUTTON2 1002 #define IDC_BUTTON3 1003 @@ -1251,7 +1252,7 @@ #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_3D_CONTROLS 1 -#define _APS_NEXT_RESOURCE_VALUE 538 +#define _APS_NEXT_RESOURCE_VALUE 539 #define _APS_NEXT_COMMAND_VALUE 44645 #define _APS_NEXT_CONTROL_VALUE 2483 #define _APS_NEXT_SYMED_VALUE 901 Modified: trunk/OpenMPT/soundlib/Load_it.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_it.cpp 2014-11-30 02:02:03 UTC (rev 4618) +++ trunk/OpenMPT/soundlib/Load_it.cpp 2014-11-30 20:14:43 UTC (rev 4619) @@ -655,7 +655,10 @@ } if(!LoadExternalSample(i + 1, filename)) { +#ifndef MODPLUG_TRACKER + // OpenMPT has its own way of reporting this error AddToLog(LogError, mpt::String::Print(MPT_USTRING("Unable to load sample %1: %2"), i, filename.ToUnicode())); +#endif // MODPLUG_TRACKER } } else { Modified: trunk/OpenMPT/soundlib/Load_mt2.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_mt2.cpp 2014-11-30 02:02:03 UTC (rev 4618) +++ trunk/OpenMPT/soundlib/Load_mt2.cpp 2014-11-30 20:14:43 UTC (rev 4619) @@ -198,7 +198,7 @@ // Note: The order of these fields differs a bit in MTIOModule_MT2.cpp - maybe just typos, I'm not sure. -// This struct follows the safe format of MadTracker 2.6.1. +// This struct follows the save format of MadTracker 2.6.1. struct PACKED MT2InstrSynth { uint8 synthID; @@ -926,7 +926,7 @@ } // Read sample headers - std::vector<bool> sampleInterpolation(256, true); + std::bitset<256> sampleNoInterpolation; for(SAMPLEINDEX i = 0; i < 256; i++) { char sampleName[32]; @@ -967,11 +967,11 @@ if(sampleHeader.flags & 5) { // External sample - strcpy(mptSmp.filename, "Ext"); + mptSmp.uFlags.set(SMP_KEEPONDISK); } if(sampleHeader.flags & 8) { - sampleInterpolation[i] = false; + sampleNoInterpolation[i] = true; for(INSTRUMENTINDEX drum = 0; drum < 8; drum++) { if(drumMap[drum] != 0 && Instruments[drumMap[drum]] != nullptr) @@ -1018,7 +1018,7 @@ mptSmp.nVibRate = insHeader.vibrate; mptSmp.nGlobalVol = uint16(group.vol) * 2; mptSmp.nFineTune = group.pitch; - if(!sampleInterpolation[sample - 1]) + if(sampleNoInterpolation[sample - 1]) { mptIns->nResampling = SRCMODE_NEAREST; } @@ -1039,7 +1039,7 @@ ModSample &mptSmp = Samples[i + 1]; const uint32 freq = Util::Round<uint32>(mptSmp.nC5Speed * std::pow(2.0, -(mptSmp.RelativeTone - 49 - (mptSmp.nFineTune / 128.0)) / 12.0)); - if(strcmp(mptSmp.filename, "Ext")) + if(!mptSmp.uFlags[SMP_KEEPONDISK]) { SampleIO( mptSmp.uFlags[CHN_16BIT] ? SampleIO::_16bit : SampleIO::_8bit, @@ -1082,7 +1082,10 @@ } if(!LoadExternalSample(i + 1, path)) { +#ifndef MODPLUG_TRACKER + // OpenMPT has its own way of reporting this error AddToLog(LogError, mpt::String::Print(MPT_USTRING("Unable to load sample %1: %2"), i, path.ToUnicode())); +#endif // MODPLUG_TRACKER } #else #if defined(MPT_WITH_CHARSET_LOCALE) Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2014-11-30 02:02:03 UTC (rev 4618) +++ trunk/OpenMPT/soundlib/Sndfile.h 2014-11-30 20:14:43 UTC (rev 4619) @@ -534,6 +534,7 @@ void ResetSamplePath(SAMPLEINDEX smp) { if(m_samplePaths.size() >= smp) m_samplePaths[smp - 1] = mpt::PathString(); Samples[smp].uFlags.reset(SMP_KEEPONDISK | SMP_MODIFIED);} mpt::PathString GetSamplePath(SAMPLEINDEX smp) const { if(m_samplePaths.size() >= smp) return m_samplePaths[smp - 1]; else return mpt::PathString(); } bool SampleHasPath(SAMPLEINDEX smp) const { if(m_samplePaths.size() >= smp) return !m_samplePaths[smp - 1].empty(); else return false; } + bool IsExternalSampleMissing(SAMPLEINDEX smp) const { return Samples[smp].uFlags[SMP_KEEPONDISK] && Samples[smp].pSample == nullptr; } bool LoadExternalSample(SAMPLEINDEX smp, const mpt::PathString &filename); #endif // MPT_EXTERNAL_SAMPLES This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |