From: <sag...@us...> - 2011-07-28 15:00:02
|
Revision: 931 http://modplug.svn.sourceforge.net/modplug/?rev=931&view=rev Author: saga-games Date: 2011-07-28 14:59:55 +0000 (Thu, 28 Jul 2011) Log Message: ----------- [Imp] When using the channel search in the Find/Replace dialog, swapped channel numbers are now treated correctly [Imp] Find/Replace dialog limits volume column parameters better now. It's still possible to do something like "Search for volume command d, replace by volume parameter 24", though... [Ref] Macro config loading/saving has been moved to TrackerSettings [Ref] More refactoring Modified Paths: -------------- trunk/OpenMPT/mptrack/Draw_pat.cpp trunk/OpenMPT/mptrack/Mainfrm.h trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp trunk/OpenMPT/mptrack/PatternEditorDialogs.h trunk/OpenMPT/mptrack/TrackerSettings.cpp trunk/OpenMPT/mptrack/TrackerSettings.h trunk/OpenMPT/mptrack/misc_util.cpp Modified: trunk/OpenMPT/mptrack/Draw_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/Draw_pat.cpp 2011-07-28 14:56:16 UTC (rev 930) +++ trunk/OpenMPT/mptrack/Draw_pat.cpp 2011-07-28 14:59:55 UTC (rev 931) @@ -17,7 +17,7 @@ #define COLHDR_HEIGHT 16 // Column header #define COLUMN_HEIGHT 13 #define VUMETERS_HEIGHT 13 // Height of vu-meters -#define PLUGNAME_HEIGHT 16 // Height of vu-meters +#define PLUGNAME_HEIGHT 16 // Height of plugin names #define VUMETERS_BMPWIDTH 32 #define VUMETERS_BMPHEIGHT 10 #define VUMETERS_MEDWIDTH 24 @@ -102,7 +102,7 @@ // Effect colour codes // Effect number => Effect colour assignment -const BYTE effectColors[] = +const int effectColors[] = { 0, 0, MODCOLOR_PITCH, MODCOLOR_PITCH, MODCOLOR_PITCH, MODCOLOR_PITCH, MODCOLOR_VOLUME, MODCOLOR_VOLUME, @@ -119,7 +119,7 @@ STATIC_ASSERT(CountOf(effectColors) == MAX_EFFECTS); // Volume effect number => Effect colour assignment -const BYTE volEffectColors[] = +const int volEffectColors[] = { 0, MODCOLOR_VOLUME, MODCOLOR_PANNING, MODCOLOR_VOLUME, MODCOLOR_VOLUME, MODCOLOR_VOLUME, MODCOLOR_VOLUME, MODCOLOR_PITCH, @@ -342,7 +342,7 @@ void CViewPattern::DrawNote(int x, int y, UINT note, CTuning* pTuning) -//--------------------------------------------------------------------------- +//-------------------------------------------------------------------- { PCPATTERNFONT pfnt = GetCurrentPatternFont(); Modified: trunk/OpenMPT/mptrack/Mainfrm.h =================================================================== --- trunk/OpenMPT/mptrack/Mainfrm.h 2011-07-28 14:56:16 UTC (rev 930) +++ trunk/OpenMPT/mptrack/Mainfrm.h 2011-07-28 14:59:55 UTC (rev 931) @@ -165,7 +165,7 @@ // Pattern Setup (contains also non-pattern related settings) // Feel free to replace the deprecated flags by new flags, but be sure to -// update CMainFrame::LoadIniSettings() as well. +// update TrackerSettings::LoadINISettings() / TrackerSettings::LoadRegistrySettings() as well. #define PATTERN_PLAYNEWNOTE 0x01 // play new notes while recording #define PATTERN_LARGECOMMENTS 0x02 // use large font in comments #define PATTERN_STDHIGHLIGHT 0x04 // enable primary highlight (measures) Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2011-07-28 14:56:16 UTC (rev 930) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2011-07-28 14:59:55 UTC (rev 931) @@ -849,24 +849,6 @@ // Load Midi Library if (m_szConfigFileName[0]) ImportMidiConfig(m_szConfigFileName); - // Load default macro configuration - for (UINT isfx=0; isfx<16; isfx++) - { - CHAR s[64], snam[32]; - wsprintf(snam, "SF%X", isfx); - GetPrivateProfileString("Zxx Macros", snam, m_MidiCfg.szMidiSFXExt[isfx], s, CountOf(s), m_szConfigFileName); - s[MACRO_LENGTH - 1] = 0; - memcpy(m_MidiCfg.szMidiSFXExt[isfx], s, MACRO_LENGTH); - } - for (UINT izxx=0; izxx<128; izxx++) - { - CHAR s[64], snam[32]; - wsprintf(snam, "Z%02X", izxx|0x80); - GetPrivateProfileString("Zxx Macros", snam, m_MidiCfg.szMidiZXXExt[izxx], s, CountOf(s), m_szConfigFileName); - s[MACRO_LENGTH - 1] = 0; - memcpy(m_MidiCfg.szMidiZXXExt[izxx], s, MACRO_LENGTH); - } - // create main MDI Frame window CMainFrame* pMainFrame = new CMainFrame(/*cmdInfo.m_csExtension*/); if (!pMainFrame->LoadFrame(IDR_MAINFRAME)) return FALSE; @@ -972,26 +954,7 @@ gpDLSBanks[i] = NULL; } } - // Save default macro configuration - if (m_szConfigFileName[0]) - { - for (UINT isfx=0; isfx<16; isfx++) - { - CHAR s[64], snam[32]; - wsprintf(snam, "SF%X", isfx); - memcpy(s, m_MidiCfg.szMidiSFXExt[isfx], MACRO_LENGTH); - s[31] = 0; - if (!WritePrivateProfileString("Zxx Macros", snam, s, m_szConfigFileName)) break; - } - for (UINT izxx=0; izxx<128; izxx++) - { - CHAR s[64], snam[32]; - wsprintf(snam, "Z%02X", izxx|0x80); - memcpy(s, m_MidiCfg.szMidiZXXExt[izxx], MACRO_LENGTH); - s[MACRO_LENGTH - 1] = 0; - if (!WritePrivateProfileString("Zxx Macros", snam, s, m_szConfigFileName)) break; - } - } + // Uninitialize DX-Plugins UninitializeDXPlugins(); Modified: trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp =================================================================== --- trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp 2011-07-28 14:56:16 UTC (rev 930) +++ trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp 2011-07-28 14:59:55 UTC (rev 931) @@ -260,6 +260,7 @@ } } ChangeEffect(); + ChangeVolCmd(); OnCheckChannelSearch(); return TRUE; } @@ -285,6 +286,7 @@ int newpos; if (oldcount) newpos = combo->GetCurSel() % newcount; else newpos = m_nParam % newcount; combo->ResetContent(); + combo->InitStorage(newcount, 4); for (UINT i=0; i<newcount; i++) { wsprintf(s, (newcount == 256) ? "%02X" : "%X", i); @@ -296,6 +298,43 @@ } +void CFindReplaceTab::ChangeVolCmd() +//---------------------------------- +{ + int fxndx = -1; + CComboBox *combo; + if ((combo = (CComboBox *)GetDlgItem(IDC_COMBO3)) != NULL) + { + fxndx = combo->GetItemData(combo->GetCurSel()); + } + // Update Param range + if (((combo = (CComboBox *)GetDlgItem(IDC_COMBO4)) != NULL) && (m_pModDoc)) + { + DWORD rangeMin, rangeMax; + if(!m_pModDoc->GetVolCmdInfo(fxndx, nullptr, &rangeMin, &rangeMax)) + { + rangeMin = 0; + rangeMax = 64; + } + UINT oldcount = combo->GetCount(); + UINT newcount = rangeMax - rangeMin + 1; + if (oldcount != newcount) + { + CHAR s[16]; + int newpos; + if (oldcount) newpos = combo->GetCurSel() % newcount; else newpos = m_nParam % newcount; + combo->ResetContent(); + for (UINT i = rangeMin; i <= rangeMax; i++) + { + wsprintf(s, (rangeMax < 10) ? "%d" : "%02d", i); + combo->SetItemData(combo->AddString(s), i); + } + combo->SetCurSel(newpos); + } + } +} + + void CFindReplaceTab::OnCheckChannelSearch() //------------------------------------------ { @@ -389,7 +428,10 @@ { m_nMinChannel = GetDlgItemInt(IDC_EDIT1) - 1; m_nMaxChannel = GetDlgItemInt(IDC_EDIT2) - 1; - if (m_nMaxChannel < m_nMinChannel) m_nMaxChannel = m_nMinChannel; + if (m_nMaxChannel < m_nMinChannel) + { + std::swap(m_nMinChannel, m_nMaxChannel); + } } CPropertyPage::OnOK(); } Modified: trunk/OpenMPT/mptrack/PatternEditorDialogs.h =================================================================== --- trunk/OpenMPT/mptrack/PatternEditorDialogs.h 2011-07-28 14:56:16 UTC (rev 930) +++ trunk/OpenMPT/mptrack/PatternEditorDialogs.h 2011-07-28 14:59:55 UTC (rev 931) @@ -67,6 +67,7 @@ protected: void ChangeEffect(); + void ChangeVolCmd(); public: CFindReplaceTab(UINT nIDD, bool bReplaceTab, CModDoc *pModDoc):CPropertyPage(nIDD) { m_bReplace = bReplaceTab; m_pModDoc = pModDoc; } @@ -79,7 +80,7 @@ void CheckOnChange(int nIDButton) { CheckDlgButton(nIDButton, BST_CHECKED); CheckReplace(nIDButton); }; afx_msg void OnNoteChanged() { CheckOnChange(IDC_CHECK1); }; afx_msg void OnInstrChanged() { CheckOnChange(IDC_CHECK2); }; - afx_msg void OnVolCmdChanged() { CheckOnChange(IDC_CHECK3); }; + afx_msg void OnVolCmdChanged() { CheckOnChange(IDC_CHECK3); ChangeVolCmd(); }; afx_msg void OnVolumeChanged() { CheckOnChange(IDC_CHECK4); }; afx_msg void OnEffectChanged() { CheckOnChange(IDC_CHECK5); ChangeEffect(); }; afx_msg void OnParamChanged() { CheckOnChange(IDC_CHECK6); }; Modified: trunk/OpenMPT/mptrack/TrackerSettings.cpp =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.cpp 2011-07-28 14:56:16 UTC (rev 930) +++ trunk/OpenMPT/mptrack/TrackerSettings.cpp 2011-07-28 14:59:55 UTC (rev 931) @@ -17,7 +17,6 @@ #include "snddev.h" #include "version.h" #include "UpdateCheck.h" -#include "Ctrl_pat.h" #include "Mpdlgs.h" #include "AutoSaver.h" #include "TrackerSettings.h" @@ -150,20 +149,20 @@ Chords[ichord].notes[0] = 0; Chords[ichord].notes[1] = 0; Chords[ichord].notes[2] = 0; - // Major Chords + if (ichord < 12) { + // Major Chords Chords[ichord].notes[0] = (BYTE)(ichord+5); Chords[ichord].notes[1] = (BYTE)(ichord+8); Chords[ichord].notes[2] = (BYTE)(ichord+11); - } else + } else if (ichord < 24) + { // Minor Chords - if (ichord < 24) - { - Chords[ichord].notes[0] = (BYTE)(ichord-8); - Chords[ichord].notes[1] = (BYTE)(ichord-4); - Chords[ichord].notes[2] = (BYTE)(ichord-1); - } + Chords[ichord].notes[0] = (BYTE)(ichord-8); + Chords[ichord].notes[1] = (BYTE)(ichord-4); + Chords[ichord].notes[2] = (BYTE)(ichord-1); + } } gnPlugWindowX = 243; @@ -178,17 +177,40 @@ void TrackerSettings::LoadSettings() //---------------------------------- { - CString storedVersion = CMainFrame::GetPrivateProfileCString("Version", "Version", "", theApp.GetConfigFileName()); + const CString iniFile = theApp.GetConfigFileName(); + + CString storedVersion = CMainFrame::GetPrivateProfileCString("Version", "Version", "", iniFile); // If version number stored in INI is 1.17.02.40 or later, always load setting from INI file. // If it isn't, try loading from Registry first, then from the INI file. if (storedVersion >= "1.17.02.40" || !LoadRegistrySettings()) { - LoadINISettings(); + LoadINISettings(iniFile); } + // The following stuff was also stored in mptrack.ini while the registry was still being used... + // Load Chords theApp.LoadChords(Chords); + // Load default macro configuration + MODMIDICFG macros; + theApp.GetDefaultMidiMacro(¯os); + for(int isfx = 0; isfx < 16; isfx++) + { + CHAR snam[8]; + wsprintf(snam, "SF%X", isfx); + GetPrivateProfileString("Zxx Macros", snam, macros.szMidiSFXExt[isfx], macros.szMidiSFXExt[isfx], CountOf(macros.szMidiSFXExt[isfx]), iniFile); + SetNullTerminator(macros.szMidiSFXExt[isfx]); + } + for(int izxx = 0; izxx < 128; izxx++) + { + CHAR snam[8]; + wsprintf(snam, "Z%02X", izxx | 0x80); + GetPrivateProfileString("Zxx Macros", snam, macros.szMidiZXXExt[izxx], macros.szMidiZXXExt[izxx], CountOf(macros.szMidiZXXExt[izxx]), iniFile); + SetNullTerminator(macros.szMidiZXXExt[izxx]); + } + theApp.SetDefaultMidiMacro(¯os); + // Default directory location for(UINT i = 0; i < NUM_DIRS; i++) { @@ -198,10 +220,9 @@ } -void TrackerSettings::LoadINISettings() -//------------------------------------- +void TrackerSettings::LoadINISettings(const CString &iniFile) +//---------------------------------------------------------- { - CString iniFile = theApp.GetConfigFileName(); //CHAR collectedString[INIBUFFERSIZE]; MptVersion::VersionNum vIniVersion; @@ -392,7 +413,7 @@ CMainFrame::m_pAutoSaver->SetPath(szPath); CMainFrame::m_pAutoSaver->SetFilenameTemplate(CMainFrame::GetPrivateProfileCString("AutoSave", "FileNameTemplate", "", iniFile)); - GetPrivateProfileString("Misc", "DefaultModType", gdefaultModType->fileExtension, szPath, INIBUFFERSIZE, iniFile); + GetPrivateProfileString("Misc", "DefaultModType", defaultModType->fileExtension, szPath, INIBUFFERSIZE, iniFile); // for(size_t i = 0; i < CountOf(ModSpecs::Collection); i++) // { // if(!strcmp(szPath, ModSpecs::Collection[i]->fileExtension)) @@ -718,7 +739,21 @@ theApp.SaveChords(Chords); - WritePrivateProfileString("Misc", "DefaultModType", gdefaultModType->fileExtension, iniFile); + // Save default macro configuration + MODMIDICFG macros; + theApp.GetDefaultMidiMacro(¯os); + for(int isfx = 0; isfx < 16; isfx++) + { + CHAR snam[8]; + wsprintf(snam, "SF%X", isfx); + WritePrivateProfileString("Zxx Macros", snam, macros.szMidiSFXExt[isfx], iniFile); + } + for(int izxx = 0; izxx < 128; izxx++) + { + CHAR snam[8]; + wsprintf(snam, "Z%02X", izxx | 0x80); + if (!WritePrivateProfileString("Zxx Macros", snam, macros.szMidiZXXExt[izxx], iniFile)) break; + } CMainFrame::GetMainFrame()->SaveBarState("Toolbars"); } Modified: trunk/OpenMPT/mptrack/TrackerSettings.h =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.h 2011-07-28 14:56:16 UTC (rev 930) +++ trunk/OpenMPT/mptrack/TrackerSettings.h 2011-07-28 14:59:55 UTC (rev 931) @@ -42,7 +42,7 @@ glInstrumentWindowHeight, glCommentsWindowHeight, glGraphWindowHeight; //rewbs.varWindowSize CString gcsPreviousVersion; CString gcsInstallGUID; - CModSpecifications const *gdefaultModType; + CModSpecifications const *defaultModType; // Audio Setup DWORD m_dwSoundSetup, m_dwRate, m_dwQuality, m_nSrcMode, m_nBitsPerSample, m_nPreAmp, gbLoopSong, m_nChannels; LONG m_nWaveDevice; // use the SNDDEV_GET_NUMBER and SNDDEV_GET_TYPE macros to decode @@ -103,7 +103,7 @@ protected: - void LoadINISettings(); + void LoadINISettings(const CString &iniFile); bool LoadRegistrySettings(); void SetDirectory(const LPCTSTR szFilenameFrom, Directory dir, TCHAR (&pDirs)[NUM_DIRS][_MAX_PATH], bool bStripFilename); Modified: trunk/OpenMPT/mptrack/misc_util.cpp =================================================================== --- trunk/OpenMPT/mptrack/misc_util.cpp 2011-07-28 14:56:16 UTC (rev 930) +++ trunk/OpenMPT/mptrack/misc_util.cpp 2011-07-28 14:59:55 UTC (rev 931) @@ -31,25 +31,24 @@ } -// Returns error message corresponding to error code returned by GetLastError(). +// Returns WinAPI error message corresponding to error code returned by GetLastError(). CString GetErrorMessage(DWORD nErrorCode) //--------------------------------------- { - const size_t nBufferSize = 256; - CString sMsg; - LPTSTR pszBuf = sMsg.GetBuffer(nBufferSize); + LPVOID lpMsgBuf; - FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, + FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, nErrorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - pszBuf, - nBufferSize, + (LPTSTR)&lpMsgBuf, + 0, NULL ); - sMsg.ReleaseBuffer(); + CString msg = (LPTSTR)lpMsgBuf; + LocalFree(lpMsgBuf); - return sMsg; + return msg; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |