From: <sag...@us...> - 2011-11-19 23:57:23
|
Revision: 1139 http://modplug.svn.sourceforge.net/modplug/?rev=1139&view=rev Author: saga-games Date: 2011-11-19 23:57:16 +0000 (Sat, 19 Nov 2011) Log Message: ----------- [Fix] Channel Manager: Reordering / removing channels broke some revisions ago. [Fix] Sample Editor: When loading multiple samples at once, existing samples are not overwritten anymore. Modified Paths: -------------- trunk/OpenMPT/mptrack/ChannelManagerDlg.cpp trunk/OpenMPT/mptrack/Ctrl_smp.cpp Modified: trunk/OpenMPT/mptrack/ChannelManagerDlg.cpp =================================================================== --- trunk/OpenMPT/mptrack/ChannelManagerDlg.cpp 2011-11-18 22:52:19 UTC (rev 1138) +++ trunk/OpenMPT/mptrack/ChannelManagerDlg.cpp 2011-11-19 23:57:16 UTC (rev 1139) @@ -188,7 +188,7 @@ CriticalSection cs; //Creating new order-vector for ReArrangeChannels. - vector<CHANNELINDEX> newChnOrder(nChannels); + vector<CHANNELINDEX> newChnOrder; for(CHANNELINDEX nChn = 0; nChn < nChannels; nChn++) { newChnOrder.push_back(newpat[nChn]); @@ -372,7 +372,8 @@ CModDoc *pModDoc = pMainFrm ? pMainFrm->GetActiveDoc() : NULL; CSoundFile * m_pSndFile = pModDoc ? pModDoc->GetSoundFile() : NULL; - if(pModDoc && m_pSndFile){ + if(pModDoc && m_pSndFile) + { int nbOk = 0, nbSelect = 0; @@ -450,7 +451,8 @@ CModDoc *pModDoc = pMainFrm ? pMainFrm->GetActiveDoc() : NULL; CSoundFile * m_pSndFile = pModDoc ? pModDoc->GetSoundFile() : NULL; - switch(currentTab){ + switch(currentTab) + { case 0: for(CHANNELINDEX nChn = 0; nChn < m_pSndFile->m_nChannels; nChn++) { @@ -487,7 +489,8 @@ EnterCriticalSection(&applying); - switch(currentTab){ + switch(currentTab) + { case 0: for(CHANNELINDEX nChn = 0; nChn < m_pSndFile->m_nChannels; nChn++) { @@ -531,7 +534,8 @@ int sel = TabCtrl_GetCurFocus(::GetDlgItem(m_hWnd,IDC_TAB1)); currentTab = sel; - switch(currentTab){ + switch(currentTab) + { case 0: SetDlgItemText(IDC_BUTTON5, "Solo"); SetDlgItemText(IDC_BUTTON6, "Mute"); @@ -597,7 +601,8 @@ } else ::FrameRect(hdc,&rect,CMainFrame::brushBlack); - if ((lpszText) && (lpszText[0])){ + if ((lpszText) && (lpszText[0])) + { rect.left += 13; rect.right -= 5; @@ -613,42 +618,49 @@ void CChannelManagerDlg::OnSize(UINT nType,int cx,int cy) { CWnd::OnSize(nType,cx,cy); - if(!m_hWnd || show == false) return; + if(!m_hWnd || !show) return; - CWnd * button; + CWnd *button; CRect wnd,btn; GetWindowRect(&wnd); - if((button = GetDlgItem(IDC_BUTTON1)) != 0){ + if((button = GetDlgItem(IDC_BUTTON1)) != nullptr) + { button->GetWindowRect(&btn); button->SetWindowPos(NULL, btn.left - wnd.left - 3, wnd.Height() - btn.Height() * 2 - 8, 0, 0, SWP_NOSIZE | SWP_NOZORDER); } - if((button = GetDlgItem(IDC_BUTTON2)) != 0){ + if((button = GetDlgItem(IDC_BUTTON2)) != nullptr) + { button->GetWindowRect(&btn); button->SetWindowPos(NULL, btn.left - wnd.left - 3, wnd.Height() - btn.Height() * 2 - 8, 0, 0, SWP_NOSIZE | SWP_NOZORDER); } - if((button = GetDlgItem(IDC_BUTTON3)) != 0){ + if((button = GetDlgItem(IDC_BUTTON3)) != nullptr) + { button->GetWindowRect(&btn); button->SetWindowPos(NULL, btn.left - wnd.left - 3, wnd.Height() - btn.Height() * 2 - 8, 0, 0, SWP_NOSIZE | SWP_NOZORDER); } - if((button = GetDlgItem(IDC_BUTTON4)) != 0){ + if((button = GetDlgItem(IDC_BUTTON4)) != nullptr) + { button->GetWindowRect(&btn); button->SetWindowPos(NULL, btn.left - wnd.left - 3, wnd.Height() - btn.Height() * 2 - 8, 0, 0, SWP_NOSIZE | SWP_NOZORDER); } - if((button = GetDlgItem(IDC_BUTTON5)) != 0){ + if((button = GetDlgItem(IDC_BUTTON5)) != nullptr) + { button->GetWindowRect(&btn); button->SetWindowPos(NULL, btn.left - wnd.left - 3, wnd.Height() - btn.Height() * 2 - 8, 0, 0, SWP_NOSIZE | SWP_NOZORDER); } - if((button = GetDlgItem(IDC_BUTTON6)) != 0){ + if((button = GetDlgItem(IDC_BUTTON6)) != nullptr) + { button->GetWindowRect(&btn); button->SetWindowPos(NULL, btn.left - wnd.left - 3, wnd.Height() - btn.Height() * 2 - 8, 0, 0, SWP_NOSIZE | SWP_NOZORDER); } GetClientRect(&wnd); - wnd.SetRect(wnd.left + 10, wnd.top + 38, wnd.right - 8, wnd.bottom - 30); + wnd.DeflateRect(10, 38, 8, 30); if(bkgnd) DeleteObject(bkgnd); - bkgnd = ::CreateCompatibleBitmap(::GetDC(m_hWnd),wnd.Width(),wnd.Height()); - if(!moveRect && bkgnd){ + bkgnd = ::CreateCompatibleBitmap(::GetDC(m_hWnd), wnd.Width(), wnd.Height()); + if(!moveRect && bkgnd) + { HDC bdc = ::CreateCompatibleDC(::GetDC(m_hWnd)); ::SelectObject(bdc,bkgnd); ::BitBlt(bdc,0,0,wnd.Width(),wnd.Height(),::GetDC(m_hWnd),wnd.left,wnd.top,SRCCOPY); @@ -657,7 +669,7 @@ } nChannelsOld = 0; - InvalidateRect(NULL,FALSE); + InvalidateRect(NULL, FALSE); } void CChannelManagerDlg::OnActivate(UINT nState,CWnd* pWndOther,BOOL bMinimized) @@ -689,10 +701,11 @@ ::BeginPaint(m_hWnd,&pDC); CMainFrame * pMainFrm = CMainFrame::GetMainFrame(); - CModDoc *pModDoc = pMainFrm ? pMainFrm->GetActiveDoc() : NULL; - CSoundFile * m_pSndFile = pModDoc ? pModDoc->GetSoundFile() : NULL; + CModDoc *pModDoc = pMainFrm ? pMainFrm->GetActiveDoc() : nullptr; + CSoundFile * m_pSndFile = pModDoc ? pModDoc->GetSoundFile() : nullptr; - if(!pModDoc || !m_pSndFile){ + if(!pModDoc || !m_pSndFile) + { ::EndPaint(m_hWnd,&pDC); LeaveCriticalSection(&applying); return; @@ -713,7 +726,7 @@ if(chnSizeY != CM_BT_HEIGHT) { - // resize window + // Window height is not sufficient => resize window ::EndPaint(m_hWnd,&pDC); LeaveCriticalSection(&applying); CWnd::SetWindowPos(NULL, 0, 0, btn.Width(), btn.Height() + (CM_BT_HEIGHT - chnSizeY) * nLines, SWP_NOMOVE | SWP_NOZORDER); @@ -798,17 +811,15 @@ btn.top = client.top + l * chnSizeY + 3; btn.bottom = btn.top + chnSizeY - 3; - ok = intersection.IntersectRect(&pDC.rcPaint,&client); + ok = intersection.IntersectRect(&pDC.rcPaint, &client); if(ok) DrawChannelButton(pDC.hdc, &btn, s, select[nThisChn], removed[nThisChn] ? FALSE : TRUE, DT_RIGHT | DT_VCENTER, NULL); btn.right = btn.left + chnSizeX / 7; - btn.left += 3; - btn.right -= 3; - btn.top += 3; - btn.bottom -= 3; + btn.DeflateRect(3, 3, 3, 3); - switch(currentTab){ + switch(currentTab) + { case 0: if(m_pSndFile->ChnSettings[nThisChn].dwFlags & CHN_MUTE) FillRect(pDC.hdc,&btn,red); else if(m_pSndFile->ChnSettings[nThisChn].dwFlags & CHN_SOLO) FillRect(pDC.hdc,&btn,green); @@ -832,7 +843,8 @@ break; } - if(!removed[nThisChn]){ + if(!removed[nThisChn]) + { HGDIOBJ oldpen = ::SelectObject(pDC.hdc, CMainFrame::penLightGray); ::MoveToEx(pDC.hdc, btn.right, btn.top-2, NULL); ::LineTo(pDC.hdc, btn.right, btn.bottom+1); @@ -869,7 +881,8 @@ CModDoc *pModDoc = pMainFrm ? pMainFrm->GetActiveDoc() : NULL; CSoundFile * m_pSndFile = pModDoc ? pModDoc->GetSoundFile() : NULL; - if(pModDoc && m_pSndFile){ + if(pModDoc && m_pSndFile) + { //UINT nChannels = m_pSndFile->m_nChannels; UINT nColns = CM_NB_COLS; //UINT nLines = nChannels / nColns + (nChannels % nColns ? 1 : 0); @@ -883,9 +896,11 @@ x = x / dx; y = y / dy; CHANNELINDEX n = static_cast<CHANNELINDEX>(y * nColns + x); - if(n >= 0 && n < (int)m_pSndFile->m_nChannels){ + if(n >= 0 && n < (int)m_pSndFile->m_nChannels) + { if(id) *id = n; - if(invalidate){ + if(invalidate) + { invalidate->left = client.left + x * dx; invalidate->right = invalidate->left + dx; invalidate->top = client.top + y * dy; @@ -960,7 +975,8 @@ mouseTracking = _TrackMouseEvent(&tme) != FALSE; } - if(!leftButton && !rightButton){ + if(!leftButton && !rightButton) + { mx = point.x; my = point.y; LeaveCriticalSection(&applying); @@ -981,7 +997,8 @@ CModDoc *pModDoc = pMainFrm ? pMainFrm->GetActiveDoc() : NULL; CSoundFile * m_pSndFile = pModDoc ? pModDoc->GetSoundFile() : NULL; - if(moveRect && m_pSndFile){ + if(moveRect && m_pSndFile) + { CHANNELINDEX n, i, k; CHANNELINDEX newpat[MAX_BASECHANNELS]; Modified: trunk/OpenMPT/mptrack/Ctrl_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2011-11-18 22:52:19 UTC (rev 1138) +++ trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2011-11-19 23:57:16 UTC (rev 1139) @@ -957,6 +957,7 @@ { memcpy(m_pSndFile->GetSample(smp).pSample, m_pSndFile->GetSample(nOldSmp).pSample, m_pSndFile->GetSample(nOldSmp).GetSampleSizeInBytes()); } + m_pSndFile->AdjustSampleLoop(&m_pSndFile->GetSample(smp)); } } @@ -999,17 +1000,10 @@ for(size_t counter = 0; counter < files.filenames.size(); counter++) { - //If loading multiple samples, advancing to next sample and creating - //new one if necessary. + // If loading multiple samples, create new slots for them if(counter > 0) { - if(m_nSample >= MAX_SAMPLES-1) - break; - else - m_nSample++; - - if(m_nSample > m_pSndFile->GetNumSamples()) - OnSampleNew(); + OnSampleNew(); } if(!OpenSample(files.filenames[counter].c_str())) @@ -1051,7 +1045,7 @@ if(sPath.IsEmpty()) sPath = "untitled"; sPath += " - %sample_number% - "; - if(m_pSndFile->m_nType & (MOD_TYPE_XM|MOD_TYPE_MOD)) + if(m_pSndFile->GetType() & (MOD_TYPE_XM|MOD_TYPE_MOD)) sPath += "%sample_name%.wav"; else sPath += "%sample_filename%.wav"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |