From: <sag...@us...> - 2015-04-21 18:00:45
|
Revision: 4957 http://sourceforge.net/p/modplug/code/4957 Author: saga-games Date: 2015-04-21 18:00:31 +0000 (Tue, 21 Apr 2015) Log Message: ----------- [Fix] Make note and data entry shortcuts always operate on octaves instead of +/- 12 notes when using custom tunings (http://bugs.openmpt.org/view.php?id=681) [Mod] OpenMPT: Version is now 1.24.04.01 Modified Paths: -------------- trunk/OpenMPT/common/versionNumber.h trunk/OpenMPT/mptrack/CommandSet.cpp trunk/OpenMPT/mptrack/Ctrl_ins.cpp trunk/OpenMPT/mptrack/View_pat.cpp trunk/OpenMPT/mptrack/View_pat.h Modified: trunk/OpenMPT/common/versionNumber.h =================================================================== --- trunk/OpenMPT/common/versionNumber.h 2015-04-19 17:28:15 UTC (rev 4956) +++ trunk/OpenMPT/common/versionNumber.h 2015-04-21 18:00:31 UTC (rev 4957) @@ -19,7 +19,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 24 #define VER_MINOR 04 -#define VER_MINORMINOR 00 +#define VER_MINORMINOR 01 //Version string. For example "1.17.02.28" #define MPT_VERSION_STR VER_STRINGIZE(VER_MAJORMAJOR) "." VER_STRINGIZE(VER_MAJOR) "." VER_STRINGIZE(VER_MINOR) "." VER_STRINGIZE(VER_MINORMINOR) Modified: trunk/OpenMPT/mptrack/CommandSet.cpp =================================================================== --- trunk/OpenMPT/mptrack/CommandSet.cpp 2015-04-19 17:28:15 UTC (rev 4956) +++ trunk/OpenMPT/mptrack/CommandSet.cpp 2015-04-21 18:00:31 UTC (rev 4957) @@ -85,12 +85,12 @@ DefineKeyCommand(kcPatternPlayRow, 1002, _T("Play Row")); DefineKeyCommand(kcCursorCopy, 1003, _T("Quick Copy")); DefineKeyCommand(kcCursorPaste, 1004, _T("Quick Paste")); - DefineKeyCommand(kcChannelMute, 1005, _T("Mute current Channel")); - DefineKeyCommand(kcChannelSolo, 1006, _T("Solo current Channel")); + DefineKeyCommand(kcChannelMute, 1005, _T("Mute Current Channel")); + DefineKeyCommand(kcChannelSolo, 1006, _T("Solo Current Channel")); DefineKeyCommand(kcTransposeUp, 1007, _T("Transpose +1")); DefineKeyCommand(kcTransposeDown, 1008, _T("Transpose -1")); - DefineKeyCommand(kcTransposeOctUp, 1009, _T("Transpose +12")); - DefineKeyCommand(kcTransposeOctDown, 1010, _T("Transpose -12")); + DefineKeyCommand(kcTransposeOctUp, 1009, _T("Transpose +1 Octave")); + DefineKeyCommand(kcTransposeOctDown, 1010, _T("Transpose -1 Octave")); DefineKeyCommand(kcSelectColumn, 1011, _T("Select channel / Select all")); DefineKeyCommand(kcPatternAmplify, 1012, _T("Amplify selection")); DefineKeyCommand(kcPatternSetInstrument, 1013, _T("Apply current instrument")); @@ -598,8 +598,8 @@ DefineKeyCommand(kcVSTGUIBypassPlug, 1841, _T("Bypass Plugin")); DefineKeyCommand(kcInsNoteMapTransposeDown, 1842, _T("Transpose -1 (Note Map)")); DefineKeyCommand(kcInsNoteMapTransposeUp, 1843, _T("Transpose +1 (Note Map)")); - DefineKeyCommand(kcInsNoteMapTransposeOctDown, 1844, _T("Transpose -12 (Note Map)")); - DefineKeyCommand(kcInsNoteMapTransposeOctUp, 1845, _T("Transpose +12 (Note Map)")); + DefineKeyCommand(kcInsNoteMapTransposeOctDown, 1844, _T("Transpose -1 Octave (Note Map)")); + DefineKeyCommand(kcInsNoteMapTransposeOctUp, 1845, _T("Transpose +1 Octave (Note Map)")); DefineKeyCommand(kcInsNoteMapCopyCurrentNote, 1846, _T("Map all notes to selected note")); DefineKeyCommand(kcInsNoteMapCopyCurrentSample, 1847, _T("Map all notes to selected sample")); DefineKeyCommand(kcInsNoteMapReset, 1848, _T("Reset Note Mapping")); @@ -663,8 +663,8 @@ DefineKeyCommand(kcFileAppend, 1906, _T("File/Append Module")); DefineKeyCommand(kcSampleTransposeUp, 1907, _T("Transpose +1")); DefineKeyCommand(kcSampleTransposeDown, 1908, _T("Transpose -1")); - DefineKeyCommand(kcSampleTransposeOctUp, 1909, _T("Transpose +12")); - DefineKeyCommand(kcSampleTransposeOctDown, 1910, _T("Transpose -12")); + DefineKeyCommand(kcSampleTransposeOctUp, 1909, _T("Transpose +1 Octave")); + DefineKeyCommand(kcSampleTransposeOctDown, 1910, _T("Transpose -1 Octave")); DefineKeyCommand(kcPatternInterpolateInstr, 1911, _T("Interpolate Instrument")); DefineKeyCommand(kcDummyShortcut, 1912, _T("Dummy Shortcut")); DefineKeyCommand(kcSampleUpsample, 1913, _T("Upsample")); @@ -681,7 +681,7 @@ for(int j = kcStartSampleCues; j <= kcEndSampleCues; j++) { TCHAR s[32]; - wsprintf(s, "Preview Sample Cue %u", j - kcStartSampleCues + 1); + wsprintf(s, _T("Preview Sample Cue %u"), j - kcStartSampleCues + 1); DefineKeyCommand((CommandID)j, 1924 + j - kcStartSampleCues, s); } @@ -843,7 +843,7 @@ //Needs refactoring. Maybe make lots of Rule subclasses, each with their own Enforce() method? KeyCombination curKc; // for looping through key combinations KeyCombination newKc; // for adding new key combinations - CString report=""; + CString report; if(enforceRule[krAllowNavigationWithSelection]) { @@ -1022,9 +1022,7 @@ if (enforceRule[krAutoSelectOff]) { KeyCombination newKcDeSel; - bool ruleApplies = true; CommandID cmdOff = kcNull; - switch (inCmd) { case kcSelect: cmdOff = kcSelectOff; break; @@ -1033,11 +1031,9 @@ case kcCopySelectWithNav: cmdOff = kcCopySelectOffWithNav; break; case kcSelectWithCopySelect: cmdOff = kcSelectOffWithCopySelect; break; case kcCopySelectWithSelect: cmdOff = kcCopySelectOffWithSelect; break; - - default: ruleApplies = false; } - if(ruleApplies) + if(cmdOff != kcNull) { newKcDeSel = inKc; newKcDeSel.EventType(kKeyEventUp); @@ -1511,7 +1507,7 @@ fprintf(outStream, "//----------------------------------------------------------------------\n"); fprintf(outStream, "version:%u\n", KEYMAP_VERSION); - for (int ctx=0; ctx<kCtxMaxInputContexts; ctx++) + for (int ctx = 0; ctx < kCtxMaxInputContexts; ctx++) { fprintf(outStream, "\n//----( %s (%d) )------------\n", KeyCombination::GetContextText((InputTargetContext)ctx), ctx); @@ -1545,7 +1541,7 @@ //--------------------------------------------------------------------------------------------------------------- { KeyCombination kc; - CommandID cmd=kcNumCommands; + CommandID cmd = kcNumCommands; char s[1024]; CString curLine, token; int commentStart; @@ -1915,10 +1911,9 @@ if(codeNmod != -1) { kc.KeyCode(LOBYTE(codeNmod)); - kc.Modifier(0); // Don't add modifier keys, since on French keyboards, numbers are input using Shift. // We don't really want that behaviour here, and I'm sure we don't want that in other cases on other layouts as well. - //kc.Modifier(HIBYTE(codeNmod) & 0x07); //We're only interest in the bottom 3 bits. + kc.Modifier(0); Add(kc, cmd, true); } @@ -2025,7 +2020,5 @@ return m_isParentContext[kc1.Context()][kc2.Context()] || m_isParentContext[kc2.Context()][kc1.Context()]; } -//end rewbs.customKeys - OPENMPT_NAMESPACE_END Modified: trunk/OpenMPT/mptrack/Ctrl_ins.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2015-04-19 17:28:15 UTC (rev 4956) +++ trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2015-04-21 18:00:31 UTC (rev 4957) @@ -470,6 +470,12 @@ if(nAmount == 0) return; ModInstrument *pIns = m_modDoc.GetrSoundFile().Instruments[m_nInstrument]; + if((nAmount == 12 || nAmount == -12) && pIns->pTuning != nullptr) + { + // Special case for instrument-specific tunings + nAmount = pIns->pTuning->GetGroupSize() * sgn(nAmount); + } + if (pIns) { bool bModified = false; Modified: trunk/OpenMPT/mptrack/View_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_pat.cpp 2015-04-19 17:28:15 UTC (rev 4956) +++ trunk/OpenMPT/mptrack/View_pat.cpp 2015-04-21 18:00:31 UTC (rev 4957) @@ -2970,6 +2970,7 @@ PrepareUndo(m_Selection, "Transpose"); + std::vector<int> lastGroupSize(pSndFile->GetNumChannels(), 12); for(ROWINDEX row = startRow; row <= endRow; row++) { PatternRow m = pSndFile->Patterns[m_nPattern].GetRow(row); @@ -2977,7 +2978,21 @@ { if (m[chn].IsNote()) { - int note = m[chn].note + transp; + if(m[chn].instr > 0 && m[chn].instr <= pSndFile->GetNumInstruments()) + { + const ModInstrument *pIns = pSndFile->Instruments[m[chn].instr]; + if(pIns != nullptr && pIns->pTuning != nullptr) + { + lastGroupSize[chn] = pIns->pTuning->GetGroupSize(); + } + } + int transpose = transp; + if(transpose == 12000 || transpose == -12000) + { + // Transpose one octave + transpose = lastGroupSize[chn] * sgn(transpose); + } + int note = m[chn].note + transpose; Limit(note, noteMin, noteMax); m[chn].note = static_cast<ModCommand::NOTE>(note); } @@ -3012,6 +3027,8 @@ PrepareUndo(m_Selection, "Data Entry"); + // Notes per octave for non-TET12 tunings and coarse note steps + std::vector<int> lastGroupSize(pSndFile->GetNumChannels(), 12); for(ROWINDEX row = startRow; row <= endRow; row++) { PatternRow m = pSndFile->Patterns[m_nPattern].GetRow(row); @@ -3022,7 +3039,15 @@ // Increase / decrease note if(m[chn].IsNote()) { - int note = m[chn].note + offset * (coarse ? 12 : 1); + if(m[chn].instr > 0 && m[chn].instr <= pSndFile->GetNumInstruments()) + { + const ModInstrument *pIns = pSndFile->Instruments[m[chn].instr]; + if(pIns != nullptr && pIns->pTuning != nullptr) + { + lastGroupSize[chn] = pIns->pTuning->GetGroupSize(); + } + } + int note = m[chn].note + offset * (coarse ? lastGroupSize[chn] : 1); Limit(note, noteMin, noteMax); m[chn].note = (ModCommand::NOTE)note; } else if(m[chn].IsSpecialNote()) @@ -5094,8 +5119,20 @@ const ModCommand &target = GetCursorCommand(); if(target.IsNote()) { + int groupSize = 12; + if(target.instr > 0 && target.instr <= pSndFile->GetNumInstruments()) + { + const ModInstrument *pIns = pSndFile->Instruments[target.instr]; + if(pIns != nullptr && pIns->pTuning != nullptr) + { + groupSize = pIns->pTuning->GetGroupSize(); + } + } + PrepareUndo(m_Cursor, m_Cursor, "Octave Entry"); - TempEnterNote(((target.note - NOTE_MIN) % 12) + val * 12 + NOTE_MIN); + // The following might look a bit convoluted... This is mostly because the "middle-C" in + // custom tunings always has octave 5, no matter how many octaves the tuning actually has. + TempEnterNote(((target.note - NOTE_MIDDLEC) % groupSize) + (val - 5) * groupSize + NOTE_MIDDLEC); // Memorize note for key-up ASSERT(size_t(val) < octaveKeyMemory.size()); octaveKeyMemory[val] = target.note; Modified: trunk/OpenMPT/mptrack/View_pat.h =================================================================== --- trunk/OpenMPT/mptrack/View_pat.h 2015-04-19 17:28:15 UTC (rev 4956) +++ trunk/OpenMPT/mptrack/View_pat.h 2015-04-21 18:00:31 UTC (rev 4957) @@ -413,8 +413,8 @@ afx_msg void OnVisualizeEffect(); //rewbs.fxvis afx_msg void OnTransposeUp() { TransposeSelection(1); } afx_msg void OnTransposeDown() { TransposeSelection(-1); } - afx_msg void OnTransposeOctUp() { TransposeSelection(12); } - afx_msg void OnTransposeOctDown() { TransposeSelection(-12); } + afx_msg void OnTransposeOctUp() { TransposeSelection(12000); } + afx_msg void OnTransposeOctDown() { TransposeSelection(-12000); } afx_msg void OnTransposeCustom(); afx_msg void OnSetSelInstrument(); afx_msg void OnAddChannelFront() { AddChannelBefore(m_MenuCursor.GetChannel()); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |