From: <sag...@us...> - 2015-07-10 19:44:49
|
Revision: 5399 http://sourceforge.net/p/modplug/code/5399 Author: saga-games Date: 2015-07-10 19:44:42 +0000 (Fri, 10 Jul 2015) Log Message: ----------- [Ref] UNICODE fixes in key handling code [Fix] When upgrading from an older OpenMPT version with a default general tab height, the current default value was loaded and and the size difference from the old value was still added. Modified Paths: -------------- trunk/OpenMPT/mptrack/CommandSet.cpp trunk/OpenMPT/mptrack/CommandSet.h trunk/OpenMPT/mptrack/KeyConfigDlg.cpp trunk/OpenMPT/mptrack/KeyConfigDlg.h trunk/OpenMPT/mptrack/TrackerSettings.cpp Modified: trunk/OpenMPT/mptrack/CommandSet.cpp =================================================================== --- trunk/OpenMPT/mptrack/CommandSet.cpp 2015-07-10 18:48:59 UTC (rev 5398) +++ trunk/OpenMPT/mptrack/CommandSet.cpp 2015-07-10 19:44:42 UTC (rev 5399) @@ -1745,33 +1745,33 @@ } -CString KeyCombination::GetContextText(InputTargetContext ctx) -//------------------------------------------------------------ +const TCHAR *KeyCombination::GetContextText(InputTargetContext ctx) +//----------------------------------------------------------------- { switch(ctx) { - case kCtxAllContexts: return "Global Context"; - case kCtxViewGeneral: return "General Context [bottom]"; - case kCtxViewPatterns: return "Pattern Context [bottom]"; - case kCtxViewPatternsNote: return "Pattern Context [bottom] - Note Col"; - case kCtxViewPatternsIns: return "Pattern Context [bottom] - Ins Col"; - case kCtxViewPatternsVol: return "Pattern Context [bottom] - Vol Col"; - case kCtxViewPatternsFX: return "Pattern Context [bottom] - FX Col"; - case kCtxViewPatternsFXparam: return "Pattern Context [bottom] - Param Col"; - case kCtxViewSamples: return "Sample Context [bottom]"; - case kCtxViewInstruments: return "Instrument Context [bottom]"; - case kCtxViewComments: return "Comments Context [bottom]"; - case kCtxCtrlGeneral: return "General Context [top]"; - case kCtxCtrlPatterns: return "Pattern Context [top]"; - case kCtxCtrlSamples: return "Sample Context [top]"; - case kCtxCtrlInstruments: return "Instrument Context [top]"; - case kCtxCtrlComments: return "Comments Context [top]"; - case kCtxCtrlOrderlist: return "Orderlist"; - case kCtxVSTGUI: return "Plugin GUI Context"; - case kCtxChannelSettings: return "Quick Channel Settings Context"; + case kCtxAllContexts: return _T("Global Context"); + case kCtxViewGeneral: return _T("General Context [bottom]"); + case kCtxViewPatterns: return _T("Pattern Context [bottom]"); + case kCtxViewPatternsNote: return _T("Pattern Context [bottom] - Note Col"); + case kCtxViewPatternsIns: return _T("Pattern Context [bottom] - Ins Col"); + case kCtxViewPatternsVol: return _T("Pattern Context [bottom] - Vol Col"); + case kCtxViewPatternsFX: return _T("Pattern Context [bottom] - FX Col"); + case kCtxViewPatternsFXparam: return _T("Pattern Context [bottom] - Param Col"); + case kCtxViewSamples: return _T("Sample Context [bottom]"); + case kCtxViewInstruments: return _T("Instrument Context [bottom]"); + case kCtxViewComments: return _T("Comments Context [bottom]"); + case kCtxCtrlGeneral: return _T("General Context [top]"); + case kCtxCtrlPatterns: return _T("Pattern Context [top]"); + case kCtxCtrlSamples: return _T("Sample Context [top]"); + case kCtxCtrlInstruments: return _T("Instrument Context [top]"); + case kCtxCtrlComments: return _T("Comments Context [top]"); + case kCtxCtrlOrderlist: return _T("Orderlist"); + case kCtxVSTGUI: return _T("Plugin GUI Context"); + case kCtxChannelSettings: return _T("Quick Channel Settings Context"); case kCtxUnknownContext: - default: return "Unknown Context"; + default: return _T("Unknown Context"); } }; @@ -1779,24 +1779,24 @@ CString KeyCombination::GetKeyEventText(FlagSet<KeyEventType> event) //------------------------------------------------------------------ { - CString text=""; + CString text = _T(""); bool first = true; if (event & kKeyEventDown) { first=false; - text.Append("KeyDown"); + text.Append(_T("KeyDown")); } if (event & kKeyEventRepeat) { - if (!first) text.Append("|"); - text.Append("KeyHold"); + if (!first) text.Append(_T("|")); + text.Append(_T("KeyHold")); first=false; } if (event & kKeyEventUp) { - if (!first) text.Append("|"); - text.Append("KeyUp"); + if (!first) text.Append(_T("|")); + text.Append(_T("KeyUp")); } return text; @@ -1806,12 +1806,12 @@ CString KeyCombination::GetModifierText(UINT mod) //----------------------------------------------- { - CString text = ""; - if (mod & HOTKEYF_SHIFT) text.Append("Shift+"); - if (mod & HOTKEYF_CONTROL) text.Append("Ctrl+"); - if (mod & HOTKEYF_ALT) text.Append("Alt+"); - if (mod & HOTKEYF_EXT) text.Append("Win+"); // Feature: use Windows keys as modifier keys - if (mod & HOTKEYF_MIDI) text.Append("MidiCC:"); + CString text = _T(""); + if (mod & HOTKEYF_SHIFT) text.Append(_T("Shift+")); + if (mod & HOTKEYF_CONTROL) text.Append(_T("Ctrl+")); + if (mod & HOTKEYF_ALT) text.Append(_T("Alt+")); + if (mod & HOTKEYF_EXT) text.Append(_T("Win+")); // Feature: use Windows keys as modifier keys + if (mod & HOTKEYF_MIDI) text.Append(_T("MidiCC:")); return text; } @@ -1822,13 +1822,13 @@ CString keyText; keyText=GetModifierText(mod); if(mod & HOTKEYF_MIDI) - keyText.AppendFormat("%d",code); + keyText.AppendFormat(_T("%u"),code); else keyText.Append(CHotKeyCtrl::GetKeyName(code, IsExtended(code))); //HACK: - if (keyText == "Ctrl+CTRL") keyText="Ctrl"; - if (keyText == "Alt+ALT") keyText="Alt"; - if (keyText == "Shift+SHIFT") keyText="Shift"; + if (keyText == _T("Ctrl+CTRL")) keyText = _T("Ctrl"); + if (keyText == _T("Alt+ALT")) keyText = _T("Alt"); + if (keyText == _T("Shift+SHIFT")) keyText = _T("Shift"); return keyText; } @@ -1840,7 +1840,7 @@ if ( key < commands[c].kcList.size()) return commands[c].kcList[0].GetKeyText(); else - return ""; + return _T(""); } Modified: trunk/OpenMPT/mptrack/CommandSet.h =================================================================== --- trunk/OpenMPT/mptrack/CommandSet.h 2015-07-10 18:48:59 UTC (rev 5398) +++ trunk/OpenMPT/mptrack/CommandSet.h 2015-07-10 19:44:42 UTC (rev 5399) @@ -1219,8 +1219,8 @@ FlagSet<KeyEventType> EventType() const { FlagSet<KeyEventType> result; result.SetRaw(event); return result; } // Key combination to string - static CString GetContextText(InputTargetContext ctx); - CString GetContextText() const { return GetContextText(Context()); } + static const TCHAR *GetContextText(InputTargetContext ctx); + const TCHAR *GetContextText() const { return GetContextText(Context()); } static CString GetModifierText(UINT mod); CString GetModifierText() const { return GetModifierText(Modifier()); } Modified: trunk/OpenMPT/mptrack/KeyConfigDlg.cpp =================================================================== --- trunk/OpenMPT/mptrack/KeyConfigDlg.cpp 2015-07-10 18:48:59 UTC (rev 5398) +++ trunk/OpenMPT/mptrack/KeyConfigDlg.cpp 2015-07-10 19:44:42 UTC (rev 5399) @@ -185,7 +185,7 @@ m_eCustHotKey.SetParent(m_hWnd, IDC_CUSTHOTKEY, this); m_eFindHotKey.SetParent(m_hWnd, IDC_FINDHOTKEY, this); m_eReport.FmtLines(TRUE); - m_eReport.SetWindowText(""); + m_eReport.SetWindowText(_T("")); m_eChordWaitTime.SetWindowText(mpt::ToString(TrackerSettings::Instance().gnAutoChordWaitTime).c_str()); return TRUE; @@ -198,7 +198,7 @@ //---------------------------------------------- { { - CommandCategory newCat("Global keys", kCtxAllContexts); + CommandCategory newCat(_T("Global keys"), kCtxAllContexts); for(int c = kcStartFile; c <= kcEndFile; c++) newCat.commands.push_back(c); @@ -221,22 +221,22 @@ } { - CommandCategory newCat(" General [Top]", kCtxCtrlGeneral); + CommandCategory newCat(_T(" General [Top]"), kCtxCtrlGeneral); commandCategories.push_back(newCat); } { - CommandCategory newCat(" General [Bottom]", kCtxViewGeneral); + CommandCategory newCat(_T(" General [Bottom]"), kCtxViewGeneral); commandCategories.push_back(newCat); } { - CommandCategory newCat(" Pattern Editor [Top]", kCtxCtrlPatterns); + CommandCategory newCat(_T(" Pattern Editor [Top]"), kCtxCtrlPatterns); commandCategories.push_back(newCat); } { - CommandCategory newCat(" Pattern Editor - Order List", kCtxCtrlOrderlist); + CommandCategory newCat(_T(" Pattern Editor - Order List"), kCtxCtrlOrderlist); for(int c = kcStartOrderlistCommands; c <= kcEndOrderlistCommands; c++) newCat.commands.push_back(c); @@ -248,7 +248,7 @@ } { - CommandCategory newCat(" Pattern Editor - Quick Channel Settings", kCtxChannelSettings); + CommandCategory newCat(_T(" Pattern Editor - Quick Channel Settings"), kCtxChannelSettings); for(int c = kcStartChnSettingsCommands; c <= kcEndChnSettingsCommands; c++) newCat.commands.push_back(c); @@ -257,7 +257,7 @@ } { - CommandCategory newCat(" Pattern Editor - General", kCtxViewPatterns); + CommandCategory newCat(_T(" Pattern Editor - General"), kCtxViewPatterns); for(int c = kcStartPlainNavigate; c <= kcEndPlainNavigate; c++) newCat.commands.push_back(c); @@ -298,7 +298,7 @@ } { - CommandCategory newCat(" Pattern Editor - Note Column", kCtxViewPatternsNote); + CommandCategory newCat(_T(" Pattern Editor - Note Column"), kCtxViewPatternsNote); for(int c = kcVPStartNotes; c <= kcVPEndNotes; c++) newCat.commands.push_back(c); @@ -313,7 +313,7 @@ } { - CommandCategory newCat(" Pattern Editor - Instrument Column", kCtxViewPatternsIns); + CommandCategory newCat(_T(" Pattern Editor - Instrument Column"), kCtxViewPatternsIns); for(int c = kcSetIns0; c <= kcSetIns9; c++) newCat.commands.push_back(c); @@ -322,7 +322,7 @@ } { - CommandCategory newCat(" Pattern Editor - Volume Column", kCtxViewPatternsVol); + CommandCategory newCat(_T(" Pattern Editor - Volume Column"), kCtxViewPatternsVol); for(int c = kcSetVolumeStart; c <= kcSetVolumeEnd; c++) newCat.commands.push_back(c); @@ -331,7 +331,7 @@ } { - CommandCategory newCat(" Pattern Editor - Effect Column", kCtxViewPatternsFX); + CommandCategory newCat(_T(" Pattern Editor - Effect Column"), kCtxViewPatternsFX); for(int c = kcSetFXStart; c <= kcSetFXEnd; c++) newCat.commands.push_back(c); @@ -340,23 +340,23 @@ } { - CommandCategory newCat(" Pattern Editor - Effect Parameter Column", kCtxViewPatternsFXparam); + CommandCategory newCat(_T(" Pattern Editor - Effect Parameter Column"), kCtxViewPatternsFXparam); for(int c = kcSetFXParam0; c <= kcSetFXParamF; c++) newCat.commands.push_back(c); commandCategories.push_back(newCat); } { - CommandCategory newCat(" Sample [Top]", kCtxCtrlSamples); + CommandCategory newCat(_T(" Sample [Top]"), kCtxCtrlSamples); commandCategories.push_back(newCat); } { - CommandCategory newCat(" Sample Editor", kCtxViewSamples); + CommandCategory newCat(_T(" Sample Editor"), kCtxViewSamples); for(int c = kcStartSampleEditing; c <= kcEndSampleEditing; c++) newCat.commands.push_back(c); - newCat.separators.push_back(kcEndSampleEditing); //-------------------------------------- + newCat.separators.push_back(kcEndSampleEditing); //-------------------------------------- for(int c = kcStartSampleMisc; c <= kcEndSampleMisc; c++) newCat.commands.push_back(c); newCat.separators.push_back(kcEndSampleMisc); //-------------------------------------- @@ -367,7 +367,7 @@ } { - CommandCategory newCat(" Instrument Editor", kCtxCtrlInstruments); + CommandCategory newCat(_T(" Instrument Editor"), kCtxCtrlInstruments); for(int c = kcStartInstrumentCtrlMisc; c <= kcEndInstrumentCtrlMisc; c++) newCat.commands.push_back(c); @@ -376,7 +376,7 @@ } { - CommandCategory newCat(" Envelope Editor", kCtxViewInstruments); + CommandCategory newCat(_T(" Envelope Editor"), kCtxViewInstruments); for(int c = kcStartInstrumentMisc; c <= kcEndInstrumentMisc; c++) newCat.commands.push_back(c); @@ -385,17 +385,17 @@ } { - CommandCategory newCat(" Comments [Top]", kCtxCtrlComments); + CommandCategory newCat(_T(" Comments [Top]"), kCtxCtrlComments); commandCategories.push_back(newCat); } { - CommandCategory newCat(" Comments [Bottom]", kCtxViewComments); + CommandCategory newCat(_T(" Comments [Bottom]"), kCtxViewComments); commandCategories.push_back(newCat); } { - CommandCategory newCat(" Plugin Editor", kCtxVSTGUI); + CommandCategory newCat(_T(" Plugin Editor"), kCtxVSTGUI); for(int c = kcStartVSTGUICommands; c <= kcEndVSTGUICommands; c++) newCat.commands.push_back(c); @@ -547,7 +547,7 @@ { if(doSearch && addCategoryName) { - const CString catName = "------ " + commandCategories[cat].name.Trim() + " ------"; + const CString catName = _T("------ ") + commandCategories[cat].name.Trim() + _T(" ------"); m_lbnCommandKeys.SetItemData(m_lbnCommandKeys.AddString(catName), DWORD_PTR(-1)); addCategoryName = false; } @@ -563,7 +563,7 @@ } if(commandCategories[cat].separatorAt(com)) - m_lbnCommandKeys.SetItemData(m_lbnCommandKeys.AddString("------------------------------------------------------"), DWORD_PTR(-1)); + m_lbnCommandKeys.SetItemData(m_lbnCommandKeys.AddString(_T("------------------------------------------------------")), DWORD_PTR(-1)); } } @@ -587,9 +587,9 @@ //Separator if (nCmd == kcNull) { - m_cmbKeyChoice.SetWindowText(""); + m_cmbKeyChoice.SetWindowText(_T("")); m_cmbKeyChoice.EnableWindow(FALSE); - m_eCustHotKey.SetWindowText(""); + m_eCustHotKey.SetWindowText(_T("")); m_eCustHotKey.EnableWindow(FALSE); m_bKeyDown.SetCheck(0); m_bKeyDown.EnableWindow(FALSE); @@ -621,11 +621,11 @@ { for (int i=0; i<numChoices; i++) { - wsprintf(s, "Choice %d (of %d)", i+1, numChoices); + wsprintf(s, _T("Choice %u (of %u)"), i+1, numChoices); m_cmbKeyChoice.SetItemData(m_cmbKeyChoice.AddString(s), i); } } - m_cmbKeyChoice.SetItemData(m_cmbKeyChoice.AddString("<new>"), numChoices); + m_cmbKeyChoice.SetItemData(m_cmbKeyChoice.AddString(_T("<new>")), numChoices); m_cmbKeyChoice.SetCurSel(0); m_nCurKeyChoice = -1; OnKeyChoiceSelect(); @@ -680,7 +680,7 @@ if (val>5000) { val = 5000; - m_eChordWaitTime.SetWindowText("5000"); + m_eChordWaitTime.SetWindowText(_T("5000")); } OnSettingsChanged(); } @@ -758,8 +758,7 @@ //detect invalid input if (!kc.KeyCode()) { - CString error = "You need to say to which key you'd like to map this command to."; - Reporting::Warning(error, "Invalid key data", this); + Reporting::Warning("You need to say to which key you'd like to map this command to.", "Invalid key data", this); return; } if (!kc.EventType()) @@ -778,7 +777,7 @@ && conflictCmd.first != cmd && !plocalCmdSet->IsCrossContextConflict(kc, conflictCmd.second)) { - ConfirmAnswer delOld = Reporting::Confirm("New shortcut (" + kc.GetKeyText() + ") has the same key combination as " + plocalCmdSet->GetCommandText(conflictCmd.first) + " in " + conflictCmd.second.GetContextText() + ".\nDo you want to delete the other shortcut, only keeping the new one?", "Shortcut Conflict", true, false, this); + ConfirmAnswer delOld = Reporting::Confirm(_T("New shortcut (") + kc.GetKeyText() + _T(") has the same key combination as ") + plocalCmdSet->GetCommandText(conflictCmd.first) + _T(" in ") + conflictCmd.second.GetContextText() + _T(".\nDo you want to delete the other shortcut, only keeping the new one?"), _T("Shortcut Conflict"), true, false, this); if(delOld == cnfYes) { plocalCmdSet->Remove(conflictCmd.second, conflictCmd.first); @@ -915,7 +914,7 @@ void COptionsKeyboard::OnClearLog() //--------------------------------- { - m_eReport.SetWindowText(""); + m_eReport.SetWindowText(_T("")); ForceUpdateGUI(); } Modified: trunk/OpenMPT/mptrack/KeyConfigDlg.h =================================================================== --- trunk/OpenMPT/mptrack/KeyConfigDlg.h 2015-07-10 18:48:59 UTC (rev 5398) +++ trunk/OpenMPT/mptrack/KeyConfigDlg.h 2015-07-10 19:44:42 UTC (rev 5399) @@ -22,7 +22,7 @@ class CommandCategory { public: - CommandCategory(CString n, InputTargetContext d) : name(n), id(d) { } + CommandCategory(const TCHAR *n, InputTargetContext d) : name(n), id(d) { } bool separatorAt(int c) const { Modified: trunk/OpenMPT/mptrack/TrackerSettings.cpp =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.cpp 2015-07-10 18:48:59 UTC (rev 5398) +++ trunk/OpenMPT/mptrack/TrackerSettings.cpp 2015-07-10 19:44:42 UTC (rev 5399) @@ -588,7 +588,7 @@ patternFont = FontSetting((m_dwPatternSetup & 0x08) ? PATTERNFONT_SMALL : PATTERNFONT_LARGE, 0); m_dwPatternSetup &= ~(0x08 | 0x02); } - if(storedVersion < MAKE_VERSION_NUMERIC(1,25,00,08)) + if(storedVersion < MAKE_VERSION_NUMERIC(1,25,00,08) && glGeneralWindowHeight < 222) { glGeneralWindowHeight += 44; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |