From: <man...@us...> - 2013-10-24 12:09:28
|
Revision: 3002 http://sourceforge.net/p/modplug/code/3002 Author: manxorist Date: 2013-10-24 12:09:20 +0000 (Thu, 24 Oct 2013) Log Message: ----------- [Ref] Replace the convoluted notification forwarding thread with a way simpler solution: If the audio devie is playing, the GUI thread starts a timer which polls the notification buffer. The audio thread simply writes the notifications to the bufffer without notifying the GUI thread at all. This appears to fix sporadic deadlocks in wine which i cannot really explain though. Modified Paths: -------------- trunk/OpenMPT/mptrack/ExceptionHandler.cpp trunk/OpenMPT/mptrack/InputHandler.h trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mainfrm.h Modified: trunk/OpenMPT/mptrack/ExceptionHandler.cpp =================================================================== --- trunk/OpenMPT/mptrack/ExceptionHandler.cpp 2013-10-24 11:57:14 UTC (rev 3001) +++ trunk/OpenMPT/mptrack/ExceptionHandler.cpp 2013-10-24 12:09:20 UTC (rev 3002) @@ -147,6 +147,11 @@ pMainFrame->gpSoundDevice->Reset(); pMainFrame->gpSoundDevice->Close(); } + if(pMainFrame->m_NotifyTimer) + { + pMainFrame->KillTimer(pMainFrame->m_NotifyTimer); + pMainFrame->m_NotifyTimer = 0; + } } catch(...) { } Modified: trunk/OpenMPT/mptrack/InputHandler.h =================================================================== --- trunk/OpenMPT/mptrack/InputHandler.h 2013-10-24 11:57:14 UTC (rev 3001) +++ trunk/OpenMPT/mptrack/InputHandler.h 2013-10-24 12:09:20 UTC (rev 3002) @@ -16,7 +16,6 @@ enum { WM_MOD_UPDATEPOSITION = (WM_USER+1973), - WM_MOD_NOTIFICATION, WM_MOD_INVALIDATEPATTERNS, WM_MOD_ACTIVATEVIEW, WM_MOD_CHANGEVIEWCLASS, Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2013-10-24 11:57:14 UTC (rev 3001) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2013-10-24 12:09:20 UTC (rev 3002) @@ -89,7 +89,6 @@ ON_UPDATE_COMMAND_UI(ID_INDICATOR_XINFO,OnUpdateXInfo) //rewbs.xinfo ON_UPDATE_COMMAND_UI(ID_INDICATOR_CPU, OnUpdateCPU) ON_UPDATE_COMMAND_UI(IDD_TREEVIEW, OnUpdateControlBarMenu) - ON_MESSAGE(WM_MOD_NOTIFICATION, OnNotification) ON_MESSAGE(WM_MOD_UPDATEPOSITION, OnUpdatePosition) ON_MESSAGE(WM_MOD_INVALIDATEPATTERNS, OnInvalidatePatterns) ON_MESSAGE(WM_MOD_SPECIALKEY, OnSpecialKey) @@ -183,9 +182,7 @@ //---------------------- { - m_hNotifyThread = NULL; - m_dwNotifyThreadId = 0; - m_hNotifyWakeUp = NULL; + m_NotifyTimer = 0; gpSoundDevice = NULL; m_bModTreeHasFocus = false; //rewbs.customKeys @@ -205,8 +202,6 @@ m_szInfoText[0] = 0; m_szXInfoText[0]= 0; //rewbs.xinfo - m_PendingNotificationSempahore = NULL; - MemsetZero(gcolrefVuMeter); // Create Audio Critical Section @@ -261,13 +256,9 @@ #endif // NO_ASIO } - // Create Notify Thread - m_PendingNotificationSempahore = CreateSemaphore(NULL, 0, 1, NULL); - m_hNotifyWakeUp = CreateEvent(NULL, FALSE, FALSE, NULL); - m_hNotifyThread = CreateThread(NULL, 0, NotifyThreadWrapper, NULL, 0, &m_dwNotifyThreadId); // Setup timer OnUpdateUser(NULL); - m_nTimer = SetTimer(1, MPTTIMER_PERIOD, NULL); + m_nTimer = SetTimer(TIMERID_GUI, MPTTIMER_PERIOD, NULL); // Setup Keyboard Hook ghKbdHook = SetWindowsHookEx(WH_KEYBOARD, KeyboardProc, AfxGetInstanceHandle(), GetCurrentThreadId()); @@ -391,23 +382,6 @@ m_nTimer = 0; } if (shMidiIn) midiCloseDevice(); - if(m_hNotifyThread != NULL) - { - PostThreadMessage(m_dwNotifyThreadId, WM_QUIT, 0, 0); - WaitForSingleObject(m_hNotifyThread, INFINITE); - m_dwNotifyThreadId = 0; - m_hNotifyThread = NULL; - } - if(m_hNotifyWakeUp != NULL) - { - CloseHandle(m_hNotifyWakeUp); - m_hNotifyWakeUp = NULL; - } - if(m_PendingNotificationSempahore != NULL) - { - CloseHandle(m_PendingNotificationSempahore); - m_PendingNotificationSempahore = NULL; - } // Delete bitmaps if (bmpPatterns) { @@ -674,57 +648,10 @@ ///////////////////////////////////////////////////////////////////////////// // CMainFrame Sound Library -// Notify thread -DWORD WINAPI CMainFrame::NotifyThreadWrapper(LPVOID) -//-------------------------------------------------- -{ - return ((CMainFrame*)theApp.m_pMainWnd)->NotifyThread(); -} - -DWORD CMainFrame::NotifyThread() +void CMainFrame::OnTimerNotify() //------------------------------ { - MSG msg; - PeekMessage(&msg, NULL, WM_USER, WM_USER, PM_NOREMOVE); // initialize thread message queue - bool terminate = false; - bool cansend = true; - while(!terminate) - { - HANDLE waitHandles[2]; - waitHandles[0] = m_PendingNotificationSempahore; - waitHandles[1] = m_hNotifyWakeUp; - switch(MsgWaitForMultipleObjects(2, waitHandles, FALSE, 1000, QS_ALLEVENTS)) - { - case WAIT_OBJECT_0 + 0: - // last notification has been handled by gui thread - cansend = true; - break; - case WAIT_OBJECT_0 + 1: - if(cansend) - { - if(PostMessage(WM_MOD_NOTIFICATION, 0, 0)) - { - // message sent, do not send any more until it has been handled - cansend = false; - } - } - break; - case WAIT_OBJECT_0 + 2: - while(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) - { - if(msg.message == WM_QUIT) terminate = true; - } - break; - } - } - return 0; -} - - -LRESULT CMainFrame::OnNotification(WPARAM, LPARAM) -//------------------------------------------------ -{ Notification PendingNotification; bool found = false; int64 currenttotalsamples = 0; @@ -763,8 +690,6 @@ { OnUpdatePosition(0, (LPARAM)&PendingNotification); } - ReleaseSemaphore(m_PendingNotificationSempahore, 1, NULL); - return 0; } @@ -901,7 +826,11 @@ } gpSoundDevice->SetMessageReceiver(this); gpSoundDevice->SetSource(this); - return gpSoundDevice->Open(TrackerSettings::Instance().GetSoundDeviceSettings()); + if(!gpSoundDevice->Open(TrackerSettings::Instance().GetSoundDeviceSettings())) + { + return false; + } + return true; } @@ -966,6 +895,11 @@ Util::lock_guard<Util::mutex> lock(m_NotificationBufferMutex); m_NotifyBuffer.clear(); } + if(m_NotifyTimer) + { + KillTimer(m_NotifyTimer); + m_NotifyTimer = 0; + } } @@ -1016,9 +950,6 @@ notifyItem = m_pSndFile->m_pModDoc->GetNotificationItem(); } - // Notify Client - SetEvent(m_hNotifyWakeUp); - // Add an entry to the notification history Notification notification(notifyType, notifyItem, streamPosition, m_pSndFile->m_nRow, m_pSndFile->m_nTickCount, m_pSndFile->m_nCurrentOrder, m_pSndFile->m_nPattern, m_pSndFile->GetMixStat()); @@ -1126,8 +1057,6 @@ m_NotifyBuffer.push(notification); } - SetEvent(m_hNotifyWakeUp); - return true; } @@ -1318,6 +1247,10 @@ Util::lock_guard<Util::mutex> lock(m_SoundDeviceMutex); gpSoundDevice->Start(); } + if(!m_NotifyTimer) + { + m_NotifyTimer = SetTimer(TIMERID_NOTIFY, TrackerSettings::Instance().m_UpdateIntervalMS, NULL); + } return true; } @@ -1330,6 +1263,11 @@ Util::lock_guard<Util::mutex> lock(m_SoundDeviceMutex); gpSoundDevice->Stop(); } + if(m_NotifyTimer) + { + KillTimer(m_NotifyTimer); + m_NotifyTimer = 0; + } audioCloseDevice(); } @@ -1342,6 +1280,11 @@ Util::lock_guard<Util::mutex> lock(m_SoundDeviceMutex); gpSoundDevice->Stop(); } + if(m_NotifyTimer) + { + KillTimer(m_NotifyTimer); + m_NotifyTimer = 0; + } return true; } @@ -2029,9 +1972,24 @@ } -void CMainFrame::OnTimer(UINT_PTR) -//-------------------------------- +void CMainFrame::OnTimer(UINT_PTR timerID) +//---------------------------------------- { + switch(timerID) + { + case TIMERID_GUI: + OnTimerGUI(); + break; + case TIMERID_NOTIFY: + OnTimerNotify(); + break; + } +} + + +void CMainFrame::OnTimerGUI() +//--------------------------- +{ // Display Time in status bar CSoundFile::samplecount_t time = 0; if(m_pSndFile != nullptr && m_pSndFile->GetSampleRate() != 0) Modified: trunk/OpenMPT/mptrack/Mainfrm.h =================================================================== --- trunk/OpenMPT/mptrack/Mainfrm.h 2013-10-24 11:57:14 UTC (rev 3001) +++ trunk/OpenMPT/mptrack/Mainfrm.h 2013-10-24 12:09:20 UTC (rev 3002) @@ -241,6 +241,8 @@ #define MAX_UPDATE_HISTORY 256 // same as SNDDEV_MAXBUFFERS #include "Notification.h" +#define TIMERID_GUI 1 +#define TIMERID_NOTIFY 2 #include "mainbar.h" #include "TrackerSettings.h" @@ -273,10 +275,9 @@ // Low-Level Audio mutable Util::mutex m_SoundDeviceMutex; ISoundDevice *gpSoundDevice; + UINT_PTR m_NotifyTimer; Dither m_Dither; - HANDLE m_hNotifyWakeUp; - HANDLE m_hNotifyThread; - DWORD m_dwNotifyThreadId; + static LONG gnLVuMeter, gnRVuMeter; static bool gnClipLeft, gnClipRight; @@ -303,7 +304,6 @@ // Notification Buffer Util::mutex m_NotificationBufferMutex; // to avoid deadlocks, this mutex should only be taken as a innermost lock, i.e. do not block on anything while holding this mutex Util::fixed_size_queue<Notification,MAX_UPDATE_HISTORY> m_NotifyBuffer; - HANDLE m_PendingNotificationSempahore; // protects the one notification that is in flight from the notification thread to the gui thread from being freed while the gui thread still uses it // Instrument preview in tree view CSoundFile m_WaveFile; @@ -320,8 +320,6 @@ static void UpdateDspEffects(CSoundFile &sndFile, bool reset=false); static void UpdateAudioParameters(CSoundFile &sndFile, bool reset=false); static void CalcStereoVuMeters(int *, unsigned long, unsigned long); - static DWORD WINAPI NotifyThreadWrapper(LPVOID); - DWORD NotifyThread(); // from ISoundSource void FillAudioBufferLocked(IFillAudioBuffer &callback); @@ -476,6 +474,9 @@ virtual void Dump(CDumpContext& dc) const; #endif + void OnTimerGUI(); + void OnTimerNotify(); + // Message map functions //{{AFX_MSG(CMainFrame) public: @@ -513,7 +514,6 @@ afx_msg void OnPanic(); afx_msg void OnReportBug(); //rewbs.customKeys afx_msg BOOL OnInternetLink(UINT nID); - afx_msg LRESULT OnNotification(WPARAM, LPARAM lParam); afx_msg LRESULT OnUpdatePosition(WPARAM, LPARAM lParam); afx_msg void OnExampleSong(UINT nId); afx_msg void OnOpenTemplateModule(UINT nId); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-10-24 12:55:06
|
Revision: 3005 http://sourceforge.net/p/modplug/code/3005 Author: manxorist Date: 2013-10-24 12:54:57 +0000 (Thu, 24 Oct 2013) Log Message: ----------- [Ref] gpSoundDevice is only ever accessed from the main gui thread. So m_SoundDeviceMutex actually protects nothing at all. Remove it. Modified Paths: -------------- trunk/OpenMPT/mptrack/ExceptionHandler.cpp trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mainfrm.h trunk/OpenMPT/mptrack/Mpdlgs.cpp Modified: trunk/OpenMPT/mptrack/ExceptionHandler.cpp =================================================================== --- trunk/OpenMPT/mptrack/ExceptionHandler.cpp 2013-10-24 12:13:39 UTC (rev 3004) +++ trunk/OpenMPT/mptrack/ExceptionHandler.cpp 2013-10-24 12:54:57 UTC (rev 3005) @@ -141,7 +141,6 @@ { try { - // do not take m_SoundDeviceMutex here, just try closing it, no matter what if(pMainFrame->gpSoundDevice) { pMainFrame->gpSoundDevice->Reset(); Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2013-10-24 12:13:39 UTC (rev 3004) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2013-10-24 12:54:57 UTC (rev 3005) @@ -454,13 +454,10 @@ if (IsPlaying()) PauseMod(); if (pMDIActive) pMDIActive->SavePosition(TRUE); + if(gpSoundDevice) { - Util::lock_guard<Util::mutex> lock(m_SoundDeviceMutex); - if(gpSoundDevice) - { - delete gpSoundDevice; - gpSoundDevice = nullptr; - } + delete gpSoundDevice; + gpSoundDevice = nullptr; } // Save Settings @@ -655,12 +652,9 @@ Notification PendingNotification; bool found = false; int64 currenttotalsamples = 0; + if(gpSoundDevice) { - Util::lock_guard<Util::mutex> lock(m_SoundDeviceMutex); - if(gpSoundDevice) - { - currenttotalsamples = gpSoundDevice->GetStreamPositionSamples(); - } + currenttotalsamples = gpSoundDevice->GetStreamPositionSamples(); } { // advance to the newest notification, drop the obsolete ones @@ -809,7 +803,6 @@ bool CMainFrame::audioTryOpeningDevice() //-------------------------------------- { - Util::lock_guard<Util::mutex> lock(m_SoundDeviceMutex); const SoundDeviceID deviceID = TrackerSettings::Instance().m_nWaveDevice; if(gpSoundDevice && (gpSoundDevice->GetDeviceID() != deviceID)) { @@ -837,7 +830,6 @@ bool CMainFrame::IsAudioDeviceOpen() const //---------------------------------------- { - Util::lock_guard<Util::mutex> lock(m_SoundDeviceMutex); return gpSoundDevice && gpSoundDevice->IsOpen(); } @@ -853,11 +845,7 @@ { if(audioTryOpeningDevice()) { - SampleFormat actualSampleFormat = SampleFormatInvalid; - { - Util::lock_guard<Util::mutex> lock(m_SoundDeviceMutex); - actualSampleFormat = gpSoundDevice->GetActualSampleFormat(); - } + SampleFormat actualSampleFormat = gpSoundDevice->GetActualSampleFormat(); if(actualSampleFormat.IsValid()) { TrackerSettings::Instance().m_SampleFormat = actualSampleFormat; @@ -883,7 +871,6 @@ void CMainFrame::audioCloseDevice() //--------------------------------- { - Util::lock_guard<Util::mutex> lock(m_SoundDeviceMutex); if(gpSoundDevice) { gpSoundDevice->Reset(); @@ -1243,10 +1230,7 @@ { if(!m_pSndFile) return false; // nothing to play if(!IsAudioDeviceOpen()) return false; - { - Util::lock_guard<Util::mutex> lock(m_SoundDeviceMutex); - gpSoundDevice->Start(); - } + gpSoundDevice->Start(); if(!m_NotifyTimer) { m_NotifyTimer = SetTimer(TIMERID_NOTIFY, TrackerSettings::Instance().m_UpdateIntervalMS, NULL); @@ -1259,10 +1243,7 @@ //----------------------------- { if(!IsAudioDeviceOpen()) return; - { - Util::lock_guard<Util::mutex> lock(m_SoundDeviceMutex); - gpSoundDevice->Stop(); - } + gpSoundDevice->Stop(); if(m_NotifyTimer) { KillTimer(m_NotifyTimer); @@ -1276,10 +1257,7 @@ //------------------------------ { if(!IsAudioDeviceOpen()) return false; - { - Util::lock_guard<Util::mutex> lock(m_SoundDeviceMutex); - gpSoundDevice->Stop(); - } + gpSoundDevice->Stop(); if(m_NotifyTimer) { KillTimer(m_NotifyTimer); Modified: trunk/OpenMPT/mptrack/Mainfrm.h =================================================================== --- trunk/OpenMPT/mptrack/Mainfrm.h 2013-10-24 12:13:39 UTC (rev 3004) +++ trunk/OpenMPT/mptrack/Mainfrm.h 2013-10-24 12:54:57 UTC (rev 3005) @@ -273,7 +273,6 @@ public: // Low-Level Audio - mutable Util::mutex m_SoundDeviceMutex; ISoundDevice *gpSoundDevice; UINT_PTR m_NotifyTimer; Dither m_Dither; Modified: trunk/OpenMPT/mptrack/Mpdlgs.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mpdlgs.cpp 2013-10-24 12:13:39 UTC (rev 3004) +++ trunk/OpenMPT/mptrack/Mpdlgs.cpp 2013-10-24 12:54:57 UTC (rev 3005) @@ -417,13 +417,8 @@ { m_CbnMixingFreq.ResetContent(); - std::vector<uint32> samplerates; + std::vector<uint32> samplerates = theApp.GetSoundDevicesManager()->GetDeviceCaps(dev, TrackerSettings::Instance().GetSampleRates(), CMainFrame::GetMainFrame(), CMainFrame::GetMainFrame()->gpSoundDevice).supportedSampleRates; - { - Util::lock_guard<Util::mutex> lock(CMainFrame::GetMainFrame()->m_SoundDeviceMutex); - samplerates = theApp.GetSoundDevicesManager()->GetDeviceCaps(dev, TrackerSettings::Instance().GetSampleRates(), CMainFrame::GetMainFrame(), CMainFrame::GetMainFrame()->gpSoundDevice).supportedSampleRates; - } - if(samplerates.empty()) { // We have no valid list of supported playback rates! Assume all rates supported by OpenMPT are possible... @@ -542,22 +537,19 @@ { if (!m_EditStatistics) return; CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); + if(pMainFrm->gpSoundDevice && pMainFrm->IsPlaying()) { - Util::lock_guard<Util::mutex> lock(pMainFrm->m_SoundDeviceMutex); - if(pMainFrm->gpSoundDevice && pMainFrm->IsPlaying()) - { - CHAR s[256]; - _snprintf(s, 255, "Buffers: %d\r\nUpdate interval: %4.1f ms\r\nLatency: %4.1f ms\r\nCurrent Latency: %4.1f ms", - pMainFrm->gpSoundDevice->GetNumBuffers(), - (float)pMainFrm->gpSoundDevice->GetRealUpdateIntervalMS(), - (float)pMainFrm->gpSoundDevice->GetRealLatencyMS(), - (float)pMainFrm->gpSoundDevice->GetCurrentRealLatencyMS() - ); - m_EditStatistics.SetWindowText(s); - } else - { - m_EditStatistics.SetWindowText(""); - } + CHAR s[256]; + _snprintf(s, 255, "Buffers: %d\r\nUpdate interval: %4.1f ms\r\nLatency: %4.1f ms\r\nCurrent Latency: %4.1f ms", + pMainFrm->gpSoundDevice->GetNumBuffers(), + (float)pMainFrm->gpSoundDevice->GetRealUpdateIntervalMS(), + (float)pMainFrm->gpSoundDevice->GetRealLatencyMS(), + (float)pMainFrm->gpSoundDevice->GetCurrentRealLatencyMS() + ); + m_EditStatistics.SetWindowText(s); + } else + { + m_EditStatistics.SetWindowText(""); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2013-10-24 14:13:55
|
Revision: 3012 http://sourceforge.net/p/modplug/code/3012 Author: saga-games Date: 2013-10-24 14:13:46 +0000 (Thu, 24 Oct 2013) Log Message: ----------- [New] Added command-line option /fullMemDump to write a minidump with heap. Modified Paths: -------------- trunk/OpenMPT/mptrack/ExceptionHandler.cpp trunk/OpenMPT/mptrack/ExceptionHandler.h trunk/OpenMPT/mptrack/Mptrack.cpp Modified: trunk/OpenMPT/mptrack/ExceptionHandler.cpp =================================================================== --- trunk/OpenMPT/mptrack/ExceptionHandler.cpp 2013-10-24 13:36:00 UTC (rev 3011) +++ trunk/OpenMPT/mptrack/ExceptionHandler.cpp 2013-10-24 14:13:46 UTC (rev 3012) @@ -18,6 +18,9 @@ #include "../common/version.h" +bool ExceptionHandler::fullMemDump = false; + + typedef BOOL (WINAPI *MINIDUMPWRITEDUMP)(HANDLE hProcess, DWORD dwPid, HANDLE hFile, MINIDUMP_TYPE DumpType, CONST PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam, CONST PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam, @@ -75,7 +78,9 @@ ExInfo.ClientPointers = NULL; } - pDump(GetCurrentProcess(), GetCurrentProcessId(), hFile, MiniDumpNormal, pExceptionInfo ? &ExInfo : NULL, NULL, NULL); + pDump(GetCurrentProcess(), GetCurrentProcessId(), hFile, + ExceptionHandler::fullMemDump ? (MINIDUMP_TYPE)(MiniDumpWithFullMemory | MiniDumpWithHandleData | MiniDumpWithThreadInfo | MiniDumpWithProcessThreadData | MiniDumpWithFullMemoryInfo | MiniDumpIgnoreInaccessibleMemory | MiniDumpWithTokenInformation) : MiniDumpNormal, + pExceptionInfo ? &ExInfo : NULL, NULL, NULL); ::CloseHandle(hFile); errorMessage.AppendFormat("\n\nDebug information has been saved to\n%s", baseRescuePath); Modified: trunk/OpenMPT/mptrack/ExceptionHandler.h =================================================================== --- trunk/OpenMPT/mptrack/ExceptionHandler.h 2013-10-24 13:36:00 UTC (rev 3011) +++ trunk/OpenMPT/mptrack/ExceptionHandler.h 2013-10-24 14:13:46 UTC (rev 3012) @@ -15,7 +15,8 @@ //==================== { public: - + static bool fullMemDump; + // Call this to activate unhandled exception filtering. static void Register() { ::SetUnhandledExceptionFilter(UnhandledExceptionFilter); }; Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2013-10-24 13:36:00 UTC (rev 3011) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2013-10-24 14:13:46 UTC (rev 3012) @@ -292,6 +292,7 @@ if (!lstrcmpi(lpszParam, "noplugs")) { m_bNoPlugins = true; return; } else if (!lstrcmpi(lpszParam, "portable")) { m_bPortable = true; return; } else if (!lstrcmpi(lpszParam, "noSettingsOnNewVersion")) { m_bNoSettingsOnNewVersion = true; return; } + if (!lstrcmpi(lpszParam, "fullMemDump")) { ExceptionHandler::fullMemDump = true; return; } } CCommandLineInfo::ParseParam(lpszParam, bFlag, bLast); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-10-26 07:42:09
|
Revision: 3030 http://sourceforge.net/p/modplug/code/3030 Author: manxorist Date: 2013-10-26 07:42:01 +0000 (Sat, 26 Oct 2013) Log Message: ----------- [Mod] Mod Export: Also sort formats from best to worst, like all other codec related options. Modified Paths: -------------- trunk/OpenMPT/mptrack/Mod2wave.cpp trunk/OpenMPT/mptrack/Moddoc.cpp Modified: trunk/OpenMPT/mptrack/Mod2wave.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mod2wave.cpp 2013-10-25 17:50:17 UTC (rev 3029) +++ trunk/OpenMPT/mptrack/Mod2wave.cpp 2013-10-26 07:42:01 UTC (rev 3030) @@ -260,6 +260,10 @@ const Encoder::Traits &encTraits = m_Settings.EncoderFactories[i]->GetTraits(); int ndx = m_CbnFileType.AddString(encTraits.fileShortDescription.c_str()); m_CbnFileType.SetItemData(ndx, i); + if(m_Settings.EncoderIndex == i) + { + sel = ndx; + } } m_CbnFileType.SetCurSel(sel); } Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2013-10-25 17:50:17 UTC (rev 3029) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2013-10-26 07:42:01 UTC (rev 3030) @@ -1648,7 +1648,7 @@ if ((!pMainFrm) || (!m_SndFile.GetType()) || encFactories.empty()) return; - CWaveConvert wsdlg(pMainFrm, nMinOrder, nMaxOrder, m_SndFile.Order.GetLengthTailTrimmed() - 1, &m_SndFile, 0, encFactories); + CWaveConvert wsdlg(pMainFrm, nMinOrder, nMaxOrder, m_SndFile.Order.GetLengthTailTrimmed() - 1, &m_SndFile, encFactories.size() > 2 ? 2 : 0, encFactories); if (wsdlg.DoModal() != IDOK) return; EncoderFactoryBase *encFactory = wsdlg.m_Settings.GetEncoderFactory(); @@ -1853,33 +1853,32 @@ void CModDoc::OnFileMP3Convert() //------------------------------ { + WAVEncoder wavencoder; + FLACEncoder flacencoder; + OggOpusEncoder opusencoder; + VorbisEncoder vorbisencoder; MP3Encoder mp3lame(MP3EncoderLame); MP3Encoder mp3blade(MP3EncoderBlade); MP3Encoder mp3acm(MP3EncoderACM); - VorbisEncoder vorbisencoder; - OggOpusEncoder opusencoder; - FLACEncoder flacencoder; - WAVEncoder wavencoder; std::vector<EncoderFactoryBase*> encoders; + if(wavencoder.IsAvailable()) encoders.push_back(&wavencoder); + if(flacencoder.IsAvailable()) encoders.push_back(&flacencoder); + if(opusencoder.IsAvailable()) encoders.push_back(&opusencoder); + if(vorbisencoder.IsAvailable()) encoders.push_back(&vorbisencoder); if(mp3lame.IsAvailable()) encoders.push_back(&mp3lame); if(mp3blade.IsAvailable()) encoders.push_back(&mp3blade); if(mp3acm.IsAvailable()) encoders.push_back(&mp3acm); - if(vorbisencoder.IsAvailable()) encoders.push_back(&vorbisencoder); - if(opusencoder.IsAvailable()) encoders.push_back(&opusencoder); - if(flacencoder.IsAvailable()) encoders.push_back(&flacencoder); - if(wavencoder.IsAvailable()) encoders.push_back(&wavencoder); - if(encoders.empty()) + if(encoders.size() == 2) { - Reporting::Error( - "No MP3/Vorbis/Opus codec found.\n" + Reporting::Warning( + "No Opus/Vorbis/MP3 codec found.\n" "Please copy\n" + " - Xipg.Org Opus libraries\n" + " - Ogg Vorbis libraries\n" " - libmp3lame.dll or Lame_Enc.dll\n" - " - Ogg Vorbis libraries\n" - " - Xipg.Org Opus libraries\n" "into OpenMPT's root directory.\n" "Alternatively, you can install a MP3 ACM codec.", "OpenMPT - Export"); - return; } OnFileWaveConvert(ORDERINDEX_INVALID, ORDERINDEX_INVALID, encoders); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-10-26 08:45:02
|
Revision: 3033 http://sourceforge.net/p/modplug/code/3033 Author: manxorist Date: 2013-10-26 08:44:52 +0000 (Sat, 26 Oct 2013) Log Message: ----------- [Ref] Remove unneeded includes of SoundDevice.h. Modified Paths: -------------- trunk/OpenMPT/mptrack/Mainfrm.h trunk/OpenMPT/mptrack/Mpdlgs.cpp trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/TrackerSettings.cpp Modified: trunk/OpenMPT/mptrack/Mainfrm.h =================================================================== --- trunk/OpenMPT/mptrack/Mainfrm.h 2013-10-26 08:41:27 UTC (rev 3032) +++ trunk/OpenMPT/mptrack/Mainfrm.h 2013-10-26 08:44:52 UTC (rev 3033) @@ -14,7 +14,6 @@ #include "InputHandler.h" #include "../common/AudioCriticalSection.h" #include "../common/mutex.h" -#include "../sounddev/SoundDevice.h" #include "../soundlib/Sndfile.h" #include "../soundlib/Dither.h" Modified: trunk/OpenMPT/mptrack/Mpdlgs.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mpdlgs.cpp 2013-10-26 08:41:27 UTC (rev 3032) +++ trunk/OpenMPT/mptrack/Mpdlgs.cpp 2013-10-26 08:44:52 UTC (rev 3033) @@ -17,7 +17,7 @@ #include "moptions.h" #include "moddoc.h" #include "../sounddev/SoundDevice.h" -#include ".\mpdlgs.h" +#include "mpdlgs.h" #include "../common/StringFixer.h" #define str_preampChangeNote GetStrI18N(_TEXT("Note: The Pre-Amp setting affects sample volume only. Changing it may cause undesired effects on volume balance between sample based instruments and plugin instruments.\nIn other words: Don't touch this slider unless you know what you are doing.")) Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2013-10-26 08:41:27 UTC (rev 3032) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2013-10-26 08:44:52 UTC (rev 3033) @@ -15,7 +15,6 @@ #include "moddoc.h" #include "globals.h" #include "Dlsbank.h" -#include "../sounddev/SoundDevice.h" #include "vstplug.h" #include "CreditStatic.h" #include "commctrl.h" Modified: trunk/OpenMPT/mptrack/TrackerSettings.cpp =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.cpp 2013-10-26 08:41:27 UTC (rev 3032) +++ trunk/OpenMPT/mptrack/TrackerSettings.cpp 2013-10-26 08:44:52 UTC (rev 3033) @@ -23,7 +23,6 @@ #include "TrackerSettings.h" #include "../common/misc_util.h" #include "PatternClipboard.h" -#include "../sounddev/SoundDevice.h" #define OLD_SNDDEV_MINBUFFERLEN 1 // 1ms This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-11-06 12:44:30
|
Revision: 3095 http://sourceforge.net/p/modplug/code/3095 Author: manxorist Date: 2013-11-06 12:44:23 +0000 (Wed, 06 Nov 2013) Log Message: ----------- [Int] Make mptrack project configuration names consistent with solution configuration names. Modified Paths: -------------- trunk/OpenMPT/mptrack/MPTRACK_10.sln trunk/OpenMPT/mptrack/mptrack_10.vcxproj Property Changed: ---------------- trunk/OpenMPT/mptrack/ Index: trunk/OpenMPT/mptrack =================================================================== --- trunk/OpenMPT/mptrack 2013-11-06 09:21:58 UTC (rev 3094) +++ trunk/OpenMPT/mptrack 2013-11-06 12:44:23 UTC (rev 3095) Property changes on: trunk/OpenMPT/mptrack ___________________________________________________________________ Modified: svn:ignore ## -5,5 +5,6 ## Debug Release ReleaseLTCG +ReleaseNoLTCG ipch mptrack.aps Modified: trunk/OpenMPT/mptrack/MPTRACK_10.sln =================================================================== --- trunk/OpenMPT/mptrack/MPTRACK_10.sln 2013-11-06 09:21:58 UTC (rev 3094) +++ trunk/OpenMPT/mptrack/MPTRACK_10.sln 2013-11-06 12:44:23 UTC (rev 3095) @@ -35,12 +35,12 @@ {21D95071-FB97-4E69-B3B1-050D0D4A5021}.Debug|Win32.ActiveCfg = Debug|Win32 {21D95071-FB97-4E69-B3B1-050D0D4A5021}.Debug|Win32.Build.0 = Debug|Win32 {21D95071-FB97-4E69-B3B1-050D0D4A5021}.Debug|x64.ActiveCfg = Debug|Win32 - {21D95071-FB97-4E69-B3B1-050D0D4A5021}.Release|Win32.ActiveCfg = ReleaseLTCG|Win32 - {21D95071-FB97-4E69-B3B1-050D0D4A5021}.Release|Win32.Build.0 = ReleaseLTCG|Win32 + {21D95071-FB97-4E69-B3B1-050D0D4A5021}.Release|Win32.ActiveCfg = Release|Win32 + {21D95071-FB97-4E69-B3B1-050D0D4A5021}.Release|Win32.Build.0 = Release|Win32 {21D95071-FB97-4E69-B3B1-050D0D4A5021}.Release|x64.ActiveCfg = Release|Win32 - {21D95071-FB97-4E69-B3B1-050D0D4A5021}.ReleaseNoLTCG|Win32.ActiveCfg = Release|Win32 - {21D95071-FB97-4E69-B3B1-050D0D4A5021}.ReleaseNoLTCG|Win32.Build.0 = Release|Win32 - {21D95071-FB97-4E69-B3B1-050D0D4A5021}.ReleaseNoLTCG|x64.ActiveCfg = Release|Win32 + {21D95071-FB97-4E69-B3B1-050D0D4A5021}.ReleaseNoLTCG|Win32.ActiveCfg = ReleaseNoLTCG|Win32 + {21D95071-FB97-4E69-B3B1-050D0D4A5021}.ReleaseNoLTCG|Win32.Build.0 = ReleaseNoLTCG|Win32 + {21D95071-FB97-4E69-B3B1-050D0D4A5021}.ReleaseNoLTCG|x64.ActiveCfg = ReleaseNoLTCG|Win32 {E599F5AA-F9A3-46CC-8DB0-C8DEFCEB90C5}.Debug|Win32.ActiveCfg = Debug|Win32 {E599F5AA-F9A3-46CC-8DB0-C8DEFCEB90C5}.Debug|Win32.Build.0 = Debug|Win32 {E599F5AA-F9A3-46CC-8DB0-C8DEFCEB90C5}.Debug|x64.ActiveCfg = Debug|x64 Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2013-11-06 09:21:58 UTC (rev 3094) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2013-11-06 12:44:23 UTC (rev 3095) @@ -1,12 +1,12 @@ -<?xml version="1.0" encoding="utf-8"?> +<?xml version="1.0" encoding="utf-8"?> <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> <ProjectConfiguration Include="Debug|Win32"> <Configuration>Debug</Configuration> <Platform>Win32</Platform> </ProjectConfiguration> - <ProjectConfiguration Include="ReleaseLTCG|Win32"> - <Configuration>ReleaseLTCG</Configuration> + <ProjectConfiguration Include="ReleaseNoLTCG|Win32"> + <Configuration>ReleaseNoLTCG</Configuration> <Platform>Win32</Platform> </ProjectConfiguration> <ProjectConfiguration Include="Release|Win32"> @@ -24,13 +24,13 @@ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <ConfigurationType>Application</ConfigurationType> <UseOfMfc>Static</UseOfMfc> - <WholeProgramOptimization>false</WholeProgramOptimization> + <WholeProgramOptimization>true</WholeProgramOptimization> <PlatformToolset>v100</PlatformToolset> </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseLTCG|Win32'" Label="Configuration"> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseNoLTCG|Win32'" Label="Configuration"> <ConfigurationType>Application</ConfigurationType> <UseOfMfc>Static</UseOfMfc> - <WholeProgramOptimization>true</WholeProgramOptimization> + <WholeProgramOptimization>false</WholeProgramOptimization> <PlatformToolset>v100</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> @@ -44,7 +44,7 @@ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> </ImportGroup> - <ImportGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseLTCG|Win32'" Label="PropertySheets"> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseNoLTCG|Win32'" Label="PropertySheets"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> </ImportGroup> @@ -59,12 +59,12 @@ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\Debug\</IntDir> <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental> <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.\bin\</OutDir> - <OutDir Condition="'$(Configuration)|$(Platform)'=='ReleaseLTCG|Win32'">.\bin\</OutDir> + <OutDir Condition="'$(Configuration)|$(Platform)'=='ReleaseNoLTCG|Win32'">.\bin\</OutDir> <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir> - <IntDir Condition="'$(Configuration)|$(Platform)'=='ReleaseLTCG|Win32'">$(Configuration)\</IntDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='ReleaseNoLTCG|Win32'">$(Configuration)\</IntDir> <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental> - <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='ReleaseLTCG|Win32'">false</LinkIncremental> - <TargetName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectName)-noLTCG</TargetName> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='ReleaseNoLTCG|Win32'">false</LinkIncremental> + <TargetName Condition="'$(Configuration)|$(Platform)'=='ReleaseNoLTCG|Win32'">$(ProjectName)-noLTCG</TargetName> </PropertyGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <Midl> @@ -156,6 +156,7 @@ <IntrinsicFunctions>true</IntrinsicFunctions> <FloatingPointModel>Fast</FloatingPointModel> <MultiProcessorCompilation>true</MultiProcessorCompilation> + <WholeProgramOptimization>true</WholeProgramOptimization> </ClCompile> <ResourceCompile> <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> @@ -179,7 +180,7 @@ <DataExecutionPrevention>false</DataExecutionPrevention> <IgnoreSpecificDefaultLibraries> </IgnoreSpecificDefaultLibraries> - <LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration> + <LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration> </Link> <Manifest> <AdditionalManifestFiles>$(ProjectDir)res/rt_manif.bin;%(AdditionalManifestFiles)</AdditionalManifestFiles> @@ -188,7 +189,7 @@ <Command>subwcrev .. ..\common\svn_version_subwcrev\svn_version.template.h ..\common\svn_version_subwcrev\svn_version.h || del ..\common\svn_version_subwcrev\svn_version.h || true</Command> </PreBuildEvent> </ItemDefinitionGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseLTCG|Win32'"> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseNoLTCG|Win32'"> <Midl> <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> <MkTypLibCompatible>true</MkTypLibCompatible> @@ -208,10 +209,10 @@ <ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope> <PrecompiledHeader>Use</PrecompiledHeader> <PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile> - <PrecompiledHeaderOutputFile>.\ReleaseLTCG/mptrack.pch</PrecompiledHeaderOutputFile> - <AssemblerListingLocation>.\ReleaseLTCG/</AssemblerListingLocation> - <ObjectFileName>.\ReleaseLTCG/</ObjectFileName> - <ProgramDataBaseFileName>.\ReleaseLTCG/</ProgramDataBaseFileName> + <PrecompiledHeaderOutputFile>.\ReleaseNoLTCG/mptrack.pch</PrecompiledHeaderOutputFile> + <AssemblerListingLocation>.\ReleaseNoLTCG/</AssemblerListingLocation> + <ObjectFileName>.\ReleaseNoLTCG/</ObjectFileName> + <ProgramDataBaseFileName>.\ReleaseNoLTCG/</ProgramDataBaseFileName> <WarningLevel>Level4</WarningLevel> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <CompileAs>Default</CompileAs> @@ -219,7 +220,6 @@ <IntrinsicFunctions>true</IntrinsicFunctions> <FloatingPointModel>Fast</FloatingPointModel> <MultiProcessorCompilation>true</MultiProcessorCompilation> - <WholeProgramOptimization>true</WholeProgramOptimization> </ClCompile> <ResourceCompile> <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> @@ -235,7 +235,7 @@ <DelayLoadDLLs>OpenMPT_SoundTouch_i16.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <GenerateMapFile>false</GenerateMapFile> - <MapFileName>.\ReleaseLTCG/mptrack.map</MapFileName> + <MapFileName>.\ReleaseNoLTCG/mptrack.map</MapFileName> <SubSystem>Windows</SubSystem> <OptimizeReferences>true</OptimizeReferences> <EnableCOMDATFolding>true</EnableCOMDATFolding> @@ -243,7 +243,7 @@ <DataExecutionPrevention>false</DataExecutionPrevention> <IgnoreSpecificDefaultLibraries> </IgnoreSpecificDefaultLibraries> - <LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration> + <LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration> </Link> <Manifest> <AdditionalManifestFiles>$(ProjectDir)res/rt_manif.bin;%(AdditionalManifestFiles)</AdditionalManifestFiles> @@ -364,9 +364,9 @@ <ClCompile Include="..\common\stdafx.cpp"> <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader> <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader> - <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='ReleaseLTCG|Win32'">Create</PrecompiledHeader> + <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='ReleaseNoLTCG|Win32'">Create</PrecompiledHeader> <MultiProcessorCompilation Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</MultiProcessorCompilation> - <MultiProcessorCompilation Condition="'$(Configuration)|$(Platform)'=='ReleaseLTCG|Win32'">false</MultiProcessorCompilation> + <MultiProcessorCompilation Condition="'$(Configuration)|$(Platform)'=='ReleaseNoLTCG|Win32'">false</MultiProcessorCompilation> </ClCompile> <ClCompile Include="..\soundlib\tuning.cpp" /> <ClCompile Include="..\soundlib\tuningbase.cpp" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-11-06 16:20:13
|
Revision: 3099 http://sourceforge.net/p/modplug/code/3099 Author: manxorist Date: 2013-11-06 16:20:05 +0000 (Wed, 06 Nov 2013) Log Message: ----------- [New] Add 64bit configurations to VS2010 mptrack project. Modified Paths: -------------- trunk/OpenMPT/mptrack/MPTRACK_10.sln trunk/OpenMPT/mptrack/mptrack_10.vcxproj Modified: trunk/OpenMPT/mptrack/MPTRACK_10.sln =================================================================== --- trunk/OpenMPT/mptrack/MPTRACK_10.sln 2013-11-06 15:37:31 UTC (rev 3098) +++ trunk/OpenMPT/mptrack/MPTRACK_10.sln 2013-11-06 16:20:05 UTC (rev 3099) @@ -34,13 +34,16 @@ GlobalSection(ProjectConfigurationPlatforms) = postSolution {21D95071-FB97-4E69-B3B1-050D0D4A5021}.Debug|Win32.ActiveCfg = Debug|Win32 {21D95071-FB97-4E69-B3B1-050D0D4A5021}.Debug|Win32.Build.0 = Debug|Win32 - {21D95071-FB97-4E69-B3B1-050D0D4A5021}.Debug|x64.ActiveCfg = Debug|Win32 + {21D95071-FB97-4E69-B3B1-050D0D4A5021}.Debug|x64.ActiveCfg = Debug|x64 + {21D95071-FB97-4E69-B3B1-050D0D4A5021}.Debug|x64.Build.0 = Debug|x64 {21D95071-FB97-4E69-B3B1-050D0D4A5021}.Release|Win32.ActiveCfg = Release|Win32 {21D95071-FB97-4E69-B3B1-050D0D4A5021}.Release|Win32.Build.0 = Release|Win32 - {21D95071-FB97-4E69-B3B1-050D0D4A5021}.Release|x64.ActiveCfg = Release|Win32 + {21D95071-FB97-4E69-B3B1-050D0D4A5021}.Release|x64.ActiveCfg = Release|x64 + {21D95071-FB97-4E69-B3B1-050D0D4A5021}.Release|x64.Build.0 = Release|x64 {21D95071-FB97-4E69-B3B1-050D0D4A5021}.ReleaseNoLTCG|Win32.ActiveCfg = ReleaseNoLTCG|Win32 {21D95071-FB97-4E69-B3B1-050D0D4A5021}.ReleaseNoLTCG|Win32.Build.0 = ReleaseNoLTCG|Win32 - {21D95071-FB97-4E69-B3B1-050D0D4A5021}.ReleaseNoLTCG|x64.ActiveCfg = ReleaseNoLTCG|Win32 + {21D95071-FB97-4E69-B3B1-050D0D4A5021}.ReleaseNoLTCG|x64.ActiveCfg = ReleaseNoLTCG|x64 + {21D95071-FB97-4E69-B3B1-050D0D4A5021}.ReleaseNoLTCG|x64.Build.0 = ReleaseNoLTCG|x64 {E599F5AA-F9A3-46CC-8DB0-C8DEFCEB90C5}.Debug|Win32.ActiveCfg = Debug|Win32 {E599F5AA-F9A3-46CC-8DB0-C8DEFCEB90C5}.Debug|Win32.Build.0 = Debug|Win32 {E599F5AA-F9A3-46CC-8DB0-C8DEFCEB90C5}.Debug|x64.ActiveCfg = Debug|x64 Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2013-11-06 15:37:31 UTC (rev 3098) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2013-11-06 16:20:05 UTC (rev 3099) @@ -5,14 +5,26 @@ <Configuration>Debug</Configuration> <Platform>Win32</Platform> </ProjectConfiguration> + <ProjectConfiguration Include="Debug|x64"> + <Configuration>Debug</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> <ProjectConfiguration Include="ReleaseNoLTCG|Win32"> <Configuration>ReleaseNoLTCG</Configuration> <Platform>Win32</Platform> </ProjectConfiguration> + <ProjectConfiguration Include="ReleaseNoLTCG|x64"> + <Configuration>ReleaseNoLTCG</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> <ProjectConfiguration Include="Release|Win32"> <Configuration>Release</Configuration> <Platform>Win32</Platform> </ProjectConfiguration> + <ProjectConfiguration Include="Release|x64"> + <Configuration>Release</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> </ItemGroup> <PropertyGroup Label="Globals"> <ProjectName>mptrack</ProjectName> @@ -27,16 +39,32 @@ <WholeProgramOptimization>true</WholeProgramOptimization> <PlatformToolset>v100</PlatformToolset> </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseOfMfc>Static</UseOfMfc> + <WholeProgramOptimization>true</WholeProgramOptimization> + <PlatformToolset>v100</PlatformToolset> + </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseNoLTCG|Win32'" Label="Configuration"> <ConfigurationType>Application</ConfigurationType> <UseOfMfc>Static</UseOfMfc> <WholeProgramOptimization>false</WholeProgramOptimization> <PlatformToolset>v100</PlatformToolset> </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseNoLTCG|x64'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseOfMfc>Static</UseOfMfc> + <WholeProgramOptimization>false</WholeProgramOptimization> + <PlatformToolset>v100</PlatformToolset> + </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <ConfigurationType>Application</ConfigurationType> <UseOfMfc>Dynamic</UseOfMfc> </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseOfMfc>Dynamic</UseOfMfc> + </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> </ImportGroup> @@ -44,26 +72,47 @@ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> + </ImportGroup> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseNoLTCG|Win32'" Label="PropertySheets"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseNoLTCG|x64'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> + </ImportGroup> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> + </ImportGroup> <PropertyGroup Label="UserMacros" /> <PropertyGroup> <_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion> <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">..\bin\$(Platform)-Debug\</OutDir> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">..\bin\$(Platform)-Debug\</OutDir> <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">..\build\obj\$(ProjectName)\$(Platform)\$(Configuration)\</IntDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">..\build\obj\$(ProjectName)\$(Platform)\$(Configuration)\</IntDir> <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental> <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">..\bin\$(Platform)\</OutDir> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">..\bin\$(Platform)\</OutDir> <OutDir Condition="'$(Configuration)|$(Platform)'=='ReleaseNoLTCG|Win32'">..\bin\$(Platform)\</OutDir> + <OutDir Condition="'$(Configuration)|$(Platform)'=='ReleaseNoLTCG|x64'">..\bin\$(Platform)\</OutDir> <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">..\build\obj\$(ProjectName)\$(Platform)\$(Configuration)\</IntDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">..\build\obj\$(ProjectName)\$(Platform)\$(Configuration)\</IntDir> <IntDir Condition="'$(Configuration)|$(Platform)'=='ReleaseNoLTCG|Win32'">..\build\obj\$(ProjectName)\$(Platform)\$(Configuration)\</IntDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='ReleaseNoLTCG|x64'">..\build\obj\$(ProjectName)\$(Platform)\$(Configuration)\</IntDir> <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental> <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='ReleaseNoLTCG|Win32'">false</LinkIncremental> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='ReleaseNoLTCG|x64'">false</LinkIncremental> </PropertyGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <Midl> @@ -117,6 +166,57 @@ <Command>subwcrev .. ..\common\svn_version_subwcrev\svn_version.template.h ..\common\svn_version_subwcrev\svn_version.h || del ..\common\svn_version_subwcrev\svn_version.h || true</Command> </PreBuildEvent> </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <Midl> + <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <MkTypLibCompatible>true</MkTypLibCompatible> + <SuppressStartupBanner>true</SuppressStartupBanner> + <TypeLibraryName>.\Debug/mptrack.tlb</TypeLibraryName> + </Midl> + <ClCompile> + <AdditionalOptions>/EHsc %(AdditionalOptions)</AdditionalOptions> + <Optimization>Disabled</Optimization> + <AdditionalIncludeDirectories>..\common;..\soundlib;..\include;..\include\msinttypes\inttypes;..\include\vstsdk2.4\;..\include\ASIOSDK2\common\;..\include\lhasa\lib\public;..\include\zlib;..\;..\common\svn_version_subwcrev;..\common\svn_version_default;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>_DEBUG;WIN32;_WINDOWS;MODPLUG_TRACKER;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <StringPooling>true</StringPooling> + <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> + <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> + <BufferSecurityCheck>true</BufferSecurityCheck> + <FunctionLevelLinking>true</FunctionLevelLinking> + <ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope> + <PrecompiledHeader>Use</PrecompiledHeader> + <PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile> + <BrowseInformation>true</BrowseInformation> + <WarningLevel>Level4</WarningLevel> + <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> + <CompileAs>Default</CompileAs> + </ClCompile> + <ResourceCompile> + <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <Culture>0x0409</Culture> + </ResourceCompile> + <Link> + <AdditionalOptions>%(AdditionalOptions)</AdditionalOptions> + <AdditionalDependencies>winmm.lib;strmiids.lib;dmoguids.lib;version.lib;Rpcrt4.lib;delayimp.lib;dsound.lib;msacm32.lib;%(AdditionalDependencies)</AdditionalDependencies> + <Version>5.0</Version> + <SuppressStartupBanner>true</SuppressStartupBanner> + <AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> + <DelayLoadDLLs>OpenMPT_SoundTouch_i16.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <GenerateDebugInformation>true</GenerateDebugInformation> + <AssemblyDebug>true</AssemblyDebug> + <GenerateMapFile>true</GenerateMapFile> + <SubSystem>Windows</SubSystem> + <RandomizedBaseAddress>false</RandomizedBaseAddress> + <DataExecutionPrevention> + </DataExecutionPrevention> + </Link> + <Manifest> + <AdditionalManifestFiles>$(ProjectDir)res/rt_manif.bin;%(AdditionalManifestFiles)</AdditionalManifestFiles> + </Manifest> + <PreBuildEvent> + <Command>subwcrev .. ..\common\svn_version_subwcrev\svn_version.template.h ..\common\svn_version_subwcrev\svn_version.h || del ..\common\svn_version_subwcrev\svn_version.h || true</Command> + </PreBuildEvent> + </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <Midl> <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> @@ -174,6 +274,62 @@ <Command>subwcrev .. ..\common\svn_version_subwcrev\svn_version.template.h ..\common\svn_version_subwcrev\svn_version.h || del ..\common\svn_version_subwcrev\svn_version.h || true</Command> </PreBuildEvent> </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <Midl> + <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <MkTypLibCompatible>true</MkTypLibCompatible> + <SuppressStartupBanner>true</SuppressStartupBanner> + <TypeLibraryName>.\Bin/mptrack.tlb</TypeLibraryName> + </Midl> + <ClCompile> + <Optimization>MaxSpeed</Optimization> + <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion> + <AdditionalIncludeDirectories>..\common;..\soundlib;..\include;..\include\msinttypes\inttypes;..\include\vstsdk2.4\;..\include\ASIOSDK2\common\;..\include\lhasa\lib\public;..\include\zlib;..\;..\common\svn_version_subwcrev;..\common\svn_version_default;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>NDEBUG;WIN32;_WINDOWS;MODPLUG_TRACKER;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <StringPooling>true</StringPooling> + <RuntimeLibrary>MultiThreaded</RuntimeLibrary> + <BufferSecurityCheck>true</BufferSecurityCheck> + <FunctionLevelLinking>true</FunctionLevelLinking> + <ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope> + <PrecompiledHeader>Use</PrecompiledHeader> + <PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile> + <WarningLevel>Level4</WarningLevel> + <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> + <CompileAs>Default</CompileAs> + <ExceptionHandling>Async</ExceptionHandling> + <IntrinsicFunctions>true</IntrinsicFunctions> + <FloatingPointModel>Fast</FloatingPointModel> + <MultiProcessorCompilation>true</MultiProcessorCompilation> + <WholeProgramOptimization>true</WholeProgramOptimization> + </ClCompile> + <ResourceCompile> + <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <Culture>0x0409</Culture> + </ResourceCompile> + <Link> + <AdditionalOptions>%(AdditionalOptions)</AdditionalOptions> + <AdditionalDependencies>winmm.lib;strmiids.lib;dmoguids.lib;version.lib;Rpcrt4.lib;delayimp.lib;wininet.lib;dsound.lib;msacm32.lib;%(AdditionalDependencies)</AdditionalDependencies> + <Version>5.0</Version> + <SuppressStartupBanner>true</SuppressStartupBanner> + <AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> + <DelayLoadDLLs>OpenMPT_SoundTouch_i16.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <GenerateDebugInformation>true</GenerateDebugInformation> + <SubSystem>Windows</SubSystem> + <OptimizeReferences>true</OptimizeReferences> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <RandomizedBaseAddress>true</RandomizedBaseAddress> + <DataExecutionPrevention>false</DataExecutionPrevention> + <IgnoreSpecificDefaultLibraries> + </IgnoreSpecificDefaultLibraries> + <LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration> + </Link> + <Manifest> + <AdditionalManifestFiles>$(ProjectDir)res/rt_manif.bin;%(AdditionalManifestFiles)</AdditionalManifestFiles> + </Manifest> + <PreBuildEvent> + <Command>subwcrev .. ..\common\svn_version_subwcrev\svn_version.template.h ..\common\svn_version_subwcrev\svn_version.h || del ..\common\svn_version_subwcrev\svn_version.h || true</Command> + </PreBuildEvent> + </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseNoLTCG|Win32'"> <Midl> <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> @@ -230,6 +386,61 @@ <Command>subwcrev .. ..\common\svn_version_subwcrev\svn_version.template.h ..\common\svn_version_subwcrev\svn_version.h || del ..\common\svn_version_subwcrev\svn_version.h || true</Command> </PreBuildEvent> </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseNoLTCG|x64'"> + <Midl> + <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <MkTypLibCompatible>true</MkTypLibCompatible> + <SuppressStartupBanner>true</SuppressStartupBanner> + <TypeLibraryName>.\Bin/mptrack.tlb</TypeLibraryName> + </Midl> + <ClCompile> + <Optimization>MaxSpeed</Optimization> + <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion> + <AdditionalIncludeDirectories>..\common;..\soundlib;..\include;..\include\msinttypes\inttypes;..\include\vstsdk2.4\;..\include\ASIOSDK2\common\;..\include\lhasa\lib\public;..\include\zlib;..\;..\common\svn_version_subwcrev;..\common\svn_version_default;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>NDEBUG;WIN32;_WINDOWS;MODPLUG_TRACKER;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <StringPooling>true</StringPooling> + <RuntimeLibrary>MultiThreaded</RuntimeLibrary> + <BufferSecurityCheck>true</BufferSecurityCheck> + <FunctionLevelLinking>true</FunctionLevelLinking> + <ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope> + <PrecompiledHeader>Use</PrecompiledHeader> + <PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile> + <WarningLevel>Level4</WarningLevel> + <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> + <CompileAs>Default</CompileAs> + <ExceptionHandling>Async</ExceptionHandling> + <IntrinsicFunctions>true</IntrinsicFunctions> + <FloatingPointModel>Fast</FloatingPointModel> + <MultiProcessorCompilation>true</MultiProcessorCompilation> + </ClCompile> + <ResourceCompile> + <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <Culture>0x0409</Culture> + </ResourceCompile> + <Link> + <AdditionalOptions>%(AdditionalOptions)</AdditionalOptions> + <AdditionalDependencies>winmm.lib;strmiids.lib;dmoguids.lib;version.lib;Rpcrt4.lib;delayimp.lib;wininet.lib;dsound.lib;msacm32.lib;%(AdditionalDependencies)</AdditionalDependencies> + <Version>5.0</Version> + <SuppressStartupBanner>true</SuppressStartupBanner> + <AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> + <DelayLoadDLLs>OpenMPT_SoundTouch_i16.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <GenerateDebugInformation>true</GenerateDebugInformation> + <SubSystem>Windows</SubSystem> + <OptimizeReferences>true</OptimizeReferences> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <RandomizedBaseAddress>true</RandomizedBaseAddress> + <DataExecutionPrevention>false</DataExecutionPrevention> + <IgnoreSpecificDefaultLibraries> + </IgnoreSpecificDefaultLibraries> + <LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration> + </Link> + <Manifest> + <AdditionalManifestFiles>$(ProjectDir)res/rt_manif.bin;%(AdditionalManifestFiles)</AdditionalManifestFiles> + </Manifest> + <PreBuildEvent> + <Command>subwcrev .. ..\common\svn_version_subwcrev\svn_version.template.h ..\common\svn_version_subwcrev\svn_version.h || del ..\common\svn_version_subwcrev\svn_version.h || true</Command> + </PreBuildEvent> + </ItemDefinitionGroup> <ItemGroup> <ClCompile Include="..\common\AudioCriticalSection.cpp" /> <ClCompile Include="..\common\misc_util.cpp" /> @@ -341,10 +552,15 @@ <ClCompile Include="ScaleEnvPointsDlg.cpp" /> <ClCompile Include="..\common\stdafx.cpp"> <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader> + <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader> <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader> + <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader> <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='ReleaseNoLTCG|Win32'">Create</PrecompiledHeader> + <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='ReleaseNoLTCG|x64'">Create</PrecompiledHeader> <MultiProcessorCompilation Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</MultiProcessorCompilation> + <MultiProcessorCompilation Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</MultiProcessorCompilation> <MultiProcessorCompilation Condition="'$(Configuration)|$(Platform)'=='ReleaseNoLTCG|Win32'">false</MultiProcessorCompilation> + <MultiProcessorCompilation Condition="'$(Configuration)|$(Platform)'=='ReleaseNoLTCG|x64'">false</MultiProcessorCompilation> </ClCompile> <ClCompile Include="..\soundlib\tuning.cpp" /> <ClCompile Include="..\soundlib\tuningbase.cpp" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2013-11-07 21:22:53
|
Revision: 3115 http://sourceforge.net/p/modplug/code/3115 Author: saga-games Date: 2013-11-07 21:22:42 +0000 (Thu, 07 Nov 2013) Log Message: ----------- [Ref] Rewrote CTrackApp::ShowOpenSaveFileDialog; has been moved to FileDialog.cpp and is now a bit easier to use. No longer uses MFC's implementation, so we can use the unicode version without having to compile MFC with unicode support. [Ref] Moved and unified folder browser code to FileDialog.cpp [Fix] TrackerSettings::SetWorkingDirectory was broken Modified Paths: -------------- trunk/OpenMPT/mptrack/AutoSaver.cpp trunk/OpenMPT/mptrack/Ctrl_ins.cpp trunk/OpenMPT/mptrack/Ctrl_smp.cpp trunk/OpenMPT/mptrack/KeyConfigDlg.cpp trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/Moptions.cpp trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/Mptrack.h trunk/OpenMPT/mptrack/SelectPluginDialog.cpp trunk/OpenMPT/mptrack/TrackerSettings.cpp trunk/OpenMPT/mptrack/TuningDialog.cpp trunk/OpenMPT/mptrack/View_tre.cpp trunk/OpenMPT/mptrack/Vstplug.cpp trunk/OpenMPT/mptrack/mptrack_08.vcproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters Added Paths: ----------- trunk/OpenMPT/mptrack/FileDialog.cpp trunk/OpenMPT/mptrack/FileDialog.h Modified: trunk/OpenMPT/mptrack/AutoSaver.cpp =================================================================== --- trunk/OpenMPT/mptrack/AutoSaver.cpp 2013-11-07 20:47:49 UTC (rev 3114) +++ trunk/OpenMPT/mptrack/AutoSaver.cpp 2013-11-07 21:22:42 UTC (rev 3115) @@ -14,6 +14,7 @@ #include "moddoc.h" #include "AutoSaver.h" #include "moptions.h" +#include "FileDialog.h" #include <algorithm> #include <io.h> #include <stdio.h> @@ -402,19 +403,12 @@ void CAutoSaverGUI::OnBnClickedAutosaveBrowse() { CHAR szPath[_MAX_PATH] = ""; - BROWSEINFO bi; + GetDlgItemText(IDC_AUTOSAVE_PATH, szPath, CountOf(szPath)); - GetDlgItemText(IDC_AUTOSAVE_PATH, szPath, CountOf(szPath)); - MemsetZero(bi); - bi.hwndOwner = m_hWnd; - bi.lpszTitle = "Select a folder to store autosaved files in..."; - bi.pszDisplayName = szPath; - bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_USENEWUI; - LPITEMIDLIST pid = SHBrowseForFolder(&bi); - if (pid != NULL) + BrowseForFolder dlg(szPath, "Select a folder to store autosaved files in..."); + if(dlg.Show()) { - SHGetPathFromIDList(pid, szPath); - SetDlgItemText(IDC_AUTOSAVE_PATH, szPath); + SetDlgItemText(IDC_AUTOSAVE_PATH, dlg.GetDirectory().c_str()); OnSettingsChanged(); } } Modified: trunk/OpenMPT/mptrack/Ctrl_ins.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2013-11-07 20:47:49 UTC (rev 3114) +++ trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2013-11-07 21:22:42 UTC (rev 3115) @@ -23,6 +23,7 @@ #include "../common/StringFixer.h" #include "SelectPluginDialog.h" #include "MemoryMappedFile.h" +#include "FileDialog.h" #pragma warning(disable:4244) //conversion from 'type1' to 'type2', possible loss of data @@ -1680,20 +1681,22 @@ { static int nLastIndex = 0; - FileDlgResult files = CTrackApp::ShowOpenSaveFileDialog(true, "", "", - "All Instruments|*.xi;*.pat;*.iti;*.flac;*.wav;*.aif;*.aiff|" - "FastTracker II Instruments (*.xi)|*.xi|" - "GF1 Patches (*.pat)|*.pat|" - "Impulse Tracker Instruments (*.iti)|*.iti|" - "All Files (*.*)|*.*||", - TrackerSettings::Instance().GetWorkingDirectory(DIR_INSTRUMENTS), - true, - &nLastIndex); - if(files.abort) return; + FileDialog dlg = OpenFileDialog() + .AllowMultiSelect() + .ExtensionFilter( + "All Instruments|*.xi;*.pat;*.iti;*.flac;*.wav;*.aif;*.aiff|" + "FastTracker II Instruments (*.xi)|*.xi|" + "GF1 Patches (*.pat)|*.pat|" + "Impulse Tracker Instruments (*.iti)|*.iti|" + "All Files (*.*)|*.*||") + .WorkingDirectory(TrackerSettings::Instance().GetWorkingDirectory(DIR_INSTRUMENTS)) + .FilterIndex(&nLastIndex); + if(!dlg.Show()) return; - TrackerSettings::Instance().SetWorkingDirectory(files.workingDirectory.c_str(), DIR_INSTRUMENTS, true); + TrackerSettings::Instance().SetWorkingDirectory(dlg.GetWorkingDirectory().c_str(), DIR_INSTRUMENTS, true); - for(size_t counter = 0; counter < files.filenames.size(); counter++) + const FileDialog::PathList &files = dlg.GetFilenames(); + for(size_t counter = 0; counter < files.size(); counter++) { //If loading multiple instruments, advancing to next instrument and creating //new instrument if necessary. @@ -1708,7 +1711,7 @@ OnInstrumentNew(); } - if(!OpenInstrument(files.filenames[counter].c_str())) + if(!OpenInstrument(files[counter].c_str())) ErrorBox(IDS_ERR_FILEOPEN, this); } @@ -1734,39 +1737,42 @@ SanitizeFilename(szFileName); int index = 0; - FileDlgResult files = CTrackApp::ShowOpenSaveFileDialog(false, (m_sndFile.GetType() == MOD_TYPE_XM) ? "xi" : "iti", szFileName, - (m_sndFile.GetType() == MOD_TYPE_XM) ? - "FastTracker II Instruments (*.xi)|*.xi|" - "Impulse Tracker Instruments (*.iti)|*.iti|" - "Compressed Impulse Tracker Instruments (*.iti)|*.iti||" : - "Impulse Tracker Instruments (*.iti)|*.iti|" - "Compressed Impulse Tracker Instruments (*.iti)|*.iti|" - "FastTracker II Instruments (*.xi)|*.xi||", - TrackerSettings::Instance().GetWorkingDirectory(DIR_INSTRUMENTS), false, &index); - if(files.abort) return; + FileDialog dlg = SaveFileDialog() + .DefaultExtension(m_sndFile.GetType() == MOD_TYPE_XM ? "xi" : "iti") + .DefaultFilename(szFileName) + .ExtensionFilter((m_sndFile.GetType() == MOD_TYPE_XM) ? + "FastTracker II Instruments (*.xi)|*.xi|" + "Impulse Tracker Instruments (*.iti)|*.iti|" + "Compressed Impulse Tracker Instruments (*.iti)|*.iti||" + : "Impulse Tracker Instruments (*.iti)|*.iti|" + "Compressed Impulse Tracker Instruments (*.iti)|*.iti|" + "FastTracker II Instruments (*.xi)|*.xi||") + .WorkingDirectory(TrackerSettings::Instance().GetWorkingDirectory(DIR_INSTRUMENTS)) + .FilterIndex(&index); + if(!dlg.Show()) return; BeginWaitCursor(); - _splitpath(files.first_file.c_str(), drive, path, NULL, ext); - BOOL bOk = FALSE; + _splitpath(dlg.GetFirstFile().c_str(), drive, path, NULL, ext); + bool ok = false; if (!lstrcmpi(ext, ".iti")) - bOk = m_sndFile.SaveITIInstrument(m_nInstrument, files.first_file.c_str(), index == (m_sndFile.GetType() == MOD_TYPE_XM ? 3 : 2)); + ok = m_sndFile.SaveITIInstrument(m_nInstrument, dlg.GetFirstFile().c_str(), index == (m_sndFile.GetType() == MOD_TYPE_XM ? 3 : 2)); else - bOk = m_sndFile.SaveXIInstrument(m_nInstrument, files.first_file.c_str()); + ok = m_sndFile.SaveXIInstrument(m_nInstrument, dlg.GetFirstFile().c_str()); // -> CODE#0023 // -> DESC="IT project files (.itp)" - m_sndFile.m_szInstrumentPath[m_nInstrument - 1] = files.first_file; + m_sndFile.m_szInstrumentPath[m_nInstrument - 1] = dlg.GetFirstFile(); SetInstrumentModified(false); // -! NEW_FEATURE#0023 EndWaitCursor(); - if (!bOk) ErrorBox(IDS_ERR_SAVEINS, this); else + if (!ok) ErrorBox(IDS_ERR_SAVEINS, this); else { strcpy(szFileName, drive); strcat(szFileName, path); - TrackerSettings::Instance().SetWorkingDirectory(files.workingDirectory.c_str(), DIR_INSTRUMENTS); + TrackerSettings::Instance().SetWorkingDirectory(dlg.GetWorkingDirectory().c_str(), DIR_INSTRUMENTS); // -> CODE#0023 // -> DESC="IT project files (.itp)" Modified: trunk/OpenMPT/mptrack/Ctrl_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2013-11-07 20:47:49 UTC (rev 3114) +++ trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2013-11-07 21:22:42 UTC (rev 3115) @@ -30,6 +30,7 @@ #include "MemoryMappedFile.h" #include "../soundlib/FileReader.h" #include <Shlwapi.h> +#include "FileDialog.h" #ifdef _DEBUG #define new DEBUG_NEW @@ -943,31 +944,31 @@ //------------------------------- { static int nLastIndex = 0; - - FileDlgResult files = CTrackApp::ShowOpenSaveFileDialog(true, "", "", - "All Samples|*.wav;*.flac;*.pat;*.s3i;*.smp;*.snd;*.raw;*.xi;*.aif;*.aiff;*.its;*.8sv;*.8svx;*.svx;*.pcm;*.mp1;*.mp2;*.mp3|" - "Wave Files (*.wav)|*.wav|" -#ifndef NO_FLAC - "FLAC Files (*.flac)|*.flac|" -#endif // NO_FLAC -#ifndef NO_MP3_SAMPLES - "MPEG Files (*.mp1,*.mp2,*.mp3)|*.mp1;*.mp2;*.mp3|" -#endif // NO_MP3_SAMPLES - "XI Samples (*.xi)|*.xi|" - "Impulse Tracker Samples (*.its)|*.its|" - "ScreamTracker Samples (*.s3i,*.smp)|*.s3i;*.smp|" - "GF1 Patches (*.pat)|*.pat|" - "AIFF Files (*.aiff;*.8svx)|*.aif;*.aiff;*.8sv;*.8svx;*.svx|" - "Raw Samples (*.raw,*.snd,*.pcm)|*.raw;*.snd;*.pcm|" - "All Files (*.*)|*.*||", - TrackerSettings::Instance().GetWorkingDirectory(DIR_SAMPLES), - true, - &nLastIndex); - if(files.abort) return; + FileDialog dlg = OpenFileDialog() + .AllowMultiSelect() + .ExtensionFilter("All Samples|*.wav;*.flac;*.pat;*.s3i;*.smp;*.snd;*.raw;*.xi;*.aif;*.aiff;*.its;*.8sv;*.8svx;*.svx;*.pcm;*.mp1;*.mp2;*.mp3|" + "Wave Files (*.wav)|*.wav|" + #ifndef NO_FLAC + "FLAC Files (*.flac)|*.flac|" + #endif // NO_FLAC + #ifndef NO_MP3_SAMPLES + "MPEG Files (*.mp1,*.mp2,*.mp3)|*.mp1;*.mp2;*.mp3|" + #endif // NO_MP3_SAMPLES + "XI Samples (*.xi)|*.xi|" + "Impulse Tracker Samples (*.its)|*.its|" + "ScreamTracker Samples (*.s3i,*.smp)|*.s3i;*.smp|" + "GF1 Patches (*.pat)|*.pat|" + "AIFF Files (*.aiff;*.8svx)|*.aif;*.aiff;*.8sv;*.8svx;*.svx|" + "Raw Samples (*.raw,*.snd,*.pcm)|*.raw;*.snd;*.pcm|" + "All Files (*.*)|*.*||") + .WorkingDirectory(TrackerSettings::Instance().GetWorkingDirectory(DIR_SAMPLES)) + .FilterIndex(&nLastIndex); + if(!dlg.Show()) return; - TrackerSettings::Instance().SetWorkingDirectory(files.workingDirectory.c_str(), DIR_SAMPLES, true); + TrackerSettings::Instance().SetWorkingDirectory(dlg.GetWorkingDirectory().c_str(), DIR_SAMPLES, true); - for(size_t counter = 0; counter < files.filenames.size(); counter++) + const FileDialog::PathList &files = dlg.GetFilenames(); + for(size_t counter = 0; counter < files.size(); counter++) { // If loading multiple samples, create new slots for them if(counter > 0) @@ -975,7 +976,7 @@ OnSampleNew(); } - if(!OpenSample(files.filenames[counter].c_str())) + if(!OpenSample(files[counter].c_str())) ErrorBox(IDS_ERR_FILEOPEN, this); } SwitchToView(); @@ -1034,21 +1035,24 @@ else if(!format.CompareNoCase("raw")) filter = 3; - FileDlgResult files = CTrackApp::ShowOpenSaveFileDialog(false, std::string(format), szFileName, - "Wave File (*.wav)|*.wav|" - "FLAC File (*.flac)|*.flac|" - "RAW Audio (*.raw)|*.raw||", - TrackerSettings::Instance().GetWorkingDirectory(DIR_SAMPLES), false, &filter); - if(files.abort) return; + FileDialog dlg = SaveFileDialog() + .DefaultExtension(std::string(format)) + .DefaultFilename(szFileName) + .ExtensionFilter("Wave File (*.wav)|*.wav|" + "FLAC File (*.flac)|*.flac|" + "RAW Audio (*.raw)|*.raw||") + .WorkingDirectory(TrackerSettings::Instance().GetWorkingDirectory(DIR_SAMPLES)) + .FilterIndex(&filter); + if(!dlg.Show()) return; BeginWaitCursor(); TCHAR ext[_MAX_EXT]; - _splitpath(files.first_file.c_str(), NULL, NULL, NULL, ext); + _splitpath(dlg.GetFirstFile().c_str(), NULL, NULL, NULL, ext); bool bOk = false; SAMPLEINDEX iMinSmp = m_nSample, iMaxSmp = m_nSample; - CString sFilename = files.first_file.c_str(), sNumberFormat; + CString sFilename = dlg.GetFirstFile().c_str(), sNumberFormat; if(doBatchSave) { iMinSmp = 1; @@ -1071,7 +1075,7 @@ SanitizeFilename(sSampleName); SanitizeFilename(sSampleFilename); - sFilename = files.first_file.c_str(); + sFilename = dlg.GetFirstFile().c_str(); sFilename.Replace("%sample_number%", sSampleNumber); sFilename.Replace("%sample_filename%", sSampleFilename); sFilename.Replace("%sample_name%", sSampleName); @@ -1091,7 +1095,7 @@ ErrorBox(IDS_ERR_SAVESMP, this); } else { - TrackerSettings::Instance().SetWorkingDirectory(files.workingDirectory.c_str(), DIR_SAMPLES, true); + TrackerSettings::Instance().SetWorkingDirectory(dlg.GetWorkingDirectory().c_str(), DIR_SAMPLES, true); } SwitchToView(); } Added: trunk/OpenMPT/mptrack/FileDialog.cpp =================================================================== --- trunk/OpenMPT/mptrack/FileDialog.cpp (rev 0) +++ trunk/OpenMPT/mptrack/FileDialog.cpp 2013-11-07 21:22:42 UTC (rev 3115) @@ -0,0 +1,142 @@ +/* + * FileDialog.cpp + * -------------- + * Purpose: File and folder selection dialogs implementation. + * Notes : (currently none) + * Authors: OpenMPT Devs + * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. + */ + + +#include "stdafx.h" +#include "FileDialog.h" +#include "Mptrack.h" +#include "Mainfrm.h" +#include "../common/StringFixer.h" + + +// Display the file dialog. +bool FileDialog::Show() +//--------------------- +{ + filenames.clear(); + + // Convert filter representation to WinAPI style. + for(size_t i = 0; i < extFilter.length(); i++) + if(extFilter[i] == '|') extFilter[i] = 0; + extFilter.push_back(0); + + // Prepare filename buffer. + std::vector<TCHAR> filenameBuffer(uint16_max, 0); + filenameBuffer.insert(filenameBuffer.begin(), defaultFilename.begin(), defaultFilename.end()); + filenameBuffer.push_back(0); + + // First, set up the dialog... + OPENFILENAME ofn; + MemsetZero(ofn); + ofn.lStructSize = sizeof(OPENFILENAME); + ofn.hwndOwner = theApp.m_pMainWnd->GetSafeHwnd(); + ofn.hInstance = theApp.m_hInstance; + ofn.lpstrFilter = extFilter.c_str(); + ofn.lpstrCustomFilter = NULL; + ofn.nMaxCustFilter = 0; + ofn.nFilterIndex = filterIndex != nullptr ? *filterIndex : 0; + ofn.lpstrFile = &filenameBuffer[0]; + ofn.nMaxFile = filenameBuffer.size(); + ofn.lpstrFileTitle = NULL; + ofn.nMaxFileTitle = 0; + ofn.lpstrInitialDir = workingDirectory.empty() ? NULL : workingDirectory.c_str(); + ofn.lpstrTitle = NULL; + ofn.Flags = OFN_EXPLORER | OFN_HIDEREADONLY | OFN_ENABLESIZING | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | (multiSelect ? OFN_ALLOWMULTISELECT : 0) | (load ? 0 : OFN_NOREADONLYRETURN); + ofn.nFileOffset = 0; + ofn.nFileExtension = 0; + ofn.lpstrDefExt = defaultExtension.empty() ? NULL : defaultExtension.c_str(); + ofn.lCustData = NULL; + ofn.lpfnHook = NULL; + ofn.lpTemplateName = NULL; + ofn.pvReserved = NULL; + ofn.dwReserved = 0; + ofn.FlagsEx = 0; + + // Do it! + CMainFrame::GetInputHandler()->Bypass(true); + BOOL result = load ? GetOpenFileName(&ofn) : GetSaveFileName(&ofn); + CMainFrame::GetInputHandler()->Bypass(false); + + if(result == FALSE) + { + return false; + } + + // Retrieve variables + if(filterIndex != nullptr) + *filterIndex = ofn.nFilterIndex; + + if(multiSelect) + { + // Multiple files might have been selected + int pos = ofn.nFileOffset; + const TCHAR *currentFile = ofn.lpstrFile + pos; + TCHAR filePath[MAX_PATH + 1]; + lstrcpy(filePath, ofn.lpstrFile); + lstrcat(filePath, "\\"); + + while(currentFile[0] != 0) + { + lstrcpy(&filePath[ofn.nFileOffset], currentFile); + currentFile += lstrlen(currentFile) + 1; + filenames.push_back(filePath); + } + } else + { + // Only one file + filenames.push_back(ofn.lpstrFile); + } + + if(filenames.empty()) + { + return false; + } + + workingDirectory = filenames.front().substr(0, ofn.nFileOffset); + defaultExtension = filenames.front().substr(ofn.nFileExtension); + + return true; +} + + +// Helper callback to set start path. +int CALLBACK BrowseForFolder::BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM /*lParam*/, LPARAM lpData) +//------------------------------------------------------------------------------------------------------ +{ + if(uMsg == BFFM_INITIALIZED && lpData != NULL) + { + const BrowseForFolder *that = reinterpret_cast<BrowseForFolder *>(lpData); + SendMessage(hwnd, BFFM_SETSELECTION, TRUE, reinterpret_cast<LPARAM>(that->workingDirectory.c_str())); + } + return 0; +} + + +// Display the folder dialog. +bool BrowseForFolder::Show() +//-------------------------- +{ + TCHAR path[MAX_PATH]; + + BROWSEINFO bi; + MemsetZero(bi); + bi.hwndOwner = theApp.m_pMainWnd->GetSafeHwnd(); + bi.lpszTitle = caption; + bi.pszDisplayName = path; + bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_USENEWUI; + bi.lpfn = BrowseCallbackProc; + bi.lParam = reinterpret_cast<LPARAM>(this); + LPITEMIDLIST pid = SHBrowseForFolder(&bi); + if(pid != NULL && SHGetPathFromIDList(pid, path)) + { + workingDirectory = path; + return true; + } + return false; +} Added: trunk/OpenMPT/mptrack/FileDialog.h =================================================================== --- trunk/OpenMPT/mptrack/FileDialog.h (rev 0) +++ trunk/OpenMPT/mptrack/FileDialog.h 2013-11-07 21:22:42 UTC (rev 3115) @@ -0,0 +1,100 @@ +/* + * FileDialog.h + * ------------ + * Purpose: File and folder selection dialogs implementation. + * Notes : (currently none) + * Authors: OpenMPT Devs + * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. + */ + +#pragma once + +#include <string> +#include <vector> + +// Generic open / save file dialog. Cannot be instanced by the user, use OpenFileDialog / SaveFileDialog instead. +class FileDialog +{ +public: + typedef std::vector<std::string> PathList; + +protected: + std::string defaultExtension; + std::string defaultFilename; + std::string extFilter; + std::string workingDirectory; + std::string lastPreviewFile; + PathList filenames; + int *filterIndex; + bool load; + bool multiSelect; + +protected: + FileDialog(bool load) : filterIndex(nullptr), load(load), multiSelect(false) { } + +public: + // Default extension to use if none is specified. + FileDialog &DefaultExtension(const std::string &ext) { defaultExtension = ext; return *this; } + // Default suggested filename. + FileDialog &DefaultFilename(const std::string &name) { defaultFilename = name; return *this; } + // List of possible extensions. Format: "description|extensions|...|description|extensions||" + FileDialog &ExtensionFilter(const std::string &filter) { extFilter = filter; return *this; } + // Default directory of the dialog. + FileDialog &WorkingDirectory(const std::string &dir) { workingDirectory = dir; return *this; } + // Pointer to a variable holding the index of the last extension filter to use. Holds the selected filter after the dialog has been closed. + FileDialog &FilterIndex(int *index) { filterIndex = index; return *this; } + + // Show the file selection dialog. + bool Show(); + + // Get some selected file. Mostly useful when only one selected file is possible anyway. + const std::string &GetFirstFile() const { return filenames.front(); } + // Gets all selected files. + const PathList &GetFilenames() const { return filenames; } + // Gets directory in which the selected files are placed. + const std::string &GetWorkingDirectory() const { return workingDirectory; } + // Gets the extension of the first selected file, without dot. + const std::string &GetExtension() const { return defaultExtension; } + +protected: + static UINT_PTR CALLBACK OFNHookProc(HWND hdlg, UINT uiMsg, WPARAM wParam, LPARAM lParam); +}; + + +// Dialog for opening files +class OpenFileDialog : public FileDialog +{ +public: + OpenFileDialog() : FileDialog(true) { } + + // Enable selection of multiple files + OpenFileDialog &AllowMultiSelect() { multiSelect = true; return *this; } +}; + + +// Dialog for saving files +class SaveFileDialog : public FileDialog +{ +public: + SaveFileDialog() : FileDialog(false) { } +}; + + +class BrowseForFolder +{ +protected: + std::string workingDirectory; + const char *caption; + +public: + BrowseForFolder(const std::string &dir, const char *caption) : workingDirectory(dir), caption(caption) { } + + // Show the folder selection dialog. + bool Show(); + + // Gets selected directory. + const std::string &GetDirectory() const { return workingDirectory; } + +protected: + static int CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData); +}; Modified: trunk/OpenMPT/mptrack/KeyConfigDlg.cpp =================================================================== --- trunk/OpenMPT/mptrack/KeyConfigDlg.cpp 2013-11-07 20:47:49 UTC (rev 3114) +++ trunk/OpenMPT/mptrack/KeyConfigDlg.cpp 2013-11-07 21:22:42 UTC (rev 3115) @@ -10,6 +10,7 @@ #include "stdafx.h" #include "KeyConfigDlg.h" +#include "FileDialog.h" //***************************************************************************************// // CCustEdit: customised CEdit control to catch keypresses. @@ -836,14 +837,15 @@ void COptionsKeyboard::OnLoad() //----------------------------- -{ - std::string filename = m_sFullPathName; - FileDlgResult files = CTrackApp::ShowOpenSaveFileDialog(true, "mkb", filename, - "OpenMPT Key Bindings (*.mkb)|*.mkb||", - TrackerSettings::Instance().m_szKbdFile); - if(files.abort) return; +{ + FileDialog dlg = OpenFileDialog() + .DefaultExtension("mkb") + .DefaultFilename(std::string(m_sFullPathName)) + .ExtensionFilter("OpenMPT Key Bindings (*.mkb)|*.mkb||") + .WorkingDirectory(TrackerSettings::Instance().m_szKbdFile); + if(!dlg.Show()) return; - m_sFullPathName = files.first_file.c_str(); + m_sFullPathName = dlg.GetFirstFile().c_str(); plocalCmdSet->LoadFile(m_sFullPathName); ForceUpdateGUI(); //TentativeSetToDefaultFile(m_sFullPathName); @@ -853,13 +855,14 @@ void COptionsKeyboard::OnSave() //----------------------------- { - std::string filename = m_sFullPathName; - FileDlgResult files = CTrackApp::ShowOpenSaveFileDialog(false, "mkb", filename, - "OpenMPT Key Bindings (*.mkb)|*.mkb||", - TrackerSettings::Instance().m_szKbdFile); - if(files.abort) return; + FileDialog dlg = SaveFileDialog() + .DefaultExtension("mkb") + .DefaultFilename(std::string(m_sFullPathName)) + .ExtensionFilter("OpenMPT Key Bindings (*.mkb)|*.mkb||") + .WorkingDirectory(TrackerSettings::Instance().m_szKbdFile); + if(!dlg.Show()) return; - m_sFullPathName = files.first_file.c_str(); + m_sFullPathName = dlg.GetFirstFile().c_str(); plocalCmdSet->SaveFile(m_sFullPathName); //TentativeSetToDefaultFile(m_sFullPathName); } Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2013-11-07 20:47:49 UTC (rev 3114) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2013-11-07 21:22:42 UTC (rev 3115) @@ -39,6 +39,7 @@ #include "MemoryMappedFile.h" #include "soundlib/FileReader.h" #include "../common/Profiler.h" +#include "FileDialog.h" #ifdef _DEBUG #define new DEBUG_NEW @@ -1846,19 +1847,19 @@ void CMainFrame::OnAddDlsBank() //----------------------------- { - FileDlgResult files = CTrackApp::ShowOpenSaveFileDialog(true, "dls", "", - "All Sound Banks|*.dls;*.sbk;*.sf2;*.mss|" - "Downloadable Sounds Banks (*.dls)|*.dls;*.mss|" - "SoundFont 2.0 Banks (*.sf2)|*.sbk;*.sf2|" - "All Files (*.*)|*.*||", - "", - true); - if(files.abort) return; + FileDialog dlg = OpenFileDialog() + .AllowMultiSelect() + .ExtensionFilter("All Sound Banks|*.dls;*.sbk;*.sf2;*.mss|" + "Downloadable Sounds Banks (*.dls)|*.dls;*.mss|" + "SoundFont 2.0 Banks (*.sf2)|*.sbk;*.sf2|" + "All Files (*.*)|*.*||"); + if(!dlg.Show()) return; BeginWaitCursor(); - for(size_t counter = 0; counter < files.filenames.size(); counter++) + const FileDialog::PathList &files = dlg.GetFilenames(); + for(size_t counter = 0; counter < files.size(); counter++) { - CTrackApp::AddDLSBank(files.filenames[counter].c_str()); + CTrackApp::AddDLSBank(files[counter].c_str()); } m_wndTree.RefreshDlsBanks(); EndWaitCursor(); @@ -1868,16 +1869,16 @@ void CMainFrame::OnImportMidiLib() //-------------------------------- { - FileDlgResult files = CTrackApp::ShowOpenSaveFileDialog(true, "", "", - "Text and INI files (*.txt,*.ini)|*.txt;*.ini;*.dls;*.sf2;*.sbk|" - "Downloadable Sound Banks (*.dls)|*.dls;*.mss|" - "SoundFont 2.0 banks (*.sf2)|*.sbk;*.sf2|" - "Gravis UltraSound (ultrasnd.ini)|ultrasnd.ini|" - "All Files (*.*)|*.*||"); - if(files.abort) return; + FileDialog dlg = OpenFileDialog() + .ExtensionFilter("Text and INI files (*.txt,*.ini)|*.txt;*.ini;*.dls;*.sf2;*.sbk|" + "Downloadable Sound Banks (*.dls)|*.dls;*.mss|" + "SoundFont 2.0 banks (*.sf2)|*.sbk;*.sf2|" + "Gravis UltraSound (ultrasnd.ini)|ultrasnd.ini|" + "All Files (*.*)|*.*||"); + if(!dlg.Show()) return; BeginWaitCursor(); - CTrackApp::ImportMidiConfig(files.first_file.c_str()); + CTrackApp::ImportMidiConfig(dlg.GetFirstFile().c_str()); m_wndTree.RefreshMidiLibrary(); EndWaitCursor(); } Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2013-11-07 20:47:49 UTC (rev 3114) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2013-11-07 21:22:42 UTC (rev 3115) @@ -35,6 +35,7 @@ #endif #include "soundlib/FileReader.h" #include <shlwapi.h> +#include "FileDialog.h" #ifdef _DEBUG #define new DEBUG_NEW @@ -602,14 +603,16 @@ strcat(s, fname); strcat(s, fext); - FileDlgResult files = CTrackApp::ShowOpenSaveFileDialog(false, defaultExtension, s, - ModTypeToFilter(m_SndFile), - TrackerSettings::Instance().GetWorkingDirectory(DIR_MODS)); - if(files.abort) return FALSE; + FileDialog dlg = SaveFileDialog() + .DefaultExtension(defaultExtension) + .DefaultFilename(s) + .ExtensionFilter(ModTypeToFilter(m_SndFile)) + .WorkingDirectory(TrackerSettings::Instance().GetWorkingDirectory(DIR_MODS)); + if(!dlg.Show()) return FALSE; - TrackerSettings::Instance().SetWorkingDirectory(files.workingDirectory.c_str(), DIR_MODS, true); + TrackerSettings::Instance().SetWorkingDirectory(dlg.GetWorkingDirectory().c_str(), DIR_MODS, true); - strcpy(s, files.first_file.c_str()); + strcpy(s, dlg.GetFirstFile().c_str()); _splitpath(s, drive, path, fname, fext); } else { @@ -1660,19 +1663,18 @@ strcat_s(fname, CountOf(fname), "."); strcat_s(fname, CountOf(fname), extension.c_str()); - std::string filter = encFactory->GetTraits().fileDescription + " (*." + extension + ")|*." + extension + "||"; - FileDlgResult files = CTrackApp::ShowOpenSaveFileDialog(false, - extension.c_str(), - fname, - filter.c_str(), - TrackerSettings::Instance().GetWorkingDirectory(DIR_EXPORT)); - if(files.abort) return; + FileDialog dlg = SaveFileDialog() + .DefaultExtension(extension) + .DefaultFilename(fname) + .ExtensionFilter(encFactory->GetTraits().fileDescription + " (*." + extension + ")|*." + extension + "||") + .WorkingDirectory(TrackerSettings::Instance().GetWorkingDirectory(DIR_EXPORT)); + if(!dlg.Show()) return; // will set default dir here because there's no setup option for export dir yet (feel free to add one...) - TrackerSettings::Instance().SetDefaultDirectory(files.workingDirectory.c_str(), DIR_EXPORT, true); + TrackerSettings::Instance().SetDefaultDirectory(dlg.GetWorkingDirectory().c_str(), DIR_EXPORT, true); char drive[_MAX_DRIVE], dir[_MAX_DIR], name[_MAX_FNAME], ext[_MAX_EXT]; - _splitpath(files.first_file.c_str(), drive, dir, name, ext); + _splitpath(dlg.GetFirstFile().c_str(), drive, dir, name, ext); const CString fileName = CString(drive) + CString(dir) + CString(name); const CString fileExt = CString(ext); @@ -1898,12 +1900,14 @@ strcat(s, fname); strcat(s, ".mid"); - FileDlgResult files = CTrackApp::ShowOpenSaveFileDialog(false, "mid", s, - "Midi Files (*.mid,*.rmi)|*.mid;*.rmi||"); - if(files.abort) return; + FileDialog dlg = SaveFileDialog() + .DefaultExtension("mid") + .DefaultFilename(s) + .ExtensionFilter("Midi Files (*.mid,*.rmi)|*.mid;*.rmi||"); + if(!dlg.Show()) return; - CModToMidi mididlg(files.first_file.c_str(), &m_SndFile, pMainFrm); - if (mididlg.DoModal() == IDOK) + CModToMidi mididlg(dlg.GetFirstFile().c_str(), &m_SndFile, pMainFrm); + if(mididlg.DoModal() == IDOK) { BeginWaitCursor(); mididlg.DoConvert(); @@ -1953,18 +1957,22 @@ filename += ext; } - FileDlgResult files = CTrackApp::ShowOpenSaveFileDialog(false, ext, filename, pattern, TrackerSettings::Instance().GetWorkingDirectory(DIR_MODS)); - if(files.abort) return; + FileDialog dlg = SaveFileDialog() + .DefaultExtension(ext) + .DefaultFilename(filename) + .ExtensionFilter(pattern) + .WorkingDirectory(TrackerSettings::Instance().GetWorkingDirectory(DIR_MODS)); + if(!dlg.Show()) return; ScopedLogCapturer logcapturer(*this); FixNullStrings(); switch (type) { case MOD_TYPE_XM: - m_SndFile.SaveXM(files.first_file.c_str(), true); + m_SndFile.SaveXM(dlg.GetFirstFile().c_str(), true); break; case MOD_TYPE_IT: - m_SndFile.SaveIT(files.first_file.c_str(), true); + m_SndFile.SaveIT(dlg.GetFirstFile().c_str(), true); break; } } @@ -2903,14 +2911,16 @@ } // Ask file name from user. - FileDlgResult fdr = CTrackApp::ShowOpenSaveFileDialog(false, m_SndFile.GetModSpecifications().fileExtension, (LPCTSTR)sName, - ModTypeToFilter(m_SndFile), pszTemplateFolder); - - if (fdr.abort) + FileDialog dlg = SaveFileDialog() + .DefaultExtension(m_SndFile.GetModSpecifications().fileExtension) + .DefaultFilename(std::string(sName)) + .ExtensionFilter(ModTypeToFilter(m_SndFile)) + .WorkingDirectory(pszTemplateFolder); + if(!dlg.Show()) return; const CString sOldPath = m_strPathName; - OnSaveDocument(fdr.first_file.c_str(), true/*template file*/); + OnSaveDocument(dlg.GetFirstFile().c_str(), true/*template file*/); m_strPathName = sOldPath; } Modified: trunk/OpenMPT/mptrack/Moptions.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moptions.cpp 2013-11-07 20:47:49 UTC (rev 3114) +++ trunk/OpenMPT/mptrack/Moptions.cpp 2013-11-07 21:22:42 UTC (rev 3115) @@ -17,6 +17,7 @@ #include "moddoc.h" #include "Settings.h" #include "dlg_misc.h" +#include "FileDialog.h" ////////////////////////////////////////////////////////////// @@ -487,15 +488,16 @@ void COptionsColors::OnLoadColorScheme() //-------------------------------------- { - FileDlgResult files = CTrackApp::ShowOpenSaveFileDialog(true, "mptcolor", "", - "OpenMPT Color Schemes|*.mptcolor||", - theApp.GetConfigPath()); - if(files.abort) return; + FileDialog dlg = OpenFileDialog() + .DefaultExtension("mptcolor") + .ExtensionFilter("OpenMPT Color Schemes|*.mptcolor||") + .WorkingDirectory(theApp.GetConfigPath()); + if(!dlg.Show()) return; // Ensure that all colours are reset (for outdated colour schemes) OnPresetMPT(); { - IniFileSettingsContainer file(mpt::PathString::FromLocale(files.first_file)); + IniFileSettingsContainer file(mpt::PathString::FromLocale(dlg.GetFirstFile())); for(int i = 0; i < MAX_MODCOLORS; i++) { TCHAR sKeyName[16]; @@ -509,13 +511,14 @@ void COptionsColors::OnSaveColorScheme() //-------------------------------------- { - FileDlgResult files = CTrackApp::ShowOpenSaveFileDialog(false, "mptcolor", "", - "OpenMPT Color Schemes|*.mptcolor||", - theApp.GetConfigPath()); - if(files.abort) - return; + FileDialog dlg = SaveFileDialog() + .DefaultExtension("mptcolor") + .ExtensionFilter("OpenMPT Color Schemes|*.mptcolor||") + .WorkingDirectory(theApp.GetConfigPath()); + if(!dlg.Show()) return; + { - IniFileSettingsContainer file(mpt::PathString::FromLocale(files.first_file)); + IniFileSettingsContainer file(mpt::PathString::FromLocale(dlg.GetFirstFile())); for(int i = 0; i < MAX_MODCOLORS; i++) { TCHAR sKeyName[16]; @@ -657,19 +660,12 @@ //--------------------------------------------- { CHAR szPath[_MAX_PATH] = ""; - BROWSEINFO bi; + GetDlgItemText(nID, szPath, CountOf(szPath)); - GetDlgItemText(nID, szPath, CountOf(szPath)); - MemsetZero(bi); - bi.hwndOwner = m_hWnd; - bi.lpszTitle = "Select a default folder..."; - bi.pszDisplayName = szPath; - bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_USENEWUI; - LPITEMIDLIST pid = SHBrowseForFolder(&bi); - if (pid != NULL) + ::BrowseForFolder dlg(szPath, "Select a default folder..."); + if(dlg.Show()) { - SHGetPathFromIDList(pid, szPath); - SetDlgItemText(nID, szPath); + SetDlgItemText(nID, dlg.GetDirectory().c_str()); OnSettingsChanged(); } } Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2013-11-07 20:47:49 UTC (rev 3114) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2013-11-07 21:22:42 UTC (rev 3115) @@ -27,6 +27,7 @@ #include "ExceptionHandler.h" #include "CloseMainDialog.h" #include "AutoSaver.h" +#include "FileDialog.h" // rewbs.memLeak #define _CRTDBG_MAP_ALLOC @@ -624,10 +625,6 @@ ON_COMMAND(ID_FILE_OPEN, OnFileOpen) ON_COMMAND(ID_FILE_CLOSEALL, OnFileCloseAll) ON_COMMAND(ID_APP_ABOUT, OnAppAbout) - ON_COMMAND(ID_HELP_INDEX, CWinApp::OnHelpIndex) - ON_COMMAND(ID_HELP_FINDER, CWinApp::OnHelpFinder) - ON_COMMAND(ID_HELP_USING, CWinApp::OnHelpUsing) - ON_COMMAND(ID_HELP_SEARCH, OnHelpSearch) //}}AFX_MSG_MAP END_MESSAGE_MAP() @@ -1107,41 +1104,42 @@ } static int nFilterIndex = 0; - FileDlgResult files = ShowOpenSaveFileDialog(true, "", "", - "All Modules|" + exts + - "|" - "Compressed Modules (*.mdz;*.s3z;*.xmz;*.itz" -#ifndef NO_MO3 - ";*.mo3" -#endif - ")|*.mdz;*.s3z;*.xmz;*.itz;*.mdr;*.zip;*.rar;*.lha;*.pma;*.lzs;*.gz" -#ifndef NO_MO3 - ";*.mo3" -#endif - "|" - "ProTracker Modules (*.mod,*.nst)|*.mod;mod.*;*.mdz;*.nst;*.m15|" - "ScreamTracker Modules (*.s3m,*.stm)|*.s3m;*.stm;*.s3z|" - "FastTracker Modules (*.xm)|*.xm;*.xmz|" - "Impulse Tracker Modules (*.it)|*.it;*.itz|" - // -> CODE#0023 - // -> DESC="IT project files (.itp)" - "Impulse Tracker Projects (*.itp)|*.itp;*.itpz|" - // -! NEW_FEATURE#0023 - "OpenMPT Modules (*.mptm)|*.mptm;*.mptmz|" - "Other Modules (mtm,okt,mdl,669,far,...)|*.mtm;*.669;*.ult;*.wow;*.far;*.mdl;*.okt;*.dmf;*.ptm;*.med;*.ams;*.dbm;*.digi;*.dsm;*.umx;*.amf;*.psm;*.mt2;*.gdm;*.imf;*.j2b|" - "Wave Files (*.wav)|*.wav|" - "Midi Files (*.mid,*.rmi)|*.mid;*.rmi;*.smf|" - "All Files (*.*)|*.*||", - TrackerSettings::Instance().GetWorkingDirectory(DIR_MODS), - true, - &nFilterIndex); - if(files.abort) return; + FileDialog dlg = OpenFileDialog() + .AllowMultiSelect() + .ExtensionFilter("All Modules|" + exts + + "|" + "Compressed Modules (*.mdz;*.s3z;*.xmz;*.itz" + #ifndef NO_MO3 + ";*.mo3" + #endif + ")|*.mdz;*.s3z;*.xmz;*.itz;*.mdr;*.zip;*.rar;*.lha;*.pma;*.lzs;*.gz" + #ifndef NO_MO3 + ";*.mo3" + #endif + "|" + "ProTracker Modules (*.mod,*.nst)|*.mod;mod.*;*.mdz;*.nst;*.m15|" + "ScreamTracker Modules (*.s3m,*.stm)|*.s3m;*.stm;*.s3z|" + "FastTracker Modules (*.xm)|*.xm;*.xmz|" + "Impulse Tracker Modules (*.it)|*.it;*.itz|" + // -> CODE#0023 + // -> DESC="IT project files (.itp)" + "Impulse Tracker Projects (*.itp)|*.itp;*.itpz|" + // -! NEW_FEATURE#0023 + "OpenMPT Modules (*.mptm)|*.mptm;*.mptmz|" + "Other Modules (mtm,okt,mdl,669,far,...)|*.mtm;*.669;*.ult;*.wow;*.far;*.mdl;*.okt;*.dmf;*.ptm;*.med;*.ams;*.dbm;*.digi;*.dsm;*.umx;*.amf;*.psm;*.mt2;*.gdm;*.imf;*.j2b|" + "Wave Files (*.wav)|*.wav|" + "Midi Files (*.mid,*.rmi)|*.mid;*.rmi;*.smf|" + "All Files (*.*)|*.*||") + .WorkingDirectory(TrackerSettings::Instance().GetWorkingDirectory(DIR_MODS)) + .FilterIndex(&nFilterIndex); + if(!dlg.Show()) return; - TrackerSettings::Instance().SetWorkingDirectory(files.workingDirectory.c_str(), DIR_MODS, true); + TrackerSettings::Instance().SetWorkingDirectory(dlg.GetWorkingDirectory().c_str(), DIR_MODS, true); - for(size_t counter = 0; counter < files.filenames.size(); counter++) + const FileDialog::PathList &files = dlg.GetFilenames(); + for(size_t counter = 0; counter < files.size(); counter++) { - OpenDocumentFile(files.filenames[counter].c_str()); + OpenDocumentFile(files[counter].c_str()); } } @@ -1175,13 +1173,6 @@ } -void CTrackApp::OnHelpSearch() -//---------------------------- -{ - CHAR s[80] = ""; - WinHelp((DWORD)&s, HELP_KEY); -} - ///////////////////////////////////////////////////////////////////////////// // CAboutDlg dialog used for App About @@ -2054,95 +2045,6 @@ } -/* Open or save one or multiple files using the system's file dialog - * Parameter list: - * - load: true: load dialog. false: save dialog. - * - defaultExtension: dialog should use this as the default extension for the file(s) - * - defaultFilename: dialog should use this as the default filename - * - extFilter: list of possible extensions. format: "description|extensions|...|description|extensions||" - * - workingDirectory: default directory of the dialog - * - allowMultiSelect: allow the user to select multiple files? (will be ignored if load == false) - * - filterIndex: pointer to a variable holding the index of the last extension filter used. - */ -FileDlgResult CTrackApp::ShowOpenSaveFileDialog(const bool load, const std::string defaultExtension, const std::string defaultFilename, const std::string extFilter, const std::string workingDirectory, const bool allowMultiSelect, int *filterIndex) -//----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -{ - FileDlgResult result; - result.workingDirectory = workingDirectory; - result.first_file = ""; - result.filenames.clear(); - result.extension = defaultExtension; - result.abort = true; - - // we can't save multiple files. - const bool multiSelect = allowMultiSelect && load; - - // First, set up the dialog... - CFileDialog dlg(load ? TRUE : FALSE, - defaultExtension.empty() ? NULL : defaultExtension.c_str(), - defaultFilename.empty() ? NULL : defaultFilename.c_str(), - load ? (OFN_HIDEREADONLY | OFN_ENABLESIZING | OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | (multiSelect ? OFN_ALLOWMULTISELECT : 0)) - : (OFN_HIDEREADONLY | OFN_ENABLESIZING | OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST | OFN_NOREADONLYRETURN), - extFilter.empty() ? NULL : extFilter.c_str(), - theApp.m_pMainWnd); - if(!workingDirectory.empty()) - dlg.m_ofn.lpstrInitialDir = workingDirectory.c_str(); - if(filterIndex != nullptr) - dlg.m_ofn.nFilterIndex = (DWORD)(*filterIndex); - - std::vector<TCHAR> filenameBuffer; - if(multiSelect) - { - const size_t bufferSize = 2048; // Note: This is possibly the maximum buffer size in MFC 7(this note was written November 2006). - filenameBuffer.resize(bufferSize, 0); - dlg.GetOFN().lpstrFile = &filenameBuffer[0]; - dlg.GetOFN().nMaxFile = bufferSize; - } - - // Do it! - CMainFrame::GetInputHandler()->Bypass(true); - bool doCancel = dlg.DoModal() != IDOK; - CMainFrame::GetInputHandler()->Bypass(false); - if(doCancel) - { - return result; - } - - // Retrieve variables - if(filterIndex != nullptr) - *filterIndex = dlg.m_ofn.nFilterIndex; - - if(multiSelect) - { - // multiple files might have been selected - POSITION pos = dlg.GetStartPosition(); - while(pos != NULL) - { - std::string filename = dlg.GetNextPathName(pos); - result.filenames.push_back(filename); - } - - } else - { - // only one file - std::string filename = dlg.GetPathName(); - result.filenames.push_back(filename); - } - - if(!result.filenames.empty()) - { - // some file has been selected. - result.workingDirectory = result.filenames.back(); - result.first_file = result.filenames.front(); - result.abort = false; - } - - result.extension = dlg.GetFileExt(); - - return result; -} - - // Convert an absolute path to a path that's relative to OpenMPT's directory. // Paths are relative to the executable path. // nLength specifies the maximum number of character that can be written into szPath, Modified: trunk/OpenMPT/mptrack/Mptrack.h =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.h 2013-11-07 20:47:49 UTC (rev 3114) +++ trunk/OpenMPT/mptrack/Mptrack.h 2013-11-07 21:22:42 UTC (rev 3115) @@ -70,18 +70,6 @@ ///////////////////////////////////////////////////////////////////////////// -// File dialog (open/save) results -struct FileDlgResult -{ - std::string workingDirectory; // working directory. will include filename, so beware. - std::string first_file; // for some convenience, this will keep the first filename of the filenames vector. - std::vector <std::string> filenames; // all selected filenames in one vector. - std::string extension; // extension used. beware of this when multiple files can be selected! - bool abort; // no selection has been made. -}; - - -///////////////////////////////////////////////////////////////////////////// // CTrackApp: // See mptrack.cpp for the implementation of this class // @@ -158,8 +146,6 @@ static bool OpenFile(const LPCSTR file) { return OpenURL(file); }; static bool OpenDirectory(const LPCSTR directory) { return OpenURL(directory); }; - static FileDlgResult ShowOpenSaveFileDialog(const bool load, const std::string defaultExtension, const std::string defaultFilename, const std::string extFilter, const std::string workingDirectory = "", const bool allowMultiSelect = false, int *filterIndex = nullptr); - int GetOpenDocumentCount() const; std::vector<CModDoc *>GetOpenDocuments() const; @@ -232,7 +218,6 @@ afx_msg void OnFileOpen(); afx_msg void OnAppAbout(); - afx_msg void OnHelpSearch(); afx_msg void OnFileCloseAll(); //}}AFX_MSG Modified: trunk/OpenMPT/mptrack/SelectPluginDialog.cpp =================================================================== --- trunk/OpenMPT/mptrack/SelectPluginDialog.cpp 2013-11-07 20:47:49 UTC (rev 3114) +++ trunk/OpenMPT/mptrack/SelectPluginDialog.cpp 2013-11-07 21:22:42 UTC (rev 3115) @@ -15,6 +15,7 @@ #include "Moddoc.h" #include "SelectPluginDialog.h" #include "../common/StringFixer.h" +#include "FileDialog.h" #ifndef NO_VST @@ -453,22 +454,24 @@ void CSelectPluginDlg::OnAddPlugin() //---------------------------------- { - FileDlgResult files = CTrackApp::ShowOpenSaveFileDialog(true, "dll", "", - "VST Plugins (*.dll)|*.dll||", - TrackerSettings::Instance().GetWorkingDirectory(DIR_PLUGINS), - true); - if(files.abort) return; + FileDialog dlg = OpenFileDialog() + .AllowMultiSelect() + .DefaultExtension("dll") + .ExtensionFilter("VST Plugins (*.dll)|*.dll||") + .WorkingDirectory(TrackerSettings::Instance().GetWorkingDirectory(DIR_PLUGINS)); + if(!dlg.Show()) return; - TrackerSettings::Instance().SetWorkingDirectory(files.workingDirectory.c_str(), DIR_PLUGINS, true); + TrackerSettings::Instance().SetWorkingDirectory(dlg.GetWorkingDirectory().c_str(), DIR_PLUGINS, true); CVstPluginManager *pManager = theApp.GetPluginManager(); bool bOk = false; VSTPluginLib *plugLib = nullptr; - for(size_t counter = 0; counter < files.filenames.size(); counter++) + const FileDialog::PathList &files = dlg.GetFilenames(); + for(size_t counter = 0; counter < files.size(); counter++) { - CString sFilename = files.filenames[counter].c_str(); + CString sFilename = files[counter].c_str(); if (pManager) { Modified: trunk/OpenMPT/mptrack/TrackerSettings.cpp =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.cpp 2013-11-07 20:47:49 UTC (rev 3114) +++ trunk/OpenMPT/mptrack/TrackerSettings.cpp 2013-11-07 21:22:42 UTC (rev 3115) @@ -783,7 +783,7 @@ void TrackerSettings::SetWorkingDirectory(const LPCTSTR szFilenameFrom, Directory dir, bool bStripFilename) //--------------------------------------------------------------------------------------------------------- { - TrackerDirectories::Instance().SetDefaultDirectory(szFilenameFrom, dir, bStripFilename); + TrackerDirectories::Instance().SetWorkingDirectory(szFilenameFrom, dir, bStripFilename); } Modified: trunk/OpenMPT/mptrack/TuningDialog.cpp =================================================================== --- trunk/OpenMPT/mptrack/TuningDialog.cpp 2013-11-07 20:47:49 UTC (rev 3114) +++ trunk/OpenMPT/mptrack/TuningDialog.cpp 2013-11-07 21:22:42 UTC (rev 3115) @@ -16,6 +16,7 @@ #include "../common/mptFstream.h" #include "../common/misc_util.h" #include "tuningdialog.h" +#include "FileDialog.h" const CTuningDialog::TUNINGTREEITEM CTuningDialog::s_notFoundItemTuning = TUNINGTREEITEM(); const HTREEITEM CTuningDialog::s_notFoundItemTree = NULL; @@ -630,27 +631,29 @@ if(pTC != NULL) filter += std::string("Tuning collection files (") + CTuningCollection::s_FileExtension + std::string(")|*") + CTuningCollection::s_FileExtension + std::string("|"); - FileDlgResult files = CTrackApp::ShowOpenSaveFileDialog(false, CTuning::s_FileExtension, "", - filter, - TrackerSettings::Instance().GetWorkingDirectory(DIR_TUNING)); - if(files.abort) return; + int filterIndex = 0; + FileDialog dlg = SaveFileDialog() + .DefaultExtension(CTuning::s_FileExtension) + .ExtensionFilter(filter) + .WorkingDirectory(TrackerSettings::Instance().GetWorkingDirectory(DIR_TUNING)) + .FilterIndex(&filterIndex); + if(!dlg.Show()) return; BeginWaitCursor(); bool failure = true; - mpt::ofstream fout(files.first_file.c_str(), std::ios::binary); - const std::string ext = "." + files.extension; + mpt::ofstream fout(dlg.GetFirstFile().c_str(), std::ios::binary); - if(ext == CTuning::s_FileExtension) + if(filterIndex == 0) { if(pT != NULL) failure = pT->Serialize(fout); + } else //Case: Saving tuning collection. + { + if(pTC != NULL) + failure = pTC->Serialize(fout); } - else //Case: Saving tuning collection. - if(ext == CTuningCollection::s_FileExtension) - if(pTC != NULL) - failure = pTC->Serialize(fout); fout.close(); EndWaitCursor(); @@ -664,29 +667,29 @@ void CTuningDialog::OnBnClickedButtonImport() //------------------------------------------- { - CString sFilter; - sFilter.Format(TEXT("Tuning files (*%s, *%s, *.scl)|*%s;*%s;*.scl|"), - CTuning::s_FileExtension, - CTuningCollection::s_FileExtension, - CTuning::s_FileExtension, - CTuningCollection::s_FileExtension); + std::string sFilter = mpt::String::Format(TEXT("Tuning files (*%s, *%s, *.scl)|*%s;*%s;*.scl|"), + CTuning::s_FileExtension, + CTuningCollection::s_FileExtension, + CTuning::s_FileExtension, + CTuningCollection::s_FileExtension); - FileDlgResult files = CTrackApp::ShowOpenSaveFileDialog(true, TEXT(""), TEXT(""), - (LPCTSTR)sFilter, - TrackerSettings::Instance().GetWorkingDirectory(DIR_TUNING), - true); - if(files.abort) + FileDialog dlg = OpenFileDialog() + .AllowMultiSelect() + .ExtensionFilter(sFilter) + .WorkingDirectory(TrackerSettings::Instance().GetWorkingDirectory(DIR_TUNING)); + if(!dlg.Show()) return; - TrackerSettings::Instance().SetWorkingDirectory(files.workingDirectory.c_str(), DIR_TUNING, true); + TrackerSettings::Instance().SetWorkingDirectory(dlg.GetWorkingDirectory().c_str(), DIR_TUNING, true); CString sLoadReport; - const size_t nFiles = files.filenames.size(); + 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.filenames[counter].c_str(), nullptr, nullptr, szFileName, szExt); + _tsplitpath(files[counter].c_str(), nullptr, nullptr, szFileName, szExt); _tcslwr(szExt); // Convert extension to lower case. @@ -699,7 +702,7 @@ if (bIsTun) { - mpt::ifstream fin(files.filenames[counter].c_str(), std::ios::binary); + mpt::ifstream fin(files[counter].c_str(), std::ios::binary); pT = CTuningRTI::DeserializeOLD(fin); if(pT == 0) {fin.clear(); fin.seekg(0); pT = CTuningRTI::Deserialize(fin);} @@ -733,7 +736,7 @@ } else // scl import. { - EnSclImport a = ImportScl(files.filenames[counter].c_str(), szFileName); + EnSclImport a = ImportScl(files[counter].c_str(), szFileName); if (a != enSclImportOk) { if (a == enSclImportAddTuningFailure && m_TempTunings.GetNumTunings() >= CTuningCollection::s_nMaxTuningCount) @@ -767,7 +770,7 @@ // a separate collection - no possibility to // directly replace some collection. CTuningCollection* pNewTCol = new CTuningCollection; - pNewTCol->SetSavefilePath(files.filenames[counter]); + pNewTCol->SetSavefilePath(files[counter]); if (pNewTCol->Deserialize()) { delete pNewTCol; pNewTCol = 0; Modified: trunk/OpenMPT/mptrack/View_tre.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_tre.cpp 2013-11-07 20:47:49 UTC (rev 3114) +++ trunk/OpenMPT/mptrack/View_tre.cpp 2013-11-07 21:22:42 UTC (rev 3115) @@ -19,6 +19,7 @@ #include "vstplug.h" #include "MemoryMappedFile.h" #include "../soundlib/FileReader.h" +#include "FileDialog.h" CSoundFile *CModTree::m_SongFile = nullptr; @@ -1501,27 +1502,28 @@ BOOL CModTree::OpenMidiInstrument(DWORD dwItem) //--------------------------------------------- { - FileDlgResult files = CTrackApp::ShowOpenSaveFileDialog(true, "", "", - "All Instruments and Banks|*.xi;*.pat;*.iti;*.wav;*.aif;*.aiff;*.sf2;*.sbk;*.dls;*.flac;*.mp1;*.mp2;*.mp3|" - "FastTracker II Instruments (*.xi)|*.xi|" - "GF1 Patches (*.pat)|*.pat|" - "Wave Files (*.wav)|*.wav|" -#ifndef NO_FLAC - "FLAC Files (*.flac)|*.flac|" -#endif // NO_FLAC -#ifndef NO_MP3_SAMPLES - "MPEG Files (*.mp1,*.mp2,*.mp3)|*.mp1;*.mp2;*.mp3|" -#endif // NO_MP3_SAMPLES - "Impulse Tracker Instruments (*.iti)|*.iti;*.its|" - "SoundFont 2.0 Banks (*.sf2)|*.sf2;*.sbk|" - "DLS Sound Banks (*.dls)|*.dls|" - "All Files (*.*)|*.*||"); - if(files.abort) return FALSE; + FileDialog dlg = OpenFileDialog() + .ExtensionFilter( + "All Instruments and Banks|*.xi;*.pat;*.iti;*.wav;*.aif;*.aiff;*.sf2;*.sbk;*.dls;*.flac;*.mp1;*.mp2;*.mp3|" + "FastTracker II Instruments (*.xi)|*.xi|" + "GF1 Patches (*.pat)|*.pat|" + "Wave Files (*.wav)|*.wav|" + #ifndef NO_FLAC + "FLAC Files (*.flac)|*.flac|" + #endif // NO_FLAC + #ifndef NO_MP3_SAMPLES + "MPEG Files (*.mp1,*.mp2,*.mp3)|*.mp1;*.mp2;*.mp3|" + #endif // NO_MP3_SAMPLES + "Impulse Tracker Instruments (*.iti)|*.iti;*.its|" + "SoundFont 2.0 Banks (*.sf2)|*.sf2;*.sbk|" + "DLS Sound Banks (*.dls)|*.dls|" + "All Files (*.*)|*.*||"); + if(!dlg.Show()) return FALSE; if (dwItem & 0x80) - return SetMidiPercussion(dwItem & 0x7F, files.first_file.c_str()); + return SetMidiPercussion(dwItem & 0x7F, dlg.GetFirstFile().c_str()); else - return SetMidiInstrument(dwItem, files.first_file.c_str()); + return SetMidiInstrument(dwItem, dlg.GetFirstFile().c_str()); } @@ -3083,12 +3085,11 @@ if(pSndFile && modItem.val1) { + FileDialog dlg = OpenFileDialog() + .ExtensionFilter("All files(*.*)|*.*||"); + if(!dlg.Show()) return; - FileDlgResult files = CTrackApp::ShowOpenSaveFileDialog(true, "", "", - "All files(*.*)|*.*||"); - if(files.abort) return; - - pSndFile->m_szInstrumentPath[modItem.val1 - 1] = files.first_file; + pSndFile->m_szInstrumentPath[modItem.val1 - 1] = dlg.GetFirstFile(); OnRefreshTree(); } } @@ -3107,15 +3108,16 @@ if(pSndFile->m_szInstrumentPath[modItem.val1 - 1].empty()) { - FileDlgResult files = CTrackApp::ShowOpenSaveFileDialog(false, (pSndFile->GetType() == MOD_TYPE_XM) ? "xi" : "iti", "", - (pSndFile->GetType() == MOD_TYPE_XM) ? + FileDialog dlg = SaveFileDialog() + .DefaultExtension(pSndFile->GetType() == MOD_TYPE_XM ? "xi" : "iti") + .ExtensionFilter((pSndFile->GetType() == MOD_TYPE_XM) ? "FastTracker II Instruments (*.xi)|*.xi|" - "Impulse Tracker Instruments (*.iti)|*.iti||" : - "Impulse Tracker Instruments (*.iti)|*.iti|" + "Impulse Tracker Instruments (*.iti)|*.iti||" + : "Impulse Tracker Instruments (*.iti)|*.iti|" "FastTracker II Instruments (*.xi)|*.xi||"); - if(files.abort) return; + if(!dlg.Show()) return; - pSndFile->m_szInstrumentPath[modItem.val1 - 1] = files.first_file; + pSndFile->m_szInstrumentPath[modItem.val1 - 1] = dlg.GetFirstFile(); } pModDoc->SaveInstrument(static_cast<INSTRUMENTINDEX>(modItem.val1)); @@ -3146,12 +3148,14 @@ void CModTree::OnExportMidiLib() //------------------------------ { - FileDlgResult files = CTrackApp::ShowOpenSaveFileDialog(false, "ini", "mptrack.ini", - "Text and INI files (*.txt,*.ini)|*.txt;*.ini|" - "All Files (*.*)|*.*||"); - if(files.abort) return; + FileDialog dlg = SaveFileDialog() + .DefaultExtension("ini") + .DefaultFilename("mptrack.ini") + .ExtensionFilter("Text and INI files (*.txt,*.ini)|*.txt;*.ini|" + "All Files (*.*)|*.*||"); + if(!dlg.Show()) return; - CTrackApp::ExportMidiConfig(files.first_file.c_str()); + CTrackApp::ExportMidiConfig(dlg.GetFirstFile().c_str()); } Modified: trunk/OpenMPT/mptrack/Vstplug.cpp =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.cpp 2013-11-07 20:47:49 UTC (rev 3114) +++ trunk/OpenMPT/mptrack/Vstplug.cpp 2013-11-07 21:22:42 UTC (rev 3115) @@ -28,6 +28,7 @@ #include "MemoryMappedFile.h" #include "../soundlib/FileReader.h" #include "../soundlib/plugins/JBridge.h" +#include "FileDialog.h" #include "../common/mptFstream.h" #ifdef VST_USE_ALTERNATIVE_MAGIC //Pelya's plugin ID fix. Breaks fx presets, so let's avoid it for now. #include "../zlib/zlib.h" //For CRC32 calculation (to detect plugins with same UID) @@ -1099,6 +1100,7 @@ #endif extensions += "|"; } + extensions += "|"; if(fileSel->initialPath != nullptr) { @@ -1106,29 +1108,34 @@ } else { // Plugins are probably looking for presets...? - workingDir = ""; //TrackerSettings::Instance().GetWorkingDirectory(DIR_PLUGINPRESETS); + //workingDir = TrackerSettings::Instance().GetWorkingDirectory(DIR_PLUGINPRESETS); } - FileDlgResult files = CTrackApp::ShowOpenSaveFileDialog( - (fileSel->command != kVstFileSave), - "", "", extensions, workingDir, - (fileSel->command == kVstMultipleFilesLoad) - ); - - if(files.abort) + FileDialog dlg = OpenFileDialog(); + if(fileSel->command == kVstFileSave) { + dlg = SaveFileDialog(); + } else if(fileSel->command == kVstMultipleFilesLoad) + { + dlg = OpenFileDialog().AllowMultiSelect(); + } + dlg.ExtensionFilter(extensions) + .WorkingDirectory(workingDir); + if(!dlg.Show()) + { return 0; } if(fileSel->command == kVstMultipleFilesLoad) { // Multiple paths - fileSel->nbReturnPath = files.filenames.size(); + const FileDialog::PathList &files = dlg.GetFilenames(); + fileSel->nbReturnPath = files.size(); fileSel->returnMultiplePaths = new char *[fileSel->nbReturnPath]; - for(size_t i = 0; i < files.filenames.size(); i++) + for(size_t i = 0; i < files.size(); i++) { - char *fname = new char[files.filenames[i].length() + 1]; - strcpy(fname, files.filenames[i].c_str()); + char *fname = new char[files[i].length() + 1]; + strcpy(fname, files[i].c_str()); fileSel->returnMultiplePaths[i] = fname; } return 1; @@ -1146,7 +1153,7 @@ { // Provide some memory for the return path. - fileSel->sizeReturnPath = files.first_file.length() + 1; + fileSel->sizeReturnPath = dlg.GetFirstFile().length() + 1; fileSel->returnPath = new char[fileSel->sizeReturnPath]; if(fileSel->returnPath == nullptr) { @@ -1158,7 +1165,7 @@ { fileSel->reserved = 0; } - strncpy(fileSel->returnPath, files.first_file.c_str(), fileSel->sizeReturnPath - 1); + strncpy(fileSel->returnPath, dlg.GetFirstFile().c_str(), fileSel->sizeReturnPath - 1); fileSel->nbReturnPath = 1; fileSel->returnMultiplePaths = nullptr; } @@ -1167,37 +1174,22 @@ } else { // Plugin wants a directory - - char szInitPath[_MAX_PATH] = { '\0' }; - if(fileSel->initialPath) + BrowseForFolder dlg(fileSel->initialPath != nullptr ? fileSel->initialPath : "", fileSel->title); + if(dlg.Show()) { - mpt::String::CopyN(szInitPath, fileSel->initialPath); - } - - char szBuffer[_MAX_PATH]; - MemsetZero(szBuffer); - - BROWSEINFO bi; - MemsetZero(bi); - bi.hwndOwner = CMainFrame::GetMainFrame()->m_hWnd; - bi.lpszTitle = fileSel->title; - bi.pszDisplayName = szInitPath; - bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_USENEWUI; - LPITEMIDLIST pid = SHBrowseForFolder(&bi); - if(pid != nullptr && SHGetPathFromIDList(pid, szBuffer)) - { + const std::string &dir = dlg.GetDirectory(); if(CCONST('V', 'S', 'T', 'r') == effect->uniqueID && fileSel->returnPath != nullptr && fileSel->sizeReturnPath == 0) { // old versions of reViSiT (which still relied on the host's file selection code) seem to be dodgy. // They report a path size of 0, but when using an own buffer, they will crash. // So we'll just assume that reViSiT can handle long enough (_MAX_PATH) paths here. - fileSel->sizeReturnPath = strlen(szBuffer) + 1; + fileSel->sizeReturnPath = dir.length() + 1; fileSel->returnPath[fileSel->sizeReturnPath - 1] = '\0'; } if(fileSel->returnPath == nullptr || fileSel->sizeReturnPath == 0) { // Provide some memory for the return path. - fileSel->sizeReturnPath = strlen(szBuffer) + 1; + fileSel->sizeReturnPath = dir.length() + 1; fileSel->returnPath = new char[fileSel->sizeReturnPath]; if(fileSel->returnPath == nullptr) { @@ -1209,7 +1201,7 @@ { fileSel->reserved = 0; } - strncpy(fileSel->returnPath, szBuffer, fileSel->sizeReturnPath - 1); + strncpy(fileSel->returnPath, dir.c_str(), fileSel->sizeReturnPath - 1); fileSel->nbReturnPath = 1; return 1; } else @@ -1609,20 +1601,23 @@ Dispatch(effGetProgramName, 0, 0, rawname, 0); SanitizeFilename(rawname); mpt::String::SetNullTerminator(rawname); - FileDlgResult files = CTrackApp::ShowOpenSaveFileDialog(false, "fxp", rawname, - "VST Plugin Programs (*.fxp)|*.fxp|" - "VST Plugin Banks (*.fxb)|*.fxb||", - defaultDir); - if(files.abort) return false; + FileDialog dlg = SaveFileDialog() + .DefaultExtension("fxp") + .DefaultFilename(rawname) + .ExtensionFilter("VST Plugin Programs (*.fxp)|*.fxp|" + "VST Plugin Banks (*.fxb)|*.fxb||") + .WorkingDirectory(defaultDir); + if(!dlg.Show()) return false; + if(useDefaultDir) { - TrackerSettings::Instance().SetWorkingDirectory(files.workingDirectory.c_str(), DIR_PLUGINPRESETS, true); + TrackerSettings::Instance().SetWorkingDirectory(dlg.GetWorkingDirectory().c_str(), DIR_PLUGINPRESETS, true); } - bool bank = !mpt::strnicmp(files.first_file.substr(files.first_file.length() - 3).c_str(), "fxb", 3); + bool bank = (dlg.GetExtension() == "fxb"); - mpt::fstream f(files.first_file.c_str(), std::ios::out | std::ios::trunc | std::ios::binary); + mpt::fstream f(dlg.GetFirstFile().c_str(), std::ios::out | std::ios::trunc | std::ios::binary); if(f.good() && VSTPresets::SaveFile(f, *this, bank)) { return true; @@ -1646,22 +1641,23 @@ defaultDir = defaultDir.substr(0, defaultDir.find_last_of("\\/")); } - FileDlgResult files = CTrackApp::ShowOpenSaveFileDialog(true, "fxp", "", - "VST Plugin Programs and Banks (*.fxp,*.fxb)|*.fxp;*.fxb|" + FileDialog dlg = OpenFileDialog() + .DefaultExtension("fxp") + .ExtensionFilter("VST Plugin Programs and Banks (*.fxp,*.fxb)|*.fxp;*.fxb|" "VST Plugin Programs (*.fxp)|*.fxp|" "VST Plugin Banks (*.fxb)|*.fxb|" - "All Files|*.*||", - defaultDir); - if(files.abort) return false; + "All Files|*.*||") + .WorkingDirectory(defaultDir); + if(!dlg.Show()) return false; if(useDefaultDir) { - TrackerSettings::Instance().SetWorkingDirectory(files.workingDirectory.c_str(), DIR_PLUGINPRESETS, true); + TrackerSettings::Instance().SetWorkingDirectory(dlg.GetWorkingDirectory().c_str(), DIR_PLUGINPRESETS, true); } CMappedFile f; const char *errorStr = nullptr; - if(f.Open(files.first_file.c_str())) + if(f.Open(dlg.GetFirstFile().c_str())) { FileReader file = f.GetFile(); errorStr = VSTPresets::GetErrorMessage(VSTPresets::LoadFile(file, *this)); Modified: trunk/OpenMPT/mptrack/mptrack_08.vcproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_08.vcproj 2013-11-07 20:47:49 UTC (rev 3114) +++ trunk/OpenMPT/mptrack/mptrack_08.vcproj 2013-11-07 21:22:42 UTC (rev 3115) @@ -323,6 +323,10 @@ > </File> <File + RelativePath=".\FileDialog.cpp" + > + </File> + <File RelativePath=".\globals.cpp" > </File> @@ -941,6 +945,10 @@ > </File> <File + RelativePath=".\FileDialog.h" + > + </File> + <File RelativePath=".\globals.h" > </File> Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj =========================... [truncated message content] |
From: <man...@us...> - 2013-11-08 00:41:52
|
Revision: 3118 http://sourceforge.net/p/modplug/code/3118 Author: manxorist Date: 2013-11-08 00:41:45 +0000 (Fri, 08 Nov 2013) Log Message: ----------- [Mod] Mod Export: Default output file sample rate to configured soundcard sample rate. Some plugins cope badly with changing sample rates, so this is a more compatible default. Add a hidden [Export]DefaultToSoundcardSamplerate setting which can be set to false to revert to old, per codec setting, behaviour. Modified Paths: -------------- trunk/OpenMPT/mptrack/Mod2wave.cpp trunk/OpenMPT/mptrack/TrackerSettings.cpp trunk/OpenMPT/mptrack/TrackerSettings.h Modified: trunk/OpenMPT/mptrack/Mod2wave.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mod2wave.cpp 2013-11-07 21:59:14 UTC (rev 3117) +++ trunk/OpenMPT/mptrack/Mod2wave.cpp 2013-11-08 00:41:45 UTC (rev 3118) @@ -339,7 +339,18 @@ { Encoder::Settings &encSettings = m_Settings.GetEncoderSettings(); m_CbnSampleRate.CComboBox::ResetContent(); - int sel = 0; + int sel = -1; + if(TrackerSettings::Instance().ExportDefaultToSoundcardSamplerate) + { + for(std::vector<uint32>::const_iterator it = encTraits->samplerates.begin(); it != encTraits->samplerates.end(); ++it) + { + uint32 samplerate = *it; + if(samplerate == TrackerSettings::Instance().MixerSamplerate) + { + encSettings.Samplerate = samplerate; + } + } + } for(std::vector<uint32>::const_iterator it = encTraits->samplerates.begin(); it != encTraits->samplerates.end(); ++it) { uint32 samplerate = *it; @@ -350,6 +361,10 @@ sel = ndx; } } + if(sel == -1) + { + sel = 0; + } m_CbnSampleRate.SetCurSel(sel); } Modified: trunk/OpenMPT/mptrack/TrackerSettings.cpp =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.cpp 2013-11-07 21:59:14 UTC (rev 3117) +++ trunk/OpenMPT/mptrack/TrackerSettings.cpp 2013-11-08 00:41:45 UTC (rev 3118) @@ -192,6 +192,8 @@ // Sample Editor , m_SampleUndoMaxBufferMB(conf, "Sample Editor", "UndoBufferSize", GetDefaultUndoBufferSize() >> 20) , m_MayNormalizeSamplesOnLoad(conf, "Sample Editor", "MayNormalizeSamplesOnLoad", true) + // Export + , ExportDefaultToSoundcardSamplerate(conf, "Export", "DefaultToSoundcardSamplerate", true) { // Effects #ifndef NO_DSP Modified: trunk/OpenMPT/mptrack/TrackerSettings.h =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.h 2013-11-07 21:59:14 UTC (rev 3117) +++ trunk/OpenMPT/mptrack/TrackerSettings.h 2013-11-08 00:41:45 UTC (rev 3118) @@ -330,6 +330,10 @@ uint32 GetSampleUndoBufferSize() const { return m_SampleUndoMaxBufferMB << 20; } Setting<bool> m_MayNormalizeSamplesOnLoad; + // Export + + Setting<bool> ExportDefaultToSoundcardSamplerate; + // Effects #ifndef NO_REVERB This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2013-11-08 01:01:56
|
Revision: 3119 http://sourceforge.net/p/modplug/code/3119 Author: saga-games Date: 2013-11-08 01:01:41 +0000 (Fri, 08 Nov 2013) Log Message: ----------- [Fix] Export: Set song position after rendering silence, for plugins that might not like it. [Fix] Export: Even when rendering the full module, reset song position properly so that plugins are in sync. [Fix] Save dialog didn't prompt for overwrite. Modified Paths: -------------- trunk/OpenMPT/mptrack/FileDialog.cpp trunk/OpenMPT/mptrack/Mod2wave.cpp trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/mod2wave.h Modified: trunk/OpenMPT/mptrack/FileDialog.cpp =================================================================== --- trunk/OpenMPT/mptrack/FileDialog.cpp 2013-11-08 00:41:45 UTC (rev 3118) +++ trunk/OpenMPT/mptrack/FileDialog.cpp 2013-11-08 01:01:41 UTC (rev 3119) @@ -47,7 +47,7 @@ ofn.nMaxFileTitle = 0; ofn.lpstrInitialDir = workingDirectory.empty() ? NULL : workingDirectory.c_str(); ofn.lpstrTitle = NULL; - ofn.Flags = OFN_EXPLORER | OFN_HIDEREADONLY | OFN_ENABLESIZING | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | (multiSelect ? OFN_ALLOWMULTISELECT : 0) | (load ? 0 : OFN_NOREADONLYRETURN); + ofn.Flags = OFN_EXPLORER | OFN_HIDEREADONLY | OFN_ENABLESIZING | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | (multiSelect ? OFN_ALLOWMULTISELECT : 0) | (load ? 0 : (OFN_OVERWRITEPROMPT | OFN_NOREADONLYRETURN)); ofn.nFileOffset = 0; ofn.nFileExtension = 0; ofn.lpstrDefExt = defaultExtension.empty() ? NULL : defaultExtension.c_str(); Modified: trunk/OpenMPT/mptrack/Mod2wave.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mod2wave.cpp 2013-11-08 00:41:45 UTC (rev 3118) +++ trunk/OpenMPT/mptrack/Mod2wave.cpp 2013-11-08 01:01:41 UTC (rev 3119) @@ -123,28 +123,22 @@ END_MESSAGE_MAP() -CWaveConvert::CWaveConvert(CWnd *parent, ORDERINDEX minOrder, ORDERINDEX maxOrder, ORDERINDEX numOrders, CSoundFile *sndfile, const std::vector<EncoderFactoryBase*> &encFactories) +CWaveConvert::CWaveConvert(CWnd *parent, ORDERINDEX minOrder, ORDERINDEX maxOrder, ORDERINDEX numOrders, CSoundFile &sndFile, const std::vector<EncoderFactoryBase*> &encFactories) //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- : CDialog(IDD_WAVECONVERT, parent) + , m_SndFile(sndFile) , m_Settings(theApp.GetSettings(), encFactories) { ASSERT(!encFactories.empty()); encTraits = m_Settings.GetTraits(); - m_pSndFile = sndfile; m_bGivePlugsIdleTime = false; - m_bHighQuality = false; - m_bSelectPlay = false; if(minOrder != ORDERINDEX_INVALID && maxOrder != ORDERINDEX_INVALID) { // render selection - m_nMinOrder = minOrder; - m_nMaxOrder = maxOrder; - m_bSelectPlay = true; - } else - { - m_nMinOrder = m_nMaxOrder = 0; + m_Settings.minOrder = minOrder; + m_Settings.maxOrder = maxOrder; } - loopCount = 1; + m_Settings.repeatCount = 1; m_nNumOrders = numOrders; m_dwFileLimit = 0; @@ -178,7 +172,6 @@ //------------------------------- { CDialog::OnInitDialog(); - CheckRadioButton(IDC_RADIO1, IDC_RADIO2, m_bSelectPlay ? IDC_RADIO2 : IDC_RADIO1); CheckDlgButton(IDC_CHECK5, MF_UNCHECKED); // Normalize CheckDlgButton(IDC_CHECK3, MF_CHECKED); // Cue points @@ -186,12 +179,17 @@ CheckDlgButton(IDC_CHECK4, MF_UNCHECKED); CheckDlgButton(IDC_CHECK6, MF_UNCHECKED); - SetDlgItemInt(IDC_EDIT3, m_nMinOrder); + const bool selection = (m_Settings.minOrder != ORDERINDEX_INVALID && m_Settings.maxOrder != ORDERINDEX_INVALID); + CheckRadioButton(IDC_RADIO1, IDC_RADIO2, selection ? IDC_RADIO2 : IDC_RADIO1); + if(selection) + { + SetDlgItemInt(IDC_EDIT3, m_Settings.minOrder); + SetDlgItemInt(IDC_EDIT4, m_Settings.maxOrder); + } m_SpinMinOrder.SetRange(0, m_nNumOrders); - SetDlgItemInt(IDC_EDIT4, m_nMaxOrder); m_SpinMaxOrder.SetRange(0, m_nNumOrders); - SetDlgItemInt(IDC_EDIT5, loopCount, FALSE); + SetDlgItemInt(IDC_EDIT5, m_Settings.repeatCount, FALSE); m_SpinLoopCount.SetRange(1, int16_max); FillFileTypes(); @@ -217,7 +215,7 @@ GetDlgItem(IDC_RENDERSILENCE)->EnableWindow(FALSE); for(PLUGINDEX i = 0; i < MAX_MIXPLUGINS; i++) { - if(m_pSndFile->m_MixPlugins[i].pMixPlugin != nullptr) + if(m_SndFile.m_MixPlugins[i].pMixPlugin != nullptr) { GetDlgItem(IDC_GIVEPLUGSIDLETIME)->EnableWindow(TRUE); GetDlgItem(IDC_RENDERSILENCE)->EnableWindow(TRUE); @@ -233,8 +231,8 @@ void CWaveConvert::LoadTags() //--------------------------- { - m_Settings.Tags.title = mpt::String::Decode(m_pSndFile->GetTitle(), mpt::CharsetLocale); - m_Settings.Tags.comments = mpt::String::Decode(m_pSndFile->songMessage, mpt::CharsetLocale); + 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.artist = m_Settings.storedTags.artist; m_Settings.Tags.album = m_Settings.storedTags.album; m_Settings.Tags.trackno = m_Settings.storedTags.trackno; @@ -552,10 +550,15 @@ CheckDlgButton(IDC_CHECK2, (m_dwSongLimit) ? MF_CHECKED : 0); ::EnableWindow(::GetDlgItem(m_hWnd, IDC_EDIT1), (m_dwFileLimit) ? TRUE : FALSE); ::EnableWindow(::GetDlgItem(m_hWnd, IDC_EDIT2), (m_dwSongLimit) ? TRUE : FALSE); + + // Repeat / selection play BOOL bSel = IsDlgButtonChecked(IDC_RADIO2) ? TRUE : FALSE; + /*m_SpinMinOrder.EnableWindow(bSel); + m_SpinMaxOrder.EnableWindow(bSel);*/ GetDlgItem(IDC_EDIT3)->EnableWindow(bSel); GetDlgItem(IDC_EDIT4)->EnableWindow(bSel); GetDlgItem(IDC_EDIT5)->EnableWindow(!bSel); + m_SpinLoopCount.EnableWindow(!bSel); } @@ -621,11 +624,20 @@ { if (m_dwFileLimit) m_dwFileLimit = GetDlgItemInt(IDC_EDIT1, NULL, FALSE); if (m_dwSongLimit) m_dwSongLimit = GetDlgItemInt(IDC_EDIT2, NULL, FALSE); - m_bSelectPlay = IsDlgButtonChecked(IDC_RADIO2) != BST_UNCHECKED; - m_nMinOrder = static_cast<ORDERINDEX>(GetDlgItemInt(IDC_EDIT3, NULL, FALSE)); - m_nMaxOrder = static_cast<ORDERINDEX>(GetDlgItemInt(IDC_EDIT4, NULL, FALSE)); - loopCount = static_cast<uint16>(GetDlgItemInt(IDC_EDIT5, NULL, FALSE)); - if (m_nMaxOrder < m_nMinOrder) m_bSelectPlay = false; + + const bool selection = IsDlgButtonChecked(IDC_RADIO2) != BST_UNCHECKED; + if(selection) + { + // Play selection + m_Settings.minOrder = static_cast<ORDERINDEX>(GetDlgItemInt(IDC_EDIT3, NULL, FALSE)); + m_Settings.maxOrder = static_cast<ORDERINDEX>(GetDlgItemInt(IDC_EDIT4, NULL, FALSE)); + } + if(!selection || m_Settings.maxOrder < m_Settings.minOrder) + { + m_Settings.minOrder = m_Settings.maxOrder = ORDERINDEX_INVALID; + } + + m_Settings.repeatCount = static_cast<uint16>(GetDlgItemInt(IDC_EDIT5, NULL, FALSE)); m_Settings.Normalize = IsDlgButtonChecked(IDC_CHECK5) != BST_UNCHECKED; m_Settings.SilencePlugBuffers = IsDlgButtonChecked(IDC_RENDERSILENCE) != BST_UNCHECKED; m_bGivePlugsIdleTime = IsDlgButtonChecked(IDC_GIVEPLUGSIDLETIME) != BST_UNCHECKED; @@ -681,12 +693,12 @@ m_Settings.Tags.year = std::wstring(); } - if(!m_pSndFile->songMessage.empty()) + if(!m_SndFile.songMessage.empty()) { - m_Settings.Tags.comments = mpt::String::Decode(m_pSndFile->songMessage, mpt::CharsetLocale); + m_Settings.Tags.comments = mpt::String::Decode(m_SndFile.songMessage, mpt::CharsetLocale); } - m_Settings.Tags.bpm = mpt::String::Decode(mpt::String::Format("%d", (int)m_pSndFile->GetCurrentBPM()), mpt::CharsetLocale); + m_Settings.Tags.bpm = mpt::String::Decode(mpt::String::Format("%d", (int)m_SndFile.GetCurrentBPM()), mpt::CharsetLocale); SaveTags(); @@ -795,6 +807,8 @@ , EncoderIndex(FindEncoder(EncoderName)) , FinalSampleFormat(SampleFormatInt16) , storedTags(conf) + , repeatCount(0) + , minOrder(ORDERINDEX_INVALID), maxOrder(ORDERINDEX_INVALID) , Normalize(false) , SilencePlugBuffers(false) { @@ -852,7 +866,7 @@ UINT ok = IDOK, pos = 0; uint64 ullSamples = 0, ullMaxSamples; - if (!m_pSndFile || !m_lpszFileName) + if(!m_lpszFileName) { EndDialog(IDCANCEL); return; @@ -887,14 +901,15 @@ // Silence mix buffer of plugins, for plugins that don't clear their reverb buffers and similar stuff when they are reset if(m_Settings.SilencePlugBuffers) { + SetDlgItemText(IDC_TEXT1, "Clearing plugin buffers"); for(PLUGINDEX i = 0; i < MAX_MIXPLUGINS; i++) { - if(m_pSndFile->m_MixPlugins[i].pMixPlugin != nullptr) + if(m_SndFile.m_MixPlugins[i].pMixPlugin != nullptr) { // Render up to 20 seconds per plugin for(int j = 0; j < 20; j++) { - const float maxVal = m_pSndFile->m_MixPlugins[i].pMixPlugin->RenderSilence(samplerate); + const float maxVal = m_SndFile.m_MixPlugins[i].pMixPlugin->RenderSilence(samplerate); if(maxVal <= FLT_EPSILON) { break; @@ -904,12 +919,12 @@ } } - MixerSettings oldmixersettings = m_pSndFile->m_MixerSettings; + MixerSettings oldmixersettings = m_SndFile.m_MixerSettings; MixerSettings mixersettings = TrackerSettings::Instance().GetMixerSettings(); mixersettings.m_nMaxMixChannels = MAX_CHANNELS; // always use max mixing channels when rendering mixersettings.gdwMixingFreq = samplerate; mixersettings.gnChannels = channels; - m_pSndFile->m_SongFlags.reset(SONG_PAUSED | SONG_STEP); + m_SndFile.m_SongFlags.reset(SONG_PAUSED | SONG_STEP); if(m_Settings.Normalize) { #ifndef NO_AGC @@ -919,10 +934,10 @@ Dither dither; - m_pSndFile->ResetChannels(); - m_pSndFile->SetMixerSettings(mixersettings); - m_pSndFile->SetResamplerSettings(TrackerSettings::Instance().GetResamplerSettings()); - m_pSndFile->InitPlayer(TRUE); + m_SndFile.ResetChannels(); + m_SndFile.SetMixerSettings(mixersettings); + m_SndFile.SetResamplerSettings(TrackerSettings::Instance().GetResamplerSettings()); + m_SndFile.InitPlayer(TRUE); if ((!m_dwFileLimit) || (m_dwFileLimit > 2047*1024)) m_dwFileLimit = 2047*1024; // 2GB m_dwFileLimit <<= 10; @@ -942,14 +957,32 @@ if (l < ullMaxSamples) ullMaxSamples = l; } - // calculate maximum samples + // Calculate maximum samples uint64 max = ullMaxSamples; - uint64 l = static_cast<uint64>(m_pSndFile->GetSongTime() + 0.5) * samplerate * std::max<uint64>(1, 1 + m_pSndFile->GetRepeatCount()); - if (m_nMaxPatterns > 0) + uint64 l = static_cast<uint64>(m_SndFile.GetSongTime() + 0.5) * samplerate * std::max<uint64>(1, 1 + m_SndFile.GetRepeatCount()); + + // Reset song position tracking + m_SndFile.InitializeVisitedRows(); + m_SndFile.SetCurrentPos(0); + m_SndFile.m_SongFlags.reset(SONG_PATTERNLOOP); + ORDERINDEX startOrder = 0; + if(m_Settings.minOrder != ORDERINDEX_INVALID && m_Settings.maxOrder != ORDERINDEX_INVALID) { - ORDERINDEX dwOrds = m_pSndFile->Order.GetLengthFirstEmpty(); - if ((m_nMaxPatterns < dwOrds) && (dwOrds > 0)) l = (l*m_nMaxPatterns) / dwOrds; + startOrder = m_Settings.minOrder; + m_SndFile.m_nMaxOrderPosition = m_Settings.maxOrder + 1; + m_SndFile.SetRepeatCount(0); + + // Weird calculations ahead... + ORDERINDEX dwOrds = m_SndFile.Order.GetLengthFirstEmpty(); + PATTERNINDEX maxPatterns = m_Settings.maxOrder - m_Settings.minOrder + 1; + if((maxPatterns < dwOrds) && (dwOrds > 0)) l = (l * maxPatterns) / dwOrds; + } else + { + m_SndFile.SetRepeatCount(std::max(0, m_Settings.repeatCount - 1)); } + m_SndFile.SetCurrentOrder(startOrder); + m_SndFile.GetLength(eAdjust, GetLengthTarget(startOrder, 0)); // adjust playback variables / visited rows vector + m_SndFile.m_nCurrentOrder = startOrder; if (l < max) max = l; @@ -959,8 +992,8 @@ } // No pattern cue points yet - m_pSndFile->m_PatternCuePoints.clear(); - m_pSndFile->m_PatternCuePoints.reserve(m_pSndFile->Order.GetLength()); + m_SndFile.m_PatternCuePoints.clear(); + m_SndFile.m_PatternCuePoints.reserve(m_SndFile.Order.GetLength()); // Process the conversion @@ -972,22 +1005,22 @@ size_t bytesWritten = 0; CMainFrame::GetMainFrame()->PauseMod(); - m_pSndFile->m_SongFlags.reset(SONG_STEP | SONG_PATTERNLOOP); - CMainFrame::GetMainFrame()->InitRenderer(m_pSndFile); //rewbs.VSTTimeInfo + m_SndFile.m_SongFlags.reset(SONG_STEP | SONG_PATTERNLOOP); + CMainFrame::GetMainFrame()->InitRenderer(&m_SndFile); //rewbs.VSTTimeInfo for (UINT n = 0; ; n++) { UINT lRead = 0; if(m_Settings.Normalize || m_Settings.FinalSampleFormat == SampleFormatFloat32) { - lRead = ReadInterleaved(*m_pSndFile, floatbuffer, MIXBUFFERSIZE, SampleFormatFloat32, dither); + lRead = ReadInterleaved(m_SndFile, floatbuffer, MIXBUFFERSIZE, SampleFormatFloat32, dither); } else { - lRead = ReadInterleaved(*m_pSndFile, buffer, MIXBUFFERSIZE, m_Settings.FinalSampleFormat, dither); + lRead = ReadInterleaved(m_SndFile, buffer, MIXBUFFERSIZE, m_Settings.FinalSampleFormat, dither); } // Process cue points (add base offset), if there are any to process. std::vector<PatternCuePoint>::reverse_iterator iter; - for(iter = m_pSndFile->m_PatternCuePoints.rbegin(); iter != m_pSndFile->m_PatternCuePoints.rend(); ++iter) + for(iter = m_SndFile.m_PatternCuePoints.rbegin(); iter != m_SndFile.m_PatternCuePoints.rend(); ++iter) { if(iter->processed) { @@ -1003,14 +1036,14 @@ Sleep(20); } - if (!lRead) + if (!lRead) break; ullSamples += lRead; if(m_Settings.Normalize) { - std::size_t countSamples = lRead * m_pSndFile->m_MixerSettings.gnChannels; + std::size_t countSamples = lRead * m_SndFile.m_MixerSettings.gnChannels; const float *src = floatbuffer; while(countSamples--) { @@ -1020,7 +1053,7 @@ src++; } - normalizeFile.write(reinterpret_cast<const char*>(floatbuffer), lRead * m_pSndFile->m_MixerSettings.gnChannels * sizeof(float)); + normalizeFile.write(reinterpret_cast<const char*>(floatbuffer), lRead * m_SndFile.m_MixerSettings.gnChannels * sizeof(float)); if(!normalizeFile) break; @@ -1051,7 +1084,7 @@ break; if (!(n % 10)) { - DWORD l = (DWORD)(ullSamples / m_pSndFile->m_MixerSettings.gdwMixingFreq); + DWORD l = (DWORD)(ullSamples / m_SndFile.m_MixerSettings.gdwMixingFreq); const DWORD dwCurrentTime = timeGetTime(); DWORD timeRemaining = 0; // estimated remainig time @@ -1094,9 +1127,9 @@ } } - m_pSndFile->m_nMaxOrderPosition = 0; + m_SndFile.m_nMaxOrderPosition = 0; - CMainFrame::GetMainFrame()->StopRenderer(m_pSndFile); //rewbs.VSTTimeInfo + CMainFrame::GetMainFrame()->StopRenderer(&m_SndFile); if(m_Settings.Normalize) { @@ -1178,19 +1211,19 @@ } - if(m_pSndFile->m_PatternCuePoints.size() > 0) + if(m_SndFile.m_PatternCuePoints.size() > 0) { if(encSettings.Cues) { std::vector<PatternCuePoint>::const_iterator iter; std::vector<uint64> cues; - for(iter = m_pSndFile->m_PatternCuePoints.begin(); iter != m_pSndFile->m_PatternCuePoints.end(); iter++) + for(iter = m_SndFile.m_PatternCuePoints.begin(); iter != m_SndFile.m_PatternCuePoints.end(); iter++) { cues.push_back(static_cast<uint32>(iter->offset)); } fileEnc->WriteCues(cues); } - m_pSndFile->m_PatternCuePoints.clear(); + m_SndFile.m_PatternCuePoints.clear(); } fileEnc->Finalize(); @@ -1200,7 +1233,7 @@ fileStream.flush(); fileStream.close(); - CMainFrame::UpdateAudioParameters(*m_pSndFile, TRUE); + CMainFrame::UpdateAudioParameters(m_SndFile, TRUE); EndDialog(ok); } Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2013-11-08 00:41:45 UTC (rev 3118) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2013-11-08 01:01:41 UTC (rev 3119) @@ -1651,7 +1651,7 @@ if ((!pMainFrm) || (!m_SndFile.GetType()) || encFactories.empty()) return; - CWaveConvert wsdlg(pMainFrm, nMinOrder, nMaxOrder, m_SndFile.Order.GetLengthTailTrimmed() - 1, &m_SndFile, encFactories); + CWaveConvert wsdlg(pMainFrm, nMinOrder, nMaxOrder, m_SndFile.Order.GetLengthTailTrimmed() - 1, m_SndFile, encFactories); if (wsdlg.DoModal() != IDOK) return; EncoderFactoryBase *encFactory = wsdlg.m_Settings.GetEncoderFactory(); @@ -1796,26 +1796,10 @@ thisName += fileExt; // Render song (or current channel, or current sample/instrument) - m_SndFile.InitializeVisitedRows(); - m_SndFile.SetCurrentPos(0); - m_SndFile.m_SongFlags.reset(SONG_PATTERNLOOP); - if(wsdlg.m_bSelectPlay) - { - m_SndFile.SetCurrentOrder(wsdlg.m_nMinOrder); - m_SndFile.GetLength(eAdjust, GetLengthTarget(wsdlg.m_nMinOrder, 0)); // adjust playback variables / visited rows vector - m_SndFile.m_nCurrentOrder = wsdlg.m_nMinOrder; - m_SndFile.m_nMaxOrderPosition = wsdlg.m_nMaxOrder + 1; - m_SndFile.SetRepeatCount(0); - } else - { - m_SndFile.SetRepeatCount(std::max(0, wsdlg.loopCount - 1)); - } - - CDoWaveConvert dwcdlg(&m_SndFile, thisName, wsdlg.m_Settings, pMainFrm); + CDoWaveConvert dwcdlg(m_SndFile, thisName, wsdlg.m_Settings, pMainFrm); dwcdlg.m_dwFileLimit = static_cast<DWORD>(wsdlg.m_dwFileLimit); dwcdlg.m_bGivePlugsIdleTime = wsdlg.m_bGivePlugsIdleTime; dwcdlg.m_dwSongLimit = wsdlg.m_dwSongLimit; - dwcdlg.m_nMaxPatterns = (wsdlg.m_bSelectPlay) ? wsdlg.m_nMaxOrder - wsdlg.m_nMinOrder + 1 : 0; if(dwcdlg.DoModal() != IDOK) break; } Modified: trunk/OpenMPT/mptrack/mod2wave.h =================================================================== --- trunk/OpenMPT/mptrack/mod2wave.h 2013-11-08 00:41:45 UTC (rev 3118) +++ trunk/OpenMPT/mptrack/mod2wave.h 2013-11-08 01:01:41 UTC (rev 3119) @@ -45,6 +45,9 @@ StoredTags storedTags; FileTags Tags; + int repeatCount; + ORDERINDEX minOrder, maxOrder; + bool Normalize; bool SilencePlugBuffers; @@ -56,6 +59,7 @@ CWaveConvertSettings(SettingsContainer &conf, const std::vector<EncoderFactoryBase*> &encFactories); }; + //================================ class CWaveConvert: public CDialog //================================ @@ -63,18 +67,17 @@ public: CWaveConvertSettings m_Settings; const Encoder::Traits *encTraits; - CSoundFile *m_pSndFile; + CSoundFile &m_SndFile; uint64 m_dwFileLimit; DWORD m_dwSongLimit; - bool m_bSelectPlay, m_bHighQuality, m_bGivePlugsIdleTime; - ORDERINDEX m_nMinOrder, m_nMaxOrder, m_nNumOrders; - int loopCount; + ORDERINDEX m_nNumOrders; CComboBox m_CbnFileType, m_CbnSampleRate, m_CbnChannels, m_CbnSampleFormat; CSpinButtonCtrl m_SpinLoopCount, m_SpinMinOrder, m_SpinMaxOrder; + bool m_bGivePlugsIdleTime; bool m_bChannelMode; // Render by channel - bool m_bInstrumentMode; // Render by instrument + bool m_bInstrumentMode; // Render by instrument CEdit m_EditTitle, m_EditAuthor, m_EditURL, m_EditAlbum, m_EditYear; CComboBox m_CbnGenre; @@ -94,7 +97,7 @@ void SaveTags(); public: - CWaveConvert(CWnd *parent, ORDERINDEX minOrder, ORDERINDEX maxOrder, ORDERINDEX numOrders, CSoundFile *sndfile, const std::vector<EncoderFactoryBase*> &encFactories); + CWaveConvert(CWnd *parent, ORDERINDEX minOrder, ORDERINDEX maxOrder, ORDERINDEX numOrders, CSoundFile &sndFile, const std::vector<EncoderFactoryBase*> &encFactories); public: void UpdateDialog(); @@ -120,21 +123,19 @@ { public: const CWaveConvertSettings &m_Settings; - CSoundFile *m_pSndFile; + CSoundFile &m_SndFile; const char *m_lpszFileName; DWORD m_dwFileLimit, m_dwSongLimit; - UINT m_nMaxPatterns; bool m_bAbort, m_bGivePlugsIdleTime; public: - CDoWaveConvert(CSoundFile *sndfile, const char *fname, const CWaveConvertSettings &settings, CWnd *parent = NULL) + CDoWaveConvert(CSoundFile &sndFile, const char *fname, const CWaveConvertSettings &settings, CWnd *parent = NULL) : CDialog(IDD_PROGRESS, parent) + , m_SndFile(sndFile) , m_Settings(settings) - { m_pSndFile = sndfile; - m_lpszFileName = fname; - m_bAbort = false; - m_dwFileLimit = m_dwSongLimit = 0; - m_nMaxPatterns = 0; } + , m_lpszFileName(fname) + , m_bAbort(false) + , m_dwFileLimit(0), m_dwSongLimit(0) { } BOOL OnInitDialog(); void OnCancel() { m_bAbort = true; } afx_msg void OnButton1(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-11-08 10:25:50
|
Revision: 3121 http://sourceforge.net/p/modplug/code/3121 Author: manxorist Date: 2013-11-08 10:25:40 +0000 (Fri, 08 Nov 2013) Log Message: ----------- [Ref] Dynamically allocate TrackerDirectories, so that we can eventually do more complicated stuff in its constructor. Modified Paths: -------------- trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/Mptrack.h trunk/OpenMPT/mptrack/TrackerSettings.cpp trunk/OpenMPT/mptrack/TrackerSettings.h Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2013-11-08 10:23:08 UTC (rev 3120) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2013-11-08 10:25:40 UTC (rev 3121) @@ -633,7 +633,8 @@ CTrackApp::CTrackApp() //-------------------- - : m_pSettingsIniFile(nullptr) + : m_pTrackerDirectories(nullptr) + , m_pSettingsIniFile(nullptr) , m_pSettings(nullptr) , m_pTrackerSettings(nullptr) , m_pPluginCache(nullptr) @@ -830,6 +831,8 @@ CMPTCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); + m_pTrackerDirectories = new TrackerDirectories(); + // Set up paths to store configuration in SetupPaths(cmdInfo.m_bPortable); @@ -965,6 +968,8 @@ m_pSettings = nullptr; delete m_pSettingsIniFile; m_pSettingsIniFile = nullptr; + delete m_pTrackerDirectories; + m_pTrackerDirectories = nullptr; return CWinApp::ExitInstance(); } Modified: trunk/OpenMPT/mptrack/Mptrack.h =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.h 2013-11-08 10:23:08 UTC (rev 3120) +++ trunk/OpenMPT/mptrack/Mptrack.h 2013-11-08 10:25:40 UTC (rev 3121) @@ -23,6 +23,7 @@ class CVstPluginManager; class SoundDevicesManager; class CDLSBank; +class TrackerDirectories; class TrackerSettings; ///////////////////////////////////////////////////////////////////////////// @@ -101,6 +102,7 @@ protected: + TrackerDirectories *m_pTrackerDirectories; IniFileSettingsBackend *m_pSettingsIniFile; SettingsContainer *m_pSettings; TrackerSettings *m_pTrackerSettings; @@ -156,6 +158,11 @@ void GetDefaultMidiMacro(MIDIMacroConfig &cfg) const { cfg = m_MidiCfg; } void SetDefaultMidiMacro(const MIDIMacroConfig &cfg) { m_MidiCfg = cfg; } std::string GetConfigFileName() const { return m_szConfigFileName; } + TrackerDirectories & GetTrackerDirectories() + { + ASSERT(m_pTrackerDirectories); + return *m_pTrackerDirectories; + } SettingsContainer & GetSettings() { ASSERT(m_pSettings); Modified: trunk/OpenMPT/mptrack/TrackerSettings.cpp =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.cpp 2013-11-08 10:23:08 UTC (rev 3120) +++ trunk/OpenMPT/mptrack/TrackerSettings.cpp 2013-11-08 10:25:40 UTC (rev 3121) @@ -30,8 +30,13 @@ #define OLD_SOUNDSETUP_NOBOOSTTHREADPRIORITY 0x80 -TrackerDirectories TrackerDirectories::directories; +TrackerDirectories &TrackerDirectories::Instance() +//------------------------------------------------ +{ + return theApp.GetTrackerDirectories(); +} + const TCHAR *TrackerDirectories::m_szDirectoryToSettingsName[NUM_DIRS] = { _T("Songs_Directory"), _T("Samples_Directory"), _T("Instruments_Directory"), _T("Plugins_Directory"), _T("Plugin_Presets_Directory"), _T("Export_Directory"), _T(""), _T("") }; Modified: trunk/OpenMPT/mptrack/TrackerSettings.h =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.h 2013-11-08 10:23:08 UTC (rev 3120) +++ trunk/OpenMPT/mptrack/TrackerSettings.h 2013-11-08 10:25:40 UTC (rev 3121) @@ -412,12 +412,10 @@ void SetDefaultDirectory(const LPCTSTR szFilenameFrom, Directory dir, bool bStripFilename = false); LPCTSTR GetDefaultDirectory(Directory dir) const; - static TrackerDirectories &Instance() { return directories; } + static TrackerDirectories &Instance(); protected: void SetDirectory(const LPCTSTR szFilenameFrom, Directory dir, TCHAR (&pDirs)[NUM_DIRS][_MAX_PATH], bool bStripFilename); - static TrackerDirectories directories; - }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-11-08 12:39:02
|
Revision: 3125 http://sourceforge.net/p/modplug/code/3125 Author: manxorist Date: 2013-11-08 12:38:53 +0000 (Fri, 08 Nov 2013) Log Message: ----------- [Ref] Second batch of PathString conversions. Still a lot of work to do. Modified Paths: -------------- trunk/OpenMPT/mptrack/TrackerSettings.cpp trunk/OpenMPT/mptrack/TrackerSettings.h Modified: trunk/OpenMPT/mptrack/TrackerSettings.cpp =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.cpp 2013-11-08 12:19:51 UTC (rev 3124) +++ trunk/OpenMPT/mptrack/TrackerSettings.cpp 2013-11-08 12:38:53 UTC (rev 3125) @@ -437,11 +437,12 @@ // Paths for(size_t i = 0; i < NUM_DIRS; i++) { - mpt::String::Copy(TrackerDirectories::Instance().m_szWorkingDirectory[i], TrackerDirectories::Instance().m_szDefaultDirectory[i]); + TrackerDirectories::Instance().m_szWorkingDirectory[i] = TrackerDirectories::Instance().m_szDefaultDirectory[i]; + mpt::String::Copy(TrackerDirectories::Instance().m_szWorkingDirectoryCache[i], TrackerDirectories::Instance().m_szDefaultDirectoryCache[i]); } - if(TrackerDirectories::Instance().m_szDefaultDirectory[DIR_MODS][0]) + if(!TrackerDirectories::Instance().m_szDefaultDirectory[DIR_MODS].empty()) { - SetCurrentDirectory(TrackerDirectories::Instance().m_szDefaultDirectory[DIR_MODS]); + SetCurrentDirectoryW(TrackerDirectories::Instance().m_szDefaultDirectory[DIR_MODS].AsNative().c_str()); } CString tmpKbdFile = m_szKbdFile.ToCString(); theApp.RelativePathToAbsolute(tmpKbdFile); @@ -783,72 +784,93 @@ // retrieve / set default directory from given string and store it our setup variables -void TrackerDirectories::SetDirectory(const LPCTSTR szFilenameFrom, Directory dir, TCHAR (&directories)[NUM_DIRS][_MAX_PATH], bool bStripFilename) -//------------------------------------------------------------------------------------------------------------------------------------------------ +void TrackerDirectories::SetDirectory(const mpt::PathString &szFilenameFrom, Directory dir, mpt::PathString (&directories)[NUM_DIRS], TCHAR (&pDirsCache)[NUM_DIRS][MAX_PATH], bool bStripFilename) +//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- { - TCHAR szPath[_MAX_PATH], szDir[_MAX_DIR]; + mpt::PathString path; if(bStripFilename) { - _tsplitpath(szFilenameFrom, szPath, szDir, 0, 0); - _tcscat(szPath, szDir); + wchar_t szPath[_MAX_PATH]; + wchar_t szDir[_MAX_DIR]; + _wsplitpath(szFilenameFrom.AsNative().c_str(), szPath, szDir, 0, 0); + path = mpt::PathString::FromNative(szPath) + mpt::PathString::FromNative(szDir); } else { - _tcscpy(szPath, szFilenameFrom); + path = szFilenameFrom; } - TCHAR szOldDir[CountOf(directories[dir])]; // for comparison - _tcscpy(szOldDir, directories[dir]); + mpt::PathString szOldDir = directories[dir]; // for comparison - _tcscpy(directories[dir], szPath); + directories[dir] = path; + _tcscpy(pDirsCache[dir], path.ToCString()); // When updating default directory, also update the working directory. - if(szPath[0] && directories == m_szDefaultDirectory) + if(!path.empty() && directories == m_szDefaultDirectory) { - if(_tcscmp(szOldDir, szPath) != 0) // update only if default directory has changed - SetWorkingDirectory(szPath, dir); + if(szOldDir != path) // update only if default directory has changed + SetWorkingDirectory(path, dir); } } -void TrackerDirectories::SetDefaultDirectory(const LPCTSTR szFilenameFrom, Directory dir, bool bStripFilename) -//------------------------------------------------------------------------------------------------------------ +void TrackerDirectories::SetDefaultDirectory(const mpt::PathString &szFilenameFrom, Directory dir, bool bStripFilename) +//--------------------------------------------------------------------------------------------------------------------- { - SetDirectory(szFilenameFrom, dir, m_szDefaultDirectory, bStripFilename); + SetDirectory(szFilenameFrom, dir, m_szDefaultDirectory, m_szDefaultDirectoryCache, bStripFilename); } -void TrackerDirectories::SetWorkingDirectory(const LPCTSTR szFilenameFrom, Directory dir, bool bStripFilename) -//------------------------------------------------------------------------------------------------------------ +void TrackerDirectories::SetWorkingDirectory(const mpt::PathString &szFilenameFrom, Directory dir, bool bStripFilename) +//--------------------------------------------------------------------------------------------------------------------- { - SetDirectory(szFilenameFrom, dir, m_szWorkingDirectory, bStripFilename); + SetDirectory(szFilenameFrom, dir, m_szWorkingDirectory, m_szWorkingDirectoryCache, bStripFilename); } -LPCTSTR TrackerDirectories::GetDefaultDirectory(Directory dir) const -//------------------------------------------------------------------ +mpt::PathString TrackerDirectories::GetDefaultDirectoryAsPathString(Directory dir) const +//-------------------------------------------------------------------------------------- { return m_szDefaultDirectory[dir]; } +mpt::PathString TrackerDirectories::GetWorkingDirectoryAsPathString(Directory dir) const +//-------------------------------------------------------------------------------------- +{ + return m_szWorkingDirectory[dir]; +} + + +void TrackerDirectories::SetDefaultDirectory(LPCTSTR szFilenameFrom, Directory dir, bool bStripFilename) +//--------------------------------------------------------------------------------------------------------------------- +{ + SetDefaultDirectory(mpt::PathString::FromLocale(szFilenameFrom), dir, bStripFilename); +} +void TrackerDirectories::SetWorkingDirectory(LPCTSTR szFilenameFrom, Directory dir, bool bStripFilename) +//--------------------------------------------------------------------------------------------------------------------- +{ + SetWorkingDirectory(mpt::PathString::FromLocale(szFilenameFrom), dir, bStripFilename); +} +LPCTSTR TrackerDirectories::GetDefaultDirectory(Directory dir) const +//------------------------------------------------------------------ +{ + return m_szDefaultDirectoryCache[dir]; +} LPCTSTR TrackerDirectories::GetWorkingDirectory(Directory dir) const //------------------------------------------------------------------ { - return m_szWorkingDirectory[dir]; + return m_szWorkingDirectoryCache[dir]; } + TrackerDirectories::TrackerDirectories() //-------------------------------------- { - // Directory Arrays (Default + Last) - for(size_t i = 0; i < NUM_DIRS; i++) - { - m_szDefaultDirectory[i][0] = '\0'; - m_szWorkingDirectory[i][0] = '\0'; - } + MemsetZero(m_szDefaultDirectoryCache); + MemsetZero(m_szWorkingDirectoryCache); } Modified: trunk/OpenMPT/mptrack/TrackerSettings.h =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.h 2013-11-08 12:19:51 UTC (rev 3124) +++ trunk/OpenMPT/mptrack/TrackerSettings.h 2013-11-08 12:38:53 UTC (rev 3125) @@ -390,26 +390,36 @@ private: // Directory Arrays (default dir + last dir) - TCHAR m_szDefaultDirectory[NUM_DIRS][_MAX_PATH]; - TCHAR m_szWorkingDirectory[NUM_DIRS][_MAX_PATH]; + mpt::PathString m_szDefaultDirectory[NUM_DIRS]; + mpt::PathString m_szWorkingDirectory[NUM_DIRS]; // Directory to INI setting translation static const TCHAR *m_szDirectoryToSettingsName[NUM_DIRS]; + // Cache is necessary because users might expect long lifetimes of pointers returned from Get*Directory. + // Cache can be removed when all users are converted to PathString. + MPT_DEPRECATED TCHAR m_szDefaultDirectoryCache[NUM_DIRS][MAX_PATH]; + MPT_DEPRECATED TCHAR m_szWorkingDirectoryCache[NUM_DIRS][MAX_PATH]; + public: TrackerDirectories(); ~TrackerDirectories(); // access to default + working directories - void SetWorkingDirectory(const LPCTSTR szFilenameFrom, Directory dir, bool bStripFilename = false); - LPCTSTR GetWorkingDirectory(Directory dir) const; - void SetDefaultDirectory(const LPCTSTR szFilenameFrom, Directory dir, bool bStripFilename = false); - LPCTSTR GetDefaultDirectory(Directory dir) const; + void SetWorkingDirectory(const mpt::PathString &szFilenameFrom, Directory dir, bool bStripFilename = false); + mpt::PathString GetWorkingDirectoryAsPathString(Directory dir) const; + void SetDefaultDirectory(const mpt::PathString &szFilenameFrom, Directory dir, bool bStripFilename = false); + mpt::PathString GetDefaultDirectoryAsPathString(Directory dir) const; + void SetWorkingDirectory(LPCTSTR szFilenameFrom, Directory dir, bool bStripFilename = false); + void SetDefaultDirectory(LPCTSTR szFilenameFrom, Directory dir, bool bStripFilename = false); + MPT_DEPRECATED LPCTSTR GetWorkingDirectory(Directory dir) const; + MPT_DEPRECATED LPCTSTR GetDefaultDirectory(Directory dir) const; + static TrackerDirectories &Instance(); protected: - void SetDirectory(const LPCTSTR szFilenameFrom, Directory dir, TCHAR (&pDirs)[NUM_DIRS][_MAX_PATH], bool bStripFilename); + void SetDirectory(const mpt::PathString &szFilenameFrom, Directory dir, mpt::PathString (&pDirs)[NUM_DIRS], TCHAR (&pDirsCache)[NUM_DIRS][MAX_PATH], bool bStripFilename); }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-11-08 14:40:02
|
Revision: 3128 http://sourceforge.net/p/modplug/code/3128 Author: manxorist Date: 2013-11-08 14:39:53 +0000 (Fri, 08 Nov 2013) Log Message: ----------- [Ref] Convert AbsolutePathToRelative and RelativePathToAbsolute to mpt::PathString. 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-08 14:24:25 UTC (rev 3127) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2013-11-08 14:39:53 UTC (rev 3128) @@ -2076,91 +2076,92 @@ // Convert an absolute path to a path that's relative to OpenMPT's directory. // Paths are relative to the executable path. -// nLength specifies the maximum number of character that can be written into szPath, -// including the trailing null char. +mpt::PathString CTrackApp::AbsolutePathToRelative(const mpt::PathString &path) +//---------------------------------------------------------------------------- +{ + mpt::PathString result = path; + if(path.empty()) + { + return result; + } + mpt::PathString exePath = GetAppDirPath(); + if(!_wcsnicmp(exePath.AsNative().c_str(), path.AsNative().c_str(), exePath.AsNative().length())) + { + // Path is OpenMPT's directory or a sub directory ("C:\OpenMPT\Somepath" => ".\Somepath") + result = mpt::PathString::FromUTF8(".\\"); // ".\" + result += mpt::PathString::FromNative(path.AsNative().substr(exePath.AsNative().length())); + } else if(!_wcsnicmp(exePath.AsNative().c_str(), path.AsNative().c_str(), 2)) + { + // Path is on the same drive as OpenMPT ("C:\Somepath" => "\Somepath") + result = mpt::PathString::FromNative(path.AsNative().substr(2)); + } + return result; +} + template <size_t nLength> void CTrackApp::AbsolutePathToRelative(TCHAR (&szPath)[nLength]) //--------------------------------------------------------------- { STATIC_ASSERT(nLength >= 3); - if(_tcslen(szPath) == 0) return; - - const size_t nStrLength = nLength - 1; // "usable" length, i.e. not including the null char. - TCHAR szExePath[nLength], szTempPath[nLength]; - _tcsncpy(szExePath, GetAppDirPath().ToCString(), nStrLength); - mpt::String::SetNullTerminator(szExePath); - - if(!_tcsncicmp(szExePath, szPath, _tcslen(szExePath))) - { - // Path is OpenMPT's directory or a sub directory ("C:\OpenMPT\Somepath" => ".\Somepath") - _tcscpy(szTempPath, _T(".\\")); // ".\" - _tcsncat(szTempPath, &szPath[_tcslen(szExePath)], nStrLength - 2); // "Somepath" - _tcscpy(szPath, szTempPath); - } else if(!_tcsncicmp(szExePath, szPath, 2)) - { - // Path is on the same drive as OpenMPT ("C:\Somepath" => "\Somepath") - _tcsncpy(szTempPath, &szPath[2], nStrLength); // "\Somepath" - _tcscpy(szPath, szTempPath); - } - mpt::String::SetNullTerminator(szPath); + #ifdef UNICODE + mpt::String::Copy(szPath, AbsolutePathToRelative(mpt::PathString::FromNative(szPath)).AsNative()); + #else + mpt::String::Copy(szPath, AbsolutePathToRelative(mpt::PathString::FromLocale(szPath)).ToLocale()); + #endif } CString CTrackApp::AbsolutePathToRelative(const CString &path) //------------------------------------------------------------ { - TCHAR szPath[_MAX_PATH] = ""; - mpt::String::Copy(szPath, std::string(path.GetString())); - AbsolutePathToRelative(szPath); - return szPath; + return AbsolutePathToRelative(mpt::PathString::FromCString(path)).ToCString(); } // Convert a relative path to an absolute path. // Paths are relative to the executable path. -// nLength specifies the maximum number of character that can be written into szPath, -// including the trailing null char. +mpt::PathString CTrackApp::RelativePathToAbsolute(const mpt::PathString &path) +//---------------------------------------------------------------------------- +{ + mpt::PathString result = path; + if(path.empty()) + { + return result; + } + mpt::PathString exePath = GetAppDirPath(); + if(path.AsNative().length() >= 2 && path.AsNative().substr(0, 1) == L"\\" && path.AsNative().substr(0, 2) != L"\\\\") + { + // Path is on the same drive as OpenMPT ("\Somepath\" => "C:\Somepath\"), but ignore network paths starting with "\\" + result = mpt::PathString::FromNative(exePath.AsNative().substr(0, 2)); + result += path; + } else if(path.AsNative().length() >= 2 && path.AsNative().substr(0, 2) == L".\\") + { + // Path is OpenMPT's directory or a sub directory (".\Somepath\" => "C:\OpenMPT\Somepath\") + result = exePath; // "C:\OpenMPT\" + result += mpt::PathString::FromNative(path.AsNative().substr(2)); + } + return result; +} + template <size_t nLength> void CTrackApp::RelativePathToAbsolute(TCHAR (&szPath)[nLength]) //--------------------------------------------------------------- { STATIC_ASSERT(nLength >= 3); - if(_tcslen(szPath) == 0) return; - - const size_t nStrLength = nLength - 1; // "usable" length, i.e. not including the null char. - TCHAR szExePath[nLength], szTempPath[nLength] = _T(""); - _tcsncpy(szExePath, GetAppDirPath().ToCString(), nStrLength); - mpt::String::SetNullTerminator(szExePath); - - if(!_tcsncicmp(szPath, _T("\\"), 1) && _tcsncicmp(szPath, _T("\\\\"), 2)) - { - // Path is on the same drive as OpenMPT ("\Somepath\" => "C:\Somepath\"), but ignore network paths starting with "\\" - _tcsncat(szTempPath, szExePath, 2); // "C:" - _tcsncat(szTempPath, szPath, nStrLength - 2); // "\Somepath\" - _tcscpy(szPath, szTempPath); - } else if(!_tcsncicmp(szPath, _T(".\\"), 2)) - { - // Path is OpenMPT's directory or a sub directory (".\Somepath\" => "C:\OpenMPT\Somepath\") - _tcsncpy(szTempPath, szExePath, nStrLength); // "C:\OpenMPT\" - if(_tcslen(szTempPath) < nStrLength) - { - _tcsncat(szTempPath, &szPath[2], nStrLength - _tcslen(szTempPath)); // "Somepath" - } - _tcscpy(szPath, szTempPath); - } - mpt::String::SetNullTerminator(szPath); + #ifdef UNICODE + mpt::String::Copy(szPath, RelativePathToAbsolute(mpt::PathString::FromNative(szPath)).AsNative()); + #else + mpt::String::Copy(szPath, RelativePathToAbsolute(mpt::PathString::FromLocale(szPath)).ToLocale()); + #endif } CString CTrackApp::RelativePathToAbsolute(const CString &path) //------------------------------------------------------------ { - TCHAR szPath[_MAX_PATH] = ""; - mpt::String::Copy(szPath, std::string(path.GetString())); - RelativePathToAbsolute(szPath); - return szPath; + return RelativePathToAbsolute(mpt::PathString::FromCString(path)).ToCString(); } Modified: trunk/OpenMPT/mptrack/Mptrack.h =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.h 2013-11-08 14:24:25 UTC (rev 3127) +++ trunk/OpenMPT/mptrack/Mptrack.h 2013-11-08 14:39:53 UTC (rev 3128) @@ -189,13 +189,16 @@ /// Returns path to config folder including trailing '\'. mpt::PathString GetConfigPath() const { return m_szConfigDirectory; } void SetupPaths(bool overridePortable); + // Relative / absolute paths conversion + mpt::PathString AbsolutePathToRelative(const mpt::PathString &path); + mpt::PathString RelativePathToAbsolute(const mpt::PathString &path); template <size_t nLength> - void AbsolutePathToRelative(TCHAR (&szPath)[nLength]); - CString AbsolutePathToRelative(const CString &path); + MPT_DEPRECATED void AbsolutePathToRelative(TCHAR (&szPath)[nLength]); + MPT_DEPRECATED CString AbsolutePathToRelative(const CString &path); template <size_t nLength> - void RelativePathToAbsolute(TCHAR (&szPath)[nLength]); - CString RelativePathToAbsolute(const CString &path); + MPT_DEPRECATED void RelativePathToAbsolute(TCHAR (&szPath)[nLength]); + MPT_DEPRECATED CString RelativePathToAbsolute(const CString &path); /// Removes item from MRU-list; most recent item has index zero. void RemoveMruItem(const int nItem); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-11-08 16:52:41
|
Revision: 3133 http://sourceforge.net/p/modplug/code/3133 Author: manxorist Date: 2013-11-08 16:52:32 +0000 (Fri, 08 Nov 2013) Log Message: ----------- [Fix] Make BrowseForFolder dialog work for unicode paths. Modified Paths: -------------- trunk/OpenMPT/mptrack/AutoSaver.cpp trunk/OpenMPT/mptrack/FileDialog.cpp trunk/OpenMPT/mptrack/FileDialog.h trunk/OpenMPT/mptrack/Moptions.cpp trunk/OpenMPT/mptrack/Vstplug.cpp Modified: trunk/OpenMPT/mptrack/AutoSaver.cpp =================================================================== --- trunk/OpenMPT/mptrack/AutoSaver.cpp 2013-11-08 16:44:04 UTC (rev 3132) +++ trunk/OpenMPT/mptrack/AutoSaver.cpp 2013-11-08 16:52:32 UTC (rev 3133) @@ -402,13 +402,13 @@ void CAutoSaverGUI::OnBnClickedAutosaveBrowse() { - CHAR szPath[_MAX_PATH] = ""; + TCHAR szPath[_MAX_PATH] = TEXT(""); GetDlgItemText(IDC_AUTOSAVE_PATH, szPath, CountOf(szPath)); - BrowseForFolder dlg(szPath, "Select a folder to store autosaved files in..."); + BrowseForFolder dlg(mpt::PathString::FromCString(szPath), TEXT("Select a folder to store autosaved files in...")); if(dlg.Show()) { - SetDlgItemText(IDC_AUTOSAVE_PATH, dlg.GetDirectory().c_str()); + SetDlgItemText(IDC_AUTOSAVE_PATH, dlg.GetDirectory().ToCString()); OnSettingsChanged(); } } Modified: trunk/OpenMPT/mptrack/FileDialog.cpp =================================================================== --- trunk/OpenMPT/mptrack/FileDialog.cpp 2013-11-08 16:44:04 UTC (rev 3132) +++ trunk/OpenMPT/mptrack/FileDialog.cpp 2013-11-08 16:52:32 UTC (rev 3133) @@ -112,7 +112,8 @@ if(uMsg == BFFM_INITIALIZED && lpData != NULL) { const BrowseForFolder *that = reinterpret_cast<BrowseForFolder *>(lpData); - SendMessage(hwnd, BFFM_SETSELECTION, TRUE, reinterpret_cast<LPARAM>(that->workingDirectory.c_str())); + std::wstring startPath = that->workingDirectory.AsNative(); + SendMessage(hwnd, BFFM_SETSELECTIONW, TRUE, reinterpret_cast<LPARAM>(startPath.c_str())); } return 0; } @@ -122,20 +123,20 @@ bool BrowseForFolder::Show() //-------------------------- { - TCHAR path[MAX_PATH]; + WCHAR path[MAX_PATH]; - BROWSEINFO bi; + BROWSEINFOW bi; MemsetZero(bi); bi.hwndOwner = theApp.m_pMainWnd->GetSafeHwnd(); - bi.lpszTitle = caption; + bi.lpszTitle = caption.c_str(); bi.pszDisplayName = path; bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_USENEWUI; bi.lpfn = BrowseCallbackProc; bi.lParam = reinterpret_cast<LPARAM>(this); - LPITEMIDLIST pid = SHBrowseForFolder(&bi); - if(pid != NULL && SHGetPathFromIDList(pid, path)) + LPITEMIDLIST pid = SHBrowseForFolderW(&bi); + if(pid != NULL && SHGetPathFromIDListW(pid, path)) { - workingDirectory = path; + workingDirectory = mpt::PathString::FromNative(path); return true; } return false; Modified: trunk/OpenMPT/mptrack/FileDialog.h =================================================================== --- trunk/OpenMPT/mptrack/FileDialog.h 2013-11-08 16:44:04 UTC (rev 3132) +++ trunk/OpenMPT/mptrack/FileDialog.h 2013-11-08 16:52:32 UTC (rev 3133) @@ -83,17 +83,17 @@ class BrowseForFolder { protected: - std::string workingDirectory; - const char *caption; + mpt::PathString workingDirectory; + std::wstring caption; public: - BrowseForFolder(const std::string &dir, const char *caption) : workingDirectory(dir), caption(caption) { } + BrowseForFolder(const mpt::PathString &dir, const CString &caption) : workingDirectory(dir), caption(mpt::String::FromCString(caption)) { } // Show the folder selection dialog. bool Show(); // Gets selected directory. - const std::string &GetDirectory() const { return workingDirectory; } + const mpt::PathString &GetDirectory() const { return workingDirectory; } protected: static int CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData); Modified: trunk/OpenMPT/mptrack/Moptions.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moptions.cpp 2013-11-08 16:44:04 UTC (rev 3132) +++ trunk/OpenMPT/mptrack/Moptions.cpp 2013-11-08 16:52:32 UTC (rev 3133) @@ -659,13 +659,13 @@ void COptionsGeneral::BrowseForFolder(UINT nID) //--------------------------------------------- { - CHAR szPath[_MAX_PATH] = ""; + TCHAR szPath[MAX_PATH] = TEXT(""); GetDlgItemText(nID, szPath, CountOf(szPath)); - ::BrowseForFolder dlg(szPath, "Select a default folder..."); + ::BrowseForFolder dlg(mpt::PathString::FromCString(szPath), TEXT("Select a default folder...")); if(dlg.Show()) { - SetDlgItemText(nID, dlg.GetDirectory().c_str()); + SetDlgItemText(nID, dlg.GetDirectory().ToCString()); OnSettingsChanged(); } } Modified: trunk/OpenMPT/mptrack/Vstplug.cpp =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.cpp 2013-11-08 16:44:04 UTC (rev 3132) +++ trunk/OpenMPT/mptrack/Vstplug.cpp 2013-11-08 16:52:32 UTC (rev 3133) @@ -1174,10 +1174,10 @@ } else { // Plugin wants a directory - BrowseForFolder dlg(fileSel->initialPath != nullptr ? fileSel->initialPath : "", fileSel->title); + BrowseForFolder dlg(mpt::PathString::FromLocale(fileSel->initialPath != nullptr ? fileSel->initialPath : ""), fileSel->title); if(dlg.Show()) { - const std::string &dir = dlg.GetDirectory(); + const std::string dir = dlg.GetDirectory().ToLocale(); if(CCONST('V', 'S', 'T', 'r') == effect->uniqueID && fileSel->returnPath != nullptr && fileSel->sizeReturnPath == 0) { // old versions of reViSiT (which still relied on the host's file selection code) seem to be dodgy. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2013-11-08 17:07:00
|
Revision: 3134 http://sourceforge.net/p/modplug/code/3134 Author: saga-games Date: 2013-11-08 17:06:54 +0000 (Fri, 08 Nov 2013) Log Message: ----------- [Fix] Avoid crash with empty folder browser message for VST plugins. Modified Paths: -------------- trunk/OpenMPT/mptrack/FileDialog.cpp trunk/OpenMPT/mptrack/Vstplug.cpp Modified: trunk/OpenMPT/mptrack/FileDialog.cpp =================================================================== --- trunk/OpenMPT/mptrack/FileDialog.cpp 2013-11-08 16:52:32 UTC (rev 3133) +++ trunk/OpenMPT/mptrack/FileDialog.cpp 2013-11-08 17:06:54 UTC (rev 3134) @@ -128,7 +128,7 @@ BROWSEINFOW bi; MemsetZero(bi); bi.hwndOwner = theApp.m_pMainWnd->GetSafeHwnd(); - bi.lpszTitle = caption.c_str(); + bi.lpszTitle = caption.empty() ? NULL : caption.c_str(); bi.pszDisplayName = path; bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_USENEWUI; bi.lpfn = BrowseCallbackProc; Modified: trunk/OpenMPT/mptrack/Vstplug.cpp =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.cpp 2013-11-08 16:52:32 UTC (rev 3133) +++ trunk/OpenMPT/mptrack/Vstplug.cpp 2013-11-08 17:06:54 UTC (rev 3134) @@ -1000,7 +1000,10 @@ // get plug directory, FSSpec on MAC, else char* case audioMasterGetDirectory: //Log("VST plugin to host: Get Directory\n"); - return ToVstPtr(TrackerDirectories::Instance().GetDefaultDirectory(DIR_PLUGINS)); + // Need to allocate space for path only, but I guess noone relies on this anyway. + //return ToVstPtr(pVstPlugin->GetPluginFactory().szDllPath); + //return ToVstPtr(TrackerDirectories::Instance().GetDefaultDirectory(DIR_PLUGINS)); + break; // something has changed, update 'multi-fx' display case audioMasterUpdateDisplay: @@ -1174,7 +1177,7 @@ } else { // Plugin wants a directory - BrowseForFolder dlg(mpt::PathString::FromLocale(fileSel->initialPath != nullptr ? fileSel->initialPath : ""), fileSel->title); + BrowseForFolder dlg(mpt::PathString::FromLocale(fileSel->initialPath != nullptr ? fileSel->initialPath : ""), fileSel->title != nullptr ? fileSel->title : ""); if(dlg.Show()) { const std::string dir = dlg.GetDirectory().ToLocale(); @@ -1327,7 +1330,7 @@ m_bIsVst2 = Dispatch(effGetVstVersion, 0,0, nullptr, 0.0f) >= 2; if (m_bIsVst2) { - // Set VST speaker in/out setup to Stereo. Required for some plugins (possibly all VST 2.4+ plugins?) + // Set VST speaker in/out setup to Stereo. Required for some plugins (e.g. Voxengo SPAN 2) // All this might get more interesting when adding sidechaining support... VstSpeakerArrangement sa; MemsetZero(sa); @@ -1922,10 +1925,9 @@ { CVstPluginManager::ReportPlugException("Exception in Resume() (Plugin=%s)\n", m_Factory.szLibraryName); } +} -} - void CVstPlugin::Suspend() //------------------------ { @@ -2670,7 +2672,7 @@ if (!p) { - nByteSize = Dispatch(effGetChunk, 1,0, &p, 0); // Getting bank failed, try to get get just preset + nByteSize = Dispatch(effGetChunk, 1,0, &p, 0); // Getting bank failed, try to get just preset } else { m_pMixStruct->defaultProgram = GetCurrentProgram(); //we managed to get the bank, now we need to remember which program we're on. @@ -3208,6 +3210,15 @@ case effSetSampleRate: m_nSamplesPerSec = (int)opt; + { + + m_Effect.initialDelay = 0; + REFERENCE_TIME time; // Unit 100-nanoseconds + if(m_pMediaProcess->GetLatency(&time) == S_OK) + { + m_Effect.initialDelay = static_cast<VstInt32>(time * m_nSamplesPerSec / (10 * 1000 * 1000)); + } + } break; case effMainsChanged: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-11-09 14:19:55
|
Revision: 3148 http://sourceforge.net/p/modplug/code/3148 Author: manxorist Date: 2013-11-09 14:19:48 +0000 (Sat, 09 Nov 2013) Log Message: ----------- [Ref] Convert CAutoSaver interface to mpt::PathString. [Ref] Convert the last bits of class TrackerSettings to mpt::PathString. Modified Paths: -------------- trunk/OpenMPT/mptrack/AutoSaver.cpp trunk/OpenMPT/mptrack/AutoSaver.h trunk/OpenMPT/mptrack/TrackerSettings.cpp Modified: trunk/OpenMPT/mptrack/AutoSaver.cpp =================================================================== --- trunk/OpenMPT/mptrack/AutoSaver.cpp 2013-11-09 14:03:07 UTC (rev 3147) +++ trunk/OpenMPT/mptrack/AutoSaver.cpp 2013-11-09 14:19:48 UTC (rev 3148) @@ -29,9 +29,9 @@ // Construction/Destruction /////////////////////////// -CAutoSaver::CAutoSaver(bool enabled, int saveInterval, int backupHistory, - bool useOriginalPath, CString path, CString fileNameTemplate) : - m_bSaveInProgress(false) +CAutoSaver::CAutoSaver(bool enabled, int saveInterval, int backupHistory, bool useOriginalPath, mpt::PathString path, mpt::PathString fileNameTemplate) +//----------------------------------------------------------------------------------------------------------------------------------------------------- + : m_bSaveInProgress(false) { m_nLastSave = timeGetTime(); m_bEnabled = enabled; @@ -131,29 +131,29 @@ } -void CAutoSaver::SetPath(CString path) -//------------------------------------ +void CAutoSaver::SetPath(mpt::PathString path) +//-------------------------------------------- { m_csPath = path; } -CString CAutoSaver::GetPath() -//--------------------------- +mpt::PathString CAutoSaver::GetPath() +//----------------------------------- { return m_csPath; } -void CAutoSaver::SetFilenameTemplate(CString fnTemplate) -//------------------------------------------------------ +void CAutoSaver::SetFilenameTemplate(mpt::PathString fnTemplate) +//-------------------------------------------------------------- { m_csFileNameTemplate = fnTemplate; } -CString CAutoSaver::GetFilenameTemplate() -//--------------------------------------- +mpt::PathString CAutoSaver::GetFilenameTemplate() +//------------------------------------------------ { return m_csFileNameTemplate; } @@ -206,37 +206,37 @@ mpt::PathString CAutoSaver::BuildFileName(CModDoc &modDoc) //-------------------------------------------------------- { - CString timeStamp = (CTime::GetCurrentTime()).Format("%Y%m%d.%H%M%S"); - CString name; + std::wstring timeStamp = mpt::String::FromCString((CTime::GetCurrentTime()).Format("%Y%m%d.%H%M%S")); + mpt::PathString name; if(m_bUseOriginalPath) { if(modDoc.m_bHasValidPath) { // Check that the file has a user-chosen path - name = modDoc.GetPathName(); + name = mpt::PathString::FromCString(modDoc.GetPathName()); } else { // if it doesnt, put it in settings dir - name = theApp.GetConfigPath().ToCString() + modDoc.GetTitle(); + name = theApp.GetConfigPath() + mpt::PathString::FromCString(modDoc.GetTitle()); } } else { - name = m_csPath+modDoc.GetTitle(); + name = m_csPath + mpt::PathString::FromCString(modDoc.GetTitle()); } - name.Append(".AutoSave."); //append backup tag - name.Append(timeStamp); //append timestamp - name.Append("."); //append extension + name += MPT_PATHSTRING(".AutoSave."); //append backup tag + name += mpt::PathString::FromWide(timeStamp); //append timestamp + name += MPT_PATHSTRING("."); //append extension if(modDoc.GetrSoundFile().m_SongFlags[SONG_ITPROJECT]) { - name.Append("itp"); + name += MPT_PATHSTRING("itp"); } else { - name.Append(modDoc.GetrSoundFile().GetModSpecifications().fileExtension); + name += mpt::PathString::FromUTF8(modDoc.GetrSoundFile().GetModSpecifications().fileExtension); } - return mpt::PathString::FromCString(name); + return name; } @@ -300,7 +300,7 @@ } } else { - path = m_csPath; + path = m_csPath.ToCString(); } CString searchPattern = path + modDoc.GetTitle() + ".AutoSave.*"; @@ -371,7 +371,7 @@ CheckDlgButton(IDC_AUTOSAVE_ENABLE, m_pAutoSaver->IsEnabled()?BST_CHECKED:BST_UNCHECKED); //SetDlgItemText(IDC_AUTOSAVE_FNTEMPLATE, m_pAutoSaver->GetFilenameTemplate()); SetDlgItemInt(IDC_AUTOSAVE_HISTORY, m_pAutoSaver->GetHistoryDepth()); //TODO - SetDlgItemText(IDC_AUTOSAVE_PATH, m_pAutoSaver->GetPath()); + SetDlgItemText(IDC_AUTOSAVE_PATH, m_pAutoSaver->GetPath().ToCString()); SetDlgItemInt(IDC_AUTOSAVE_INTERVAL, m_pAutoSaver->GetSaveInterval()); CheckDlgButton(IDC_AUTOSAVE_USEORIGDIR, m_pAutoSaver->GetUseOriginalPath()?BST_CHECKED:BST_UNCHECKED); CheckDlgButton(IDC_AUTOSAVE_USECUSTOMDIR, m_pAutoSaver->GetUseOriginalPath()?BST_UNCHECKED:BST_CHECKED); @@ -388,14 +388,14 @@ { CString tempPath; IsDlgButtonChecked(IDC_AUTOSAVE_ENABLE) ? m_pAutoSaver->Enable() : m_pAutoSaver->Disable(); - m_pAutoSaver->SetFilenameTemplate(""); //TODO + m_pAutoSaver->SetFilenameTemplate(MPT_PATHSTRING("")); //TODO m_pAutoSaver->SetHistoryDepth(GetDlgItemInt(IDC_AUTOSAVE_HISTORY)); m_pAutoSaver->SetSaveInterval(GetDlgItemInt(IDC_AUTOSAVE_INTERVAL)); m_pAutoSaver->SetUseOriginalPath(IsDlgButtonChecked(IDC_AUTOSAVE_USEORIGDIR) == BST_CHECKED); GetDlgItemText(IDC_AUTOSAVE_PATH, tempPath); if (!tempPath.IsEmpty() && (tempPath.Right(1)!="\\")) tempPath.Append("\\"); - m_pAutoSaver->SetPath(tempPath); + m_pAutoSaver->SetPath(mpt::PathString::FromCString(tempPath)); CPropertyPage::OnOK(); } Modified: trunk/OpenMPT/mptrack/AutoSaver.h =================================================================== --- trunk/OpenMPT/mptrack/AutoSaver.h 2013-11-09 14:03:07 UTC (rev 3147) +++ trunk/OpenMPT/mptrack/AutoSaver.h 2013-11-09 14:19:48 UTC (rev 3148) @@ -19,7 +19,7 @@ public: //Cons/Destr CAutoSaver(bool enabled=true, int saveInterval=10, int backupHistory=3, - bool useOriginalPath=true, CString path="", CString fileNameTemplate=""); + bool useOriginalPath=true, mpt::PathString path=mpt::PathString(), mpt::PathString fileNameTemplate=mpt::PathString()); ~CAutoSaver(); //Work @@ -32,10 +32,10 @@ bool IsEnabled(); void SetUseOriginalPath(bool useOrgPath); bool GetUseOriginalPath(); - void SetPath(CString path); - CString GetPath(); - void SetFilenameTemplate(CString path); - CString GetFilenameTemplate(); + void SetPath(mpt::PathString path); + mpt::PathString GetPath(); + void SetFilenameTemplate(mpt::PathString path); + mpt::PathString GetFilenameTemplate(); void SetHistoryDepth(int); int GetHistoryDepth(); void SetSaveInterval(int minutes); @@ -59,8 +59,8 @@ DWORD m_nSaveInterval; size_t m_nBackupHistory; bool m_bUseOriginalPath; - CString m_csPath; - CString m_csFileNameTemplate; + mpt::PathString m_csPath; + mpt::PathString m_csFileNameTemplate; }; Modified: trunk/OpenMPT/mptrack/TrackerSettings.cpp =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.cpp 2013-11-09 14:03:07 UTC (rev 3147) +++ trunk/OpenMPT/mptrack/TrackerSettings.cpp 2013-11-09 14:19:48 UTC (rev 3148) @@ -232,8 +232,8 @@ CMainFrame::m_pAutoSaver->SetSaveInterval(conf.Read<int32>("AutoSave", "IntervalMinutes", CMainFrame::m_pAutoSaver->GetSaveInterval())); CMainFrame::m_pAutoSaver->SetHistoryDepth(conf.Read<int32>("AutoSave", "BackupHistory", CMainFrame::m_pAutoSaver->GetHistoryDepth())); CMainFrame::m_pAutoSaver->SetUseOriginalPath(conf.Read<bool>("AutoSave", "UseOriginalPath", CMainFrame::m_pAutoSaver->GetUseOriginalPath())); - CMainFrame::m_pAutoSaver->SetPath(theApp.RelativePathToAbsolute(conf.Read<CString>("AutoSave", "Path", CMainFrame::m_pAutoSaver->GetPath()))); - CMainFrame::m_pAutoSaver->SetFilenameTemplate(conf.Read<CString>("AutoSave", "FileNameTemplate", CMainFrame::m_pAutoSaver->GetFilenameTemplate())); + CMainFrame::m_pAutoSaver->SetPath(theApp.RelativePathToAbsolute(conf.Read<mpt::PathString>("AutoSave", "Path", CMainFrame::m_pAutoSaver->GetPath()))); + CMainFrame::m_pAutoSaver->SetFilenameTemplate(conf.Read<mpt::PathString>("AutoSave", "FileNameTemplate", CMainFrame::m_pAutoSaver->GetFilenameTemplate())); // Paths for(size_t i = 0; i < NUM_DIRS; i++) { @@ -443,9 +443,7 @@ { SetCurrentDirectoryW(TrackerDirectories::Instance().m_szDefaultDirectory[DIR_MODS].AsNative().c_str()); } - CString tmpKbdFile = m_szKbdFile.ToCString(); - theApp.RelativePathToAbsolute(tmpKbdFile); - m_szKbdFile = mpt::PathString::FromCString(tmpKbdFile); + m_szKbdFile = theApp.RelativePathToAbsolute(m_szKbdFile); // Last fixup: update config version IniVersion = MptVersion::str; @@ -643,8 +641,8 @@ conf.Write<int32>("AutoSave", "IntervalMinutes", CMainFrame::m_pAutoSaver->GetSaveInterval()); conf.Write<int32>("AutoSave", "BackupHistory", CMainFrame::m_pAutoSaver->GetHistoryDepth()); conf.Write<bool>("AutoSave", "UseOriginalPath", CMainFrame::m_pAutoSaver->GetUseOriginalPath()); - conf.Write<CString>("AutoSave", "Path", theApp.AbsolutePathToRelative(CMainFrame::m_pAutoSaver->GetPath())); - conf.Write<CString>("AutoSave", "FileNameTemplate", CMainFrame::m_pAutoSaver->GetFilenameTemplate()); + conf.Write<mpt::PathString>("AutoSave", "Path", theApp.AbsolutePathToRelative(CMainFrame::m_pAutoSaver->GetPath())); + conf.Write<mpt::PathString>("AutoSave", "FileNameTemplate", CMainFrame::m_pAutoSaver->GetFilenameTemplate()); // Paths for(size_t i = 0; i < NUM_DIRS; i++) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-11-09 22:31:45
|
Revision: 3157 http://sourceforge.net/p/modplug/code/3157 Author: manxorist Date: 2013-11-09 22:31:36 +0000 (Sat, 09 Nov 2013) Log Message: ----------- [Ref] Small mpt::PathString conversion in TuningDialog.cpp. Modified Paths: -------------- trunk/OpenMPT/mptrack/TuningDialog.cpp trunk/OpenMPT/mptrack/TuningDialog.h Modified: trunk/OpenMPT/mptrack/TuningDialog.cpp =================================================================== --- trunk/OpenMPT/mptrack/TuningDialog.cpp 2013-11-09 21:54:52 UTC (rev 3156) +++ trunk/OpenMPT/mptrack/TuningDialog.cpp 2013-11-09 22:31:36 UTC (rev 3157) @@ -736,7 +736,7 @@ } else // scl import. { - EnSclImport a = ImportScl(files[counter].ToCString(), szFileName); + EnSclImport a = ImportScl(files[counter], szFileName); if (a != enSclImportOk) { if (a == enSclImportAddTuningFailure && m_TempTunings.GetNumTunings() >= CTuningCollection::s_nMaxTuningCount) @@ -1481,10 +1481,10 @@ } -CTuningDialog::EnSclImport CTuningDialog::ImportScl(LPCTSTR pszPath, LPCTSTR pszName) -//----------------------------------------------------------------------------------- +CTuningDialog::EnSclImport CTuningDialog::ImportScl(const mpt::PathString &filename, LPCTSTR pszName) +//--------------------------------------------------------------------------------------------------- { - mpt::ifstream iStrm(pszPath, std::ios::in | std::ios::binary); + mpt::ifstream iStrm(filename.AsNative().c_str(), std::ios::in | std::ios::binary); if(!iStrm) { return enSclImportFailUnableToOpenFile; Modified: trunk/OpenMPT/mptrack/TuningDialog.h =================================================================== --- trunk/OpenMPT/mptrack/TuningDialog.h 2013-11-09 21:54:52 UTC (rev 3156) +++ trunk/OpenMPT/mptrack/TuningDialog.h 2013-11-09 22:31:36 UTC (rev 3157) @@ -255,7 +255,7 @@ bool IsDeletable(const CTuningCollection* const pTC) const; // Scl-file import. - EnSclImport ImportScl(LPCTSTR pszPath, LPCTSTR pszName); + EnSclImport ImportScl(const mpt::PathString &filename, LPCTSTR pszName); EnSclImport ImportScl(std::istream& iStrm, LPCTSTR pszName); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-11-09 23:33:38
|
Revision: 3158 http://sourceforge.net/p/modplug/code/3158 Author: manxorist Date: 2013-11-09 23:33:29 +0000 (Sat, 09 Nov 2013) Log Message: ----------- [Ref] Use unicode strings for configuration setting paths. Modified Paths: -------------- trunk/OpenMPT/mptrack/Moptions.cpp trunk/OpenMPT/mptrack/Settings.cpp trunk/OpenMPT/mptrack/Settings.h Modified: trunk/OpenMPT/mptrack/Moptions.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moptions.cpp 2013-11-09 22:31:36 UTC (rev 3157) +++ trunk/OpenMPT/mptrack/Moptions.cpp 2013-11-09 23:33:29 UTC (rev 3158) @@ -710,7 +710,7 @@ static std::string FormatSetting(const SettingPath &path, const SettingValue &val) //-------------------------------------------------------------------------------- { - return path.FormatAsString() + " = " + mpt::String::Encode(val.FormatAsString(), mpt::CharsetLocale); + return mpt::String::Encode(path.FormatAsString() + L" = " + val.FormatAsString(), mpt::CharsetLocale); } @@ -762,7 +762,7 @@ } const SettingPath path = m_IndexToPath[index]; SettingValue val = theApp.GetSettings().GetMap().find(path)->second; - CInputDlg inputDlg(this, path.FormatAsString().c_str(), mpt::String::Encode(val.FormatValueAsString(), mpt::CharsetLocale).c_str()); + CInputDlg inputDlg(this, mpt::String::Encode(path.FormatAsString(), mpt::CharsetLocale).c_str(), mpt::String::Encode(val.FormatValueAsString(), mpt::CharsetLocale).c_str()); if(inputDlg.DoModal() != IDOK) { return; Modified: trunk/OpenMPT/mptrack/Settings.cpp =================================================================== --- trunk/OpenMPT/mptrack/Settings.cpp 2013-11-09 22:31:36 UTC (rev 3157) +++ trunk/OpenMPT/mptrack/Settings.cpp 2013-11-09 23:33:29 UTC (rev 3158) @@ -412,11 +412,11 @@ std::wstring IniFileSettingsBackend::GetSection(const SettingPath &path) { - return mpt::String::Decode(path.GetSection(), mpt::CharsetLocale); + return path.GetSection(); } std::wstring IniFileSettingsBackend::GetKey(const SettingPath &path) { - return mpt::String::Decode(path.GetKey(), mpt::CharsetLocale); + return path.GetKey(); } Modified: trunk/OpenMPT/mptrack/Settings.h =================================================================== --- trunk/OpenMPT/mptrack/Settings.h 2013-11-09 22:31:36 UTC (rev 3157) +++ trunk/OpenMPT/mptrack/Settings.h 2013-11-09 23:33:29 UTC (rev 3158) @@ -388,24 +388,30 @@ class SettingPath { private: - std::string section; - std::string key; + std::wstring section; + std::wstring key; public: SettingPath() { return; } - SettingPath(const std::string §ion_, const std::string &key_) + SettingPath(const std::wstring §ion_, const std::wstring &key_) : section(section_) , key(key_) { return; } - std::string GetSection() const + SettingPath(const std::string §ion_, const std::string &key_) + : section(mpt::String::Decode(section_, mpt::CharsetLocale)) + , key(mpt::String::Decode(key_, mpt::CharsetLocale)) { + return; + } + std::wstring GetSection() const + { return section; } - std::string GetKey() const + std::wstring GetKey() const { return key; } @@ -419,9 +425,9 @@ int cmp_key = key.compare(other.key); return cmp_key; } - std::string FormatAsString() const + std::wstring FormatAsString() const { - return section + "." + key; + return section + L"." + key; } }; @@ -510,6 +516,11 @@ return FromSettingValue<T>(ReadSetting(path, ToSettingValue<T>(def), metadata)); } template <typename T> + T Read(const std::wstring §ion, const std::wstring &key, const T &def = T(), const SettingMetadata &metadata = SettingMetadata()) const + { + return FromSettingValue<T>(ReadSetting(SettingPath(section, key), ToSettingValue<T>(def), metadata)); + } + template <typename T> T Read(const std::string §ion, const std::string &key, const T &def = T(), const SettingMetadata &metadata = SettingMetadata()) const { return FromSettingValue<T>(ReadSetting(SettingPath(section, key), ToSettingValue<T>(def), metadata)); @@ -520,6 +531,11 @@ WriteSetting(path, ToSettingValue<T>(val)); } template <typename T> + void Write(const std::wstring §ion, const std::wstring &key, const T &val) + { + WriteSetting(SettingPath(section, key), ToSettingValue<T>(val)); + } + template <typename T> void Write(const std::string §ion, const std::string &key, const T &val) { WriteSetting(SettingPath(section, key), ToSettingValue<T>(val)); @@ -528,6 +544,10 @@ { RemoveSetting(path); } + void Remove(const std::wstring §ion, const std::wstring &key) + { + RemoveSetting(SettingPath(section, key)); + } void Remove(const std::string §ion, const std::string &key) { RemoveSetting(SettingPath(section, key)); @@ -586,6 +606,12 @@ { conf.Read(path, def, metadata); // set default value } + Setting(SettingsContainer &conf_, const std::wstring §ion, const std::wstring &key, const T&def, const SettingMetadata &metadata = SettingMetadata()) + : conf(conf_) + , path(section, key) + { + conf.Read(path, def, metadata); // set default value + } Setting(SettingsContainer &conf_, const SettingPath &path_, const T&def, const SettingMetadata &metadata = SettingMetadata()) : conf(conf_) , path(path_) @@ -644,6 +670,14 @@ value = conf.Read(path, def, metadata); conf.Register(this, path); } + CachedSetting(SettingsContainer &conf_, const std::wstring §ion, const std::wstring &key, const T&def, const SettingMetadata &metadata = SettingMetadata()) + : value(def) + , conf(conf_) + , path(section, key) + { + value = conf.Read(path, def, metadata); + conf.Register(this, path); + } CachedSetting(SettingsContainer &conf_, const SettingPath &path_, const T&def, const SettingMetadata &metadata = SettingMetadata()) : value(def) , conf(conf_) @@ -719,6 +753,13 @@ { value = conf.Read(path, def, metadata); } + Setting(SettingsContainer &conf_, const std::wstring §ion, const std::wstring &key, const T&def, const SettingMetadata &metadata = SettingMetadata()) + : value(def) + , conf(conf_) + , path(section, key) + { + value = conf.Read(path, def, metadata); + } Setting(SettingsContainer &conf_, const SettingPath &path_, const T&def, const SettingMetadata &metadata = SettingMetadata()) : value(def) , conf(conf_) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-11-10 11:40:15
|
Revision: 3166 http://sourceforge.net/p/modplug/code/3166 Author: manxorist Date: 2013-11-10 11:40:07 +0000 (Sun, 10 Nov 2013) Log Message: ----------- [Ref] Convert CMainFrame::PlaySoundFile to mpt::PathString. Modified Paths: -------------- trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mainfrm.h trunk/OpenMPT/mptrack/View_tre.cpp Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2013-11-10 10:04:22 UTC (rev 3165) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2013-11-10 11:40:07 UTC (rev 3166) @@ -1411,22 +1411,22 @@ } -BOOL CMainFrame::PlaySoundFile(LPCSTR lpszFileName, ModCommand::NOTE note) -//------------------------------------------------------------------------ +BOOL CMainFrame::PlaySoundFile(const mpt::PathString &filename, ModCommand::NOTE note) +//------------------------------------------------------------------------------------ { bool ok = false; BeginWaitCursor(); { CriticalSection cs; - static CString prevFile; + static mpt::PathString prevFile; // Did we already load this file for previewing? Don't load it again if the preview is still running. - ok = (prevFile == lpszFileName && m_pSndFile == &m_WaveFile); + ok = (prevFile == filename && m_pSndFile == &m_WaveFile); - if(!ok && lpszFileName) + if(!ok && !filename.empty()) { CMappedFile f; - if(f.Open(mpt::PathString::FromLocale(lpszFileName))) + if(f.Open(filename)) { FileReader file = f.GetFile(); if(file.IsValid()) @@ -1451,7 +1451,7 @@ { // Write notes to pattern. Also done if we have previously loaded this file, since we might be previewing another note now. PreparePreview(note); - prevFile = lpszFileName; + prevFile = filename; } } EndWaitCursor(); Modified: trunk/OpenMPT/mptrack/Mainfrm.h =================================================================== --- trunk/OpenMPT/mptrack/Mainfrm.h 2013-11-10 10:04:22 UTC (rev 3165) +++ trunk/OpenMPT/mptrack/Mainfrm.h 2013-11-10 11:40:07 UTC (rev 3166) @@ -422,7 +422,7 @@ bool StopSoundFile(CSoundFile *); bool PlaySoundFile(CSoundFile *); - BOOL PlaySoundFile(LPCSTR lpszFileName, ModCommand::NOTE note); + BOOL PlaySoundFile(const mpt::PathString &filename, ModCommand::NOTE note); BOOL PlaySoundFile(CSoundFile &sndFile, INSTRUMENTINDEX nInstrument, SAMPLEINDEX nSample, ModCommand::NOTE note); BOOL PlayDLSInstrument(UINT nDLSBank, UINT nIns, UINT nRgn, ModCommand::NOTE note); Modified: trunk/OpenMPT/mptrack/View_tre.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_tre.cpp 2013-11-10 10:04:22 UTC (rev 3165) +++ trunk/OpenMPT/mptrack/View_tre.cpp 2013-11-10 11:40:07 UTC (rev 3166) @@ -1304,7 +1304,7 @@ CHAR szFullPath[_MAX_PATH] = ""; InsLibGetFullPath(hItem, szFullPath); CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); - if (pMainFrm) pMainFrm->PlaySoundFile(szFullPath, nParam); + if (pMainFrm) pMainFrm->PlaySoundFile(mpt::PathString::FromLocale(szFullPath), nParam); } return TRUE; @@ -1316,7 +1316,7 @@ if ((lpMidiLib) && (modItemID < 256) && (lpMidiLib->MidiMap[modItemID])) { CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); - if (pMainFrm) pMainFrm->PlaySoundFile(lpMidiLib->MidiMap[modItemID], static_cast<ModCommand::NOTE>(nParam)); + if (pMainFrm) pMainFrm->PlaySoundFile(mpt::PathString::FromLocale(lpMidiLib->MidiMap[modItemID]), static_cast<ModCommand::NOTE>(nParam)); } } return TRUE; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-11-10 12:48:31
|
Revision: 3168 http://sourceforge.net/p/modplug/code/3168 Author: manxorist Date: 2013-11-10 12:48:22 +0000 (Sun, 10 Nov 2013) Log Message: ----------- [Ref] Add wide string overloads in Reporting.h. This allows proper displaying of filenames in message boxes. Modified Paths: -------------- trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mainfrm.h trunk/OpenMPT/mptrack/Reporting.cpp trunk/OpenMPT/mptrack/Reporting.h Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2013-11-10 12:31:11 UTC (rev 3167) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2013-11-10 12:48:22 UTC (rev 3168) @@ -2506,11 +2506,10 @@ void CMainFrame::OnHelp() //----------------------- { - mpt::PathString helpFile = theApp.GetAppDirPath(); - helpFile += MPT_PATHSTRING("OpenMPT Manual.pdf"); + mpt::PathString helpFile = theApp.GetAppDirPath() + MPT_PATHSTRING("OpenMPT Manual.pdf"); if(!theApp.OpenFile(helpFile)) { - Reporting::Error(std::string("Could not find help file:\n" + helpFile.ToLocale()).c_str()); + Reporting::Error(L"Could not find help file:\n" + helpFile.ToWide()); } } Modified: trunk/OpenMPT/mptrack/Mainfrm.h =================================================================== --- trunk/OpenMPT/mptrack/Mainfrm.h 2013-11-10 12:31:11 UTC (rev 3167) +++ trunk/OpenMPT/mptrack/Mainfrm.h 2013-11-10 12:48:22 UTC (rev 3168) @@ -24,6 +24,7 @@ class ISoundSource; #define MAINFRAME_TITLE "Open ModPlug Tracker" +#define MAINFRAME_TITLEW L"Open ModPlug Tracker" enum { Modified: trunk/OpenMPT/mptrack/Reporting.cpp =================================================================== --- trunk/OpenMPT/mptrack/Reporting.cpp 2013-11-10 12:31:11 UTC (rev 3167) +++ trunk/OpenMPT/mptrack/Reporting.cpp 2013-11-10 12:48:22 UTC (rev 3168) @@ -38,6 +38,31 @@ } +UINT Reporting::ShowNotification(const std::wstring &text, const std::wstring &caption, UINT flags, const CWnd *parent) +//--------------------------------------------------------------------------------------------------------------------- +{ + CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); + + if(pMainFrm != nullptr && pMainFrm->GetInputHandler() != nullptr) + { + pMainFrm->GetInputHandler()->Bypass(true); + } + + if(parent == nullptr) + { + parent = pMainFrm; + } + UINT result = ::MessageBoxW((parent ? parent->m_hWnd : NULL), text.c_str(), caption.c_str(), flags); + + if(pMainFrm != nullptr && pMainFrm->GetInputHandler() != nullptr) + { + pMainFrm->GetInputHandler()->Bypass(false); + } + + return result; +} + + void Reporting::Notification(const char *text, const CWnd *parent) //---------------------------------------------------------------- { @@ -138,3 +163,105 @@ return rtyCancel; } } + + +void Reporting::Notification(const std::wstring &text, const CWnd *parent) +//------------------------------------------------------------------------ +{ + Notification(text, MAINFRAME_TITLEW, parent); +} + + +void Reporting::Notification(const std::wstring &text, const std::wstring &caption, const CWnd *parent) +//----------------------------------------------------------------------------------------------------- +{ + ShowNotification(text, caption, MB_OK, parent); +} + + +void Reporting::Information(const std::wstring &text, const CWnd *parent) +//----------------------------------------------------------------------- +{ + Information(text, MAINFRAME_TITLEW, parent); +} + + +void Reporting::Information(const std::wstring &text, const std::wstring &caption, const CWnd *parent) +//---------------------------------------------------------------------------------------------------- +{ + ShowNotification(text, caption, MB_OK | MB_ICONINFORMATION, parent); +} + + +void Reporting::Warning(const std::wstring &text, const CWnd *parent) +//----------------------------------------------------------- +{ + Warning(text, MAINFRAME_TITLEW L" - Warning", parent); +} + + +void Reporting::Warning(const std::wstring &text, const std::wstring &caption, const CWnd *parent) +//------------------------------------------------------------------------------------------------ +{ + ShowNotification(text, caption, MB_OK | MB_ICONWARNING, parent); +} + + +void Reporting::Error(const std::wstring &text, const CWnd *parent) +//--------------------------------------------------------- +{ + Error(text, MAINFRAME_TITLEW L" - Error", parent); +} + + +void Reporting::Error(const std::wstring &text, const std::wstring &caption, const CWnd *parent) +//---------------------------------------------------------------------------------------------- +{ + ShowNotification(text, caption, MB_OK | MB_ICONERROR, parent); +} + + +ConfirmAnswer Reporting::Confirm(const std::wstring &text, bool showCancel, bool defaultNo, const CWnd *parent) +//------------------------------------------------------------------------------------------------------------- +{ + return Confirm(text, MAINFRAME_TITLEW L" - Confirmation", showCancel, defaultNo, parent); +} + + +ConfirmAnswer Reporting::Confirm(const std::wstring &text, const std::wstring &caption, bool showCancel, bool defaultNo, const CWnd *parent) +//------------------------------------------------------------------------------------------------------------------------------------------ +{ + UINT result = ShowNotification(text, caption, (showCancel ? MB_YESNOCANCEL : MB_YESNO) | MB_ICONQUESTION | (defaultNo ? MB_DEFBUTTON2 : 0), parent); + switch(result) + { + case IDYES: + return cnfYes; + case IDNO: + return cnfNo; + default: + case IDCANCEL: + return cnfCancel; + } +} + + +RetryAnswer Reporting::RetryCancel(const std::wstring &text, const CWnd *parent) +//------------------------------------------------------------------------------ +{ + return RetryCancel(text, MAINFRAME_TITLEW, parent); +} + + +RetryAnswer Reporting::RetryCancel(const std::wstring &text, const std::wstring &caption, const CWnd *parent) +//----------------------------------------------------------------------------------------------------------- +{ + UINT result = ShowNotification(text, caption, MB_RETRYCANCEL, parent); + switch(result) + { + case IDRETRY: + return rtyRetry; + default: + case IDCANCEL: + return rtyCancel; + } +} Modified: trunk/OpenMPT/mptrack/Reporting.h =================================================================== --- trunk/OpenMPT/mptrack/Reporting.h 2013-11-10 12:31:11 UTC (rev 3167) +++ trunk/OpenMPT/mptrack/Reporting.h 2013-11-10 12:48:22 UTC (rev 3168) @@ -34,34 +34,48 @@ protected: static UINT ShowNotification(const char *text, const char *caption, UINT flags, const CWnd *parent); + static UINT ShowNotification(const std::wstring &text, const std::wstring &caption, UINT flags, const CWnd *parent); public: // TODO Quick'n'dirty workaround for MsgBox(). Shouldn't be public. static UINT CustomNotification(const char *text, const char *caption, UINT flags, const CWnd *parent) { return ShowNotification(text, caption, flags, parent); }; + static UINT CustomNotification(const std::wstring &text, const std::wstring &caption, UINT flags, const CWnd *parent) { return ShowNotification(text, caption, flags, parent); }; // Show a simple notification static void Notification(const char *text, const CWnd *parent = nullptr); static void Notification(const char *text, const char *caption, const CWnd *parent = nullptr); + static void Notification(const std::wstring &text, const CWnd *parent = nullptr); + static void Notification(const std::wstring &text, const std::wstring &caption, const CWnd *parent = nullptr); // Show a simple information static void Information(const char *text, const CWnd *parent = nullptr); static void Information(const char *text, const char *caption, const CWnd *parent = nullptr); + static void Information(const std::wstring &text, const CWnd *parent = nullptr); + static void Information(const std::wstring &text, const std::wstring &caption, const CWnd *parent = nullptr); // Show a simple warning static void Warning(const char *text, const CWnd *parent = nullptr); static void Warning(const char *text, const char *caption, const CWnd *parent = nullptr); + static void Warning(const std::wstring &text, const CWnd *parent = nullptr); + static void Warning(const std::wstring &text, const std::wstring &caption, const CWnd *parent = nullptr); // Show an error box. static void Error(const char *text, const CWnd *parent = nullptr); static void Error(const char *text, const char *caption, const CWnd *parent = nullptr); + static void Error(const std::wstring &text, const CWnd *parent = nullptr); + static void Error(const std::wstring &text, const std::wstring &caption, const CWnd *parent = nullptr); // Show a confirmation dialog. static ConfirmAnswer Confirm(const char *text, bool showCancel = false, bool defaultNo = false, const CWnd *parent = nullptr); static ConfirmAnswer Confirm(const char *text, const char *caption, bool showCancel = false, bool defaultNo = false, const CWnd *parent = nullptr); + static ConfirmAnswer Confirm(const std::wstring &text, bool showCancel = false, bool defaultNo = false, const CWnd *parent = nullptr); + static ConfirmAnswer Confirm(const std::wstring &text, const std::wstring &caption, bool showCancel = false, bool defaultNo = false, const CWnd *parent = nullptr); // Show a confirmation dialog. static RetryAnswer RetryCancel(const char *text, const CWnd *parent = nullptr); static RetryAnswer RetryCancel(const char *text, const char *caption, const CWnd *parent = nullptr); + static RetryAnswer RetryCancel(const std::wstring &text, const CWnd *parent = nullptr); + static RetryAnswer RetryCancel(const std::wstring &text, const std::wstring &caption, const CWnd *parent = nullptr); }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-11-10 13:11:56
|
Revision: 3169 http://sourceforge.net/p/modplug/code/3169 Author: manxorist Date: 2013-11-10 13:11:40 +0000 (Sun, 10 Nov 2013) Log Message: ----------- [Ref] Convert CreateFileMenu signature to mpt::PathString (not complete yet). [Ref] Convert IsPathFileAvailable to mpt::PathString. Modified Paths: -------------- trunk/OpenMPT/mptrack/MPTrackUtil.cpp trunk/OpenMPT/mptrack/MPTrackUtil.h trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mainfrm.h trunk/OpenMPT/mptrack/Moddoc.cpp Modified: trunk/OpenMPT/mptrack/MPTrackUtil.cpp =================================================================== --- trunk/OpenMPT/mptrack/MPTrackUtil.cpp 2013-11-10 12:48:22 UTC (rev 3168) +++ trunk/OpenMPT/mptrack/MPTrackUtil.cpp 2013-11-10 13:11:40 UTC (rev 3169) @@ -71,7 +71,7 @@ } -bool Util::sdOs::IsPathFileAvailable(LPCTSTR pszFilePath, FileMode fm) +bool Util::sdOs::IsPathFileAvailable(const mpt::PathString &pszFilePath, FileMode fm) { - return (_taccess(pszFilePath, fm) == 0); + return (_waccess(pszFilePath.AsNative().c_str(), fm) == 0); } Modified: trunk/OpenMPT/mptrack/MPTrackUtil.h =================================================================== --- trunk/OpenMPT/mptrack/MPTrackUtil.h 2013-11-10 12:48:22 UTC (rev 3168) +++ trunk/OpenMPT/mptrack/MPTrackUtil.h 2013-11-10 13:11:40 UTC (rev 3169) @@ -30,7 +30,7 @@ { /// Checks whether file or folder exists and whether it has the given mode. enum FileMode {FileModeExists = 0, FileModeRead = 4, FileModeWrite = 2, FileModeReadWrite = 6}; - bool IsPathFileAvailable(LPCTSTR pszFilePath, FileMode fm); + bool IsPathFileAvailable(const mpt::PathString &pszFilePath, FileMode fm); }} // namespace Util::sdOs Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2013-11-10 12:48:22 UTC (rev 3168) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2013-11-10 13:11:40 UTC (rev 3169) @@ -108,8 +108,8 @@ UINT CMainFrame::m_nLastOptionsPage = 0; HHOOK CMainFrame::ghKbdHook = NULL; -std::vector<CString> CMainFrame::s_ExampleModulePaths; -std::vector<CString> CMainFrame::s_TemplateModulePaths; +std::vector<mpt::PathString> CMainFrame::s_ExampleModulePaths; +std::vector<mpt::PathString> CMainFrame::s_TemplateModulePaths; LONG CMainFrame::gnLVuMeter = 0; LONG CMainFrame::gnRVuMeter = 0; @@ -2100,16 +2100,16 @@ //------------------------------------------------------------------------- { const UINT nIdBegin = (bTemplateFile) ? ID_FILE_OPENTEMPLATE : ID_EXAMPLE_MODULES; - const std::vector<CString>& vecFilePaths = (bTemplateFile) ? s_TemplateModulePaths : s_ExampleModulePaths; + const std::vector<mpt::PathString>& vecFilePaths = (bTemplateFile) ? s_TemplateModulePaths : s_ExampleModulePaths; const UINT nIndex = nId - nIdBegin; if (nIndex < vecFilePaths.size()) { - const CString& sPath = vecFilePaths[nIndex]; + const mpt::PathString& sPath = vecFilePaths[nIndex]; const bool bAvailable = Util::sdOs::IsPathFileAvailable(sPath, Util::sdOs::FileModeRead); if (bAvailable) { - CDocument* pDoc = theApp.OpenDocumentFile(sPath, bTemplateFile ? FALSE : TRUE); + CDocument* pDoc = theApp.OpenDocumentFile(sPath.ToCString(), bTemplateFile ? FALSE : TRUE); if (pDoc != nullptr) { ASSERT(pDoc->IsKindOf(RUNTIME_CLASS(CModDoc)) == TRUE); @@ -2136,9 +2136,9 @@ const bool bExists = Util::sdOs::IsPathFileAvailable(sPath, Util::sdOs::FileModeExists); CString str; if (bExists) - AfxFormatString1(str, IDS_FILE_EXISTS_BUT_IS_NOT_READABLE, (LPCTSTR)sPath); + AfxFormatString1(str, IDS_FILE_EXISTS_BUT_IS_NOT_READABLE, (LPCTSTR)sPath.ToCString()); else - AfxFormatString1(str, IDS_FILE_DOES_NOT_EXIST, (LPCTSTR)sPath); + AfxFormatString1(str, IDS_FILE_DOES_NOT_EXIST, (LPCTSTR)sPath.ToCString()); Reporting::Notification(str); } } @@ -2514,8 +2514,8 @@ } -HMENU CMainFrame::CreateFileMenu(const size_t nMaxCount, std::vector<CString>& vPaths, const LPCTSTR pszFolderName, const uint16 nIdRangeBegin) -//--------------------------------------------------------------------------------------------------------------------------------------------- +HMENU CMainFrame::CreateFileMenu(const size_t nMaxCount, std::vector<mpt::PathString>& vPaths, const mpt::PathString &pszFolderName, const uint16 nIdRangeBegin) +//-------------------------------------------------------------------------------------------------------------------------------------------------------------- { vPaths.clear(); HMENU hMenu = ::CreatePopupMenu(); @@ -2529,14 +2529,14 @@ if (i == 1 && mpt::PathString::CompareNoCase(CTrackApp::GetAppDirPath(), theApp.GetConfigPath()) == 0) break; CFileFind fileFind; - CFixedStringT<CString, MAX_PATH> sPath; - sPath = (i == 0) ? CTrackApp::GetAppDirPath().ToCString() : theApp.GetConfigPath().ToCString(); + mpt::PathString sPath; + sPath = (i == 0) ? CTrackApp::GetAppDirPath() : theApp.GetConfigPath(); sPath += pszFolderName; if (Util::sdOs::IsPathFileAvailable(sPath, Util::sdOs::FileModeExists) == false) continue; - sPath += _T("*"); + sPath += MPT_PATHSTRING("*"); - BOOL bWorking = fileFind.FindFile(sPath); + BOOL bWorking = fileFind.FindFile(sPath.ToCString()); // Note: The order in which the example files appears in the menu is unspecified. while (bWorking && nAddCounter < nMaxCount) { @@ -2544,7 +2544,7 @@ const CString fn = fileFind.GetFileName(); if (fileFind.IsDirectory() == FALSE) { - vPaths.push_back(fileFind.GetFilePath()); + vPaths.push_back(mpt::PathString::FromCString(fileFind.GetFilePath())); AppendMenu(hMenu, MF_STRING, nIdRangeBegin + nAddCounter, fileFind.GetFileName()); ++nAddCounter; } @@ -2565,7 +2565,7 @@ { static_assert(nMaxItemsInExampleModulesMenu == ID_EXAMPLE_MODULES_LASTINRANGE - ID_EXAMPLE_MODULES + 1, "Make sure that there's a proper range for menu commands in resources."); - HMENU hMenu = CreateFileMenu(nMaxItemsInExampleModulesMenu, s_ExampleModulePaths, _T("ExampleSongs\\"), ID_EXAMPLE_MODULES); + HMENU hMenu = CreateFileMenu(nMaxItemsInExampleModulesMenu, s_ExampleModulePaths, MPT_PATHSTRING("ExampleSongs\\"), ID_EXAMPLE_MODULES); CMenu* const pMainMenu = GetMenu(); if (hMenu && pMainMenu && m_InputHandler) VERIFY(pMainMenu->ModifyMenu(ID_EXAMPLE_MODULES, MF_BYCOMMAND | MF_POPUP, (UINT_PTR)hMenu, m_InputHandler->GetMenuText(ID_EXAMPLE_MODULES))); @@ -2579,7 +2579,7 @@ { static_assert(nMaxItemsInTemplateModulesMenu == ID_FILE_OPENTEMPLATE_LASTINRANGE - ID_FILE_OPENTEMPLATE + 1, "Make sure that there's a proper range for menu commands in resources."); - HMENU hMenu = CreateFileMenu(nMaxItemsInTemplateModulesMenu, s_TemplateModulePaths, _T("TemplateModules\\"), ID_FILE_OPENTEMPLATE); + HMENU hMenu = CreateFileMenu(nMaxItemsInTemplateModulesMenu, s_TemplateModulePaths, MPT_PATHSTRING("TemplateModules\\"), ID_FILE_OPENTEMPLATE); CMenu* const pMainMenu = GetMenu(); CMenu* pFileMenu = (pMainMenu) ? pMainMenu->GetSubMenu(0) : nullptr; if (hMenu && pFileMenu && m_InputHandler) Modified: trunk/OpenMPT/mptrack/Mainfrm.h =================================================================== --- trunk/OpenMPT/mptrack/Mainfrm.h 2013-11-10 12:48:22 UTC (rev 3168) +++ trunk/OpenMPT/mptrack/Mainfrm.h 2013-11-10 13:11:40 UTC (rev 3169) @@ -400,7 +400,7 @@ /// [out] vPaths: Receives the full paths of the files added to the menu. /// [in] pszFolderName: Name of the folder (should end with \) /// [in] nIdRangeBegin: First ID for the menu item. - static HMENU CreateFileMenu(const size_t nMaxCount, std::vector<CString>& vPaths, const LPCTSTR pszFolderName, const uint16 nIdRangeBegin); + static HMENU CreateFileMenu(const size_t nMaxCount, std::vector<mpt::PathString>& vPaths, const mpt::PathString &pszFolderName, const uint16 nIdRangeBegin); // Player functions public: @@ -534,9 +534,9 @@ static const size_t nMaxItemsInTemplateModulesMenu = 50; /// Array of paths of example modules that are available from help menu. - static std::vector<CString> s_ExampleModulePaths; + static std::vector<mpt::PathString> s_ExampleModulePaths; /// Array of paths of template modules that are available from file menu. - static std::vector<CString> s_TemplateModulePaths; + static std::vector<mpt::PathString> s_TemplateModulePaths; }; Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2013-11-10 12:48:22 UTC (rev 3168) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2013-11-10 13:11:40 UTC (rev 3169) @@ -2888,19 +2888,19 @@ } // Generate file name candidate. - CString sName; + mpt::PathString sName; for(size_t i = 0; i<1000; ++i) { - sName.Format(_T("newTemplate%u."), i); - sName += m_SndFile.GetModSpecifications().fileExtension; - if (!Util::sdOs::IsPathFileAvailable(pszTemplateFolder + sName, Util::sdOs::FileModeExists)) + sName += MPT_PATHSTRING("newTemplate") + mpt::PathString::FromWide(StringifyW(i)); + sName += MPT_PATHSTRING(".") + mpt::PathString::FromUTF8(m_SndFile.GetModSpecifications().fileExtension); + if (!Util::sdOs::IsPathFileAvailable(templateFolder + sName, Util::sdOs::FileModeExists)) break; } // Ask file name from user. FileDialog dlg = SaveFileDialog() .DefaultExtension(m_SndFile.GetModSpecifications().fileExtension) - .DefaultFilename(std::string(sName)) + .DefaultFilename(sName) .ExtensionFilter(ModTypeToFilter(m_SndFile)) .WorkingDirectory(templateFolder); if(!dlg.Show()) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-11-10 13:42:12
|
Revision: 3170 http://sourceforge.net/p/modplug/code/3170 Author: manxorist Date: 2013-11-10 13:42:01 +0000 (Sun, 10 Nov 2013) Log Message: ----------- [Ref] Convert mod export to mpt::PathString. Modified Paths: -------------- trunk/OpenMPT/mptrack/Mod2wave.cpp trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/mod2wave.h Modified: trunk/OpenMPT/mptrack/Mod2wave.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mod2wave.cpp 2013-11-10 13:11:40 UTC (rev 3169) +++ trunk/OpenMPT/mptrack/Mod2wave.cpp 2013-11-10 13:42:01 UTC (rev 3170) @@ -866,23 +866,23 @@ UINT ok = IDOK, pos = 0; uint64 ullSamples = 0, ullMaxSamples; - if(!m_lpszFileName) + if(m_lpszFileName.empty()) { EndDialog(IDCANCEL); return; } float normalizePeak = 0.0f; - char *tempPath = _tempnam("", "OpenMPT_mod2wave"); - const std::string normalizeFileName = tempPath; + wchar_t *tempPath = _wtempnam(L"", L"OpenMPT_mod2wave"); + const mpt::PathString normalizeFileName = mpt::PathString::FromNative(tempPath); free(tempPath); mpt::fstream normalizeFile; if(m_Settings.Normalize) { - normalizeFile.open(normalizeFileName.c_str(), std::ios::binary | std::ios::in | std::ios::out | std::ios::trunc); + normalizeFile.open(normalizeFileName.AsNative().c_str(), std::ios::binary | std::ios::in | std::ios::out | std::ios::trunc); } - mpt::ofstream fileStream(m_lpszFileName, std::ios::binary | std::ios::trunc); + mpt::ofstream fileStream(m_lpszFileName.AsNative().c_str(), std::ios::binary | std::ios::trunc); if(!fileStream) { @@ -1202,7 +1202,7 @@ for(int retry=0; retry<10; retry++) { // stupid virus scanners - if(remove(normalizeFileName.c_str()) != EACCES) + if(DeleteFileW(normalizeFileName.AsNative().c_str()) != EACCES) { break; } Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2013-11-10 13:11:40 UTC (rev 3169) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2013-11-10 13:42:01 UTC (rev 3170) @@ -1657,16 +1657,11 @@ EncoderFactoryBase *encFactory = wsdlg.m_Settings.GetEncoderFactory(); - std::string extension = encFactory->GetTraits().fileExtension; + const std::string extension = encFactory->GetTraits().fileExtension; - TCHAR fname[_MAX_FNAME] = _T(""); - _splitpath(GetPathName(), NULL, NULL, fname, NULL); - strcat_s(fname, CountOf(fname), "."); - strcat_s(fname, CountOf(fname), extension.c_str()); - FileDialog dlg = SaveFileDialog() .DefaultExtension(extension) - .DefaultFilename(fname) + .DefaultFilename(mpt::PathString::FromCString(GetPathName()).GetFileName() + MPT_PATHSTRING(".") + mpt::PathString::FromUTF8(extension)) .ExtensionFilter(encFactory->GetTraits().fileDescription + " (*." + extension + ")|*." + extension + "||") .WorkingDirectory(TrackerDirectories::Instance().GetWorkingDirectory(DIR_EXPORT)); if(!dlg.Show()) return; @@ -1674,10 +1669,10 @@ // will set default dir here because there's no setup option for export dir yet (feel free to add one...) TrackerDirectories::Instance().SetDefaultDirectory(dlg.GetWorkingDirectory(), DIR_EXPORT, true); - char drive[_MAX_DRIVE], dir[_MAX_DIR], name[_MAX_FNAME], ext[_MAX_EXT]; - _splitpath(dlg.GetFirstFile().ToLocale().c_str(), drive, dir, name, ext); - const CString fileName = CString(drive) + CString(dir) + CString(name); - const CString fileExt = CString(ext); + mpt::PathString drive, dir, name, ext; + dlg.GetFirstFile().SplitPath(&drive, &dir, &name, &ext); + const mpt::PathString fileName = drive + dir + name; + const mpt::PathString fileExt = ext; // Saving as wave file @@ -1736,7 +1731,7 @@ for(int i = 0 ; i < nRenderPasses ; i++) { - CString thisName = fileName; + mpt::PathString thisName = fileName; char fileNameAdd[_MAX_FNAME] = ""; // Channel mode @@ -1792,7 +1787,7 @@ if(strcmp(fileNameAdd, "")) { SanitizeFilename(fileNameAdd); - thisName += CString(fileNameAdd); + thisName += mpt::PathString::FromLocale(fileNameAdd); } thisName += fileExt; Modified: trunk/OpenMPT/mptrack/mod2wave.h =================================================================== --- trunk/OpenMPT/mptrack/mod2wave.h 2013-11-10 13:11:40 UTC (rev 3169) +++ trunk/OpenMPT/mptrack/mod2wave.h 2013-11-10 13:42:01 UTC (rev 3170) @@ -124,16 +124,16 @@ public: const CWaveConvertSettings &m_Settings; CSoundFile &m_SndFile; - const char *m_lpszFileName; + mpt::PathString m_lpszFileName; DWORD m_dwFileLimit, m_dwSongLimit; bool m_bAbort, m_bGivePlugsIdleTime; public: - CDoWaveConvert(CSoundFile &sndFile, const char *fname, const CWaveConvertSettings &settings, CWnd *parent = NULL) + CDoWaveConvert(CSoundFile &sndFile, const mpt::PathString &filename, const CWaveConvertSettings &settings, CWnd *parent = NULL) : CDialog(IDD_PROGRESS, parent) , m_SndFile(sndFile) , m_Settings(settings) - , m_lpszFileName(fname) + , m_lpszFileName(filename) , m_bAbort(false) , m_dwFileLimit(0), m_dwSongLimit(0) { } 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-10 14:21:02
|
Revision: 3171 http://sourceforge.net/p/modplug/code/3171 Author: manxorist Date: 2013-11-10 14:20:52 +0000 (Sun, 10 Nov 2013) Log Message: ----------- [Ref] Replace some AfxFormatString with simple wide string concatenation so that message boxes containing unicode filenames are displayed correctly. Modified Paths: -------------- trunk/OpenMPT/mptrack/CommandSet.cpp trunk/OpenMPT/mptrack/Ctrl_seq.cpp trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/mptrack.rc trunk/OpenMPT/mptrack/resource.h Modified: trunk/OpenMPT/mptrack/CommandSet.cpp =================================================================== --- trunk/OpenMPT/mptrack/CommandSet.cpp 2013-11-10 13:42:01 UTC (rev 3170) +++ trunk/OpenMPT/mptrack/CommandSet.cpp 2013-11-10 14:20:52 UTC (rev 3171) @@ -1680,9 +1680,7 @@ mpt::ifstream fin(filename.AsNative().c_str()); if (fin.fail()) { - CString strMsg; - AfxFormatString1(strMsg, IDS_CANT_OPEN_KEYBINDING_FILE, filename.ToCString()); - Reporting::Warning(strMsg); + Reporting::Warning(L"Can't open keybindings file " + filename.ToWide() + L" for reading. Default keybindings will be used."); return false; } else Modified: trunk/OpenMPT/mptrack/Ctrl_seq.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_seq.cpp 2013-11-10 13:42:01 UTC (rev 3170) +++ trunk/OpenMPT/mptrack/Ctrl_seq.cpp 2013-11-10 14:20:52 UTC (rev 3171) @@ -1345,9 +1345,7 @@ CSoundFile &sndFile = m_pModDoc.GetrSoundFile(); if(nSeq == MAX_SEQUENCES + 2) { - CString strParam; strParam.Format(TEXT("%u: %s"), sndFile.Order.GetCurrentSequenceIndex(), (LPCTSTR)sndFile.Order.m_sName); - CString str; - AfxFormatString1(str, IDS_CONFIRM_SEQUENCE_DELETE, strParam); + std::wstring str = L"Delete sequence " + StringifyW(sndFile.Order.GetCurrentSequenceIndex()) + L": " + mpt::String::Decode(sndFile.Order.m_sName, mpt::CharsetLocale) + L"?"; if (Reporting::Confirm(str) == cnfYes) sndFile.Order.RemoveSequence(); else Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2013-11-10 13:42:01 UTC (rev 3170) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2013-11-10 14:20:52 UTC (rev 3171) @@ -2134,12 +2134,7 @@ else { const bool bExists = Util::sdOs::IsPathFileAvailable(sPath, Util::sdOs::FileModeExists); - CString str; - if (bExists) - AfxFormatString1(str, IDS_FILE_EXISTS_BUT_IS_NOT_READABLE, (LPCTSTR)sPath.ToCString()); - else - AfxFormatString1(str, IDS_FILE_DOES_NOT_EXIST, (LPCTSTR)sPath.ToCString()); - Reporting::Notification(str); + Reporting::Notification(L"The file '" + sPath.ToWide() + L"' " + (bExists ? L"exists but can't be read" : L"does not exist")); } } else Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2013-11-10 13:42:01 UTC (rev 3170) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2013-11-10 14:20:52 UTC (rev 3171) @@ -2869,15 +2869,11 @@ { // Create template folder if doesn't exist already. const mpt::PathString templateFolder = TrackerDirectories::Instance().GetDefaultDirectory(DIR_TEMPLATE_FILES_USER); - const CString templateFolderDummy = templateFolder.ToCString(); - const LPCTSTR pszTemplateFolder = templateFolderDummy; if (!PathIsDirectoryW(templateFolder.AsNative().c_str())) { if (!CreateDirectoryW(templateFolder.AsNative().c_str(), nullptr)) { - CString sErrMsg; - AfxFormatString1(sErrMsg, IDS_UNABLE_TO_CREATE_USER_TEMPLATE_FOLDER, pszTemplateFolder); - Reporting::Notification(sErrMsg); + Reporting::Notification(L"Error: Unable to create template folder '" + templateFolder.ToWide() + L"'"); return; } } Modified: trunk/OpenMPT/mptrack/mptrack.rc =================================================================== --- trunk/OpenMPT/mptrack/mptrack.rc 2013-11-10 13:42:01 UTC (rev 3170) +++ trunk/OpenMPT/mptrack/mptrack.rc 2013-11-10 14:20:52 UTC (rev 3171) @@ -2123,11 +2123,6 @@ 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_UNABLE_TO_CREATE_USER_TEMPLATE_FOLDER - """Error: Unable to create template folder '%1'""" - IDS_FILE_DOES_NOT_EXIST "The file '%1' does not exist" - IDS_FILE_EXISTS_BUT_IS_NOT_READABLE - "The file '%1' exists but can't be read" IDS_ERR_FILEOPEN "Unable to open file." IDS_ERR_FILETYPE "Unsupported file type" IDS_ERR_SAVEINS "Unable to save instrument" @@ -2439,12 +2434,9 @@ IDS_UNSUPPORTED_TUNING_DnD "For the time being Drag and Drop is only supported for tuning instances." IDS_OPERATION_FAIL "Operation failed." - IDS_CANT_OPEN_KEYBINDING_FILE - "Can't open keybindings file %1 for reading. Default keybindings will be used." IDS_UNABLE_TO_LOAD_KEYBINDINGS "Loading keybindings failed. The keyboard won't work properly." IDS_CANT_OPEN_FILE_FOR_WRITING "Can't open keybindings file for writing." - IDS_CONFIRM_SEQUENCE_DELETE "Delete sequence %1?" IDS_PATTERN_CLEANUP_UNAVAILABLE "Removing unused patterns is not available when using multiple sequences." IDS_SCL_IMPORT_FAIL_1 "Invalid numerator or denominator" Modified: trunk/OpenMPT/mptrack/resource.h =================================================================== --- trunk/OpenMPT/mptrack/resource.h 2013-11-10 13:42:01 UTC (rev 3170) +++ trunk/OpenMPT/mptrack/resource.h 2013-11-10 14:20:52 UTC (rev 3171) @@ -47,10 +47,8 @@ #define IDS_ERR_NO_TUNING_SELECTION 208 #define IDS_UNSUPPORTED_TUNING_DnD 209 #define IDS_OPERATION_FAIL 210 -#define IDS_CANT_OPEN_KEYBINDING_FILE 211 #define IDS_UNABLE_TO_LOAD_KEYBINDINGS 212 #define IDS_CANT_OPEN_FILE_FOR_WRITING 213 -#define IDS_CONFIRM_SEQUENCE_DELETE 214 #define IDS_PATTERN_CLEANUP_UNAVAILABLE 215 #define IDS_SCL_IMPORT_FAIL_1 216 #define IDS_SCL_IMPORT_FAIL_2 217 @@ -67,9 +65,6 @@ #define IDS_TUNING_IMPORT_SCL_FAILURE 228 #define IDS_TUNING_IMPORT_UNRECOGNIZED_FILE 229 #define IDS_SOUNDTOUCH_LOADFAILURE 230 -#define IDS_UNABLE_TO_CREATE_USER_TEMPLATE_FOLDER 231 -#define IDS_FILE_DOES_NOT_EXIST 232 -#define IDS_FILE_EXISTS_BUT_IS_NOT_READABLE 233 #define IDS_ERR_FILEOPEN 234 #define IDS_ERR_FILETYPE 235 #define IDS_ERR_SAVEINS 236 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-11-10 14:26:51
|
Revision: 3172 http://sourceforge.net/p/modplug/code/3172 Author: manxorist Date: 2013-11-10 14:26:38 +0000 (Sun, 10 Nov 2013) Log Message: ----------- [Ref] Fix 2 mpt::PathString warnings in CommandSet.cpp. Modified Paths: -------------- trunk/OpenMPT/mptrack/CommandSet.cpp trunk/OpenMPT/mptrack/CommandSet.h Modified: trunk/OpenMPT/mptrack/CommandSet.cpp =================================================================== --- trunk/OpenMPT/mptrack/CommandSet.cpp 2013-11-10 14:20:52 UTC (rev 3171) +++ trunk/OpenMPT/mptrack/CommandSet.cpp 2013-11-10 14:26:38 UTC (rev 3172) @@ -1541,8 +1541,8 @@ } -bool CCommandSet::LoadFile(std::istream& iStrm, const CString &filenameDescription) -//--------------------------------------------------------------------------------- +bool CCommandSet::LoadFile(std::istream& iStrm, const std::wstring &filenameDescription) +//-------------------------------------------------------------------------------------- { KeyCombination kc; CommandID cmd=kcNumCommands; @@ -1660,8 +1660,8 @@ } if(!errText.IsEmpty()) { - CString err = TEXT("The following problems have been encountered while trying to load the key binding file ") + filenameDescription + TEXT(":\n"); - err += errText; + std::wstring err = L"The following problems have been encountered while trying to load the key binding file " + filenameDescription + L":\n"; + err += mpt::String::FromCString(errText); Reporting::Warning(err); } @@ -1684,7 +1684,7 @@ return false; } else - return LoadFile(fin, filename.ToCString()); + return LoadFile(fin, filename.ToWide()); } @@ -1698,7 +1698,7 @@ if (LoadResource(MAKEINTRESOURCE(IDR_DEFAULT_KEYBINDINGS), TEXT("KEYBINDINGS"), pData, nSize, hglob) != nullptr) { std::istringstream iStrm(std::string(pData, nSize)); - success = LoadFile(iStrm, TEXT("\"executable resource\"")); + success = LoadFile(iStrm, L"\"executable resource\""); FreeResource(hglob); } return success; Modified: trunk/OpenMPT/mptrack/CommandSet.h =================================================================== --- trunk/OpenMPT/mptrack/CommandSet.h 2013-11-10 14:20:52 UTC (rev 3171) +++ trunk/OpenMPT/mptrack/CommandSet.h 2013-11-10 14:26:38 UTC (rev 3172) @@ -1265,7 +1265,7 @@ void GenKeyMap(KeyMap &km); // Generate a keymap from this command set bool SaveFile(const mpt::PathString &filename); bool LoadFile(const mpt::PathString &filename); - bool LoadFile(std::istream& iStrm, const CString &filenameDescription); + bool LoadFile(std::istream& iStrm, const std::wstring &filenameDescription); bool LoadDefaultKeymap(); void UpgradeKeymap(CCommandSet *pCommands, int oldVersion); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-11-10 15:25:09
|
Revision: 3173 http://sourceforge.net/p/modplug/code/3173 Author: manxorist Date: 2013-11-10 15:25:02 +0000 (Sun, 10 Nov 2013) Log Message: ----------- [Ref] Convert struct MIDILIBSTRUCT to mpt::PathString. Modified Paths: -------------- trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/Mptrack.h trunk/OpenMPT/mptrack/View_tre.cpp Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2013-11-10 14:26:38 UTC (rev 3172) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2013-11-10 15:25:02 UTC (rev 3173) @@ -247,7 +247,7 @@ if (m_SndFile.m_nType == MOD_TYPE_MID) { CDLSBank *pCachedBank = NULL, *pEmbeddedBank = NULL; - CHAR szCachedBankFile[_MAX_PATH] = ""; + mpt::PathString szCachedBankFile = MPT_PATHSTRING(""); if (CDLSBank::IsDLSBank(mpt::PathString::FromCString(lpszPathName))) { @@ -260,7 +260,7 @@ // Scan Instruments if (lpMidiLib) for (INSTRUMENTINDEX nIns = 1; nIns <= m_SndFile.m_nInstruments; nIns++) if (m_SndFile.Instruments[nIns]) { - const char *pszMidiMapName; + mpt::PathString pszMidiMapName; ModInstrument *pIns = m_SndFile.Instruments[nIns]; UINT nMidiCode; BOOL bEmbedded = FALSE; @@ -296,22 +296,22 @@ pIns = m_SndFile.Instruments[nIns]; // Reset pIns because ExtractInstrument may delete the previous value. } } - if ((pszMidiMapName) && (pszMidiMapName[0]) && (!bEmbedded)) + if((!pszMidiMapName.empty()) && (!bEmbedded)) { // Load From DLS Bank - if (CDLSBank::IsDLSBank(mpt::PathString::FromLocale(pszMidiMapName))) + if (CDLSBank::IsDLSBank(pszMidiMapName)) { CDLSBank *pDLSBank = NULL; - if ((pCachedBank) && (!lstrcmpi(szCachedBankFile, pszMidiMapName))) + if ((pCachedBank) && (!mpt::PathString::CompareNoCase(szCachedBankFile, pszMidiMapName))) { pDLSBank = pCachedBank; } else { if (pCachedBank) delete pCachedBank; pCachedBank = new CDLSBank; - strcpy(szCachedBankFile, pszMidiMapName); - if (pCachedBank->Open(mpt::PathString::FromLocale(pszMidiMapName))) pDLSBank = pCachedBank; + szCachedBankFile = pszMidiMapName; + if (pCachedBank->Open(pszMidiMapName)) pDLSBank = pCachedBank; } if (pDLSBank) { @@ -337,19 +337,19 @@ } else { // Load from Instrument or Sample file - CHAR szName[_MAX_FNAME], szExt[_MAX_EXT]; CMappedFile f; - if(f.Open(mpt::PathString::FromLocale(pszMidiMapName))) + if(f.Open(pszMidiMapName)) { FileReader file = f.GetFile(); if(file.IsValid()) { m_SndFile.ReadInstrumentFromFile(nIns, file, false); - _splitpath(pszMidiMapName, NULL, NULL, szName, szExt); - strncat(szName, szExt, sizeof(szName)); + mpt::PathString szName, szExt; + pszMidiMapName.SplitPath(nullptr, nullptr, &szName, &szExt); + szName += szExt; pIns = m_SndFile.Instruments[nIns]; - if (!pIns->filename[0]) mpt::String::Copy(pIns->filename, szName); + if (!pIns->filename[0]) mpt::String::Copy(pIns->filename, szName.ToLocale().c_str()); if (!pIns->name[0]) { if (nMidiCode < 128) Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2013-11-10 14:26:38 UTC (rev 3172) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2013-11-10 15:25:02 UTC (rev 3173) @@ -313,7 +313,6 @@ { glpMidiLibrary = new MIDILIBSTRUCT; if (!glpMidiLibrary) return FALSE; - MemsetZero(*glpMidiLibrary); } if (CDLSBank::IsDLSBank(filename)) @@ -332,18 +331,14 @@ { for (UINT iIns=0; iIns<256; iIns++) { - if ((bReplaceAll) || (!glpMidiLibrary->MidiMap[iIns]) || (!glpMidiLibrary->MidiMap[iIns][0])) + if((bReplaceAll) || glpMidiLibrary->MidiMap[iIns].empty()) { DWORD dwProgram = (iIns < 128) ? iIns : 0xFF; DWORD dwKey = (iIns < 128) ? 0xFF : iIns & 0x7F; DWORD dwBank = (iIns < 128) ? 0 : F_INSTRUMENT_DRUMS; if (dlsbank.FindInstrument((iIns < 128) ? FALSE : TRUE, dwBank, dwProgram, dwKey)) { - if (!glpMidiLibrary->MidiMap[iIns]) - { - if ((glpMidiLibrary->MidiMap[iIns] = new CHAR[_MAX_PATH]) == NULL) break; - } - strcpy(glpMidiLibrary->MidiMap[iIns], filename.ToLocale().c_str()); + glpMidiLibrary->MidiMap[iIns] = filename; } } } @@ -358,56 +353,59 @@ BOOL CTrackApp::ImportMidiConfig(SettingsContainer &file) //------------------------------------------------------- { - TCHAR szFileName[_MAX_PATH], s[_MAX_PATH], szUltraSndPath[_MAX_PATH]; + TCHAR s[_MAX_PATH]; + mpt::PathString UltraSndPath; if (!glpMidiLibrary) { glpMidiLibrary = new MIDILIBSTRUCT; if (!glpMidiLibrary) return FALSE; - MemsetZero(*glpMidiLibrary); } - mpt::String::Copy(szUltraSndPath, file.Read<std::string>("Ultrasound", "PatchDir", "")); - if (!strcmp(szUltraSndPath, _T(".\\"))) szUltraSndPath[0] = 0; - if (!szUltraSndPath[0]) GetCurrentDirectory(CountOf(szUltraSndPath), szUltraSndPath); + UltraSndPath = file.Read<mpt::PathString>("Ultrasound", "PatchDir", mpt::PathString()); + if(UltraSndPath == MPT_PATHSTRING(".\\")) UltraSndPath = mpt::PathString(); + if(UltraSndPath.empty()) + { + WCHAR curDir[MAX_PATH]; + GetCurrentDirectoryW(CountOf(curDir), curDir); + UltraSndPath = mpt::PathString::FromNative(curDir); + } for (UINT iMidi=0; iMidi<256; iMidi++) { - szFileName[0] = 0; + mpt::PathString filename; wsprintf(s, (iMidi < 128) ? _T("Midi%d") : _T("Perc%d"), iMidi & 0x7f); - mpt::String::Copy(szFileName, file.Read<std::string>("Midi Library", s, "")); + filename = file.Read<mpt::PathString>("Midi Library", s, mpt::PathString()); // Check for ULTRASND.INI - if (!szFileName[0]) + if(filename.empty()) { LPCSTR pszSection = (iMidi < 128) ? _T("Melodic Patches") : _T("Drum Patches"); wsprintf(s, _T("%d"), iMidi & 0x7f); - mpt::String::Copy(szFileName, file.Read<std::string>(pszSection, s, "")); - if (!szFileName[0]) + filename = file.Read<mpt::PathString>(pszSection, s, mpt::PathString()); + if(filename.empty()) { pszSection = (iMidi < 128) ? _T("Melodic Bank 0") : _T("Drum Bank 0"); - mpt::String::Copy(szFileName, file.Read<std::string>(pszSection, s, "")); + filename = file.Read<mpt::PathString>(pszSection, s, mpt::PathString()); } - if (szFileName[0]) + if(!filename.empty()) { - s[0] = 0; - if (szUltraSndPath[0]) + mpt::PathString tmp; + if(!UltraSndPath.empty()) { - strcpy(s, szUltraSndPath); - int len = strlen(s)-1; - if ((len) && (s[len-1] != '\\')) strcat(s, _T("\\")); + tmp = UltraSndPath; + if(!tmp.HasTrailingSlash()) + { + tmp += MPT_PATHSTRING("\\"); + } } - _tcsncat(s, szFileName, CountOf(s)); - _tcsncat(s, ".pat", CountOf(s)); - _tcscpy(szFileName, s); + tmp += filename; + tmp += MPT_PATHSTRING(".pat"); + filename = tmp; } } - if (szFileName[0]) + if(!filename.empty()) { - if (!glpMidiLibrary->MidiMap[iMidi]) - { - if ((glpMidiLibrary->MidiMap[iMidi] = new TCHAR[_MAX_PATH]) == nullptr) return FALSE; - } - theApp.RelativePathToAbsolute(szFileName); - _tcscpy(glpMidiLibrary->MidiMap[iMidi], szFileName); + filename = theApp.RelativePathToAbsolute(filename); + glpMidiLibrary->MidiMap[iMidi] = filename; } } return FALSE; @@ -425,23 +423,23 @@ BOOL CTrackApp::ExportMidiConfig(SettingsContainer &file) //------------------------------------------------------- { - TCHAR szFileName[_MAX_PATH], s[128]; + CHAR s[128]; if (!glpMidiLibrary) return FALSE; - for(size_t iMidi = 0; iMidi < 256; iMidi++) if (glpMidiLibrary->MidiMap[iMidi]) + for(size_t iMidi = 0; iMidi < 256; iMidi++) if (!glpMidiLibrary->MidiMap[iMidi].empty()) { if (iMidi < 128) wsprintf(s, _T("Midi%d"), iMidi); else wsprintf(s, _T("Perc%d"), iMidi & 0x7F); - strcpy(szFileName, glpMidiLibrary->MidiMap[iMidi]); + mpt::PathString szFileName = glpMidiLibrary->MidiMap[iMidi]; - if(szFileName[0]) + if(!szFileName.empty()) { if(theApp.IsPortableMode()) theApp.AbsolutePathToRelative(szFileName); - file.Write<std::string>("Midi Library", s, szFileName); + file.Write<mpt::PathString>("Midi Library", s, szFileName); } } return TRUE; @@ -948,13 +946,6 @@ if (glpMidiLibrary) { ExportMidiConfig(theApp.GetSettings()); - for (UINT iMidi=0; iMidi<256; iMidi++) - { - if (glpMidiLibrary->MidiMap[iMidi]) - { - delete[] glpMidiLibrary->MidiMap[iMidi]; - } - } delete glpMidiLibrary; glpMidiLibrary = NULL; } Modified: trunk/OpenMPT/mptrack/Mptrack.h =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.h 2013-11-10 14:26:38 UTC (rev 3172) +++ trunk/OpenMPT/mptrack/Mptrack.h 2013-11-10 15:25:02 UTC (rev 3173) @@ -41,7 +41,7 @@ typedef struct MIDILIBSTRUCT { - LPTSTR MidiMap[128*2]; // 128 instruments + 128 percussions + mpt::PathString MidiMap[128*2]; // 128 instruments + 128 percussions } MIDILIBSTRUCT, *LPMIDILIBSTRUCT; Modified: trunk/OpenMPT/mptrack/View_tre.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_tre.cpp 2013-11-10 14:26:38 UTC (rev 3172) +++ trunk/OpenMPT/mptrack/View_tre.cpp 2013-11-10 15:25:02 UTC (rev 3173) @@ -411,9 +411,9 @@ DWORD dwImage = IMAGE_NOINSTRUMENT; wsprintf(s, "%u: %s", iMidi, szMidiProgramNames[iMidi]); const LPARAM param = (MODITEM_MIDIINSTRUMENT << MIDILIB_SHIFT) | iMidi; - if ((lpMidiLib) && (lpMidiLib->MidiMap[iMidi]) && (lpMidiLib->MidiMap[iMidi][0])) + if((lpMidiLib) && (!lpMidiLib->MidiMap[iMidi].empty())) { - _splitpath(lpMidiLib->MidiMap[iMidi], NULL, NULL, szName, szExt); + _splitpath(lpMidiLib->MidiMap[iMidi].ToLocale().c_str(), NULL, NULL, szName, szExt); strncat(s, ": ", sizeof(s)); s[sizeof(s)-1] = 0; strncat(s, szName, sizeof(s)); @@ -447,9 +447,9 @@ DWORD dwImage = IMAGE_NOSAMPLE; wsprintf(s, "%s: %s", szDefaultNoteNames[iPerc], szMidiPercussionNames[iPerc-24]); const LPARAM param = (MODITEM_MIDIPERCUSSION << MIDILIB_SHIFT) | iPerc; - if ((lpMidiLib) && (lpMidiLib->MidiMap[iPerc|0x80]) && (lpMidiLib->MidiMap[iPerc|0x80][0])) + if((lpMidiLib) && (!lpMidiLib->MidiMap[iPerc|0x80].empty())) { - _splitpath(lpMidiLib->MidiMap[iPerc|0x80], NULL, NULL, szName, szExt); + _splitpath(lpMidiLib->MidiMap[iPerc|0x80].ToLocale().c_str(), NULL, NULL, szName, szExt); strncat(s, ": ", sizeof(s)); mpt::String::SetNullTerminator(s); strncat(s, szName, sizeof(s)); @@ -1313,10 +1313,10 @@ case MODITEM_MIDIINSTRUMENT: { LPMIDILIBSTRUCT lpMidiLib = CTrackApp::GetMidiLibrary(); - if ((lpMidiLib) && (modItemID < 256) && (lpMidiLib->MidiMap[modItemID])) + if((lpMidiLib) && (modItemID < 256) && (!lpMidiLib->MidiMap[modItemID].empty())) { CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); - if (pMainFrm) pMainFrm->PlaySoundFile(mpt::PathString::FromLocale(lpMidiLib->MidiMap[modItemID]), static_cast<ModCommand::NOTE>(nParam)); + if (pMainFrm) pMainFrm->PlaySoundFile(lpMidiLib->MidiMap[modItemID], static_cast<ModCommand::NOTE>(nParam)); } } return TRUE; @@ -1357,11 +1357,7 @@ LPMIDILIBSTRUCT lpMidiLib = CTrackApp::GetMidiLibrary(); if ((lpMidiLib) && (nIns < 128)) { - if (!lpMidiLib->MidiMap[nIns]) - { - if ((lpMidiLib->MidiMap[nIns] = new TCHAR[_MAX_PATH]) == NULL) return FALSE; - } - strcpy(lpMidiLib->MidiMap[nIns], lpszFileName); + lpMidiLib->MidiMap[nIns] = mpt::PathString::FromCString(lpszFileName); RefreshMidiLibrary(); return TRUE; } @@ -1376,11 +1372,7 @@ if ((lpMidiLib) && (nPerc < 128)) { UINT nIns = nPerc | 0x80; - if (!lpMidiLib->MidiMap[nIns]) - { - if ((lpMidiLib->MidiMap[nIns] = new TCHAR[_MAX_PATH]) == NULL) return FALSE; - } - strcpy(lpMidiLib->MidiMap[nIns], lpszFileName); + lpMidiLib->MidiMap[nIns] = mpt::PathString::FromCString(lpszFileName); RefreshMidiLibrary(); return TRUE; } @@ -1980,9 +1972,9 @@ case MODITEM_MIDIINSTRUMENT: { LPMIDILIBSTRUCT lpMidiLib = CTrackApp::GetMidiLibrary(); - if ((lpMidiLib) && (lpMidiLib->MidiMap[pdropinfo->dwDropItem&0xFF])) + if((lpMidiLib) && (!lpMidiLib->MidiMap[pdropinfo->dwDropItem&0xFF].empty())) { - strcpy(pszFullPath, lpMidiLib->MidiMap[pdropinfo->dwDropItem&0xFF]); + strcpy(pszFullPath, lpMidiLib->MidiMap[pdropinfo->dwDropItem&0xFF].ToLocale().c_str()); pdropinfo->dwDropType = DRAGONDROP_MIDIINSTR; pdropinfo->lDropParam = (LPARAM)pszFullPath; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |