From: <man...@us...> - 2013-11-10 15:50:43
|
Revision: 3174 http://sourceforge.net/p/modplug/code/3174 Author: manxorist Date: 2013-11-10 15:50:33 +0000 (Sun, 10 Nov 2013) Log Message: ----------- [Ref] Convert midi export to mpt::PathString. Modified Paths: -------------- trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/mod2midi.cpp trunk/OpenMPT/mptrack/mod2midi.h Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2013-11-10 15:25:02 UTC (rev 3173) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2013-11-10 15:50:33 UTC (rev 3174) @@ -1886,7 +1886,7 @@ .ExtensionFilter("Midi Files (*.mid,*.rmi)|*.mid;*.rmi||"); if(!dlg.Show()) return; - CModToMidi mididlg(dlg.GetFirstFile().ToLocale().c_str(), &m_SndFile, pMainFrm); + CModToMidi mididlg(dlg.GetFirstFile(), &m_SndFile, pMainFrm); if(mididlg.DoModal() == IDOK) { BeginWaitCursor(); Modified: trunk/OpenMPT/mptrack/mod2midi.cpp =================================================================== --- trunk/OpenMPT/mptrack/mod2midi.cpp 2013-11-10 15:25:02 UTC (rev 3173) +++ trunk/OpenMPT/mptrack/mod2midi.cpp 2013-11-10 15:50:33 UTC (rev 3174) @@ -150,16 +150,13 @@ } -CModToMidi::CModToMidi(const char * pszPathName, CSoundFile *pSndFile, CWnd *pWndParent):CDialog(IDD_MOD2MIDI, pWndParent) -//------------------------------------------------------------------------------------------------------------------------ +CModToMidi::CModToMidi(const mpt::PathString &filename, CSoundFile *pSndFile, CWnd *pWndParent):CDialog(IDD_MOD2MIDI, pWndParent) +//------------------------------------------------------------------------------------------------------------------------------- { - CHAR fext[_MAX_EXT]; - m_bRmi = FALSE; m_pSndFile = pSndFile; - strcpy(m_szFileName, pszPathName); - _splitpath(pszPathName, NULL, NULL, NULL, fext); - if (!_stricmp(fext, ".rmi")) m_bRmi = TRUE; + m_szFileName = filename; + if(!mpt::PathString::CompareNoCase(filename.GetFileExt(), MPT_PATHSTRING(".rmi"))) m_bRmi = TRUE; MemsetZero(m_InstrMap); for (UINT nIns=1; nIns<=m_pSndFile->m_nInstruments; nIns++) { @@ -373,7 +370,7 @@ UINT nSpeed; FILE *f = nullptr; - f = mpt_fopen(mpt::PathString::FromLocale(m_szFileName), "wb"); + f = mpt_fopen(m_szFileName, "wb"); if(!f) { return FALSE; Modified: trunk/OpenMPT/mptrack/mod2midi.h =================================================================== --- trunk/OpenMPT/mptrack/mod2midi.h 2013-11-10 15:25:02 UTC (rev 3173) +++ trunk/OpenMPT/mptrack/mod2midi.h 2013-11-10 15:50:33 UTC (rev 3174) @@ -27,11 +27,11 @@ CSoundFile *m_pSndFile; BOOL m_bRmi, m_bPerc; UINT m_nCurrInstr; - CHAR m_szFileName[_MAX_PATH]; + mpt::PathString m_szFileName; MOD2MIDIINSTR m_InstrMap[MAX_SAMPLES]; public: - CModToMidi(const char *pszFileName, CSoundFile *pSndFile, CWnd *pWndParent=NULL); + CModToMidi(const mpt::PathString &filename, CSoundFile *pSndFile, CWnd *pWndParent=NULL); ~CModToMidi() {} BOOL DoConvert(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-11-10 16:12:15
|
Revision: 3175 http://sourceforge.net/p/modplug/code/3175 Author: manxorist Date: 2013-11-10 16:12:08 +0000 (Sun, 10 Nov 2013) Log Message: ----------- [Ref] Convert tuning import error messages to unicode. Modified Paths: -------------- trunk/OpenMPT/mptrack/TuningDialog.cpp trunk/OpenMPT/mptrack/mptrack.rc trunk/OpenMPT/mptrack/resource.h Modified: trunk/OpenMPT/mptrack/TuningDialog.cpp =================================================================== --- trunk/OpenMPT/mptrack/TuningDialog.cpp 2013-11-10 15:50:33 UTC (rev 3174) +++ trunk/OpenMPT/mptrack/TuningDialog.cpp 2013-11-10 16:12:08 UTC (rev 3175) @@ -682,19 +682,19 @@ TrackerDirectories::Instance().SetWorkingDirectory(dlg.GetWorkingDirectory(), DIR_TUNING, true); - CString sLoadReport; + std::wstring sLoadReport; const FileDialog::PathList &files = dlg.GetFilenames(); const size_t nFiles = files.size(); for(size_t counter = 0; counter < nFiles; counter++) { - TCHAR szFileName[_MAX_FNAME], szExt[_MAX_EXT]; - _tsplitpath(files[counter].ToCString(), nullptr, nullptr, szFileName, szExt); + mpt::PathString fileName; + mpt::PathString fileExt; + files[counter].SplitPath(nullptr, nullptr, &fileName, &fileExt); + const std::wstring fileNameExt = (fileName + fileExt).ToWide(); - _tcslwr(szExt); // Convert extension to lower case. - - const bool bIsTun = (_tcscmp(szExt, CTuning::s_FileExtension) == 0); - const bool bIsScl = (_tcscmp(szExt, TEXT(".scl")) == 0); + const bool bIsTun = (mpt::PathString::CompareNoCase(fileExt, mpt::PathString::FromUTF8(CTuning::s_FileExtension)) == 0); + const bool bIsScl = (mpt::PathString::CompareNoCase(fileExt, MPT_PATHSTRING(".scl")) == 0); if (bIsTun || bIsScl) { @@ -714,44 +714,31 @@ delete pT; pT = nullptr; if (m_TempTunings.GetNumTunings() >= CTuningCollection::s_nMaxTuningCount) { - CString sFormat, sMsg; - sFormat.LoadString(IDS_TUNING_IMPORT_LIMIT); - sMsg.FormatMessage(sFormat, szFileName, szExt, CTuningCollection::s_nMaxTuningCount); - sLoadReport += sMsg; + sLoadReport += L"-Failed to load file " + fileNameExt + L": maximum number(" + StringifyW(CTuningCollection::s_nMaxTuningCount) + L") of temporary tunings is already open.\n"; } else // Case: Can't add tuning to tuning collection for unknown reason. { - CString sMsg; - AfxFormatString2(sMsg, IDS_TUNING_IMPORT_UNKNOWN_FAILURE, szFileName, szExt); - sLoadReport += sMsg; + sLoadReport += L"-Unable to import file \"" + fileNameExt + L"\": unknown reason.\n"; } } } else // pT == nullptr { - CString sMsg; - AfxFormatString2(sMsg, IDS_TUNING_IMPORT_UNRECOGNIZED_FILE, szFileName, szExt); - sLoadReport += sMsg; + sLoadReport += L"-Unable to import file \"" + fileNameExt + L"\": unrecognized file.\n"; } } else // scl import. { - EnSclImport a = ImportScl(files[counter], szFileName); + EnSclImport a = ImportScl(files[counter], fileName.ToCString()); if (a != enSclImportOk) { if (a == enSclImportAddTuningFailure && m_TempTunings.GetNumTunings() >= CTuningCollection::s_nMaxTuningCount) { - CString sFormat, sMsg; - sFormat.LoadString(IDS_TUNING_IMPORT_LIMIT); - sMsg.FormatMessage(sFormat, szFileName, szExt, CTuningCollection::s_nMaxTuningCount); - sLoadReport += sMsg; + sLoadReport += L"-Failed to load file " + fileNameExt + L": maximum number(" + StringifyW(CTuningCollection::s_nMaxTuningCount) + L") of temporary tunings is already open.\n"; } else { - CString sFormat, sMsg; - sFormat.LoadString(IDS_TUNING_IMPORT_SCL_FAILURE); - sMsg.FormatMessage(sFormat, szFileName, szExt, (LPCTSTR)GetSclImportFailureMsg(a)); - sLoadReport += sMsg; + sLoadReport += L"-Unable to import " + fileNameExt + L": " + mpt::String::FromCString(GetSclImportFailureMsg(a)) + L".\n"; } } else // scl import successful. @@ -764,7 +751,7 @@ AddTreeItem(m_pActiveTuning, m_TreeItemTuningItemMap.GetMapping_21(TUNINGTREEITEM(&m_TempTunings)), NULL); } } - else if (_tcscmp(szExt, CTuningCollection::s_FileExtension) == 0) + else if(mpt::PathString::CompareNoCase(fileExt, mpt::PathString::FromUTF8(CTuningCollection::s_FileExtension)) == 0) { // For now only loading tuning collection as // a separate collection - no possibility to @@ -774,9 +761,7 @@ if (pNewTCol->Deserialize()) { delete pNewTCol; pNewTCol = 0; - CString sMsg; - AfxFormatString2(sMsg, IDS_TUNING_IMPORT_UNKNOWN_TC_FAILURE, szFileName, szExt); - sLoadReport += sMsg; + sLoadReport += L"-Unable to import tuning collection \"" + fileNameExt + L"\": unrecognized file.\n"; } else { @@ -787,12 +772,10 @@ } else // Case: Unknown extension (should not happen). { - CString sMsg; - AfxFormatString2(sMsg, IDS_TUNING_IMPORT_UNRECOGNIZED_FILE_EXT, szFileName, szExt); - sLoadReport += sMsg; + sLoadReport += L"-Unable to load \"" + fileNameExt + L"\": unrecognized file extension.\n"; } } - if (sLoadReport.GetLength() > 0) + if(sLoadReport.length() > 0) Reporting::Information(sLoadReport); UpdateView(); } Modified: trunk/OpenMPT/mptrack/mptrack.rc =================================================================== --- trunk/OpenMPT/mptrack/mptrack.rc 2013-11-10 15:50:33 UTC (rev 3174) +++ trunk/OpenMPT/mptrack/mptrack.rc 2013-11-10 16:12:08 UTC (rev 3175) @@ -2112,16 +2112,6 @@ STRINGTABLE BEGIN - IDS_TUNING_IMPORT_LIMIT "-Failed to load file %1%2: maximum number(=%3!u!) of temporary tunings is already open.\n" - IDS_TUNING_IMPORT_UNKNOWN_FAILURE - "-Unable to import file ""%1%2"": unknown reason.\n" - IDS_TUNING_IMPORT_UNRECOGNIZED_FILE_EXT - "-Unable to load ""%1%2"": unrecognized file extension.\n" - IDS_TUNING_IMPORT_UNKNOWN_TC_FAILURE - "-Unable to import tuning collection ""%1%2"": unrecognized file.\n" - IDS_TUNING_IMPORT_SCL_FAILURE "-Unable to import ""%1%2"": %3.\n" - IDS_TUNING_IMPORT_UNRECOGNIZED_FILE - "-Unable to import file ""%1%2"": unrecognized file.\n" IDS_SOUNDTOUCH_LOADFAILURE "Unable to load OpenMPT_soundtouch_i16.dll." IDS_ERR_FILEOPEN "Unable to open file." IDS_ERR_FILETYPE "Unsupported file type" Modified: trunk/OpenMPT/mptrack/resource.h =================================================================== --- trunk/OpenMPT/mptrack/resource.h 2013-11-10 15:50:33 UTC (rev 3174) +++ trunk/OpenMPT/mptrack/resource.h 2013-11-10 16:12:08 UTC (rev 3175) @@ -58,12 +58,6 @@ #define IDS_SCL_IMPORT_FAIL_6 221 #define IDS_SCL_IMPORT_FAIL_7 222 #define IDS_SCL_IMPORT_FAIL_8 223 -#define IDS_TUNING_IMPORT_LIMIT 224 -#define IDS_TUNING_IMPORT_UNKNOWN_FAILURE 225 -#define IDS_TUNING_IMPORT_UNRECOGNIZED_FILE_EXT 226 -#define IDS_TUNING_IMPORT_UNKNOWN_TC_FAILURE 227 -#define IDS_TUNING_IMPORT_SCL_FAILURE 228 -#define IDS_TUNING_IMPORT_UNRECOGNIZED_FILE 229 #define IDS_SOUNDTOUCH_LOADFAILURE 230 #define IDS_ERR_FILEOPEN 234 #define IDS_ERR_FILETYPE 235 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2013-11-10 18:36:41
|
Revision: 3182 http://sourceforge.net/p/modplug/code/3182 Author: saga-games Date: 2013-11-10 18:36:31 +0000 (Sun, 10 Nov 2013) Log Message: ----------- [Ref] Explicitely implement drag&drop for CMainFrame. Modified Paths: -------------- trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mainfrm.h Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2013-11-10 18:17:47 UTC (rev 3181) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2013-11-10 18:36:31 UTC (rev 3182) @@ -61,6 +61,7 @@ ON_WM_CLOSE() ON_WM_CREATE() ON_WM_RBUTTONDOWN() + ON_WM_DROPFILES() ON_COMMAND(ID_VIEW_OPTIONS, OnViewOptions) ON_COMMAND(ID_PLUGIN_SETUP, OnPluginManager) @@ -475,6 +476,23 @@ } +// Drop files from Windows +void CMainFrame::OnDropFiles(HDROP hDropInfo) +//------------------------------------------- +{ + const UINT nFiles = ::DragQueryFileW(hDropInfo, (UINT)-1, NULL, 0); + CMainFrame::GetMainFrame()->SetForegroundWindow(); + for(UINT f = 0; f < nFiles; f++) + { + WCHAR fileName[MAX_PATH]; + if(::DragQueryFileW(hDropInfo, f, fileName, CountOf(fileName))) + { + const mpt::PathString file = mpt::PathString::FromNative(fileName); + theApp.OpenDocumentFile(file.ToCString()); + } + } + ::DragFinish(hDropInfo); +} LRESULT CALLBACK CMainFrame::KeyboardProc(int code, WPARAM wParam, LPARAM lParam) Modified: trunk/OpenMPT/mptrack/Mainfrm.h =================================================================== --- trunk/OpenMPT/mptrack/Mainfrm.h 2013-11-10 18:17:47 UTC (rev 3181) +++ trunk/OpenMPT/mptrack/Mainfrm.h 2013-11-10 18:36:31 UTC (rev 3182) @@ -521,6 +521,7 @@ afx_msg void OnInternetUpdate(); afx_msg void OnShowSettingsFolder(); afx_msg void OnHelp(); + afx_msg void OnDropFiles(HDROP hDropInfo); //}}AFX_MSG DECLARE_MESSAGE_MAP() public: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-11-10 19:16:52
|
Revision: 3185 http://sourceforge.net/p/modplug/code/3185 Author: manxorist Date: 2013-11-10 19:16:46 +0000 (Sun, 10 Nov 2013) Log Message: ----------- [Ref] Explicitely include <sstream> header when needed. [Ref] Force locale to classic() for std::stringstream when iostream formatting (operator <<, >>) is used. Modified Paths: -------------- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp trunk/OpenMPT/mptrack/CommandSet.cpp trunk/OpenMPT/mptrack/StreamEncoderFLAC.cpp trunk/OpenMPT/mptrack/StreamEncoderMP3.cpp Modified: trunk/OpenMPT/mptrack/AbstractVstEditor.cpp =================================================================== --- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2013-11-10 19:10:25 UTC (rev 3184) +++ trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2013-11-10 19:16:46 UTC (rev 3185) @@ -21,6 +21,8 @@ #include "VstPresets.h" #include "../soundlib/FileReader.h" +#include <sstream> + #ifndef NO_VST UINT CAbstractVstEditor::clipboardFormat = RegisterClipboardFormat("VST Preset Data"); Modified: trunk/OpenMPT/mptrack/CommandSet.cpp =================================================================== --- trunk/OpenMPT/mptrack/CommandSet.cpp 2013-11-10 19:10:25 UTC (rev 3184) +++ trunk/OpenMPT/mptrack/CommandSet.cpp 2013-11-10 19:16:46 UTC (rev 3185) @@ -18,6 +18,8 @@ #include <stdlib.h> #include "../common/mptFstream.h" +#include <sstream> + #define ENABLE_LOGGING 0 #if(ENABLE_LOGGING) Modified: trunk/OpenMPT/mptrack/StreamEncoderFLAC.cpp =================================================================== --- trunk/OpenMPT/mptrack/StreamEncoderFLAC.cpp 2013-11-10 19:10:25 UTC (rev 3184) +++ trunk/OpenMPT/mptrack/StreamEncoderFLAC.cpp 2013-11-10 19:16:46 UTC (rev 3185) @@ -17,6 +17,9 @@ #include "Mptrack.h" #include "TrackerSettings.h" +#include <locale> +#include <sstream> + #define FLAC__NO_DLL #include <flac/include/FLAC/metadata.h> #include <flac/include/FLAC/format.h> @@ -263,6 +266,7 @@ traits.encoderSettingsName = "FLAC"; traits.encoderName = "libFLAC"; std::ostringstream description; + description.imbue(std::locale::classic()); description << "Free Lossless Audio Codec" << std::endl; description << "Vendor: " << FLAC__VENDOR_STRING << std::endl; description << "Version: " << FLAC__VERSION_STRING << std::endl; Modified: trunk/OpenMPT/mptrack/StreamEncoderMP3.cpp =================================================================== --- trunk/OpenMPT/mptrack/StreamEncoderMP3.cpp 2013-11-10 19:10:25 UTC (rev 3184) +++ trunk/OpenMPT/mptrack/StreamEncoderMP3.cpp 2013-11-10 19:16:46 UTC (rev 3185) @@ -27,6 +27,8 @@ #include <deque> #include <iomanip> +#include <locale> +#include <sstream> #include <cstdlib> @@ -711,6 +713,7 @@ traits.encoderSettingsName = "MP3Blade"; traits.encoderName = lame ? "Lame_enc.dll" : "BladeEnc.dll"; std::ostringstream description; + description.imbue(std::locale::classic()); BE_VERSION ver; MemsetZero(ver); beVersion(&ver); @@ -927,6 +930,7 @@ if(layer3_samplerates[i] == (int)pafd->pwfx->nSamplesPerSec) { std::ostringstream driverDescription; + driverDescription.imbue(std::locale::classic()); std::string driverNameLong; std::string driverNameShort; std::string driverNameCombined; @@ -1074,6 +1078,7 @@ traits.fileShortDescription = "MP3 (ACM)"; traits.fileDescription = "MPEG Layer 3"; std::ostringstream name; + name.imbue(std::locale::classic()); DWORD ver = acmGetVersion(); if(ver & 0xffff) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2013-11-13 19:42:06
|
Revision: 3211 http://sourceforge.net/p/modplug/code/3211 Author: saga-games Date: 2013-11-13 19:41:56 +0000 (Wed, 13 Nov 2013) Log Message: ----------- [Imp] Tree view: Improve handling of case when trying to load a module into the instrument library fails. Modified Paths: -------------- trunk/OpenMPT/mptrack/View_tre.cpp trunk/OpenMPT/mptrack/View_tre.h Modified: trunk/OpenMPT/mptrack/View_tre.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_tre.cpp 2013-11-13 19:38:03 UTC (rev 3210) +++ trunk/OpenMPT/mptrack/View_tre.cpp 2013-11-13 19:41:56 UTC (rev 3211) @@ -295,10 +295,9 @@ } -void CModTree::InsLibSetFullPath(const mpt::PathString &libPath, const mpt::PathString &songName) +bool CModTree::InsLibSetFullPath(const mpt::PathString &libPath, const mpt::PathString &songName) //----------------------------------------------------------------------------------------------- { - m_InstrLibPath = libPath; if(!songName.empty() && mpt::PathString::CompareNoCase(m_SongFileName, songName)) { // Load module for previewing its instruments @@ -318,15 +317,23 @@ } if(m_SongFile != nullptr) { - m_SongFile->Create(file, CSoundFile::loadNoPatternData, nullptr); + if(!m_SongFile->Create(file, CSoundFile::loadNoPatternData, nullptr)) + { + return false; + } // Destroy some stuff that we're not going to use anyway. m_SongFile->Patterns.DestroyPatterns(); m_SongFile->songMessage.clear(); } } + } else + { + return false; } } + m_InstrLibPath = libPath; m_SongFileName = songName; + return true; } @@ -1853,16 +1860,19 @@ bool ok = false; if(isSong) { - m_InstrLibHighlightPath = m_SongFileName = dir; if(!IsSampleBrowser()) { - m_pDataTree->InsLibSetFullPath(m_InstrLibPath, m_SongFileName); + ok = m_pDataTree->InsLibSetFullPath(m_InstrLibPath, dir); m_pDataTree->RefreshInstrumentLibrary(); } else { PostMessage(WM_COMMAND, ID_MODTREE_REFRESHINSTRLIB); + ok = true; } - ok = true; + if(ok) + { + m_InstrLibHighlightPath = dir; + } } else { if(dir == MPT_PATHSTRING("..")) @@ -1898,7 +1908,7 @@ if(!ok) { - std::wstring s = L"Unable to browse to \"" + dir.AsNative() + L"\""; + std::wstring s = L"Unable to browse to \"" + dir.ToWide() + L"\""; Reporting::Error(s, L"Instrument Library"); } else { @@ -3233,8 +3243,7 @@ while (hItem != NULL) { const mpt::PathString str = mpt::PathString::FromWide(GetItemTextW(hItem)); - if((!m_SongFileName.empty() && !mpt::PathString::CompareNoCase(str, m_SongFileName)) - || (m_SongFileName.empty() && !mpt::PathString::CompareNoCase(str, m_InstrLibHighlightPath))) + if(!mpt::PathString::CompareNoCase(str, m_InstrLibHighlightPath)) { hActive = hItem; break; Modified: trunk/OpenMPT/mptrack/View_tre.h =================================================================== --- trunk/OpenMPT/mptrack/View_tre.h 2013-11-13 19:38:03 UTC (rev 3210) +++ trunk/OpenMPT/mptrack/View_tre.h 2013-11-13 19:41:56 UTC (rev 3211) @@ -192,7 +192,7 @@ // Attributes public: void Init(); - void InsLibSetFullPath(const mpt::PathString &libPath, const mpt::PathString &songFolder); + bool InsLibSetFullPath(const mpt::PathString &libPath, const mpt::PathString &songFolder); mpt::PathString InsLibGetFullPath(HTREEITEM hItem) const; void RefreshMidiLibrary(); void RefreshDlsBanks(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-11-14 19:28:39
|
Revision: 3217 http://sourceforge.net/p/modplug/code/3217 Author: manxorist Date: 2013-11-14 19:28:25 +0000 (Thu, 14 Nov 2013) Log Message: ----------- [Ref] Convert mod export to shorter charset conversion syntax. Modified Paths: -------------- trunk/OpenMPT/mptrack/Mod2wave.cpp trunk/OpenMPT/mptrack/StreamEncoderFLAC.cpp trunk/OpenMPT/mptrack/StreamEncoderMP3.cpp trunk/OpenMPT/mptrack/StreamEncoderOpus.cpp trunk/OpenMPT/mptrack/StreamEncoderVorbis.cpp Modified: trunk/OpenMPT/mptrack/Mod2wave.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mod2wave.cpp 2013-11-14 19:15:48 UTC (rev 3216) +++ trunk/OpenMPT/mptrack/Mod2wave.cpp 2013-11-14 19:28:25 UTC (rev 3217) @@ -78,7 +78,7 @@ { if(std::getenv("USERNAME")) { - return mpt::String::Decode(std::getenv("USERNAME"), mpt::CharsetLocale); + return mpt::ToWide(mpt::CharsetLocale, std::getenv("USERNAME")); } return std::wstring(); } @@ -87,7 +87,7 @@ static std::wstring GetDefaultYear() //---------------------------------- { - return mpt::String::Decode(CTime::GetCurrentTime().Format("%Y").GetString(), mpt::CharsetLocale); + return mpt::ToWide(CTime::GetCurrentTime().Format("%Y")); } @@ -201,12 +201,12 @@ m_EditYear.SetLimitText(4); - m_EditTitle.SetWindowText(mpt::String::Encode(m_Settings.Tags.title, mpt::CharsetLocale).c_str()); - m_EditAuthor.SetWindowText(mpt::String::Encode(m_Settings.Tags.artist, mpt::CharsetLocale).c_str()); - m_EditURL.SetWindowText(mpt::String::Encode(m_Settings.Tags.url, mpt::CharsetLocale).c_str()); - m_EditAlbum.SetWindowText(mpt::String::Encode(m_Settings.Tags.album, mpt::CharsetLocale).c_str()); - m_EditYear.SetWindowText(mpt::String::Encode(m_Settings.Tags.year, mpt::CharsetLocale).c_str()); - m_EditGenre.SetWindowText(mpt::String::Encode(m_Settings.Tags.genre, mpt::CharsetLocale).c_str()); + m_EditTitle.SetWindowText(mpt::ToCString(m_Settings.Tags.title)); + m_EditAuthor.SetWindowText(mpt::ToCString(m_Settings.Tags.artist)); + m_EditURL.SetWindowText(mpt::ToCString(m_Settings.Tags.url)); + m_EditAlbum.SetWindowText(mpt::ToCString(m_Settings.Tags.album)); + m_EditYear.SetWindowText(mpt::ToCString(m_Settings.Tags.year)); + m_EditGenre.SetWindowText(mpt::ToCString(m_Settings.Tags.genre)); FillTags(); @@ -231,8 +231,8 @@ void CWaveConvert::LoadTags() //--------------------------- { - m_Settings.Tags.title = mpt::String::Decode(m_SndFile.GetTitle(), mpt::CharsetLocale); - m_Settings.Tags.comments = mpt::String::Decode(m_SndFile.songMessage, mpt::CharsetLocale); + m_Settings.Tags.title = mpt::ToWide(mpt::CharsetLocale, m_SndFile.GetTitle()); + m_Settings.Tags.comments = mpt::ToWide(mpt::CharsetLocale, m_SndFile.songMessage); m_Settings.Tags.artist = m_Settings.storedTags.artist; m_Settings.Tags.album = m_Settings.storedTags.album; m_Settings.Tags.trackno = m_Settings.storedTags.trackno; @@ -665,29 +665,29 @@ CString tmp; m_EditTitle.GetWindowText(tmp); - m_Settings.Tags.title = mpt::String::Decode(tmp.GetString(), mpt::CharsetLocale); + m_Settings.Tags.title = mpt::ToWide(tmp); m_EditAuthor.GetWindowText(tmp); - m_Settings.Tags.artist = mpt::String::Decode(tmp.GetString(), mpt::CharsetLocale); + m_Settings.Tags.artist = mpt::ToWide(tmp); m_EditAlbum.GetWindowText(tmp); - m_Settings.Tags.album = mpt::String::Decode(tmp.GetString(), mpt::CharsetLocale); + m_Settings.Tags.album = mpt::ToWide(tmp); m_EditURL.GetWindowText(tmp); - m_Settings.Tags.url = mpt::String::Decode(tmp.GetString(), mpt::CharsetLocale); + m_Settings.Tags.url = mpt::ToWide(tmp); if((encTraits->modesWithFixedGenres & encSettings.Mode) && !encTraits->genres.empty()) { m_CbnGenre.GetWindowText(tmp); - m_Settings.Tags.genre = mpt::String::Decode(tmp.GetString(), mpt::CharsetLocale); + m_Settings.Tags.genre = mpt::ToWide(tmp); } else { m_EditGenre.GetWindowText(tmp); - m_Settings.Tags.genre = mpt::String::Decode(tmp.GetString(), mpt::CharsetLocale); + m_Settings.Tags.genre = mpt::ToWide(tmp); } m_EditYear.GetWindowText(tmp); - m_Settings.Tags.year = mpt::String::Decode(tmp.GetString(), mpt::CharsetLocale); + m_Settings.Tags.year = mpt::ToWide(tmp); if(m_Settings.Tags.year == L"0") { m_Settings.Tags.year = std::wstring(); @@ -695,10 +695,10 @@ if(!m_SndFile.songMessage.empty()) { - m_Settings.Tags.comments = mpt::String::Decode(m_SndFile.songMessage, mpt::CharsetLocale); + m_Settings.Tags.comments = mpt::ToWide(mpt::CharsetLocale, m_SndFile.songMessage); } - m_Settings.Tags.bpm = mpt::String::Decode(mpt::String::Format("%d", (int)m_SndFile.GetCurrentBPM()), mpt::CharsetLocale); + m_Settings.Tags.bpm = mpt::ToWString(m_SndFile.GetCurrentBPM()); SaveTags(); Modified: trunk/OpenMPT/mptrack/StreamEncoderFLAC.cpp =================================================================== --- trunk/OpenMPT/mptrack/StreamEncoderFLAC.cpp 2013-11-14 19:15:48 UTC (rev 3216) +++ trunk/OpenMPT/mptrack/StreamEncoderFLAC.cpp 2013-11-14 19:28:25 UTC (rev 3217) @@ -117,7 +117,7 @@ if(!field.empty() && !data.empty()) { FLAC__StreamMetadata_VorbisComment_Entry entry; - FLAC__metadata_object_vorbiscomment_entry_from_name_value_pair(&entry, field.c_str(), mpt::String::Encode(data, mpt::CharsetUTF8).c_str()); + FLAC__metadata_object_vorbiscomment_entry_from_name_value_pair(&entry, field.c_str(), mpt::To(mpt::CharsetUTF8, data).c_str()); FLAC__metadata_object_vorbiscomment_append_comment(flac_metadata[0], entry, false); } } Modified: trunk/OpenMPT/mptrack/StreamEncoderMP3.cpp =================================================================== --- trunk/OpenMPT/mptrack/StreamEncoderMP3.cpp 2013-11-14 19:15:48 UTC (rev 3216) +++ trunk/OpenMPT/mptrack/StreamEncoderMP3.cpp 2013-11-14 19:28:25 UTC (rev 3217) @@ -181,17 +181,17 @@ s.write(reinterpret_cast<const char*>(&tHeader), sizeof(tHeader)); // Write TIT2 (Title), TCOM / TPE1 (Composer), TALB (Album), TCON (Genre), TYER / TDRC (Date), WXXX (URL), TENC (Encoder), COMM (Comment) - WriteID3v2Frame("TIT2", mpt::String::Encode(tags.title, mpt::CharsetUTF8), s); - WriteID3v2Frame("TPE1", mpt::String::Encode(tags.artist, mpt::CharsetUTF8), s); - WriteID3v2Frame("TCOM", mpt::String::Encode(tags.artist, mpt::CharsetUTF8), s); - WriteID3v2Frame("TALB", mpt::String::Encode(tags.album, mpt::CharsetUTF8), s); - WriteID3v2Frame("TCON", mpt::String::Encode(tags.genre, mpt::CharsetUTF8), s); - //WriteID3v2Frame("TYER", mpt::String::Encode(tags.year, mpt::CharsetUTF8), s); // Deprecated - WriteID3v2Frame("TDRC", mpt::String::Encode(tags.year, mpt::CharsetUTF8), s); - WriteID3v2Frame("TBPM", mpt::String::Encode(tags.bpm, mpt::CharsetUTF8), s); - WriteID3v2Frame("WXXX", mpt::String::Encode(tags.url, mpt::CharsetUTF8), s); - WriteID3v2Frame("TENC", mpt::String::Encode(tags.encoder, mpt::CharsetUTF8), s); - WriteID3v2Frame("COMM", mpt::String::Encode(tags.comments, mpt::CharsetUTF8), s); + WriteID3v2Frame("TIT2", mpt::To(mpt::CharsetUTF8, tags.title), s); + WriteID3v2Frame("TPE1", mpt::To(mpt::CharsetUTF8, tags.artist), s); + WriteID3v2Frame("TCOM", mpt::To(mpt::CharsetUTF8, tags.artist), s); + WriteID3v2Frame("TALB", mpt::To(mpt::CharsetUTF8, tags.album), s); + WriteID3v2Frame("TCON", mpt::To(mpt::CharsetUTF8, tags.genre), s); + //WriteID3v2Frame("TYER", mpt::To(mpt::CharsetUTF8, tags.year), s); // Deprecated + WriteID3v2Frame("TDRC", mpt::To(mpt::CharsetUTF8, tags.year), s); + WriteID3v2Frame("TBPM", mpt::To(mpt::CharsetUTF8, tags.bpm), s); + WriteID3v2Frame("WXXX", mpt::To(mpt::CharsetUTF8, tags.url), s); + WriteID3v2Frame("TENC", mpt::To(mpt::CharsetUTF8, tags.encoder), s); + WriteID3v2Frame("COMM", mpt::To(mpt::CharsetUTF8, tags.comments), s); // Write Padding for(size_t i = 0; i < ID3v2_PADDING; i++) @@ -564,13 +564,13 @@ virtual void WriteMetatags(const FileTags &tags) { // Lame API expects Latin1, which is sad, but we cannot change that. - if(!tags.title.empty()) lame.id3tag_set_title( gfp, mpt::String::Encode(tags.title , mpt::CharsetISO8859_1).c_str()); - if(!tags.artist.empty()) lame.id3tag_set_artist( gfp, mpt::String::Encode(tags.artist , mpt::CharsetISO8859_1).c_str()); - if(!tags.album.empty()) lame.id3tag_set_album( gfp, mpt::String::Encode(tags.album , mpt::CharsetISO8859_1).c_str()); - if(!tags.year.empty()) lame.id3tag_set_year( gfp, mpt::String::Encode(tags.year , mpt::CharsetISO8859_1).c_str()); - if(!tags.comments.empty()) lame.id3tag_set_comment( gfp, mpt::String::Encode(tags.comments, mpt::CharsetISO8859_1).c_str()); - if(!tags.trackno.empty()) lame.id3tag_set_track( gfp, mpt::String::Encode(tags.trackno , mpt::CharsetISO8859_1).c_str()); - if(!tags.genre.empty()) lame.id3tag_set_genre( gfp, mpt::String::Encode(tags.genre , mpt::CharsetISO8859_1).c_str()); + if(!tags.title.empty()) lame.id3tag_set_title( gfp, mpt::To(mpt::CharsetISO8859_1, tags.title ).c_str()); + if(!tags.artist.empty()) lame.id3tag_set_artist( gfp, mpt::To(mpt::CharsetISO8859_1, tags.artist ).c_str()); + if(!tags.album.empty()) lame.id3tag_set_album( gfp, mpt::To(mpt::CharsetISO8859_1, tags.album ).c_str()); + if(!tags.year.empty()) lame.id3tag_set_year( gfp, mpt::To(mpt::CharsetISO8859_1, tags.year ).c_str()); + if(!tags.comments.empty()) lame.id3tag_set_comment( gfp, mpt::To(mpt::CharsetISO8859_1, tags.comments).c_str()); + if(!tags.trackno.empty()) lame.id3tag_set_track( gfp, mpt::To(mpt::CharsetISO8859_1, tags.trackno ).c_str()); + if(!tags.genre.empty()) lame.id3tag_set_genre( gfp, mpt::To(mpt::CharsetISO8859_1, tags.genre ).c_str()); } virtual void WriteInterleaved(size_t count, const float *interleaved) { Modified: trunk/OpenMPT/mptrack/StreamEncoderOpus.cpp =================================================================== --- trunk/OpenMPT/mptrack/StreamEncoderOpus.cpp 2013-11-14 19:15:48 UTC (rev 3216) +++ trunk/OpenMPT/mptrack/StreamEncoderOpus.cpp 2013-11-14 19:28:25 UTC (rev 3217) @@ -332,7 +332,7 @@ { if(!field.empty() && !data.empty()) { - opus_comments.push_back(field + "=" + mpt::String::Encode(data, mpt::CharsetUTF8)); + opus_comments.push_back(field + "=" + mpt::To(mpt::CharsetUTF8, data)); } } public: Modified: trunk/OpenMPT/mptrack/StreamEncoderVorbis.cpp =================================================================== --- trunk/OpenMPT/mptrack/StreamEncoderVorbis.cpp 2013-11-14 19:15:48 UTC (rev 3216) +++ trunk/OpenMPT/mptrack/StreamEncoderVorbis.cpp 2013-11-14 19:28:25 UTC (rev 3217) @@ -294,7 +294,7 @@ { if(!field.empty() && !data.empty()) { - vorbis.vorbis_comment_add_tag(&vc, field.c_str(), mpt::String::Encode(data, mpt::CharsetUTF8).c_str()); + vorbis.vorbis_comment_add_tag(&vc, field.c_str(), mpt::To(mpt::CharsetUTF8, data).c_str()); } } public: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-11-15 14:10:54
|
Revision: 3227 http://sourceforge.net/p/modplug/code/3227 Author: manxorist Date: 2013-11-15 14:10:44 +0000 (Fri, 15 Nov 2013) Log Message: ----------- [Ref] Prevent calling some code paths in the wrong thread or state context by enforcing correct API use with assertions. Modified Paths: -------------- trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mainfrm.h trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/Mptrack.h trunk/OpenMPT/mptrack/Settings.cpp Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2013-11-15 06:27:22 UTC (rev 3226) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2013-11-15 14:10:44 UTC (rev 3227) @@ -187,6 +187,9 @@ m_NotifyTimer = 0; gpSoundDevice = NULL; + m_AudioThreadId = 0; + m_InNotifyHandler = false; + m_bModTreeHasFocus = false; //rewbs.customKeys m_pNoteMapHasFocus = nullptr; //rewbs.customKeys m_pOrderlistHasFocus = nullptr; @@ -596,6 +599,9 @@ void CMainFrame::OnTimerNotify() //------------------------------ { + ASSERT(InGuiThread()); + ASSERT(!InNotifyHandler()); + m_InNotifyHandler = true; Notification PendingNotification; bool found = false; int64 currenttotalsamples = 0; @@ -631,6 +637,8 @@ { OnUpdatePosition(0, (LPARAM)&PendingNotification); } + m_InNotifyHandler = false; + ASSERT(!InNotifyHandler()); } @@ -646,7 +654,9 @@ { CriticalSection cs; ALWAYS_ASSERT(m_pSndFile != nullptr); + m_AudioThreadId = GetCurrentThreadId(); callback.FillAudioBuffer(); + m_AudioThreadId = 0; } @@ -717,6 +727,7 @@ void CMainFrame::AudioRead(const SoundDeviceSettings &settings, std::size_t numFrames, void *buffer) //-------------------------------------------------------------------------------------------------- { + ASSERT(InAudioThread()); OPENMPT_PROFILE_FUNCTION(Profiler::Audio); StereoVuMeterTargetWrapper target(settings.sampleFormat, m_Dither, buffer); CSoundFile::samplecount_t renderedFrames = m_pSndFile->Read(numFrames, target); @@ -742,6 +753,7 @@ //---------------------------------------------------------------------------------------------------------- { MPT_UNREFERENCED_PARAMETER(settings); + ASSERT(InAudioThread()); OPENMPT_PROFILE_FUNCTION(Profiler::Notify); DoNotification(numFrames, streamPosition); } @@ -859,6 +871,7 @@ bool CMainFrame::DoNotification(DWORD dwSamplesRead, int64 streamPosition) //------------------------------------------------------------------------ { + ASSERT(InAudioThread()); if(!m_pSndFile) return false; FlagSet<Notification::Type> notifyType(Notification::Default); Modified: trunk/OpenMPT/mptrack/Mainfrm.h =================================================================== --- trunk/OpenMPT/mptrack/Mainfrm.h 2013-11-15 06:27:22 UTC (rev 3226) +++ trunk/OpenMPT/mptrack/Mainfrm.h 2013-11-15 14:10:44 UTC (rev 3227) @@ -284,6 +284,9 @@ UINT_PTR m_NotifyTimer; Dither m_Dither; + DWORD m_AudioThreadId; + bool m_InNotifyHandler; + static LONG gnLVuMeter, gnRVuMeter; static bool gnClipLeft, gnClipRight; @@ -335,6 +338,10 @@ // from ISoundMessageReceiver void AudioMessage(const std::string &str); + bool InGuiThread() const { return theApp.InGuiThread(); } + bool InAudioThread() const { return GetCurrentThreadId() == m_AudioThreadId; } + bool InNotifyHandler() const { return m_InNotifyHandler; } + bool audioOpenDevice(); bool audioReopenDevice(); void audioCloseDevice(); Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2013-11-15 06:27:22 UTC (rev 3226) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2013-11-15 14:10:44 UTC (rev 3227) @@ -621,7 +621,8 @@ CTrackApp::CTrackApp() //-------------------- - : m_pTrackerDirectories(nullptr) + : m_GuiThreadId(0) + , m_pTrackerDirectories(nullptr) , m_pSettingsIniFile(nullptr) , m_pSettings(nullptr) , m_pTrackerSettings(nullptr) @@ -631,6 +632,8 @@ _CrtSetDebugFillThreshold(0); // Disable buffer filling in secure enhanced CRT functions. #endif + m_GuiThreadId = GetCurrentThreadId(); + ExceptionHandler::Register(); m_bPortableMode = false; @@ -797,6 +800,8 @@ //---------------------------- { + m_GuiThreadId = GetCurrentThreadId(); + // Initialize OLE MFC support AfxOleInit(); // Standard initialization Modified: trunk/OpenMPT/mptrack/Mptrack.h =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.h 2013-11-15 06:27:22 UTC (rev 3226) +++ trunk/OpenMPT/mptrack/Mptrack.h 2013-11-15 14:10:44 UTC (rev 3227) @@ -113,6 +113,8 @@ protected: + DWORD m_GuiThreadId; + TrackerDirectories *m_pTrackerDirectories; IniFileSettingsBackend *m_pSettingsIniFile; SettingsContainer *m_pSettings; @@ -169,6 +171,7 @@ std::vector<CModDoc *>GetOpenDocuments() const; public: + bool InGuiThread() const { return GetCurrentThreadId() == m_GuiThreadId; } CDocTemplate *GetModDocTemplate() const { return m_pModTemplate; } CVstPluginManager *GetPluginManager() const { return m_pPluginManager; } SoundDevicesManager *GetSoundDevicesManager() const { return m_pSoundDevicesManager; } Modified: trunk/OpenMPT/mptrack/Settings.cpp =================================================================== --- trunk/OpenMPT/mptrack/Settings.cpp 2013-11-15 06:27:22 UTC (rev 3226) +++ trunk/OpenMPT/mptrack/Settings.cpp 2013-11-15 14:10:44 UTC (rev 3227) @@ -16,9 +16,8 @@ #include "../common/misc_util.h" #include "../common/StringFixer.h" #include "Mptrack.h" +#include "Mainfrm.h" -#include <shlwapi.h> - #include <algorithm> #include "../common/mptFstream.h" #include <iterator> @@ -199,6 +198,8 @@ SettingValue SettingsContainer::ReadSetting(const SettingPath &path, const SettingValue &def, const SettingMetadata &metadata) const { + ASSERT(theApp.InGuiThread()); + ASSERT(!CMainFrame::GetMainFrame() || (CMainFrame::GetMainFrame() && !CMainFrame::GetMainFrame()->InNotifyHandler())); // This is a slow path, use CachedSetting for stuff that is accessed in notify handler. SettingsMap::iterator entry = map.find(path); if(entry == map.end()) { @@ -210,6 +211,8 @@ void SettingsContainer::WriteSetting(const SettingPath &path, const SettingValue &val) { + ASSERT(theApp.InGuiThread()); + ASSERT(!CMainFrame::GetMainFrame() || (CMainFrame::GetMainFrame() && !CMainFrame::GetMainFrame()->InNotifyHandler())); // This is a slow path, use CachedSetting for stuff that is accessed in notify handler. SettingsMap::iterator entry = map.find(path); if(entry == map.end()) { @@ -229,6 +232,8 @@ void SettingsContainer::RemoveSetting(const SettingPath &path) { + ASSERT(theApp.InGuiThread()); + ASSERT(!CMainFrame::GetMainFrame() || (CMainFrame::GetMainFrame() && !CMainFrame::GetMainFrame()->InNotifyHandler())); // This is a slow path, use CachedSetting for stuff that is accessed in notify handler. map.erase(path); BackendsRemoveSetting(path); } @@ -249,6 +254,8 @@ void SettingsContainer::WriteSettings() { + ASSERT(theApp.InGuiThread()); + ASSERT(!CMainFrame::GetMainFrame() || (CMainFrame::GetMainFrame() && !CMainFrame::GetMainFrame()->InNotifyHandler())); // This is a slow path, use CachedSetting for stuff that is accessed in notify handler. for(SettingsMap::iterator i = map.begin(); i != map.end(); ++i) { if(i->second.IsDirty()) @@ -261,6 +268,8 @@ void SettingsContainer::Flush() { + ASSERT(theApp.InGuiThread()); + ASSERT(!CMainFrame::GetMainFrame() || (CMainFrame::GetMainFrame() && !CMainFrame::GetMainFrame()->InNotifyHandler())); // This is a slow path, use CachedSetting for stuff that is accessed in notify handler. WriteSettings(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2013-11-16 19:02:00
|
Revision: 3239 http://sourceforge.net/p/modplug/code/3239 Author: saga-games Date: 2013-11-16 19:01:51 +0000 (Sat, 16 Nov 2013) Log Message: ----------- [Imp] Tree view: Display unicode file names for open songs. [Fix] CModDoc::SetPathName should include file extension. [Int] Added documentation to CloseMainDialog why it's pointless to use unicode there in ANSI builds. Modified Paths: -------------- trunk/OpenMPT/mptrack/CloseMainDialog.cpp trunk/OpenMPT/mptrack/Moddoc.h trunk/OpenMPT/mptrack/View_tre.cpp Modified: trunk/OpenMPT/mptrack/CloseMainDialog.cpp =================================================================== --- trunk/OpenMPT/mptrack/CloseMainDialog.cpp 2013-11-16 18:09:05 UTC (rev 3238) +++ trunk/OpenMPT/mptrack/CloseMainDialog.cpp 2013-11-16 19:01:51 UTC (rev 3239) @@ -32,7 +32,8 @@ } -// Format a list entry string +// Format a list entry string - apparently list boxes in ANSI windows are ANSI too, so inserted unicode +// strings are converted to ANSI. Thus, we will keep using CStrings here for ANSI builds. CString CloseMainDialog::FormatTitle(const CModDoc *pModDoc, bool fullPath) //------------------------------------------------------------------------- { Modified: trunk/OpenMPT/mptrack/Moddoc.h =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.h 2013-11-16 18:09:05 UTC (rev 3238) +++ trunk/OpenMPT/mptrack/Moddoc.h 2013-11-16 19:01:51 UTC (rev 3239) @@ -410,7 +410,7 @@ // with replacement character but overall the // unicode handling is sane and consistent this // way. - SetTitle(mpt::ToCString(filename.GetFileName().ToWide())); + SetTitle(mpt::ToCString((filename.GetFileName() + filename.GetFileExt()).ToWide())); #endif } MPT_DEPRECATED_PATH const CString& GetPathName() const Modified: trunk/OpenMPT/mptrack/View_tre.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_tre.cpp 2013-11-16 18:09:05 UTC (rev 3238) +++ trunk/OpenMPT/mptrack/View_tre.cpp 2013-11-16 19:01:51 UTC (rev 3239) @@ -678,10 +678,11 @@ void CModTree::UpdateView(ModTreeDocInfo *pInfo, DWORD lHint) -//---------------------------------------------------------- +//----------------------------------------------------------- { TCHAR s[256], stmp[256]; TV_ITEM tvi; + MemsetZero(tvi); const DWORD hintFlagPart = HintFlagPart(lHint); if ((pInfo == nullptr) || (pInfo->pModDoc == nullptr) || IsSampleBrowser()) return; if (!hintFlagPart) return; @@ -691,40 +692,30 @@ // Create headers s[0] = 0; - if ((hintFlagPart & (HINT_MODGENERAL|HINT_MODTYPE)) || (!pInfo->hSong)) + if((hintFlagPart & (HINT_MODGENERAL|HINT_MODTYPE)) || (!pInfo->hSong)) { - _tcscpy(s, pDoc->GetPathNameMpt().GetFileName().ToCString().GetString()); - if (!s[0]) strcpy(s, "untitled"); - MemsetZero(tvi); - } - if (!pInfo->hSong) - { - pInfo->hSong = InsertItem(s, TVI_ROOT, TVI_FIRST); - pInfo->hOrders = InsertItem(_T("Sequence"), IMAGE_FOLDER, IMAGE_FOLDER, pInfo->hSong, TVI_LAST); - pInfo->hPatterns = InsertItem(_T("Patterns"), IMAGE_FOLDER, IMAGE_FOLDER, pInfo->hSong, TVI_LAST); - pInfo->hSamples = InsertItem(_T("Samples"), IMAGE_FOLDER, IMAGE_FOLDER, pInfo->hSong, TVI_LAST); - } - if (hintFlagPart & (HINT_MODGENERAL|HINT_MODTYPE)) - { - tvi.mask |= TVIF_TEXT | TVIF_HANDLE | TVIF_IMAGE | TVIF_SELECTEDIMAGE; - tvi.hItem = pInfo->hSong; - tvi.pszText = stmp; - tvi.cchTextMax = CountOf(stmp); - tvi.iImage = tvi.iSelectedImage = IMAGE_FOLDER; - GetItem(&tvi); - if(tvi.iImage != IMAGE_FOLDER || strcmp(s, stmp)) + // Module folder + sub folders + std::wstring name = pDoc->GetPathNameMpt().GetFileName().ToWide(); + if(name.empty()) name = mpt::PathString::FromWide(mpt::ToWide(pInfo->pModDoc->GetTitle())).SanitizeComponent().ToWide(); + + if(!pInfo->hSong) { - tvi.mask |= TVIF_TEXT | TVIF_HANDLE | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM; - tvi.hItem = pInfo->hSong; - tvi.pszText = s; - tvi.iImage = tvi.iSelectedImage = IMAGE_FOLDER; - tvi.lParam = (LPARAM)pInfo->pModDoc; - SetItem(&tvi); + pInfo->hSong = InsertItem(TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM, name.c_str(), IMAGE_FOLDER, IMAGE_FOLDER, 0, 0, (LPARAM)pInfo->pModDoc, TVI_ROOT, TVI_FIRST); + pInfo->hOrders = InsertItem(_T("Sequence"), IMAGE_FOLDER, IMAGE_FOLDER, pInfo->hSong, TVI_LAST); + pInfo->hPatterns = InsertItem(_T("Patterns"), IMAGE_FOLDER, IMAGE_FOLDER, pInfo->hSong, TVI_LAST); + pInfo->hSamples = InsertItem(_T("Samples"), IMAGE_FOLDER, IMAGE_FOLDER, pInfo->hSong, TVI_LAST); + } else if(hintFlagPart & (HINT_MODGENERAL|HINT_MODTYPE)) + { + if(name != GetItemTextW(tvi.hItem)) + { + SetItemText(pInfo->hSong, name.c_str()); + } } } + if (sndFile.GetModSpecifications().instrumentsMax > 0) { - if (!pInfo->hInstruments) pInfo->hInstruments = InsertItem(_T("Instruments"), IMAGE_FOLDER, IMAGE_FOLDER, pInfo->hSong, TVI_LAST); + if (!pInfo->hInstruments) pInfo->hInstruments = InsertItem(_T("Instruments"), IMAGE_FOLDER, IMAGE_FOLDER, pInfo->hSong, pInfo->hSamples); } else { if (pInfo->hInstruments) @@ -738,31 +729,30 @@ // Add effects if (hintFlagPart & (HINT_MODGENERAL|HINT_MODTYPE|HINT_MODCHANNELS|HINT_MIXPLUGINS)) { - UINT nFx = 0; - DeleteChildren(pInfo->hEffects); - for (UINT iFx=0; iFx<MAX_MIXPLUGINS; iFx++) + if(!pInfo->hEffects) { - const SNDMIXPLUGIN &plugin = sndFile.m_MixPlugins[iFx]; + pInfo->hEffects = InsertItem(_T("Plugins"), IMAGE_FOLDER, IMAGE_FOLDER, pInfo->hSong, pInfo->hInstruments ? pInfo->hInstruments : pInfo->hSamples); + } else + { + DeleteChildren(pInfo->hEffects); + } + bool hasPlugs = false; + for(PLUGINDEX i = 0; i < MAX_MIXPLUGINS; i++) + { + const SNDMIXPLUGIN &plugin = sndFile.m_MixPlugins[i]; if (plugin.IsValidPlugin()) { - if (!pInfo->hEffects) - { - pInfo->hEffects = InsertItem(_T("Plugins"), IMAGE_FOLDER, IMAGE_FOLDER, pInfo->hSong, TVI_LAST); - } - wsprintf(s, "FX%u: %s", iFx + 1, plugin.GetName()); + wsprintf(s, "FX%u: %s", i + 1, plugin.GetName()); int nImage = IMAGE_NOPLUGIN; if(plugin.pMixPlugin != nullptr) nImage = (plugin.pMixPlugin->isInstrument()) ? IMAGE_PLUGININSTRUMENT : IMAGE_EFFECTPLUGIN; - InsertItem(TVIF_TEXT | TVIF_HANDLE | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM, s, nImage, nImage, 0, 0, iFx, pInfo->hEffects, TVI_LAST); - nFx++; + InsertItem(TVIF_TEXT | TVIF_HANDLE | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM, s, nImage, nImage, 0, 0, i, pInfo->hEffects, TVI_LAST); + hasPlugs = true; } } - if (!nFx) + if(!hasPlugs && pInfo->hEffects) { - if (pInfo->hEffects) - { - DeleteItem(pInfo->hEffects); - pInfo->hEffects = NULL; - } + DeleteItem(pInfo->hEffects); + pInfo->hEffects = NULL; } } // Add Orders This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-11-16 19:33:23
|
Revision: 3240 http://sourceforge.net/p/modplug/code/3240 Author: manxorist Date: 2013-11-16 19:33:16 +0000 (Sat, 16 Nov 2013) Log Message: ----------- [Ref] 2 more tiny mpt::PathString cleanups. Modified Paths: -------------- trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/Moddoc.h trunk/OpenMPT/mptrack/TuningDialog.cpp Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2013-11-16 19:01:51 UTC (rev 3239) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2013-11-16 19:33:16 UTC (rev 3240) @@ -236,10 +236,10 @@ #endif EndWaitCursor(); - logcapturer.ShowLog(std::string() - + "File: " + filename.ToLocale() + "\n" - + "Last saved with: " + m_SndFile.madeWithTracker + ", you are using OpenMPT " + MptVersion::str + "\n" - + "\n" + logcapturer.ShowLog(std::wstring() + + L"File: " + filename.ToWide() + L"\n" + + L"Last saved with: " + mpt::ToWide(mpt::CharsetLocale, m_SndFile.madeWithTracker) + L", you are using OpenMPT " + mpt::ToWide(mpt::CharsetUTF8, MptVersion::str) + L"\n" + + L"\n" ); if ((m_SndFile.m_nType == MOD_TYPE_NONE) || (!m_SndFile.GetNumChannels())) return FALSE; @@ -517,7 +517,7 @@ if(success) m_bsInstrumentModified.reset(instr); else - Reporting::Error(("Error while saving\n" + m_SndFile.m_szInstrumentPath[instr].ToLocale() + "!").c_str()); + Reporting::Error(L"Error while saving\n" + m_SndFile.m_szInstrumentPath[instr].ToWide() + L"!"); } } return success; @@ -815,6 +815,17 @@ } +void ScopedLogCapturer::ShowLog(const std::wstring &preamble, bool force) +//----------------------------------------------------------------------- +{ + if(force || m_oldLogMode == LogModeInstantReporting) + { + m_modDoc.ShowLog(preamble, mpt::ToWide(mpt::CharsetLocale, m_title), m_pParent); + m_modDoc.ClearLog(); + } +} + + ScopedLogCapturer::~ScopedLogCapturer() //------------------------------------- { @@ -881,11 +892,18 @@ UINT CModDoc::ShowLog(const std::string &preamble, const std::string &title, CWnd *parent) //---------------------------------------------------------------------------------------- { + return ShowLog(mpt::ToWide(mpt::CharsetLocale, preamble), mpt::ToWide(mpt::CharsetLocale, title), parent); +} + + +UINT CModDoc::ShowLog(const std::wstring &preamble, const std::wstring &title, CWnd *parent) +//------------------------------------------------------------------------------------------ +{ if(!parent) parent = CMainFrame::GetMainFrame(); if(GetLog().size() > 0) { - std::string text = preamble + GetLogString(); - std::string actualTitle = (title.length() == 0) ? std::string(MAINFRAME_TITLE) : title; + std::wstring text = preamble + mpt::ToWide(mpt::CharsetLocale, GetLogString()); + std::wstring actualTitle = (title.length() == 0) ? MAINFRAME_TITLEW : title; switch(GetMaxLogLevel()) { case LogError: Reporting::Error(text.c_str(), actualTitle.c_str(), parent); break; Modified: trunk/OpenMPT/mptrack/Moddoc.h =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.h 2013-11-16 19:01:51 UTC (rev 3239) +++ trunk/OpenMPT/mptrack/Moddoc.h 2013-11-16 19:33:16 UTC (rev 3240) @@ -171,6 +171,7 @@ ~ScopedLogCapturer(); void ShowLog(bool force = false); void ShowLog(const std::string &preamble, bool force = false); + void ShowLog(const std::wstring &preamble, bool force = false); }; @@ -238,6 +239,7 @@ void SetLogMode(LogMode mode) { m_LogMode = mode; } void ClearLog(); UINT ShowLog(const std::string &preamble, const std::string &title = "", CWnd *parent = nullptr); + UINT ShowLog(const std::wstring &preamble, const std::wstring &title = std::wstring(), CWnd *parent = nullptr); UINT ShowLog(const std::string &title = "", CWnd *parent = nullptr) { return ShowLog("", title, parent); } public: Modified: trunk/OpenMPT/mptrack/TuningDialog.cpp =================================================================== --- trunk/OpenMPT/mptrack/TuningDialog.cpp 2013-11-16 19:01:51 UTC (rev 3239) +++ trunk/OpenMPT/mptrack/TuningDialog.cpp 2013-11-16 19:33:16 UTC (rev 3240) @@ -249,7 +249,7 @@ m_EditTuningCollectionVersion.SetWindowText(m_pActiveTuningCollection->GetVersionString().c_str()); m_EditTuningCollectionEditMask.SetWindowText(m_pActiveTuningCollection->GetEditMaskString().c_str()); m_EditTuningCollectionItemNum.SetWindowText(Stringify(m_pActiveTuningCollection->GetNumTunings()).c_str()); - m_EditTuningCollectionPath.SetWindowText(m_pActiveTuningCollection->GetSaveFilePath().ToCString()); + ::SetWindowTextW(m_EditTuningCollectionPath.m_hWnd, m_pActiveTuningCollection->GetSaveFilePath().ToWide().c_str()); } //<-- Updating tuning collection part This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2013-11-16 20:08:17
|
Revision: 3242 http://sourceforge.net/p/modplug/code/3242 Author: saga-games Date: 2013-11-16 20:08:07 +0000 (Sat, 16 Nov 2013) Log Message: ----------- [Ref] Make plugin selection dialog name filter string unicode. [Imp] Plugin selection dialog: Up/Down keys can be used to select a plugin while the name filter is focussed. Modified Paths: -------------- trunk/OpenMPT/mptrack/SelectPluginDialog.cpp trunk/OpenMPT/mptrack/SelectPluginDialog.h Modified: trunk/OpenMPT/mptrack/SelectPluginDialog.cpp =================================================================== --- trunk/OpenMPT/mptrack/SelectPluginDialog.cpp 2013-11-16 19:42:46 UTC (rev 3241) +++ trunk/OpenMPT/mptrack/SelectPluginDialog.cpp 2013-11-16 20:08:07 UTC (rev 3242) @@ -40,7 +40,6 @@ { CDialog::DoDataExchange(pDX); DDX_Control(pDX, IDC_TREE1, m_treePlugins); - DDX_Text(pDX, IDC_NAMEFILTER, m_sNameFilter); } @@ -230,11 +229,45 @@ } +BOOL CSelectPluginDlg::PreTranslateMessage(MSG *pMsg) +//--------------------------------------------------- +{ + // Use up/down keys to navigate in tree view, even if search field is focussed. + if(pMsg != nullptr && pMsg->message == WM_KEYDOWN && (pMsg->wParam == VK_UP || pMsg->wParam == VK_DOWN) && GetFocus() != &m_treePlugins) + { + HTREEITEM selItem = m_treePlugins.GetSelectedItem(); + if(selItem == nullptr) + { + selItem = m_treePlugins.GetRootItem(); + } + while((selItem = m_treePlugins.GetNextItem(selItem, pMsg->wParam == VK_UP ? TVGN_PREVIOUSVISIBLE : TVGN_NEXTVISIBLE)) != nullptr) + { + int nImage, nSelectedImage; + m_treePlugins.GetItemImage(selItem, nImage, nSelectedImage); + if(nImage != IMAGE_FOLDER) + { + m_treePlugins.SelectItem(selItem); + m_treePlugins.EnsureVisible(selItem); + return TRUE; + } + } + return TRUE; + } + + return CDialog::PreTranslateMessage(pMsg); +} + + void CSelectPluginDlg::OnNameFilterChanged() //------------------------------------------ { - GetDlgItem(IDC_NAMEFILTER)->GetWindowText(m_sNameFilter); - m_sNameFilter = m_sNameFilter.MakeLower(); + // Update name filter text + HWND hwnd = GetDlgItem(IDC_NAMEFILTER)->m_hWnd; + int len = GetWindowTextLengthW(hwnd); + m_nameFilter.resize(len); + GetWindowTextW(hwnd, &m_nameFilter[0], len + 1); + for(int i = 0; i < len; i++) m_nameFilter[i] = ::towlower(m_nameFilter[i]); + UpdatePluginsList(); } @@ -280,7 +313,7 @@ HTREEITEM currentPlug = noPlug; bool foundCurrentPlug = false; - const bool nameFilterActive = !m_sNameFilter.IsEmpty(); + const bool nameFilterActive = !m_nameFilter.empty(); if(pManager) { bool first = true; @@ -291,8 +324,9 @@ if(nameFilterActive) { // Apply name filter - CString displayName = p->libraryName.ToCString(); - if (displayName.MakeLower().Find(m_sNameFilter) == -1) + std::wstring displayName = p->libraryName.ToWide(); + for(size_t i = 0; i < displayName.length(); i++) displayName[i] = ::towlower(displayName[i]); + if(displayName.find(m_nameFilter, 0) == displayName.npos) { p = p->pNext; continue; @@ -363,15 +397,13 @@ } m_treePlugins.SetRedraw(TRUE); - if(currentPlug) + + if(!nameFilterActive || currentPlug != noPlug) { - if(!nameFilterActive || currentPlug != noPlug) - { - m_treePlugins.SelectItem(currentPlug); - } - m_treePlugins.SetItemState(currentPlug, TVIS_BOLD, TVIS_BOLD); - m_treePlugins.EnsureVisible(currentPlug); + m_treePlugins.SelectItem(currentPlug); } + m_treePlugins.SetItemState(currentPlug, TVIS_BOLD, TVIS_BOLD); + m_treePlugins.EnsureVisible(currentPlug); } Modified: trunk/OpenMPT/mptrack/SelectPluginDialog.h =================================================================== --- trunk/OpenMPT/mptrack/SelectPluginDialog.h 2013-11-16 19:42:46 UTC (rev 3241) +++ trunk/OpenMPT/mptrack/SelectPluginDialog.h 2013-11-16 20:08:07 UTC (rev 3242) @@ -25,7 +25,7 @@ SNDMIXPLUGIN *m_pPlugin; CModDoc *m_pModDoc; CTreeCtrlW m_treePlugins; - CString m_sNameFilter; + std::wstring m_nameFilter; HTREEITEM AddTreeItem(const WCHAR *title, int image, bool sort, HTREEITEM hParent = TVI_ROOT, LPARAM lParam = NULL); @@ -39,6 +39,7 @@ virtual BOOL OnInitDialog(); virtual void OnOK(); virtual void OnCancel(); + virtual BOOL PreTranslateMessage(MSG *pMsg); afx_msg void OnAddPlugin(); afx_msg void OnRemovePlugin(); afx_msg void OnNameFilterChanged(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2013-11-17 23:42:27
|
Revision: 3256 http://sourceforge.net/p/modplug/code/3256 Author: saga-games Date: 2013-11-17 23:42:19 +0000 (Sun, 17 Nov 2013) Log Message: ----------- [Fix] Sound bank information didn't show complete paths since unicode path conversion. Modified Paths: -------------- trunk/OpenMPT/mptrack/View_tre.cpp trunk/OpenMPT/mptrack/dlg_misc.cpp trunk/OpenMPT/mptrack/dlg_misc.h Modified: trunk/OpenMPT/mptrack/View_tre.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_tre.cpp 2013-11-17 22:13:33 UTC (rev 3255) +++ trunk/OpenMPT/mptrack/View_tre.cpp 2013-11-17 23:42:19 UTC (rev 3256) @@ -3279,7 +3279,7 @@ if(modItem.type == MODITEM_DLSBANK_FOLDER && modItem.val1 < CTrackApp::gpDLSBanks.size() && CTrackApp::gpDLSBanks[modItem.val1]) { - CSoundBankProperties dlg(CTrackApp::gpDLSBanks[modItem.val1], this); + CSoundBankProperties dlg(*CTrackApp::gpDLSBanks[modItem.val1], this); dlg.DoModal(); } } Modified: trunk/OpenMPT/mptrack/dlg_misc.cpp =================================================================== --- trunk/OpenMPT/mptrack/dlg_misc.cpp 2013-11-17 22:13:33 UTC (rev 3255) +++ trunk/OpenMPT/mptrack/dlg_misc.cpp 2013-11-17 23:42:19 UTC (rev 3256) @@ -574,33 +574,32 @@ //////////////////////////////////////////////////////////////////////////////// // Sound Bank Information -CSoundBankProperties::CSoundBankProperties(CDLSBank *pBank, CWnd *parent):CDialog(IDD_SOUNDBANK_INFO, parent) -//----------------------------------------------------------------------------------------------------------- +CSoundBankProperties::CSoundBankProperties(CDLSBank &bank, CWnd *parent) : CDialog(IDD_SOUNDBANK_INFO, parent) +//------------------------------------------------------------------------------------------------------------ { SOUNDBANKINFO bi; m_szInfo[0] = 0; - if (pBank) + + fileName = bank.GetFileName(); + + UINT nType = bank.GetBankInfo(&bi); + wsprintf(&m_szInfo[strlen(m_szInfo)], "Type:\t%s\r\n", (nType & SOUNDBANK_TYPE_SF2) ? "Sound Font (SF2)" : "Downloadable Sound (DLS)"); + if (bi.szBankName[0]) + wsprintf(&m_szInfo[strlen(m_szInfo)], "Name:\t\"%s\"\r\n", bi.szBankName); + if (bi.szDescription[0]) + wsprintf(&m_szInfo[strlen(m_szInfo)], "\t\"%s\"\r\n", bi.szDescription); + if (bi.szCopyRight[0]) + wsprintf(&m_szInfo[strlen(m_szInfo)], "Copyright:\t\"%s\"\r\n", bi.szCopyRight); + if (bi.szEngineer[0]) + wsprintf(&m_szInfo[strlen(m_szInfo)], "Author:\t\"%s\"\r\n", bi.szEngineer); + if (bi.szSoftware[0]) + wsprintf(&m_szInfo[strlen(m_szInfo)], "Software:\t\"%s\"\r\n", bi.szSoftware); + // Last lines: comments + if (bi.szComments[0]) { - UINT nType = pBank->GetBankInfo(&bi); - wsprintf(m_szInfo, "File:\t\"%s\"\r\n", pBank->GetFileName()); - wsprintf(&m_szInfo[strlen(m_szInfo)], "Type:\t%s\r\n", (nType & SOUNDBANK_TYPE_SF2) ? "Sound Font (SF2)" : "Downloadable Sound (DLS)"); - if (bi.szBankName[0]) - wsprintf(&m_szInfo[strlen(m_szInfo)], "Name:\t\"%s\"\r\n", bi.szBankName); - if (bi.szDescription[0]) - wsprintf(&m_szInfo[strlen(m_szInfo)], "\t\"%s\"\r\n", bi.szDescription); - if (bi.szCopyRight[0]) - wsprintf(&m_szInfo[strlen(m_szInfo)], "Copyright:\t\"%s\"\r\n", bi.szCopyRight); - if (bi.szEngineer[0]) - wsprintf(&m_szInfo[strlen(m_szInfo)], "Author:\t\"%s\"\r\n", bi.szEngineer); - if (bi.szSoftware[0]) - wsprintf(&m_szInfo[strlen(m_szInfo)], "Software:\t\"%s\"\r\n", bi.szSoftware); - // Last lines: comments - if (bi.szComments[0]) - { - strncat(m_szInfo, "\r\nComments:\r\n", strlen(m_szInfo) - sizeof(m_szInfo) - 1); - strncat(m_szInfo, bi.szComments, strlen(m_szInfo) - sizeof(m_szInfo) - 1); - } + strncat(m_szInfo, "\r\nComments:\r\n", strlen(m_szInfo) - sizeof(m_szInfo) - 1); + strncat(m_szInfo, bi.szComments, strlen(m_szInfo) - sizeof(m_szInfo) - 1); } } @@ -610,6 +609,7 @@ { CDialog::OnInitDialog(); SetDlgItemText(IDC_EDIT1, m_szInfo); + SetWindowTextW(m_hWnd, (fileName.AsNative() + L" - Sound Bank Information").c_str()); return TRUE; } Modified: trunk/OpenMPT/mptrack/dlg_misc.h =================================================================== --- trunk/OpenMPT/mptrack/dlg_misc.h 2013-11-17 22:13:33 UTC (rev 3255) +++ trunk/OpenMPT/mptrack/dlg_misc.h 2013-11-17 23:42:19 UTC (rev 3256) @@ -111,9 +111,10 @@ { protected: CHAR m_szInfo[4096]; + mpt::PathString fileName; public: - CSoundBankProperties(CDLSBank *pBank, CWnd *parent=NULL); + CSoundBankProperties(CDLSBank &bank, CWnd *parent = nullptr); virtual BOOL OnInitDialog(); }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-11-18 00:05:17
|
Revision: 3257 http://sourceforge.net/p/modplug/code/3257 Author: manxorist Date: 2013-11-18 00:05:11 +0000 (Mon, 18 Nov 2013) Log Message: ----------- [Fix] Make File/Save work with unicode filenames. Modified Paths: -------------- trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/Moddoc.h trunk/OpenMPT/mptrack/Mptrack.h Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2013-11-17 23:42:19 UTC (rev 3256) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2013-11-18 00:05:11 UTC (rev 3257) @@ -551,6 +551,30 @@ } +#ifndef UNICODE +BOOL CModDoc::DoFileSave() +//------------------------ +{ + // Completely replaces MFC implementation. + DWORD dwAttrib = GetFileAttributesW(mpt::PathString::TunnelOutofCString(m_strPathName).AsNative().c_str()); + if(dwAttrib & FILE_ATTRIBUTE_READONLY) + { + if(!DoSave(mpt::PathString())) + { + return FALSE; + } + } else + { + if(!DoSave(mpt::PathString::TunnelOutofCString(m_strPathName))) + { + return FALSE; + } + } + return TRUE; +} +#endif + + BOOL CModDoc::DoSave(const mpt::PathString &filename, BOOL) //--------------------------------------------------------- { Modified: trunk/OpenMPT/mptrack/Moddoc.h =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.h 2013-11-17 23:42:19 UTC (rev 3256) +++ trunk/OpenMPT/mptrack/Moddoc.h 2013-11-18 00:05:11 UTC (rev 3257) @@ -430,6 +430,12 @@ bool SaveInstrument(INSTRUMENTINDEX instr); // -! NEW_FEATURE#0023 +#ifndef UNICODE + // MFC checks for writeable filename in there and issues SaveAs dialog if not. + // This fails for our utf8-in-CString hack. + virtual BOOL DoFileSave(); +#endif + MPT_DEPRECATED_PATH virtual BOOL DoSave(LPCSTR lpszPathName, BOOL bSaveAs=TRUE) { return DoSave(lpszPathName ? mpt::PathString::TunnelOutofCString(lpszPathName) : mpt::PathString(), bSaveAs); Modified: trunk/OpenMPT/mptrack/Mptrack.h =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.h 2013-11-17 23:42:19 UTC (rev 3256) +++ trunk/OpenMPT/mptrack/Mptrack.h 2013-11-18 00:05:11 UTC (rev 3257) @@ -103,6 +103,7 @@ // CModDoc: // CDocument::GetPathName // CDocument::SetPathName +// CDocument::DoFileSave // CDocument::DoSave // CDocument::OnOpenDocument // CDocument::OnSaveDocument This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-11-18 00:22:59
|
Revision: 3258 http://sourceforge.net/p/modplug/code/3258 Author: manxorist Date: 2013-11-18 00:22:49 +0000 (Mon, 18 Nov 2013) Log Message: ----------- [Ref] settings: Add Forget(SettingPath) method which forgets the specified path from the loaded settings map but does not remove the path from the backends. Modified Paths: -------------- trunk/OpenMPT/mptrack/Settings.cpp trunk/OpenMPT/mptrack/Settings.h Modified: trunk/OpenMPT/mptrack/Settings.cpp =================================================================== --- trunk/OpenMPT/mptrack/Settings.cpp 2013-11-18 00:05:11 UTC (rev 3257) +++ trunk/OpenMPT/mptrack/Settings.cpp 2013-11-18 00:22:49 UTC (rev 3258) @@ -230,6 +230,13 @@ } } +void SettingsContainer::ForgetSetting(const SettingPath &path) +{ + ASSERT(theApp.InGuiThread()); + ASSERT(!CMainFrame::GetMainFrame() || (CMainFrame::GetMainFrame() && !CMainFrame::GetMainFrame()->InNotifyHandler())); // This is a slow path, use CachedSetting for stuff that is accessed in notify handler. + map.erase(path); +} + void SettingsContainer::RemoveSetting(const SettingPath &path) { ASSERT(theApp.InGuiThread()); Modified: trunk/OpenMPT/mptrack/Settings.h =================================================================== --- trunk/OpenMPT/mptrack/Settings.h 2013-11-18 00:05:11 UTC (rev 3257) +++ trunk/OpenMPT/mptrack/Settings.h 2013-11-18 00:22:49 UTC (rev 3258) @@ -503,6 +503,7 @@ void NotifyListeners(const SettingPath &path); SettingValue ReadSetting(const SettingPath &path, const SettingValue &def, const SettingMetadata &metadata) const; void WriteSetting(const SettingPath &path, const SettingValue &val); + void ForgetSetting(const SettingPath &path); void RemoveSetting(const SettingPath &path); private: SettingsContainer(const SettingsContainer &other); // disable @@ -540,6 +541,18 @@ { WriteSetting(SettingPath(section, key), ToSettingValue<T>(val)); } + void Forget(const SettingPath &path) + { + ForgetSetting(path); + } + void Forget(const std::wstring §ion, const std::wstring &key) + { + ForgetSetting(SettingPath(section, key)); + } + void Forget(const std::string §ion, const std::string &key) + { + ForgetSetting(SettingPath(section, key)); + } void Remove(const SettingPath &path) { RemoveSetting(path); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-11-18 00:32:37
|
Revision: 3259 http://sourceforge.net/p/modplug/code/3259 Author: manxorist Date: 2013-11-18 00:32:28 +0000 (Mon, 18 Nov 2013) Log Message: ----------- [Ref] settings: Forget ultrasound patches related setting paths after importing them from mptrack.ini, so they do not clutter the advanced options dialog. Modified Paths: -------------- trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/Mptrack.h Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2013-11-18 00:22:49 UTC (rev 3258) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2013-11-18 00:32:28 UTC (rev 3259) @@ -322,13 +322,14 @@ return ImportMidiConfig(file); } -BOOL CTrackApp::ImportMidiConfig(SettingsContainer &file) -//------------------------------------------------------- +BOOL CTrackApp::ImportMidiConfig(SettingsContainer &file, bool forgetSettings) +//---------------------------------------------------------------------------- { TCHAR s[_MAX_PATH]; mpt::PathString UltraSndPath; UltraSndPath = file.Read<mpt::PathString>("Ultrasound", "PatchDir", mpt::PathString()); + if(forgetSettings) file.Forget("Ultrasound", "PatchDir"); if(UltraSndPath == MPT_PATHSTRING(".\\")) UltraSndPath = mpt::PathString(); if(UltraSndPath.empty()) { @@ -341,16 +342,19 @@ mpt::PathString filename; wsprintf(s, (iMidi < 128) ? _T("Midi%d") : _T("Perc%d"), iMidi & 0x7f); filename = file.Read<mpt::PathString>("Midi Library", s, mpt::PathString()); + if(forgetSettings) file.Forget("Midi Library", s); // Check for ULTRASND.INI if(filename.empty()) { LPCSTR pszSection = (iMidi < 128) ? _T("Melodic Patches") : _T("Drum Patches"); wsprintf(s, _T("%d"), iMidi & 0x7f); filename = file.Read<mpt::PathString>(pszSection, s, mpt::PathString()); + if(forgetSettings) file.Forget(pszSection, s); if(filename.empty()) { pszSection = (iMidi < 128) ? _T("Melodic Bank 0") : _T("Drum Bank 0"); filename = file.Read<mpt::PathString>(pszSection, s, mpt::PathString()); + if(forgetSettings) file.Forget(pszSection, s); } if(!filename.empty()) { @@ -849,7 +853,7 @@ AddDocTemplate(m_pModTemplate); // Load Midi Library - ImportMidiConfig(theApp.GetSettings()); + ImportMidiConfig(theApp.GetSettings(), true); // create main MDI Frame window CMainFrame* pMainFrame = new CMainFrame(/*cmdInfo.m_csExtension*/); Modified: trunk/OpenMPT/mptrack/Mptrack.h =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.h 2013-11-18 00:22:49 UTC (rev 3258) +++ trunk/OpenMPT/mptrack/Mptrack.h 2013-11-18 00:32:28 UTC (rev 3259) @@ -217,7 +217,7 @@ static MIDILIBSTRUCT &GetMidiLibrary() { return midiLibrary; } static BOOL ImportMidiConfig(const mpt::PathString &filename, BOOL bNoWarning=FALSE); static BOOL ExportMidiConfig(const mpt::PathString &filename); - static BOOL ImportMidiConfig(SettingsContainer &file); + static BOOL ImportMidiConfig(SettingsContainer &file, bool forgetSettings = false); static BOOL ExportMidiConfig(SettingsContainer &file); static void RegisterExtensions(); static BOOL LoadDefaultDLSBanks(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2013-11-18 18:40:27
|
Revision: 3263 http://sourceforge.net/p/modplug/code/3263 Author: saga-games Date: 2013-11-18 18:40:19 +0000 (Mon, 18 Nov 2013) Log Message: ----------- [Fix] Tree view: Less flickering when updating tree view (broke in rev.3239) Modified Paths: -------------- trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/Mptrack.h trunk/OpenMPT/mptrack/View_tre.cpp Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2013-11-18 16:54:35 UTC (rev 3262) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2013-11-18 18:40:19 UTC (rev 3263) @@ -426,23 +426,14 @@ { mpt::PathString filename; - CString storedVersion = theApp.GetSettings().Read<CString>("Version", "Version", ""); - //If version number stored in INI is 1.17.02.40 or later, load DLS from INI file. - //Else load DLS from Registry - if (storedVersion >= "1.17.02.40") + UINT numBanks = theApp.GetSettings().Read<int32>("DLS Banks", "NumBanks", 0); + for(size_t i = 0; i < numBanks; i++) { - CHAR s[MAX_PATH]; - UINT numBanks = theApp.GetSettings().Read<int32>("DLS Banks", "NumBanks", 0); - for(size_t i = 0; i < numBanks; i++) - { - wsprintf(s, _T("Bank%d"), i + 1); - mpt::PathString path = theApp.GetSettings().Read<mpt::PathString>("DLS Banks", s, mpt::PathString()); - path = theApp.RelativePathToAbsolute(path); - AddDLSBank(path); - } - } else - { - LoadRegistryDLS(); + char s[16]; + wsprintf(s, _T("Bank%d"), i + 1); + mpt::PathString path = theApp.GetSettings().Read<mpt::PathString>("DLS Banks", s, mpt::PathString()); + path = theApp.RelativePathToAbsolute(path); + AddDLSBank(path); } SaveDefaultDLSBanks(); // This will avoid a crash the next time if we crash while loading the bank @@ -480,35 +471,7 @@ return TRUE; } -void CTrackApp::LoadRegistryDLS() -//------------------------------- -{ - WCHAR szFileNameX[MAX_PATH]; - HKEY keyX; - if(RegOpenKeyExW(HKEY_CURRENT_USER, L"Software\\Olivier Lapicque\\ModPlug Tracker\\DLS Banks", 0, KEY_READ, &keyX) == ERROR_SUCCESS) - { - DWORD dwRegType = REG_DWORD; - DWORD dwSize = sizeof(DWORD); - DWORD d = 0; - if(RegQueryValueExW(keyX, L"NumBanks", NULL, &dwRegType, (LPBYTE)&d, &dwSize) == ERROR_SUCCESS) - { - CHAR s[64]; - for (UINT i=0; i<d; i++) - { - wsprintf(s, "Bank%d", i+1); - szFileNameX[0] = 0; - dwRegType = REG_SZ; - dwSize = sizeof(szFileNameX); - RegQueryValueExW(keyX, mpt::ToWide(mpt::CharsetLocale, s).c_str(), NULL, &dwRegType, (LPBYTE)szFileNameX, &dwSize); - AddDLSBank(mpt::PathString::FromNative(szFileNameX)); - } - } - RegCloseKey(keyX); - } -} - - BOOL CTrackApp::SaveDefaultDLSBanks() //----------------------------------- { Modified: trunk/OpenMPT/mptrack/Mptrack.h =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.h 2013-11-18 16:54:35 UTC (rev 3262) +++ trunk/OpenMPT/mptrack/Mptrack.h 2013-11-18 18:40:19 UTC (rev 3263) @@ -312,9 +312,6 @@ DECLARE_MESSAGE_MAP() protected: - static void LoadRegistryDLS(); - -protected: BOOL InitializeDXPlugins(); BOOL UninitializeDXPlugins(); Modified: trunk/OpenMPT/mptrack/View_tre.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_tre.cpp 2013-11-18 16:54:35 UTC (rev 3262) +++ trunk/OpenMPT/mptrack/View_tre.cpp 2013-11-18 18:40:19 UTC (rev 3263) @@ -695,7 +695,7 @@ if((hintFlagPart & (HINT_MODGENERAL|HINT_MODTYPE)) || (!pInfo->hSong)) { // Module folder + sub folders - std::wstring name = pDoc->GetPathNameMpt().GetFileName().ToWide(); + std::wstring name = pDoc->GetPathNameMpt().GetFullFileName().ToWide(); if(name.empty()) name = mpt::PathString::FromCStringSilent(pInfo->pModDoc->GetTitle()).SanitizeComponent().ToWide(); if(!pInfo->hSong) @@ -715,12 +715,11 @@ if (sndFile.GetModSpecifications().instrumentsMax > 0) { - if (!pInfo->hInstruments) pInfo->hInstruments = InsertItem(_T("Instruments"), IMAGE_FOLDER, IMAGE_FOLDER, pInfo->hSong, pInfo->hSamples); + if(!pInfo->hInstruments) pInfo->hInstruments = InsertItem(_T("Instruments"), IMAGE_FOLDER, IMAGE_FOLDER, pInfo->hSong, pInfo->hSamples); } else { - if (pInfo->hInstruments) + if(pInfo->hInstruments) { - //DeleteChildren(pInfo->hInstruments); DeleteItem(pInfo->hInstruments); pInfo->hInstruments = NULL; } @@ -729,19 +728,22 @@ // Add effects if (hintFlagPart & (HINT_MODGENERAL|HINT_MODTYPE|HINT_MODCHANNELS|HINT_MIXPLUGINS)) { - if(!pInfo->hEffects) - { - pInfo->hEffects = InsertItem(_T("Plugins"), IMAGE_FOLDER, IMAGE_FOLDER, pInfo->hSong, pInfo->hInstruments ? pInfo->hInstruments : pInfo->hSamples); - } else - { - DeleteChildren(pInfo->hEffects); - } bool hasPlugs = false; for(PLUGINDEX i = 0; i < MAX_MIXPLUGINS; i++) { const SNDMIXPLUGIN &plugin = sndFile.m_MixPlugins[i]; - if (plugin.IsValidPlugin()) + if(plugin.IsValidPlugin()) { + // Now we can be sure that we want to create this folder. + if(!pInfo->hEffects) + { + pInfo->hEffects = InsertItem(_T("Plugins"), IMAGE_FOLDER, IMAGE_FOLDER, pInfo->hSong, pInfo->hInstruments ? pInfo->hInstruments : pInfo->hSamples); + } else if(!hasPlugs) + { + // Delete previously existing items + DeleteChildren(pInfo->hEffects); + } + wsprintf(s, "FX%u: %s", i + 1, plugin.GetName()); int nImage = IMAGE_NOPLUGIN; if(plugin.pMixPlugin != nullptr) nImage = (plugin.pMixPlugin->isInstrument()) ? IMAGE_PLUGININSTRUMENT : IMAGE_EFFECTPLUGIN; @@ -752,7 +754,7 @@ if(!hasPlugs && pInfo->hEffects) { DeleteItem(pInfo->hEffects); - pInfo->hEffects = NULL; + pInfo->hEffects = nullptr; } } // Add Orders @@ -1540,10 +1542,7 @@ if (!m_hInsLib) return; if (!IsSampleBrowser()) { - while ((h = GetChildItem(m_hInsLib)) != NULL) - { - DeleteItem(h); - } + DeleteChildren(m_hInsLib); } else { while ((h = GetNextItem(m_hInsLib, TVGN_NEXT)) != NULL) @@ -3360,14 +3359,12 @@ void CModTree::DeleteChildren(HTREEITEM hItem) //-------------------------------------------- { - if(hItem != nullptr && ItemHasChildren(hItem)) + if(hItem != nullptr) { - HTREEITEM hChildItem = GetChildItem(hItem); - while(hChildItem != nullptr) + HTREEITEM hChildItem; + while((hChildItem = GetChildItem(hItem)) != nullptr) { - HTREEITEM hNextItem = GetNextSiblingItem(hChildItem); DeleteItem(hChildItem); - hChildItem = hNextItem; } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2013-11-19 16:44:55
|
Revision: 3270 http://sourceforge.net/p/modplug/code/3270 Author: saga-games Date: 2013-11-19 16:44:45 +0000 (Tue, 19 Nov 2013) Log Message: ----------- [Ref] Simplify treeview document info handling a bit (index into DocInfo vector is now stored in the module's folder item data) Modified Paths: -------------- trunk/OpenMPT/mptrack/View_tre.cpp trunk/OpenMPT/mptrack/View_tre.h Modified: trunk/OpenMPT/mptrack/View_tre.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_tre.cpp 2013-11-19 03:43:48 UTC (rev 3269) +++ trunk/OpenMPT/mptrack/View_tre.cpp 2013-11-19 16:44:45 UTC (rev 3270) @@ -375,11 +375,9 @@ { return; } - pInfo->nSeqSel = SEQUENCEINDEX_INVALID; - pInfo->nOrdSel = ORDERINDEX_INVALID; DocInfo.push_back(pInfo); - UpdateView(pInfo, HINT_MODTYPE); + UpdateView(*pInfo, HINT_MODTYPE); if (pInfo->hSong) { Expand(pInfo->hSong, TVE_EXPAND); @@ -393,28 +391,37 @@ //--------------------------------------------- { std::vector<ModTreeDocInfo *>::iterator iter; - for (iter = DocInfo.begin(); iter != DocInfo.end(); iter++) + for(iter = DocInfo.begin(); iter != DocInfo.end(); iter++) { if((*iter)->pModDoc == pModDoc) { DeleteItem((*iter)->hSong); delete (*iter); DocInfo.erase(iter); - return; + break; } } + // Refresh all item IDs + for(size_t i = 0; i < DocInfo.size(); i++) + { + SetItemData(DocInfo[i]->hSong, i); + } } // Get CModDoc that is associated with a tree item -CModDoc *CModTree::GetDocumentFromItem(HTREEITEM hItem) -//----------------------------------------------------- +ModTreeDocInfo *CModTree::GetDocumentInfoFromItem(HTREEITEM hItem) +//---------------------------------------------------------------- { hItem = GetParentRootItem(hItem); - if (hItem != nullptr) + if(hItem != nullptr) { // Root item has moddoc pointer - return (CModDoc *)GetItemData(hItem); + const size_t doc = GetItemData(hItem); + if(doc < DocInfo.size() && hItem == DocInfo[doc]->hSong) + { + return DocInfo[doc]; + } } return nullptr; } @@ -677,54 +684,54 @@ } -void CModTree::UpdateView(ModTreeDocInfo *pInfo, DWORD lHint) -//----------------------------------------------------------- +void CModTree::UpdateView(ModTreeDocInfo &info, DWORD lHint) +//---------------------------------------------------------- { TCHAR s[256], stmp[256]; TV_ITEM tvi; MemsetZero(tvi); const DWORD hintFlagPart = HintFlagPart(lHint); - if ((pInfo == nullptr) || (pInfo->pModDoc == nullptr) || IsSampleBrowser()) return; + if (info.pModDoc == nullptr || IsSampleBrowser()) return; if (!hintFlagPart) return; - const CModDoc *pDoc = pInfo->pModDoc; + const CModDoc *pDoc = info.pModDoc; const CSoundFile &sndFile = pDoc->GetrSoundFile(); // Create headers s[0] = 0; - if((hintFlagPart & (HINT_MODGENERAL|HINT_MODTYPE)) || (!pInfo->hSong)) + if((hintFlagPart & (HINT_MODGENERAL|HINT_MODTYPE)) || (!info.hSong)) { // Module folder + sub folders std::wstring name = pDoc->GetPathNameMpt().GetFullFileName().ToWide(); - if(name.empty()) name = mpt::PathString::FromCStringSilent(pInfo->pModDoc->GetTitle()).SanitizeComponent().ToWide(); + if(name.empty()) name = mpt::PathString::FromCStringSilent(info.pModDoc->GetTitle()).SanitizeComponent().ToWide(); - if(!pInfo->hSong) + if(!info.hSong) { - pInfo->hSong = InsertItem(TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM, name.c_str(), IMAGE_FOLDER, IMAGE_FOLDER, 0, 0, (LPARAM)pInfo->pModDoc, TVI_ROOT, TVI_FIRST); - pInfo->hOrders = InsertItem(_T("Sequence"), IMAGE_FOLDER, IMAGE_FOLDER, pInfo->hSong, TVI_LAST); - pInfo->hPatterns = InsertItem(_T("Patterns"), IMAGE_FOLDER, IMAGE_FOLDER, pInfo->hSong, TVI_LAST); - pInfo->hSamples = InsertItem(_T("Samples"), IMAGE_FOLDER, IMAGE_FOLDER, pInfo->hSong, TVI_LAST); + info.hSong = InsertItem(TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM, name.c_str(), IMAGE_FOLDER, IMAGE_FOLDER, 0, 0, (LPARAM)(DocInfo.size() - 1), TVI_ROOT, TVI_FIRST); + info.hOrders = InsertItem(_T("Sequence"), IMAGE_FOLDER, IMAGE_FOLDER, info.hSong, TVI_LAST); + info.hPatterns = InsertItem(_T("Patterns"), IMAGE_FOLDER, IMAGE_FOLDER, info.hSong, TVI_LAST); + info.hSamples = InsertItem(_T("Samples"), IMAGE_FOLDER, IMAGE_FOLDER, info.hSong, TVI_LAST); } else if(hintFlagPart & (HINT_MODGENERAL|HINT_MODTYPE)) { if(name != GetItemTextW(tvi.hItem)) { - SetItemText(pInfo->hSong, name.c_str()); + SetItemText(info.hSong, name.c_str()); } } } if (sndFile.GetModSpecifications().instrumentsMax > 0) { - if(!pInfo->hInstruments) pInfo->hInstruments = InsertItem(_T("Instruments"), IMAGE_FOLDER, IMAGE_FOLDER, pInfo->hSong, pInfo->hSamples); + if(!info.hInstruments) info.hInstruments = InsertItem(_T("Instruments"), IMAGE_FOLDER, IMAGE_FOLDER, info.hSong, info.hSamples); } else { - if(pInfo->hInstruments) + if(info.hInstruments) { - DeleteItem(pInfo->hInstruments); - pInfo->hInstruments = NULL; + DeleteItem(info.hInstruments); + info.hInstruments = NULL; } } - if (!pInfo->hComments) pInfo->hComments = InsertItem(_T("Comments"), IMAGE_COMMENTS, IMAGE_COMMENTS, pInfo->hSong, TVI_LAST); + if (!info.hComments) info.hComments = InsertItem(_T("Comments"), IMAGE_COMMENTS, IMAGE_COMMENTS, info.hSong, TVI_LAST); // Add effects if (hintFlagPart & (HINT_MODGENERAL|HINT_MODTYPE|HINT_MODCHANNELS|HINT_MIXPLUGINS)) { @@ -735,66 +742,66 @@ if(plugin.IsValidPlugin()) { // Now we can be sure that we want to create this folder. - if(!pInfo->hEffects) + if(!info.hEffects) { - pInfo->hEffects = InsertItem(_T("Plugins"), IMAGE_FOLDER, IMAGE_FOLDER, pInfo->hSong, pInfo->hInstruments ? pInfo->hInstruments : pInfo->hSamples); + info.hEffects = InsertItem(_T("Plugins"), IMAGE_FOLDER, IMAGE_FOLDER, info.hSong, info.hInstruments ? info.hInstruments : info.hSamples); } else if(!hasPlugs) { // Delete previously existing items - DeleteChildren(pInfo->hEffects); + DeleteChildren(info.hEffects); } wsprintf(s, "FX%u: %s", i + 1, plugin.GetName()); int nImage = IMAGE_NOPLUGIN; if(plugin.pMixPlugin != nullptr) nImage = (plugin.pMixPlugin->isInstrument()) ? IMAGE_PLUGININSTRUMENT : IMAGE_EFFECTPLUGIN; - InsertItem(TVIF_TEXT | TVIF_HANDLE | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM, s, nImage, nImage, 0, 0, i, pInfo->hEffects, TVI_LAST); + InsertItem(TVIF_TEXT | TVIF_HANDLE | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM, s, nImage, nImage, 0, 0, i, info.hEffects, TVI_LAST); hasPlugs = true; } } - if(!hasPlugs && pInfo->hEffects) + if(!hasPlugs && info.hEffects) { - DeleteItem(pInfo->hEffects); - pInfo->hEffects = nullptr; + DeleteItem(info.hEffects); + info.hEffects = nullptr; } } // Add Orders - if ((pInfo->hOrders) && (hintFlagPart != HINT_INSNAMES) && (hintFlagPart != HINT_SMPNAMES)) + if ((info.hOrders) && (hintFlagPart != HINT_INSNAMES) && (hintFlagPart != HINT_SMPNAMES)) { const DWORD nPat = (lHint >> HINT_SHIFT_PAT); bool adjustParentNode = false; // adjust sequence name of "Sequence" node? // (only one seq remaining || previously only one sequence): update parent item - if((pInfo->tiSequences.size() > 1 && sndFile.Order.GetNumSequences() == 1) || (pInfo->tiSequences.size() == 1 && sndFile.Order.GetNumSequences() > 1)) + if((info.tiSequences.size() > 1 && sndFile.Order.GetNumSequences() == 1) || (info.tiSequences.size() == 1 && sndFile.Order.GetNumSequences() > 1)) { - for(size_t nSeq = 0; nSeq < pInfo->tiOrders.size(); nSeq++) + for(size_t nSeq = 0; nSeq < info.tiOrders.size(); nSeq++) { - for(size_t nOrd = 0; nOrd < pInfo->tiOrders[nSeq].size(); nOrd++) if (pInfo->tiOrders[nSeq][nOrd]) + for(size_t nOrd = 0; nOrd < info.tiOrders[nSeq].size(); nOrd++) if (info.tiOrders[nSeq][nOrd]) { - if(pInfo->tiOrders[nSeq][nOrd]) DeleteItem(pInfo->tiOrders[nSeq][nOrd]); pInfo->tiOrders[nSeq][nOrd] = NULL; + if(info.tiOrders[nSeq][nOrd]) DeleteItem(info.tiOrders[nSeq][nOrd]); info.tiOrders[nSeq][nOrd] = NULL; } - if(pInfo->tiSequences[nSeq]) DeleteItem(pInfo->tiSequences[nSeq]); pInfo->tiSequences[nSeq] = NULL; + if(info.tiSequences[nSeq]) DeleteItem(info.tiSequences[nSeq]); info.tiSequences[nSeq] = NULL; } - pInfo->tiOrders.resize(sndFile.Order.GetNumSequences()); - pInfo->tiSequences.resize(sndFile.Order.GetNumSequences(), NULL); + info.tiOrders.resize(sndFile.Order.GetNumSequences()); + info.tiSequences.resize(sndFile.Order.GetNumSequences(), NULL); adjustParentNode = true; } // If there are too many sequences, delete them. - for(size_t nSeq = sndFile.Order.GetNumSequences(); nSeq < pInfo->tiSequences.size(); nSeq++) if (pInfo->tiSequences[nSeq]) + for(size_t nSeq = sndFile.Order.GetNumSequences(); nSeq < info.tiSequences.size(); nSeq++) if (info.tiSequences[nSeq]) { - for(size_t nOrd = 0; nOrd < pInfo->tiOrders[nSeq].size(); nOrd++) if (pInfo->tiOrders[nSeq][nOrd]) + for(size_t nOrd = 0; nOrd < info.tiOrders[nSeq].size(); nOrd++) if (info.tiOrders[nSeq][nOrd]) { - DeleteItem(pInfo->tiOrders[nSeq][nOrd]); pInfo->tiOrders[nSeq][nOrd] = NULL; + DeleteItem(info.tiOrders[nSeq][nOrd]); info.tiOrders[nSeq][nOrd] = NULL; } - DeleteItem(pInfo->tiSequences[nSeq]); pInfo->tiSequences[nSeq] = NULL; + DeleteItem(info.tiSequences[nSeq]); info.tiSequences[nSeq] = NULL; } - if (pInfo->tiSequences.size() < sndFile.Order.GetNumSequences()) // Resize tiSequences if needed. + if (info.tiSequences.size() < sndFile.Order.GetNumSequences()) // Resize tiSequences if needed. { - pInfo->tiSequences.resize(sndFile.Order.GetNumSequences(), NULL); - pInfo->tiOrders.resize(sndFile.Order.GetNumSequences()); + info.tiSequences.resize(sndFile.Order.GetNumSequences(), NULL); + info.tiOrders.resize(sndFile.Order.GetNumSequences()); } - HTREEITEM hAncestorNode = pInfo->hOrders; + HTREEITEM hAncestorNode = info.hOrders; SEQUENCEINDEX nSeqMin = 0, nSeqMax = sndFile.Order.GetNumSequences() - 1; SEQUENCEINDEX nHintParam = lHint >> HINT_SHIFT_SEQUENCE; @@ -808,7 +815,7 @@ seqName = _T("Sequence"); else seqName = _T("Sequence: ") + seqName; - SetItem(pInfo->hOrders, TVIF_TEXT, seqName, 0, 0, 0, 0, 0); + SetItem(info.hOrders, TVIF_TEXT, seqName, 0, 0, 0, 0, 0); } // go through all sequences @@ -825,33 +832,33 @@ UINT state = (nSeq == sndFile.Order.GetCurrentSequenceIndex()) ? TVIS_BOLD : 0; - if(pInfo->tiSequences[nSeq] == NULL) + if(info.tiSequences[nSeq] == NULL) { - pInfo->tiSequences[nSeq] = InsertItem(sSeqName, IMAGE_FOLDER, IMAGE_FOLDER, pInfo->hOrders, TVI_LAST); + info.tiSequences[nSeq] = InsertItem(sSeqName, IMAGE_FOLDER, IMAGE_FOLDER, info.hOrders, TVI_LAST); } // Update bold item strcpy(stmp, sSeqName); tvi.mask = TVIF_TEXT | TVIF_HANDLE | TVIF_STATE | TVIF_PARAM; tvi.state = 0; tvi.stateMask = TVIS_BOLD; - tvi.hItem = pInfo->tiSequences[nSeq]; + tvi.hItem = info.tiSequences[nSeq]; tvi.pszText = stmp; tvi.cchTextMax = CountOf(stmp); LPARAM param = (nSeq << SEQU_SHIFT) | ORDERINDEX_INVALID; GetItem(&tvi); if(tvi.state != state || tvi.pszText != sSeqName || tvi.lParam != param) - SetItem(pInfo->tiSequences[nSeq], TVIF_TEXT | TVIF_STATE | TVIF_PARAM, sSeqName, 0, 0, state, TVIS_BOLD, param); + SetItem(info.tiSequences[nSeq], TVIF_TEXT | TVIF_STATE | TVIF_PARAM, sSeqName, 0, 0, state, TVIS_BOLD, param); - hAncestorNode = pInfo->tiSequences[nSeq]; + hAncestorNode = info.tiSequences[nSeq]; } // If there are items past the new sequence length, delete them. - for(size_t nOrd = sndFile.Order.GetSequence(nSeq).GetLengthTailTrimmed(); nOrd < pInfo->tiOrders[nSeq].size(); nOrd++) if (pInfo->tiOrders[nSeq][nOrd]) + for(size_t nOrd = sndFile.Order.GetSequence(nSeq).GetLengthTailTrimmed(); nOrd < info.tiOrders[nSeq].size(); nOrd++) if (info.tiOrders[nSeq][nOrd]) { - DeleteItem(pInfo->tiOrders[nSeq][nOrd]); pInfo->tiOrders[nSeq][nOrd] = NULL; + DeleteItem(info.tiOrders[nSeq][nOrd]); info.tiOrders[nSeq][nOrd] = NULL; } - if (pInfo->tiOrders[nSeq].size() < sndFile.Order.GetSequence(nSeq).GetLengthTailTrimmed()) // Resize tiOrders if needed. - pInfo->tiOrders[nSeq].resize(sndFile.Order.GetSequence(nSeq).GetLengthTailTrimmed(), nullptr); + if (info.tiOrders[nSeq].size() < sndFile.Order.GetSequence(nSeq).GetLengthTailTrimmed()) // Resize tiOrders if needed. + info.tiOrders[nSeq].resize(sndFile.Order.GetSequence(nSeq).GetLengthTailTrimmed(), nullptr); const bool patNamesOnly = (hintFlagPart == HINT_PATNAMES); //if (hintFlagPart == HINT_PATNAMES) && (dwHintParam < sndFile.Order.size())) imin = imax = dwHintParam; @@ -859,7 +866,7 @@ { if(patNamesOnly && sndFile.Order.GetSequence(nSeq)[iOrd] != nPat) continue; - UINT state = (iOrd == pInfo->nOrdSel && nSeq == pInfo->nSeqSel) ? TVIS_BOLD : 0; + UINT state = (iOrd == info.nOrdSel && nSeq == info.nSeqSel) ? TVIS_BOLD : 0; if (sndFile.Order.GetSequence(nSeq)[iOrd] < sndFile.Patterns.Size()) { stmp[0] = 0; @@ -887,40 +894,40 @@ } LPARAM param = (nSeq << SEQU_SHIFT) | iOrd; - if (pInfo->tiOrders[nSeq][iOrd]) + if (info.tiOrders[nSeq][iOrd]) { tvi.mask = TVIF_TEXT | TVIF_HANDLE | TVIF_STATE; tvi.state = 0; tvi.stateMask = TVIS_BOLD; - tvi.hItem = pInfo->tiOrders[nSeq][iOrd]; + tvi.hItem = info.tiOrders[nSeq][iOrd]; tvi.pszText = stmp; tvi.cchTextMax = CountOf(stmp); GetItem(&tvi); if(tvi.state != state || strcmp(s, stmp)) - SetItem(pInfo->tiOrders[nSeq][iOrd], TVIF_TEXT | TVIF_STATE | TVIF_PARAM, s, 0, 0, state, TVIS_BOLD, param); + SetItem(info.tiOrders[nSeq][iOrd], TVIF_TEXT | TVIF_STATE | TVIF_PARAM, s, 0, 0, state, TVIS_BOLD, param); } else { - pInfo->tiOrders[nSeq][iOrd] = InsertItem(TVIF_HANDLE | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM, s, IMAGE_PARTITION, IMAGE_PARTITION, 0, 0, param, hAncestorNode, TVI_LAST); + info.tiOrders[nSeq][iOrd] = InsertItem(TVIF_HANDLE | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM, s, IMAGE_PARTITION, IMAGE_PARTITION, 0, 0, param, hAncestorNode, TVI_LAST); } } } } // Add Patterns - if ((pInfo->hPatterns) && (hintFlagPart != HINT_INSNAMES) && (hintFlagPart != HINT_SMPNAMES)) + if ((info.hPatterns) && (hintFlagPart != HINT_INSNAMES) && (hintFlagPart != HINT_SMPNAMES)) { const PATTERNINDEX nPat = (PATTERNINDEX)(lHint >> HINT_SHIFT_PAT); - pInfo->tiPatterns.resize(sndFile.Patterns.Size(), NULL); + info.tiPatterns.resize(sndFile.Patterns.Size(), NULL); PATTERNINDEX imin = 0, imax = sndFile.Patterns.Size()-1; if ((hintFlagPart == HINT_PATNAMES) && (nPat < sndFile.Patterns.Size())) imin = imax = nPat; bool bDelPat = false; - ASSERT(pInfo->tiPatterns.size() == sndFile.Patterns.Size()); + ASSERT(info.tiPatterns.size() == sndFile.Patterns.Size()); for(PATTERNINDEX iPat = imin; iPat <= imax; iPat++) { - if ((bDelPat) && (pInfo->tiPatterns[iPat])) + if ((bDelPat) && (info.tiPatterns[iPat])) { - DeleteItem(pInfo->tiPatterns[iPat]); - pInfo->tiPatterns[iPat] = NULL; + DeleteItem(info.tiPatterns[iPat]); + info.tiPatterns[iPat] = NULL; } if (sndFile.Patterns[iPat]) { @@ -933,32 +940,32 @@ { wsprintf(s, "%u", iPat); } - if (pInfo->tiPatterns[iPat]) + if (info.tiPatterns[iPat]) { tvi.mask = TVIF_TEXT | TVIF_HANDLE; - tvi.hItem = pInfo->tiPatterns[iPat]; + tvi.hItem = info.tiPatterns[iPat]; tvi.pszText = stmp; tvi.cchTextMax = CountOf(stmp); GetItem(&tvi); - if (strcmp(s, stmp)) SetItem(pInfo->tiPatterns[iPat], TVIF_TEXT, s, 0, 0, 0, 0, 0); + if (strcmp(s, stmp)) SetItem(info.tiPatterns[iPat], TVIF_TEXT, s, 0, 0, 0, 0, 0); } else { - pInfo->tiPatterns[iPat] = InsertItem(s, IMAGE_PATTERNS, IMAGE_PATTERNS, pInfo->hPatterns, TVI_LAST); + info.tiPatterns[iPat] = InsertItem(s, IMAGE_PATTERNS, IMAGE_PATTERNS, info.hPatterns, TVI_LAST); } - SetItemData(pInfo->tiPatterns[iPat], iPat); + SetItemData(info.tiPatterns[iPat], iPat); } else { - if (pInfo->tiPatterns[iPat]) + if (info.tiPatterns[iPat]) { - DeleteItem(pInfo->tiPatterns[iPat]); - pInfo->tiPatterns[iPat] = NULL; + DeleteItem(info.tiPatterns[iPat]); + info.tiPatterns[iPat] = NULL; bDelPat = true; } } } } // Add Samples - if ((pInfo->hSamples) && (hintFlagPart != HINT_INSNAMES) && (hintFlagPart != HINT_PATNAMES)) + if ((info.hSamples) && (hintFlagPart != HINT_INSNAMES) && (hintFlagPart != HINT_PATNAMES)) { const SAMPLEINDEX nSmp = (SAMPLEINDEX)(lHint >> HINT_SHIFT_SMP); SAMPLEINDEX smin = 1, smax = MAX_SAMPLES - 1; @@ -966,7 +973,7 @@ { smin = smax = nSmp; } - HTREEITEM hChild = GetNthChildItem(pInfo->hSamples, smin - 1); + HTREEITEM hChild = GetNthChildItem(info.hSamples, smin - 1); for(SAMPLEINDEX nSmp = smin; nSmp <= smax; nSmp++) { HTREEITEM hNextChild = GetNextSiblingItem(hChild); @@ -974,13 +981,13 @@ { const bool sampleExists = (sndFile.GetSample(nSmp).pSample != nullptr); int nImage = (sampleExists) ? IMAGE_SAMPLES : IMAGE_NOSAMPLE; - if(sampleExists && pInfo->samplesPlaying[nSmp]) nImage = IMAGE_SAMPLEACTIVE; - if(pInfo->pModDoc->IsSampleMuted(nSmp)) nImage = IMAGE_SAMPLEMUTE; + if(sampleExists && info.samplesPlaying[nSmp]) nImage = IMAGE_SAMPLEACTIVE; + if(info.pModDoc->IsSampleMuted(nSmp)) nImage = IMAGE_SAMPLEMUTE; wsprintf(s, "%3d: %s", nSmp, sndFile.m_szNames[nSmp]); if (!hChild) { - hChild = InsertItem(s, nImage, nImage, pInfo->hSamples, TVI_LAST); + hChild = InsertItem(s, nImage, nImage, info.hSamples, TVI_LAST); } else { tvi.mask = TVIF_TEXT | TVIF_HANDLE | TVIF_IMAGE; @@ -1006,7 +1013,7 @@ } } // Add Instruments - if ((pInfo->hInstruments) && (hintFlagPart != HINT_SMPNAMES) && (hintFlagPart != HINT_PATNAMES)) + if ((info.hInstruments) && (hintFlagPart != HINT_SMPNAMES) && (hintFlagPart != HINT_PATNAMES)) { INSTRUMENTINDEX smin = 1, smax = MAX_INSTRUMENTS - 1; const INSTRUMENTINDEX nIns = (INSTRUMENTINDEX)(lHint >> HINT_SHIFT_INS); @@ -1014,7 +1021,7 @@ { smin = smax = nIns; } - HTREEITEM hChild = GetNthChildItem(pInfo->hInstruments, smin - 1); + HTREEITEM hChild = GetNthChildItem(info.hInstruments, smin - 1); for (INSTRUMENTINDEX nIns = smin; nIns <= smax; nIns++) { HTREEITEM hNextChild = GetNextSiblingItem(hChild); @@ -1032,12 +1039,12 @@ } int nImage = IMAGE_INSTRUMENTS; - if(pInfo->instrumentsPlaying[nIns]) nImage = IMAGE_INSTRACTIVE; - if(!sndFile.Instruments[nIns] || pInfo->pModDoc->IsInstrumentMuted(nIns)) nImage = IMAGE_INSTRMUTE; + if(info.instrumentsPlaying[nIns]) nImage = IMAGE_INSTRACTIVE; + if(!sndFile.Instruments[nIns] || info.pModDoc->IsInstrumentMuted(nIns)) nImage = IMAGE_INSTRMUTE; if (!hChild) { - hChild = InsertItem(s, nImage, nImage, pInfo->hInstruments, TVI_LAST); + hChild = InsertItem(s, nImage, nImage, info.hInstruments, TVI_LAST); } else { tvi.mask = TVIF_TEXT | TVIF_HANDLE | TVIF_IMAGE; @@ -1066,30 +1073,32 @@ CModTree::ModItem CModTree::GetModItem(HTREEITEM hItem) //----------------------------------------------------- { - HTREEITEM hItemParent, hItemParentParent, hRootParent; - if (!hItem) return ModItem(MODITEM_NULL); // First, test root items if (hItem == m_hInsLib) return ModItem(MODITEM_HDR_INSTRUMENTLIB); if (hItem == m_hMidiLib) return ModItem(MODITEM_HDR_MIDILIB); - hItemParent = GetParentItem(hItem); - hItemParentParent = GetParentItem(hItemParent); - hRootParent = hItemParent; + // The immediate parent of the item (NULL if this item is on the root level of the tree) + HTREEITEM hItemParent = GetParentItem(hItem); + // Parent of the parent. + HTREEITEM hItemParentParent = GetParentItem(hItemParent); + // Get the root parent of the selected item, which can be the item itself. + HTREEITEM hRootParent = hItem; + if(!IsSampleBrowser()) + { + hRootParent = GetParentRootItem(hItem); + } + DWORD_PTR itemData = GetItemData(hItem); + DWORD_PTR rootItemData = GetItemData(hRootParent); - CModDoc *pModDoc = GetDocumentFromItem(hItem); - if(hRootParent != nullptr && !IsSampleBrowser()) - { - hRootParent = GetParentRootItem(hRootParent); - } // Midi Library - if ((hRootParent == m_hMidiLib) && !IsSampleBrowser()) + if(hRootParent == m_hMidiLib && hRootParent != hItem && !IsSampleBrowser()) { return ModItem(static_cast<ModItemType>(itemData >> MIDILIB_SHIFT), static_cast<uint32>(itemData & MIDILIB_MASK)); } // Instrument Library - if ((hRootParent == m_hInsLib) || (IsSampleBrowser() && (hItem != m_hInsLib))) + if(hRootParent == m_hInsLib || (IsSampleBrowser() && hItem != m_hInsLib)) { TV_ITEM tvi; tvi.mask = TVIF_IMAGE|TVIF_HANDLE; @@ -1109,12 +1118,13 @@ } if (IsSampleBrowser()) return ModItem(MODITEM_NULL); // Songs - for (size_t i = 0; i < DocInfo.size(); i++) + if(rootItemData < DocInfo.size()) { - m_nDocNdx = i; - ModTreeDocInfo *pInfo = DocInfo[i]; - if (hItem == pInfo->hSong) return ModItem(MODITEM_HDR_SONG); - if (hRootParent == pInfo->hSong) + m_nDocNdx = rootItemData; + ModTreeDocInfo *pInfo = DocInfo[rootItemData]; + + if(hItem == pInfo->hSong) return ModItem(MODITEM_HDR_SONG); + if(hRootParent == pInfo->hSong) { if (hItem == pInfo->hPatterns) return ModItem(MODITEM_HDR_PATTERNS); if (hItem == pInfo->hOrders) return ModItem(MODITEM_HDR_ORDERS); @@ -1165,16 +1175,15 @@ // DLS Instruments if(hRootParent != nullptr) { - DWORD_PTR dlsItem = GetItemData(hRootParent); - if(dlsItem < m_tiDLS.size() && m_tiDLS[dlsItem] == hRootParent) + if(rootItemData < m_tiDLS.size() && m_tiDLS[rootItemData] == hRootParent) { - if (hItem == m_tiDLS[dlsItem]) - return ModItem(MODITEM_DLSBANK_FOLDER, (uint32)dlsItem); + if (hItem == m_tiDLS[rootItemData]) + return ModItem(MODITEM_DLSBANK_FOLDER, (uint32)rootItemData); if ((itemData & DLS_TYPEMASK) == DLS_TYPEPERC || (itemData & DLS_TYPEMASK) == DLS_TYPEINST) { - return DlsItem(dlsItem, itemData); + return DlsItem(rootItemData, itemData); } } } @@ -2193,7 +2202,7 @@ { pInfo->nOrdSel = nNewOrd; pInfo->nSeqSel = nNewSeq; - UpdateView(pInfo, HINT_MODSEQUENCE); + UpdateView(*pInfo, HINT_MODSEQUENCE); } // Update sample / instrument playing status icons (will only detect instruments with samples, though) @@ -2245,7 +2254,7 @@ } // what should be updated? DWORD dwHintFlags = (updateSamples ? HINT_SAMPLEINFO : 0) | (updateInstruments ? HINT_INSTRUMENT : 0); - if(dwHintFlags != 0) UpdateView(pInfo, dwHintFlags); + if(dwHintFlags != 0) UpdateView(*pInfo, dwHintFlags); } @@ -2265,7 +2274,7 @@ { if (((*iter)->pModDoc == pModDoc) || (!pModDoc)) { - UpdateView((*iter), dwHint); + UpdateView((**iter), dwHint); break; } } @@ -2450,7 +2459,7 @@ bool isCurSeq = false; CModDoc *pModDoc = GetDocumentFromItem(hItem); CSoundFile *pSndFile = (pModDoc) ? pModDoc->GetSoundFile() : nullptr; - if(pModDoc && pSndFile && (pModDoc->GetModType() == MOD_TYPE_MPT)) + if(pSndFile && (pSndFile->GetType() == MOD_TYPE_MPT)) { if(pSndFile->Order.GetSequence((SEQUENCEINDEX)modItemID).GetLength() == 0) { @@ -2474,7 +2483,7 @@ { CModDoc *pModDoc = GetDocumentFromItem(hItem); CSoundFile *pSndFile = (pModDoc) ? pModDoc->GetSoundFile() : nullptr; - if(pModDoc && pSndFile && (pModDoc->GetModType() == MOD_TYPE_MPT)) + if(pSndFile && (pSndFile->GetType() == MOD_TYPE_MPT)) { AppendMenu(hMenu, MF_STRING, ID_MODTREE_INSERT, "&Insert Sequence"); if(pSndFile->Order.GetNumSequences() == 1) // this is a sequence @@ -2836,7 +2845,7 @@ std::vector<ModTreeDocInfo *>::iterator iter; for (iter = DocInfo.begin(); iter != DocInfo.end(); iter++) { - UpdateView((*iter), HINT_MODTYPE); + UpdateView((**iter), HINT_MODTYPE); } RefreshMidiLibrary(); RefreshDlsBanks(); @@ -2877,24 +2886,23 @@ //----------------------------- { HTREEITEM hItem = GetSelectedItem(); - CModDoc *pModDoc; const ModItem modItem = GetModItem(hItem); const uint32 modItemID = modItem.val1; - pModDoc = GetDocumentFromItem(hItem); - - if (pModDoc) + ModTreeDocInfo *info = GetDocumentInfoFromItem(hItem); + if (info) { + CModDoc *pModDoc = info->pModDoc; if ((modItem.type == MODITEM_SAMPLE) && (!pModDoc->GetNumInstruments())) { pModDoc->MuteSample((SAMPLEINDEX)modItemID, (!pModDoc->IsSampleMuted((SAMPLEINDEX)modItemID))); - UpdateView(GetDocumentInfoFromModDoc(pModDoc), HINT_SMPNAMES | HINT_SAMPLEINFO); + UpdateView(*info, HINT_SMPNAMES | HINT_SAMPLEINFO | (modItemID << HINT_SHIFT_SMP)); } else if ((modItem.type == MODITEM_INSTRUMENT) && (pModDoc->GetNumInstruments())) { pModDoc->MuteInstrument((INSTRUMENTINDEX)modItemID, (!pModDoc->IsInstrumentMuted((INSTRUMENTINDEX)modItemID))); - UpdateView(GetDocumentInfoFromModDoc(pModDoc), HINT_INSNAMES | HINT_INSTRUMENT); + UpdateView(*info, HINT_INSNAMES | HINT_INSTRUMENT | (modItemID << HINT_SHIFT_INS)); } else if ((modItem.type == MODITEM_EFFECT)) { CVstPlugin *pVstPlugin = dynamic_cast<CVstPlugin *>(pModDoc->GetrSoundFile().m_MixPlugins[modItemID].pMixPlugin); @@ -2912,29 +2920,29 @@ //----------------------------- { HTREEITEM hItem = GetSelectedItem(); - CModDoc *pModDoc; const ModItem modItem = GetModItem(hItem); const uint32 modItemID = modItem.val1; - pModDoc = GetDocumentFromItem(hItem); - if (pModDoc) + ModTreeDocInfo *info = GetDocumentInfoFromItem(hItem); + if (info) { + CModDoc *pModDoc = info->pModDoc; INSTRUMENTINDEX nInstruments = pModDoc->GetNumInstruments(); if ((modItem.type == MODITEM_SAMPLE) && (!nInstruments)) { for (SAMPLEINDEX nSmp = 1; nSmp <= pModDoc->GetNumSamples(); nSmp++) { pModDoc->MuteSample(nSmp, nSmp != modItemID); - UpdateView(GetDocumentInfoFromModDoc(pModDoc), HINT_SMPNAMES | HINT_SAMPLEINFO); } + UpdateView(*info, HINT_SMPNAMES | HINT_SAMPLEINFO); } else if ((modItem.type == MODITEM_INSTRUMENT) && (nInstruments)) { for (INSTRUMENTINDEX nIns = 1; nIns <= nInstruments; nIns++) { pModDoc->MuteInstrument(nIns, nIns != modItemID); - UpdateView(GetDocumentInfoFromModDoc(pModDoc), HINT_INSNAMES | HINT_INSTRUMENT); } + UpdateView(*info, HINT_INSNAMES | HINT_INSTRUMENT); } } } @@ -2944,25 +2952,25 @@ //---------------------------------- { HTREEITEM hItem = GetSelectedItem(); - CModDoc *pModDoc; const ModItem modItem = GetModItem(hItem); - pModDoc = GetDocumentFromItem(hItem); - if (pModDoc) + ModTreeDocInfo *info = GetDocumentInfoFromItem(hItem); + if (info) { + CModDoc *pModDoc = info->pModDoc; if ((modItem.type == MODITEM_SAMPLE) || (modItem.type == MODITEM_INSTRUMENT)) { for (SAMPLEINDEX nSmp = 1; nSmp <= pModDoc->GetNumSamples(); nSmp++) { pModDoc->MuteSample(nSmp, false); - UpdateView(GetDocumentInfoFromModDoc(pModDoc), HINT_SMPNAMES | HINT_SAMPLEINFO); } + UpdateView(*info, HINT_SMPNAMES | HINT_SAMPLEINFO); for (INSTRUMENTINDEX nIns = 1; nIns <= pModDoc->GetNumInstruments(); nIns++) { pModDoc->MuteInstrument(nIns, false); - UpdateView(GetDocumentInfoFromModDoc(pModDoc), HINT_INSNAMES | HINT_INSTRUMENT); } + UpdateView(*info, HINT_INSNAMES | HINT_INSTRUMENT); } } } @@ -2991,10 +2999,10 @@ const ModItem modItem = GetModItem(hItem); const uint32 modItemID = modItem.val1; - CModDoc *pModDoc = GetDocumentFromItem(hItem); - - if(pModDoc) + ModTreeDocInfo *info = GetDocumentInfoFromItem(hItem); + if (info) { + CModDoc *pModDoc = info->pModDoc; CSoundFile &sndFile = pModDoc->GetrSoundFile(); if(modItem.type == MODITEM_SEQUENCE || modItem.type == MODITEM_HDR_ORDERS) { @@ -3008,7 +3016,7 @@ sndFile.Order.AddSequence(true); } pModDoc->SetModified(); - UpdateView(GetDocumentInfoFromModDoc(pModDoc), HINT_SEQNAMES|HINT_MODSEQUENCE | (DWORD)(MAX_SEQUENCES << HINT_SHIFT_SEQUENCE)); + UpdateView(*info, HINT_SEQNAMES|HINT_MODSEQUENCE | (DWORD)(MAX_SEQUENCES << HINT_SHIFT_SEQUENCE)); pModDoc->UpdateAllViews(NULL, HINT_SEQNAMES|HINT_MODSEQUENCE); } else if(modItem.type == MODITEM_SAMPLE) { @@ -3043,12 +3051,10 @@ //--------------------------------- { HTREEITEM hItem = GetSelectedItem(); - CModDoc *pModDoc; const ModItem modItem = GetModItem(hItem); - pModDoc = GetDocumentFromItem(hItem); - + CModDoc *pModDoc = GetDocumentFromItem(hItem); if (pModDoc && (modItem.type == MODITEM_SEQUENCE)) { pModDoc->ActivateView(IDD_CONTROL_PATTERNS, uint32(modItem.val1 << SEQU_SHIFT) | SEQU_INDICATOR); @@ -3061,18 +3067,17 @@ //---------------------------- { HTREEITEM hItem = GetSelectedItem(); - CModDoc *pModDoc = GetDocumentFromItem(hItem); - CSoundFile *pSndFile = pModDoc ? pModDoc->GetSoundFile() : NULL; const ModItem modItem = GetModItem(hItem); + CModDoc *pModDoc = GetDocumentFromItem(hItem); - if(pSndFile && modItem.val1) + if(pModDoc && modItem.val1) { FileDialog dlg = SaveFileDialog() .ExtensionFilter("All files(*.*)|*.*||"); if(!dlg.Show()) return; - pSndFile->m_szInstrumentPath[modItem.val1 - 1] = dlg.GetFirstFile(); + pModDoc->GetrSoundFile().m_szInstrumentPath[modItem.val1 - 1] = dlg.GetFirstFile(); OnRefreshTree(); } } @@ -3081,26 +3086,25 @@ //------------------------- { HTREEITEM hItem = GetSelectedItem(); - CModDoc *pModDoc = GetDocumentFromItem(hItem); - CSoundFile *pSndFile = pModDoc ? pModDoc->GetSoundFile() : NULL; const ModItem modItem = GetModItem(hItem); + CModDoc *pModDoc = GetDocumentFromItem(hItem); - if(pSndFile && modItem.val1) + if(pModDoc && modItem.val1) { - - if(pSndFile->m_szInstrumentPath[modItem.val1 - 1].empty()) + CSoundFile &sndFile = pModDoc->GetrSoundFile(); + if(sndFile.m_szInstrumentPath[modItem.val1 - 1].empty()) { FileDialog dlg = SaveFileDialog() - .DefaultExtension(pSndFile->GetType() == MOD_TYPE_XM ? "xi" : "iti") - .ExtensionFilter((pSndFile->GetType() == MOD_TYPE_XM) ? + .DefaultExtension(sndFile.GetType() == MOD_TYPE_XM ? "xi" : "iti") + .ExtensionFilter((sndFile.GetType() == MOD_TYPE_XM) ? "FastTracker II Instruments (*.xi)|*.xi|" "Impulse Tracker Instruments (*.iti)|*.iti||" : "Impulse Tracker Instruments (*.iti)|*.iti|" "FastTracker II Instruments (*.xi)|*.xi||"); if(!dlg.Show()) return; - pSndFile->m_szInstrumentPath[modItem.val1 - 1] = dlg.GetFirstFile(); + sndFile.m_szInstrumentPath[modItem.val1 - 1] = dlg.GetFirstFile(); } pModDoc->SaveInstrument(static_cast<INSTRUMENTINDEX>(modItem.val1)); Modified: trunk/OpenMPT/mptrack/View_tre.h =================================================================== --- trunk/OpenMPT/mptrack/View_tre.h 2013-11-19 03:43:48 UTC (rev 3269) +++ trunk/OpenMPT/mptrack/View_tre.h 2013-11-19 16:44:45 UTC (rev 3270) @@ -213,7 +213,7 @@ void OnOptionsChanged(); void AddDocument(CModDoc *pModDoc); void RemoveDocument(CModDoc *pModDoc); - void UpdateView(ModTreeDocInfo *pInfo, DWORD dwHint); + void UpdateView(ModTreeDocInfo &info, DWORD dwHint); void OnUpdate(CModDoc *pModDoc, DWORD dwHint, CObject *pHint); bool CanDrop(HTREEITEM hItem, bool bDoDrop); void UpdatePlayPos(CModDoc *pModDoc, Notification *pNotify); @@ -241,7 +241,8 @@ static int CALLBACK ModTreeInsLibCompareProc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort); static int CALLBACK ModTreeDrumCompareProc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort); void ModTreeInsert(const WCHAR *name, int image); - CModDoc *GetDocumentFromItem(HTREEITEM hItem); + ModTreeDocInfo *GetDocumentInfoFromItem(HTREEITEM hItem); + CModDoc *GetDocumentFromItem(HTREEITEM hItem) { ModTreeDocInfo *info = GetDocumentInfoFromItem(hItem); return info ? info->pModDoc : nullptr; } ModTreeDocInfo *GetDocumentInfoFromModDoc(CModDoc *pModDoc); void InsertOrDupItem(bool insert); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2013-11-19 17:18:56
|
Revision: 3271 http://sourceforge.net/p/modplug/code/3271 Author: saga-games Date: 2013-11-19 17:18:47 +0000 (Tue, 19 Nov 2013) Log Message: ----------- [Fix] Selecting a pattern from the treeview to edit automatically set the document as modified. [Ref] More Treeview refactoring. Modified Paths: -------------- trunk/OpenMPT/mptrack/Ctrl_seq.cpp trunk/OpenMPT/mptrack/Mainbar.cpp trunk/OpenMPT/mptrack/View_tre.cpp trunk/OpenMPT/mptrack/View_tre.h Modified: trunk/OpenMPT/mptrack/Ctrl_seq.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_seq.cpp 2013-11-19 16:44:45 UTC (rev 3270) +++ trunk/OpenMPT/mptrack/Ctrl_seq.cpp 2013-11-19 17:18:47 UTC (rev 3271) @@ -1351,6 +1351,8 @@ else return; } + else if(nSeq == sndFile.Order.GetCurrentSequenceIndex()) + return; else if(nSeq == MAX_SEQUENCES || nSeq == MAX_SEQUENCES + 1) sndFile.Order.AddSequence((nSeq == MAX_SEQUENCES)); else if(nSeq < sndFile.Order.GetNumSequences()) Modified: trunk/OpenMPT/mptrack/Mainbar.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mainbar.cpp 2013-11-19 16:44:45 UTC (rev 3270) +++ trunk/OpenMPT/mptrack/Mainbar.cpp 2013-11-19 17:18:47 UTC (rev 3271) @@ -921,14 +921,14 @@ VOID CModTreeBar::OnDocumentCreated(CModDoc *pModDoc) //--------------------------------------------------- { - if (m_pModTree) m_pModTree->AddDocument(pModDoc); + if (m_pModTree && pModDoc) m_pModTree->AddDocument(*pModDoc); } VOID CModTreeBar::OnDocumentClosed(CModDoc *pModDoc) //-------------------------------------------------- { - if (m_pModTree) m_pModTree->RemoveDocument(pModDoc); + if (m_pModTree && pModDoc) m_pModTree->RemoveDocument(*pModDoc); } @@ -942,7 +942,7 @@ VOID CModTreeBar::UpdatePlayPos(CModDoc *pModDoc, Notification *pNotify) //---------------------------------------------------------------------- { - if (m_pModTree) m_pModTree->UpdatePlayPos(pModDoc, pNotify); + if (m_pModTree && pModDoc) m_pModTree->UpdatePlayPos(*pModDoc, pNotify); } Modified: trunk/OpenMPT/mptrack/View_tre.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_tre.cpp 2013-11-19 16:44:45 UTC (rev 3270) +++ trunk/OpenMPT/mptrack/View_tre.cpp 2013-11-19 17:18:47 UTC (rev 3271) @@ -10,10 +10,10 @@ #include "stdafx.h" +#include "mainfrm.h" +#include "view_tre.h" #include "mptrack.h" #include "moddoc.h" -#include "mainfrm.h" -#include "view_tre.h" #include "Dlsbank.h" #include "dlg_misc.h" #include "vstplug.h" @@ -60,6 +60,20 @@ } +ModTreeDocInfo::ModTreeDocInfo(CModDoc &modDoc) : modDoc(modDoc) +{ + CSoundFile &sndFile = modDoc.GetrSoundFile(); + nSeqSel = SEQUENCEINDEX_INVALID; + nOrdSel = ORDERINDEX_INVALID; + hSong = hPatterns = hSamples = hInstruments = hComments = hOrders = hEffects = nullptr; + tiPatterns.resize(sndFile.Patterns.Size(), nullptr); + tiOrders.resize(sndFile.Order.GetNumSequences()); + tiSequences.resize(sndFile.Order.GetNumSequences(), nullptr); + samplesPlaying.reset(); + instrumentsPlaying.reset(); +} + + ///////////////////////////////////////////////////////////////////////////// // CModTree @@ -357,20 +371,20 @@ } -void CModTree::AddDocument(CModDoc *pModDoc) -//------------------------------------------ +void CModTree::AddDocument(CModDoc &modDoc) +//----------------------------------------- { // Check if document is already in the list std::vector<ModTreeDocInfo *>::iterator iter; - for (iter = DocInfo.begin(); iter != DocInfo.end(); iter++) + for(iter = DocInfo.begin(); iter != DocInfo.end(); iter++) { - if ((*iter)->pModDoc == pModDoc) + if(&(*iter)->modDoc == &modDoc) { return; } } - ModTreeDocInfo *pInfo = new (std::nothrow) ModTreeDocInfo(pModDoc->GetrSoundFile()); + ModTreeDocInfo *pInfo = new (std::nothrow) ModTreeDocInfo(modDoc); if(!pInfo) { return; @@ -387,13 +401,13 @@ } -void CModTree::RemoveDocument(CModDoc *pModDoc) -//--------------------------------------------- +void CModTree::RemoveDocument(CModDoc &modDoc) +//-------------------------------------------- { std::vector<ModTreeDocInfo *>::iterator iter; for(iter = DocInfo.begin(); iter != DocInfo.end(); iter++) { - if((*iter)->pModDoc == pModDoc) + if(&(*iter)->modDoc == &modDoc) { DeleteItem((*iter)->hSong); delete (*iter); @@ -428,13 +442,13 @@ // Get modtree doc information for a given CModDoc -ModTreeDocInfo *CModTree::GetDocumentInfoFromModDoc(CModDoc *pModDoc) -//------------------------------------------------------------------- +ModTreeDocInfo *CModTree::GetDocumentInfoFromModDoc(CModDoc &modDoc) +//------------------------------------------------------------------ { std::vector<ModTreeDocInfo *>::iterator iter; - for (iter = DocInfo.begin(); iter != DocInfo.end(); iter++) + for(iter = DocInfo.begin(); iter != DocInfo.end(); iter++) { - if ((*iter)->pModDoc == pModDoc) + if(&(*iter)->modDoc == &modDoc) { return (*iter); } @@ -691,19 +705,18 @@ TV_ITEM tvi; MemsetZero(tvi); const DWORD hintFlagPart = HintFlagPart(lHint); - if (info.pModDoc == nullptr || IsSampleBrowser()) return; - if (!hintFlagPart) return; + if (IsSampleBrowser() || !hintFlagPart) return; - const CModDoc *pDoc = info.pModDoc; - const CSoundFile &sndFile = pDoc->GetrSoundFile(); + const CModDoc &modDoc = info.modDoc; + const CSoundFile &sndFile = modDoc.GetrSoundFile(); // Create headers s[0] = 0; if((hintFlagPart & (HINT_MODGENERAL|HINT_MODTYPE)) || (!info.hSong)) { // Module folder + sub folders - std::wstring name = pDoc->GetPathNameMpt().GetFullFileName().ToWide(); - if(name.empty()) name = mpt::PathString::FromCStringSilent(info.pModDoc->GetTitle()).SanitizeComponent().ToWide(); + std::wstring name = modDoc.GetPathNameMpt().GetFullFileName().ToWide(); + if(name.empty()) name = mpt::PathString::FromCStringSilent(modDoc.GetTitle()).SanitizeComponent().ToWide(); if(!info.hSong) { @@ -982,7 +995,7 @@ const bool sampleExists = (sndFile.GetSample(nSmp).pSample != nullptr); int nImage = (sampleExists) ? IMAGE_SAMPLES : IMAGE_NOSAMPLE; if(sampleExists && info.samplesPlaying[nSmp]) nImage = IMAGE_SAMPLEACTIVE; - if(info.pModDoc->IsSampleMuted(nSmp)) nImage = IMAGE_SAMPLEMUTE; + if(info.modDoc.IsSampleMuted(nSmp)) nImage = IMAGE_SAMPLEMUTE; wsprintf(s, "%3d: %s", nSmp, sndFile.m_szNames[nSmp]); if (!hChild) @@ -1031,7 +1044,7 @@ { // path info for ITP instruments const bool pathOk = !sndFile.m_szInstrumentPath[nIns - 1].empty(); - const bool instMod = pDoc->m_bsInstrumentModified.test(nIns - 1); + const bool instMod = modDoc.m_bsInstrumentModified.test(nIns - 1); wsprintf(s, pathOk ? (instMod ? "%3u: * %s" : "%3u: %s") : "%3u: ? %s", nIns, sndFile.GetInstrumentName(nIns)); } else { @@ -1040,7 +1053,7 @@ int nImage = IMAGE_INSTRUMENTS; if(info.instrumentsPlaying[nIns]) nImage = IMAGE_INSTRACTIVE; - if(!sndFile.Instruments[nIns] || info.pModDoc->IsInstrumentMuted(nIns)) nImage = IMAGE_INSTRMUTE; + if(!sndFile.Instruments[nIns] || info.modDoc.IsInstrumentMuted(nIns)) nImage = IMAGE_INSTRMUTE; if (!hChild) { @@ -1198,32 +1211,32 @@ { const ModItem modItem = GetModItem(hItem); uint32 modItemID = modItem.val1; - ModTreeDocInfo *pInfo = (m_nDocNdx < DocInfo.size() ? DocInfo[m_nDocNdx] : nullptr); - CModDoc *pModDoc = (pInfo) ? pInfo->pModDoc : NULL; + CModDoc *modDoc = m_nDocNdx < DocInfo.size() ? &(DocInfo[m_nDocNdx]->modDoc) : nullptr; + switch(modItem.type) { case MODITEM_COMMENTS: - if (pModDoc) pModDoc->ActivateView(IDD_CONTROL_COMMENTS, 0); + if (modDoc) modDoc->ActivateView(IDD_CONTROL_COMMENTS, 0); return TRUE; /*case MODITEM_SEQUENCE: - if (pModDoc) pModDoc->ActivateView(IDD_CONTROL_PATTERNS, (dwItem << SEQU_SHIFT) | SEQU_INDICATOR); + if (modDoc) modDoc->ActivateView(IDD_CONTROL_PATTERNS, (dwItem << SEQU_SHIFT) | SEQU_INDICATOR); return TRUE;*/ case MODITEM_ORDER: - if (pModDoc) pModDoc->ActivateView(IDD_CONTROL_PATTERNS, modItemID | (uint32(modItem.val2) << SEQU_SHIFT) | SEQU_INDICATOR); + if (modDoc) modDoc->ActivateView(IDD_CONTROL_PATTERNS, modItemID | (uint32(modItem.val2) << SEQU_SHIFT) | SEQU_INDICATOR); return TRUE; case MODITEM_PATTERN: - if (pModDoc) pModDoc->ActivateView(IDD_CONTROL_PATTERNS, modItemID); + if (modDoc) modDoc->ActivateView(IDD_CONTROL_PATTERNS, modItemID); return TRUE; case MODITEM_SAMPLE: - if (pModDoc) pModDoc->ActivateView(IDD_CONTROL_SAMPLES, modItemID); + if (modDoc) modDoc->ActivateView(IDD_CONTROL_SAMPLES, modItemID); return TRUE; case MODITEM_INSTRUMENT: - if (pModDoc) pModDoc->ActivateView(IDD_CONTROL_INSTRUMENTS, modItemID); + if (modDoc) modDoc->ActivateView(IDD_CONTROL_INSTRUMENTS, modItemID); return TRUE; case MODITEM_MIDIPERCUSSION: @@ -1244,7 +1257,7 @@ return TRUE; case MODITEM_HDR_SONG: - if (pModDoc) pModDoc->ActivateWindow(); + if (modDoc) modDoc->ActivateWindow(); return TRUE; case MODITEM_DLSBANK_INSTRUMENT: @@ -1263,40 +1276,40 @@ { const ModItem modItem = GetModItem(hItem); uint32 modItemID = modItem.val1; - ModTreeDocInfo *pInfo = (m_nDocNdx < DocInfo.size() ? DocInfo[m_nDocNdx] : nullptr); - CModDoc *pModDoc = (pInfo) ? pInfo->pModDoc : NULL; + CModDoc *modDoc = m_nDocNdx < DocInfo.size() ? &(DocInfo[m_nDocNdx]->modDoc) : nullptr; + switch(modItem.type) { case MODITEM_SAMPLE: - if (pModDoc) + if (modDoc) { if (nParam & 0x80) { - pModDoc->NoteOff(nParam & 0x7F, true); + modDoc->NoteOff(nParam & 0x7F, true); } else { - pModDoc->NoteOff(0, true); // cut previous playing samples - pModDoc->PlayNote(nParam & 0x7F, 0, static_cast<SAMPLEINDEX>(modItemID), false); + modDoc->NoteOff(0, true); // cut previous playing samples + modDoc->PlayNote(nParam & 0x7F, 0, static_cast<SAMPLEINDEX>(modItemID), false); } } return TRUE; case MODITEM_INSTRUMENT: - if (pModDoc) + if (modDoc) { if (nParam & 0x80) { - pModDoc->NoteOff(nParam & 0x7F, true); + modDoc->NoteOff(nParam & 0x7F, true); } else { - pModDoc->NoteOff(0, true); - pModDoc->PlayNote(nParam & 0x7F, static_cast<INSTRUMENTINDEX>(modItemID), 0, false); + modDoc->NoteOff(0, true); + modDoc->PlayNote(nParam & 0x7F, static_cast<INSTRUMENTINDEX>(modItemID), 0, false); } } return TRUE; case MODITEM_EFFECT: - if ((pModDoc) && (modItemID < MAX_MIXPLUGINS)) + if ((modDoc) && (modItemID < MAX_MIXPLUGINS)) {/* CSoundFile *pSndFile = pModDoc->GetSoundFile(); PSNDMIXPLUGIN pPlugin = &pSndFile->m_MixPlugins[dwItem]; @@ -1305,7 +1318,7 @@ CVstPlugin *pVstPlugin = (CVstPlugin *)pPlugin->pMixPlugin; pVstPlugin->ToggleEditor(); }*/ - pModDoc->TogglePluginEditor(modItemID); + modDoc->TogglePluginEditor(modItemID); } return TRUE; @@ -1415,9 +1428,8 @@ uint32 modItemID = modItem.val1; TCHAR s[64]; - ModTreeDocInfo *pInfo = (m_nDocNdx < DocInfo.size() ? DocInfo[m_nDocNdx] : nullptr); - CModDoc *pModDoc = (pInfo) ? pInfo->pModDoc : nullptr; - if(modItem.IsSongItem() && pModDoc == nullptr) + CModDoc *modDoc = m_nDocNdx < DocInfo.size() ? &(DocInfo[m_nDocNdx]->modDoc) : nullptr; + if(modItem.IsSongItem() && modDoc == nullptr) { return; } @@ -1427,41 +1439,41 @@ case MODITEM_SEQUENCE: wsprintf(s, _T("Remove sequence %u?"), modItemID); if(Reporting::Confirm(s, false, true) == cnfNo) break; - pModDoc->GetrSoundFile().Order.RemoveSequence((SEQUENCEINDEX)(modItemID)); - pModDoc->UpdateAllViews(NULL, HINT_MODSEQUENCE, NULL); + modDoc->GetrSoundFile().Order.RemoveSequence((SEQUENCEINDEX)(modItemID)); + modDoc->UpdateAllViews(NULL, HINT_MODSEQUENCE, NULL); break; case MODITEM_ORDER: // might be slightly annoying to ask for confirmation here, and it's rather easy to restore the orderlist anyway. - if(pModDoc->RemoveOrder((SEQUENCEINDEX)(modItem.val2), (ORDERINDEX)(modItem.val1))) + if(modDoc->RemoveOrder((SEQUENCEINDEX)(modItem.val2), (ORDERINDEX)(modItem.val1))) { - pModDoc->UpdateAllViews(NULL, HINT_MODSEQUENCE, NULL); + modDoc->UpdateAllViews(NULL, HINT_MODSEQUENCE, NULL); } break; case MODITEM_PATTERN: wsprintf(s, _T("Remove pattern %u?"), modItemID); - if(Reporting::Confirm(s, false, true) == cnfYes && pModDoc->RemovePattern((PATTERNINDEX)modItemID)) + if(Reporting::Confirm(s, false, true) == cnfYes && modDoc->RemovePattern((PATTERNINDEX)modItemID)) { - pModDoc->UpdateAllViews(NULL, (UINT(modItemID) << HINT_SHIFT_PAT) | HINT_PATTERNDATA|HINT_PATNAMES); + modDoc->UpdateAllViews(NULL, (UINT(modItemID) << HINT_SHIFT_PAT) | HINT_PATTERNDATA|HINT_PATNAMES); } break; case MODITEM_SAMPLE: wsprintf(s, _T("Remove sample %u?"), modItemID); if(Reporting::Confirm(s, false, true) == cnfNo) break; - pModDoc->GetSampleUndo().PrepareUndo((SAMPLEINDEX)modItemID, sundo_replace); - if (pModDoc->RemoveSample((SAMPLEINDEX)modItemID)) + modDoc->GetSampleUndo().PrepareUndo((SAMPLEINDEX)modItemID, sundo_replace); + if (modDoc->RemoveSample((SAMPLEINDEX)modItemID)) { - pModDoc->UpdateAllViews(NULL, (UINT(modItemID) << HINT_SHIFT_SMP) | HINT_SMPNAMES|HINT_SAMPLEDATA|HINT_SAMPLEINFO); + modDoc->UpdateAllViews(NULL, (UINT(modItemID) << HINT_SHIFT_SMP) | HINT_SMPNAMES|HINT_SAMPLEDATA|HINT_SAMPLEINFO); } break; case MODITEM_INSTRUMENT: wsprintf(s, _T("Remove instrument %u?"), modItemID); - if(Reporting::Confirm(s, false, true) == cnfYes && pModDoc->RemoveInstrument((INSTRUMENTINDEX)modItemID)) + if(Reporting::Confirm(s, false, true) == cnfYes && modDoc->RemoveInstrument((INSTRUMENTINDEX)modItemID)) { - pModDoc->UpdateAllViews(NULL, (UINT(modItemID) << HINT_SHIFT_INS) | HINT_MODTYPE|HINT_ENVELOPE|HINT_INSTRUMENT); + modDoc->UpdateAllViews(NULL, (UINT(modItemID) << HINT_SHIFT_INS) | HINT_MODTYPE|HINT_ENVELOPE|HINT_INSTRUMENT); } break; @@ -1921,8 +1933,7 @@ bool CModTree::GetDropInfo(DRAGONDROP &dropInfo, mpt::PathString &fullPath) //------------------------------------------------------------------------- { - ModTreeDocInfo *pInfo = (m_nDragDocNdx < DocInfo.size() ? DocInfo[m_nDragDocNdx] : nullptr); - dropInfo.pModDoc = (pInfo) ? pInfo->pModDoc : nullptr; + dropInfo.pModDoc = (m_nDragDocNdx < DocInfo.size() ? &(DocInfo[m_nDragDocNdx]->modDoc) : nullptr); dropInfo.dwDropType = DRAGONDROP_NOTHING; dropInfo.dwDropItem = m_itemDrag.val1; dropInfo.lDropParam = 0; @@ -2016,9 +2027,9 @@ const ModTreeDocInfo *pInfoDrag = (m_nDragDocNdx < DocInfo.size() ? DocInfo[m_nDragDocNdx] : nullptr); const ModTreeDocInfo *pInfoDrop = (m_nDocNdx < DocInfo.size() ? DocInfo[m_nDocNdx] : nullptr); - CModDoc *pModDoc = (pInfoDrop) ? pInfoDrop->pModDoc : nullptr; + CModDoc *pModDoc = (pInfoDrop) ? &pInfoDrop->modDoc : nullptr; CSoundFile *pSndFile = (pModDoc) ? pModDoc->GetSoundFile() : nullptr; - const bool sameModDoc = pInfoDrag && (pModDoc == pInfoDrag->pModDoc); + const bool sameModDoc = pInfoDrag && (pModDoc == &pInfoDrag->modDoc); switch(modItemDrop.type) { @@ -2058,13 +2069,9 @@ if(bDoDrop && pInfoDrag != nullptr) { // copy mod sequence over. - CModDoc *pDragDoc = pInfoDrag->pModDoc; - if(pDragDoc == nullptr) return false; - CSoundFile *pDragSndFile = pDragDoc->GetSoundFile(); - if(pDragSndFile == nullptr) return false; + CSoundFile &dragSndFile = pInfoDrag->modDoc.GetrSoundFile(); const SEQUENCEINDEX nOrigSeq = (SEQUENCEINDEX)modItemDragID; - const ModSequence *pOrigSeq = &(pDragSndFile->Order.GetSequence(nOrigSeq)); - if(pOrigSeq == nullptr) return false; + const ModSequence &origSeq = dragSndFile.Order.GetSequence(nOrigSeq); if(pSndFile->GetType() == MOD_TYPE_MPT) { @@ -2075,16 +2082,16 @@ if(Reporting::Confirm(_T("Replace the current orderlist?"), _T("Sequence import")) == cnfNo) return false; } - pSndFile->Order.resize(std::min(pSndFile->GetModSpecifications().ordersMax, pOrigSeq->GetLength()), pSndFile->Order.GetInvalidPatIndex()); - for(ORDERINDEX nOrd = 0; nOrd < std::min(pSndFile->GetModSpecifications().ordersMax, pOrigSeq->GetLengthTailTrimmed()); nOrd++) + pSndFile->Order.resize(std::min(pSndFile->GetModSpecifications().ordersMax, origSeq.GetLength()), pSndFile->Order.GetInvalidPatIndex()); + for(ORDERINDEX nOrd = 0; nOrd < std::min(pSndFile->GetModSpecifications().ordersMax, origSeq.GetLengthTailTrimmed()); nOrd++) { - PATTERNINDEX nOrigPat = pDragSndFile->Order.GetSequence(nOrigSeq)[nOrd]; + PATTERNINDEX nOrigPat = dragSndFile.Order.GetSequence(nOrigSeq)[nOrd]; // translate pattern index - if(nOrigPat == pDragSndFile->Order.GetInvalidPatIndex()) + if(nOrigPat == dragSndFile.Order.GetInvalidPatIndex()) pSndFile->Order[nOrd] = pSndFile->Order.GetInvalidPatIndex(); - else if(nOrigPat == pDragSndFile->Order.GetIgnoreIndex() && pSndFile->GetModSpecifications().hasIgnoreIndex) + else if(nOrigPat == dragSndFile.Order.GetIgnoreIndex() && pSndFile->GetModSpecifications().hasIgnoreIndex) pSndFile->Order[nOrd] = pSndFile->Order.GetIgnoreIndex(); - else if(nOrigPat == pDragSndFile->Order.GetIgnoreIndex() && !pSndFile->GetModSpecifications().hasIgnoreIndex) + else if(nOrigPat == dragSndFile.Order.GetIgnoreIndex() && !pSndFile->GetModSpecifications().hasIgnoreIndex) pSndFile->Order[nOrd] = pSndFile->Order.GetInvalidPatIndex(); else if(nOrigPat >= pSndFile->GetModSpecifications().patternsMax) pSndFile->Order[nOrd] = pSndFile->Order.GetInvalidPatIndex(); @@ -2118,13 +2125,10 @@ newOrder.insert(newOrder.begin() + to, from + 1); pModDoc->ReArrangeSamples(newOrder); - } else if(pInfoDrag->pModDoc != nullptr) + } else { // Load sample into other module - pSndFile->ReadSampleFromSong(static_cast<SAMPLEINDEX>(modItemDropID), pInfoDrag->pModDoc->GetrSoundFile(), static_cast<SAMPLEINDEX>(modItemDragID)); - } else - { - return true; + pSndFile->ReadSampleFromSong(static_cast<SAMPLEINDEX>(modItemDropID), pInfoDrag->modDoc.GetrSoundFile(), static_cast<SAMPLEINDEX>(modItemDragID)); } pModDoc->UpdateAllViews(NULL, HINT_SMPNAMES | HINT_SAMPLEINFO | HINT_SAMPLEDATA | HINT_PATTERNDATA, NULL); pModDoc->SetModified(); @@ -2154,13 +2158,10 @@ newOrder.insert(newOrder.begin() + to, from + 1); pModDoc->ReArrangeInstruments(newOrder); - } else if(pInfoDrag->pModDoc != nullptr) + } else { // Load instrument into other module - pSndFile->ReadInstrumentFromSong(static_cast<INSTRUMENTINDEX>(modItemDropID), pInfoDrag->pModDoc->GetrSoundFile(), static_cast<INSTRUMENTINDEX>(modItemDragID)); - } else - { - return true; + pSndFile->ReadInstrumentFromSong(static_cast<INSTRUMENTINDEX>(modItemDropID), pInfoDrag->modDoc.GetrSoundFile(), static_cast<INSTRUMENTINDEX>(modItemDragID)); } pModDoc->UpdateAllViews(NULL, HINT_INSNAMES | HINT_INSTRUMENT | HINT_ENVELOPE | HINT_PATTERNDATA, NULL); pModDoc->SetModified(); @@ -2190,14 +2191,15 @@ } -void CModTree::UpdatePlayPos(CModDoc *pModDoc, Notification *pNotify) -//------------------------------------------------------------------- +void CModTree::UpdatePlayPos(CModDoc &modDoc, Notification *pNotify) +//------------------------------------------------------------------ { - ModTreeDocInfo *pInfo = GetDocumentInfoFromModDoc(pModDoc); + ModTreeDocInfo *pInfo = GetDocumentInfoFromModDoc(modDoc); if(pInfo == nullptr) return; + const CSoundFile &sndFile = modDoc.GetrSoundFile(); ORDERINDEX nNewOrd = (pNotify) ? pNotify->order : ORDERINDEX_INVALID; - SEQUENCEINDEX nNewSeq = pModDoc->GetrSoundFile().Order.GetCurrentSequenceIndex(); + SEQUENCEINDEX nNewSeq = sndFile.Order.GetCurrentSequenceIndex(); if (nNewOrd != pInfo->nOrdSel || nNewSeq != pInfo->nSeqSel) { pInfo->nOrdSel = nNewOrd; @@ -2222,8 +2224,6 @@ if(!updateSamples && !updateInstruments) return; - const CSoundFile &sndFile = pModDoc->GetrSoundFile(); - for(CHANNELINDEX nChn = 0; nChn < MAX_CHANNELS; nChn++) { if(sndFile.Chn[nChn].pCurrentSample != nullptr) @@ -2272,7 +2272,7 @@ std::vector<ModTreeDocInfo *>::iterator iter; for (iter = DocInfo.begin(); iter != DocInfo.end(); iter++) { - if (((*iter)->pModDoc == pModDoc) || (!pModDoc)) + if (&(*iter)->modDoc == pModDoc || !pModDoc) { UpdateView((**iter), dwHint); break; @@ -2326,7 +2326,7 @@ case MODITEM_HDR_ORDERS: // can we drag an order header? (only in MPTM format and if there's only one sequence) { - const CModDoc *pModDoc = (m_nDragDocNdx < DocInfo.size() ? DocInfo[m_nDragDocNdx]->pModDoc : nullptr); + const CModDoc *pModDoc = (m_nDragDocNdx < DocInfo.size() ? &(DocInfo[m_nDragDocNdx]->modDoc) : nullptr); if(pModDoc && pModDoc->GetrSoundFile().Order.GetNumSequences() == 1) bDrag = true; } @@ -2893,23 +2893,23 @@ ModTreeDocInfo *info = GetDocumentInfoFromItem(hItem); if (info) { - CModDoc *pModDoc = info->pModDoc; - if ((modItem.type == MODITEM_SAMPLE) && (!pModDoc->GetNumInstruments())) + CModDoc &modDoc = info->modDoc; + if ((modItem.type == MODITEM_SAMPLE) && !modDoc.GetNumInstruments()) { - pModDoc->MuteSample((SAMPLEINDEX)modItemID, (!pModDoc->IsSampleMuted((SAMPLEINDEX)modItemID))); + modDoc.MuteSample((SAMPLEINDEX)modItemID, !modDoc.IsSampleMuted((SAMPLEINDEX)modItemID)); UpdateView(*info, HINT_SMPNAMES | HINT_SAMPLEINFO | (modItemID << HINT_SHIFT_SMP)); } else - if ((modItem.type == MODITEM_INSTRUMENT) && (pModDoc->GetNumInstruments())) + if ((modItem.type == MODITEM_INSTRUMENT) && modDoc.GetNumInstruments()) { - pModDoc->MuteInstrument((INSTRUMENTINDEX)modItemID, (!pModDoc->IsInstrumentMuted((INSTRUMENTINDEX)modItemID))); + modDoc.MuteInstrument((INSTRUMENTINDEX)modItemID, !modDoc.IsInstrumentMuted((INSTRUMENTINDEX)modItemID)); UpdateView(*info, HINT_INSNAMES | HINT_INSTRUMENT | (modItemID << HINT_SHIFT_INS)); } else if ((modItem.type == MODITEM_EFFECT)) { - CVstPlugin *pVstPlugin = dynamic_cast<CVstPlugin *>(pModDoc->GetrSoundFile().m_MixPlugins[modItemID].pMixPlugin); + CVstPlugin *pVstPlugin = dynamic_cast<CVstPlugin *>(modDoc.GetrSoundFile().m_MixPlugins[modItemID].pMixPlugin); if(pVstPlugin == nullptr) return; pVstPlugin->ToggleBypass(); - pModDoc->SetModified(); + modDoc.SetModified(); //UpdateView(GetDocumentIDFromModDoc(pModDoc), HINT_MIXPLUGINS); } } @@ -2927,20 +2927,20 @@ ModTreeDocInfo *info = GetDocumentInfoFromItem(hItem); if (info) { - CModDoc *pModDoc = info->pModDoc; - INSTRUMENTINDEX nInstruments = pModDoc->GetNumInstruments(); + CModDoc &modDoc = info->modDoc; + INSTRUMENTINDEX nInstruments = modDoc.GetNumInstruments(); if ((modItem.type == MODITEM_SAMPLE) && (!nInstruments)) { - for (SAMPLEINDEX nSmp = 1; nSmp <= pModDoc->GetNumSamples(); nSmp++) + for (SAMPLEINDEX nSmp = 1; nSmp <= modDoc.GetNumSamples(); nSmp++) { - pModDoc->MuteSample(nSmp, nSmp != modItemID); + modDoc.MuteSample(nSmp, nSmp != modItemID); } UpdateView(*info, HINT_SMPNAMES | HINT_SAMPLEINFO); } else if ((modItem.type == MODITEM_INSTRUMENT) && (nInstruments)) { for (INSTRUMENTINDEX nIns = 1; nIns <= nInstruments; nIns++) { - pModDoc->MuteInstrument(nIns, nIns != modItemID); + modDoc.MuteInstrument(nIns, nIns != modItemID); } UpdateView(*info, HINT_INSNAMES | HINT_INSTRUMENT); } @@ -2958,17 +2958,17 @@ ModTreeDocInfo *info = GetDocumentInfoFromItem(hItem); if (info) { - CModDoc *pModDoc = info->pModDoc; + CModDoc &modDoc = info->modDoc; if ((modItem.type == MODITEM_SAMPLE) || (modItem.type == MODITEM_INSTRUMENT)) { - for (SAMPLEINDEX nSmp = 1; nSmp <= pModDoc->GetNumSamples(); nSmp++) + for (SAMPLEINDEX nSmp = 1; nSmp <= modDoc.GetNumSamples(); nSmp++) { - pModDoc->MuteSample(nSmp, false); + modDoc.MuteSample(nSmp, false); } UpdateView(*info, HINT_SMPNAMES | HINT_SAMPLEINFO); - for (INSTRUMENTINDEX nIns = 1; nIns <= pModDoc->GetNumInstruments(); nIns++) + for (INSTRUMENTINDEX nIns = 1; nIns <= modDoc.GetNumInstruments(); nIns++) { - pModDoc->MuteInstrument(nIns, false); + modDoc.MuteInstrument(nIns, false); } UpdateView(*info, HINT_INSNAMES | HINT_INSTRUMENT); } @@ -3002,8 +3002,8 @@ ModTreeDocInfo *info = GetDocumentInfoFromItem(hItem); if (info) { - CModDoc *pModDoc = info->pModDoc; - CSoundFile &sndFile = pModDoc->GetrSoundFile(); + CModDoc &modDoc = info->modDoc; + CSoundFile &sndFile = modDoc.GetrSoundFile(); if(modItem.type == MODITEM_SEQUENCE || modItem.type == MODITEM_HDR_ORDERS) { // Duplicate / insert sequence @@ -3015,17 +3015,17 @@ sndFile.Order.SetSequence((SEQUENCEINDEX)modItemID); sndFile.Order.AddSequence(true); } - pModDoc->SetModified(); + modDoc.SetModified(); UpdateView(*info, HINT_SEQNAMES|HINT_MODSEQUENCE | (DWORD)(MAX_SEQUENCES << HINT_SHIFT_SEQUENCE)); - pModDoc->UpdateAllViews(NULL, HINT_SEQNAMES|HINT_MODSEQUENCE); + modDoc.UpdateAllViews(NULL, HINT_SEQNAMES|HINT_MODSEQUENCE); } else if(modItem.type == MODITEM_SAMPLE) { // Duplicate / insert sample std::vector<SAMPLEINDEX> newOrder = GenerateInsertVector<SAMPLEINDEX>(sndFile.GetNumSamples(), modItemID, static_cast<SAMPLEINDEX>(insert ? 0 : modItemID)); - if(pModDoc->ReArrangeSamples(newOrder) != SAMPLEINDEX_INVALID) + if(modDoc.ReArrangeSamples(newOrder) != SAMPLEINDEX_INVALID) { - pModDoc->SetModified(); - pModDoc->UpdateAllViews(NULL, HINT_SMPNAMES | HINT_SAMPLEINFO | HINT_SAMPLEDATA | HINT_PATTERNDATA); + modDoc.SetModified(); + modDoc.UpdateAllViews(NULL, HINT_SMPNAMES | HINT_SAMPLEINFO | HINT_SAMPLEDATA | HINT_PATTERNDATA); } else { Reporting::Error("Maximum number of samples reached."); @@ -3034,10 +3034,10 @@ { // Duplicate / insert instrument std::vector<INSTRUMENTINDEX> newOrder = GenerateInsertVector<INSTRUMENTINDEX>(sndFile.GetNumInstruments(), modItemID, static_cast<INSTRUMENTINDEX>(insert ? 0 : modItemID)); - if(pModDoc->ReArrangeInstruments(newOrder) != INSTRUMENTINDEX_INVALID) + if(modDoc.ReArrangeInstruments(newOrder) != INSTRUMENTINDEX_INVALID) { - pModDoc->UpdateAllViews(NULL, HINT_INSNAMES | HINT_INSTRUMENT | HINT_ENVELOPE | HINT_PATTERNDATA); - pModDoc->SetModified(); + modDoc.UpdateAllViews(NULL, HINT_INSNAMES | HINT_INSTRUMENT | HINT_ENVELOPE | HINT_PATTERNDATA); + modDoc.SetModified(); } else { Reporting::Error("Maximum number of instruments reached."); Modified: trunk/OpenMPT/mptrack/View_tre.h =================================================================== --- trunk/OpenMPT/mptrack/View_tre.h 2013-11-19 16:44:45 UTC (rev 3270) +++ trunk/OpenMPT/mptrack/View_tre.h 2013-11-19 17:18:47 UTC (rev 3271) @@ -13,6 +13,7 @@ class CModDoc; class CModTree; +class CSoundFile; #include <vector> #include <bitset> @@ -27,7 +28,7 @@ // Tree state variables std::vector<std::vector<HTREEITEM> > tiOrders; std::vector<HTREEITEM> tiSequences, tiPatterns; - CModDoc *pModDoc; + CModDoc &modDoc; HTREEITEM hSong, hPatterns, hSamples, hInstruments, hComments, hOrders, hEffects; // Module information @@ -37,18 +38,7 @@ std::bitset<MAX_SAMPLES> samplesPlaying; std::bitset<MAX_INSTRUMENTS> instrumentsPlaying; - ModTreeDocInfo(const CSoundFile &sndFile) - { - pModDoc = sndFile.GetpModDoc(); - nSeqSel = SEQUENCEINDEX_INVALID; - nOrdSel = ORDERINDEX_INVALID; - hSong = hPatterns = hSamples = hInstruments = hComments = hOrders = hEffects = nullptr; - tiPatterns.resize(sndFile.Patterns.Size(), nullptr); - tiOrders.resize(sndFile.Order.GetNumSequences()); - tiSequences.resize(sndFile.Order.GetNumSequences(), nullptr); - samplesPlaying.reset(); - instrumentsPlaying.reset(); - } + ModTreeDocInfo(CModDoc &modDoc); }; @@ -211,12 +201,12 @@ void InstrumentLibraryChDir(mpt::PathString dir, bool isSong); bool GetDropInfo(DRAGONDROP &dropInfo, mpt::PathString &fullPath); void OnOptionsChanged(); - void AddDocument(CModDoc *pModDoc); - void RemoveDocument(CModDoc *pModDoc); + void AddDocument(CModDoc &modDoc); + void RemoveDocument(CModDoc &modDoc); void UpdateView(ModTreeDocInfo &info, DWORD dwHint); void OnUpdate(CModDoc *pModDoc, DWORD dwHint, CObject *pHint); bool CanDrop(HTREEITEM hItem, bool bDoDrop); - void UpdatePlayPos(CModDoc *pModDoc, Notification *pNotify); + void UpdatePlayPos(CModDoc &modDoc, Notification *pNotify); bool IsItemExpanded(HTREEITEM hItem); void DeleteChildren(HTREEITEM hItem); HTREEITEM GetNthChildItem(HTREEITEM hItem, int index); @@ -242,8 +232,8 @@ static int CALLBACK ModTreeDrumCompareProc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort); void ModTreeInsert(const WCHAR *name, int image); ModTreeDocInfo *GetDocumentInfoFromItem(HTREEITEM hItem); - CModDoc *GetDocumentFromItem(HTREEITEM hItem) { ModTreeDocInfo *info = GetDocumentInfoFromItem(hItem); return info ? info->pModDoc : nullptr; } - ModTreeDocInfo *GetDocumentInfoFromModDoc(CModDoc *pModDoc); + CModDoc *GetDocumentFromItem(HTREEITEM hItem) { ModTreeDocInfo *info = GetDocumentInfoFromItem(hItem); return info ? &info->modDoc : nullptr; } + ModTreeDocInfo *GetDocumentInfoFromModDoc(CModDoc &modDoc); void InsertOrDupItem(bool insert); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2013-11-24 23:33:35
|
Revision: 3306 http://sourceforge.net/p/modplug/code/3306 Author: saga-games Date: 2013-11-24 23:33:26 +0000 (Sun, 24 Nov 2013) Log Message: ----------- [Fix] Tab background colour is now finally correct in VS2010 builds. Modified Paths: -------------- trunk/OpenMPT/mptrack/Globals.cpp trunk/OpenMPT/mptrack/Globals.h Modified: trunk/OpenMPT/mptrack/Globals.cpp =================================================================== --- trunk/OpenMPT/mptrack/Globals.cpp 2013-11-24 19:28:11 UTC (rev 3305) +++ trunk/OpenMPT/mptrack/Globals.cpp 2013-11-24 23:33:26 UTC (rev 3306) @@ -187,7 +187,6 @@ //{{AFX_MSG_MAP(CModControlView) ON_WM_SIZE() ON_WM_DESTROY() - ON_WM_ERASEBKGND() ON_NOTIFY(TCN_SELCHANGE, IDC_TABCTRL1, OnTabSelchange) ON_MESSAGE(WM_MOD_ACTIVATEVIEW, OnActivateModView) ON_MESSAGE(WM_MOD_CTRLMSG, OnModCtrlMsg) Modified: trunk/OpenMPT/mptrack/Globals.h =================================================================== --- trunk/OpenMPT/mptrack/Globals.h 2013-11-24 19:28:11 UTC (rev 3305) +++ trunk/OpenMPT/mptrack/Globals.h 2013-11-24 23:33:26 UTC (rev 3306) @@ -160,7 +160,6 @@ protected: //{{AFX_MSG(CModControlView) afx_msg void OnSize(UINT nType, int cx, int cy); - afx_msg BOOL OnEraseBkgnd(CDC *) { return TRUE; } afx_msg void OnDestroy(); afx_msg void OnTabSelchange(NMHDR* pNMHDR, LRESULT* pResult); afx_msg void OnEditCut() { if (m_hWndView) ::SendMessage(m_hWndView, WM_COMMAND, ID_EDIT_CUT, 0); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2013-12-01 00:08:32
|
Revision: 3342 http://sourceforge.net/p/modplug/code/3342 Author: saga-games Date: 2013-12-01 00:08:23 +0000 (Sun, 01 Dec 2013) Log Message: ----------- [Imp] Set large address awareness flag for OpenMPT. Modified Paths: -------------- trunk/OpenMPT/mptrack/mptrack_08.vcproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj Modified: trunk/OpenMPT/mptrack/mptrack_08.vcproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_08.vcproj 2013-11-30 20:22:32 UTC (rev 3341) +++ trunk/OpenMPT/mptrack/mptrack_08.vcproj 2013-12-01 00:08:23 UTC (rev 3342) @@ -91,6 +91,7 @@ SubSystem="2" RandomizedBaseAddress="1" DataExecutionPrevention="0" + LargeAddressAware="2" /> <Tool Name="VCALinkTool" @@ -190,6 +191,7 @@ EnableCOMDATFolding="2" RandomizedBaseAddress="2" DataExecutionPrevention="0" + LargeAddressAware="2" /> <Tool Name="VCALinkTool" Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2013-11-30 20:22:32 UTC (rev 3341) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2013-12-01 00:08:23 UTC (rev 3342) @@ -157,6 +157,7 @@ <RandomizedBaseAddress>false</RandomizedBaseAddress> <DataExecutionPrevention> </DataExecutionPrevention> + <LargeAddressAware>true</LargeAddressAware> </Link> <Manifest> <AdditionalManifestFiles>$(ProjectDir)res/rt_manif.bin;%(AdditionalManifestFiles)</AdditionalManifestFiles> @@ -207,6 +208,7 @@ <RandomizedBaseAddress>false</RandomizedBaseAddress> <DataExecutionPrevention> </DataExecutionPrevention> + <LargeAddressAware>true</LargeAddressAware> </Link> <Manifest> <AdditionalManifestFiles>$(ProjectDir)res/rt_manif.bin;%(AdditionalManifestFiles)</AdditionalManifestFiles> @@ -263,6 +265,7 @@ <IgnoreSpecificDefaultLibraries> </IgnoreSpecificDefaultLibraries> <LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration> + <LargeAddressAware>true</LargeAddressAware> </Link> <Manifest> <AdditionalManifestFiles>$(ProjectDir)res/rt_manif.bin;%(AdditionalManifestFiles)</AdditionalManifestFiles> @@ -318,6 +321,7 @@ <IgnoreSpecificDefaultLibraries> </IgnoreSpecificDefaultLibraries> <LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration> + <LargeAddressAware>true</LargeAddressAware> </Link> <Manifest> <AdditionalManifestFiles>$(ProjectDir)res/rt_manif.bin;%(AdditionalManifestFiles)</AdditionalManifestFiles> @@ -374,6 +378,7 @@ </IgnoreSpecificDefaultLibraries> <LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration> <GenerateDebugInformation>false</GenerateDebugInformation> + <LargeAddressAware>true</LargeAddressAware> </Link> <Manifest> <AdditionalManifestFiles>$(ProjectDir)res/rt_manif.bin;%(AdditionalManifestFiles)</AdditionalManifestFiles> @@ -429,6 +434,7 @@ <IgnoreSpecificDefaultLibraries> </IgnoreSpecificDefaultLibraries> <LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration> + <LargeAddressAware>true</LargeAddressAware> </Link> <Manifest> <AdditionalManifestFiles>$(ProjectDir)res/rt_manif.bin;%(AdditionalManifestFiles)</AdditionalManifestFiles> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2013-12-01 23:02:27
|
Revision: 3345 http://sourceforge.net/p/modplug/code/3345 Author: saga-games Date: 2013-12-01 23:02:18 +0000 (Sun, 01 Dec 2013) Log Message: ----------- [Imp] Add proper parent window handles to file / folder selection dialogs. Modified Paths: -------------- trunk/OpenMPT/mptrack/AutoSaver.cpp trunk/OpenMPT/mptrack/Ctrl_ins.cpp trunk/OpenMPT/mptrack/Ctrl_smp.cpp trunk/OpenMPT/mptrack/FileDialog.cpp trunk/OpenMPT/mptrack/FileDialog.h trunk/OpenMPT/mptrack/KeyConfigDlg.cpp trunk/OpenMPT/mptrack/Moptions.cpp trunk/OpenMPT/mptrack/SelectPluginDialog.cpp trunk/OpenMPT/mptrack/TuningDialog.cpp Modified: trunk/OpenMPT/mptrack/AutoSaver.cpp =================================================================== --- trunk/OpenMPT/mptrack/AutoSaver.cpp 2013-12-01 21:06:29 UTC (rev 3344) +++ trunk/OpenMPT/mptrack/AutoSaver.cpp 2013-12-01 23:02:18 UTC (rev 3345) @@ -415,7 +415,7 @@ ::GetDlgItemTextW(m_hWnd, IDC_AUTOSAVE_PATH, szPath, CountOf(szPath)); BrowseForFolder dlg(mpt::PathString::FromNative(szPath), TEXT("Select a folder to store autosaved files in...")); - if(dlg.Show()) + if(dlg.Show(this)) { ::SetDlgItemTextW(m_hWnd, IDC_AUTOSAVE_PATH, dlg.GetDirectory().AsNative().c_str()); OnSettingsChanged(); Modified: trunk/OpenMPT/mptrack/Ctrl_ins.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2013-12-01 21:06:29 UTC (rev 3344) +++ trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2013-12-01 23:02:18 UTC (rev 3345) @@ -1691,7 +1691,7 @@ "All Files (*.*)|*.*||") .WorkingDirectory(TrackerDirectories::Instance().GetWorkingDirectory(DIR_INSTRUMENTS)) .FilterIndex(&nLastIndex); - if(!dlg.Show()) return; + if(!dlg.Show(this)) return; TrackerDirectories::Instance().SetWorkingDirectory(dlg.GetWorkingDirectory(), DIR_INSTRUMENTS, true); @@ -1749,7 +1749,7 @@ "FastTracker II Instruments (*.xi)|*.xi||") .WorkingDirectory(TrackerDirectories::Instance().GetWorkingDirectory(DIR_INSTRUMENTS)) .FilterIndex(&index); - if(!dlg.Show()) return; + if(!dlg.Show(this)) return; BeginWaitCursor(); Modified: trunk/OpenMPT/mptrack/Ctrl_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2013-12-01 21:06:29 UTC (rev 3344) +++ trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2013-12-01 23:02:18 UTC (rev 3345) @@ -962,7 +962,7 @@ "All Files (*.*)|*.*||") .WorkingDirectory(TrackerDirectories::Instance().GetWorkingDirectory(DIR_SAMPLES)) .FilterIndex(&nLastIndex); - if(!dlg.Show()) return; + if(!dlg.Show(this)) return; TrackerDirectories::Instance().SetWorkingDirectory(dlg.GetWorkingDirectory(), DIR_SAMPLES, true); @@ -1033,7 +1033,7 @@ "RAW Audio (*.raw)|*.raw||") .WorkingDirectory(TrackerDirectories::Instance().GetWorkingDirectory(DIR_SAMPLES)) .FilterIndex(&filter); - if(!dlg.Show()) return; + if(!dlg.Show(this)) return; BeginWaitCursor(); Modified: trunk/OpenMPT/mptrack/FileDialog.cpp =================================================================== --- trunk/OpenMPT/mptrack/FileDialog.cpp 2013-12-01 21:06:29 UTC (rev 3344) +++ trunk/OpenMPT/mptrack/FileDialog.cpp 2013-12-01 23:02:18 UTC (rev 3345) @@ -16,8 +16,8 @@ // Display the file dialog. -bool FileDialog::Show() -//--------------------- +bool FileDialog::Show(CWnd *parent) +//--------------------------------- { filenames.clear(); @@ -37,7 +37,7 @@ OPENFILENAMEW ofn; MemsetZero(ofn); ofn.lStructSize = sizeof(OPENFILENAMEW); - ofn.hwndOwner = theApp.m_pMainWnd->GetSafeHwnd(); + ofn.hwndOwner = (parent != nullptr ? parent : theApp.m_pMainWnd)->GetSafeHwnd(); ofn.hInstance = theApp.m_hInstance; ofn.lpstrFilter = extFilter.c_str(); ofn.lpstrCustomFilter = NULL; @@ -122,14 +122,14 @@ // Display the folder dialog. -bool BrowseForFolder::Show() -//-------------------------- +bool BrowseForFolder::Show(CWnd *parent) +//-------------------------------------- { WCHAR path[MAX_PATH]; BROWSEINFOW bi; MemsetZero(bi); - bi.hwndOwner = theApp.m_pMainWnd->GetSafeHwnd(); + bi.hwndOwner = (parent != nullptr ? parent : theApp.m_pMainWnd)->GetSafeHwnd(); bi.lpszTitle = caption.empty() ? NULL : caption.c_str(); bi.pszDisplayName = path; bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_USENEWUI; Modified: trunk/OpenMPT/mptrack/FileDialog.h =================================================================== --- trunk/OpenMPT/mptrack/FileDialog.h 2013-12-01 21:06:29 UTC (rev 3344) +++ trunk/OpenMPT/mptrack/FileDialog.h 2013-12-01 23:02:18 UTC (rev 3345) @@ -52,7 +52,7 @@ FileDialog &FilterIndex(int *index) { filterIndex = index; return *this; } // Show the file selection dialog. - bool Show(); + bool Show(CWnd *parent = nullptr); // Get some selected file. Mostly useful when only one selected file is possible anyway. mpt::PathString GetFirstFile() const @@ -106,7 +106,7 @@ BrowseForFolder(const mpt::PathString &dir, const CString &caption) : workingDirectory(dir), caption(mpt::ToWide(caption)) { } // Show the folder selection dialog. - bool Show(); + bool Show(CWnd *parent = nullptr); // Gets selected directory. mpt::PathString GetDirectory() const { return workingDirectory; } Modified: trunk/OpenMPT/mptrack/KeyConfigDlg.cpp =================================================================== --- trunk/OpenMPT/mptrack/KeyConfigDlg.cpp 2013-12-01 21:06:29 UTC (rev 3344) +++ trunk/OpenMPT/mptrack/KeyConfigDlg.cpp 2013-12-01 23:02:18 UTC (rev 3345) @@ -842,7 +842,7 @@ .DefaultFilename(m_sFullPathName) .ExtensionFilter("OpenMPT Key Bindings (*.mkb)|*.mkb||") .WorkingDirectory(TrackerSettings::Instance().m_szKbdFile); - if(!dlg.Show()) return; + if(!dlg.Show(this)) return; m_sFullPathName = dlg.GetFirstFile(); plocalCmdSet->LoadFile(m_sFullPathName); @@ -859,7 +859,7 @@ .DefaultFilename(m_sFullPathName) .ExtensionFilter("OpenMPT Key Bindings (*.mkb)|*.mkb||") .WorkingDirectory(TrackerSettings::Instance().m_szKbdFile); - if(!dlg.Show()) return; + if(!dlg.Show(this)) return; m_sFullPathName = dlg.GetFirstFile(); plocalCmdSet->SaveFile(m_sFullPathName); Modified: trunk/OpenMPT/mptrack/Moptions.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moptions.cpp 2013-12-01 21:06:29 UTC (rev 3344) +++ trunk/OpenMPT/mptrack/Moptions.cpp 2013-12-01 23:02:18 UTC (rev 3345) @@ -492,7 +492,7 @@ .DefaultExtension("mptcolor") .ExtensionFilter("OpenMPT Color Schemes|*.mptcolor||") .WorkingDirectory(theApp.GetConfigPath()); - if(!dlg.Show()) return; + if(!dlg.Show(this)) return; // Ensure that all colours are reset (for outdated colour schemes) OnPresetMPT(); @@ -515,7 +515,7 @@ .DefaultExtension("mptcolor") .ExtensionFilter("OpenMPT Color Schemes|*.mptcolor||") .WorkingDirectory(theApp.GetConfigPath()); - if(!dlg.Show()) return; + if(!dlg.Show(this)) return; { IniFileSettingsContainer file(dlg.GetFirstFile()); @@ -669,7 +669,7 @@ ::GetDlgItemTextW(m_hWnd, nID, szPath, CountOf(szPath)); ::BrowseForFolder dlg(mpt::PathString::FromNative(szPath), TEXT("Select a default folder...")); - if(dlg.Show()) + if(dlg.Show(this)) { ::SetDlgItemTextW(m_hWnd, nID, dlg.GetDirectory().AsNative().c_str()); OnSettingsChanged(); Modified: trunk/OpenMPT/mptrack/SelectPluginDialog.cpp =================================================================== --- trunk/OpenMPT/mptrack/SelectPluginDialog.cpp 2013-12-01 21:06:29 UTC (rev 3344) +++ trunk/OpenMPT/mptrack/SelectPluginDialog.cpp 2013-12-01 23:02:18 UTC (rev 3345) @@ -488,7 +488,7 @@ .DefaultExtension("dll") .ExtensionFilter("VST Plugins (*.dll)|*.dll||") .WorkingDirectory(TrackerDirectories::Instance().GetWorkingDirectory(DIR_PLUGINS)); - if(!dlg.Show()) return; + if(!dlg.Show(this)) return; TrackerDirectories::Instance().SetWorkingDirectory(dlg.GetWorkingDirectory(), DIR_PLUGINS, true); Modified: trunk/OpenMPT/mptrack/TuningDialog.cpp =================================================================== --- trunk/OpenMPT/mptrack/TuningDialog.cpp 2013-12-01 21:06:29 UTC (rev 3344) +++ trunk/OpenMPT/mptrack/TuningDialog.cpp 2013-12-01 23:02:18 UTC (rev 3345) @@ -637,7 +637,7 @@ .ExtensionFilter(filter) .WorkingDirectory(TrackerDirectories::Instance().GetWorkingDirectory(DIR_TUNING)) .FilterIndex(&filterIndex); - if(!dlg.Show()) return; + if(!dlg.Show(this)) return; BeginWaitCursor(); @@ -677,7 +677,7 @@ .AllowMultiSelect() .ExtensionFilter(sFilter) .WorkingDirectory(TrackerDirectories::Instance().GetWorkingDirectory(DIR_TUNING)); - if(!dlg.Show()) + if(!dlg.Show(this)) return; TrackerDirectories::Instance().SetWorkingDirectory(dlg.GetWorkingDirectory(), DIR_TUNING, true); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-12-02 15:04:53
|
Revision: 3349 http://sourceforge.net/p/modplug/code/3349 Author: manxorist Date: 2013-12-02 15:04:47 +0000 (Mon, 02 Dec 2013) Log Message: ----------- [Imp] sounddev: Add hidden setting [Sound Settings]KeepDeviceOpen which keeps the sound device open when playback is stopped and thereby avoids pontential latency caused by (re-)opening the device. Modified Paths: -------------- trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mainfrm.h trunk/OpenMPT/mptrack/TrackerSettings.cpp trunk/OpenMPT/mptrack/TrackerSettings.h Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2013-12-02 14:24:42 UTC (rev 3348) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2013-12-02 15:04:47 UTC (rev 3349) @@ -459,6 +459,8 @@ if(gpSoundDevice) { + gpSoundDevice->Stop(); + gpSoundDevice->Close(); delete gpSoundDevice; gpSoundDevice = nullptr; } @@ -786,6 +788,8 @@ const SoundDeviceID deviceID = TrackerSettings::Instance().GetSoundDeviceID(); if(gpSoundDevice && (gpSoundDevice->GetDeviceID() != deviceID)) { + gpSoundDevice->Stop(); + gpSoundDevice->Close(); delete gpSoundDevice; gpSoundDevice = nullptr; } @@ -822,14 +826,6 @@ } -bool CMainFrame::audioReopenDevice() -//---------------------------------- -{ - audioCloseDevice(); - return audioOpenDevice(); -} - - void CMainFrame::audioCloseDevice() //--------------------------------- { @@ -1211,7 +1207,10 @@ m_NotifyTimer = 0; } ResetNotificationBuffer(); - audioCloseDevice(); + if(!TrackerSettings::Instance().m_SoundSettingsKeepDeviceOpen) + { + audioCloseDevice(); + } } @@ -1596,25 +1595,23 @@ BOOL CMainFrame::SetupSoundCard(const SoundDeviceSettings &deviceSettings, SoundDeviceID deviceID) //------------------------------------------------------------------------------------------------ { - const bool isPlaying = IsPlaying(); if((TrackerSettings::Instance().GetSoundDeviceID() != deviceID) || (TrackerSettings::Instance().GetSoundDeviceSettings(deviceID) != deviceSettings)) { - CModDoc *pActiveMod = NULL; - if (isPlaying) + CModDoc *pActiveMod = nullptr; + if(IsPlaying()) { if ((m_pSndFile) && (!m_pSndFile->IsPaused())) pActiveMod = GetModPlaying(); PauseMod(); } + gpSoundDevice->Close(); TrackerSettings::Instance().SetSoundDeviceID(deviceID); TrackerSettings::Instance().SetSoundDeviceSettings(deviceID, deviceSettings); - TrackerSettings::Instance().MixerOutputChannels = deviceSettings.Channels; TrackerSettings::Instance().MixerSamplerate = deviceSettings.Samplerate; + if(pActiveMod) { - CriticalSection cs; - if (pActiveMod) UpdateAudioParameters(pActiveMod->GetrSoundFile(), FALSE); + PlayMod(pActiveMod); } - if (pActiveMod) PlayMod(pActiveMod); UpdateWindow(); } else { Modified: trunk/OpenMPT/mptrack/Mainfrm.h =================================================================== --- trunk/OpenMPT/mptrack/Mainfrm.h 2013-12-02 14:24:42 UTC (rev 3348) +++ trunk/OpenMPT/mptrack/Mainfrm.h 2013-12-02 15:04:47 UTC (rev 3349) @@ -343,7 +343,6 @@ bool InNotifyHandler() const { return m_InNotifyHandler; } bool audioOpenDevice(); - bool audioReopenDevice(); void audioCloseDevice(); bool IsAudioDeviceOpen() const; bool DoNotification(DWORD dwSamplesRead, int64 streamPosition); Modified: trunk/OpenMPT/mptrack/TrackerSettings.cpp =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.cpp 2013-12-02 14:24:42 UTC (rev 3348) +++ trunk/OpenMPT/mptrack/TrackerSettings.cpp 2013-12-02 15:04:47 UTC (rev 3349) @@ -154,6 +154,7 @@ // Sound Settings , m_SoundSampleRates(conf, "Sound Settings", "SampleRates", GetDefaultSampleRates()) , m_MorePortaudio(conf, "Sound Settings", "MorePortaudio", false) + , m_SoundSettingsKeepDeviceOpen(conf, "Sound Settings", "KeepDeviceOpen", false) , m_SoundDeviceSettingsUseOldDefaults(false) , m_SoundDeviceIdentifier(conf, "Sound Settings", "Device", std::wstring()) , MixerMaxChannels(conf, "Sound Settings", "MixChannels", MixerSettings().m_nMaxMixChannels) Modified: trunk/OpenMPT/mptrack/TrackerSettings.h =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.h 2013-12-02 14:24:42 UTC (rev 3348) +++ trunk/OpenMPT/mptrack/TrackerSettings.h 2013-12-02 15:04:47 UTC (rev 3349) @@ -274,6 +274,7 @@ Setting<std::vector<uint32> > m_SoundSampleRates; Setting<bool> m_MorePortaudio; + Setting<bool> m_SoundSettingsKeepDeviceOpen; bool m_SoundDeviceSettingsUseOldDefaults; SoundDeviceID m_SoundDeviceID_DEPRECATED; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-12-02 16:02:47
|
Revision: 3351 http://sourceforge.net/p/modplug/code/3351 Author: manxorist Date: 2013-12-02 16:02:40 +0000 (Mon, 02 Dec 2013) Log Message: ----------- [Mod] Mod Export: Do not use 96kHz default samplerate for WAV and FLAC. Modified Paths: -------------- trunk/OpenMPT/mptrack/StreamEncoderFLAC.cpp trunk/OpenMPT/mptrack/StreamEncoderWAV.cpp Modified: trunk/OpenMPT/mptrack/StreamEncoderFLAC.cpp =================================================================== --- trunk/OpenMPT/mptrack/StreamEncoderFLAC.cpp 2013-12-02 15:49:11 UTC (rev 3350) +++ trunk/OpenMPT/mptrack/StreamEncoderFLAC.cpp 2013-12-02 16:02:40 UTC (rev 3351) @@ -293,7 +293,7 @@ } } } - traits.defaultSamplerate = 96000; + traits.defaultSamplerate = 48000; traits.defaultChannels = 2; traits.defaultMode = Encoder::ModeEnumerated; traits.defaultFormat = 0; Modified: trunk/OpenMPT/mptrack/StreamEncoderWAV.cpp =================================================================== --- trunk/OpenMPT/mptrack/StreamEncoderWAV.cpp 2013-12-02 15:49:11 UTC (rev 3350) +++ trunk/OpenMPT/mptrack/StreamEncoderWAV.cpp 2013-12-02 16:02:40 UTC (rev 3351) @@ -197,7 +197,7 @@ } } } - traits.defaultSamplerate = 96000; + traits.defaultSamplerate = 48000; traits.defaultChannels = 2; traits.defaultMode = Encoder::ModeEnumerated; traits.defaultFormat = 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2013-12-05 16:44:19
|
Revision: 3380 http://sourceforge.net/p/modplug/code/3380 Author: saga-games Date: 2013-12-05 16:44:13 +0000 (Thu, 05 Dec 2013) Log Message: ----------- [Mod] Song properites: Disable MixMode RC3 for XM/IT. [Imp] Envelope view: Always use the back buffer for drawing position marks. Modified Paths: -------------- trunk/OpenMPT/mptrack/View_ins.cpp trunk/OpenMPT/mptrack/View_ins.h trunk/OpenMPT/mptrack/dlg_misc.cpp Modified: trunk/OpenMPT/mptrack/View_ins.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_ins.cpp 2013-12-05 16:43:01 UTC (rev 3379) +++ trunk/OpenMPT/mptrack/View_ins.cpp 2013-12-05 16:44:13 UTC (rev 3380) @@ -850,7 +850,7 @@ } } - pDC->BitBlt(m_rcClient.left, m_rcClient.top, m_rcClient.right-m_rcClient.left, m_rcClient.bottom-m_rcClient.top, &m_dcGrid, 0, 0, SRCCOPY); + pDC->BitBlt(m_rcClient.left, m_rcClient.top, m_rcClient.Width(), m_rcClient.Height(), &m_dcGrid, 0, 0, SRCCOPY); } //end rewbs.envRowGrid @@ -962,11 +962,11 @@ } } - DrawPositionMarks(m_dcMemMain.m_hDC); + DrawPositionMarks(); if (oldpen) m_dcMemMain.SelectObject(oldpen); //rewbs.envRowGrid - pDC->BitBlt(m_rcClient.left, m_rcClient.top, m_rcClient.right-m_rcClient.left, m_rcClient.bottom-m_rcClient.top, &m_dcMemMain, 0, 0, SRCCOPY); + pDC->BitBlt(m_rcClient.left, m_rcClient.top, m_rcClient.Width(), m_rcClient.Height(), &m_dcMemMain, 0, 0, SRCCOPY); // -> CODE#0015 // -> DESC="channels management dlg" @@ -1127,8 +1127,8 @@ -void CViewInstrument::DrawPositionMarks(HDC hdc) -//---------------------------------------------- +void CViewInstrument::DrawPositionMarks() +//--------------------------------------- { CRect rect; for(UINT i = 0; i < MAX_CHANNELS; i++) if (m_dwNotifyPos[i] != Notification::PosInvalid) @@ -1137,7 +1137,7 @@ rect.left = TickToScreen(m_dwNotifyPos[i]); rect.right = rect.left + 1; rect.bottom = m_rcClient.bottom + 1; - InvertRect(hdc, &rect); + InvertRect(m_dcMemMain.m_hDC, &rect); } } @@ -1185,14 +1185,15 @@ if (bUpdate) { HDC hdc = ::GetDC(m_hWnd); - DrawPositionMarks(hdc); + DrawPositionMarks(); for (CHANNELINDEX j = 0; j < MAX_CHANNELS; j++) { //DWORD newpos = (pSndFile->m_SongFlags[SONG_PAUSED]) ? pnotify->dwPos[j] : 0; uint32 newpos = (uint32)pnotify->pos[j]; m_dwNotifyPos[j] = newpos; } - DrawPositionMarks(hdc); + DrawPositionMarks(); + BitBlt(hdc, m_rcClient.left, m_rcClient.top, m_rcClient.Width(), m_rcClient.Height(), m_dcMemMain.GetSafeHdc(), 0, 0, SRCCOPY); ::ReleaseDC(m_hWnd, hdc); } } Modified: trunk/OpenMPT/mptrack/View_ins.h =================================================================== --- trunk/OpenMPT/mptrack/View_ins.h 2013-12-05 16:43:01 UTC (rev 3379) +++ trunk/OpenMPT/mptrack/View_ins.h 2013-12-05 16:44:13 UTC (rev 3380) @@ -25,7 +25,7 @@ protected: CImageList m_bmpEnvBar; POINT m_ptMenu; - RECT m_rcClient; + CRect m_rcClient; CBitmap m_bmpGrid; CBitmap m_bmpMemMain; @@ -145,7 +145,7 @@ int ValueToScreen(int val) const { return m_rcClient.bottom - 1 - (val * (m_rcClient.bottom - 1)) / 64; } int ScreenToValue(int y) const; void InvalidateEnvelope() { InvalidateRect(NULL, FALSE); } - void DrawPositionMarks(HDC hdc); + void DrawPositionMarks(); void DrawNcButton(CDC *pDC, UINT nBtn); BOOL GetNcButtonRect(UINT nBtn, LPRECT lpRect); void UpdateNcButtonState(); Modified: trunk/OpenMPT/mptrack/dlg_misc.cpp =================================================================== --- trunk/OpenMPT/mptrack/dlg_misc.cpp 2013-12-05 16:43:01 UTC (rev 3379) +++ trunk/OpenMPT/mptrack/dlg_misc.cpp 2013-12-05 16:44:13 UTC (rev 3380) @@ -94,12 +94,12 @@ // Tempo modes // Don't show new tempo modes for XM/IT, unless they are currently used - const bool showNewTempoModes = (sndFile.GetType() == MOD_TYPE_MPT || (sndFile.m_SongFlags[SONG_ITPROJECT] != 0)); + const bool showNewModes = (sndFile.GetType() == MOD_TYPE_MPT || (sndFile.m_SongFlags[SONG_ITPROJECT] != 0)); m_TempoModeBox.SetItemData(m_TempoModeBox.AddString("Classic"), tempo_mode_classic); - if(showNewTempoModes || sndFile.m_nTempoMode == tempo_mode_alternative) + if(showNewModes || sndFile.m_nTempoMode == tempo_mode_alternative) m_TempoModeBox.SetItemData(m_TempoModeBox.AddString("Alternative"), tempo_mode_alternative); - if(showNewTempoModes || sndFile.m_nTempoMode == tempo_mode_modern) + if(showNewModes || sndFile.m_nTempoMode == tempo_mode_modern) m_TempoModeBox.SetItemData(m_TempoModeBox.AddString("Modern (accurate)"), tempo_mode_modern); m_TempoModeBox.SetCurSel(0); for(int i = m_TempoModeBox.GetCount(); i > 0; i--) @@ -113,7 +113,8 @@ // Mix levels - m_PlugMixBox.SetItemData(m_PlugMixBox.AddString("OpenMPT 1.17RC3"), mixLevels_117RC3); + if(showNewModes || sndFile.GetMixLevels() == mixLevels_117RC3) // In XM/IT, this is only shown for backwards compatibility with existing tunes + m_PlugMixBox.SetItemData(m_PlugMixBox.AddString("OpenMPT 1.17RC3"), mixLevels_117RC3); if(sndFile.GetMixLevels() == mixLevels_117RC2) // Only shown for backwards compatibility with existing tunes m_PlugMixBox.SetItemData(m_PlugMixBox.AddString("OpenMPT 1.17RC2"), mixLevels_117RC2); if(sndFile.GetMixLevels() == mixLevels_117RC1) // Dito This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-12-07 19:39:05
|
Revision: 3410 http://sourceforge.net/p/modplug/code/3410 Author: manxorist Date: 2013-12-07 19:38:57 +0000 (Sat, 07 Dec 2013) Log Message: ----------- [Imp] sounddev: Add hidden setting [Sound Settings]OpenDeviceAtStartup . This allows moving the initialization delay for slow audio driversto application startup instead of first play. Modified Paths: -------------- trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mainfrm.h trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/TrackerSettings.cpp trunk/OpenMPT/mptrack/TrackerSettings.h Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2013-12-07 19:27:40 UTC (rev 3409) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2013-12-07 19:38:57 UTC (rev 3410) @@ -1570,13 +1570,16 @@ ModCommand *m = m_WaveFile.Patterns[0]; if(m) { - m[0].note = note; - m[0].instr = 1; + if(m_WaveFile.m_nSamples > 0) + { + m[0].note = note; + m[0].instr = 1; - if(m_WaveFile.m_nSamples > 1 || m_WaveFile.GetSample(1).uFlags[CHN_LOOP]) - { - m[48 * 2].note = NOTE_KEYOFF; - m[79 * 2].note = NOTE_NOTECUT; + if(m_WaveFile.m_nSamples > 1 && m_WaveFile.GetSample(1).uFlags[CHN_LOOP]) + { + m[48 * 2].note = NOTE_KEYOFF; + m[79 * 2].note = NOTE_NOTECUT; + } } m[79 * 2].command = CMD_POSITIONJUMP; m[79 * 2 + 1].command = CMD_PATTERNBREAK; Modified: trunk/OpenMPT/mptrack/Mainfrm.h =================================================================== --- trunk/OpenMPT/mptrack/Mainfrm.h 2013-12-07 19:27:40 UTC (rev 3409) +++ trunk/OpenMPT/mptrack/Mainfrm.h 2013-12-07 19:38:57 UTC (rev 3410) @@ -434,6 +434,7 @@ void InitPreview(); void PreparePreview(ModCommand::NOTE note); void StopPreview() { StopSoundFile(&m_WaveFile); } + void PlayPreview() { PlaySoundFile(&m_WaveFile); } inline bool IsPlaying() const { return m_pSndFile != nullptr; } inline CModDoc *GetModPlaying() const { return m_pSndFile ? m_pSndFile->GetpModDoc() : nullptr; } Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2013-12-07 19:27:40 UTC (rev 3409) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2013-12-07 19:38:57 UTC (rev 3410) @@ -901,6 +901,13 @@ MptTest::DoTests(); #endif + if(TrackerSettings::Instance().m_SoundSettingsOpenDeviceAtStartup) + { + pMainFrame->InitPreview(); + pMainFrame->PreparePreview(64); + pMainFrame->PlayPreview(); + } + return TRUE; } Modified: trunk/OpenMPT/mptrack/TrackerSettings.cpp =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.cpp 2013-12-07 19:27:40 UTC (rev 3409) +++ trunk/OpenMPT/mptrack/TrackerSettings.cpp 2013-12-07 19:38:57 UTC (rev 3410) @@ -154,6 +154,7 @@ // Sound Settings , m_SoundSampleRates(conf, "Sound Settings", "SampleRates", GetDefaultSampleRates()) , m_MorePortaudio(conf, "Sound Settings", "MorePortaudio", false) + , m_SoundSettingsOpenDeviceAtStartup(conf, "Sound Settings", "OpenDeviceAtStartup", false) , m_SoundSettingsKeepDeviceOpen(conf, "Sound Settings", "KeepDeviceOpen", false) , m_SoundDeviceSettingsUseOldDefaults(false) , m_SoundDeviceIdentifier(conf, "Sound Settings", "Device", std::wstring()) Modified: trunk/OpenMPT/mptrack/TrackerSettings.h =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.h 2013-12-07 19:27:40 UTC (rev 3409) +++ trunk/OpenMPT/mptrack/TrackerSettings.h 2013-12-07 19:38:57 UTC (rev 3410) @@ -274,6 +274,7 @@ Setting<std::vector<uint32> > m_SoundSampleRates; Setting<bool> m_MorePortaudio; + Setting<bool> m_SoundSettingsOpenDeviceAtStartup; Setting<bool> m_SoundSettingsKeepDeviceOpen; bool m_SoundDeviceSettingsUseOldDefaults; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2013-12-07 20:59:45
|
Revision: 3411 http://sourceforge.net/p/modplug/code/3411 Author: saga-games Date: 2013-12-07 20:59:40 +0000 (Sat, 07 Dec 2013) Log Message: ----------- [Fix] Plugin selection dialog: Clearing the plugin filter broke a while ago. [Fix] VST: ProteusVX no longer breaks OpenMPT's plugin window (http://bugs.openmpt.org/view.php?id=79). Modified Paths: -------------- trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/SelectPluginDialog.cpp trunk/OpenMPT/mptrack/VSTEditor.cpp trunk/OpenMPT/mptrack/VSTEditor.h Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2013-12-07 19:38:57 UTC (rev 3410) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2013-12-07 20:59:40 UTC (rev 3411) @@ -1570,12 +1570,12 @@ ModCommand *m = m_WaveFile.Patterns[0]; if(m) { - if(m_WaveFile.m_nSamples > 0) + if(m_WaveFile.GetNumSamples() > 0) { m[0].note = note; m[0].instr = 1; - if(m_WaveFile.m_nSamples > 1 && m_WaveFile.GetSample(1).uFlags[CHN_LOOP]) + if(m_WaveFile.GetNumInstruments() != 0 || m_WaveFile.GetSample(1).uFlags[CHN_LOOP]) { m[48 * 2].note = NOTE_KEYOFF; m[79 * 2].note = NOTE_NOTECUT; Modified: trunk/OpenMPT/mptrack/SelectPluginDialog.cpp =================================================================== --- trunk/OpenMPT/mptrack/SelectPluginDialog.cpp 2013-12-07 19:38:57 UTC (rev 3410) +++ trunk/OpenMPT/mptrack/SelectPluginDialog.cpp 2013-12-07 20:59:40 UTC (rev 3411) @@ -264,8 +264,11 @@ HWND hwnd = GetDlgItem(IDC_NAMEFILTER)->m_hWnd; int len = GetWindowTextLengthW(hwnd); m_nameFilter.resize(len); - GetWindowTextW(hwnd, &m_nameFilter[0], len + 1); - for(int i = 0; i < len; i++) m_nameFilter[i] = ::towlower(m_nameFilter[i]); + if(len) + { + GetWindowTextW(hwnd, &m_nameFilter[0], len + 1); + for(int i = 0; i < len; i++) m_nameFilter[i] = ::towlower(m_nameFilter[i]); + } UpdatePluginsList(); } Modified: trunk/OpenMPT/mptrack/VSTEditor.cpp =================================================================== --- trunk/OpenMPT/mptrack/VSTEditor.cpp 2013-12-07 19:38:57 UTC (rev 3410) +++ trunk/OpenMPT/mptrack/VSTEditor.cpp 2013-12-07 20:59:40 UTC (rev 3411) @@ -35,12 +35,15 @@ { Create(IDD_PLUGINEDITOR, parent); + // Some plugins (e.g. ProteusVX) need to be planted into another control or else they will break our window proc, making the window unusable. + plugWindow.Create(nullptr, WS_CHILD | WS_VISIBLE, CRect(0, 0, 100, 100), this); + SetupMenu(); // Set editor window size ERect *pRect = nullptr; m_VstPlugin.Dispatch(effEditGetRect, 0, 0, &pRect, 0); - m_VstPlugin.Dispatch(effEditOpen, 0, 0, m_hWnd, 0); + m_VstPlugin.Dispatch(effEditOpen, 0, 0, plugWindow.m_hWnd, 0); m_VstPlugin.Dispatch(effEditGetRect, 0, 0, &pRect, 0); if((pRect) && (pRect->right > pRect->left) && (pRect->bottom > pRect->top)) { @@ -140,6 +143,9 @@ SetWindowPos(NULL, 0, 0, windowWidth, windowHeight, SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE); + plugWindow.SetWindowPos(NULL, 0, 0, + contentWidth, contentHeight, + SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE); // Check if the height of the menu bar has changed. GetMenuBarInfo(m_hWnd, OBJID_MENU, 0, &mbi); Modified: trunk/OpenMPT/mptrack/VSTEditor.h =================================================================== --- trunk/OpenMPT/mptrack/VSTEditor.h 2013-12-07 19:38:57 UTC (rev 3410) +++ trunk/OpenMPT/mptrack/VSTEditor.h 2013-12-07 20:59:40 UTC (rev 3411) @@ -18,6 +18,9 @@ class COwnerVstEditor: public CAbstractVstEditor //============================================== { +protected: + CStatic plugWindow; + public: COwnerVstEditor(CVstPlugin &plugin); virtual ~COwnerVstEditor(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |