From: <sag...@us...> - 2009-10-24 14:50:44
|
Revision: 404 http://modplug.svn.sourceforge.net/modplug/?rev=404&view=rev Author: saga-games Date: 2009-10-24 14:50:32 +0000 (Sat, 24 Oct 2009) Log Message: ----------- [Imp] Treeview / VST Selector: Different icons for effects / instruments [Ref] Slightly rewrote alternative VST magic code [Ref] Slightly rewrote VST Selector dialog code Modified Paths: -------------- trunk/OpenMPT/mptrack/Mainfrm.h trunk/OpenMPT/mptrack/View_tre.cpp trunk/OpenMPT/mptrack/Vstplug.cpp trunk/OpenMPT/mptrack/Vstplug.h trunk/OpenMPT/mptrack/res/img_list.bmp Modified: trunk/OpenMPT/mptrack/Mainfrm.h =================================================================== --- trunk/OpenMPT/mptrack/Mainfrm.h 2009-10-23 23:12:00 UTC (rev 403) +++ trunk/OpenMPT/mptrack/Mainfrm.h 2009-10-24 14:50:32 UTC (rev 404) @@ -256,6 +256,9 @@ IMAGE_INSTRMUTE, IMAGE_SAMPLEACTIVE, IMAGE_INSTRACTIVE, + IMAGE_NOPLUGIN, + IMAGE_EFFECTPLUGIN, + IMAGE_PLUGININSTRUMENT, }; ////////////////////////////////////////////////////////////////////////// Modified: trunk/OpenMPT/mptrack/View_tre.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_tre.cpp 2009-10-23 23:12:00 UTC (rev 403) +++ trunk/OpenMPT/mptrack/View_tre.cpp 2009-10-24 14:50:32 UTC (rev 404) @@ -681,7 +681,9 @@ pInfo->hEffects = InsertItem("Plugins", IMAGE_FOLDER, IMAGE_FOLDER, pInfo->hSong, TVI_LAST); } wsprintf(s, "FX%d: %s", iFx+1, pPlugin->Info.szName); - pInfo->tiEffects[iFx] = InsertItem(s, IMAGE_WAVEOUT, IMAGE_WAVEOUT, pInfo->hEffects, TVI_LAST); + int nImage = IMAGE_NOPLUGIN; + if(pPlugin->pMixPlugin != nullptr) nImage = (pPlugin->pMixPlugin->isInstrument()) ? IMAGE_PLUGININSTRUMENT : IMAGE_EFFECTPLUGIN; + pInfo->tiEffects[iFx] = InsertItem(s, nImage, nImage, pInfo->hEffects, TVI_LAST); nFx++; } } Modified: trunk/OpenMPT/mptrack/Vstplug.cpp =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.cpp 2009-10-23 23:12:00 UTC (rev 403) +++ trunk/OpenMPT/mptrack/Vstplug.cpp 2009-10-24 14:50:32 UTC (rev 404) @@ -16,7 +16,8 @@ #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) +#define ZLIB_WINAPI +#include "../zlib/zlib.h" //For CRC32 calculation (to detect plugins with same UID) #endif #ifndef NO_VST @@ -38,27 +39,17 @@ AEffect *DmoToVst(PVSTPLUGINLIB pLib); #ifdef VST_USE_ALTERNATIVE_MAGIC -class CalculateCRC32: public CZipArchive // Make Plugin ID unique for sure +UINT32 CalculateCRC32fromFilename(const char * s) +//----------------------------------------------- { - public: - DWORD calculate( BYTE *s, int len ) - { - CZipArchive::crc32val = 0xFFFFFFFFL; - CZipArchive::UpdateCRC( s, len ); - return CZipArchive::crc32val; - }; - DWORD calculateFilename( const char * s ) - { - char fn[_MAX_PATH]; - strncpy( fn, s, sizeof(fn) ); - fn[sizeof(fn)-1] = 0; - int f; - for( f=0; fn[f] != 0; f++ ) fn[f] = toupper( fn[f] ); - return calculate( (BYTE *)fn, f ); - }; -}; + char fn[_MAX_PATH]; + strncpy(fn, s, sizeof(fn)); + fn[sizeof(fn)-1] = 0; + int f; + for(f = 0; fn[f] != 0; f++) fn[f] = toupper(fn[f]); + return crc32(0, (BYTE *)fn, f); -CalculateCRC32 CRC32; +} #endif long VSTCALLBACK CVstPluginManager::MasterCallBack(AEffect *effect, long opcode, long index, long value, void *ptr, float opt) @@ -260,7 +251,7 @@ #ifdef VST_USE_ALTERNATIVE_MAGIC if( p->dwPluginId1 == kEffectMagic ) { - p->dwPluginId1 = CRC32.calculateFilename( p->szLibraryName ); // Make Plugin ID unique for sure (for VSTs with same UID) + p->dwPluginId1 = CalculateCRC32fromFilename(p->szLibraryName); // Make Plugin ID unique for sure (for VSTs with same UID) }; #endif #ifdef VST_LOG @@ -329,7 +320,7 @@ { pEffect->dispatcher(pEffect, effOpen, 0,0,0,0); #ifdef VST_USE_ALTERNATIVE_MAGIC - p->dwPluginId1 = CRC32.calculateFilename( p->szLibraryName ); // Make Plugin ID unique for sure + p->dwPluginId1 = CalculateCRC32fromFilename(p->szLibraryName); // Make Plugin ID unique for sure #else p->dwPluginId1 = pEffect->magic; #endif @@ -1276,41 +1267,23 @@ VOID CSelectPluginDlg::UpdatePluginsList(DWORD forceSelect/*=0*/) //--------------------------------------------------------------- { - TVINSERTSTRUCT tvis; CVstPluginManager *pManager = theApp.GetPluginManager(); HTREEITEM cursel, hDmo, hVst, hSynth; m_treePlugins.SetRedraw(FALSE); m_treePlugins.DeleteAllItems(); - memset(&tvis, 0, sizeof(tvis)); - tvis.hParent = TVI_ROOT; - tvis.hInsertAfter = TVI_FIRST; - tvis.item.mask = TVIF_IMAGE | TVIF_PARAM | TVIF_TEXT | TVIF_SELECTEDIMAGE | TVIF_TEXT; - tvis.item.pszText = "VST Instruments"; - tvis.item.iImage = IMAGE_FOLDER; - tvis.item.iSelectedImage = IMAGE_FOLDER; - tvis.item.lParam = NULL; - hSynth = m_treePlugins.InsertItem(&tvis); - tvis.item.pszText = "DirectX Media Audio Effects"; - hDmo = m_treePlugins.InsertItem(&tvis); - tvis.item.pszText = "VST Audio Effects"; - hVst = m_treePlugins.InsertItem(&tvis); - tvis.item.pszText = " No plugin (empty slot)"; - tvis.item.iImage = IMAGE_WAVEOUT; - tvis.item.iSelectedImage = IMAGE_WAVEOUT; - cursel = m_treePlugins.InsertItem(&tvis); + + hSynth = AddTreeItem("VST Instruments", IMAGE_FOLDER, false); + hDmo = AddTreeItem("DirectX Media Audio Effects", IMAGE_FOLDER, false); + hVst = AddTreeItem("VST Audio Effects", IMAGE_FOLDER, false); + cursel = AddTreeItem("No plugin (empty slot)", IMAGE_NOPLUGIN, false); + if (pManager) { PVSTPLUGINLIB pCurrent = NULL; PVSTPLUGINLIB p = pManager->GetFirstPlugin(); while (p) { - if (p->dwPluginId1 == kDmoMagic) { - tvis.hParent = hDmo; - } else { - tvis.hParent = (p->bIsInstrument) ? hSynth : hVst; - } - // Apply name filter if (m_sNameFilter != "") { CString displayName = p->szLibraryName; @@ -1320,34 +1293,41 @@ } } - tvis.hInsertAfter = TVI_SORT; - tvis.item.pszText = p->szLibraryName; - tvis.item.lParam = (LPARAM)p; - HTREEITEM h = m_treePlugins.InsertItem(&tvis); + HTREEITEM hParent; + if (p->dwPluginId1 == kDmoMagic) { + hParent = hDmo; + } else { + hParent = (p->bIsInstrument) ? hSynth : hVst; + } + HTREEITEM h = AddTreeItem(p->szLibraryName, p->bIsInstrument ? IMAGE_PLUGININSTRUMENT : IMAGE_EFFECTPLUGIN, true, hParent, (LPARAM)p); + //If filter is active, expand nodes. - if (m_sNameFilter != "") { - m_treePlugins.EnsureVisible(h); - } + if (m_sNameFilter != "") m_treePlugins.EnsureVisible(h); //Which plugin should be selected? - if (m_pPlugin) { + if (m_pPlugin) + { //forced selection (e.g. just after add plugin) - if (forceSelect != 0) { - if (p->dwPluginId2 == forceSelect) { + if (forceSelect != 0) + { + if (p->dwPluginId2 == forceSelect) + { pCurrent = p; } } //Current slot's plugin - else if (m_pPlugin->pMixPlugin) { + else if (m_pPlugin->pMixPlugin) + { CVstPlugin *pVstPlug = (CVstPlugin *)m_pPlugin->pMixPlugin; if (pVstPlug->GetPluginFactory() == p) pCurrent = p; } //Plugin with matching ID to current slot's plug - else if (/* (!pCurrent) && */ m_pPlugin->Info.dwPluginId1 !=0 || m_pPlugin->Info.dwPluginId2 != 0 ) { + else if (/* (!pCurrent) && */ m_pPlugin->Info.dwPluginId1 !=0 || m_pPlugin->Info.dwPluginId2 != 0) + { if ((p->dwPluginId1 == m_pPlugin->Info.dwPluginId1) && (p->dwPluginId2 == m_pPlugin->Info.dwPluginId2)) { pCurrent = p; @@ -1355,7 +1335,8 @@ } //Last selected plugin - else { + else + { if (p->dwPluginId2 == CMainFrame::GetMainFrame()->gnPlugWindowLast) { pCurrent = p; } @@ -1373,7 +1354,22 @@ } } +HTREEITEM CSelectPluginDlg::AddTreeItem(LPSTR szTitle, int iImage, bool bSort, HTREEITEM hParent, LPARAM lParam) +//-------------------------------------------------------------------------------------------------------------- +{ + TVINSERTSTRUCT tvis; + memset(&tvis, 0, sizeof(tvis)); + tvis.hParent = hParent; + tvis.hInsertAfter = (bSort) ? TVI_SORT : TVI_FIRST; + tvis.item.mask = TVIF_IMAGE | TVIF_PARAM | TVIF_TEXT | TVIF_SELECTEDIMAGE | TVIF_TEXT; + tvis.item.pszText = szTitle; + tvis.item.iImage = tvis.item.iSelectedImage = iImage; + tvis.item.lParam = lParam; + return m_treePlugins.InsertItem(&tvis); +} + + VOID CSelectPluginDlg::OnSelDblClk(NMHDR *, LRESULT *result) //---------------------------------------------------------- { @@ -1385,7 +1381,8 @@ HTREEITEM hSel = m_treePlugins.GetSelectedItem(); int nImage, nSelectedImage; m_treePlugins.GetItemImage(hSel, nImage, nSelectedImage); - if ((hSel) && (nImage == IMAGE_WAVEOUT)) OnOK(); + + if ((hSel) && (nImage != IMAGE_FOLDER)) OnOK(); if (result) *result = 0; } Modified: trunk/OpenMPT/mptrack/Vstplug.h =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.h 2009-10-23 23:12:00 UTC (rev 403) +++ trunk/OpenMPT/mptrack/Vstplug.h 2009-10-24 14:50:32 UTC (rev 404) @@ -275,6 +275,8 @@ CTreeCtrl m_treePlugins; CString m_sNameFilter; + HTREEITEM AddTreeItem(LPSTR szTitle, int iImage, bool bSort, HTREEITEM hParent = TVI_ROOT, LPARAM lParam = NULL); + public: CSelectPluginDlg(CModDoc *pModDoc, int nPlugSlot, CWnd *parent); //rewbs.plugDocAware VOID DoClose(); Modified: trunk/OpenMPT/mptrack/res/img_list.bmp =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |