From: <sag...@us...> - 2013-03-22 20:59:17
|
Revision: 1626 http://sourceforge.net/p/modplug/code/1626 Author: saga-games Date: 2013-03-22 20:59:07 +0000 (Fri, 22 Mar 2013) Log Message: ----------- [Imp] Sample Editor: Context menu paste is now greyed out if there's no wave data in the clipboard. (Also updated code for VST editor to not open the clipboard to query this information) [Imp] VST preset saving: If the plugin delivers invalid chunk data for some reason, fall back to parameter saving. [Mod] MIDI Input / Output plugin: Program name is now also restored properly when loading chunk. [Mod] OpenMPT: Version is now 1.21.01.24 Modified Paths: -------------- trunk/OpenMPT/common/version.h trunk/OpenMPT/mptrack/AbstractVstEditor.cpp trunk/OpenMPT/mptrack/View_smp.cpp trunk/OpenMPT/mptrack/VstPresets.cpp trunk/OpenMPT/plugins/MidiInOut/MidiInOut.cpp Modified: trunk/OpenMPT/common/version.h =================================================================== --- trunk/OpenMPT/common/version.h 2013-03-22 20:54:36 UTC (rev 1625) +++ trunk/OpenMPT/common/version.h 2013-03-22 20:59:07 UTC (rev 1626) @@ -19,7 +19,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 21 #define VER_MINOR 01 -#define VER_MINORMINOR 23 +#define VER_MINORMINOR 24 //Creates version number from version parts that appears in version string. //For example MAKE_VERSION_NUMERIC(1,17,02,28) gives version number of Modified: trunk/OpenMPT/mptrack/AbstractVstEditor.cpp =================================================================== --- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2013-03-22 20:54:36 UTC (rev 1625) +++ trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2013-03-22 20:59:07 UTC (rev 1626) @@ -179,6 +179,7 @@ { pModDoc->SetModified(); } + UpdatePresetField(); } else { Reporting::Error(VSTPresets::GetErrorMessage(error)); @@ -450,11 +451,7 @@ { case 0: // Grey out paste menu item. - if(CMainFrame::GetMainFrame() && CMainFrame::GetMainFrame()->OpenClipboard()) - { - m_pMenu->EnableMenuItem(ID_EDIT_PASTE, MF_BYCOMMAND | (::GetClipboardData(clipboardFormat) != nullptr ? 0 : MF_GRAYED)); - CloseClipboard(); - } + m_pMenu->EnableMenuItem(ID_EDIT_PASTE, MF_BYCOMMAND | (IsClipboardFormatAvailable(clipboardFormat) ? 0 : MF_GRAYED)); break; case 1: // Generate preset menu on click. Modified: trunk/OpenMPT/mptrack/View_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_smp.cpp 2013-03-22 20:54:36 UTC (rev 1625) +++ trunk/OpenMPT/mptrack/View_smp.cpp 2013-03-22 20:59:07 UTC (rev 1626) @@ -124,8 +124,8 @@ m_dwStatus = 0; m_nScrollFactor = 0; m_nBtnMouseOver = 0xFFFF; - memset(m_dwNotifyPos, 0, sizeof(m_dwNotifyPos)); - memset(m_NcButtonState, 0, sizeof(m_NcButtonState)); + MemsetZero(m_dwNotifyPos); + MemsetZero(m_NcButtonState); m_bmpEnvBar.Create(IDB_SMPTOOLBAR, 20, 0, RGB(192,192,192)); m_lastDrawPoint.SetPoint(-1, -1); } @@ -1246,7 +1246,7 @@ //--------------------------------------------------------- { STATIC_ASSERT(sizeof(T) == sizeof(uT) && sizeof(T) <= 2); - int value = (std::numeric_limits<T>::max)() - (std::numeric_limits<uT>::max)() * point.y / (m_rcClient.bottom - m_rcClient.top); + int value = (std::numeric_limits<T>::max)() - (std::numeric_limits<uT>::max)() * point.y / m_rcClient.Height(); Limit(value, (std::numeric_limits<T>::min)(), (std::numeric_limits<T>::max)()); return static_cast<T>(value); } @@ -1440,8 +1440,7 @@ InvalidateSample(); pModDoc->SetModified(); - } - else + } else { // ctrl + click = play from cursor pos if(CMainFrame::GetInputHandler()->CtrlPressed()) @@ -1565,7 +1564,7 @@ ::AppendMenu(hMenu, MF_STRING, ID_EDIT_CUT, "Cu&t\t" + ih->GetKeyTextFromCommand(kcEditCut)); ::AppendMenu(hMenu, MF_STRING, ID_EDIT_COPY, "&Copy\t" + ih->GetKeyTextFromCommand(kcEditCopy)); } - ::AppendMenu(hMenu, MF_STRING, ID_EDIT_PASTE, "&Paste\t" + ih->GetKeyTextFromCommand(kcEditPaste)); + ::AppendMenu(hMenu, MF_STRING | (IsClipboardFormatAvailable(CF_WAVE) ? 0 : MF_GRAYED), ID_EDIT_PASTE, "&Paste\t" + ih->GetKeyTextFromCommand(kcEditPaste)); ::AppendMenu(hMenu, MF_STRING | (pModDoc->GetSampleUndo().CanUndo(m_nSample) ? 0 : MF_GRAYED), ID_EDIT_UNDO, "&Undo\t" + ih->GetKeyTextFromCommand(kcEditUndo)); ClientToScreen(&pt); ::TrackPopupMenu(hMenu, TPM_LEFTALIGN|TPM_RIGHTBUTTON, pt.x, pt.y, 0, m_hWnd, NULL); @@ -2043,7 +2042,7 @@ { p[i] = (signed char) ((*((short int *)(p+i*2))) / 256); } - sample.uFlags &= ~(CHN_16BIT); + sample.uFlags.reset(CHN_16BIT); for (UINT j=0; j<MAX_CHANNELS; j++) if (pSndFile->Chn[j].pSample == sample.pSample) { pSndFile->Chn[j].dwFlags.reset(CHN_16BIT); @@ -2180,12 +2179,12 @@ if (sample.nLoopStart >= sample.nLoopEnd) { sample.nLoopStart = sample.nLoopEnd = 0; - sample.uFlags &= ~(CHN_LOOP|CHN_PINGPONGLOOP); + sample.uFlags.reset(CHN_LOOP|CHN_PINGPONGLOOP); } if (sample.nSustainStart >= sample.nSustainEnd) { sample.nSustainStart = sample.nSustainEnd = 0; - sample.uFlags &= ~(CHN_SUSTAINLOOP|CHN_PINGPONGSUSTAIN); + sample.uFlags.reset(CHN_SUSTAINLOOP|CHN_PINGPONGSUSTAIN); } sample.nLength = nEnd; @@ -2205,6 +2204,7 @@ { } + void CViewSample::PlayNote(UINT note, const uint32 nStartPos) //----------------------------------------------------------- { @@ -2225,7 +2225,7 @@ pModDoc->NoteOff(0, true); SmpLength loopstart = m_dwBeginSel, loopend = m_dwEndSel; - if (loopend - loopstart < (UINT)(4 << m_nZoom)) + if (loopend - loopstart < (SmpLength)(4 << m_nZoom)) loopend = loopstart = 0; // selection is too small -> no loop pModDoc->PlayNote(note, 0, m_nSample, false, -1, loopstart, loopend, CHANNELINDEX_INVALID, nStartPos); Modified: trunk/OpenMPT/mptrack/VstPresets.cpp =================================================================== --- trunk/OpenMPT/mptrack/VstPresets.cpp 2013-03-22 20:54:36 UTC (rev 1625) +++ trunk/OpenMPT/mptrack/VstPresets.cpp 2013-03-22 20:59:07 UTC (rev 1626) @@ -125,10 +125,9 @@ SaveProgram(f, plugin); } else { - const bool writeChunk = plugin.ProgramsAreChunks(); + bool writeChunk = plugin.ProgramsAreChunks(); ChunkHeader header; header.chunkMagic = cMagic; - header.fxMagic = writeChunk ? chunkBankMagic : bankMagic; header.version = 2; header.fxID = plugin.GetUID(); header.fxVersion = plugin.GetVersion(); @@ -136,7 +135,7 @@ // Write unfinished header... We need to update the size once we're done writing. Write(header, f); - uint32 numProgs = plugin.GetNumPrograms(), curProg = plugin.GetCurrentProgram(); + uint32 numProgs = Util::Max(plugin.GetNumPrograms(), VstInt32(1)), curProg = plugin.GetCurrentProgram(); WriteBE(numProgs, f); WriteBE(curProg, f); char reserved[124]; @@ -151,8 +150,13 @@ { WriteBE(chunkSize, f); f.write(chunk, chunkSize); + } else + { + // The plugin returned no chunk! Gracefully go back and save parameters instead... + writeChunk = false; } - } else + } + if(!writeChunk) { for(uint32 p = 0; p < numProgs; p++) { @@ -165,6 +169,7 @@ // Now we know the correct chunk size. std::streamoff end = f.tellp(); header.byteSize = static_cast<VstInt32>(end - 8); + header.fxMagic = writeChunk ? chunkBankMagic : bankMagic; header.ConvertEndianness(); f.seekp(0); Write(header, f); @@ -177,10 +182,9 @@ void VSTPresets::SaveProgram(std::ostream &f, CVstPlugin &plugin) //--------------------------------------------------------------- { - const bool writeChunk = plugin.ProgramsAreChunks(); + bool writeChunk = plugin.ProgramsAreChunks(); ChunkHeader header; header.chunkMagic = cMagic; - header.fxMagic = writeChunk ? chunkPresetMagic : fMagic; header.version = 1; header.fxID = plugin.GetUID(); header.fxVersion = plugin.GetVersion(); @@ -204,8 +208,13 @@ { WriteBE(chunkSize, f); f.write(chunk, chunkSize); + } else + { + // The plugin returned no chunk! Gracefully go back and save parameters instead... + writeChunk = false; } - } else + } + if(!writeChunk) { for(uint32 p = 0; p < numParams; p++) { @@ -216,6 +225,7 @@ // Now we know the correct chunk size. std::streamoff end = f.tellp(); header.byteSize = static_cast<VstInt32>(end - start - 8); + header.fxMagic = writeChunk ? chunkPresetMagic : fMagic; header.ConvertEndianness(); f.seekp(start); Write(header, f); Modified: trunk/OpenMPT/plugins/MidiInOut/MidiInOut.cpp =================================================================== --- trunk/OpenMPT/plugins/MidiInOut/MidiInOut.cpp 2013-03-22 20:54:36 UTC (rev 1625) +++ trunk/OpenMPT/plugins/MidiInOut/MidiInOut.cpp 2013-03-22 20:59:07 UTC (rev 1626) @@ -132,11 +132,15 @@ VstInt32 nameStrSize = std::min(header[2], byteSize - VstInt32(8 * sizeof(VstInt32))); VstInt32 inStrSize = std::min(header[4], byteSize - VstInt32(8 * sizeof(VstInt32) - nameStrSize)); VstInt32 outStrSize = std::min(header[6], byteSize - VstInt32(8 * sizeof(VstInt32) - nameStrSize - inStrSize)); + + const char *nameStr = reinterpret_cast<const char *>(data) + 8 * sizeof(VstInt32); + const char *inStr = reinterpret_cast<const char *>(data) + 8 * sizeof(VstInt32) + nameStrSize; + const char *outStr = reinterpret_cast<const char *>(data) + 8 * sizeof(VstInt32) + nameStrSize + inStrSize; + PmDeviceID inID = header[3]; PmDeviceID outID = header[5]; - const char *inStr = reinterpret_cast<const char *>(data) + 8 * sizeof(VstInt32) + header[2]; - const char *outStr = reinterpret_cast<const char *>(data) + 8 * sizeof(VstInt32) + header[2] + inStrSize; + vst_strncpy(programName, nameStr, std::min(nameStrSize, VstInt32(kVstMaxProgNameLen))); if(strncmp(inStr, GetDeviceName(inID), inStrSize)) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |