From: <sag...@us...> - 2010-11-16 21:39:31
|
Revision: 762 http://modplug.svn.sourceforge.net/modplug/?rev=762&view=rev Author: saga-games Date: 2010-11-16 21:39:23 +0000 (Tue, 16 Nov 2010) Log Message: ----------- [Mod] Changes to keymap file handling: The active keymap is now always saved to Keybindings.mkb (in either %APPDATA%\OpenMPT or the executable's directory). Any other keymaps are now only overwritten when using the "Save as" function. This behaviour is backwards-compatible when using several versions of OpenMPT 1.18+ next to each other, since the INI setting is cleared when exiting OpenMPT, so it just defaults to Keybindings.mkb in older versions. Modified Paths: -------------- trunk/OpenMPT/mptrack/CommandSet.cpp trunk/OpenMPT/mptrack/InputHandler.cpp trunk/OpenMPT/mptrack/InputHandler.h trunk/OpenMPT/mptrack/KeyConfigDlg.cpp trunk/OpenMPT/mptrack/KeyConfigDlg.h trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/mptrack.rc trunk/OpenMPT/mptrack/resource.h Modified: trunk/OpenMPT/mptrack/CommandSet.cpp =================================================================== --- trunk/OpenMPT/mptrack/CommandSet.cpp 2010-11-13 22:03:04 UTC (rev 761) +++ trunk/OpenMPT/mptrack/CommandSet.cpp 2010-11-16 21:39:23 UTC (rev 762) @@ -1504,7 +1504,7 @@ if(fileVersion > KEYMAP_VERSION) { CString err; - err.Format("Key binding file %s has version %d. Your version of OpenMPT only supports loading files up to version %d.", szFilename, fileVersion, KEYMAP_VERSION); + err.Format("Key binding file has version %d. Your version of OpenMPT only supports loading files up to version %d.", szFilename, fileVersion, KEYMAP_VERSION); errText += err + "\n"; Log(err); } @@ -1548,7 +1548,7 @@ errorCount++; CString err; if (errorCount<10) { - err.Format("Line %d in key binding file %s was not understood.", l, szFilename); + err.Format("Line %d was not understood.", l, szFilename); errText += err + "\n"; Log(err); } else if (errorCount==10) { @@ -1567,7 +1567,13 @@ l++; } - if(s_bShowErrorOnUnknownKeybinding && !errText.IsEmpty()) ::MessageBox(NULL, errText, "", MB_ICONEXCLAMATION|MB_OK); + if(s_bShowErrorOnUnknownKeybinding && !errText.IsEmpty()) + { + CString err; + err.Format("The following problems have been encountered while trying to load the key binding file %s:\n", szFilename); + errText = err + errText; + ::MessageBox(NULL, errText, "", MB_ICONEXCLAMATION|MB_OK); + } if(fileVersion < KEYMAP_VERSION) UpgradeKeymap(pTempCS, fileVersion); Modified: trunk/OpenMPT/mptrack/InputHandler.cpp =================================================================== --- trunk/OpenMPT/mptrack/InputHandler.cpp 2010-11-13 22:03:04 UTC (rev 761) +++ trunk/OpenMPT/mptrack/InputHandler.cpp 2010-11-16 21:39:23 UTC (rev 762) @@ -61,6 +61,8 @@ if (bSuccess == false) AfxMessageBox(IDS_UNABLE_TO_LOAD_KEYBINDINGS, MB_ICONERROR); } + // We will only overwrite the default Keybindings.mkb file from now on. + _tcscpy(CMainFrame::m_szKbdFile, sDefaultPath); //Get Keymap activeCommandSet->GenKeyMap(keyMap); @@ -73,9 +75,7 @@ m_bBypass = false; modifierMask=0; m_bNoAltMenu = true; - m_bAutoSave = true; - } CInputHandler::~CInputHandler(void) { Modified: trunk/OpenMPT/mptrack/InputHandler.h =================================================================== --- trunk/OpenMPT/mptrack/InputHandler.h 2010-11-13 22:03:04 UTC (rev 761) +++ trunk/OpenMPT/mptrack/InputHandler.h 2010-11-16 21:39:23 UTC (rev 762) @@ -87,7 +87,6 @@ void UpdateMainMenu(); void SetNewCommandSet(CCommandSet * newSet); bool noAltMenu(); - bool m_bAutoSave; bool SetXMEffects(void); bool SetITEffects(void); }; Modified: trunk/OpenMPT/mptrack/KeyConfigDlg.cpp =================================================================== --- trunk/OpenMPT/mptrack/KeyConfigDlg.cpp 2010-11-13 22:03:04 UTC (rev 761) +++ trunk/OpenMPT/mptrack/KeyConfigDlg.cpp 2010-11-16 21:39:23 UTC (rev 762) @@ -116,10 +116,8 @@ DDX_Control(pDX, IDC_CHECKKEYDOWN, m_bKeyDown); DDX_Control(pDX, IDC_CHECKKEYHOLD, m_bKeyHold); DDX_Control(pDX, IDC_CHECKKEYUP, m_bKeyUp); - DDX_Control(pDX, IDC_KEYMAPFILE, m_eKeyFile); DDX_Control(pDX, IDC_DEBUGSAVE, m_bDebugSave); - DDX_Control(pDX, IDC_AUTOSAVE, m_bAutoSave); } @@ -160,8 +158,6 @@ m_eReport.FmtLines(TRUE); m_eReport.SetWindowText("Log:\r\n"); - m_bAutoSave.SetCheck(CMainFrame::GetInputHandler()->m_bAutoSave); - CString s; s.Format("%d", CMainFrame::gnAutoChordWaitTime); m_eChordWaitTime.SetWindowText(s); @@ -341,7 +337,6 @@ void COptionsKeyboard::UpdateDialog() //----------------------------------- { - m_eKeyFile.SetWindowText(CMainFrame::m_szKbdFile); OnCategorySelChanged(); // Fills command list and automatically selects first command. OnCommandKeySelChanged(); // Fills command key choice list for that command and automatically selects first choice. } @@ -623,21 +618,12 @@ void COptionsKeyboard::OnOK() //--------------------------- { - CString cs; - m_eKeyFile.GetWindowText(cs); - strcpy(CMainFrame::m_szKbdFile, cs); CMainFrame::GetInputHandler()->SetNewCommandSet(plocalCmdSet); + CString cs; m_eChordWaitTime.GetWindowText(cs); CMainFrame::gnAutoChordWaitTime = atoi(cs); - if (m_bAutoSave.GetCheck()) - plocalCmdSet->SaveFile(CMainFrame::m_szKbdFile, m_bDebugSave.GetCheck()); - - CMainFrame::GetInputHandler()->m_bAutoSave = m_bAutoSave.GetCheck(); - - - CPropertyPage::OnOK(); } @@ -659,7 +645,7 @@ m_sFullPathName = files.first_file.c_str(); plocalCmdSet->LoadFile(m_sFullPathName); ForceUpdateGUI(); - TentativeSetToDefaultFile(m_sFullPathName); + //TentativeSetToDefaultFile(m_sFullPathName); } void COptionsKeyboard::OnSave() @@ -672,7 +658,7 @@ m_sFullPathName = files.first_file.c_str(); plocalCmdSet->SaveFile(m_sFullPathName, m_bDebugSave.GetCheck()); - TentativeSetToDefaultFile(m_sFullPathName); + //TentativeSetToDefaultFile(m_sFullPathName); } bool COptionsKeyboard::TentativeSetToDefaultFile(CString m_sFullPathName) Modified: trunk/OpenMPT/mptrack/KeyConfigDlg.h =================================================================== --- trunk/OpenMPT/mptrack/KeyConfigDlg.h 2010-11-13 22:03:04 UTC (rev 761) +++ trunk/OpenMPT/mptrack/KeyConfigDlg.h 2010-11-16 21:39:23 UTC (rev 762) @@ -89,7 +89,7 @@ CButton m_bKeyDown, m_bKeyHold, m_bKeyUp; CButton m_bnReset; CCustEdit m_eCustHotKey; - CEdit m_eReport, m_eKeyFile, m_eChordWaitTime; + CEdit m_eReport, m_eChordWaitTime; UINT m_nKeyboardCfg; int m_nCurHotKey, m_nCurCategory, m_nCurKeyChoice; CString m_sFullPathName; @@ -99,7 +99,6 @@ bool m_bChoiceModified; CButton m_bDebugSave; - CButton m_bAutoSave; void ForceUpdateGUI(); bool TentativeSetToDefaultFile(CString); Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2010-11-13 22:03:04 UTC (rev 761) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2010-11-16 21:39:23 UTC (rev 762) @@ -945,6 +945,10 @@ } // Save Settings SaveIniSettings(); + if(m_InputHandler && m_InputHandler->activeCommandSet) + { + m_InputHandler->activeCommandSet->SaveFile(m_szKbdFile, false); + } EndWaitCursor(); CMDIFrameWnd::OnClose(); @@ -1033,12 +1037,8 @@ WritePrivateProfileString("Paths", m_szDirectoryToSettingsName[i], szPath, iniFile); } - _tcscpy(szPath, m_szKbdFile); - if(bConvertPaths) - { - AbsolutePathToRelative(szPath); - } - WritePrivateProfileString("Paths", "Key_Config_File", szPath, iniFile); + // Obsolete, since we always write to Keybindings.mkb now. Older versions of OpenMPT 1.18+ will look for this file if this entry is missing, so this is kind of backwards compatible. + WritePrivateProfileString("Paths", "Key_Config_File", NULL, iniFile); WritePrivateProfileLong("Effects", "XBassDepth", CSoundFile::m_nXBassDepth, iniFile); WritePrivateProfileLong("Effects", "XBassRange", CSoundFile::m_nXBassRange, iniFile); Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2010-11-13 22:03:04 UTC (rev 761) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2010-11-16 21:39:23 UTC (rev 762) @@ -662,6 +662,9 @@ } #ifdef WIN32 // Legacy stuff +// Move a config file called sFileName from the App's directory (or one of its sub directories specified by sSubDir) to +// %APPDATA%. If specified, it will be renamed to sNewFileName. Existing files are never overwritten. +// Returns true on success. bool CTrackApp::MoveConfigFile(TCHAR sFileName[_MAX_PATH], TCHAR sSubDir[_MAX_PATH], TCHAR sNewFileName[_MAX_PATH]) //----------------------------------------------------------------------------------------------------------------- { @@ -682,8 +685,7 @@ if(PathFileExists(sNewPath) == 0 && PathFileExists(sOldPath) != 0) { - MoveFile(sOldPath, sNewPath); - return true; + return (MoveFile(sOldPath, sNewPath) != 0); } return false; } @@ -728,56 +730,16 @@ strcat(m_szConfigDirectory, "\\OpenMPT\\"); // Path doesn't exist yet, so it has to be created - bool justCreated = false; if(PathIsDirectory(m_szConfigDirectory) == 0) { CreateDirectory(m_szConfigDirectory, 0); - justCreated = true; } #ifdef WIN32 // Legacy stuff - - bool movedKeyboardFiles = false; - // Move files if necessary. - movedKeyboardFiles = MoveConfigFile("default.mkb", "", "Keybindings.mkb"); - movedKeyboardFiles |= MoveConfigFile("Keybindings.mkb"); - - // Check the old ini settings - if(justCreated && movedKeyboardFiles) - { - TCHAR szOldPath[_MAX_PATH], szTestPath[_MAX_PATH]; - - GetPrivateProfileString("Paths", "Key_Config_File", szOldPath, szOldPath, INIBUFFERSIZE, m_szConfigFileName); - _strlwr(szOldPath); // compare all in lower case - - bool overwritePath = false; - strcpy(szTestPath, m_szExePath); - strcat(szTestPath, "default.mkb"); - _strlwr(szTestPath); - overwritePath = (strcmp(szTestPath, szOldPath) == 0); - - if(overwritePath == false) - { - strcpy(szTestPath, m_szExePath); - strcat(szTestPath, "Keybindings.mkb"); - _strlwr(szTestPath); - overwritePath = (strcmp(szTestPath, szOldPath) == 0); - } - - if(overwritePath) - { - // if old INI entry points to a file that's going to be moved, change it. - strcpy(szTestPath, m_szConfigDirectory); - strcat(szTestPath, "Keybindings.mkb"); - WritePrivateProfileString("Paths", "Key_Config_File", szTestPath, m_szConfigFileName); - } - - } - // Move some more files + // Move the config files if they're still in the old place. MoveConfigFile("mptrack.ini"); MoveConfigFile("plugin.cache"); MoveConfigFile("mpt_intl.ini"); - #endif // WIN32 Legacy Stuff } Modified: trunk/OpenMPT/mptrack/mptrack.rc =================================================================== --- trunk/OpenMPT/mptrack/mptrack.rc 2010-11-13 22:03:04 UTC (rev 761) +++ trunk/OpenMPT/mptrack/mptrack.rc 2010-11-16 21:39:23 UTC (rev 762) @@ -346,12 +346,12 @@ END IDD_OPTIONS_KEYBOARD DIALOGEX 0, 0, 272, 279 -STYLE DS_SETFONT | WS_CHILD | WS_DISABLED | WS_CAPTION +STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_DISABLED | WS_CAPTION CAPTION "Keyboard" FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN COMBOBOX IDC_KEYCATEGORY,5,16,130,204,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - LISTBOX IDC_COMMAND_LIST,5,32,130,242,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP + LISTBOX IDC_COMMAND_LIST,5,32,130,238,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP COMBOBOX IDC_CHOICECOMBO,147,16,79,51,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP EDITTEXT IDC_CUSTHOTKEY,163,31,98,13,ES_AUTOHSCROLL CONTROL "On Key Down",IDC_CHECKKEYDOWN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,147,44,66,14 @@ -359,27 +359,24 @@ CONTROL "On Key Up",IDC_CHECKKEYUP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,147,68,66,8 PUSHBUTTON "Restore",IDC_RESTORE,217,46,43,13 PUSHBUTTON "Delete",IDC_DELETE,217,64,43,13 - EDITTEXT IDC_KEYREPORT,141,94,125,70,ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | WS_VSCROLL - PUSHBUTTON "Y",IDC_NOTESREPEAT,235,176,12,9 - PUSHBUTTON "N",IDC_NONOTESREPEAT,251,176,12,9 - EDITTEXT IDC_CHORDDETECTWAITTIME,235,189,28,12,ES_AUTOHSCROLL | ES_NUMBER,WS_EX_RIGHT + EDITTEXT IDC_KEYREPORT,138,94,128,98,ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | WS_VSCROLL + PUSHBUTTON "Y",IDC_NOTESREPEAT,234,207,12,9 + PUSHBUTTON "N",IDC_NONOTESREPEAT,250,207,12,9 + EDITTEXT IDC_CHORDDETECTWAITTIME,234,220,24,12,ES_AUTOHSCROLL | ES_NUMBER,WS_EX_RIGHT PUSHBUTTON "it",IDC_EFFECTLETTERSIT,103,184,12,9,NOT WS_VISIBLE PUSHBUTTON "xm",IDC_EFFECTLETTERSXM,119,184,12,9,NOT WS_VISIBLE - PUSHBUTTON "Load Keys...",IDC_LOAD,145,221,54,13 - PUSHBUTTON "Save Keys As...",IDC_SAVE,205,221,54,13 + PUSHBUTTON "Load Keys...",IDC_LOAD,144,252,54,13 + PUSHBUTTON "Save Keys As...",IDC_SAVE,204,252,54,13 CONTROL "Debug Save",IDC_DEBUGSAVE,"Button",BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_TABSTOP,59,199,56,10 - EDITTEXT IDC_KEYMAPFILE,145,249,114,13,ES_AUTOHSCROLL LTEXT "Select category:",IDC_STATIC,7,5,74,11 PUSHBUTTON "Set",IDC_SET,225,45,43,13,NOT WS_VISIBLE GROUPBOX "Key setup for this command ",IDC_STATIC,139,5,127,75 LTEXT "Key:",IDC_STATIC,147,33,16,8 - GROUPBOX "Misc",IDC_STATIC,139,167,126,40 - GROUPBOX "Multi Config Handling",IDC_STATIC,139,209,126,66 - LTEXT "Repeat notes on hold?",IDC_STATIC,143,176,74,11 + GROUPBOX "Misc",IDC_STATIC,138,198,126,37 + GROUPBOX "Multi Config Handling",IDC_STATIC,138,240,126,31 + LTEXT "Repeat notes on hold?",IDC_STATIC,142,207,74,11 LTEXT "Effect letters like:",IDC_STATIC,11,185,73,11,NOT WS_VISIBLE - LTEXT "Chord detect interval (ms):",IDC_STATIC,143,190,88,11 - CONTROL "Save to this file on OK/Apply?",IDC_AUTOSAVE,"Button",BS_AUTOCHECKBOX | BS_LEFTTEXT | WS_TABSTOP,153,262,106,10 - LTEXT "Config to load on startup:",IDC_STATIC,145,239,80,8 + LTEXT "Chord detect interval (ms):",IDC_STATIC,142,222,88,11 LTEXT "Log:",IDC_STATIC,141,84,19,10 PUSHBUTTON "Clear Log",IDC_CLEARLOG,227,85,37,9 END @@ -763,8 +760,8 @@ EDITTEXT IDC_EDIT_LOG,6,7,234,96,ES_MULTILINE | ES_AUTOHSCROLL | ES_READONLY | WS_VSCROLL END -IDD_REMOVECHANNELS DIALOGEX 0, 0, 171, 220 -STYLE DS_SETFONT | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME +IDD_REMOVECHANNELS DIALOGEX 0, 0, 171, 221 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Remove Channels" FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN @@ -772,7 +769,7 @@ PUSHBUTTON "Cancel",IDCANCEL,114,198,50,14 LISTBOX IDC_REMCHANSLIST,6,36,156,156,LBS_NOINTEGRALHEIGHT | LBS_EXTENDEDSEL | WS_VSCROLL | WS_TABSTOP LTEXT "Channels:",IDC_QUESTION1,6,6,157,18 - LTEXT "Detected unused channels are already selected",IDC_STATIC,6,24,159,10 + LTEXT "Detected unused channels are already selected",IDC_STATIC,4,24,159,10 END IDD_VIEW_GLOBALS DIALOGEX 0, 0, 471, 337 @@ -1636,7 +1633,7 @@ IDD_REMOVECHANNELS, DIALOG BEGIN RIGHTMARGIN, 163 - BOTTOMMARGIN, 218 + BOTTOMMARGIN, 219 END IDD_VIEW_GLOBALS, DIALOG @@ -1912,7 +1909,7 @@ MENUITEM "Import &MIDI Library...", ID_IMPORT_MIDILIB MENUITEM "Add Sound &Bank...", ID_ADD_SOUNDBANK MENUITEM SEPARATOR - MENUITEM "Recent File", ID_FILE_MRU_FILE1, GRAYED + MENUITEM "Recent File", ID_FILE_MRU_FILE1 MENUITEM SEPARATOR MENUITEM "E&xit", ID_APP_EXIT END Modified: trunk/OpenMPT/mptrack/resource.h =================================================================== --- trunk/OpenMPT/mptrack/resource.h 2010-11-13 22:03:04 UTC (rev 761) +++ trunk/OpenMPT/mptrack/resource.h 2010-11-16 21:39:23 UTC (rev 762) @@ -645,7 +645,6 @@ #define IDC_LIST6 2076 #define IDC_KEYBOARD1 2078 #define IDC_SPLASH 2079 -#define IDC_HOTKEY1 2080 #define IDC_TREEVIEW 2081 #define IDC_COMMANDKEY 2081 #define IDC_VUMETER_LEFT 2082 @@ -655,63 +654,33 @@ #define IDC_COMBO7 2085 #define IDC_TREE1 2086 #define IDC_VISSTATUS 2087 -#define IDC_CHECK130 2088 -#define IDC_CHECK131 2089 -#define IDC_CHECK132 2090 #define IDC_CHOICECOMBO 2090 -#define IDC_CHECK133 2091 -#define IDC_CHECK134 2092 #define IDC_CHOICECOMBO2 2092 #define IDC_KEYCATEGORY 2092 -#define IDC_CHECK135 2093 -#define IDC_CHECK136 2094 #define IDC_CHECKKEYDOWN 2094 -#define IDC_CHECK137 2095 #define IDC_CHECKKEYHOLD 2095 -#define IDC_CHECK138 2096 #define IDC_CHECKKEYUP 2096 -#define IDC_CHECK139 2097 #define IDC_DEBUGSAVE 2097 -#define IDC_CHECK140 2098 #define IDC_CUSTHOTKEY 2098 -#define IDC_CHECK141 2099 #define IDC_SET 2099 -#define IDC_CHECK142 2100 #define IDC_RESTORE 2100 -#define IDC_CHECK143 2101 #define IDC_DELETE 2101 -#define IDC_CHECK144 2102 #define IDC_SAVE 2102 -#define IDC_CHECK145 2103 #define IDC_LOAD 2103 -#define IDC_CHECK146 2104 -#define IDC_AUTOSAVE 2104 -#define IDC_CHECK147 2105 #define IDC_KEYREPORT 2105 -#define IDC_CHECK148 2106 -#define IDC_KEYMAPFILE 2106 -#define IDC_CHECK149 2107 #define IDC_BROWSEKEYCONF 2107 #define IDC_CLEARLOG 2107 -#define IDC_CHECK150 2108 #define IDC_NOTESREPEAT 2108 #define IDC_REMCHANSLIST 2108 -#define IDC_CHECK151 2109 #define IDC_NOTESREPEAT2 2109 #define IDC_NONOTESREPEAT 2109 -#define IDC_CHECK152 2110 #define IDC_EFFECTLETTERSIT 2110 #define IDC_INSVIEWPLG 2110 -#define IDC_CHECK153 2111 #define IDC_EFFECTLETTERSXM 2111 #define IDC_PARAMLABEL 2111 -#define IDC_CHECK154 2112 #define IDC_PARAMLIST 2112 -#define IDC_CHECK155 2113 #define IDC_PARAMVALUETEXT 2113 -#define IDC_CHECK156 2114 #define IDC_PARAMVALUESLIDE 2114 -#define IDC_CHECK157 2115 #define IDC_PARAMLABEL2 2115 #define IDC_VISFILLBLANKS 2115 #define IDC_CHECK158 2116 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |