From: <sag...@us...> - 2015-05-26 19:32:43
|
Revision: 5194 http://sourceforge.net/p/modplug/code/5194 Author: saga-games Date: 2015-05-26 19:32:38 +0000 (Tue, 26 May 2015) Log Message: ----------- [Fix] When a new shortcut has conflicts in both the same context (error) and cross-context (warning), always treat this as an error. Before, it depended on the ID order of the conflicting shortcuts. Modified Paths: -------------- trunk/OpenMPT/mptrack/CommandSet.cpp trunk/OpenMPT/mptrack/KeyConfigDlg.cpp Modified: trunk/OpenMPT/mptrack/CommandSet.cpp =================================================================== --- trunk/OpenMPT/mptrack/CommandSet.cpp 2015-05-26 18:59:43 UTC (rev 5193) +++ trunk/OpenMPT/mptrack/CommandSet.cpp 2015-05-26 19:32:38 UTC (rev 5194) @@ -771,20 +771,29 @@ if(IsDummyCommand(cmd)) // no need to search if we are adding a dummy key return std::pair<CommandID, KeyCombination>(kcNull, KeyCombination()); - for(int curCmd = 0; curCmd < kcNumCommands; curCmd++) + for(int pass = 0; pass < 2; pass++) { - if(IsDummyCommand((CommandID)curCmd)) - continue; + // In the first pass, only look for conflicts in the same context, since + // such conflicts are errors. Cross-context conflicts only emit warnings. + for(int curCmd = 0; curCmd < kcNumCommands; curCmd++) + { + if(IsDummyCommand((CommandID)curCmd)) + continue; - for(size_t k = 0; k < commands[curCmd].kcList.size(); k++) - { - const KeyCombination &curKc = commands[curCmd].kcList[k]; - if(KeyCombinationConflict(curKc, kc, checkEventConflict)) + for(size_t k = 0; k < commands[curCmd].kcList.size(); k++) { - return std::pair<CommandID, KeyCombination>((CommandID)curCmd, curKc); + const KeyCombination &curKc = commands[curCmd].kcList[k]; + if(pass == 0 && curKc.Context() != kc.Context()) + continue; + + if(KeyCombinationConflict(curKc, kc, checkEventConflict)) + { + return std::pair<CommandID, KeyCombination>((CommandID)curCmd, curKc); + } } } } + return std::pair<CommandID, KeyCombination>(kcNull, KeyCombination()); } Modified: trunk/OpenMPT/mptrack/KeyConfigDlg.cpp =================================================================== --- trunk/OpenMPT/mptrack/KeyConfigDlg.cpp 2015-05-26 18:59:43 UTC (rev 5193) +++ trunk/OpenMPT/mptrack/KeyConfigDlg.cpp 2015-05-26 19:32:38 UTC (rev 5194) @@ -776,7 +776,7 @@ if((conflictCmd = plocalCmdSet->IsConflicting(kc, cmd)).first != kcNull && conflictCmd.first != cmd && !plocalCmdSet->IsCrossContextConflict(kc, conflictCmd.second) - && Reporting::Confirm("New shortcut (" + kc.GetKeyText() + ") conflicts with " + plocalCmdSet->GetCommandText(conflictCmd.first) + " in " + conflictCmd.second.GetContextText() + ".\nDelete the other shortcut and keep the new one?", "Shortcut Conflict", false, this) == cnfNo) + && Reporting::Confirm("New shortcut (" + kc.GetKeyText() + ") conflicts with " + plocalCmdSet->GetCommandText(conflictCmd.first) + " in " + conflictCmd.second.GetContextText() + ".\nDelete the other shortcut and keep the new one?", MPT_USTRING("Shortcut Conflict"), false, false, this) == cnfNo) { // Restore original choice add = false; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |