From: <sag...@us...> - 2014-02-23 01:11:30
|
Revision: 3756 http://sourceforge.net/p/modplug/code/3756 Author: saga-games Date: 2014-02-23 01:11:19 +0000 (Sun, 23 Feb 2014) Log Message: ----------- [Imp] Cloning and moving plugin slots allows to move / clone the entire plugin chain now. [Mod] OpenMPT: Version is now 1.22.07.24 Modified Paths: -------------- trunk/OpenMPT/common/versionNumber.h trunk/OpenMPT/mptrack/MoveFXSlotDialog.cpp trunk/OpenMPT/mptrack/MoveFXSlotDialog.h trunk/OpenMPT/mptrack/View_gen.cpp trunk/OpenMPT/mptrack/mptrack.rc Modified: trunk/OpenMPT/common/versionNumber.h =================================================================== --- trunk/OpenMPT/common/versionNumber.h 2014-02-22 23:47:25 UTC (rev 3755) +++ trunk/OpenMPT/common/versionNumber.h 2014-02-23 01:11:19 UTC (rev 3756) @@ -17,7 +17,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 22 #define VER_MINOR 07 -#define VER_MINORMINOR 23 +#define VER_MINORMINOR 24 //Version string. For example "1.17.02.28" #define MPT_VERSION_STR VER_STRINGIZE(VER_MAJORMAJOR) "." VER_STRINGIZE(VER_MAJOR) "." VER_STRINGIZE(VER_MINOR) "." VER_STRINGIZE(VER_MINORMINOR) Modified: trunk/OpenMPT/mptrack/MoveFXSlotDialog.cpp =================================================================== --- trunk/OpenMPT/mptrack/MoveFXSlotDialog.cpp 2014-02-22 23:47:25 UTC (rev 3755) +++ trunk/OpenMPT/mptrack/MoveFXSlotDialog.cpp 2014-02-23 01:11:19 UTC (rev 3756) @@ -13,10 +13,20 @@ #include "MoveFXSlotDialog.h" -CMoveFXSlotDialog::CMoveFXSlotDialog(CWnd *pParent, PLUGINDEX currentSlot, const std::vector<PLUGINDEX> &emptySlots, PLUGINDEX defaultIndex, bool clone) : +void CMoveFXSlotDialog::DoDataExchange(CDataExchange* pDX) +//-------------------------------------------------------- +{ + CDialog::DoDataExchange(pDX); + DDX_Control(pDX, IDC_COMBO1, m_CbnEmptySlots); + DDX_Control(pDX, IDC_EDIT1, m_EditPrompt); +} + + +CMoveFXSlotDialog::CMoveFXSlotDialog(CWnd *pParent, PLUGINDEX currentSlot, const std::vector<PLUGINDEX> &emptySlots, PLUGINDEX defaultIndex, bool clone, bool hasChain) : CDialog(CMoveFXSlotDialog::IDD, pParent), m_nDefaultSlot(defaultIndex), - m_EmptySlots(emptySlots) + m_EmptySlots(emptySlots), + moveChain(hasChain) { if(clone) { @@ -30,23 +40,6 @@ } -void CMoveFXSlotDialog::DoDataExchange(CDataExchange* pDX) -//-------------------------------------------------------- -{ - CDialog::DoDataExchange(pDX); - DDX_Control(pDX, IDC_COMBO1, m_CbnEmptySlots); - DDX_Control(pDX, IDC_EDIT1, m_EditPrompt); -} - - -void CMoveFXSlotDialog::OnOK() -//---------------------------- -{ - m_nToSlot = static_cast<PLUGINDEX>(m_CbnEmptySlots.GetItemData(m_CbnEmptySlots.GetCurSel())); - CDialog::OnOK(); -} - - BOOL CMoveFXSlotDialog::OnInitDialog() //------------------------------------ { @@ -67,7 +60,7 @@ for(size_t nSlot = 0; nSlot < m_EmptySlots.size(); nSlot++) { slotText.Format("FX%d", m_EmptySlots[nSlot] + 1); - m_CbnEmptySlots.SetItemData(m_CbnEmptySlots.AddString(slotText), m_EmptySlots[nSlot]); + m_CbnEmptySlots.SetItemData(m_CbnEmptySlots.AddString(slotText), nSlot); if(m_EmptySlots[nSlot] >= m_nDefaultSlot && !foundDefault) { defaultSlot = nSlot; @@ -76,5 +69,17 @@ } m_CbnEmptySlots.SetCurSel(defaultSlot); + GetDlgItem(IDC_CHECK1)->EnableWindow(moveChain ? TRUE : FALSE); + CheckDlgButton(IDC_CHECK1, moveChain ? BST_CHECKED : BST_UNCHECKED); + return TRUE; } + + +void CMoveFXSlotDialog::OnOK() +//---------------------------- +{ + m_nToSlot = m_CbnEmptySlots.GetItemData(m_CbnEmptySlots.GetCurSel()); + moveChain = IsDlgButtonChecked(IDC_CHECK1) != BST_UNCHECKED; + CDialog::OnOK(); +} \ No newline at end of file Modified: trunk/OpenMPT/mptrack/MoveFXSlotDialog.h =================================================================== --- trunk/OpenMPT/mptrack/MoveFXSlotDialog.h 2014-02-22 23:47:25 UTC (rev 3755) +++ trunk/OpenMPT/mptrack/MoveFXSlotDialog.h 2014-02-23 01:11:19 UTC (rev 3756) @@ -16,15 +16,19 @@ const std::vector<PLUGINDEX> &m_EmptySlots; CString m_csPrompt, m_csTitle; CEdit m_EditPrompt; - PLUGINDEX m_nDefaultSlot, m_nToSlot; + size_t m_nToSlot; + PLUGINDEX m_nDefaultSlot; + bool moveChain; CComboBox m_CbnEmptySlots; enum { IDD = IDD_MOVEFXSLOT }; public: - CMoveFXSlotDialog(CWnd *pParent, PLUGINDEX currentSlot, const std::vector<PLUGINDEX> &emptySlots, PLUGINDEX defaultIndex, bool clone); - PLUGINDEX GetSlot() const { return m_nToSlot; } + CMoveFXSlotDialog(CWnd *pParent, PLUGINDEX currentSlot, const std::vector<PLUGINDEX> &emptySlots, PLUGINDEX defaultIndex, bool clone, bool hasChain); + PLUGINDEX GetSlot() const { return m_EmptySlots[m_nToSlot]; } + size_t GetSlotIndex() const { return m_nToSlot; } + bool DoMoveChain() const { return moveChain; } protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support Modified: trunk/OpenMPT/mptrack/View_gen.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_gen.cpp 2014-02-22 23:47:25 UTC (rev 3755) +++ trunk/OpenMPT/mptrack/View_gen.cpp 2014-02-23 01:11:19 UTC (rev 3756) @@ -1169,28 +1169,49 @@ void CViewGlobals::OnMovePlugToSlot() //----------------------------------- { + if(GetCurrentPlugin() == nullptr) + { + return; + } + // If any plugin routes its output to the current plugin, we shouldn't try to move it before that plugin... PLUGINDEX defaultIndex = 0; - const CSoundFile *pSndFile = GetDocument() ? (GetDocument()->GetSoundFile()) : nullptr; - if(pSndFile) + CSoundFile &sndFile = GetDocument()->GetrSoundFile(); + for(PLUGINDEX i = 0; i < m_nCurrentPlugin; i++) { - for(PLUGINDEX i = 0; i < m_nCurrentPlugin; i++) + if(sndFile.m_MixPlugins[i].GetOutputPlugin() == m_nCurrentPlugin) { - if(pSndFile->m_MixPlugins[i].GetOutputPlugin() == m_nCurrentPlugin) - { - defaultIndex = i + 1; - } + defaultIndex = i + 1; } } std::vector<PLUGINDEX> emptySlots; BuildEmptySlotList(emptySlots); - CMoveFXSlotDialog dlg(this, m_nCurrentPlugin, emptySlots, defaultIndex, false); + CMoveFXSlotDialog dlg(this, m_nCurrentPlugin, emptySlots, defaultIndex, false, !sndFile.m_MixPlugins[m_nCurrentPlugin].IsOutputToMaster()); if(dlg.DoModal() == IDOK) { - MovePlug(m_nCurrentPlugin, dlg.GetSlot()); + size_t toIndex = dlg.GetSlotIndex(); + do + { + const SNDMIXPLUGIN &curPlugin = sndFile.m_MixPlugins[m_nCurrentPlugin]; + SNDMIXPLUGIN &newPlugin = sndFile.m_MixPlugins[emptySlots[toIndex]]; + const PLUGINDEX nextPlugin = curPlugin.GetOutputPlugin(); + + MovePlug(m_nCurrentPlugin, emptySlots[toIndex]); + + if(nextPlugin == PLUGINDEX_INVALID || toIndex == emptySlots.size() - 1) + { + break; + } + + m_nCurrentPlugin = nextPlugin; + toIndex++; + + newPlugin.SetOutputPlugin(emptySlots[toIndex]); + } while(dlg.DoMoveChain()); + m_CbnPlugin.SetCurSel(dlg.GetSlot()); OnPluginChanged(); } @@ -1372,42 +1393,64 @@ } +static void ClonePlugin(const SNDMIXPLUGIN &curPlugin, SNDMIXPLUGIN &newPlugin) +//----------------------------------------------------------------------------- +{ + CVstPlugin *curVstPlug = static_cast<CVstPlugin *>(curPlugin.pMixPlugin); + newPlugin.Destroy(); + MemCopy(newPlugin.Info, curPlugin.Info); + if(theApp.GetPluginManager()->CreateMixPlugin(newPlugin, curVstPlug->GetSoundFile())) + { + CVstPlugin *newVstPlug = static_cast<CVstPlugin *>(newPlugin.pMixPlugin); + newVstPlug->SetCurrentProgram(curVstPlug->GetCurrentProgram()); + + std::ostringstream f(std::ios::out | std::ios::binary); + if(VSTPresets::SaveFile(f, *curVstPlug, false)) + { + const std::string data = f.str(); + FileReader file(data.c_str(), data.length()); + VSTPresets::LoadFile(file, *newVstPlug); + } + } +} + + void CViewGlobals::OnClonePlug() //------------------------------ { - if(GetCurrentPlugin() == nullptr || GetDocument() == nullptr) + if(GetCurrentPlugin() == nullptr) { - MessageBeep(MB_ICONEXCLAMATION); return; } + CSoundFile &sndFile = GetDocument()->GetrSoundFile(); + std::vector<PLUGINDEX> emptySlots; BuildEmptySlotList(emptySlots); - CMoveFXSlotDialog dlg(this, m_nCurrentPlugin, emptySlots, 0, true); + CMoveFXSlotDialog dlg(this, m_nCurrentPlugin, emptySlots, 0, true, !sndFile.m_MixPlugins[m_nCurrentPlugin].IsOutputToMaster()); if(dlg.DoModal() == IDOK) { - CSoundFile &sndFile = GetDocument()->GetrSoundFile(); - const SNDMIXPLUGIN &curPlugin = sndFile.m_MixPlugins[m_nCurrentPlugin]; - SNDMIXPLUGIN &newPlugin = sndFile.m_MixPlugins[dlg.GetSlot()]; - - newPlugin.Destroy(); - MemCopy(newPlugin.Info, curPlugin.Info); - if(theApp.GetPluginManager()->CreateMixPlugin(newPlugin, sndFile)) + size_t toIndex = dlg.GetSlotIndex(); + do { - CVstPlugin *vstPlug = static_cast<CVstPlugin *>(newPlugin.pMixPlugin); - vstPlug->SetCurrentProgram(GetCurrentPlugin()->GetCurrentProgram()); + const SNDMIXPLUGIN &curPlugin = sndFile.m_MixPlugins[m_nCurrentPlugin]; + SNDMIXPLUGIN &newPlugin = sndFile.m_MixPlugins[emptySlots[toIndex]]; - std::ostringstream f(std::ios::out | std::ios::binary); - if(VSTPresets::SaveFile(f, *GetCurrentPlugin(), false)) + ClonePlugin(curPlugin, newPlugin); + + if(curPlugin.IsOutputToMaster() || toIndex == emptySlots.size() - 1) { - const std::string data = f.str(); - FileReader file(data.c_str(), data.length()); - VSTPresets::LoadFile(file, *vstPlug); + break; } - } + m_nCurrentPlugin = curPlugin.GetOutputPlugin(); + toIndex++; + + newPlugin.SetOutputPlugin(emptySlots[toIndex]); + } while(dlg.DoMoveChain()); + m_CbnPlugin.SetCurSel(dlg.GetSlot()); OnPluginChanged(); } Modified: trunk/OpenMPT/mptrack/mptrack.rc =================================================================== --- trunk/OpenMPT/mptrack/mptrack.rc 2014-02-22 23:47:25 UTC (rev 3755) +++ trunk/OpenMPT/mptrack/mptrack.rc 2014-02-23 01:11:19 UTC (rev 3756) @@ -2572,15 +2572,16 @@ SCROLLBAR IDC_SCROLLBAR1,317,7,12,233,SBS_VERT | WS_DISABLED | WS_TABSTOP END -IDD_MOVEFXSLOT DIALOGEX 0, 0, 133, 78 +IDD_MOVEFXSLOT DIALOGEX 0, 0, 133, 87 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Dialog" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN - DEFPUSHBUTTON "OK",IDOK,76,59,50,14 - PUSHBUTTON "Cancel",IDCANCEL,7,59,50,14 - COMBOBOX IDC_COMBO1,42,38,48,172,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - EDITTEXT IDC_EDIT1,7,14,119,19,ES_CENTER | ES_MULTILINE | ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + DEFPUSHBUTTON "OK",IDOK,78,66,50,14 + PUSHBUTTON "Cancel",IDCANCEL,6,66,50,14 + COMBOBOX IDC_COMBO1,42,30,48,172,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + EDITTEXT IDC_EDIT1,6,6,120,19,ES_CENTER | ES_MULTILINE | ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + CONTROL "Move plugin chain if possible",IDC_CHECK1,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,6,48,120,12 END IDD_CONTROL_GRAPH DIALOGEX 0, 0, 424, 145 @@ -2672,7 +2673,7 @@ LEFTMARGIN, 7 RIGHTMARGIN, 126 TOPMARGIN, 7 - BOTTOMMARGIN, 73 + BOTTOMMARGIN, 82 END IDD_CONTROL_GRAPH, DIALOG This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |