From: <rel...@us...> - 2009-08-26 20:40:41
|
Revision: 344 http://modplug.svn.sourceforge.net/modplug/?rev=344&view=rev Author: relabsoluness Date: 2009-08-26 20:40:27 +0000 (Wed, 26 Aug 2009) Log Message: ----------- [New] MIDI mapping: Editing a plug param in its editor while holding shift key will now open MIDI mapping dialog. [Fix] MIDI mapping: Some minor tweaks and fixes to the MIDI mapping dialog. [Fix] Pattern tab: Fixed possible crash occurring if echo pattern in echo paste doesn't exist. Modified Paths: -------------- trunk/OpenMPT/mptrack/MIDIMappingDialog.cpp trunk/OpenMPT/mptrack/MIDIMappingDialog.h trunk/OpenMPT/mptrack/Modedit.cpp trunk/OpenMPT/mptrack/Mpt_midi.cpp trunk/OpenMPT/mptrack/View_pat.cpp trunk/OpenMPT/mptrack/Vstplug.cpp trunk/OpenMPT/soundlib/midi.h trunk/OpenMPT/soundlib/patternContainer.h Modified: trunk/OpenMPT/mptrack/MIDIMappingDialog.cpp =================================================================== --- trunk/OpenMPT/mptrack/MIDIMappingDialog.cpp 2009-08-25 20:14:24 UTC (rev 343) +++ trunk/OpenMPT/mptrack/MIDIMappingDialog.cpp 2009-08-26 20:40:27 UTC (rev 344) @@ -65,6 +65,7 @@ m_ChannelCBox.SetCurSel(1+GetFromMIDIMsg_Channel(dwMidiDataParam)); m_EventCBox.SetCurSel(0); m_ControllerCBox.SetCurSel(GetFromMIDIMsg_DataByte1(dwMidiDataParam)); + OnCbnSelchangeComboChannel(); OnCbnSelchangeComboEvent(); OnCbnSelchangeComboController(); UpdateString(); @@ -78,16 +79,6 @@ { CDialog::OnInitDialog(); - if (m_rMIDIMapper.GetCount() > 0) - m_Setting = m_rMIDIMapper.GetDirective(0); - - m_ChannelCBox.SetCurSel(m_Setting.GetChannel()); - - CheckDlgButton(IDC_CHECKACTIVE, m_Setting.IsActive() ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(IDC_CHECKCAPTURE, m_Setting.GetCaptureMIDI() ? BST_CHECKED : BST_UNCHECKED); - GetDlgItem(IDC_CHECK_PATRECORD)->ShowWindow((m_rSndFile.GetType() == MOD_TYPE_MPT) ? SW_SHOW : SW_HIDE); - CheckDlgButton(IDC_CHECK_PATRECORD, m_Setting.GetAllowPatternEdit() ? BST_CHECKED : BST_UNCHECKED); - m_EventCBox.SetCurSel(0); //Add controller names. @@ -97,14 +88,13 @@ temp.Format("%3d %s", i, MidiCCNames[i]); m_ControllerCBox.AddString(temp); } - m_ControllerCBox.SetCurSel(m_Setting.GetController()); //Add Pluginnames AddPluginNamesToCombobox(m_PluginCBox, m_rSndFile.m_MixPlugins); m_PluginCBox.SetCurSel(m_Setting.GetPlugIndex()-1); //Add plugin parameter names - AddPluginParameternamesToCombobox(m_PlugParamCBox, m_rSndFile.m_MixPlugins[0]); + AddPluginParameternamesToCombobox(m_PlugParamCBox, m_rSndFile.m_MixPlugins[(m_Setting.GetPlugIndex() <= MAX_MIXPLUGINS) ? m_Setting.GetPlugIndex() - 1 : 0]); m_PlugParamCBox.SetCurSel(m_Setting.GetParamIndex()); //Add directives to list. @@ -113,16 +103,26 @@ { m_List.AddString(CreateListString(*iter)); } - if(m_rMIDIMapper.GetCount() > 0) + if(m_rMIDIMapper.GetCount() > 0 && m_Setting.IsDefault()) { m_List.SetCurSel(0); OnLbnSelchangeList1(); - m_Setting = m_rMIDIMapper.GetDirective(0); } + else + { + m_ChannelCBox.SetCurSel(m_Setting.GetChannel()); + m_ControllerCBox.SetCurSel(m_Setting.GetController()); + CheckDlgButton(IDC_CHECKACTIVE, m_Setting.IsActive() ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(IDC_CHECKCAPTURE, m_Setting.GetCaptureMIDI() ? BST_CHECKED : BST_UNCHECKED); + GetDlgItem(IDC_CHECK_PATRECORD)->ShowWindow((m_rSndFile.GetType() == MOD_TYPE_MPT) ? SW_SHOW : SW_HIDE); + CheckDlgButton(IDC_CHECK_PATRECORD, m_Setting.GetAllowPatternEdit() ? BST_CHECKED : BST_UNCHECKED); + } UpdateString(); CMainFrame::GetMainFrame()->SetMidiRecordWnd(GetSafeHwnd()); + + CheckDlgButton(IDC_CHECK_MIDILEARN, BST_CHECKED); return TRUE; // return TRUE unless you set the focus to a control } Modified: trunk/OpenMPT/mptrack/MIDIMappingDialog.h =================================================================== --- trunk/OpenMPT/mptrack/MIDIMappingDialog.h 2009-08-25 20:14:24 UTC (rev 343) +++ trunk/OpenMPT/mptrack/MIDIMappingDialog.h 2009-08-26 20:40:27 UTC (rev 344) @@ -21,6 +21,8 @@ // Dialog Data enum { IDD = IDD_MIDIPARAMCONTROL }; + CMIDIMappingDirective m_Setting; + protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support @@ -49,7 +51,7 @@ CSpinButtonCtrl m_SpinMoveMapping; - CMIDIMappingDirective m_Setting; + public: afx_msg void OnLbnSelchangeList1(); Modified: trunk/OpenMPT/mptrack/Modedit.cpp =================================================================== --- trunk/OpenMPT/mptrack/Modedit.cpp 2009-08-25 20:14:24 UTC (rev 343) +++ trunk/OpenMPT/mptrack/Modedit.cpp 2009-08-26 20:40:27 UTC (rev 344) @@ -2304,7 +2304,7 @@ ORDERINDEX oNextOrder = m_SndFile.Order.GetNextOrderIgnoringSkips(oCurrentOrder); if((oNextOrder <= 0) || (oNextOrder >= m_SndFile.Order.size())) goto PasteDone; nPattern = m_SndFile.Order[oNextOrder]; - if(m_SndFile.Patterns.IsValidIndex(nPattern) == false) goto PasteDone; + if(m_SndFile.Patterns.IsValidPat(nPattern) == false) goto PasteDone; m = m_SndFile.Patterns[nPattern]; PrepareUndo(nPattern, 0,0, m_SndFile.m_nChannels, m_SndFile.PatternSize[nPattern]); oCurrentOrder = oNextOrder; Modified: trunk/OpenMPT/mptrack/Mpt_midi.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mpt_midi.cpp 2009-08-25 20:14:24 UTC (rev 343) +++ trunk/OpenMPT/mptrack/Mpt_midi.cpp 2009-08-26 20:40:27 UTC (rev 344) @@ -165,6 +165,20 @@ //---------------------------------------------------------------------------- +CString CMIDIMappingDirective::ToString() const +//--------------------------------------------- +{ + CString str; str.Preallocate(20); + char flags[4] = "000"; + if(m_Active) flags[0] = '1'; + if(m_CaptureMIDI) flags[1] = '1'; + if(m_AllowPatternEdit) flags[2] = '1'; + str.Format("%s:%d:%x:%d:%d:%d", flags, (int)GetChannel(), (int)GetEvent(), (int)GetController(), (int)m_PluginIndex, m_Parameter); + str.Trim(); + return str; +} + + size_t CMIDIMapper::GetSerializationSize() const //--------------------------------------------- { Modified: trunk/OpenMPT/mptrack/View_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_pat.cpp 2009-08-25 20:14:24 UTC (rev 343) +++ trunk/OpenMPT/mptrack/View_pat.cpp 2009-08-26 20:40:27 UTC (rev 344) @@ -3018,7 +3018,7 @@ //-------------------------------------------------------------------------------- { static MODCOMMAND m; - if (rSf.Patterns.IsValidIndex(pos.nPat) && pos.nRow < rSf.Patterns[pos.nPat].GetNumRows() && pos.nChn < rSf.GetNumChannels()) + if (rSf.Patterns.IsValidPat(pos.nPat) && pos.nRow < rSf.Patterns[pos.nPat].GetNumRows() && pos.nChn < rSf.GetNumChannels()) return rSf.Patterns[pos.nPat].GetpModCommand(pos.nRow, pos.nChn); else return &m; @@ -5125,7 +5125,7 @@ const ROWINDEX iRowCandidate, const PATTERNINDEX iPatCandidate) const //------------------------------------------------------------------------------------------- { - if(rSndFile.Patterns.IsValidIndex(iPatCandidate) && rSndFile.Patterns[iPatCandidate].IsValidRow(iRowCandidate)) + if(rSndFile.Patterns.IsValidPat(iPatCandidate) && rSndFile.Patterns[iPatCandidate].IsValidRow(iRowCandidate)) { // Case: Edit position candidates are valid -- use them. iPat = iPatCandidate; iRow = iRowCandidate; Modified: trunk/OpenMPT/mptrack/Vstplug.cpp =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.cpp 2009-08-25 20:14:24 UTC (rev 343) +++ trunk/OpenMPT/mptrack/Vstplug.cpp 2009-08-26 20:40:27 UTC (rev 344) @@ -14,6 +14,7 @@ #include "defaultvsteditor.h" //rewbs.defaultPlugGUI #include "midi.h" #include "version.h" +#include "midimappingdialog.h" #ifdef VST_USE_ALTERNATIVE_MAGIC //Pelya's plugin ID fix. Breaks fx presets, so let's avoid it for now. #include "Unzip32.h" //For CRC calculation (to detect plugins with same UID) #endif @@ -677,6 +678,18 @@ pModDoc->RecordParamChange(pVstPlugin->GetSlot(), index); } + if (CMainFrame::GetInputHandler()->ShiftPressed()) + { + CMainFrame::GetInputHandler()->SetModifierMask(0); // Make sure that the dialog will open only once. + CAbstractVstEditor *pVstEditor = pVstPlugin->GetEditor(); + const HWND oldMIDIRecondWnd = CMainFrame::GetMainFrame()->GetMidiRecordWnd(); + CMIDIMappingDialog dlg(pVstEditor, *pModDoc->GetSoundFile()); + dlg.m_Setting.SetParamIndex(index); + dlg.m_Setting.SetPlugIndex(pVstPlugin->GetSlot()+1); + dlg.DoModal(); + CMainFrame::GetMainFrame()->SetMidiRecordWnd(oldMIDIRecondWnd); + } + // Learn macro CAbstractVstEditor *pVstEditor = pVstPlugin->GetEditor(); if (pVstEditor) { Modified: trunk/OpenMPT/soundlib/midi.h =================================================================== --- trunk/OpenMPT/soundlib/midi.h 2009-08-25 20:14:24 UTC (rev 343) +++ trunk/OpenMPT/soundlib/midi.h 2009-08-26 20:40:27 UTC (rev 344) @@ -63,20 +63,12 @@ void SetParamIndex(const int i) {m_Parameter = i;} uint32 GetParamIndex() const {return m_Parameter;} - bool operator==(const CMIDIMappingDirective& d) {return memcmp(this, &d, sizeof(CMIDIMappingDirective)) == 0;} + bool IsDefault() const {return *this == CMIDIMappingDirective();} - CString ToString() const - { - CString str; str.Preallocate(20); - char flags[4] = "000"; - if(m_Active) flags[0] = '1'; - if(m_CaptureMIDI) flags[1] = '1'; - if(m_AllowPatternEdit) flags[2] = '1'; - str.Format("%s:%d:%x:%d:%d:%d", flags, (int)GetChannel(), (int)GetEvent(), (int)GetController(), (int)m_PluginIndex, m_Parameter); - str.Trim(); - return str; - } + bool operator==(const CMIDIMappingDirective& d) const {return memcmp(this, &d, sizeof(CMIDIMappingDirective)) == 0;} + CString ToString() const; + BYTE GetChnEvent() const {return m_ChnEvent;} private: Modified: trunk/OpenMPT/soundlib/patternContainer.h =================================================================== --- trunk/OpenMPT/soundlib/patternContainer.h 2009-08-25 20:14:24 UTC (rev 343) +++ trunk/OpenMPT/soundlib/patternContainer.h 2009-08-26 20:40:27 UTC (rev 344) @@ -55,6 +55,9 @@ // Return true if pattern can be accessed with operator[](iPat), false otherwise. bool IsValidIndex(const PATTERNINDEX iPat) const {return (iPat < Size());} + + // Return true if IsValidIndex() is true and the corresponding pattern has allocated modcommand array, false otherwise. + bool IsValidPat(const PATTERNINDEX iPat) const {return IsValidIndex(iPat) && (*this)[iPat];} void ResizeArray(const PATTERNINDEX newSize); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |