From: <sag...@us...> - 2013-11-16 23:10:50
|
Revision: 3248 http://sourceforge.net/p/modplug/code/3248 Author: saga-games Date: 2013-11-16 23:10:41 +0000 (Sat, 16 Nov 2013) Log Message: ----------- [Mod] Store plugin library names as UTF-8 in module files. This won't make a difference in 99% of all plugin names probably - I've never come across a plugin DLL with non-ASCII characters. Note: Library name is still converted to ANSI in GUI for this reason. Modified Paths: -------------- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/SelectPluginDialog.cpp trunk/OpenMPT/mptrack/View_gen.cpp trunk/OpenMPT/mptrack/view_com.cpp trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/soundlib/plugins/PlugInterface.h trunk/OpenMPT/soundlib/plugins/PluginManager.cpp Modified: trunk/OpenMPT/mptrack/AbstractVstEditor.cpp =================================================================== --- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2013-11-16 21:28:43 UTC (rev 3247) +++ trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2013-11-16 23:10:41 UTC (rev 3248) @@ -346,7 +346,7 @@ if(strcmp(m_VstPlugin.m_pMixStruct->GetName(), "")) Title.Append(m_VstPlugin.m_pMixStruct->GetName()); else - Title.Append(m_VstPlugin.m_pMixStruct->GetLibraryName()); + Title.Append(mpt::ToLocale(mpt::CharsetUTF8, m_VstPlugin.m_pMixStruct->GetLibraryName()).c_str()); SetWindowText(Title); } @@ -869,7 +869,7 @@ m_nInstrument = nIns; _snprintf(pIns->name, CountOf(pIns->name) - 1, _T("%d: %s"), m_VstPlugin.GetSlot() + 1, sndFile.m_MixPlugins[m_VstPlugin.GetSlot()].GetName()); - mpt::String::CopyN(pIns->filename, sndFile.m_MixPlugins[m_VstPlugin.GetSlot()].GetLibraryName()); + mpt::String::Copy(pIns->filename, mpt::ToLocale(mpt::CharsetUTF8, sndFile.m_MixPlugins[m_VstPlugin.GetSlot()].GetLibraryName())); pIns->nMixPlug = (PLUGINDEX)m_VstPlugin.GetSlot() + 1; pIns->nMidiChannel = 1; // People will forget to change this anyway, so the following lines can lead to some bad surprises after re-opening the module. Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2013-11-16 21:28:43 UTC (rev 3247) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2013-11-16 23:10:41 UTC (rev 3248) @@ -2635,7 +2635,7 @@ str.Preallocate(80); str.Format(_T("FX%d: "), iPlug + 1); const int size0 = str.GetLength(); - str += (librarynames) ? plugin.GetLibraryName() : plugin.GetName(); + str += (librarynames) ? mpt::ToLocale(mpt::CharsetUTF8, plugin.GetLibraryName()).c_str() : plugin.GetName(); if(str.GetLength() <= size0) str += _T("undefined"); CBox.SetItemData(CBox.AddString(str), iPlug + 1); Modified: trunk/OpenMPT/mptrack/SelectPluginDialog.cpp =================================================================== --- trunk/OpenMPT/mptrack/SelectPluginDialog.cpp 2013-11-16 21:28:43 UTC (rev 3247) +++ trunk/OpenMPT/mptrack/SelectPluginDialog.cpp 2013-11-16 23:10:41 UTC (rev 3248) @@ -148,9 +148,8 @@ break; } - const std::string libraryName = pFactory->libraryName.ToLocale(); - mpt::String::Copy(m_pPlugin->Info.szName, libraryName); - mpt::String::Copy(m_pPlugin->Info.szLibraryName, libraryName); + mpt::String::Copy(m_pPlugin->Info.szName, pFactory->libraryName.ToLocale().c_str()); + mpt::String::Copy(m_pPlugin->Info.szLibraryName, pFactory->libraryName.ToUTF8().c_str()); cs.Leave(); Modified: trunk/OpenMPT/mptrack/View_gen.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_gen.cpp 2013-11-16 21:28:43 UTC (rev 3247) +++ trunk/OpenMPT/mptrack/View_gen.cpp 2013-11-16 23:10:41 UTC (rev 3248) @@ -550,12 +550,13 @@ const SNDMIXPLUGIN &plugin = pSndFile->m_MixPlugins[iOut]; if(plugin.IsValidPlugin()) { - if(!strcmp(plugin.GetLibraryName(), plugin.GetName()) || !strcmp(plugin.GetName(), "")) + std::string libName = mpt::ToLocale(mpt::CharsetUTF8, plugin.GetLibraryName()); + if(!strcmp(plugin.GetName(), "") || libName != plugin.GetName()) { - wsprintf(s, "FX%d: %s", iOut + 1, plugin.GetLibraryName()); + wsprintf(s, "FX%d: %s", iOut + 1, libName.c_str()); } else { - wsprintf(s, "FX%d: %s (%s)", iOut + 1, plugin.GetLibraryName(), plugin.GetName()); + wsprintf(s, "FX%d: %s (%s)", iOut + 1, libName.c_str(), plugin.GetName()); } int n = m_CbnOutput.AddString(s); Modified: trunk/OpenMPT/mptrack/view_com.cpp =================================================================== --- trunk/OpenMPT/mptrack/view_com.cpp 2013-11-16 21:28:43 UTC (rev 3247) +++ trunk/OpenMPT/mptrack/view_com.cpp 2013-11-16 23:10:41 UTC (rev 3248) @@ -420,7 +420,7 @@ case INSLIST_PLUGIN: if (pIns != nullptr && pIns->nMixPlug > 0 && pSndFile->m_MixPlugins[pIns->nMixPlug - 1].pMixPlugin != nullptr) { - wsprintf(s, "FX%02d: %s", pIns->nMixPlug, pSndFile->m_MixPlugins[pIns->nMixPlug - 1].GetLibraryName()); + wsprintf(s, "FX%02d: %s", pIns->nMixPlug, mpt::ToLocale(mpt::CharsetUTF8, pSndFile->m_MixPlugins[pIns->nMixPlug - 1].GetLibraryName()).c_str()); } break; // -> CODE#0023 Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2013-11-16 21:28:43 UTC (rev 3247) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2013-11-16 23:10:41 UTC (rev 3248) @@ -884,13 +884,13 @@ { notFoundText = "The following plugins have not been found:\n\n" + notFoundText + "\nDo you want to search for them online?"; } - if (Reporting::Confirm(notFoundText.c_str(), "OpenMPT - Plugins missing", false, true) == cnfYes) + if (Reporting::Confirm(mpt::ToWide(mpt::CharsetUTF8, notFoundText.c_str()), L"OpenMPT - Plugins missing", false, true) == cnfYes) { std::string sUrl = "http://resources.openmpt.org/plugins/search.php?p="; for(std::vector<PLUGINDEX>::iterator i = notFoundIDs.begin(); i != notFoundIDs.end(); ++i) { sUrl += mpt::fmt::HEX0<8>(LittleEndian(m_MixPlugins[*i].Info.dwPluginId2)); - sUrl += mpt::To(mpt::CharsetUTF8, mpt::CharsetLocale, m_MixPlugins[*i].GetLibraryName()); + sUrl += m_MixPlugins[*i].GetLibraryName(); sUrl += "%0a"; } CTrackApp::OpenURL(mpt::PathString::FromUTF8(sUrl)); @@ -2348,5 +2348,15 @@ } } + if(m_dwLastSavedWithVersion < MAKE_VERSION_NUMERIC(1, 22, 07, 01)) + { + // Convert ANSI plugin path names to UTF-8 (irrelevant in probably 99% of all cases anyway, I think I've never seen a VST plugin with a non-ASCII file name) + for(PLUGINDEX i = 0; i < MAX_MIXPLUGINS; i++) + { + const std::string name = mpt::To(mpt::CharsetUTF8, mpt::CharsetLocale, m_MixPlugins[i].Info.szLibraryName); + mpt::String::Copy(m_MixPlugins[i].Info.szLibraryName, name); + } + } + Patterns.ForEachModCommand(UpgradePatternData(*this)); } \ No newline at end of file Modified: trunk/OpenMPT/soundlib/plugins/PlugInterface.h =================================================================== --- trunk/OpenMPT/soundlib/plugins/PlugInterface.h 2013-11-16 21:28:43 UTC (rev 3247) +++ trunk/OpenMPT/soundlib/plugins/PlugInterface.h 2013-11-16 23:10:41 UTC (rev 3248) @@ -121,8 +121,8 @@ uint8 reserved; uint32 dwOutputRouting; // 0 = send to master 0x80 + x = send to plugin x uint32 dwReserved[4]; // Reserved for routing info - char szName[32]; // User-chosen plugin name - char szLibraryName[64]; // original DLL name + char szName[32]; // User-chosen plugin name - this is locale ANSI! + char szLibraryName[64]; // original DLL name - this is UTF-8! // Should only be called from SNDMIXPLUGIN::SetBypass() and IMixPlugin::Bypass() void SetBypass(bool bypass = true) { if(bypass) routingFlags |= irBypass; else routingFlags &= ~irBypass; } Modified: trunk/OpenMPT/soundlib/plugins/PluginManager.cpp =================================================================== --- trunk/OpenMPT/soundlib/plugins/PluginManager.cpp 2013-11-16 21:28:43 UTC (rev 3247) +++ trunk/OpenMPT/soundlib/plugins/PluginManager.cpp 2013-11-16 23:10:41 UTC (rev 3248) @@ -254,6 +254,8 @@ //--------------------------------------------------------------------------------------------------------------------------------------------------- { const mpt::PathString fileName = dllPath.GetFileName(); + const char *const cacheSection = "PluginCache"; + const wchar_t *const cacheSectionW = L"PluginCache"; if(checkFileExistence && (PathFileExistsW(dllPath.AsNative().c_str()) == FALSE)) { @@ -274,8 +276,6 @@ if(fromCache) { SettingsContainer & cacheFile = theApp.GetPluginCache(); - const char *const cacheSection = "PluginCache"; - const wchar_t *const cacheSectionW = L"PluginCache"; const std::string IDs = cacheFile.Read<std::string>(cacheSectionW, fileName.ToWide(), ""); if(IDs.length() >= 16) @@ -394,8 +394,6 @@ if(validPlug) { SettingsContainer &cacheFile = theApp.GetPluginCache(); - const char *const cacheSection = "PluginCache"; - const wchar_t *const cacheSectionW = L"PluginCache"; const std::string IDs = mpt::String::Format("%08X%08X", p->pluginId1, p->pluginId2); const std::string flagsKey = mpt::String::Format("%s.Flags", IDs); @@ -458,6 +456,8 @@ //----------------------------------------------------------------------------------- { VSTPluginLib *pFound = nullptr; + const char *cacheSection = "PluginCache"; + const wchar_t *cacheSectionW = L"PluginCache"; // Find plugin in library VSTPluginLib *p = m_pVstHead; @@ -466,7 +466,7 @@ { const bool matchID = (p->pluginId1 == mixPlugin.Info.dwPluginId1) && (p->pluginId2 == mixPlugin.Info.dwPluginId2); - const bool matchName = !mpt::strnicmp(p->libraryName.ToLocale().c_str(), mixPlugin.GetLibraryName(), CountOf(mixPlugin.Info.szLibraryName)); + const bool matchName = !mpt::PathString::CompareNoCase(p->libraryName, mpt::PathString::FromUTF8(mixPlugin.GetLibraryName())); if(matchID && matchName) { @@ -508,14 +508,13 @@ { fullPath += MPT_PATHSTRING("\\"); } - fullPath += mpt::PathString::FromLocale(mixPlugin.GetLibraryName()) + MPT_PATHSTRING(".dll"); + fullPath += mpt::PathString::FromUTF8(mixPlugin.GetLibraryName()) + MPT_PATHSTRING(".dll"); pFound = AddPlugin(fullPath); if(!pFound) { SettingsContainer &cacheFile = theApp.GetPluginCache(); - const char *cacheSection = "PluginCache"; - std::string IDs = cacheFile.Read<std::string>(cacheSection, mixPlugin.GetLibraryName(), ""); + std::string IDs = cacheFile.Read<std::string>(cacheSectionW, mpt::ToWide(mpt::CharsetUTF8, mixPlugin.GetLibraryName()), ""); if(IDs.length() >= 16) { fullPath = cacheFile.Read<mpt::PathString>(cacheSection, IDs, MPT_PATHSTRING("")); @@ -547,7 +546,6 @@ { // Update cached information SettingsContainer &cacheFile = theApp.GetPluginCache(); - const char *cacheSection = "PluginCache"; std::string flagsKey = mpt::String::Format("%08X%08X.Flags", pFound->pluginId1, pFound->pluginId2); cacheFile.Write<int32>(cacheSection, flagsKey, pFound->EncodeCacheFlags()); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |