From: <rel...@us...> - 2009-12-30 21:54:27
|
Revision: 452 http://modplug.svn.sourceforge.net/modplug/?rev=452&view=rev Author: relabsoluness Date: 2009-12-30 21:54:16 +0000 (Wed, 30 Dec 2009) Log Message: ----------- [Imp] Pattern editor: If keyboard split is active, instrument drop list will show split instrument and split note. [Mod] Pattern c&p: Mix paste shouldn't anymore trigger conversion on modcommands that weren't changed at all (appeared in rev. 403). Now, however, partial conversion will not be done so this still needs further fixing. [Fix] Pattern c&p: Mix paste should behave better with parameter control notes. [Ref/Fix] Minor tweaks and fixes (fixes to use of CStrings in wsprintf parameters, cleaned compiler warnings, small adjustment to orderlist resizing after loading module...) Modified Paths: -------------- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp trunk/OpenMPT/mptrack/Ctrl_pat.cpp trunk/OpenMPT/mptrack/Ctrl_seq.cpp trunk/OpenMPT/mptrack/Mod2wave.cpp trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/Moddoc.h trunk/OpenMPT/mptrack/Modedit.cpp trunk/OpenMPT/mptrack/View_pat.cpp trunk/OpenMPT/mptrack/dlg_misc.cpp trunk/OpenMPT/mptrack/fxp.cpp trunk/OpenMPT/mptrack/misc_util.cpp trunk/OpenMPT/mptrack/misc_util.h trunk/OpenMPT/mptrack/typedefs.h trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/soundlib/Sndfile.h trunk/OpenMPT/soundlib/modcommand.h Modified: trunk/OpenMPT/mptrack/AbstractVstEditor.cpp =================================================================== --- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2009-12-28 02:57:57 UTC (rev 451) +++ trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2009-12-30 21:54:16 UTC (rev 452) @@ -175,11 +175,11 @@ if(m_pVstPlugin->GetNumPrograms() > 0 && m_pMenu->GetMenuItemCount() < 5) { - m_pMenu->AppendMenu(MF_BYPOSITION, ID_VSTPRESETBACKWARDJUMP, (LPCTSTR)"<<"); - m_pMenu->AppendMenu(MF_BYPOSITION, ID_PREVIOUSVSTPRESET, (LPCTSTR)"<"); - m_pMenu->AppendMenu(MF_BYPOSITION, ID_NEXTVSTPRESET, (LPCTSTR)">"); - m_pMenu->AppendMenu(MF_BYPOSITION, ID_VSTPRESETFORWARDJUMP, (LPCTSTR)">>"); - m_pMenu->AppendMenu(MF_BYPOSITION|MF_DISABLED, 0, ""); + m_pMenu->AppendMenu(MF_BYPOSITION, ID_VSTPRESETBACKWARDJUMP, TEXT("<<")); + m_pMenu->AppendMenu(MF_BYPOSITION, ID_PREVIOUSVSTPRESET, TEXT("<")); + m_pMenu->AppendMenu(MF_BYPOSITION, ID_NEXTVSTPRESET, TEXT(">")); + m_pMenu->AppendMenu(MF_BYPOSITION, ID_VSTPRESETFORWARDJUMP, TEXT(">>")); + m_pMenu->AppendMenu(MF_BYPOSITION|MF_DISABLED, 0, TEXT("")); } long index = m_pVstPlugin->GetCurrentProgram(); @@ -470,7 +470,7 @@ m_pInputMenu->AppendMenu(MF_SEPARATOR); } name.Format("Ins%02d: %s", inputInstruments[nIns], pSndFile->Instruments[inputInstruments[nIns]]->name); - if (inputInstruments[nIns]==m_nInstrument) checked=true; + if (inputInstruments[nIns] == (UINT)m_nInstrument) checked=true; m_pInputMenu->AppendMenu(MF_STRING|(checked?MF_CHECKED:0), ID_SELECTINST+inputInstruments[nIns], name); } Modified: trunk/OpenMPT/mptrack/Ctrl_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_pat.cpp 2009-12-28 02:57:57 UTC (rev 451) +++ trunk/OpenMPT/mptrack/Ctrl_pat.cpp 2009-12-30 21:54:16 UTC (rev 452) @@ -254,29 +254,47 @@ LockControls(); if (dwHintMask & (HINT_MODTYPE|HINT_INSNAMES|HINT_SMPNAMES)) { + static const TCHAR szSplitFormat[] = TEXT("%02u %s %02u: %s/%s"); UINT nPos = 0; m_CbnInstrument.SetRedraw(FALSE); m_CbnInstrument.ResetContent(); m_CbnInstrument.SetItemData(m_CbnInstrument.AddString(" No Instrument"), 0); - if (m_pSndFile->m_nInstruments) { - for (UINT i=1; i<=m_pSndFile->m_nInstruments; i++) { + const INSTRUMENTINDEX nSplitIns = m_pModDoc->GetSplitKeyboardSettings()->splitInstrument; + const MODCOMMAND::NOTE noteSplit = 1 + m_pModDoc->GetSplitKeyboardSettings()->splitNote; + const CString sSplitInsName = m_pModDoc->GetPatternViewInstrumentName(nSplitIns, true, false); + if (m_pSndFile->m_nInstruments) + { + for (UINT i=1; i<=m_pSndFile->m_nInstruments; i++) + { if (m_pSndFile->Instruments[i] == NULL) { continue; } - CString displayName = m_pSndFile->GetPatternViewInstrumentName(i); - UINT n = m_CbnInstrument.AddString(displayName); + CString sDisplayName; + if (m_pModDoc->GetSplitKeyboardSettings()->IsSplitActive()) + { + wsprintf(s, szSplitFormat, nSplitIns, GetNoteStr(noteSplit), i, + (LPCTSTR)sSplitInsName, (LPCTSTR)m_pModDoc->GetPatternViewInstrumentName(i, true, false)); + sDisplayName = s; + } + else + sDisplayName = m_pModDoc->GetPatternViewInstrumentName(i); + + UINT n = m_CbnInstrument.AddString(sDisplayName); if (n == m_nInstrument) nPos = n; m_CbnInstrument.SetItemData(n, i); - } - } else { UINT nmax = m_pSndFile->m_nSamples; while ((nmax > 1) && (m_pSndFile->Samples[nmax].pSample == NULL) && (!m_pSndFile->m_szNames[nmax][0])) nmax--; - for (UINT i=1; i<=nmax; i++) if ((m_pSndFile->m_szNames[i][0]) || (m_pSndFile->Samples[i].pSample)) { - wsprintf(s, "%02d: %s", i, m_pSndFile->m_szNames[i]); + for (UINT i=1; i<=nmax; i++) if ((m_pSndFile->m_szNames[i][0]) || (m_pSndFile->Samples[i].pSample)) + { + if (m_pModDoc->GetSplitKeyboardSettings()->IsSplitActive() && nSplitIns < ARRAYELEMCOUNT(m_pSndFile->m_szNames)) + wsprintf(s, szSplitFormat, nSplitIns, GetNoteStr(noteSplit), i, m_pSndFile->m_szNames[nSplitIns], m_pSndFile->m_szNames[i]); + else + wsprintf(s, "%02u: %s", i, m_pSndFile->m_szNames[i]); + UINT n = m_CbnInstrument.AddString(s); if (n == m_nInstrument) nPos = n; m_CbnInstrument.SetItemData(n, i); @@ -482,7 +500,7 @@ if (m_CbnInstrument.GetItemData(i) == nIns) { m_CbnInstrument.SetCurSel(i); - m_nInstrument = nIns; + m_nInstrument = static_cast<INSTRUMENTINDEX>(nIns); //rewbs.instroVST if (HasValidPlug(m_nInstrument)) ::EnableWindow(::GetDlgItem(m_hWnd, IDC_PATINSTROPLUGGUI), true); @@ -678,7 +696,7 @@ int nmax = (m_pSndFile->m_nInstruments) ? m_pSndFile->m_nInstruments : m_pSndFile->m_nSamples; if ((n >= 0) && (n <= nmax) && (n != (int)m_nInstrument)) { - m_nInstrument = n; + m_nInstrument = static_cast<INSTRUMENTINDEX>(n); if (m_pParent) m_pParent->InstrumentChanged(m_nInstrument); } SwitchToView(); Modified: trunk/OpenMPT/mptrack/Ctrl_seq.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_seq.cpp 2009-12-28 02:57:57 UTC (rev 451) +++ trunk/OpenMPT/mptrack/Ctrl_seq.cpp 2009-12-30 21:54:16 UTC (rev 452) @@ -674,12 +674,13 @@ s[0] = 0; if(CMainFrame::m_dwPatternSetup & PATTERN_HEXDISPLAY) { - wsprintf(s, "Position %02Xh of %02Xh", m_nScrollPos, pSndFile->GetNumPatterns()); + wsprintf(s, "Position %02Xh of %02Xh", m_nScrollPos, pSndFile->Order.GetLengthFirstEmpty()); } else { + const ORDERINDEX nLength = pSndFile->Order.GetLengthFirstEmpty(); wsprintf(s, "Position %d of %d (%02Xh of %02Xh)", - m_nScrollPos, pSndFile->GetNumPatterns(), m_nScrollPos, pSndFile->GetNumPatterns()); + m_nScrollPos, nLength, m_nScrollPos, nLength); } if (m_nScrollPos < pSndFile->Order.GetLength()) Modified: trunk/OpenMPT/mptrack/Mod2wave.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mod2wave.cpp 2009-12-28 02:57:57 UTC (rev 451) +++ trunk/OpenMPT/mptrack/Mod2wave.cpp 2009-12-30 21:54:16 UTC (rev 452) @@ -667,7 +667,7 @@ ULONGLONG l = ((ULONGLONG)m_pSndFile->GetSongTime()) * m_pWaveFormat->nSamplesPerSec; if (m_nMaxPatterns > 0) { - DWORD dwOrds = m_pSndFile->GetNumPatterns(); + DWORD dwOrds = m_pSndFile->Order.GetLengthFirstEmpty(); if ((m_nMaxPatterns < dwOrds) && (dwOrds > 0)) l = (l*m_nMaxPatterns) / dwOrds; } if (l < max) max = l; Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2009-12-28 02:57:57 UTC (rev 451) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2009-12-30 21:54:16 UTC (rev 452) @@ -22,12 +22,12 @@ static char THIS_FILE[] = __FILE__; #endif -const std::string FileFilterMOD = _T("ProTracker Modules (*.mod)|*.mod||"); -const std::string FileFilterXM = _T("FastTracker Modules (*.xm)|*.xm||"); -const std::string FileFilterS3M = _T("ScreamTracker Modules (*.s3m)|*.s3m||"); -const std::string FileFilterIT = _T("Impulse Tracker Modules (*.it)|*.it||"); -const std::string FileFilterITP = _T("Impulse Tracker Projects (*.itp)|*.itp||"); -const std::string FileFilterMPT = _T("OpenMPT Modules (*.mptm)|*.mptm||"); +const TCHAR FileFilterMOD[] = _T("ProTracker Modules (*.mod)|*.mod||"); +const TCHAR FileFilterXM[] = _T("FastTracker Modules (*.xm)|*.xm||"); +const TCHAR FileFilterS3M[] = _T("ScreamTracker Modules (*.s3m)|*.s3m||"); +const TCHAR FileFilterIT[] = _T("Impulse Tracker Modules (*.it)|*.it||"); +const TCHAR FileFilterITP[] = _T("Impulse Tracker Projects (*.itp)|*.itp||"); +const TCHAR FileFilterMPT[] = _T("OpenMPT Modules (*.mptm)|*.mptm||"); ///////////////////////////////////////////////////////////////////////////// // CModDoc @@ -366,7 +366,7 @@ if (m_SndFile.m_dwLastSavedWithVersion > MptVersion::num) { char s[256]; wsprintf(s, "Warning: this song was last saved with a more recent version of OpenMPT.\r\nSong saved with: v%s. Current version: v%s.\r\n", - MptVersion::ToStr(m_SndFile.m_dwLastSavedWithVersion), + (LPCTSTR)MptVersion::ToStr(m_SndFile.m_dwLastSavedWithVersion), MptVersion::str); ::AfxMessageBox(s); } @@ -3467,3 +3467,50 @@ pMainFrm->ResetElapsedTime(); } + +CString CModDoc::GetPatternViewInstrumentName(UINT nInstr, + bool bEmptyInsteadOfNoName /* = false*/, + bool bIncludeIndex /* = true*/) const +//----------------------------------------------------------------------------------- +{ + if(nInstr >= MAX_INSTRUMENTS || m_SndFile.GetNumInstruments() == 0 || m_SndFile.Instruments[nInstr] == nullptr) + return TEXT(""); + + CString displayName, instrumentName, pluginName; + + // Get instrument name. + instrumentName = m_SndFile.GetInstrumentName(nInstr); + + // If instrument name is empty, use name of the sample mapped to C-5. + if (instrumentName.IsEmpty()) + { + const SAMPLEINDEX nSmp = m_SndFile.Instruments[nInstr]->Keyboard[60]; + if (nSmp < ARRAYELEMCOUNT(m_SndFile.Samples) && m_SndFile.Samples[nSmp].pSample) + instrumentName.Format(TEXT("s: %s"), (LPCTSTR)m_SndFile.GetSampleName(nSmp)); //60 is C-5 + } + + // Get plugin name. + const PLUGINDEX nPlug = m_SndFile.Instruments[nInstr]->nMixPlug; + if (nPlug > 0 && nPlug < MAX_MIXPLUGINS) + pluginName = m_SndFile.m_MixPlugins[nPlug-1].GetName(); + + if (pluginName.IsEmpty()) + { + if(bEmptyInsteadOfNoName && instrumentName.IsEmpty()) + return TEXT(""); + if(instrumentName.IsEmpty()) + instrumentName = TEXT("(no name)"); + if (bIncludeIndex) + displayName.Format(TEXT("%02d: %s"), nInstr, (LPCTSTR)instrumentName); + else + displayName.Format(TEXT("%s"), (LPCTSTR)instrumentName); + } else + { + if (bIncludeIndex) + displayName.Format(TEXT("%02d: %s (%s)"), nInstr, (LPCTSTR)instrumentName, (LPCTSTR)pluginName); + else + displayName.Format(TEXT("%s (%s)"), (LPCTSTR)instrumentName, (LPCTSTR)pluginName); + } + return displayName; +} + Modified: trunk/OpenMPT/mptrack/Moddoc.h =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.h 2009-12-28 02:57:57 UTC (rev 451) +++ trunk/OpenMPT/mptrack/Moddoc.h 2009-12-30 21:54:16 UTC (rev 452) @@ -118,9 +118,15 @@ // Split Keyboard Settings (pattern editor) #define SPLIT_OCTAVE_RANGE 9 + +//========================== struct SplitKeyboardSettings +//========================== { - UINT splitInstrument, splitNote, splitVolume; + bool IsSplitActive() {return (octaveLink && (octaveModifier != 0)) || (splitInstrument > 0) || (splitVolume != 0);} + MODCOMMAND::NOTE splitNote; + MODCOMMAND::INSTR splitInstrument; + MODCOMMAND::VOL splitVolume; int octaveModifier; // determines by how many octaves the notes should be transposed up or down bool octaveLink; // apply octaveModifier }; @@ -291,6 +297,12 @@ void OnFileWaveConvert(ORDERINDEX nMinOrder, ORDERINDEX nMaxOrder); + // Returns formatted MODINSTRUMENT name. + // [in] bEmptyInsteadOfNoName: In case of unnamed instrument string, "(no name)" is returned unless this + // parameter is true is case which an empty name is returned. + // [in] bIncludeIndex: True to include instrument index in front of the instrument name, false otherwise. + CString GetPatternViewInstrumentName(UINT nInstr, bool bEmptyInsteadOfNoName = false, bool bIncludeIndex = true) const; + // protected members protected: CSize m_szOldPatternScrollbarsPos; Modified: trunk/OpenMPT/mptrack/Modedit.cpp =================================================================== --- trunk/OpenMPT/mptrack/Modedit.cpp 2009-12-28 02:57:57 UTC (rev 451) +++ trunk/OpenMPT/mptrack/Modedit.cpp 2009-12-30 21:54:16 UTC (rev 452) @@ -1179,9 +1179,9 @@ MODTYPE origFormat = MOD_TYPE_IT; UINT len = 0, startLen; - bool doOverflowPaste = (CMainFrame::m_dwPatternSetup & PATTERN_OVERFLOWPASTE) && (pasteMode != pm_pasteflood) && (pasteMode != pm_pushforwardpaste); - bool doITStyleMix = (pasteMode == pm_mixpaste_it); - bool doMixPaste = ((pasteMode == pm_mixpaste) || doITStyleMix); + const bool doOverflowPaste = (CMainFrame::m_dwPatternSetup & PATTERN_OVERFLOWPASTE) && (pasteMode != pm_pasteflood) && (pasteMode != pm_pushforwardpaste); + const bool doITStyleMix = (pasteMode == pm_mixpaste_it); + const bool doMixPaste = ((pasteMode == pm_mixpaste) || doITStyleMix); ORDERINDEX oCurrentOrder; //jojo.echopaste ROWINDEX rTemp, startRow; @@ -1234,14 +1234,23 @@ // Paste columns while ((p[len] == '|') && (len + 11 < dwMemSize)) { - // ITSyle mixpaste requires that we keep a copy of the thing we are about to paste on - // so that we can refer back to check if there was anything in e.g. the note column before we pasted. - MODCOMMAND origModCmd = m[col]; - LPSTR s = p+len+1; - if (col < m_SndFile.m_nChannels) + // Check valid paste condition. Paste will be skipped if + // -col is not a valid channelindex or + // -doing mix paste and paste destination modcommand is a PCnote or + // -doing mix paste and trying to paste PCnote on non-empty modcommand. + const bool bSkipPaste = + (col >= m_SndFile.GetNumChannels()) || + (doMixPaste && m[col].IsPcNote()) || + (doMixPaste && s[0] == 'P' && !m[col].IsEmpty()); + + if (bSkipPaste == false) { + // ITSyle mixpaste requires that we keep a copy of the thing we are about to paste on + // so that we can refer back to check if there was anything in e.g. the note column before we pasted. + const MODCOMMAND origModCmd = m[col]; + // push channel data below paste point first. if(pasteMode == pm_pushforwardpaste) { @@ -1294,7 +1303,7 @@ { if (s[5] != '.') { - if(m[col].note == NOTE_PCS || m[col].note == NOTE_PC) + if(m[col].IsPcNote()) { char val[4]; memcpy(val, s+5, 3); @@ -1317,9 +1326,9 @@ } else m[col].volcmd = m[col].vol = 0; } - if(m[col].note == NOTE_PCS || m[col].note == NOTE_PC) + if (m[col].IsPcNote()) { - if(s[8] != '.' && s[8] > ' ') + if (s[8] != '.' && s[8] > ' ') { char val[4]; memcpy(val, s+8, 3); @@ -1382,9 +1391,14 @@ } } } + + // convert some commands, if necessary. With mix paste convert only + // if the original modcommand was empty as otherwise the unchanged parts + // of the old modcommand would falsely be interpreted being of type + // origFormat and ConvertCommand could change them. + if (origFormat != m_SndFile.m_nType && (doMixPaste == false || origModCmd.IsEmpty())) + m_SndFile.ConvertCommand(&(m[col]), origFormat, m_SndFile.m_nType); } - // convert some commands, if necessary. - if(origFormat != m_SndFile.m_nType) m_SndFile.ConvertCommand(&(m[col]), origFormat, m_SndFile.m_nType); len += 12; col++; Modified: trunk/OpenMPT/mptrack/View_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_pat.cpp 2009-12-28 02:57:57 UTC (rev 451) +++ trunk/OpenMPT/mptrack/View_pat.cpp 2009-12-30 21:54:16 UTC (rev 452) @@ -3090,7 +3090,7 @@ // Need to convert to linear in [0;64] - see below BYTE event = GetFromMIDIMsg_Event(dwMidiData); - if ((event == 0x9) && !nVol) event = 0x8; //Convert event to note-off if req'd + if ((event == MIDIEVENT_NOTEON) && !nVol) event = MIDIEVENT_NOTEOFF; //Convert event to note-off if req'd // Handle MIDI mapping. @@ -3116,14 +3116,14 @@ switch(event) { - case 0x8: // Note Off + case MIDIEVENT_NOTEOFF: // Note Off // The following method takes care of: // . Silencing specific active notes (just setting nNote to 255 as was done before is not acceptible) // . Entering a note off in pattern if required TempStopNote(nNote, ((CMainFrame::m_dwMidiSetup & MIDISETUP_RECORDNOTEOFF) != 0)); break; - case 0x9: // Note On + case MIDIEVENT_NOTEON: // Note On nVol = ApplyVolumeRelatedMidiSettings(dwMidiData, midivolume); if(nVol < 0) nVol = -1; else nVol = (nVol + 3) / 4; //Value from [0,256] to [0,64] @@ -3135,10 +3135,10 @@ break; - case 0xB: //Controller change + case MIDIEVENT_CONTROLLERCHANGE: //Controller change switch(nByte1) { - case 0x7: //Volume + case MIDICC_Volume_Coarse: //Volume midivolume = nByte2; break; } @@ -4934,8 +4934,10 @@ HMENU instrumentChangeMenu = ::CreatePopupMenu(); AppendMenu(hMenu, MF_POPUP|greyed, (UINT)instrumentChangeMenu, "Change Instrument\t" + ih->GetKeyTextFromCommand(kcPatternSetInstrument)); - if(pSndFile == NULL) + if(pSndFile == nullptr || pSndFile->GetpModDoc() == nullptr) return false; + + CModDoc* const pModDoc = pSndFile->GetpModDoc(); if(!greyed) { @@ -4946,8 +4948,8 @@ if (pSndFile->Instruments[i] == NULL) continue; - CString instString = pSndFile->GetPatternViewInstrumentName(i, true); - if(instString.GetLength() > 0) AppendMenu(instrumentChangeMenu, MF_STRING, ID_CHANGE_INSTRUMENT+i, pSndFile->GetPatternViewInstrumentName(i)); + CString instString = pModDoc->GetPatternViewInstrumentName(i, true); + if(instString.GetLength() > 0) AppendMenu(instrumentChangeMenu, MF_STRING, ID_CHANGE_INSTRUMENT+i, pModDoc->GetPatternViewInstrumentName(i)); //Adding the entry to the list only if it has some name, since if the name is empty, //it likely is some non-used instrument. } @@ -5213,7 +5215,8 @@ if(pSndFile == nullptr) return; CSplitKeyboadSettings dlg(CMainFrame::GetMainFrame(), pSndFile, pModDoc->GetSplitKeyboardSettings()); - dlg.DoModal(); + if (dlg.DoModal() == IDOK) + pModDoc->UpdateAllViews(NULL, HINT_INSNAMES|HINT_SMPNAMES); } Modified: trunk/OpenMPT/mptrack/dlg_misc.cpp =================================================================== --- trunk/OpenMPT/mptrack/dlg_misc.cpp 2009-12-28 02:57:57 UTC (rev 451) +++ trunk/OpenMPT/mptrack/dlg_misc.cpp 2009-12-30 21:54:16 UTC (rev 452) @@ -1948,7 +1948,7 @@ end=NMACROS; } - for (UINT m=0; m<NMACROS; m++) { + for (int m=0; m<NMACROS; m++) { //SFx s.Format("SF%X", m); m_EditMacro[m].SetWindowText(s); @@ -1956,7 +1956,7 @@ //Macro value: CString macroText = &m_MidiCfg.szMidiSFXExt[m*32]; m_EditMacroValue[m].SetWindowText(macroText); - m_EditMacroValue[m].SetBackColor(m==selectedMacro?RGB(200,200,225) : RGB(245,245,245) ); + m_EditMacroValue[m].SetBackColor(m == selectedMacro ? RGB(200,200,225) : RGB(245,245,245) ); //Macro Type: macroType = m_pModDoc->GetMacroType(macroText); @@ -1977,7 +1977,7 @@ default: s = "Custom"; } m_EditMacroType[m].SetWindowText(s); - m_EditMacroType[m].SetBackColor(m==selectedMacro?RGB(200,200,225) : RGB(245,245,245) ); + m_EditMacroType[m].SetBackColor(m == selectedMacro ? RGB(200,200,225) : RGB(245,245,245) ); //Param details button: if (macroType == sfx_plug) @@ -2698,7 +2698,7 @@ BOOL CSplitKeyboadSettings::OnInitDialog() //---------------------------------------- { - if(!m_pSndFile) return FALSE; + if(!m_pSndFile || m_pSndFile->GetpModDoc() == nullptr) return FALSE; CDialog::OnInitDialog(); @@ -2739,7 +2739,7 @@ continue; } - CString displayName = m_pSndFile->GetPatternViewInstrumentName(nIns); + CString displayName = m_pSndFile->GetpModDoc()->GetPatternViewInstrumentName(nIns); int n = m_CbnSplitInstrument.AddString(displayName); m_CbnSplitInstrument.SetItemData(n, nIns); } @@ -2876,7 +2876,7 @@ } if (bUsed) { CString sampleName; - sampleName.Format("%d: %s", i, m_pSndFile->GetSampleName(i)); + sampleName.Format("%d: %s", i, (LPCTSTR)m_pSndFile->GetSampleName(i)); nInsertPos = m_CbnSample.AddString(sampleName); m_CbnSample.SetItemData(nInsertPos, i); Modified: trunk/OpenMPT/mptrack/fxp.cpp =================================================================== --- trunk/OpenMPT/mptrack/fxp.cpp 2009-12-28 02:57:57 UTC (rev 451) +++ trunk/OpenMPT/mptrack/fxp.cpp 2009-12-30 21:54:16 UTC (rev 452) @@ -232,7 +232,7 @@ { ::AfxMessageBox(e->m_strFileName); char s[256]; - wsprintf(s, "%lx: %d; %d; %s;", e, e->m_cause, e->m_lOsError, e->m_strFileName); + wsprintf(s, "%lx: %d; %d; %s;", e, e->m_cause, e->m_lOsError, (LPCTSTR)e->m_strFileName); ::AfxMessageBox(s); e->Delete(); } Modified: trunk/OpenMPT/mptrack/misc_util.cpp =================================================================== --- trunk/OpenMPT/mptrack/misc_util.cpp 2009-12-28 02:57:57 UTC (rev 451) +++ trunk/OpenMPT/mptrack/misc_util.cpp 2009-12-30 21:54:16 UTC (rev 452) @@ -3,10 +3,10 @@ /* * Loads resource. - * lpName and lpType: parameters passed to FindResource(). - * pData: Pointer to loaded resource data, nullptr if load not successful. - * nSize: Size of the data in bytes, zero if load not succesfull. - * hglob: HGLOBAL returned by LoadResource-function. + * [in] lpName and lpType: parameters passed to FindResource(). + * [out] pData: Pointer to loaded resource data, nullptr if load not successful. + * [out] nSize: Size of the data in bytes, zero if load not succesfull. + * [out] hglob: HGLOBAL returned by LoadResource-function. * Return: pData. */ LPCCH LoadResource(LPCTSTR lpName, LPCTSTR lpType, LPCCH& pData, size_t& nSize, HGLOBAL& hglob) Modified: trunk/OpenMPT/mptrack/misc_util.h =================================================================== --- trunk/OpenMPT/mptrack/misc_util.h 2009-12-28 02:57:57 UTC (rev 451) +++ trunk/OpenMPT/mptrack/misc_util.h 2009-12-30 21:54:16 UTC (rev 452) @@ -5,11 +5,6 @@ #include <string> #include <limits> -#define ARRAYELEMCOUNT(x) (sizeof(x)/sizeof(x[0])) - -//Compile time assert. -#define STATIC_ASSERT(expr) C_ASSERT(expr) - //Convert object(typically number) to string template<class T> inline std::string Stringify(const T& x) Modified: trunk/OpenMPT/mptrack/typedefs.h =================================================================== --- trunk/OpenMPT/mptrack/typedefs.h 2009-12-28 02:57:57 UTC (rev 451) +++ trunk/OpenMPT/mptrack/typedefs.h 2009-12-30 21:54:16 UTC (rev 452) @@ -2,7 +2,13 @@ #define TYPEDEFS_H #define nullptr 0 +#define ARRAYELEMCOUNT(x) (sizeof(x)/sizeof(x[0])) +//Compile time assert. +#define STATIC_ASSERT(expr) C_ASSERT(expr) +#define static_assert(expr, msg) C_ASSERT(expr) + + typedef __int8 int8; typedef __int16 int16; typedef __int32 int32; Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2009-12-28 02:57:57 UTC (rev 451) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2009-12-30 21:54:16 UTC (rev 452) @@ -786,7 +786,9 @@ if (m_nType) { SetModSpecsPointer(m_pModSpecs, m_nType); - Order.resize(GetModSpecifications().ordersMax); + const ORDERINDEX nMinLength = (std::min)(ModSequenceSet::s_nCacheSize, GetModSpecifications().ordersMax); + if (Order.GetLength() < nMinLength) + Order.resize(nMinLength); return TRUE; } @@ -1056,14 +1058,6 @@ } -ORDERINDEX CSoundFile::GetNumPatterns() const -//------------------------------------- -{ - ORDERINDEX i = 0; - while ((i < Order.size()) && (Order[i] < Order.GetInvalidPatIndex())) i++; - return i; -} - /* UINT CSoundFile::GetNumInstruments() const //---------------------------------------- @@ -1422,12 +1416,18 @@ CString CSoundFile::GetInstrumentName(UINT nInstr) const -//----------------------------------------------------------- +//------------------------------------------------------ { - if ((nInstr >= MAX_INSTRUMENTS) || (!Instruments[nInstr])) { - return ""; - } - return Instruments[nInstr]->name; + if ((nInstr >= MAX_INSTRUMENTS) || (!Instruments[nInstr])) + return TEXT(""); + + const size_t nSize = ARRAYELEMCOUNT(Instruments[nInstr]->name); + CString str; + LPTSTR p = str.GetBuffer(nSize + 1); + ArrayCopy(p, Instruments[nInstr]->name, nSize); + p[nSize] = 0; + str.ReleaseBuffer(); + return str; } @@ -1669,42 +1669,6 @@ } -CString CSoundFile::GetPatternViewInstrumentName(UINT nInstr, bool returnEmptyInsteadOfNoName) const -//----------------------------------------------------------------- -{ - //Default: returnEmptyInsteadOfNoName = false; - if(nInstr >= MAX_INSTRUMENTS || m_nInstruments == 0 || Instruments[nInstr] == 0) return ""; - - CString displayName, instrumentName, pluginName = ""; - - // Use instrument name - instrumentName.Format("%s", Instruments[nInstr]->name); - - if (instrumentName == "") { - // if there's no instrument name, use name of sample associated with C-5. - //TODO: If there's no sample mapped to that note, we could check the other notes. - if (Instruments[nInstr]->Keyboard[60] && Samples[Instruments[nInstr]->Keyboard[60]].pSample) { - instrumentName.Format("s: %s", m_szNames[Instruments[nInstr]->Keyboard[60]]); //60 is C-5 - } - } - - //Get plugin name: - UINT nPlug=Instruments[nInstr]->nMixPlug; - if (nPlug>0 && nPlug<MAX_MIXPLUGINS) { - pluginName = m_MixPlugins[nPlug-1].Info.szName; - } - - if (pluginName == "") { - if(returnEmptyInsteadOfNoName && instrumentName == "") return ""; - if(instrumentName == "") instrumentName = "(no name)"; - displayName.Format("%02d: %s", nInstr, instrumentName); - } else { - displayName.Format("%02d: %s (%s)", nInstr, instrumentName, pluginName); - } - return displayName; -} - - #ifndef NO_PACKING UINT CSoundFile::PackSample(int &sample, int next) //------------------------------------------------ Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2009-12-28 02:57:57 UTC (rev 451) +++ trunk/OpenMPT/soundlib/Sndfile.h 2009-12-30 21:54:16 UTC (rev 452) @@ -653,7 +653,6 @@ LPCSTR GetTitle() const { return m_szNames[0]; } CString GetSampleName(UINT nSample) const; CString GetInstrumentName(UINT nInstr) const; - CString GetPatternViewInstrumentName(UINT nInstr, bool returnEmptyInsteadOfNoName = false) const; UINT GetMusicSpeed() const { return m_nMusicSpeed; } UINT GetMusicTempo() const { return m_nMusicTempo; } @@ -746,7 +745,7 @@ void S3MSaveConvert(UINT *pcmd, UINT *pprm, BOOL bIT, BOOL bCompatibilityExport = false) const; WORD ModSaveCommand(const MODCOMMAND *m, const bool bXM, const bool bCompatibilityExport = false) const; - static void ConvertCommand(MODCOMMAND *m, MODTYPE nOldType, MODTYPE nNewType); // Convert a complete MODCHANNEL item from one format to another + static void ConvertCommand(MODCOMMAND *m, MODTYPE nOldType, MODTYPE nNewType); // Convert a complete MODCOMMAND item from one format to another static void MODExx2S3MSxx(MODCOMMAND *m); // Convert Exx to Sxx static void S3MSxx2MODExx(MODCOMMAND *m); // Convert Sxx to Exx Modified: trunk/OpenMPT/soundlib/modcommand.h =================================================================== --- trunk/OpenMPT/soundlib/modcommand.h 2009-12-28 02:57:57 UTC (rev 451) +++ trunk/OpenMPT/soundlib/modcommand.h 2009-12-30 21:54:16 UTC (rev 452) @@ -54,8 +54,11 @@ bool IsEmpty() const {return (*this == Empty());} // Returns true if instrument column represents plugin index. - bool IsInstrPlug() const {return note == NOTE_PC || note == NOTE_PCS;} + bool IsInstrPlug() const {return IsPcNote();} + // Returns true if and only if note is NOTE_PC or NOTE_PCS. + bool IsPcNote() const {return note == NOTE_PC || note == NOTE_PCS;} + public: BYTE note; BYTE instr; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |