From: <sag...@us...> - 2014-10-07 15:17:52
|
Revision: 4403 http://sourceforge.net/p/modplug/code/4403 Author: saga-games Date: 2014-10-07 15:17:38 +0000 (Tue, 07 Oct 2014) Log Message: ----------- [Imp] Plugin selection dialog: When adding a new plugin that is missing from some open file, it is now automatically loaded and restored in that file. [Fix] MT2 Loader: MT2 only ever uses effGetChunk for programs, not banks. Since OpenMPT assumes that it should restore a plugin bank when the "default program" parameter is set, don't use it anymore when restoring plugin chunks. Modified Paths: -------------- trunk/OpenMPT/mptrack/SelectPluginDialog.cpp trunk/OpenMPT/soundlib/Load_mt2.cpp Modified: trunk/OpenMPT/mptrack/SelectPluginDialog.cpp =================================================================== --- trunk/OpenMPT/mptrack/SelectPluginDialog.cpp 2014-10-07 08:51:36 UTC (rev 4402) +++ trunk/OpenMPT/mptrack/SelectPluginDialog.cpp 2014-10-07 15:17:38 UTC (rev 4403) @@ -564,6 +564,33 @@ } else { plugLib = lib; + + // If this plugin was missing anywhere, try loading it + std::vector<CModDoc *> docs(theApp.GetOpenDocuments()); + for(size_t i = 0; i < docs.size(); i++) + { + CModDoc &doc = *docs[i]; + CSoundFile &sndFile = doc.GetrSoundFile(); + bool updateDoc = false; + for(PLUGINDEX plug = 0; plug < MAX_MIXPLUGINS; plug++) + { + SNDMIXPLUGIN &plugin = sndFile.m_MixPlugins[plug]; + if(plugin.pMixPlugin == nullptr + && plugin.Info.dwPluginId1 == lib->pluginId1 + && plugin.Info.dwPluginId2 == lib->pluginId2) + { + CSoundFile::gpMixPluginCreateProc(plugin, sndFile); + if(plugin.pMixPlugin) + { + plugin.pMixPlugin->RestoreAllParameters(plugin.defaultProgram); + } + } + } + if(updateDoc) + { + doc.UpdateAllViews(nullptr, HINT_MIXPLUGINS); + } + } } } } Modified: trunk/OpenMPT/soundlib/Load_mt2.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_mt2.cpp 2014-10-07 08:51:36 UTC (rev 4402) +++ trunk/OpenMPT/soundlib/Load_mt2.cpp 2014-10-07 15:17:38 UTC (rev 4403) @@ -639,7 +639,6 @@ } mixPlug.Info.dwPluginId1 = kEffectMagic; mixPlug.Info.dwPluginId2 = vstHeader.fxID; - mixPlug.defaultProgram = vstHeader.programNr; if(vstHeader.track >= m_nChannels) { mixPlug.SetMasterEffect(true); @@ -667,10 +666,14 @@ // Read plugin settings if(vstHeader.useChunks) { + // MT2 only ever calls effGetChunk for programs, and OpenMPT uses the defaultProgram value to determine + // whether it should use effSetChunk for programs or banks... + mixPlug.defaultProgram = -1; LimitMax(vstHeader.n, Util::MaxValueOfType(mixPlug.nPluginDataSize) - 4); mixPlug.nPluginDataSize = vstHeader.n + 4; } else { + mixPlug.defaultProgram = vstHeader.programNr; LimitMax(vstHeader.n, Util::MaxValueOfType(mixPlug.nPluginDataSize) / 4u); mixPlug.nPluginDataSize = vstHeader.n * 4; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |