From: <sag...@us...> - 2012-03-12 23:01:19
|
Revision: 1218 http://modplug.svn.sourceforge.net/modplug/?rev=1218&view=rev Author: saga-games Date: 2012-03-12 23:01:12 +0000 (Mon, 12 Mar 2012) Log Message: ----------- [Ref] Changed effect key auto setup to use the effect letters from CModSpecfications. Modified Paths: -------------- trunk/OpenMPT/mptrack/CommandSet.cpp trunk/OpenMPT/mptrack/CommandSet.h trunk/OpenMPT/mptrack/InputHandler.cpp trunk/OpenMPT/mptrack/InputHandler.h trunk/OpenMPT/mptrack/KeyConfigDlg.cpp trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/ModConvert.cpp Modified: trunk/OpenMPT/mptrack/CommandSet.cpp =================================================================== --- trunk/OpenMPT/mptrack/CommandSet.cpp 2012-03-12 22:59:25 UTC (rev 1217) +++ trunk/OpenMPT/mptrack/CommandSet.cpp 2012-03-12 23:01:12 UTC (rev 1218) @@ -72,6 +72,7 @@ commands[kc].Message = message; } + //Get command descriptions etc.. loaded up. void CCommandSet::SetupCommands() //------------------------------- @@ -636,17 +637,21 @@ #endif //_DEBUG } -//----------------------------------------- + //------------------------------------------------------- // Command Manipulation //------------------------------------------------------- CString CCommandSet::Add(KeyCombination kc, CommandID cmd, bool overwrite) +//------------------------------------------------------------------------ { return Add(kc, cmd, overwrite, -1); } + + CString CCommandSet::Add(KeyCombination kc, CommandID cmd, bool overwrite, int pos) +//--------------------------------------------------------------------------------- { CString report= ""; @@ -706,14 +711,18 @@ return report; } + bool CCommandSet::IsDummyCommand(CommandID cmd) -{ // e.g. Chord modifier is a dummy command, which serves only to automatically - // generate a set of keycombinations for chords (I'm not proud of this design). +//--------------------------------------------- +{ + // e.g. Chord modifier is a dummy command, which serves only to automatically + // generate a set of keycombinations for chords (I'm not proud of this design). return commands[cmd].isDummy; } CString CCommandSet::Remove(int pos, CommandID cmd) +//------------------------------------------------- { if (pos>=0 && pos<commands[cmd].kcList.GetSize()) { @@ -724,7 +733,9 @@ return ""; } + CString CCommandSet::Remove(KeyCombination kc, CommandID cmd) +//----------------------------------------------------------- { //find kc in commands[cmd].kcList int index=-1; @@ -749,6 +760,7 @@ CString CCommandSet::EnforceAll(KeyCombination inKc, CommandID inCmd, bool adding) +//-------------------------------------------------------------------------------- { //World's biggest, most confusing method. :) //Needs refactoring. Maybe make lots of Rule subclasses, each with their own Enforce() method? @@ -758,7 +770,7 @@ CString report=""; if (enforceRule[krAllowNavigationWithSelection]) - {//------------------------------------------------------------ + { // When we get a new navigation command key, we need to // make sure this navigation will work when any selection key is pressed if (inCmd>=kcStartPatNavigation && inCmd<=kcEndPatNavigation) @@ -805,11 +817,14 @@ // When we get a new selection key, we need to make sure that // all navigation commands will work with this selection key pressed else if (inCmd==kcSelect) - {// check that is is a selection + { + // check that is is a selection for (int curCmd=kcStartPatNavigation; curCmd<=kcEndPatNavigation; curCmd++) - {// for all nav commands + { + // for all nav commands for (int k=0; k<commands[curCmd].kcList.GetSize(); k++) - {// for all keys for this command + { + // for all keys for this command CommandID cmdNavSelection = (CommandID)(kcStartPatNavigationSelect + (curCmd-kcStartPatNavigation)); newKc=commands[curCmd].kcList[k]; // get all properties from the current nav cmd key newKc.mod|=inKc.mod; // and the new selection modifier @@ -848,7 +863,7 @@ } // end krAllowNavigationWithSelection if (enforceRule[krAllowSelectionWithNavigation]) - {//----------------------------------------------------------- + { KeyCombination newKcSel; // When we get a new navigation command key, we need to ensure @@ -926,7 +941,7 @@ } - //if we add a selector or a copy selector, we need it to switch off when we release the key. + // if we add a selector or a copy selector, we need it to switch off when we release the key. if (enforceRule[krAutoSelectOff]) { KeyCombination newKcDeSel; @@ -958,14 +973,14 @@ } - // Allow combinations of copyselect and select if (enforceRule[krAllowSelectCopySelectCombos]) { KeyCombination newKcSel, newKcCopySel; if (inCmd==kcSelect) - { //On getting a new selection key, make this selection key work with all copy selects' modifiers - //On getting a new selection key, make all copyselects work with this key's modifiers + { + // On getting a new selection key, make this selection key work with all copy selects' modifiers + // On getting a new selection key, make all copyselects work with this key's modifiers for (int k=0; k<commands[kcCopySelect].kcList.GetSize(); k++) { newKcSel=inKc; @@ -973,7 +988,7 @@ newKcCopySel=commands[kcCopySelect].kcList[k]; newKcCopySel.mod|=inKc.mod; Log("Enforcing rule krAllowSelectCopySelectCombos\n"); - if (adding) + if (adding) { Add(newKcSel, kcSelectWithCopySelect, false); Add(newKcCopySel, kcCopySelectWithSelect, false); @@ -986,8 +1001,9 @@ } } if (inCmd==kcCopySelect) - { //On getting a new copyselection key, make this copyselection key work with all selects' modifiers - //On getting a new copyselection key, make all selects work with this key's modifiers + { + // On getting a new copyselection key, make this copyselection key work with all selects' modifiers + // On getting a new copyselection key, make all selects work with this key's modifiers for (int k=0; k<commands[kcSelect].kcList.GetSize(); k++) { newKcSel=commands[kcSelect].kcList[k]; @@ -995,7 +1011,7 @@ newKcCopySel=inKc; newKcCopySel.mod|=commands[kcSelect].kcList[k].mod; Log("Enforcing rule krAllowSelectCopySelectCombos\n"); - if (adding) + if (adding) { Add(newKcSel, kcSelectWithCopySelect, false); Add(newKcCopySel, kcCopySelectWithSelect, false); @@ -1297,7 +1313,9 @@ return report; } + UINT CCommandSet::CodeToModifier(UINT code) +//----------------------------------------- { switch(code) { @@ -1310,18 +1328,20 @@ } + //------------------------------------------------------- // Export //------------------------------------------------------- //Generate a keymap from a command set void CCommandSet::GenKeyMap(KeyMap &km) +//------------------------------------- { KeyCombination curKc; CArray<KeyEventType, KeyEventType> eventTypes; CArray<InputTargetContext, InputTargetContext> contexts; //Clear map - memset(km, -1, sizeof(kcNull)*KeyMapSize); + memset(km, -1, sizeof(KeyMap)); //Copy commandlist content into map: for (UINT cmd=0; cmd<kcNumCommands; cmd++) @@ -1372,10 +1392,10 @@ } } -//------------------------------------- DWORD CCommandSet::GetKeymapLabel(InputTargetContext ctx, UINT mod, UINT code, KeyEventType ke) +//--------------------------------------------------------------------------------------------- { //Unused ASSERT((long)ctx<0xFF); ASSERT((long)mod<0xFF); @@ -1392,31 +1412,39 @@ return label; } + void CCommandSet::Copy(CCommandSet *source) +//----------------------------------------- { // copy constructors should take care of complexity (I hope) - for (int cmd=0; cmd<commands.GetSize(); cmd++) + for (int cmd = 0; cmd < commands.GetSize(); cmd++) commands[cmd] = source->commands[cmd]; } + KeyCombination CCommandSet::GetKey(CommandID cmd, UINT key) +//--------------------------------------------------------- { return commands[cmd].kcList[key]; } - int CCommandSet::GetKeyListSize(CommandID cmd) +//-------------------------------------------- { return commands[cmd].kcList.GetSize(); } + CString CCommandSet::GetCommandText(CommandID cmd) +//------------------------------------------------ { return commands[cmd].Message; } + bool CCommandSet::SaveFile(CString fileName) +//------------------------------------------ { //TODO: Make C++ /* Layout: @@ -1473,6 +1501,7 @@ bool CCommandSet::LoadFile(std::istream& iStrm, LPCTSTR szFilename) +//----------------------------------------------------------------- { KeyCombination kc; CommandID cmd=kcNumCommands; @@ -1746,6 +1775,7 @@ //Could do better search algo but this is not perf critical. int CCommandSet::FindCmd(int uid) +//------------------------------- { for (int i=0; i<kcNumCommands; i++) { @@ -1756,7 +1786,9 @@ return -1; } + CString CCommandSet::GetContextText(InputTargetContext ctx) +//--------------------------------------------------------- { switch(ctx) { @@ -1783,7 +1815,10 @@ default: return "Unknown Context"; } }; + + CString CCommandSet::GetKeyEventText(KeyEventType ke) +//--------------------------------------------------- { CString text=""; @@ -1808,7 +1843,9 @@ return text; } + CString CCommandSet::GetModifierText(UINT mod) +//-------------------------------------------- { CString text = ""; if (mod & HOTKEYF_SHIFT) text.Append("Shift+"); @@ -1818,7 +1855,9 @@ return text; } + CString CCommandSet::GetKeyText(UINT mod, UINT code) +//-------------------------------------------------- { CString keyText; keyText=GetModifierText(mod); @@ -1831,7 +1870,9 @@ return keyText; } + CString CCommandSet::GetKeyTextFromCommand(CommandID c, UINT key) +//--------------------------------------------------------------- { if ( static_cast<INT_PTR>(key) < commands[c].kcList.GetSize()) return GetKeyText(commands[c].kcList[0].mod, commands[c].kcList[0].code); @@ -1839,15 +1880,15 @@ return ""; } + bool CCommandSet::isHidden(UINT c) +//-------------------------------- { return commands[c].isHidden; } - - //------------------------------------------------------- // Quick Changes - modify many commands with one call. //------------------------------------------------------- @@ -1871,8 +1912,9 @@ return true; } + bool CCommandSet::QuickChange_NoNotesRepeat() -//----------------------------------------- +//------------------------------------------- { KeyCombination kc; int choices; @@ -1890,36 +1932,38 @@ return true; } -bool CCommandSet::QuickChange_SetEffectsXM() -//----------------------------------------- -{ - return QuickChange_SetEffects("0123456789abcdr?fte???ghk?yxplz"); -} -bool CCommandSet::QuickChange_SetEffectsIT() -//----------------------------------------- +bool CCommandSet::QuickChange_SetEffects(const CModSpecifications &modSpecs) +//-------------------------------------------------------------------------- { - return QuickChange_SetEffects("jfeghlkrxodb?cqati?smnvw?uy?p?z"); - -} - -bool CCommandSet::QuickChange_SetEffects(char comList[kcSetFXEnd-kcSetFXStart]) -//----------------------------------------- -{ int choices=0; KeyCombination kc; kc.ctx = kCtxViewPatternsFX; kc.event = kKeyEventDown; - for (CommandID cmd=kcFixedFXStart; cmd<=kcFixedFXend; cmd=(CommandID)(cmd+1)) + for(CommandID cmd = kcFixedFXStart; cmd <= kcFixedFXend; cmd = static_cast<CommandID>(cmd + 1)) { - choices = GetKeyListSize(cmd); //Remove all old choices - for (int p=choices; p>=0; --p) + //Remove all old choices + choices = GetKeyListSize(cmd); + for(int p = choices; p >= 0; --p) + { Remove(p, cmd); + } - if (comList[cmd-kcSetFXStart] != '?') //? is used an non existant command. + char effect = modSpecs.GetEffectLetter(static_cast<ModCommand::COMMAND>(cmd - kcSetFXStart + 1)); + if(effect >= 'A' && effect <= 'Z') { - SHORT codeNmod = VkKeyScanEx(comList[cmd-kcFixedFXStart], GetKeyboardLayout(0)); + // VkKeyScanEx needs lowercase letters + effect = effect - 'A' + 'a'; + } else if(effect < '0' || effect > '9') + { + // Don't map effects that use "weird" effect letters (such as # or \) + effect = '?'; + } + + if(effect != '?') + { + SHORT codeNmod = VkKeyScanEx(effect, GetKeyboardLayout(0)); kc.code = LOBYTE(codeNmod); kc.mod = HIBYTE(codeNmod) & 0x07; //We're only interest in the bottom 3 bits. Add(kc, cmd, true); Modified: trunk/OpenMPT/mptrack/CommandSet.h =================================================================== --- trunk/OpenMPT/mptrack/CommandSet.h 2012-03-12 22:59:25 UTC (rev 1217) +++ trunk/OpenMPT/mptrack/CommandSet.h 2012-03-12 23:01:12 UTC (rev 1218) @@ -10,6 +10,7 @@ #pragma once #include "afxtempl.h" +#include "../soundlib/mod_specifications.h" #include <string> //#define VK_ALT 0x12 @@ -1077,7 +1078,6 @@ }; #define MAINKEYS 256 -#define KeyMapSize kCtxMaxInputContexts*MaxMod*MAINKEYS*kNumKeyEvents typedef CommandID KeyMap[kCtxMaxInputContexts][MaxMod][MAINKEYS][kNumKeyEvents]; //typedef CMap<long, long, CommandID, CommandID> KeyMap; @@ -1119,8 +1119,7 @@ { UINT ID; CString desc; - bool enforce; - + bool enforce; }; enum RuleID @@ -1190,9 +1189,7 @@ CString Remove(int pos, CommandID cmd); //Tranformation - bool QuickChange_SetEffectsXM(); - bool QuickChange_SetEffectsIT(); - bool QuickChange_SetEffects(char comList[kcSetFXEnd-kcSetFXStart]); + bool QuickChange_SetEffects(const CModSpecifications &modSpecs); bool QuickChange_NotesRepeat(); bool QuickChange_NoNotesRepeat(); Modified: trunk/OpenMPT/mptrack/InputHandler.cpp =================================================================== --- trunk/OpenMPT/mptrack/InputHandler.cpp 2012-03-12 22:59:25 UTC (rev 1217) +++ trunk/OpenMPT/mptrack/InputHandler.cpp 2012-03-12 23:01:12 UTC (rev 1218) @@ -23,8 +23,8 @@ #define TRANSITIONBIT 0x8000 #define REPEATBIT 0x4000 -//-------------------------------------------------------------- CInputHandler::CInputHandler(CWnd *mainframe) +//------------------------------------------- { m_pMainFrm = mainframe; @@ -79,15 +79,17 @@ m_bNoAltMenu = true; } -CInputHandler::~CInputHandler(void) + + +CInputHandler::~CInputHandler() +//----------------------------- { delete activeCommandSet; } - -//-------------------------------------------------------------- CommandID CInputHandler::GeneralKeyEvent(InputTargetContext context, int code, WPARAM wParam , LPARAM lParam) +//----------------------------------------------------------------------------------------------------------- { CommandID executeCommand = kcNull; KeyEventType keyEventType; @@ -126,7 +128,7 @@ CommandID CInputHandler::KeyEvent(InputTargetContext context, UINT &nChar, UINT &/*nRepCnt*/, UINT &/*nFlags*/, KeyEventType keyEventType, CWnd* pSourceWnd) -//------------------------------------------------------------------------------------------------------------------------------------------------- +//---------------------------------------------------------------------------------------------------------------------------------------------------------- { CommandID executeCommand = keyMap[context][modifierMask][nChar][keyEventType]; @@ -144,8 +146,10 @@ return executeCommand; } + // Feature: use Windows keys as modifier keys, intercept special keys -bool CInputHandler::InterceptSpecialKeys( UINT nChar , UINT nFlags ) +bool CInputHandler::InterceptSpecialKeys(UINT nChar, UINT nFlags) +//--------------------------------------------------------------- { KeyEventType keyEventType = GetKeyEventType( HIWORD(nFlags) ); enum { VK_NonExistentKey = VK_F24+1 }; @@ -188,7 +192,9 @@ return false; }; + void CInputHandler::SetupSpecialKeyInterception() +//----------------------------------------------- { m_bInterceptWindowsKeys = m_bInterceptNumLock = m_bInterceptCapsLock = m_bInterceptScrollLock = false; for( int context=0; context < CountOf(keyMap); context++ ) @@ -269,8 +275,10 @@ return false; } + //-------------------------------------------------------------- DWORD CInputHandler::GetKey(CommandID /*c*/) +//------------------------------------------ { return 0;// command[c].kc.code command[c].kc.mod; } @@ -281,6 +289,7 @@ int CInputHandler::SetCommand(InputTargetContext context, CommandID cmd, UINT modifierMask, UINT actionKey, UINT keyEventType) +//---------------------------------------------------------------------------------------------------------------------------- { int deletedCommand = -1; @@ -295,18 +304,23 @@ return deletedCommand; } + KeyCombination CInputHandler::GetKey(CommandID cmd, UINT key) +//----------------------------------------------------------- { return activeCommandSet->GetKey(cmd, key); } int CInputHandler::GetKeyListSize(CommandID cmd) +//---------------------------------------------- { return activeCommandSet->GetKeyListSize(cmd); } + CString CInputHandler::GetCommandText(CommandID cmd) +//-------------------------------------------------- { return activeCommandSet->GetCommandText(cmd); } @@ -326,6 +340,7 @@ */ void CInputHandler::LogModifiers(UINT mask) +//----------------------------------------- { Log("----------------------------------\n"); if (mask & HOTKEYF_CONTROL) Log("Ctrl On"); else Log("Ctrl --"); @@ -334,26 +349,41 @@ if (mask & HOTKEYF_EXT) Log("\tWin On\n"); else Log("\tWin --\n"); // Feature: use Windows keys as modifier keys } + KeyEventType CInputHandler::GetKeyEventType(UINT nFlags) +//------------------------------------------------------ { - if (nFlags & TRANSITIONBIT) //Key released + if (nFlags & TRANSITIONBIT) + { + // Key released return kKeyEventUp; - else - if (nFlags & REPEATBIT) //key repeated + } else + { + if (nFlags & REPEATBIT) + { + // Key repeated return kKeyEventRepeat; - else //new key down - return kKeyEventDown; + } else + { + // New key down + return kKeyEventDown; + } + } } -bool CInputHandler::SelectionPressed(void) + +bool CInputHandler::SelectionPressed() +//------------------------------------ { bool result=false; int nSelectionKeys = activeCommandSet->GetKeyListSize(kcSelect); KeyCombination key; - for (int k=0; k<nSelectionKeys; k++) { + for (int k=0; k<nSelectionKeys; k++) + { key = activeCommandSet->GetKey(kcSelect, k); - if (modifierMask & key.mod) { + if (modifierMask & key.mod) + { result=true; break; } @@ -362,55 +392,74 @@ } -bool CInputHandler::ShiftPressed(void) +bool CInputHandler::ShiftPressed() +//-------------------------------- { return (modifierMask & HOTKEYF_SHIFT); } -bool CInputHandler::CtrlPressed(void) + +bool CInputHandler::CtrlPressed() +//------------------------------- { return ((modifierMask & HOTKEYF_CONTROL) != 0); } -bool CInputHandler::AltPressed(void) + +bool CInputHandler::AltPressed() +//------------------------------ { return ((modifierMask & HOTKEYF_ALT) != 0); } + void CInputHandler::Bypass(bool b) +//-------------------------------- { m_bBypass=b; } + bool CInputHandler::Bypass() +//-------------------------- { return m_bBypass; } + WORD CInputHandler::GetModifierMask() +//----------------------------------- { return (WORD)modifierMask; } + void CInputHandler::SetModifierMask(WORD mask) +//-------------------------------------------- { modifierMask=mask; } + CString CInputHandler::GetCurModifierText() +//----------------------------------------- { return activeCommandSet->GetModifierText(modifierMask); } + CString CInputHandler::GetKeyTextFromCommand(CommandID c) +//------------------------------------------------------- { return activeCommandSet->GetKeyTextFromCommand(c, 0); } + #define FILENEW 1 #define MAINVIEW 59392 CString CInputHandler::GetMenuText(UINT id) +//----------------------------------------- { CString s; CommandID c = kcNull; @@ -488,7 +537,9 @@ return s; } + void CInputHandler::UpdateMainMenu() +//---------------------------------- { CMenu *pMenu = (CMainFrame::GetMainFrame())->GetMenu(); if (!pMenu) return; @@ -553,6 +604,7 @@ void CInputHandler::SetNewCommandSet(CCommandSet *newSet) +//------------------------------------------------------- { activeCommandSet->Copy(newSet); activeCommandSet->GenKeyMap(keyMap); @@ -560,48 +612,35 @@ UpdateMainMenu(); } -bool CInputHandler::noAltMenu() -{ - return m_bNoAltMenu; -} - - -bool CInputHandler::SetITEffects(void) +bool CInputHandler::SetEffectLetters(const CModSpecifications &modSpecs) +//---------------------------------------------------------------------- { - Log("Setting command set to IT.\n"); - bool retval = activeCommandSet->QuickChange_SetEffectsIT(); + Log("Changing command set.\n"); + bool retval = activeCommandSet->QuickChange_SetEffects(modSpecs); activeCommandSet->GenKeyMap(keyMap); return retval; } -bool CInputHandler::SetXMEffects(void) -{ - Log("Setting command set to XM.\n"); - bool retval = activeCommandSet->QuickChange_SetEffectsXM(); - activeCommandSet->GenKeyMap(keyMap); - return retval; -} - - bool CInputHandler::isKeyPressHandledByTextBox(DWORD key) +//------------------------------------------------------- { //Alpha-numerics (only shift or no modifier): - if (!CtrlPressed() && !AltPressed() && - ((key>='A'&&key<='Z') || (key>='0'&&key<='9') || + if(!CtrlPressed() && !AltPressed() + && ((key>='A'&&key<='Z') || (key>='0'&&key<='9') || key==VK_DIVIDE || key==VK_MULTIPLY || key==VK_SPACE || key==VK_RETURN || key==VK_CAPITAL || (key>=VK_OEM_1 && key<=VK_OEM_3) || (key>=VK_OEM_4 && key<=VK_OEM_8))) return true; //navigation (any modifier): - if (key == VK_LEFT || key == VK_RIGHT || key == VK_UP || key == VK_DOWN || + if(key == VK_LEFT || key == VK_RIGHT || key == VK_UP || key == VK_DOWN || key == VK_HOME || key == VK_END || key == VK_DELETE || key == VK_INSERT || key == VK_BACK) return true; //Copy paste etc.. - if (CMainFrame::GetInputHandler()->GetModifierMask()==HOTKEYF_CONTROL && + if(CMainFrame::GetInputHandler()->GetModifierMask()==HOTKEYF_CONTROL && (key == 'Y' || key == 'Z' || key == 'X' || key == 'C' || key == 'V' || key == 'A')) return true; Modified: trunk/OpenMPT/mptrack/InputHandler.h =================================================================== --- trunk/OpenMPT/mptrack/InputHandler.h 2012-03-12 22:59:25 UTC (rev 1217) +++ trunk/OpenMPT/mptrack/InputHandler.h 2012-03-12 23:01:12 UTC (rev 1218) @@ -54,7 +54,7 @@ public: CInputHandler(CWnd *mainframe); - ~CInputHandler(void); + ~CInputHandler(); CommandID GeneralKeyEvent(InputTargetContext context, int code, WPARAM wParam , LPARAM lParam); CommandID KeyEvent(InputTargetContext context, UINT &nChar, UINT &nRepCnt, UINT &nFlags, KeyEventType keyEventType, CWnd* pSourceWnd=NULL); int SetCommand(InputTargetContext context, CommandID command, UINT modifierMask, UINT actionKey, UINT keyEventType); @@ -83,10 +83,10 @@ public: CCommandSet *activeCommandSet; - bool ShiftPressed(void); - bool SelectionPressed(void); - bool CtrlPressed(void); - bool AltPressed(void); + bool ShiftPressed(); + bool SelectionPressed(); + bool CtrlPressed(); + bool AltPressed(); bool Bypass(); void Bypass(bool); WORD GetModifierMask(); @@ -96,7 +96,6 @@ CString GetMenuText(UINT id); void UpdateMainMenu(); void SetNewCommandSet(CCommandSet * newSet); - bool noAltMenu(); - bool SetXMEffects(void); - bool SetITEffects(void); + bool noAltMenu() { return m_bNoAltMenu; }; + bool SetEffectLetters(const CModSpecifications &modSpecs); }; Modified: trunk/OpenMPT/mptrack/KeyConfigDlg.cpp =================================================================== --- trunk/OpenMPT/mptrack/KeyConfigDlg.cpp 2012-03-12 22:59:25 UTC (rev 1217) +++ trunk/OpenMPT/mptrack/KeyConfigDlg.cpp 2012-03-12 23:01:12 UTC (rev 1218) @@ -818,7 +818,7 @@ void COptionsKeyboard::OnSetITEffects() //------------------------------------- { - plocalCmdSet->QuickChange_SetEffectsIT(); + plocalCmdSet->QuickChange_SetEffects(ModSpecs::itEx); ForceUpdateGUI(); } @@ -826,7 +826,7 @@ void COptionsKeyboard::OnSetXMEffects() //------------------------------------- { - plocalCmdSet->QuickChange_SetEffectsXM(); + plocalCmdSet->QuickChange_SetEffects(ModSpecs::xmEx); ForceUpdateGUI(); } Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2012-03-12 22:59:25 UTC (rev 1217) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2012-03-12 23:01:12 UTC (rev 1218) @@ -2502,8 +2502,8 @@ //rewbs.customKeys // We have swicthed focus to a new module - might need to update effect keys to reflect module type -bool CMainFrame::UpdateEffectKeys(void) -//------------------------------------- +bool CMainFrame::UpdateEffectKeys() +//--------------------------------- { CModDoc* pModDoc = GetActiveDoc(); if (pModDoc) @@ -2511,10 +2511,7 @@ CSoundFile* pSndFile = pModDoc->GetSoundFile(); if (pSndFile) { - if (pSndFile->m_nType & (MOD_TYPE_MOD|MOD_TYPE_XM)) - return m_InputHandler->SetXMEffects(); - else - return m_InputHandler->SetITEffects(); + return m_InputHandler->SetEffectLetters(pSndFile->GetModSpecifications()); } } Modified: trunk/OpenMPT/mptrack/ModConvert.cpp =================================================================== --- trunk/OpenMPT/mptrack/ModConvert.cpp 2012-03-12 22:59:25 UTC (rev 1217) +++ trunk/OpenMPT/mptrack/ModConvert.cpp 2012-03-12 23:01:12 UTC (rev 1218) @@ -501,10 +501,7 @@ //rewbs.customKeys: update effect key commands CInputHandler *ih = CMainFrame::GetMainFrame()->GetInputHandler(); - if(newTypeIsMOD_XM) - ih->SetXMEffects(); - else - ih->SetITEffects(); + ih->SetEffectLetters(m_SndFile.GetModSpecifications()); //end rewbs.customKeys return true; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2012-03-27 21:11:58
|
Revision: 1231 http://modplug.svn.sourceforge.net/modplug/?rev=1231&view=rev Author: saga-games Date: 2012-03-27 21:11:51 +0000 (Tue, 27 Mar 2012) Log Message: ----------- [Fix] Reverted VST handling to 16-bit. Revision 1130 broke more than it fixed. Revision Links: -------------- http://modplug.svn.sourceforge.net/modplug/?rev=1130&view=rev Modified Paths: -------------- trunk/OpenMPT/mptrack/Vstplug.cpp trunk/OpenMPT/mptrack/test/test.cpp Modified: trunk/OpenMPT/mptrack/Vstplug.cpp =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.cpp 2012-03-25 00:07:09 UTC (rev 1230) +++ trunk/OpenMPT/mptrack/Vstplug.cpp 2012-03-27 21:11:51 UTC (rev 1231) @@ -3461,8 +3461,8 @@ ULONG m_nSamplesPerSec; AEffect m_Effect; REFERENCE_TIME m_DataTime; - float *m_pMixBuffer; - float m_MixBuffer[MIXBUFFERSIZE * 2 + 16]; // 16-bit Stereo interleaved + int16 *m_pMixBuffer; + int16 m_MixBuffer[MIXBUFFERSIZE * 2 + 16]; // 16-bit Stereo interleaved public: CDmo2Vst(IMediaObject *pMO, IMediaObjectInPlace *pMOIP, DWORD uid); @@ -3471,7 +3471,7 @@ VstIntPtr Dispatcher(VstInt32 opCode, VstInt32 index, VstIntPtr value, void *ptr, float opt); void SetParameter(VstInt32 index, float parameter); float GetParameter(VstInt32 index); - void Process(float * const *inputs, float **outputs, long sampleframes); + void Process(float * const *inputs, float **outputs, int samples); public: static VstIntPtr VSTCALLBACK DmoDispatcher(AEffect *effect, VstInt32 opCode, VstInt32 index, VstIntPtr value, void *ptr, float opt); @@ -3480,8 +3480,13 @@ static void VSTCALLBACK DmoProcess(AEffect *effect, float **inputs, float **outputs, VstInt32 sampleframes); protected: - void Interleave(const float *pinL, const float *pinR, int nsamples); - void Deinterleave(float *poutL, float *poutR, int nsamples); + // Stream conversion functions + void InterleaveFloatToInt16(const float *inLeft, const float *inRight, int nsamples); + void DeinterleaveInt16ToFloat(float *outLeft, float *outRight, int nsamples) const; +#ifdef ENABLE_SSE + void SSEInterleaveFloatToInt16(const float *inLeft, const float *inRight, int nsamples); + void SSEDeinterleaveInt16ToFloat(float *outLeft, float *outRight, int nsamples) const; +#endif // ENABLE_SSE }; @@ -3513,7 +3518,7 @@ m_Effect.numParams = dwParamCount; } if (FAILED(m_pMediaObject->QueryInterface(IID_IMediaParams, (void **)&m_pMediaParams))) m_pMediaParams = nullptr; - m_pMixBuffer = (float *)((((int)m_MixBuffer)+15)&~15); + m_pMixBuffer = (int16 *)((((int)m_MixBuffer) + 15) & ~15); // Callbacks m_Effect.dispatcher = DmoDispatcher; m_Effect.setParameter = DmoSetParameter; @@ -3693,12 +3698,12 @@ mt.pUnk = nullptr; mt.pbFormat = (LPBYTE)&wfx; mt.cbFormat = sizeof(WAVEFORMATEX); - mt.lSampleSize = 2 * sizeof(float); - wfx.wFormatTag = WAVE_FORMAT_IEEE_FLOAT; + mt.lSampleSize = 2 * sizeof(int16); + wfx.wFormatTag = WAVE_FORMAT_PCM; wfx.nChannels = 2; wfx.nSamplesPerSec = m_nSamplesPerSec; - wfx.wBitsPerSample = sizeof(float) * 8; - wfx.nBlockAlign = wfx.nChannels * (wfx.wBitsPerSample >> 3); + wfx.wBitsPerSample = sizeof(int16) * 8; + wfx.nBlockAlign = wfx.nChannels * (wfx.wBitsPerSample / 8); wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign; wfx.cbSize = 0; if (FAILED(m_pMediaObject->SetInputType(0, &mt, 0)) @@ -3785,41 +3790,146 @@ } -void CDmo2Vst::Interleave(const float *pinL, const float *pinR, int nsamples) -//--------------------------------------------------------------------------- +static const float _f2si = 32768.0f; +static const float _si2f = 1.0f / 32768.0f; + +// Interleave two float streams into one int16 stereo stream. +void CDmo2Vst::InterleaveFloatToInt16(const float *inLeft, const float *inRight, int samples) +//------------------------------------------------------------------------------------------- { - float *pout = m_pMixBuffer; - for(int i = nsamples; i != 0; i--) + int16 *outBuf = m_pMixBuffer; + for(int i = samples; i != 0; i--) { - *(pout++) = *(pinL++); - *(pout++) = *(pinR++); + *(outBuf++) = static_cast<int16>(Clamp(*(inLeft++) * _f2si, static_cast<float>(int16_min), static_cast<float>(int16_max))); + *(outBuf++) = static_cast<int16>(Clamp(*(inRight++) * _f2si, static_cast<float>(int16_min), static_cast<float>(int16_max))); } } -void CDmo2Vst::Deinterleave(float *poutL, float *poutR, int nsamples) -//------------------------------------------------------------------- +// Deinterleave an int16 stereo stream into two float streams. +void CDmo2Vst::DeinterleaveInt16ToFloat(float *outLeft, float *outRight, int samples) const +//----------------------------------------------------------------------------------------- { - const float *pin = m_pMixBuffer; - for(int i = nsamples; i != 0; i--) + const int16 *inBuf = m_pMixBuffer; + for(int i = samples; i != 0; i--) { - *(poutL++) += Clamp(*(pin++), -1.0f, 1.0f); - *(poutR++) += Clamp(*(pin++), -1.0f, 1.0f); + *outLeft++ += _si2f * static_cast<float>(*inBuf++); + *outRight++ += _si2f * static_cast<float>(*inBuf++); } } -void CDmo2Vst::Process(float * const *inputs, float **outputs, long sampleframes) -//------------------------------------------------------------------------------- +#ifdef ENABLE_SSE +// Interleave two float streams into one int16 stereo stream using SSE magic. +void CDmo2Vst::SSEInterleaveFloatToInt16(const float *inLeft, const float *inRight, int samples) +//---------------------------------------------------------------------------------------------- { - if ((!m_pMixBuffer) || (sampleframes <= 0)) + int16 *outBuf = m_pMixBuffer; + _asm + { + mov eax, inLeft + mov edx, inRight + mov ebx, outBuf + mov ecx, samples + movss xmm2, _f2si + xorps xmm0, xmm0 + xorps xmm1, xmm1 + shufps xmm2, xmm2, 0x00 + pxor mm0, mm0 + inc ecx + shr ecx, 1 +mainloop: + movlps xmm0, [eax] + movlps xmm1, [edx] + mulps xmm0, xmm2 + mulps xmm1, xmm2 + add ebx, 8 + cvtps2pi mm0, xmm0 // mm0 = [ x2l | x1l ] + add eax, 8 + cvtps2pi mm1, xmm1 // mm1 = [ x2r | x1r ] + add edx, 8 + packssdw mm0, mm1 // mm0 = [x2r|x1r|x2l|x1l] + pshufw mm0, mm0, 0xD8 + dec ecx + movq [ebx-8], mm0 + jnz mainloop + emms + } +} + + +// Deinterleave an int16 stereo stream into two float streams using SSE magic. +void CDmo2Vst::SSEDeinterleaveInt16ToFloat(float *outLeft, float *outRight, int samples) const +//-------------------------------------------------------------------------------------------- +{ + const int16 *inBuf = m_pMixBuffer; + _asm { + mov ebx, inBuf + mov eax, outLeft + mov edx, outRight + mov ecx, samples + movss xmm7, _si2f + inc ecx + shr ecx, 1 + shufps xmm7, xmm7, 0x00 + xorps xmm0, xmm0 + xorps xmm1, xmm1 + xorps xmm2, xmm2 +mainloop: + movq mm0, [ebx] // mm0 = [x2r|x2l|x1r|x1l] + add ebx, 8 + pxor mm1, mm1 + pxor mm2, mm2 + punpcklwd mm1, mm0 // mm1 = [x1r|0|x1l|0] + punpckhwd mm2, mm0 // mm2 = [x2r|0|x2l|0] + psrad mm1, 16 // mm1 = [x1r|x1l] + movlps xmm2, [eax] + psrad mm2, 16 // mm2 = [x2r|x2l] + cvtpi2ps xmm0, mm1 // xmm0 = [ ? | ? |x1r|x1l] + dec ecx + cvtpi2ps xmm1, mm2 // xmm1 = [ ? | ? |x2r|x2l] + movhps xmm2, [edx] // xmm2 = [y2r|y1r|y2l|y1l] + movlhps xmm0, xmm1 // xmm0 = [x2r|x2l|x1r|x1l] + shufps xmm0, xmm0, 0xD8 + lea eax, [eax+8] + mulps xmm0, xmm7 + addps xmm0, xmm2 + lea edx, [edx+8] + movlps [eax-8], xmm0 + movhps [edx-8], xmm0 + jnz mainloop + emms + } +} + +#endif // ENABLE_SSE + + +void CDmo2Vst::Process(float * const *inputs, float **outputs, int samples) +//------------------------------------------------------------------------- +{ + if(m_pMixBuffer == nullptr || samples <= 0) + { return; + } - Interleave(inputs[0], inputs[1], sampleframes); - m_pMediaProcess->Process(sampleframes * 2 * sizeof(float), (LPBYTE)m_pMixBuffer, m_DataTime, DMO_INPLACE_NORMAL); - Deinterleave(outputs[0], outputs[1], sampleframes); +#ifdef ENABLE_MMX +#ifdef ENABLE_SSE + if((CSoundFile::gdwSysInfo & SYSMIX_SSE) && (CSoundFile::gdwSoundSetup & SNDMIX_ENABLEMMX)) + { + SSEInterleaveFloatToInt16(inputs[0], inputs[1], samples); + m_pMediaProcess->Process(samples * 2 * sizeof(int16), reinterpret_cast<BYTE *>(m_pMixBuffer), m_DataTime, DMO_INPLACE_NORMAL); + SSEDeinterleaveInt16ToFloat(outputs[0], outputs[1], samples); + } else +#endif // ENABLE_SSE +#endif // ENABLE_MMX + { + InterleaveFloatToInt16(inputs[0], inputs[1], samples); + m_pMediaProcess->Process(samples * 2 * sizeof(int16), reinterpret_cast<BYTE *>(m_pMixBuffer), m_DataTime, DMO_INPLACE_NORMAL); + DeinterleaveInt16ToFloat(outputs[0], outputs[1], samples); + } - m_DataTime += _muldiv(sampleframes, 10000000, m_nSamplesPerSec); + m_DataTime += _muldiv(samples, 10000000, m_nSamplesPerSec); } Modified: trunk/OpenMPT/mptrack/test/test.cpp =================================================================== --- trunk/OpenMPT/mptrack/test/test.cpp 2012-03-25 00:07:09 UTC (rev 1230) +++ trunk/OpenMPT/mptrack/test/test.cpp 2012-03-27 21:11:51 UTC (rev 1231) @@ -870,11 +870,15 @@ #define ReadTest(mode, dst, src, expectedResult) \ StringFixer::ReadString<StringFixer::##mode>(dst, src); \ - VERIFY_EQUAL_NONCONT(strncmp(dst, expectedResult, CountOf(dst)), 0); + VERIFY_EQUAL_NONCONT(strncmp(dst, expectedResult, CountOf(dst)), 0); /* Ensure that the strings are identical */ \ + for(size_t i = strlen(dst); i < CountOf(dst); i++) \ + VERIFY_EQUAL_NONCONT(dst[i], '\0'); /* Ensure that rest of the buffer is completely nulled */ #define WriteTest(mode, dst, src, expectedResult) \ StringFixer::WriteString<StringFixer::##mode>(dst, src); \ - VERIFY_EQUAL_NONCONT(strncmp(dst, expectedResult, CountOf(dst)), 0); + VERIFY_EQUAL_NONCONT(strncmp(dst, expectedResult, CountOf(dst)), 0); /* Ensure that the strings are identical */ \ + for(size_t i = strlen(dst); i < CountOf(dst); i++) \ + VERIFY_EQUAL_NONCONT(dst[i], '\0'); /* Ensure that rest of the buffer is completely nulled */ // Check reading of null-terminated string into larger buffer ReadTest(nullTerminated, dst1, src1, "X "); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2012-03-31 23:34:47
|
Revision: 1236 http://modplug.svn.sourceforge.net/modplug/?rev=1236&view=rev Author: saga-games Date: 2012-03-31 23:34:40 +0000 (Sat, 31 Mar 2012) Log Message: ----------- [Ref] Moved Pattern Clipboard object from CModDoc to CViewPattern. It's now a static as it wouldn't make much sense to have multiple pattern clipboards for each module. [Mod] Pattern Editor: If no pattern data was found in the clipboard, the previously copied pattern data is now regained from the internal clipboard. [Mod] OpenMPT: Version is now 1.20.00.82 Modified Paths: -------------- trunk/OpenMPT/mptrack/Ctrl_pat.h trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/Moddoc.h trunk/OpenMPT/mptrack/PatternClipboard.cpp trunk/OpenMPT/mptrack/PatternClipboard.h trunk/OpenMPT/mptrack/PatternEditorDialogs.h trunk/OpenMPT/mptrack/View_pat.cpp trunk/OpenMPT/mptrack/View_pat.h Modified: trunk/OpenMPT/mptrack/Ctrl_pat.h =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_pat.h 2012-03-31 23:06:04 UTC (rev 1235) +++ trunk/OpenMPT/mptrack/Ctrl_pat.h 2012-03-31 23:34:40 UTC (rev 1236) @@ -12,6 +12,7 @@ #pragma once #include "globals.h" +#include "PatternCursor.h" class COrderList; class CCtrlPatterns; Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2012-03-31 23:06:04 UTC (rev 1235) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2012-03-31 23:34:40 UTC (rev 1236) @@ -118,8 +118,8 @@ ///////////////////////////////////////////////////////////////////////////// // CModDoc construction/destruction -CModDoc::CModDoc() : patternClipboard(m_SndFile) -//---------------------------------------------- +CModDoc::CModDoc() +//---------------- { m_bHasValidPath = false; m_bPaused = TRUE; Modified: trunk/OpenMPT/mptrack/Moddoc.h =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.h 2012-03-31 23:06:04 UTC (rev 1235) +++ trunk/OpenMPT/mptrack/Moddoc.h 2012-03-31 23:34:40 UTC (rev 1236) @@ -17,7 +17,6 @@ #include "sndfile.h" #include "../common/misc_util.h" #include "Undo.h" -#include "PatternClipboard.h" #include <time.h> @@ -96,17 +95,6 @@ STATIC_ASSERT( ((-1 << HINT_SHIFT_SEQUENCE) & HINT_MASK_ITEM) == (-1 << HINT_SHIFT_SEQUENCE) ); -// pattern paste modes -enum enmPatternPasteModes -{ - pm_overwrite = 0, - pm_mixpaste, - pm_mixpaste_it, - pm_pasteflood, - pm_pushforwardpaste, -}; - - ///////////////////////////////////////////////////////////////////////// // File edit history @@ -127,8 +115,6 @@ #define SPLIT_OCTAVE_RANGE 9 -class PatternClipboard; - //========================== struct SplitKeyboardSettings //========================== @@ -186,8 +172,6 @@ vector<FileHistory> m_FileHistory; // File edit history time_t m_creationTime; - PatternClipboard patternClipboard; - public: std::bitset<MAX_INSTRUMENTS> m_bsInstrumentModified; // which instruments have been modified? (for ITP functionality) @@ -236,8 +220,6 @@ vector<FileHistory> &GetFileHistory() { return m_FileHistory; } const vector<FileHistory> &GetFileHistory() const { return m_FileHistory; } time_t GetCreationTime() const { return m_creationTime; } - - PatternClipboard &GetPatternClipboard() { return patternClipboard; } // operations public: Modified: trunk/OpenMPT/mptrack/PatternClipboard.cpp =================================================================== --- trunk/OpenMPT/mptrack/PatternClipboard.cpp 2012-03-31 23:06:04 UTC (rev 1235) +++ trunk/OpenMPT/mptrack/PatternClipboard.cpp 2012-03-31 23:34:40 UTC (rev 1236) @@ -13,7 +13,8 @@ #include "Mainfrm.h" #include "Moddoc.h" -size_t PatternClipboard::clipboardSize = 0; +// Currently just one slot for fall-back pasting. +PatternClipboard::clipindex_t PatternClipboard::clipboardSize = 1; // Clipboard format: @@ -23,8 +24,6 @@ // Empty: '| ' // End of row: '\n' -static LPCSTR lpszClipboardPatternHdr = "ModPlug Tracker %3s\r\n"; - CString PatternClipboard::GetFileExtension(const char *ext) const //--------------------------------------------------------------- { @@ -43,8 +42,8 @@ // Copy a pattern selection to both the system clipboard and the internal clipboard. -bool PatternClipboard::Copy(PATTERNINDEX pattern, PatternRect selection) -//---------------------------------------------------------------------- +bool PatternClipboard::Copy(CSoundFile &sndFile, PATTERNINDEX pattern, PatternRect selection) +//------------------------------------------------------------------------------------------- { if(!sndFile.Patterns.IsValidPat(pattern)) { @@ -202,34 +201,34 @@ // Try pasting a pattern selection from the system clipboard. -bool PatternClipboard::Paste(PATTERNINDEX pattern, const PatternCursor &pastePos, PasteModes mode) -//------------------------------------------------------------------------------------------------ +bool PatternClipboard::Paste(CSoundFile &sndFile, PATTERNINDEX pattern, const PatternCursor &pastePos, PasteModes mode) +//--------------------------------------------------------------------------------------------------------------------- { CString data; - if(!FromSystemClipboard(data)) + if(!FromSystemClipboard(data) || !HandlePaste(sndFile, pattern, pastePos, mode, data)) { - return false; + // Fall back to internal clipboard if there's no valid pattern data in the system clipboard. + return Paste(sndFile, pattern, pastePos, mode, 0); } - - return HandlePaste(pattern, pastePos, mode, data); + return true; } // Try pasting a pattern selection from an internal clipboard. -bool PatternClipboard::Paste(PATTERNINDEX pattern, const PatternCursor &pastePos, PasteModes mode, size_t internalClipboard) -//-------------------------------------------------------------------------------------------------------------------------- +bool PatternClipboard::Paste(CSoundFile &sndFile, PATTERNINDEX pattern, const PatternCursor &pastePos, PasteModes mode, clipindex_t internalClipboard) +//---------------------------------------------------------------------------------------------------------------------------------------------------- { if(internalClipboard >= clipboards.size()) { return false; } - return HandlePaste(pattern, pastePos, mode, clipboards[internalClipboard].content); + return HandlePaste(sndFile, pattern, pastePos, mode, clipboards[internalClipboard].content); } // Perform the pasting operation. -bool PatternClipboard::HandlePaste(PATTERNINDEX pattern, const PatternCursor &pastePos, PasteModes mode, const CString &data) -//--------------------------------------------------------------------------------------------------------------------------- +bool PatternClipboard::HandlePaste(CSoundFile &sndFile, PATTERNINDEX pattern, const PatternCursor &pastePos, PasteModes mode, const CString &data) +//------------------------------------------------------------------------------------------------------------------------------------------------ { if(!sndFile.Patterns.IsValidPat(pattern) || sndFile.GetpModDoc() == nullptr) { @@ -349,7 +348,7 @@ const ModCommand origModCmd = m[col]; // push channel data below paste point first. - if(mode == pm_pushforwardpaste) + if(mode == pmPushForward) { for(ROWINDEX nPushRow = sndFile.Patterns[pattern].GetNumRows() - 1 - curRow; nPushRow > 0; nPushRow--) { @@ -551,8 +550,8 @@ // Copy one of the internal clipboards to the system clipboard. -bool PatternClipboard::SelectClipboard(size_t which) -//-------------------------------------------------- +bool PatternClipboard::SelectClipboard(clipindex_t which) +//------------------------------------------------------- { activeClipboard = which; return ToSystemClipboard(clipboards[activeClipboard]); @@ -589,8 +588,8 @@ // Set the maximum number of internal clipboards. -void PatternClipboard::SetClipboardSize(size_t maxEntries) -//-------------------------------------------------------- +void PatternClipboard::SetClipboardSize(clipindex_t maxEntries) +//------------------------------------------------------------- { clipboardSize = maxEntries; RestrictClipboardSize(); Modified: trunk/OpenMPT/mptrack/PatternClipboard.h =================================================================== --- trunk/OpenMPT/mptrack/PatternClipboard.h 2012-03-31 23:06:04 UTC (rev 1235) +++ trunk/OpenMPT/mptrack/PatternClipboard.h 2012-03-31 23:34:40 UTC (rev 1236) @@ -44,34 +44,38 @@ pmPushForward, }; + // Clipboard index type + typedef size_t clipindex_t; + protected: - CSoundFile &sndFile; - - static size_t clipboardSize; - size_t activeClipboard; + // Maximum number of internal clipboard entries + static clipindex_t clipboardSize; + // Active internal clipboard index + clipindex_t activeClipboard; + // Internal clipboard collection std::deque<PatternClipboardElement> clipboards; public: - PatternClipboard(CSoundFile &owner) : sndFile(owner), activeClipboard(0) { }; + PatternClipboard() : activeClipboard(0) { }; // Copy a pattern selection to both the system clipboard and the internal clipboard. - bool Copy(PATTERNINDEX pattern, PatternRect selection); + bool Copy(CSoundFile &sndFile, PATTERNINDEX pattern, PatternRect selection); // Try pasting a pattern selection from the system clipboard. - bool Paste(PATTERNINDEX pattern, const PatternCursor &pastePos, PasteModes mode); + bool Paste(CSoundFile &sndFile, PATTERNINDEX pattern, const PatternCursor &pastePos, PasteModes mode); // Try pasting a pattern selection from an internal clipboard. - bool Paste(PATTERNINDEX pattern, const PatternCursor &pastePos, PasteModes mode, size_t internalClipboard); + bool Paste(CSoundFile &sndFile, PATTERNINDEX pattern, const PatternCursor &pastePos, PasteModes mode, clipindex_t internalClipboard); // Copy one of the internal clipboards to the system clipboard. - bool SelectClipboard(size_t which); + bool SelectClipboard(clipindex_t which); // Switch to the next internal clipboard. bool CycleForward(); // Switch to the previous internal clipboard. bool CycleBackward(); // Set the maximum number of internal clipboards. - void SetClipboardSize(size_t maxEntries); + void SetClipboardSize(clipindex_t maxEntries); // Return the current number of clipboards. - size_t GetClipboardSize() const { return clipboards.size(); }; + clipindex_t GetClipboardSize() const { return clipboards.size(); }; // Remove all clipboard contents. void Clear(); @@ -79,7 +83,7 @@ CString GetFileExtension(const char *ext) const; // Perform the pasting operation. - bool HandlePaste(PATTERNINDEX pattern, const PatternCursor &pastePos, PasteModes mode, const CString &data); + bool HandlePaste(CSoundFile &sndFile, PATTERNINDEX pattern, const PatternCursor &pastePos, PasteModes mode, const CString &data); // Keep the number of clipboards consistent with the maximum number of allowed clipboards. void RestrictClipboardSize(); Modified: trunk/OpenMPT/mptrack/PatternEditorDialogs.h =================================================================== --- trunk/OpenMPT/mptrack/PatternEditorDialogs.h 2012-03-31 23:06:04 UTC (rev 1235) +++ trunk/OpenMPT/mptrack/PatternEditorDialogs.h 2012-03-31 23:34:40 UTC (rev 1236) @@ -13,6 +13,7 @@ #include "dlg_misc.h" // for keyboard control #include "Moddoc.h" // for SplitKeyboardSettings #include "EffectInfo.h" +#include "PatternCursor.h" ///////////////////////////////////////////////////////////////////////// Modified: trunk/OpenMPT/mptrack/View_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_pat.cpp 2012-03-31 23:06:04 UTC (rev 1235) +++ trunk/OpenMPT/mptrack/View_pat.cpp 2012-03-31 23:34:40 UTC (rev 1236) @@ -45,7 +45,9 @@ PatternRect() }; +// Static initializers ModCommand CViewPattern::m_cmdOld = ModCommand::Empty(); +PatternClipboard CViewPattern::patternClipboard; IMPLEMENT_SERIAL(CViewPattern, CModScrollView, 0) @@ -6214,7 +6216,7 @@ //--------------------------------------------------------------------------------- { BeginWaitCursor(); - bool result = GetDocument()->GetPatternClipboard().Copy(nPattern, selection); + bool result = GetPatternClipboard().Copy(*GetSoundFile(), nPattern, selection); EndWaitCursor(); return result; } @@ -6225,7 +6227,7 @@ //---------------------------------------------------------------------------------------------------------------------- { BeginWaitCursor(); - bool result = GetDocument()->GetPatternClipboard().Paste(nPattern, pastePos, mode); + bool result = GetPatternClipboard().Paste(*GetSoundFile(), nPattern, pastePos, mode); EndWaitCursor(); if(result) Modified: trunk/OpenMPT/mptrack/View_pat.h =================================================================== --- trunk/OpenMPT/mptrack/View_pat.h 2012-03-31 23:06:04 UTC (rev 1235) +++ trunk/OpenMPT/mptrack/View_pat.h 2012-03-31 23:34:40 UTC (rev 1236) @@ -161,6 +161,9 @@ static ModCommand m_cmdOld; // Quick cursor copy/paste data static FindReplaceStruct m_findReplace; // Find/replace data + // Internal pattern clipboard + static PatternClipboard patternClipboard; + // -> CODE#0012 // -> DESC="midi keyboard split" BYTE activeNoteChannel[NOTE_MAX + 1]; @@ -182,6 +185,8 @@ void SetModified(bool updateAllViews = true); + static PatternClipboard &GetPatternClipboard() { return patternClipboard; } + bool UpdateSizes(); void UpdateScrollSize(); void UpdateScrollPos(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2012-04-01 19:26:44
|
Revision: 1239 http://modplug.svn.sourceforge.net/modplug/?rev=1239&view=rev Author: saga-games Date: 2012-04-01 19:26:38 +0000 (Sun, 01 Apr 2012) Log Message: ----------- Well, this didn't compile. Modified Paths: -------------- trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/Vstplug.cpp Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2012-04-01 19:25:00 UTC (rev 1238) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2012-04-01 19:26:38 UTC (rev 1239) @@ -2248,8 +2248,8 @@ TCHAR s[_MAX_PATH], tmp[32]; VSTPluginLib *pPlug; - PLUGINDEX pPlug = m_pPluginManager->GetFirstPlugin(); - iPlug = 0; + pPlug = m_pPluginManager->GetFirstPlugin(); + PLUGINDEX iPlug = 0; while (pPlug) { if (pPlug->dwPluginId1 != kDmoMagic) Modified: trunk/OpenMPT/mptrack/Vstplug.cpp =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.cpp 2012-04-01 19:25:00 UTC (rev 1238) +++ trunk/OpenMPT/mptrack/Vstplug.cpp 2012-04-01 19:26:38 UTC (rev 1239) @@ -1703,8 +1703,8 @@ } -long CVstPlugin::GetCurrentProgram() -//---------------------------------- +VstInt32 CVstPlugin::GetCurrentProgram() +//-------------------------------------- { if ((m_pEffect) && (m_pEffect->numPrograms > 0)) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2012-04-02 18:17:07
|
Revision: 1241 http://modplug.svn.sourceforge.net/modplug/?rev=1241&view=rev Author: saga-games Date: 2012-04-02 18:17:00 +0000 (Mon, 02 Apr 2012) Log Message: ----------- [Mod] Instrument Editor: Made sample number cleaning also happen when switching pluginsm not only loading new ones. [Mod] OpenMPT: Version is now 1.20.00.83 Modified Paths: -------------- trunk/OpenMPT/mptrack/Ctrl_ins.cpp trunk/OpenMPT/mptrack/version.h Modified: trunk/OpenMPT/mptrack/Ctrl_ins.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2012-04-02 17:59:09 UTC (rev 1240) +++ trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2012-04-02 18:17:00 UTC (rev 1241) @@ -2169,42 +2169,42 @@ } UpdatePluginList(); - if(plugin.pMixPlugin != nullptr && plugin.pMixPlugin->isInstrument()) - { - // If we just added an instrument plugin, zap the sample assignments. - const std::set<SAMPLEINDEX> referencedSamples = pIns->GetSamples(); - bool hasSamples = false; - for(std::set<SAMPLEINDEX>::const_iterator sample = referencedSamples.begin(); sample != referencedSamples.end(); sample++) - { - if(*sample > 0 && *sample <= m_pSndFile->GetNumSamples() && m_pSndFile->GetSample(*sample).pSample != nullptr) - { - hasSamples = true; - break; - } - } - - if(!hasSamples || Reporting::Confirm("Remove sample associations of this instrument?") == cnfYes) - { - pIns->AssignSample(0); - m_NoteMap.Invalidate(); - } - } - m_pModDoc->UpdateAllViews(NULL, HINT_MIXPLUGINS, NULL); } #endif // NO_VST } - if(plugin.pMixPlugin) + if(plugin.pMixPlugin != nullptr) { ::EnableWindow(::GetDlgItem(m_hWnd, IDC_INSVIEWPLG), true); - // if this plug can recieve MIDI events and we have no MIDI channel - // selected for this instrument, automatically select MIDI channel 1. - if(plugin.pMixPlugin->isInstrument() && pIns->nMidiChannel == 0) + if(!IsLocked() && plugin.pMixPlugin->isInstrument()) { - pIns->nMidiChannel = 1; - UpdateView((m_nInstrument << HINT_SHIFT_INS) | HINT_INSTRUMENT, NULL); + if(pIns->nMidiChannel == MidiNoChannel) + { + // If this plugin can recieve MIDI events and we have no MIDI channel + // selected for this instrument, automatically select MIDI channel 1. + pIns->nMidiChannel = MidiFirstChannel; + UpdateView((m_nInstrument << HINT_SHIFT_INS) | HINT_INSTRUMENT, NULL); + } + + // If we just dialled up an instrument plugin, zap the sample assignments. + const std::set<SAMPLEINDEX> referencedSamples = pIns->GetSamples(); + bool hasSamples = false; + for(std::set<SAMPLEINDEX>::const_iterator sample = referencedSamples.begin(); sample != referencedSamples.end(); sample++) + { + if(*sample > 0 && *sample <= m_pSndFile->GetNumSamples() && m_pSndFile->GetSample(*sample).pSample != nullptr) + { + hasSamples = true; + break; + } + } + + if(!hasSamples || Reporting::Confirm("Remove sample associations of this instrument?") == cnfYes) + { + pIns->AssignSample(0); + m_NoteMap.Invalidate(); + } } return; } Modified: trunk/OpenMPT/mptrack/version.h =================================================================== --- trunk/OpenMPT/mptrack/version.h 2012-04-02 17:59:09 UTC (rev 1240) +++ trunk/OpenMPT/mptrack/version.h 2012-04-02 18:17:00 UTC (rev 1241) @@ -19,7 +19,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 20 #define VER_MINOR 00 -#define VER_MINORMINOR 82 +#define VER_MINORMINOR 83 //Creates version number from version parts that appears in version string. //For example MAKE_VERSION_NUMERIC(1,17,02,28) gives version number of This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2012-04-03 13:54:51
|
Revision: 1242 http://modplug.svn.sourceforge.net/modplug/?rev=1242&view=rev Author: saga-games Date: 2012-04-03 13:54:41 +0000 (Tue, 03 Apr 2012) Log Message: ----------- [Fix] Pattern Editor: When duplicating a pattern sequence that starts with an invalid pattern (+++ or ---), the pattern view didn't update properly so editing was still taking place in the old pattern (confusing!) [Fix] That one check in the sample editor was actually necessary... Modified Paths: -------------- trunk/OpenMPT/mptrack/Ctrl_pat.cpp trunk/OpenMPT/mptrack/Ctrl_smp.cpp Modified: trunk/OpenMPT/mptrack/Ctrl_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_pat.cpp 2012-04-02 18:17:00 UTC (rev 1241) +++ trunk/OpenMPT/mptrack/Ctrl_pat.cpp 2012-04-03 13:54:41 UTC (rev 1242) @@ -903,7 +903,15 @@ { m_OrderList.InvalidateRect(NULL, FALSE); m_OrderList.SetCurSel(nInsertWhere); - SetCurrentPattern(pSndFile->Order[min(nInsertWhere, pSndFile->Order.GetLastIndex())]); + + // If the first duplicated order is f.e. a +++ item, we need to move the pattern display on or else we'll still edit the previously shown pattern. + ORDERINDEX showPattern = min(nInsertWhere, pSndFile->Order.GetLastIndex()); + while(!pSndFile->Patterns.IsValidPat(pSndFile->Order[showPattern]) && showPattern < pSndFile->Order.GetLastIndex()) + { + showPattern++; + } + SetCurrentPattern(pSndFile->Order[showPattern]); + m_pModDoc->SetModified(); m_pModDoc->UpdateAllViews(NULL, HINT_MODSEQUENCE | HINT_PATNAMES, this); if(selection.nOrdHi != selection.nOrdLo) m_OrderList.m_nScrollPos2nd = nInsertWhere + nInsertCount; Modified: trunk/OpenMPT/mptrack/Ctrl_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2012-04-02 18:17:00 UTC (rev 1241) +++ trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2012-04-03 13:54:41 UTC (rev 1242) @@ -976,7 +976,7 @@ } m_pModDoc->UpdateAllViews(NULL, (smp << HINT_SHIFT_SMP) | HINT_SAMPLEINFO | HINT_SAMPLEDATA | HINT_SMPNAMES); - if(m_pModDoc->FindSampleParent(smp) == INSTRUMENTINDEX_INVALID) + if(m_pModDoc->GetNumInstruments() > 0 && m_pModDoc->FindSampleParent(smp) == INSTRUMENTINDEX_INVALID) { if(Reporting::Confirm("This sample is not used by any instrument. Do you want to create a new instrument using this sample?") == cnfYes) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2012-04-20 18:05:47
|
Revision: 1249 http://modplug.svn.sourceforge.net/modplug/?rev=1249&view=rev Author: saga-games Date: 2012-04-20 18:05:37 +0000 (Fri, 20 Apr 2012) Log Message: ----------- [Fix] Pattern Editor: When entering an octave, the triggered note was not stopped on key-up (http://forum.openmpt.org/index.php?topic=4718.0) - probably since the early OpenMPT 1.17 days. [Fix] Pattern Editor: The shortcut for setting row spacing to 9 didn't work. [Fix] Pattern Editor: Fixed potentially wrong pattern undo buffers. [Mod] OpenMPT: Version is now 1.20.00.85 Modified Paths: -------------- trunk/OpenMPT/mptrack/CommandSet.cpp trunk/OpenMPT/mptrack/CommandSet.h trunk/OpenMPT/mptrack/View_pat.cpp trunk/OpenMPT/mptrack/View_pat.h trunk/OpenMPT/mptrack/version.h Modified: trunk/OpenMPT/mptrack/CommandSet.cpp =================================================================== --- trunk/OpenMPT/mptrack/CommandSet.cpp 2012-04-18 22:26:00 UTC (rev 1248) +++ trunk/OpenMPT/mptrack/CommandSet.cpp 2012-04-20 18:05:37 UTC (rev 1249) @@ -617,6 +617,16 @@ DefineKeyCommand(kcDecreaseSpacing, 1862, _T("Decrease Row Spacing")); DefineKeyCommand(kcSampleAutotune, 1863, _T("Tune Sample to given Note")); DefineKeyCommand(kcFileCloseAll, 1864, _T("File/Close All")); + DefineKeyCommand(kcSetOctaveStop0, 1865, _T(""), kcHidden); + DefineKeyCommand(kcSetOctaveStop1, 1866, _T(""), kcHidden); + DefineKeyCommand(kcSetOctaveStop2, 1867, _T(""), kcHidden); + DefineKeyCommand(kcSetOctaveStop3, 1868, _T(""), kcHidden); + DefineKeyCommand(kcSetOctaveStop4, 1869, _T(""), kcHidden); + DefineKeyCommand(kcSetOctaveStop5, 1870, _T(""), kcHidden); + DefineKeyCommand(kcSetOctaveStop6, 1871, _T(""), kcHidden); + DefineKeyCommand(kcSetOctaveStop7, 1872, _T(""), kcHidden); + DefineKeyCommand(kcSetOctaveStop8, 1873, _T(""), kcHidden); + DefineKeyCommand(kcSetOctaveStop9, 1874, _T(""), kcHidden); // Add new key commands here. #ifdef _DEBUG @@ -1109,6 +1119,22 @@ Remove(newKc, (CommandID)(kcVPStartChordStops+noteOffset)); } } + if(inCmd >= kcSetOctave0 && inCmd <= kcSetOctave9) + { + int noteOffset = inCmd - kcSetOctave0; + newKc=inKc; + newKc.event=kKeyEventUp; + if (adding) + { + Log("Enforcing rule krNoteOffOnKeyRelease: adding Chord off command\n"); + Add(newKc, (CommandID)(kcSetOctaveStop0+noteOffset), false); + } + else + { + Log("Enforcing rule krNoteOffOnKeyRelease: removing Chord off command\n"); + Remove(newKc, (CommandID)(kcSetOctaveStop0+noteOffset)); + } + } } //# Reassign freed number keys to octaves @@ -1119,10 +1145,10 @@ ( ('0'<=inKc.code && inKc.code<='9') || (VK_NUMPAD0<=inKc.code && inKc.code<=VK_NUMPAD9) ) ) { //is number key newKc.ctx=kCtxViewPatternsNote; newKc.mod=0; - newKc.event= (KeyEventType)1; + newKc.event= kKeyEventDown; newKc.code=inKc.code; int offset = ('0'<=inKc.code && inKc.code<='9') ? newKc.code-'0' : newKc.code-VK_NUMPAD0; - Add(newKc, (CommandID)(kcSetOctave0 + (newKc.code-offset)), false); + Add(newKc, (CommandID)(kcSetOctave0 + (newKc.code-offset)), false); } } // Add spacing @@ -1135,12 +1161,12 @@ newKc.event= kKeyEventDown; for (newKc.code='0'; newKc.code<='9'; newKc.code++) { - Add(newKc, (CommandID)(kcSetSpacing0 + (newKc.code-'0')), false); + Add(newKc, (CommandID)(kcSetSpacing0 + (newKc.code-'0')), false); } for (newKc.code=VK_NUMPAD0; newKc.code<=VK_NUMPAD9; newKc.code++) { - Add(newKc, (CommandID)(kcSetSpacing0 + (newKc.code-VK_NUMPAD0)), false); - } + Add(newKc, (CommandID)(kcSetSpacing0 + (newKc.code-VK_NUMPAD0)), false); + } } else if (!adding && (inCmd<kcSetSpacing && kcSetSpacing9<inCmd)) { Modified: trunk/OpenMPT/mptrack/CommandSet.h =================================================================== --- trunk/OpenMPT/mptrack/CommandSet.h 2012-04-18 22:26:00 UTC (rev 1248) +++ trunk/OpenMPT/mptrack/CommandSet.h 2012-04-20 18:05:37 UTC (rev 1249) @@ -136,7 +136,7 @@ kcNextOctave, kcPrevOrder, kcNextOrder, - kcEndMisc=kcNextOrder, + kcEndMisc=kcNextOrder, kcGlobalEnd=kcNextOrder, //Pattern Navigation @@ -450,6 +450,18 @@ kcSetOctave8, kcSetOctave9, + // Release set octave key + kcSetOctaveStop0, + kcSetOctaveStop1, + kcSetOctaveStop2, + kcSetOctaveStop3, + kcSetOctaveStop4, + kcSetOctaveStop5, + kcSetOctaveStop6, + kcSetOctaveStop7, + kcSetOctaveStop8, + kcSetOctaveStop9, + //Note Misc kcStartNoteMisc, kcChordModifier=kcStartNoteMisc, Modified: trunk/OpenMPT/mptrack/View_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_pat.cpp 2012-04-18 22:26:00 UTC (rev 1248) +++ trunk/OpenMPT/mptrack/View_pat.cpp 2012-04-20 18:05:37 UTC (rev 1249) @@ -160,6 +160,8 @@ m_Dib.Init(CMainFrame::bmpNotes); UpdateColors(); m_PCNoteEditMemory = ModCommand::Empty(); + + octaveKeyMemory.resize(10, NOTE_NONE); } @@ -2464,7 +2466,7 @@ return; } - const ModCommand *m = pSndFile->Patterns[m_nPattern].GetpModCommand(GetCurrentRow(), GetCurrentChannel()); + const ModCommand *m = GetCursorCommand(); switch(m_Cursor.GetColumnType()) { case PatternCursor::noteColumn: @@ -2492,18 +2494,16 @@ void CViewPattern::OnCursorPaste() //-------------------------------- { - CSoundFile *pSndFile = GetSoundFile(); - if(pSndFile == nullptr || !pSndFile->Patterns.IsValidPat(m_nPattern) || !IsEditingEnabled_bmsg()) + ModCommand *p = GetCursorCommand(); + if(p == nullptr || !IsEditingEnabled_bmsg()) { return; } - PrepareUndo(m_Selection); - CHANNELINDEX nChn = GetCurrentChannel(); - PatternCursor::Columns nCursor = m_Cursor.GetColumnType(); - ModCommand *p = pSndFile->Patterns[m_nPattern].GetpModCommand(GetCurrentRow(), nChn); + PrepareUndo(m_Cursor, m_Cursor); + PatternCursor::Columns column = m_Cursor.GetColumnType(); - switch(nCursor) + switch(column) { case PatternCursor::noteColumn: p->note = m_cmdOld.note; @@ -2526,7 +2526,7 @@ SetModified(false); - if(pSndFile->IsPaused() || !(m_dwStatus & psFollowSong) || (CMainFrame::GetMainFrame() && CMainFrame::GetMainFrame()->GetFollowSong(GetDocument()) != m_hWnd)) + if(GetSoundFile()->IsPaused() || !(m_dwStatus & psFollowSong) || (CMainFrame::GetMainFrame() && CMainFrame::GetMainFrame()->GetFollowSong(GetDocument()) != m_hWnd)) { InvalidateCell(m_Cursor); SetCurrentRow(GetCurrentRow() + m_nSpacing); @@ -2801,18 +2801,18 @@ PrepareUndo(m_Selection); - for (UINT row=startRow; row <= endRow; row++) + for(ROWINDEX row = startRow; row <= endRow; row++) { - ModCommand *m = pSndFile->Patterns[m_nPattern].GetpModCommand(row, 0); - for (UINT col = startChan; col <= endChan; col++) + PatternRow m = pSndFile->Patterns[m_nPattern].GetRow(row); + for(CHANNELINDEX chn = startChan; chn <= endChan; chn++) { - if (m[col].IsNote()) + if (m[chn].IsNote()) { - int note = m[col].note; + int note = m[chn].note; note += transp; if (note < noteMin) note = noteMin; if (note > noteMax) note = noteMax; - m[col].note = (BYTE)note; + m[chn].note = (BYTE)note; } } } @@ -3171,27 +3171,27 @@ // Volume memory for each channel. vector<BYTE> chvol(lastChannel + 1, 64); - for (ROWINDEX nRow = firstRow; nRow <= lastRow; nRow++) + for(ROWINDEX nRow = firstRow; nRow <= lastRow; nRow++) { ModCommand *m = pSndFile->Patterns[m_nPattern].GetpModCommand(nRow, firstChannel); - for (CHANNELINDEX nChn = firstChannel; nChn <= lastChannel; nChn++, m++) + for(CHANNELINDEX nChn = firstChannel; nChn <= lastChannel; nChn++, m++) { - if ((m->command == CMD_VOLUME) && (m->param <= 64)) + if((m->command == CMD_VOLUME) && (m->param <= 64)) { chvol[nChn] = m->param; break; } - if (m->volcmd == VOLCMD_VOLUME) + if(m->volcmd == VOLCMD_VOLUME) { chvol[nChn] = m->vol; break; } - if ((m->note) && (m->note <= NOTE_MAX) && (m->instr)) + if(m->IsNote() && m->instr != 0) { UINT nSmp = m->instr; - if (pSndFile->GetNumInstruments()) + if(pSndFile->GetNumInstruments()) { - if ((nSmp <= pSndFile->GetNumInstruments()) && (pSndFile->Instruments[nSmp])) + if((nSmp <= pSndFile->GetNumInstruments()) && (pSndFile->Instruments[nSmp])) { nSmp = pSndFile->Instruments[nSmp]->Keyboard[m->note]; if(!nSmp) chvol[nChn] = 64; // hack for instruments without samples @@ -3200,12 +3200,11 @@ nSmp = 0; } } - if ((nSmp) && (nSmp <= pSndFile->GetNumSamples())) + if((nSmp) && (nSmp <= pSndFile->GetNumSamples())) { chvol[nChn] = (BYTE)(pSndFile->GetSample(nSmp).nVolume / 4); break; - } - else + } else { //nonexistant sample and no volume present in patten? assume volume=64. if(useVolCol) { @@ -3223,18 +3222,18 @@ } } - for (ROWINDEX nRow = firstRow; nRow <= lastRow; nRow++) + for(ROWINDEX nRow = firstRow; nRow <= lastRow; nRow++) { ModCommand *m = pSndFile->Patterns[m_nPattern].GetpModCommand(nRow, firstChannel); const int cy = lastRow - firstRow + 1; // total rows (for fading) - for (CHANNELINDEX nChn = firstChannel; nChn <= lastChannel; nChn++, m++) + for(CHANNELINDEX nChn = firstChannel; nChn <= lastChannel; nChn++, m++) { - if ((!m->volcmd) && (m->command != CMD_VOLUME) - && (m->note) && (m->note <= NOTE_MAX) && (m->instr)) + if(!m->volcmd == VOLCMD_NONE && m->command != CMD_VOLUME + && m->IsNote() && m->instr) { UINT nSmp = m->instr; bool overrideSampleVol = false; - if (pSndFile->m_nInstruments) + if(pSndFile->GetNumInstruments()) { if ((nSmp <= pSndFile->m_nInstruments) && (pSndFile->Instruments[nSmp])) { @@ -3250,7 +3249,7 @@ nSmp = 0; } } - if ((nSmp) && (nSmp <= pSndFile->m_nSamples)) + if((nSmp) && (nSmp <= pSndFile->GetNumSamples())) { if(useVolCol) { @@ -3264,9 +3263,9 @@ } } - if (m->volcmd == VOLCMD_VOLUME) chvol[nChn] = (BYTE)m->vol; + if(m->volcmd == VOLCMD_VOLUME) chvol[nChn] = (BYTE)m->vol; - if (((dlg.m_bFadeIn) || (dlg.m_bFadeOut)) && m->command != CMD_VOLUME && !m->volcmd == VOLCMD_NONE) + if((dlg.m_bFadeIn || dlg.m_bFadeOut) && m->command != CMD_VOLUME && m->volcmd == VOLCMD_NONE) { if(useVolCol) { @@ -3504,7 +3503,20 @@ } -ModCommand* CViewPattern::GetModCommand(CSoundFile& rSf, const ModCommandPos& pos) +// Get ModCommand at the pattern cursor position. +ModCommand *CViewPattern ::GetCursorCommand() +//------------------------------------------- +{ + CSoundFile *pSndFile = GetSoundFile(); + if(pSndFile != nullptr && pSndFile->Patterns.IsValidPat(GetCurrentPattern())) + { + return pSndFile->Patterns[GetCurrentPattern()].GetpModCommand(GetCurrentRow(), GetCurrentChannel()); + } + return nullptr; +} + + +ModCommand *CViewPattern::GetModCommand(CSoundFile& rSf, const ModCommandPos& pos) //-------------------------------------------------------------------------------- { static ModCommand m; @@ -4115,66 +4127,75 @@ } //Ranges: - if (wParam>=kcVPStartNotes && wParam<=kcVPEndNotes) + if(wParam >= kcVPStartNotes && wParam <= kcVPEndNotes) { - TempEnterNote(wParam-kcVPStartNotes+1+pMainFrm->GetBaseOctave()*12); + TempEnterNote(wParam - kcVPStartNotes + 1 + pMainFrm->GetBaseOctave() * 12); return wParam; } - if (wParam>=kcVPStartChords && wParam<=kcVPEndChords) + if(wParam >= kcVPStartChords && wParam <= kcVPEndChords) { - TempEnterChord(wParam-kcVPStartChords+1+pMainFrm->GetBaseOctave()*12); + TempEnterChord(wParam - kcVPStartChords + 1 + pMainFrm->GetBaseOctave() * 12); return wParam; } - if (wParam>=kcVPStartNoteStops && wParam<=kcVPEndNoteStops) + if(wParam >= kcVPStartNoteStops && wParam <= kcVPEndNoteStops) { - TempStopNote(wParam-kcVPStartNoteStops+1+pMainFrm->GetBaseOctave()*12); + TempStopNote(wParam - kcVPStartNoteStops + 1 + pMainFrm->GetBaseOctave() * 12); return wParam; } - if (wParam>=kcVPStartChordStops && wParam<=kcVPEndChordStops) + if(wParam >= kcVPStartChordStops && wParam <= kcVPEndChordStops) { - TempStopChord(wParam-kcVPStartChordStops+1+pMainFrm->GetBaseOctave()*12); + TempStopChord(wParam - kcVPStartChordStops + 1 + pMainFrm->GetBaseOctave() * 12); return wParam; } - if (wParam>=kcSetSpacing0 && wParam<kcSetSpacing9) + if(wParam >= kcSetSpacing0 && wParam <= kcSetSpacing9) { SetSpacing(wParam - kcSetSpacing0); return wParam; } - if (wParam>=kcSetIns0 && wParam<=kcSetIns9) + if(wParam >= kcSetIns0 && wParam <= kcSetIns9) { - if (IsEditingEnabled_bmsg()) - TempEnterIns(wParam-kcSetIns0); + if(IsEditingEnabled_bmsg()) + TempEnterIns(wParam - kcSetIns0); return wParam; } - if (wParam>=kcSetOctave0 && wParam<=kcSetOctave9) + if(wParam >= kcSetOctave0 && wParam <= kcSetOctave9) { - if (IsEditingEnabled()) - TempEnterOctave(wParam-kcSetOctave0); + if(IsEditingEnabled_bmsg()) + TempEnterOctave(wParam - kcSetOctave0); return wParam; } - if (wParam>=kcSetVolumeStart && wParam<=kcSetVolumeEnd) + + if(wParam >= kcSetOctaveStop0 && wParam <= kcSetOctaveStop9) { - if (IsEditingEnabled_bmsg()) - TempEnterVol(wParam-kcSetVolumeStart); + TempStopOctave(wParam - kcSetOctaveStop0); return wParam; } - if (wParam>=kcSetFXStart && wParam<=kcSetFXEnd) + + if(wParam >= kcSetVolumeStart && wParam <= kcSetVolumeEnd) { - if (IsEditingEnabled_bmsg()) - TempEnterFX(wParam-kcSetFXStart+1); + if(IsEditingEnabled_bmsg()) + TempEnterVol(wParam - kcSetVolumeStart); return wParam; } - if (wParam>=kcSetFXParam0 && wParam<=kcSetFXParamF) + + if(wParam >= kcSetFXStart && wParam <= kcSetFXEnd) { - if (IsEditingEnabled_bmsg()) - TempEnterFXparam(wParam-kcSetFXParam0); + if(IsEditingEnabled_bmsg()) + TempEnterFX(wParam - kcSetFXStart + 1); return wParam; } + if(wParam >= kcSetFXParam0 && wParam <= kcSetFXParamF) + { + if(IsEditingEnabled_bmsg()) + TempEnterFXparam(wParam - kcSetFXParam0); + return wParam; + } + return NULL; } @@ -4239,9 +4260,9 @@ return; } - PrepareUndo(m_Selection); + PrepareUndo(m_Cursor, m_Cursor); - ModCommand* pTarget = pSndFile->Patterns[m_nPattern].GetpModCommand(GetCurrentRow(), GetCurrentChannel()); + ModCommand* pTarget = GetCursorCommand(); ModCommand oldcmd = *pTarget; // This is the command we are about to overwrite if(pTarget->IsPcNote()) @@ -4323,10 +4344,10 @@ return; } - ModCommand *pTarget = pSndFile->Patterns[m_nPattern].GetpModCommand(GetCurrentRow(), GetCurrentChannel()); + ModCommand *pTarget = GetCursorCommand(); ModCommand oldcmd = *pTarget; // This is the command we are about to overwrite - PrepareUndo(m_Selection); + PrepareUndo(m_Cursor, m_Cursor); if(pTarget->IsPcNote()) { @@ -4377,10 +4398,10 @@ return; } - ModCommand *pTarget = pSndFile->Patterns[m_nPattern].GetpModCommand(GetCurrentRow(), GetCurrentChannel()); + ModCommand *pTarget = GetCursorCommand(); ModCommand oldcmd = *pTarget; // This is the command we are about to overwrite - PrepareUndo(m_Selection); + PrepareUndo(m_Cursor, m_Cursor); if(pTarget->IsPcNote()) { @@ -4566,16 +4587,31 @@ return; } - PrepareUndo(m_Selection); - - const ModCommand &target = *pSndFile->Patterns[m_nPattern].GetpModCommand(GetCurrentRow(), GetCurrentChannel()); + const ModCommand &target = *GetCursorCommand(); if(target.IsNote()) { - TempEnterNote(((target.note - 1) % 12) + val * 12 + 1); + PrepareUndo(m_Cursor, m_Cursor); + TempEnterNote(((target.note - NOTE_MIN) % 12) + val * 12 + NOTE_MIN); + // Memorize note for key-up + ASSERT(val < octaveKeyMemory.size()); + octaveKeyMemory[val] = target.note; } } +// Stop note that has been triggered by entering an octave in the pattern. +void CViewPattern::TempStopOctave(int val) +//---------------------------------------- +{ + ASSERT(val < octaveKeyMemory.size()); + if(octaveKeyMemory[val] != NOTE_NONE) + { + TempStopNote(octaveKeyMemory[val]); + octaveKeyMemory[val] = NOTE_NONE; + } +} + + // Enter an instrument number in the pattern void CViewPattern::TempEnterIns(int val) //-------------------------------------- @@ -4586,9 +4622,9 @@ return; } - PrepareUndo(m_Selection); + PrepareUndo(m_Cursor, m_Cursor); - ModCommand *pTarget = pSndFile->Patterns[m_nPattern].GetpModCommand(GetCurrentRow(), GetCurrentChannel()); + ModCommand *pTarget = GetCursorCommand(); ModCommand oldcmd = *pTarget; // This is the command we are about to overwrite UINT instr = pTarget->instr, nTotalMax, nTempMax; @@ -5140,7 +5176,7 @@ PrepareUndo(m_Cursor, m_Cursor); - ModCommand *p = pSndFile->Patterns[m_nPattern].GetpModCommand(GetCurrentRow(), GetCurrentChannel()); + ModCommand *p = GetCursorCommand(); ModCommand oldcmd = *p; if(mask.note) Modified: trunk/OpenMPT/mptrack/View_pat.h =================================================================== --- trunk/OpenMPT/mptrack/View_pat.h 2012-04-18 22:26:00 UTC (rev 1248) +++ trunk/OpenMPT/mptrack/View_pat.h 2012-04-20 18:05:37 UTC (rev 1249) @@ -168,6 +168,7 @@ // -> DESC="midi keyboard split" BYTE activeNoteChannel[NOTE_MAX + 1]; BYTE splitActiveNoteChannel[NOTE_MAX + 1]; + vector<ModCommand::NOTE> octaveKeyMemory; int oldrow, oldchn, oldsplitchn; // -! NEW_FEATURE#0012 @@ -202,6 +203,7 @@ PATTERNINDEX GetCurrentPattern() const { return m_nPattern; } ROWINDEX GetCurrentRow() const { return m_Cursor.GetRow(); } CHANNELINDEX GetCurrentChannel() const { return m_Cursor.GetChannel(); } + ModCommand *GetCursorCommand(); UINT GetColumnOffset(PatternCursor::Columns column) const; POINT GetPointFromPosition(PatternCursor cursor); @@ -274,6 +276,7 @@ void TempStopChord(int note) {TempStopNote(note, false, true);} void TempEnterIns(int val); void TempEnterOctave(int val); + void TempStopOctave(int val); void TempEnterVol(int v); void TempEnterFX(int c, int v = -1); void TempEnterFXparam(int v); Modified: trunk/OpenMPT/mptrack/version.h =================================================================== --- trunk/OpenMPT/mptrack/version.h 2012-04-18 22:26:00 UTC (rev 1248) +++ trunk/OpenMPT/mptrack/version.h 2012-04-20 18:05:37 UTC (rev 1249) @@ -19,7 +19,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 20 #define VER_MINOR 00 -#define VER_MINORMINOR 84 +#define VER_MINORMINOR 85 //Creates version number from version parts that appears in version string. //For example MAKE_VERSION_NUMERIC(1,17,02,28) gives version number of @@ -51,9 +51,18 @@ { CString strVersion; if(v == 0) + { + // Unknown version strVersion = "Unknown"; - else + } else if((v & 0xFFFF) == 0) + { + // Only parts of the version number are known (f.e. when reading the version from the IT or S3M file header) + strVersion.Format("%X.%02X", (v >> 24) & 0xFF, (v >> 16) & 0xFF); + } else + { + // Full version info available strVersion.Format("%X.%02X.%02X.%02X", (v >> 24) & 0xFF, (v >> 16) & 0xFF, (v >> 8) & 0xFF, (v) & 0xFF); + } return strVersion; }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2012-04-20 23:06:14
|
Revision: 1250 http://modplug.svn.sourceforge.net/modplug/?rev=1250&view=rev Author: saga-games Date: 2012-04-20 23:06:06 +0000 (Fri, 20 Apr 2012) Log Message: ----------- [New] Pattern Editor / MIDI: It is now possible to record MIDI aftertouch messages to patterns using volume commands or MIDI Macros (http://bugs.openmpt.org/view.php?id=195). [Imp] Pattern Editor / MIDI: "Amplify MIDI Velocity" option has been changed to use a freely adjustable amplification factor (instead of fixed x2 amplification). [Imp] Pattern Editor: Changed status bar indicator sizes a bit for more optimal space utilisation. Modified Paths: -------------- trunk/OpenMPT/mptrack/Mpdlgs.cpp trunk/OpenMPT/mptrack/Mpdlgs.h trunk/OpenMPT/mptrack/Mpt_midi.cpp trunk/OpenMPT/mptrack/TrackerSettings.cpp trunk/OpenMPT/mptrack/TrackerSettings.h trunk/OpenMPT/mptrack/View_pat.cpp trunk/OpenMPT/mptrack/View_pat.h trunk/OpenMPT/mptrack/mptrack.rc Modified: trunk/OpenMPT/mptrack/Mpdlgs.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mpdlgs.cpp 2012-04-20 18:05:37 UTC (rev 1249) +++ trunk/OpenMPT/mptrack/Mpdlgs.cpp 2012-04-20 23:06:06 UTC (rev 1250) @@ -1001,7 +1001,7 @@ SetDlgItemText(IDC_EQ_WARNING, "Note: This EQ, when enabled from Player tab, is applied to " "any and all of the modules " - "that you load in OpenMPT; its settings are stored globally, " + "that you load in OpenMPT; its settings are stored globally, " "rather than in each file. This means that you should avoid " "using it as part of your production process, and instead only " "use it to correct deficiencies in your audio hardware."); @@ -1013,16 +1013,17 @@ // CMidiSetupDlg BEGIN_MESSAGE_MAP(CMidiSetupDlg, CPropertyPage) - ON_CBN_SELCHANGE(IDC_COMBO1, OnSettingsChanged) - ON_COMMAND(IDC_CHECK1, OnSettingsChanged) - ON_COMMAND(IDC_CHECK2, OnSettingsChanged) - ON_COMMAND(IDC_CHECK3, OnSettingsChanged) - ON_COMMAND(IDC_CHECK4, OnSettingsChanged) - ON_COMMAND(IDC_MIDI_TO_PLUGIN, OnSettingsChanged) - ON_COMMAND(IDC_MIDI_MACRO_CONTROL, OnSettingsChanged) - ON_COMMAND(IDC_MIDIVOL_TO_NOTEVOL, OnSettingsChanged) - ON_COMMAND(IDC_MIDIPLAYCONTROL, OnSettingsChanged) + ON_CBN_SELCHANGE(IDC_COMBO1, OnSettingsChanged) + ON_CBN_SELCHANGE(IDC_COMBO2, OnSettingsChanged) + ON_COMMAND(IDC_CHECK1, OnSettingsChanged) + ON_COMMAND(IDC_CHECK2, OnSettingsChanged) + ON_COMMAND(IDC_CHECK4, OnSettingsChanged) + ON_COMMAND(IDC_MIDI_TO_PLUGIN, OnSettingsChanged) + ON_COMMAND(IDC_MIDI_MACRO_CONTROL, OnSettingsChanged) + ON_COMMAND(IDC_MIDIVOL_TO_NOTEVOL, OnSettingsChanged) + ON_COMMAND(IDC_MIDIPLAYCONTROL, OnSettingsChanged) ON_COMMAND(IDC_MIDIPLAYPATTERNONMIDIIN, OnSettingsChanged) + ON_EN_CHANGE(IDC_EDIT3, OnSettingsChanged) END_MESSAGE_MAP() @@ -1033,6 +1034,8 @@ //{{AFX_DATA_MAP(COptionsSoundcard) DDX_Control(pDX, IDC_SPIN1, m_SpinSpd); DDX_Control(pDX, IDC_SPIN2, m_SpinPat); + DDX_Control(pDX, IDC_SPIN3, m_SpinAmp); + DDX_Control(pDX, IDC_COMBO2, m_ATBehaviour); //}}AFX_DATA_MAP } @@ -1047,13 +1050,13 @@ // Flags if (m_dwMidiSetup & MIDISETUP_RECORDVELOCITY) CheckDlgButton(IDC_CHECK1, MF_CHECKED); if (m_dwMidiSetup & MIDISETUP_RECORDNOTEOFF) CheckDlgButton(IDC_CHECK2, MF_CHECKED); - if (m_dwMidiSetup & MIDISETUP_AMPLIFYVELOCITY) CheckDlgButton(IDC_CHECK3, MF_CHECKED); if (m_dwMidiSetup & MIDISETUP_TRANSPOSEKEYBOARD) CheckDlgButton(IDC_CHECK4, MF_CHECKED); if (m_dwMidiSetup & MIDISETUP_MIDITOPLUG) CheckDlgButton(IDC_MIDI_TO_PLUGIN, MF_CHECKED); if (m_dwMidiSetup & MIDISETUP_MIDIMACROCONTROL) CheckDlgButton(IDC_MIDI_MACRO_CONTROL, MF_CHECKED); if (m_dwMidiSetup & MIDISETUP_MIDIVOL_TO_NOTEVOL) CheckDlgButton(IDC_MIDIVOL_TO_NOTEVOL, MF_CHECKED); if (m_dwMidiSetup & MIDISETUP_RESPONDTOPLAYCONTROLMSGS) CheckDlgButton(IDC_MIDIPLAYCONTROL, MF_CHECKED); if (m_dwMidiSetup & MIDISETUP_PLAYPATTERNONMIDIIN) CheckDlgButton(IDC_MIDIPLAYPATTERNONMIDIIN, MF_CHECKED); + // Midi In Device if ((combo = (CComboBox *)GetDlgItem(IDC_COMBO1)) != NULL) { @@ -1066,6 +1069,34 @@ } combo->SetCurSel((m_nMidiDevice == MIDI_MAPPER) ? 0 : m_nMidiDevice); } + + // Aftertouch behaviour + m_ATBehaviour.ResetContent(); + static const struct + { + const char *text; + TrackerSettings::RecordAftertouchOptions option; + } aftertouchOptions[] = + { + { "Do not record Aftertouch", TrackerSettings::atDoNotRecord }, + { "Record as Volume Commands", TrackerSettings::atRecordAsVolume }, + { "Record as MIDI Macros", TrackerSettings::atRecordAsMacro }, + }; + + for(size_t i = 0; i < CountOf(aftertouchOptions); i++) + { + int item = m_ATBehaviour.AddString(aftertouchOptions[i].text); + m_ATBehaviour.SetItemData(item, aftertouchOptions[i].option); + if(aftertouchOptions[i].option == CMainFrame::GetSettings().aftertouchBehaviour) + { + m_ATBehaviour.SetCurSel(i); + } + } + + // Note Velocity amp + SetDlgItemInt(IDC_EDIT3, CMainFrame::GetSettings().midiVelocityAmp); + m_SpinAmp.SetRange(1, 10000); + // Midi Import settings SetDlgItemInt(IDC_EDIT1, CMainFrame::GetSettings().midiImportSpeed); SetDlgItemInt(IDC_EDIT2, CMainFrame::GetSettings().midiImportPatternLen); @@ -1084,7 +1115,6 @@ m_nMidiDevice = MIDI_MAPPER; if (IsDlgButtonChecked(IDC_CHECK1)) m_dwMidiSetup |= MIDISETUP_RECORDVELOCITY; if (IsDlgButtonChecked(IDC_CHECK2)) m_dwMidiSetup |= MIDISETUP_RECORDNOTEOFF; - if (IsDlgButtonChecked(IDC_CHECK3)) m_dwMidiSetup |= MIDISETUP_AMPLIFYVELOCITY; if (IsDlgButtonChecked(IDC_CHECK4)) m_dwMidiSetup |= MIDISETUP_TRANSPOSEKEYBOARD; if (IsDlgButtonChecked(IDC_MIDI_TO_PLUGIN)) m_dwMidiSetup |= MIDISETUP_MIDITOPLUG; if (IsDlgButtonChecked(IDC_MIDI_MACRO_CONTROL)) m_dwMidiSetup |= MIDISETUP_MIDIMACROCONTROL; @@ -1097,8 +1127,12 @@ int n = combo->GetCurSel(); if (n >= 0) m_nMidiDevice = combo->GetItemData(n); } + + CMainFrame::GetSettings().aftertouchBehaviour = static_cast<TrackerSettings::RecordAftertouchOptions>(m_ATBehaviour.GetItemData(m_ATBehaviour.GetCurSel())); + CMainFrame::GetSettings().midiImportSpeed = GetDlgItemInt(IDC_EDIT1); CMainFrame::GetSettings().midiImportPatternLen = GetDlgItemInt(IDC_EDIT2); + CMainFrame::GetSettings().midiVelocityAmp = static_cast<uint16>(Clamp(GetDlgItemInt(IDC_EDIT3), 1u, 10000u)); if (pMainFrm) pMainFrm->SetupMidi(m_dwMidiSetup, m_nMidiDevice); CPropertyPage::OnOK(); } Modified: trunk/OpenMPT/mptrack/Mpdlgs.h =================================================================== --- trunk/OpenMPT/mptrack/Mpdlgs.h 2012-04-20 18:05:37 UTC (rev 1249) +++ trunk/OpenMPT/mptrack/Mpdlgs.h 2012-04-20 23:06:06 UTC (rev 1250) @@ -163,7 +163,8 @@ LONG m_nMidiDevice; protected: - CSpinButtonCtrl m_SpinSpd, m_SpinPat; + CSpinButtonCtrl m_SpinSpd, m_SpinPat, m_SpinAmp; + CComboBox m_ATBehaviour; public: CMidiSetupDlg(DWORD d, LONG n):CPropertyPage(IDD_OPTIONS_MIDI) Modified: trunk/OpenMPT/mptrack/Mpt_midi.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mpt_midi.cpp 2012-04-20 18:05:37 UTC (rev 1249) +++ trunk/OpenMPT/mptrack/Mpt_midi.cpp 2012-04-20 23:06:06 UTC (rev 1250) @@ -29,7 +29,7 @@ if (CMainFrame::GetSettings().m_dwMidiSetup & MIDISETUP_RECORDVELOCITY) { nVol = (CDLSBank::DLSMidiVolumeToLinear(nVol)+255) >> 8; - if (CMainFrame::GetSettings().m_dwMidiSetup & MIDISETUP_AMPLIFYVELOCITY) nVol *= 2; + nVol *= CMainFrame::GetSettings().midiVelocityAmp / 100; Limit(nVol, 1, 256); if(CMainFrame::GetSettings().m_dwMidiSetup & MIDISETUP_MIDIVOL_TO_NOTEVOL) nVol = static_cast<int>((midivolume / 127.0) * nVol); Modified: trunk/OpenMPT/mptrack/TrackerSettings.cpp =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.cpp 2012-04-20 18:05:37 UTC (rev 1249) +++ trunk/OpenMPT/mptrack/TrackerSettings.cpp 2012-04-20 23:06:06 UTC (rev 1250) @@ -68,14 +68,17 @@ m_nPreAmp = 128; gbLoopSong = TRUE; m_nWaveDevice = SNDDEV_BUILD_ID(0, SNDDEV_WAVEOUT); // Default value will be overridden - m_nMidiDevice = 0; m_nBufferLength = 50; // Default EQ settings MemCopy(m_EqSettings, CEQSetupDlg::gEQPresets[0]); // MIDI Setup - m_dwMidiSetup = MIDISETUP_RECORDVELOCITY|MIDISETUP_RECORDNOTEOFF; + m_nMidiDevice = 0; + m_dwMidiSetup = MIDISETUP_RECORDVELOCITY | MIDISETUP_RECORDNOTEOFF | MIDISETUP_TRANSPOSEKEYBOARD | MIDISETUP_MIDITOPLUG; + aftertouchBehaviour = atDoNotRecord; + midiVelocityAmp = 100; + // MIDI Import midiImportPatternLen = 128; midiImportSpeed = 3; @@ -351,21 +354,29 @@ m_dwMidiSetup = CMainFrame::GetPrivateProfileDWord("MIDI Settings", "MidiSetup", m_dwMidiSetup, iniFile); m_nMidiDevice = CMainFrame::GetPrivateProfileDWord("MIDI Settings", "MidiDevice", m_nMidiDevice, iniFile); + aftertouchBehaviour = static_cast<RecordAftertouchOptions>(CMainFrame::GetPrivateProfileDWord("MIDI Settings", "AftertouchBehaviour", aftertouchBehaviour, iniFile)); + midiVelocityAmp = static_cast<uint16>(CMainFrame::GetPrivateProfileLong("MIDI Settings", "MidiVelocityAmp", midiVelocityAmp, iniFile)); midiImportSpeed = CMainFrame::GetPrivateProfileLong("MIDI Settings", "MidiImportSpeed", midiImportSpeed, iniFile); midiImportPatternLen = CMainFrame::GetPrivateProfileLong("MIDI Settings", "MidiImportPatLen", midiImportPatternLen, iniFile); + if((m_dwMidiSetup & 0x40) != 0 && vIniVersion < MAKE_VERSION_NUMERIC(1, 20, 00, 86)) + { + // This flag used to be "amplify MIDI Note Velocity" - with a fixed amplification factor of 2. + midiVelocityAmp = 200; + m_dwMidiSetup &= ~0x40; + } m_dwPatternSetup = CMainFrame::GetPrivateProfileDWord("Pattern Editor", "PatternSetup", m_dwPatternSetup, iniFile); - if(vIniVersion < MAKE_VERSION_NUMERIC(1,17,02,50)) + if(vIniVersion < MAKE_VERSION_NUMERIC(1, 17, 02, 50)) m_dwPatternSetup |= PATTERN_NOTEFADE; - if(vIniVersion < MAKE_VERSION_NUMERIC(1,17,03,01)) + if(vIniVersion < MAKE_VERSION_NUMERIC(1, 17, 03, 01)) m_dwPatternSetup |= PATTERN_RESETCHANNELS; - if(vIniVersion < MAKE_VERSION_NUMERIC(1,19,00,07)) + if(vIniVersion < MAKE_VERSION_NUMERIC(1, 19, 00, 07)) m_dwPatternSetup &= ~0x800; // this was previously deprecated and is now used for something else - if(vIniVersion < MAKE_VERSION_NUMERIC(1,20,00,04)) + if(vIniVersion < MAKE_VERSION_NUMERIC(1, 20, 00, 04)) m_dwPatternSetup &= ~0x200000; // dito - if(vIniVersion < MAKE_VERSION_NUMERIC(1,20,00,07)) + if(vIniVersion < MAKE_VERSION_NUMERIC(1, 20, 00, 07)) m_dwPatternSetup &= ~0x400000; // dito - if(vIniVersion < MAKE_VERSION_NUMERIC(1,20,00,39)) + if(vIniVersion < MAKE_VERSION_NUMERIC(1, 20, 00, 39)) m_dwPatternSetup &= ~0x10000000; // dito m_nRowHighlightMeasures = CMainFrame::GetPrivateProfileDWord("Pattern Editor", "RowSpacing", m_nRowHighlightMeasures, iniFile); @@ -557,6 +568,12 @@ RegQueryValueEx(key, "MixChannels", NULL, &dwREG_DWORD, (LPBYTE)&CSoundFile::m_nMaxMixChannels, &dwDWORDSize); RegQueryValueEx(key, "WaveDevice", NULL, &dwREG_DWORD, (LPBYTE)&m_nWaveDevice, &dwDWORDSize); RegQueryValueEx(key, "MidiSetup", NULL, &dwREG_DWORD, (LPBYTE)&m_dwMidiSetup, &dwDWORDSize); + if((m_dwMidiSetup & 0x40) != 0) + { + // This flag used to be "amplify MIDI Note Velocity" - with a fixed amplification factor of 2. + midiVelocityAmp = 200; + m_dwMidiSetup &= ~0x40; + } RegQueryValueEx(key, "MidiDevice", NULL, &dwREG_DWORD, (LPBYTE)&m_nMidiDevice, &dwDWORDSize); RegQueryValueEx(key, "PatternSetup", NULL, &dwREG_DWORD, (LPBYTE)&m_dwPatternSetup, &dwDWORDSize); m_dwPatternSetup &= ~(0x800|0x200000|0x400000); // various deprecated old options @@ -720,6 +737,8 @@ CMainFrame::WritePrivateProfileDWord("MIDI Settings", "MidiSetup", m_dwMidiSetup, iniFile); CMainFrame::WritePrivateProfileDWord("MIDI Settings", "MidiDevice", m_nMidiDevice, iniFile); + CMainFrame::WritePrivateProfileDWord("MIDI Settings", "AftertouchBehaviour", aftertouchBehaviour, iniFile); + CMainFrame::WritePrivateProfileLong("MIDI Settings", "MidiVelocityAmp", midiVelocityAmp, iniFile); CMainFrame::WritePrivateProfileLong("MIDI Settings", "MidiImportSpeed", midiImportSpeed, iniFile); CMainFrame::WritePrivateProfileLong("MIDI Settings", "MidiImportPatLen", midiImportPatternLen, iniFile); Modified: trunk/OpenMPT/mptrack/TrackerSettings.h =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.h 2012-04-20 18:05:37 UTC (rev 1249) +++ trunk/OpenMPT/mptrack/TrackerSettings.h 2012-04-20 23:06:06 UTC (rev 1250) @@ -35,6 +35,16 @@ public: + // MIDI recording + enum RecordAftertouchOptions + { + atDoNotRecord = 0, + atRecordAsVolume, + atRecordAsMacro, + }; + +public: + BOOL gbMdiMaximize; bool gbShowHackControls; LONG glTreeWindowWidth, glTreeSplitRatio; @@ -47,13 +57,19 @@ // 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 - LONG m_nMidiDevice; DWORD m_nBufferLength; EQPRESET m_EqSettings; + + // MIDI Setup + LONG m_nMidiDevice; + DWORD m_dwMidiSetup; + RecordAftertouchOptions aftertouchBehaviour; + uint16 midiVelocityAmp; + // Pattern Setup UINT gnPatternSpacing; BOOL gbPatternVUMeters, gbPatternPluginNames, gbPatternRecord; - DWORD m_dwPatternSetup, m_dwMidiSetup, m_nKeyboardCfg; + DWORD m_dwPatternSetup, m_nKeyboardCfg; DWORD m_nRowHighlightMeasures, m_nRowHighlightBeats; // primary (measures) and secondary (beats) highlight bool m_bHideUnavailableCtxMenuItems; int orderlistMargins; Modified: trunk/OpenMPT/mptrack/View_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_pat.cpp 2012-04-20 18:05:37 UTC (rev 1249) +++ trunk/OpenMPT/mptrack/View_pat.cpp 2012-04-20 23:06:06 UTC (rev 1250) @@ -2466,25 +2466,25 @@ return; } - const ModCommand *m = GetCursorCommand(); + const ModCommand &m = GetCursorCommand(); switch(m_Cursor.GetColumnType()) { case PatternCursor::noteColumn: case PatternCursor::instrColumn: - m_cmdOld.note = m->note; - m_cmdOld.instr = m->instr; + m_cmdOld.note = m.note; + m_cmdOld.instr = m.instr; SendCtrlMessage(CTRLMSG_SETCURRENTINSTRUMENT, m_cmdOld.instr); break; case PatternCursor::volumeColumn: - m_cmdOld.volcmd = m->volcmd; - m_cmdOld.vol = m->vol; + m_cmdOld.volcmd = m.volcmd; + m_cmdOld.vol = m.vol; break; case PatternCursor::effectColumn: case PatternCursor::paramColumn: - m_cmdOld.command = m->command; - m_cmdOld.param = m->param; + m_cmdOld.command = m.command; + m_cmdOld.param = m.param; break; } } @@ -2494,8 +2494,7 @@ void CViewPattern::OnCursorPaste() //-------------------------------- { - ModCommand *p = GetCursorCommand(); - if(p == nullptr || !IsEditingEnabled_bmsg()) + if(!IsEditingEnabled_bmsg()) { return; } @@ -2503,24 +2502,26 @@ PrepareUndo(m_Cursor, m_Cursor); PatternCursor::Columns column = m_Cursor.GetColumnType(); + ModCommand &m = GetCursorCommand(); + switch(column) { case PatternCursor::noteColumn: - p->note = m_cmdOld.note; + m.note = m_cmdOld.note; // Intentional fall-through case PatternCursor::instrColumn: - p->instr = m_cmdOld.instr; + m.instr = m_cmdOld.instr; break; case PatternCursor::volumeColumn: - p->vol = m_cmdOld.vol; - p->volcmd = m_cmdOld.volcmd; + m.vol = m_cmdOld.vol; + m.volcmd = m_cmdOld.volcmd; break; case PatternCursor::effectColumn: case PatternCursor::paramColumn: - p->command = m_cmdOld.command; - p->param = m_cmdOld.param; + m.command = m_cmdOld.command; + m.param = m_cmdOld.param; break; } @@ -3503,27 +3504,33 @@ } -// Get ModCommand at the pattern cursor position. -ModCommand *CViewPattern ::GetCursorCommand() -//------------------------------------------- +// Return ModCommand at the given cursor position of the current pattern. +// If the position is not valid, a pointer to a dummy command is returned. +ModCommand &CViewPattern::GetModCommand(PatternCursor cursor) +//----------------------------------------------------------- { CSoundFile *pSndFile = GetSoundFile(); if(pSndFile != nullptr && pSndFile->Patterns.IsValidPat(GetCurrentPattern())) { - return pSndFile->Patterns[GetCurrentPattern()].GetpModCommand(GetCurrentRow(), GetCurrentChannel()); + return *pSndFile->Patterns[GetCurrentPattern()].GetpModCommand(cursor.GetRow(), cursor.GetChannel()); } - return nullptr; + // Failed. + static ModCommand dummy; + return dummy; } -ModCommand *CViewPattern::GetModCommand(CSoundFile& rSf, const ModCommandPos& pos) -//-------------------------------------------------------------------------------- + +// Returns pointer to modcommand at given position. +// If the position is not valid, a pointer to a dummy command is returned. +ModCommand &CViewPattern::GetModCommand(CSoundFile &sndFile, const ModCommandPos &pos) +//------------------------------------------------------------------------------------ { - static ModCommand m; - if (rSf.Patterns.IsValidPat(pos.nPat) && pos.nRow < rSf.Patterns[pos.nPat].GetNumRows() && pos.nChn < rSf.GetNumChannels()) - return rSf.Patterns[pos.nPat].GetpModCommand(pos.nRow, pos.nChn); + static ModCommand dummy; + if(sndFile.Patterns.IsValidPat(pos.nPat) && pos.nRow < sndFile.Patterns[pos.nPat].GetNumRows() && pos.nChn < sndFile.GetNumChannels()) + return *sndFile.Patterns[pos.nPat].GetpModCommand(pos.nRow, pos.nChn); else - return &m; + return dummy; } @@ -3580,9 +3587,9 @@ const bool liveRecord = IsLiveRecord(); ModCommandPos editpos = GetEditPos(*pSndFile, liveRecord); - ModCommand* p = GetModCommand(*pSndFile, editpos); + ModCommand &m = GetModCommand(*pSndFile, editpos); pModDoc->GetPatternUndo().PrepareUndo(editpos.nPat, editpos.nChn, editpos.nRow, 1, 1); - p->Set(NOTE_PCS, mappedIndex, static_cast<uint16>(paramIndex), static_cast<uint16>((paramValue * ModCommand::maxColumnValue)/127)); + m.Set(NOTE_PCS, mappedIndex, static_cast<uint16>(paramIndex), static_cast<uint16>((paramValue * ModCommand::maxColumnValue)/127)); if(!liveRecord) InvalidateRow(editpos.nRow); pMainFrm->ThreadSafeSetModified(pModDoc); @@ -3612,10 +3619,14 @@ break; - case MIDIEvents::evPolyAftertouch: - case MIDIEvents::evChannelAftertouch: + case MIDIEvents::evPolyAftertouch: // Polyphonic aftertouch + EnterAftertouch(nNote, nVol); break; + case MIDIEvents::evChannelAftertouch: // Channel aftertouch + EnterAftertouch(NOTE_NONE, nByte1); + break; + case MIDIEvents::evControllerChange: //Controller change switch(nByte1) { @@ -3631,13 +3642,14 @@ const bool liveRecord = IsLiveRecord(); ModCommandPos editpos = GetEditPos(*pSndFile, liveRecord); - ModCommand* p = GetModCommand(*pSndFile, editpos); + ModCommand &m = GetModCommand(*pSndFile, editpos); - if(p->command == CMD_NONE || p->command == CMD_SMOOTHMIDI || p->command == CMD_MIDI) - { // Write command only if there's no existing command or already a midi macro command. + if(m.command == CMD_NONE || m.command == CMD_SMOOTHMIDI || m.command == CMD_MIDI) + { + // Write command only if there's no existing command or already a midi macro command. pModDoc->GetPatternUndo().PrepareUndo(editpos.nPat, editpos.nChn, editpos.nRow, 1, 1); - p->command = CMD_SMOOTHMIDI; - p->param = nByte2; + m.command = CMD_SMOOTHMIDI; + m.param = nByte2; pMainFrm->ThreadSafeSetModified(pModDoc); // Update GUI only if not recording live. @@ -4238,13 +4250,13 @@ { \ if((v >= 0) && (v <= 9)) \ { \ - uint16 val = pTarget->Get##method##(); \ + uint16 val = target.Get##method##(); \ /* Move existing digits to left, drop out leftmost digit and */ \ /* push new digit to the least meaning digit. */ \ val = (val % 100) * 10 + v; \ if(val > ModCommand::maxColumnValue) val = ModCommand::maxColumnValue; \ - pTarget->Set##method##(val); \ - m_PCNoteEditMemory = *pTarget; \ + target.Set##method##(val); \ + m_PCNoteEditMemory = target; \ } \ } @@ -4262,17 +4274,17 @@ PrepareUndo(m_Cursor, m_Cursor); - ModCommand* pTarget = GetCursorCommand(); - ModCommand oldcmd = *pTarget; // This is the command we are about to overwrite + ModCommand &target = GetCursorCommand(); + ModCommand oldcmd = target; // This is the command we are about to overwrite - if(pTarget->IsPcNote()) + if(target.IsPcNote()) { ENTER_PCNOTE_VALUE(v, ValueVolCol); } else { - UINT volcmd = pTarget->volcmd; - UINT vol = pTarget->vol; + ModCommand::VOLCMD volcmd = target.volcmd; + uint16 vol = target.vol; if ((v >= 0) && (v <= 9)) { vol = ((vol * 10) + v) % 100; @@ -4287,33 +4299,33 @@ case kcSetVolumeVolSlideDown: volcmd = VOLCMD_VOLSLIDEDOWN; break; case kcSetVolumeFineVolUp: volcmd = VOLCMD_FINEVOLUP; break; case kcSetVolumeFineVolDown: volcmd = VOLCMD_FINEVOLDOWN; break; - case kcSetVolumeVibratoSpd: if (pSndFile->m_nType & MOD_TYPE_XM) volcmd = VOLCMD_VIBRATOSPEED; break; + case kcSetVolumeVibratoSpd: if (pSndFile->GetType() & MOD_TYPE_XM) volcmd = VOLCMD_VIBRATOSPEED; break; case kcSetVolumeVibrato: volcmd = VOLCMD_VIBRATODEPTH; break; - case kcSetVolumeXMPanLeft: if (pSndFile->m_nType & MOD_TYPE_XM) volcmd = VOLCMD_PANSLIDELEFT; break; - case kcSetVolumeXMPanRight: if (pSndFile->m_nType & MOD_TYPE_XM) volcmd = VOLCMD_PANSLIDERIGHT; break; + case kcSetVolumeXMPanLeft: if (pSndFile->GetType() & MOD_TYPE_XM) volcmd = VOLCMD_PANSLIDELEFT; break; + case kcSetVolumeXMPanRight: if (pSndFile->GetType() & MOD_TYPE_XM) volcmd = VOLCMD_PANSLIDERIGHT; break; case kcSetVolumePortamento: volcmd = VOLCMD_TONEPORTAMENTO; break; - case kcSetVolumeITPortaUp: if (pSndFile->m_nType & (MOD_TYPE_IT | MOD_TYPE_MPT)) volcmd = VOLCMD_PORTAUP; break; - case kcSetVolumeITPortaDown: if (pSndFile->m_nType & (MOD_TYPE_IT | MOD_TYPE_MPT)) volcmd = VOLCMD_PORTADOWN; break; - case kcSetVolumeITOffset: if (pSndFile->m_nType & (MOD_TYPE_IT | MOD_TYPE_MPT)) volcmd = VOLCMD_OFFSET; break; //rewbs.volOff + case kcSetVolumeITPortaUp: if (pSndFile->GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT)) volcmd = VOLCMD_PORTAUP; break; + case kcSetVolumeITPortaDown: if (pSndFile->GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT)) volcmd = VOLCMD_PORTADOWN; break; + case kcSetVolumeITOffset: if (pSndFile->GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT)) volcmd = VOLCMD_OFFSET; break; //rewbs.volOff } UINT max = 64; if (volcmd > VOLCMD_PANNING) { - max = (pSndFile->m_nType == MOD_TYPE_XM) ? 0x0F : 9; + max = (pSndFile->GetType() == MOD_TYPE_XM) ? 0x0F : 9; } if (vol > max) vol %= 10; if(pSndFile->GetModSpecifications().HasVolCommand(volcmd)) { - pTarget->volcmd = volcmd; - pTarget->vol = vol; + target.volcmd = volcmd; + target.vol = vol; } } SetSelToCursor(); - if(oldcmd != *pTarget) + if(oldcmd != target) { SetModified(false); InvalidateCell(m_Cursor); @@ -4344,12 +4356,12 @@ return; } - ModCommand *pTarget = GetCursorCommand(); - ModCommand oldcmd = *pTarget; // This is the command we are about to overwrite + ModCommand &target = GetCursorCommand(); + ModCommand oldcmd = target; // This is the command we are about to overwrite PrepareUndo(m_Cursor, m_Cursor); - if(pTarget->IsPcNote()) + if(target.IsPcNote()) { ENTER_PCNOTE_VALUE(c, ValueEffectCol); } @@ -4358,27 +4370,32 @@ if (c) { - if ((c == m_cmdOld.command) && (!pTarget->param) && (!pTarget->command)) pTarget->param = m_cmdOld.param; - else m_cmdOld.param = 0; + if ((c == m_cmdOld.command) && (!target.param) && (target.command == CMD_NONE)) + { + target.param = m_cmdOld.param; + } else + { + m_cmdOld.param = 0; + } m_cmdOld.command = c; } - pTarget->command = c; + target.command = c; if(v >= 0) { - pTarget->param = v; + target.param = v; } // Check for MOD/XM Speed/Tempo command - if ((pSndFile->m_nType & (MOD_TYPE_MOD|MOD_TYPE_XM)) - && ((pTarget->command == CMD_SPEED) || (pTarget->command == CMD_TEMPO))) + if((pSndFile->GetType() & (MOD_TYPE_MOD | MOD_TYPE_XM)) + && (target.command == CMD_SPEED || target.command == CMD_TEMPO)) { - pTarget->command = (pTarget->param <= pSndFile->GetModSpecifications().speedMax) ? CMD_SPEED : CMD_TEMPO; + target.command = (target.param <= pSndFile->GetModSpecifications().speedMax) ? CMD_SPEED : CMD_TEMPO; } } SetSelToCursor(); - if(oldcmd != *pTarget) + if(oldcmd != target) { SetModified(false); InvalidateCell(m_Cursor); @@ -4398,31 +4415,34 @@ return; } - ModCommand *pTarget = GetCursorCommand(); - ModCommand oldcmd = *pTarget; // This is the command we are about to overwrite + ModCommand &target = GetCursorCommand(); + ModCommand oldcmd = target; // This is the command we are about to overwrite PrepareUndo(m_Cursor, m_Cursor); - if(pTarget->IsPcNote()) + if(target.IsPcNote()) { ENTER_PCNOTE_VALUE(v, ValueEffectCol); } else { - pTarget->param = (pTarget->param << 4) | v; - if (pTarget->command == m_cmdOld.command) m_cmdOld.param = pTarget->param; + target.param = (target.param << 4) | v; + if (target.command == m_cmdOld.command) + { + m_cmdOld.param = target.param; + } // Check for MOD/XM Speed/Tempo command - if ((pSndFile->m_nType & (MOD_TYPE_MOD|MOD_TYPE_XM)) - && ((pTarget->command == CMD_SPEED) || (pTarget->command == CMD_TEMPO))) + if((pSndFile->GetType() & (MOD_TYPE_MOD|MOD_TYPE_XM)) + && (target.command == CMD_SPEED || target.command == CMD_TEMPO)) { - pTarget->command = (pTarget->param <= pSndFile->GetModSpecifications().speedMax) ? CMD_SPEED : CMD_TEMPO; + target.command = (target.param <= pSndFile->GetModSpecifications().speedMax) ? CMD_SPEED : CMD_TEMPO; } } SetSelToCursor(); - if(*pTarget != oldcmd) + if(target != oldcmd) { SetModified(false); InvalidateCell(m_Cursor); @@ -4444,7 +4464,7 @@ const UINT nTick = pSndFile->m_nTickCount; const PATTERNINDEX nPatPlayback = pSndFile->m_nPattern; - const bool isSplit = (pModDoc->GetSplitKeyboardSettings().IsSplitActive()) && (note <= pModDoc->GetSplitKeyboardSettings().splitNote); + const bool isSplit = IsNoteSplit(note); UINT ins = 0; if(pModDoc) { @@ -4587,13 +4607,13 @@ return; } - const ModCommand &target = *GetCursorCommand(); + const ModCommand &target = GetCursorCommand(); if(target.IsNote()) { PrepareUndo(m_Cursor, m_Cursor); TempEnterNote(((target.note - NOTE_MIN) % 12) + val * 12 + NOTE_MIN); // Memorize note for key-up - ASSERT(val < octaveKeyMemory.size()); + ASSERT(size_t(val) < octaveKeyMemory.size()); octaveKeyMemory[val] = target.note; } } @@ -4603,7 +4623,7 @@ void CViewPattern::TempStopOctave(int val) //---------------------------------------- { - ASSERT(val < octaveKeyMemory.size()); + ASSERT(size_t(val) < octaveKeyMemory.size()); if(octaveKeyMemory[val] != NOTE_NONE) { TempStopNote(octaveKeyMemory[val]); @@ -4624,11 +4644,11 @@ PrepareUndo(m_Cursor, m_Cursor); - ModCommand *pTarget = GetCursorCommand(); - ModCommand oldcmd = *pTarget; // This is the command we are about to overwrite + ModCommand &target = GetCursorCommand(); + ModCommand oldcmd = target; // This is the command we are about to overwrite - UINT instr = pTarget->instr, nTotalMax, nTempMax; - if(pTarget->IsPcNote()) // this is a plugin index + UINT instr = target.instr, nTotalMax, nTempMax; + if(target.IsPcNote()) // this is a plugin index { nTotalMax = MAX_MIXPLUGINS + 1; nTempMax = MAX_MIXPLUGINS + 1; @@ -4647,20 +4667,20 @@ if (nTempMax < 100) // if we're using samples & have less than 100 samples instr = instr % 100; // or if we're using instruments and have less than 100 instruments // --> ensure the entered instrument value is less than 100. - pTarget->instr = instr; + target.instr = instr; SetSelToCursor(); - if(*pTarget != oldcmd) + if(target != oldcmd) { SetModified(false); InvalidateCell(m_Cursor); UpdateIndicator(); } - if(pTarget->IsPcNote()) + if(target.IsPcNote()) { - m_PCNoteEditMemory = *pTarget; + m_PCNoteEditMemory = target; } } @@ -5107,6 +5127,91 @@ } +// Translate incoming MIDI aftertouch messages to pattern commands +void CViewPattern::EnterAftertouch(int note, int atValue) +//------------------------------------------------------- +{ + if(CMainFrame::GetSettings().aftertouchBehaviour == TrackerSettings::atDoNotRecord) + { + return; + } + + PatternCursor cursor(m_Cursor); + + if(ModCommand::IsNote(note)) + { + // For polyphonic aftertouch, map the aftertouch note to the correct pattern channel. + BYTE *activeNoteMap = IsNoteSplit(note) ? splitActiveNoteChannel : activeNoteChannel; + if(activeNoteMap[note] < GetSoundFile()->GetNumChannels()) + { + cursor.SetColumn(activeNoteMap[note], PatternCursor::firstColumn); + } else + { + // Couldn't find the channel that belongs to this note... Don't bother writing aftertouch messages. + // This is actually necessary, because it is possible that the last aftertouch message for a note + // is received after the key-off event, in which case OpenMPT won't know anymore on which channel + // that particular note was, so it will just put the message on some other channel. We don't want that! + return; + } + } + + Limit(atValue, 0, 127); + + ModCommand &target = GetModCommand(cursor); + ModCommand origCommand = target; + CSoundFile *pSndFile = GetSoundFile(); + + switch(CMainFrame::GetSettings().aftertouchBehaviour) + { + case TrackerSettings::atRecordAsVolume: + // Record aftertouch messages as volume commands + if(pSndFile->GetModSpecifications().HasVolCommand(VOLCMD_VOLUME)) + { + if(target.volcmd == VOLCMD_NONE || target.volcmd == VOLCMD_VOLUME) + { + PrepareUndo(m_Cursor, m_Cursor); + target.volcmd = VOLCMD_VOLUME; + target.vol = static_cast<ModCommand::VOL>((atValue * 64 + 64) / 127); + } + } else if(pSndFile->GetModSpecifications().HasCommand(CMD_VOLUME)) + { + if(target.command == CMD_NONE || target.command == CMD_VOLUME) + { + PrepareUndo(m_Cursor, m_Cursor); + target.command = CMD_VOLUME; + target.param = static_cast<ModCommand::PARAM>((atValue * 64 + 64) / 127); + } + } + break; + + case TrackerSettings::atRecordAsMacro: + // Record aftertouch messages as MIDI Macros + if(target.command == CMD_NONE || target.command == CMD_SMOOTHMIDI || target.command == CMD_MIDI) + { + ModCommand::COMMAND cmd = + pSndFile->GetModSpecifications().HasCommand(CMD_SMOOTHMIDI) ? CMD_SMOOTHMIDI : + pSndFile->GetModSpecifications().HasCommand(CMD_MIDI) ? CMD_MIDI : + CMD_NONE; + + if(cmd != CMD_NONE) + { + PrepareUndo(m_Cursor, m_Cursor); + target.command = cmd; + target.param = static_cast<ModCommand::PARAM>(atValue); + } + } + break; + } + + if(target != origCommand) + { + SetModified(false); + InvalidateCell(cursor); + UpdateIndicator(); + } +} + + // Find a free channel for a record group, starting search from a given channel. // If forceFreeChannel is true and all channels in the specified record group are active, some channel is picked from the specified record group. CHANNELINDEX CViewPattern::FindGroupRecordChannel(BYTE recordGroup, bool forceFreeChannel, CHANNELINDEX startChannel) const @@ -5176,55 +5281,55 @@ PrepareUndo(m_Cursor, m_Cursor); - ModCommand *p = GetCursorCommand(); - ModCommand oldcmd = *p; + ModCommand &target = GetCursorCommand(); + ModCommand oldcmd = target; if(mask.note) { // Clear note - if(p->IsPcNote()) + if(target.IsPcNote()) { // Need to clear entire field if this is a PC Event. - p->Clear(); + target.Clear(); } else { - p->note = NOTE_NONE; + target.note = NOTE_NONE; if(ITStyle) { - p->instr = 0; + target.instr = 0; } } } if(mask.instrument) { // Clear instrument - p->instr = 0; + target.instr = 0; } if(mask.volume) { // Clear volume effect - p->volcmd = VOLCMD_NONE; - p->vol = 0; + target.volcmd = VOLCMD_NONE; + target.vol = 0; } if(mask.command) { // Clear effect command - p->command = CMD_NONE; + target.command = CMD_NONE; } if(mask.parameter) { // Clear effect parameter - p->param = 0; + target.param = 0; } - if((mask.command || mask.parameter) && (p->IsPcNote())) + if((mask.command || mask.parameter) && (target.IsPcNote())) { - p->SetValueEffectCol(0); + target.SetValueEffectCol(0); } SetSelToCursor(); - if(*p != oldcmd) + if(target != oldcmd) { SetModified(false); InvalidateRow(); Modified: trunk/OpenMPT/mptrack/View_pat.h =================================================================== --- trunk/OpenMPT/mptrack/View_pat.h 2012-04-20 18:05:37 UTC (rev 1249) +++ trunk/OpenMPT/mptrack/View_pat.h 2012-04-20 23:06:06 UTC (rev 1250) @@ -203,7 +203,8 @@ PATTERNINDEX GetCurrentPattern() const { return m_nPattern; } ROWINDEX GetCurrentRow() const { return m_Cursor.GetRow(); } CHANNELINDEX GetCurrentChannel() const { return m_Cursor.GetChannel(); } - ModCommand *GetCursorCommand(); + // Get ModCommand at the pattern cursor position. + ModCommand &GetCursorCommand() { return GetModCommand(m_Cursor); }; UINT GetColumnOffset(PatternCursor::Columns column) const; POINT GetPointFromPosition(PatternCursor cursor); @@ -280,6 +281,8 @@ void TempEnterVol(int v); void TempEnterFX(int c, int v = -1); void TempEnterFXparam(int v); + void EnterAftertouch(int note, int atValue); + void SetSpacing(int n); void OnClearField(const RowMask &mask, bool step, bool ITStyle = false); void InsertRows(CHANNELINDEX colmin, CHANNELINDEX colmax); @@ -462,9 +465,10 @@ // Returns edit position. ModCommandPos GetEditPos(CSoundFile &rSf, const bool bLiveRecord) const; - // Returns pointer to modcommand at given position. If the position is not valid, returns pointer - // to a dummy command. - ModCommand* GetModCommand(CSoundFile &rSf, const ModCommandPos &pos); + // Returns pointer to modcommand at given position. + // If the position is not valid, a pointer to a dummy command is returned. + ModCommand &GetModCommand(PatternCursor cursor); + ModCommand &GetModCommand(CSoundFile &sndFile, const ModCommandPos &pos); // Returns true if pattern editing is enabled. bool IsEditingEnabled() const { return ((m_dwStatus & psRecordingEnabled) != 0); } Modified: trunk/OpenMPT/mptrack/mptrack.rc =================================================================== --- trunk/OpenMPT/mptrack/mptrack.rc 2012-04-20 18:05:37 UTC (rev 1249) +++ trunk/OpenMPT/mptrack/mptrack.rc 2012-04-20 23:06:06 UTC (rev 1250) @@ -535,33 +535,37 @@ CAPTION "MIDI" FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN - GROUPBOX "MIDI Recording",IDC_STATIC,5,5,260,200 - LTEXT "MIDI Input Device:",IDC_STATIC,15,20,67,8 - COMBOBOX IDC_COMBO1,15,30,120,74,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - LTEXT "MIDI Output Device:",IDC_STATIC,140,20,65,8,NOT WS_VISIBLE - COMBOBOX IDC_COMBO2,140,30,120,73,CBS_DROPDOWNLIST | NOT WS_VISIBLE | WS_VSCROLL | WS_TABSTOP - CONTROL "Apply Octave Transpose on external MIDI keyboard",IDC_CHECK4, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,55,185,9 - CONTROL "Record note velocity",IDC_CHECK1,"Button",BS_AUTOCHECKBOX | BS_TOP | WS_TABSTOP,15,75,100,9 - CONTROL "Amplify MIDI velocity",IDC_CHECK3,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,90,100,9 - CONTROL "Combine MIDI volume to note velocity",IDC_MIDIVOL_TO_NOTEVOL, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,105,139,9 - CONTROL "Record Note Off (Instruments Only)",IDC_CHECK2,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,120,130,9 - CONTROL "Record MIDI controller changes as MIDI macro changes (in pattern)",IDC_MIDI_MACRO_CONTROL, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,140,226,9 - CONTROL "Pass MIDI to active instrument plugin (experimental)",IDC_MIDI_TO_PLUGIN, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,155,180,9 - CONTROL "Respond to play/continue/stop song messages",IDC_MIDIPLAYCONTROL, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,170,200,9 + GROUPBOX "MIDI Recording",IDC_STATIC,6,6,258,108 + LTEXT "MIDI Input Device:",IDC_STATIC,18,18,67,8 + COMBOBOX IDC_COMBO1,18,30,240,74,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + CONTROL "Apply Octave Transpose to incoming MIDI Notes",IDC_CHECK4, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,48,237,12 + CONTROL "Record Note Off",IDC_CHECK2,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,60,237,12 + CONTROL "Respond to Play / Continue / Stop Song messages",IDC_MIDIPLAYCONTROL, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,72,237,12 CONTROL "Continue song as soon as MIDI notes are being received",IDC_MIDIPLAYPATTERNONMIDIIN, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,185,195,10 - GROUPBOX "MIDI file import",IDC_STATIC,5,210,260,45 - LTEXT "Speed:",IDC_STATIC,15,230,24,8 - EDITTEXT IDC_EDIT1,45,230,39,12,ES_AUTOHSCROLL | ES_NUMBER - CONTROL "Spin1",IDC_SPIN1,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_NOTHOUSANDS,79,235,11,14 - LTEXT "Pattern size:",IDC_STATIC,115,230,40,8 - EDITTEXT IDC_EDIT2,165,230,39,12,ES_AUTOHSCROLL | ES_NUMBER - CONTROL "Spin1",IDC_SPIN2,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_NOTHOUSANDS,196,232,11,14 + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,84,237,12 + CONTROL "Pass MIDI to active instrument plugin",IDC_MIDI_TO_PLUGIN, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,96,237,12 + GROUPBOX "MIDI Recording - Volume and Controllers",IDC_STATIC,6,120,258,78 + CONTROL "Record MIDI Note Velocity, amplify by",IDC_CHECK1, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,134,144,16 + EDITTEXT IDC_EDIT3,162,136,42,12,ES_AUTOHSCROLL | ES_NUMBER + CONTROL "",IDC_SPIN3,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_NOTHOUSANDS,186,132,11,14 + LTEXT "%",IDC_STATIC,207,138,48,8 + CONTROL "Combine MIDI Volume (CC#07) to Note Velocity",IDC_MIDIVOL_TO_NOTEVOL, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,150,237,12 + CONTROL "Record MIDI Controller changes as MIDI Macro changes in pattern",IDC_MIDI_MACRO_CONTROL, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,162,237,12 + LTEXT "Record Aftertouch Messages",IDC_STATIC,30,174,108,12,SS_CENTERIMAGE + COMBOBOX IDC_COMBO2,138,174,120,12,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + GROUPBOX "MIDI file import",IDC_STATIC,6,204,260,36 + LTEXT "Speed:",IDC_STATIC,18,222,24,8 + EDITTEXT IDC_EDIT1,48,220,39,12,ES_AUTOHSCROLL | ES_NUMBER + CONTROL "Spin1",IDC_SPIN1,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_NOTHOUSANDS,78,222,11,14 + LTEXT "Pattern Size:",IDC_STATIC,102,222,56,8 + EDITTEXT IDC_EDIT2,156,220,39,12,ES_AUTOHSCROLL | ES_NUMBER + CONTROL "Spin1",IDC_SPIN2,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_NOTHOUSANDS,186,234,11,14 END IDD_LOADRAWSAMPLE DIALOGEX 0, 0, 178, 95 @@ -2249,10 +2253,10 @@ STRINGTABLE BEGIN - ID_INDICATOR_TIME "00:00:00 [100] 200ch" + ID_INDICATOR_TIME "00:00:00 [999] 999ch" ID_INDICATOR_USER "Row 000, Col 000" - ID_INDICATOR_INFO "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" - ID_INDICATOR_XINFO "123456789|123456789|123456789|123456789|" + ID_INDICATOR_INFO "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" + ID_INDICATOR_XINFO "Chn:999; Vol:FF; Mac:F; Cut:FF; Res:FF; Pan:FF-S" END STRINGTABLE This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2012-04-21 16:58:51
|
Revision: 1251 http://modplug.svn.sourceforge.net/modplug/?rev=1251&view=rev Author: saga-games Date: 2012-04-21 16:58:44 +0000 (Sat, 21 Apr 2012) Log Message: ----------- [Mod] Prettified MIDI settings dialog a bit. [Fix] Pattern Editor: Some of the new aftertouch was broken. [Fix] Pattern Editor: Not only fade in/out was broken, general pattern amplifaction was broken as well. Modified Paths: -------------- trunk/OpenMPT/mptrack/View_pat.cpp trunk/OpenMPT/mptrack/View_pat.h trunk/OpenMPT/mptrack/mptrack.rc Modified: trunk/OpenMPT/mptrack/View_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_pat.cpp 2012-04-20 23:06:06 UTC (rev 1250) +++ trunk/OpenMPT/mptrack/View_pat.cpp 2012-04-21 16:58:44 UTC (rev 1251) @@ -3120,13 +3120,13 @@ CSoundFile *pSndFile = GetSoundFile(); - const bool useVolCol = (pSndFile->GetType() != MOD_TYPE_MOD); + const bool useVolCol = pSndFile->GetModSpecifications().HasVolCommand(VOLCMD_VOLUME); BeginWaitCursor(); PrepareUndo(m_Selection); snOldAmp = dlg.m_nFactor; - if(pSndFile->Patterns[m_nPattern]) + if(pSndFile->Patterns.IsValidPat(m_nPattern)) { m_Selection.Sanitize(pSndFile->Patterns[m_nPattern].GetNumRows(), pSndFile->GetNumChannels()); CHANNELINDEX firstChannel = m_Selection.GetStartChannel(), lastChannel = m_Selection.GetEndChannel(); @@ -3160,7 +3160,7 @@ } if(!lastChannelValid) { - if(lastChannel == 0) + if(lastChannel <= firstChannel) { // Selection too small! EndWaitCursor(); @@ -3170,14 +3170,14 @@ } // Volume memory for each channel. - vector<BYTE> chvol(lastChannel + 1, 64); + vector<uint8> chvol(lastChannel + 1, 64); for(ROWINDEX nRow = firstRow; nRow <= lastRow; nRow++) { ModCommand *m = pSndFile->Patterns[m_nPattern].GetpModCommand(nRow, firstChannel); for(CHANNELINDEX nChn = firstChannel; nChn <= lastChannel; nChn++, m++) { - if((m->command == CMD_VOLUME) && (m->param <= 64)) + if(m->command == CMD_VOLUME && m->param <= 64) { chvol[nChn] = m->param; break; @@ -3192,7 +3192,7 @@ UINT nSmp = m->instr; if(pSndFile->GetNumInstruments()) { - if((nSmp <= pSndFile->GetNumInstruments()) && (pSndFile->Instruments[nSmp])) + if(nSmp <= pSndFile->GetNumInstruments() && pSndFile->Instruments[nSmp] != nullptr) { nSmp = pSndFile->Instruments[nSmp]->Keyboard[m->note]; if(!nSmp) chvol[nChn] = 64; // hack for instruments without samples @@ -3201,7 +3201,7 @@ nSmp = 0; } } - if((nSmp) && (nSmp <= pSndFile->GetNumSamples())) + if(nSmp > 0 && nSmp <= pSndFile->GetNumSamples()) { chvol[nChn] = (BYTE)(pSndFile->GetSample(nSmp).nVolume / 4); break; @@ -3229,14 +3229,14 @@ const int cy = lastRow - firstRow + 1; // total rows (for fading) for(CHANNELINDEX nChn = firstChannel; nChn <= lastChannel; nChn++, m++) { - if(!m->volcmd == VOLCMD_NONE && m->command != CMD_VOLUME + if(m->volcmd == VOLCMD_NONE && m->command != CMD_VOLUME && m->IsNote() && m->instr) { UINT nSmp = m->instr; bool overrideSampleVol = false; if(pSndFile->GetNumInstruments()) { - if ((nSmp <= pSndFile->m_nInstruments) && (pSndFile->Instruments[nSmp])) + if(nSmp <= pSndFile->GetNumInstruments() && pSndFile->Instruments[nSmp] != nullptr) { nSmp = pSndFile->Instruments[nSmp]->Keyboard[m->note]; // hack for instruments without samples @@ -3250,7 +3250,7 @@ nSmp = 0; } } - if((nSmp) && (nSmp <= pSndFile->GetNumSamples())) + if(nSmp > 0 && (nSmp <= pSndFile->GetNumSamples())) { if(useVolCol) { @@ -3264,7 +3264,7 @@ } } - if(m->volcmd == VOLCMD_VOLUME) chvol[nChn] = (BYTE)m->vol; + if(m->volcmd == VOLCMD_VOLUME) chvol[nChn] = m->vol; if((dlg.m_bFadeIn || dlg.m_bFadeOut) && m->command != CMD_VOLUME && m->volcmd == VOLCMD_NONE) { @@ -3279,25 +3279,25 @@ } } - if (m->volcmd == VOLCMD_VOLUME) + if(m->volcmd == VOLCMD_VOLUME) { int vol = m->vol * dlg.m_nFactor; - if (dlg.m_bFadeIn) vol = (vol * (nRow+1-firstRow)) / cy; - if (dlg.m_bFadeOut) vol = (vol * (cy+firstRow-nRow)) / cy; + if(dlg.m_bFadeIn) vol = (vol * (nRow+1-firstRow)) / cy; + if(dlg.m_bFadeOut) vol = (vol * (cy+firstRow-nRow)) / cy; vol = (vol + 50) / 100; - if (vol > 64) vol = 64; + LimitMax(vol, 64); m->vol = (BYTE)vol; } if(m_Selection.ContainsHorizontal(PatternCursor(0, nChn, PatternCursor::effectColumn)) || m_Selection.ContainsHorizontal(PatternCursor(0, nChn, PatternCursor::paramColumn))) { - if((m->command == CMD_VOLUME) && (m->param <= 64)) + if(m->command == CMD_VOLUME && m->param <= 64) { int vol = m->param * dlg.m_nFactor; - if (dlg.m_bFadeIn) vol = (vol * (nRow + 1 - firstRow)) / cy; - if (dlg.m_bFadeOut) vol = (vol * (cy + firstRow - nRow)) / cy; + if(dlg.m_bFadeIn) vol = (vol * (nRow + 1 - firstRow)) / cy; + if(dlg.m_bFadeOut) vol = (vol * (cy + firstRow - nRow)) / cy; vol = (vol + 50) / 100; - if (vol > 64) vol = 64; + LimitMax(vol, 64); m->param = (BYTE)vol; } } @@ -3565,13 +3565,14 @@ // BYTE event = (dwMidiData>>16) & 0x64; //. Sample- and instrumentview handle midi mesages in their own methods. - const BYTE nByte1 = MIDIEvents::GetDataByte1FromEvent(dwMidiData); - const BYTE nByte2 = MIDIEvents::GetDataByte2FromEvent(dwMidiData); + const uint8 nByte1 = MIDIEvents::GetDataByte1FromEvent(dwMidiData); + const uint8 nByte2 = MIDIEvents::GetDataByte2FromEvent(dwMidiData); - const BYTE nNote = nByte1 + 1; // +1 is for MPT, where middle C is 61 + const uint8 nNote = nByte1 + NOTE_MIN; // +1 is for MPT, where middle C is 61 int nVol = nByte2; // At this stage nVol is a non linear value in [0;127] // Need to convert to linear in [0;64] - see below - BYTE event = MIDIEvents::GetTypeFromEvent(dwMidiData); + uint8 event = MIDIEvents::GetTypeFromEvent(dwMidiData); + uint8 channel = MIDIEvents::GetChannelFromEvent(dwMidiData); if ((event == MIDIEvents::evNoteOn) && !nVol) event = MIDIEvents::evNoteOff; //Convert event to note-off if req'd @@ -3638,7 +3639,7 @@ // Checking whether to record MIDI controller change as MIDI macro change. // Don't write this if command was already written by MIDI mapping. if((paramValue == uint8_max || pSndFile->GetType() != MOD_TYPE_MPT) && IsEditingEnabled() && (CMainFrame::GetSettings().m_dwMidiSetup & MIDISETUP_MIDIMACROCONTROL)) - { + { const bool liveRecord = IsLiveRecord(); ModCommandPos editpos = GetEditPos(*pSndFile, liveRecord); @@ -3659,21 +3660,22 @@ } default: - if(CMainFrame::GetSettings().m_dwMidiSetup & MIDISETUP_RESPONDTOPLAYCONTROLMSGS) + if(event == MIDIEvents::evSystem && CMainFrame::GetSettings().m_dwMidiSetup & MIDISETUP_RESPONDTOPLAYCONTROLMSGS) { - switch(dwMidiData & 0xFF) + // Respond to MIDI song messages + switch(channel) { - case 0xFA: //Start song + case MIDIEvents::sysStart: //Start song if(GetDocument()) GetDocument()->OnPlayerPlayFromStart(); break; - case 0xFB: //Continue song + case MIDIEvents::sysContinue: //Continue song if(GetDocument()) GetDocument()->OnPlayerPlay(); break; - case 0xFC: //Stop song + case MIDIEvents::sysStop: //Stop song if(GetDocument()) GetDocument()->OnPlayerStop(); break; @@ -3702,8 +3704,6 @@ } - - LRESULT CViewPattern::OnModViewMsg(WPARAM wParam, LPARAM lParam) //-------------------------------------------------------------- { @@ -3792,7 +3792,6 @@ { SetCurrentRow(GetCurrentRow() + m_nSpacing); } - m_dwStatus &= ~psMIDISpacingPending; } else { // -> CODE#0012 @@ -3801,9 +3800,6 @@ Sleep(0); PostMessage(WM_MOD_VIEWMSG, VIEWMSG_DOMIDISPACING, lParam); } - } else - { - m_dwStatus &= ~psMIDISpacingPending; } break; @@ -3907,12 +3903,12 @@ { case false: //no snap - SetCurrentRow(GetCurrentRow() + ((int)(upwards ? -1 : 1)) * distance, TRUE); + SetCurrentRow(GetCurrentRow() + ((int)(upwards ? -1 : 1)) * distance, true); break; case true: //snap - SetCurrentRow((((GetCurrentRow() + (int)(upwards ? -1 : 0)) / distance) + (int)(upwards ? 0 : 1)) * distance, TRUE); + SetCurrentRow((((GetCurrentRow() + (int)(upwards ? -1 : 0)) / distance) + (int)(upwards ? 0 : 1)) * distance, true); break; } @@ -4280,8 +4276,7 @@ if(target.IsPcNote()) { ENTER_PCNOTE_VALUE(v, ValueVolCol); - } - else + } else { ModCommand::VOLCMD volcmd = target.volcmd; uint16 vol = target.vol; @@ -4289,8 +4284,7 @@ { vol = ((vol * 10) + v) % 100; if (!volcmd) volcmd = VOLCMD_VOLUME; - } - else + } else switch(v+kcSetVolumeStart) { case kcSetVolumeVol: volcmd = VOLCMD_VOLUME; break; @@ -4310,12 +4304,12 @@ } UINT max = 64; - if (volcmd > VOLCMD_PANNING) + if(volcmd > VOLCMD_PANNING) { max = (pSndFile->GetType() == MOD_TYPE_XM) ? 0x0F : 9; } - if (vol > max) vol %= 10; + if(vol > max) vol %= 10; if(pSndFile->GetModSpecifications().HasVolCommand(volcmd)) { target.volcmd = volcmd; @@ -5131,7 +5125,7 @@ void CViewPattern::EnterAftertouch(int note, int atValue) //------------------------------------------------------- { - if(CMainFrame::GetSettings().aftertouchBehaviour == TrackerSettings::atDoNotRecord) + if(CMainFrame::GetSettings().aftertouchBehaviour == TrackerSettings::atDoNotRecord || !IsEditingEnabled()) { return; } @@ -5158,7 +5152,7 @@ Limit(atValue, 0, 127); ModCommand &target = GetModCommand(cursor); - ModCommand origCommand = target; + ModCommand newCommand = target; CSoundFile *pSndFile = GetSoundFile(); switch(CMainFrame::GetSettings().aftertouchBehaviour) @@ -5167,26 +5161,24 @@ // Record aftertouch messages as volume commands if(pSndFile->GetModSpecifications().HasVolCommand(VOLCMD_VOLUME)) { - if(target.volcmd == VOLCMD_NONE || target.volcmd == VOLCMD_VOLUME) + if(newCommand.volcmd == VOLCMD_NONE || newCommand.volcmd == VOLCMD_VOLUME) { - PrepareUndo(m_Cursor, m_Cursor); - target.volcmd = VOLCMD_VOLUME; - target.vol = static_cast<ModCommand::VOL>((atValue * 64 + 64) / 127); + newCommand.volcmd = VOLCMD_VOLUME; + newCommand.vol = static_cast<ModCommand::VOL>((atValue * 64 + 64) / 127); } } else if(pSndFile->GetModSpecifications().HasCommand(CMD_VOLUME)) { - if(target.command == CMD_NONE || target.command == CMD_VOLUME) + if(newCommand.command == CMD_NONE || newCommand.command == CMD_VOLUME) { - PrepareUndo(m_Cursor, m_Cursor); - target.command = CMD_VOLUME; - target.param = static_cast<ModCommand::PARAM>((atValue * 64 + 64) / 127); + newCommand.command = CMD_VOLUME; + newCommand.param = static_cast<ModCommand::PARAM>((atValue * 64 + 64) / 127); } } break; case TrackerSettings::atRecordAsMacro: // Record aftertouch messages as MIDI Macros - if(target.command == CMD_NONE || target.command == CMD_SMOOTHMIDI || target.command == CMD_MIDI) + if(newCommand.command == CMD_NONE || newCommand.command == CMD_SMOOTHMIDI || newCommand.command == CMD_MIDI) { ModCommand::COMMAND cmd = pSndFile->GetModSpecifications().HasCommand(CMD_SMOOTHMIDI) ? CMD_SMOOTHMIDI : @@ -5195,16 +5187,18 @@ if(cmd != CMD_NONE) { - PrepareUndo(m_Cursor, m_Cursor); - target.command = cmd; - target.param = static_cast<ModCommand::PARAM>(atValue); + newCommand.command = cmd; + newCommand.param = static_cast<ModCommand::PARAM>(atValue); } } break; } - if(target != origCommand) + if(target != newCommand) { + PrepareUndo(cursor, cursor); + target = newCommand; + SetModified(false); InvalidateCell(cursor); UpdateIndicator(); Modified: trunk/OpenMPT/mptrack/View_pat.h =================================================================== --- trunk/OpenMPT/mptrack/View_pat.h 2012-04-20 23:06:06 UTC (rev 1250) +++ trunk/OpenMPT/mptrack/View_pat.h 2012-04-21 16:58:44 UTC (rev 1251) @@ -118,7 +118,7 @@ psChordPlaying = 0x100, // Is a chord playing? (pretty much unused) psDragnDropEdit = 0x200, // Drag & Drop editing (?) psDragnDropping = 0x400, // Dragging a selection around - psMIDISpacingPending = 0x800, // Unused (?) + //psMIDISpacingPending = 0x800, // Unused (?) psCtrlDragSelect = 0x1000, // Creating a selection using Ctrl psShowPluginNames = 0x2000, // Show plugin names in channel headers //rewbs.patPlugName psRowSelection = 0x4000, // Selecting a whole pattern row by clicking the row numbers Modified: trunk/OpenMPT/mptrack/mptrack.rc =================================================================== --- trunk/OpenMPT/mptrack/mptrack.rc 2012-04-20 23:06:06 UTC (rev 1250) +++ trunk/OpenMPT/mptrack/mptrack.rc 2012-04-21 16:58:44 UTC (rev 1251) @@ -549,23 +549,23 @@ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,96,237,12 GROUPBOX "MIDI Recording - Volume and Controllers",IDC_STATIC,6,120,258,78 CONTROL "Record MIDI Note Velocity, amplify by",IDC_CHECK1, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,134,144,16 - EDITTEXT IDC_EDIT3,162,136,42,12,ES_AUTOHSCROLL | ES_NUMBER + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,138,144,10 + EDITTEXT IDC_EDIT3,162,137,42,12,ES_AUTOHSCROLL | ES_NUMBER CONTROL "",IDC_SPIN3,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_NOTHOUSANDS,186,132,11,14 - LTEXT "%",IDC_STATIC,207,138,48,8 + LTEXT "%",IDC_STATIC,207,139,48,8 CONTROL "Combine MIDI Volume (CC#07) to Note Velocity",IDC_MIDIVOL_TO_NOTEVOL, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,150,237,12 CONTROL "Record MIDI Controller changes as MIDI Macro changes in pattern",IDC_MIDI_MACRO_CONTROL, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,162,237,12 LTEXT "Record Aftertouch Messages",IDC_STATIC,30,174,108,12,SS_CENTERIMAGE COMBOBOX IDC_COMBO2,138,174,120,12,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - GROUPBOX "MIDI file import",IDC_STATIC,6,204,260,36 + GROUPBOX "MIDI File Import",IDC_STATIC,6,204,260,36 LTEXT "Speed:",IDC_STATIC,18,222,24,8 EDITTEXT IDC_EDIT1,48,220,39,12,ES_AUTOHSCROLL | ES_NUMBER CONTROL "Spin1",IDC_SPIN1,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_NOTHOUSANDS,78,222,11,14 LTEXT "Pattern Size:",IDC_STATIC,102,222,56,8 EDITTEXT IDC_EDIT2,156,220,39,12,ES_AUTOHSCROLL | ES_NUMBER - CONTROL "Spin1",IDC_SPIN2,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_NOTHOUSANDS,186,234,11,14 + CONTROL "Spin1",IDC_SPIN2,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_NOTHOUSANDS,180,222,11,14 END IDD_LOADRAWSAMPLE DIALOGEX 0, 0, 178, 95 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2012-04-28 13:00:55
|
Revision: 1256 http://modplug.svn.sourceforge.net/modplug/?rev=1256&view=rev Author: saga-games Date: 2012-04-28 13:00:47 +0000 (Sat, 28 Apr 2012) Log Message: ----------- [Mod] Changed help menu entries (we are not going to use a HLP file anymore). Modified Paths: -------------- trunk/OpenMPT/mptrack/CommandSet.cpp trunk/OpenMPT/mptrack/InputHandler.cpp trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mainfrm.h trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/Mptrack.h trunk/OpenMPT/mptrack/mptrack.rc Modified: trunk/OpenMPT/mptrack/CommandSet.cpp =================================================================== --- trunk/OpenMPT/mptrack/CommandSet.cpp 2012-04-27 20:05:26 UTC (rev 1255) +++ trunk/OpenMPT/mptrack/CommandSet.cpp 2012-04-28 13:00:47 UTC (rev 1256) @@ -447,7 +447,7 @@ DefineKeyCommand(kcViewMain, 1367, _T("Toggle Main View")); DefineKeyCommand(kcViewTree, 1368, _T("Toggle Tree View")); DefineKeyCommand(kcViewOptions, 1369, _T("View Options")); - DefineKeyCommand(kcHelp, 1370, _T("Help (to do)")); + DefineKeyCommand(kcHelp, 1370, _T("Help")); /* DefineKeyCommand(kcWindowNew, 1370, _T("New Window")); DefineKeyCommand(kcWindowCascade, 1371, _T("Cascade Windows")); Modified: trunk/OpenMPT/mptrack/InputHandler.cpp =================================================================== --- trunk/OpenMPT/mptrack/InputHandler.cpp 2012-04-27 20:05:26 UTC (rev 1255) +++ trunk/OpenMPT/mptrack/InputHandler.cpp 2012-04-28 13:00:47 UTC (rev 1256) @@ -514,7 +514,7 @@ case MAINVIEW: s="&Main\t"; c = kcViewMain; break; case IDD_TREEVIEW: s="&Tree\t"; c = kcViewTree; break; case ID_VIEW_OPTIONS: s="S&etup...\t"; c = kcViewOptions; break; - case ID_HELP: s="C&ontents (todo)"; c = kcHelp; break; + case ID_HELP: s="&Help"; c = kcHelp; break; case ID_PLUGIN_SETUP: s="Pl&ugin Manager...\t"; c = kcViewAddPlugin; break; case ID_CHANNEL_MANAGER: s="Ch&annel Manager...\t"; c = kcViewChannelManager; break; case ID_VIEW_SONGPROPERTIES:s="Song P&roperties...\t"; c = kcViewSongProperties; break; //rewbs.graph Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2012-04-27 20:05:26 UTC (rev 1255) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2012-04-28 13:00:47 UTC (rev 1256) @@ -112,6 +112,7 @@ ON_MESSAGE(WM_MOD_KEYCOMMAND, OnCustomKeyMsg) //rewbs.customKeys ON_COMMAND(ID_INTERNETUPDATE, OnInternetUpdate) ON_COMMAND(ID_HELP_SHOWSETTINGSFOLDER, OnShowSettingsFolder) + ON_COMMAND(ID_HELP, OnHelp) //}}AFX_MSG_MAP ON_WM_INITMENU() ON_WM_KILLFOCUS() //rewbs.fix3116 @@ -2311,14 +2312,17 @@ BOOL CMainFrame::OnInternetLink(UINT nID) //--------------------------------------- { - LPCSTR pszURL = NULL; + LPCSTR pszURL = nullptr; switch(nID) { case ID_NETLINK_MODPLUG: pszURL = "http://openmpt.org/"; break; case ID_NETLINK_TOP_PICKS: pszURL = "http://openmpt.org/top_picks"; break; } - if (pszURL) return CTrackApp::OpenURL(pszURL); + if(pszURL != nullptr) + { + return CTrackApp::OpenURL(pszURL) ? TRUE : FALSE; + } return FALSE; } @@ -2535,16 +2539,16 @@ void CMainFrame::OnShowWindow(BOOL bShow, UINT /*nStatus*/) //--------------------------------------------------------- { - static bool firstShow = true; - if (bShow && !IsWindowVisible() && firstShow) + static bool firstShow = true; + if (bShow && !IsWindowVisible() && firstShow) { - firstShow = false; + firstShow = false; WINDOWPLACEMENT wpl; if (GetPrivateProfileStruct("Display", "WindowPlacement", &wpl, sizeof(WINDOWPLACEMENT), theApp.GetConfigFileName())) { SetWindowPlacement(&wpl); } - } + } } @@ -2588,6 +2592,19 @@ } +void CMainFrame::OnHelp() +//----------------------- +{ + CString helpFile = theApp.GetAppDirPath(); + helpFile += "OpenMPT Manual.pdf"; + if(!theApp.OpenFile(helpFile)) + { + helpFile = "Could not find help file:\n" + helpFile; + Reporting::Error(helpFile); + } +} + + HMENU CMainFrame::CreateFileMenu(const size_t nMaxCount, std::vector<CString>& vPaths, const LPCTSTR pszFolderName, const uint16 nIdRangeBegin) //--------------------------------------------------------------------------------------------------------------------------------------------- { Modified: trunk/OpenMPT/mptrack/Mainfrm.h =================================================================== --- trunk/OpenMPT/mptrack/Mainfrm.h 2012-04-27 20:05:26 UTC (rev 1255) +++ trunk/OpenMPT/mptrack/Mainfrm.h 2012-04-28 13:00:47 UTC (rev 1256) @@ -651,6 +651,7 @@ afx_msg void OnViewEditHistory(); afx_msg void OnInternetUpdate(); afx_msg void OnShowSettingsFolder(); + afx_msg void OnHelp(); //}}AFX_MSG DECLARE_MESSAGE_MAP() public: Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2012-04-27 20:05:26 UTC (rev 1255) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2012-04-28 13:00:47 UTC (rev 1256) @@ -2279,20 +2279,23 @@ /////////////////////////////////////////////////////////////////////////////////// // Internet-related functions -BOOL CTrackApp::OpenURL(const LPCSTR lpszURL) +bool CTrackApp::OpenURL(const LPCSTR lpszURL) //------------------------------------------- { - if ((lpszURL) && (lpszURL[0]) && (theApp.m_pMainWnd)) + if(lpszURL != nullptr && lpszURL[0] != '\0' && theApp.m_pMainWnd) { - if (((ULONG)ShellExecute( - theApp.m_pMainWnd->m_hWnd, - "open", - lpszURL, - NULL, - NULL, - SW_SHOW)) >= 32) return TRUE; + if(reinterpret_cast<int>(ShellExecute( + theApp.m_pMainWnd->m_hWnd, + "open", + lpszURL, + NULL, + NULL, + SW_SHOW)) >= 32) + { + return true; + } } - return FALSE; + return false; } Modified: trunk/OpenMPT/mptrack/Mptrack.h =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.h 2012-04-27 20:05:26 UTC (rev 1255) +++ trunk/OpenMPT/mptrack/Mptrack.h 2012-04-28 13:00:47 UTC (rev 1256) @@ -166,9 +166,9 @@ static BOOL SaveDefaultDLSBanks(); static BOOL RemoveDLSBank(UINT nBank); static BOOL AddDLSBank(LPCSTR); - static BOOL OpenURL(const LPCSTR lpszURL); - static BOOL OpenFile(const LPCSTR file) { return OpenURL(file); }; - static BOOL OpenDirectory(const LPCSTR directory) { return OpenURL(directory); }; + static bool OpenURL(const LPCSTR lpszURL); + static bool OpenFile(const LPCSTR file) { return OpenURL(file); }; + static bool OpenDirectory(const LPCSTR directory) { return OpenURL(directory); }; static FileDlgResult ShowOpenSaveFileDialog(const bool load, const std::string defaultExtension, const std::string defaultFilename, const std::string extFilter, const std::string workingDirectory = "", const bool allowMultiSelect = false, int *filterIndex = nullptr); Modified: trunk/OpenMPT/mptrack/mptrack.rc =================================================================== --- trunk/OpenMPT/mptrack/mptrack.rc 2012-04-27 20:05:26 UTC (rev 1255) +++ trunk/OpenMPT/mptrack/mptrack.rc 2012-04-28 13:00:47 UTC (rev 1256) @@ -2125,8 +2125,7 @@ END POPUP "&Help" BEGIN - MENUITEM "&Contents", ID_HELP_FINDER - MENUITEM "&Search...", ID_HELP_SEARCH + MENUITEM "&Help...", ID_HELP MENUITEM "&Report a Bug", ID_REPORT_BUG MENUITEM SEPARATOR MENUITEM "&Example Modules", ID_EXAMPLE_MODULES This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2012-04-28 16:37:16
|
Revision: 1257 http://modplug.svn.sourceforge.net/modplug/?rev=1257&view=rev Author: saga-games Date: 2012-04-28 16:37:09 +0000 (Sat, 28 Apr 2012) Log Message: ----------- [New] Keyboard shortcuts can now be assigned to incoming MIDI CCs. Works in pattern, sample and instrument editor. (Code by coda, thanks) Modified Paths: -------------- trunk/OpenMPT/mptrack/CommandSet.cpp trunk/OpenMPT/mptrack/CommandSet.h trunk/OpenMPT/mptrack/InputHandler.cpp trunk/OpenMPT/mptrack/InputHandler.h trunk/OpenMPT/mptrack/KeyConfigDlg.cpp trunk/OpenMPT/mptrack/KeyConfigDlg.h trunk/OpenMPT/mptrack/View_ins.cpp trunk/OpenMPT/mptrack/View_pat.cpp trunk/OpenMPT/mptrack/View_smp.cpp trunk/OpenMPT/mptrack/mptrack.rc Modified: trunk/OpenMPT/mptrack/CommandSet.cpp =================================================================== --- trunk/OpenMPT/mptrack/CommandSet.cpp 2012-04-28 13:00:47 UTC (rev 1256) +++ trunk/OpenMPT/mptrack/CommandSet.cpp 2012-04-28 16:37:09 UTC (rev 1257) @@ -1878,6 +1878,7 @@ 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:"); return text; } @@ -1887,7 +1888,10 @@ { CString keyText; keyText=GetModifierText(mod); - keyText.Append(CHotKeyCtrl::GetKeyName(code, IsExtended(code))); + if(mod & HOTKEYF_MIDI) + keyText.AppendFormat("%d",code); + else + keyText.Append(CHotKeyCtrl::GetKeyName(code, IsExtended(code))); //HACK: if (keyText == "Ctrl+CTRL") keyText="Ctrl"; if (keyText == "Alt+ALT") keyText="Alt"; Modified: trunk/OpenMPT/mptrack/CommandSet.h =================================================================== --- trunk/OpenMPT/mptrack/CommandSet.h 2012-04-28 13:00:47 UTC (rev 1256) +++ trunk/OpenMPT/mptrack/CommandSet.h 2012-04-28 16:37:09 UTC (rev 1257) @@ -17,6 +17,8 @@ #define KEYMAP_VERSION 1 // Version of the .mkb format +#define HOTKEYF_MIDI 0x10 + enum InputTargetContext { kCtxUnknownContext = -1, @@ -198,7 +200,7 @@ //Pattern Editing kcStartPatternEditing, - kcStartSelect=kcStartPatternEditing, + kcStartSelect=kcStartPatternEditing, kcSelect=kcStartSelect, kcSelectWithNav, kcSelectOff, @@ -1086,9 +1088,10 @@ RAlt = 1<<5, MaxMod = 1<<6, */ - MaxMod = 15 // HOTKEYF_ALT | HOTKEYF_CONTROL | HOTKEYF_EXT | HOTKEYF_SHIFT + MaxMod = HOTKEYF_ALT | HOTKEYF_CONTROL | HOTKEYF_EXT | HOTKEYF_SHIFT | HOTKEYF_MIDI, }; + #define MAINKEYS 256 typedef CommandID KeyMap[kCtxMaxInputContexts][MaxMod][MAINKEYS][kNumKeyEvents]; //typedef CMap<long, long, CommandID, CommandID> KeyMap; Modified: trunk/OpenMPT/mptrack/InputHandler.cpp =================================================================== --- trunk/OpenMPT/mptrack/InputHandler.cpp 2012-04-28 13:00:47 UTC (rev 1256) +++ trunk/OpenMPT/mptrack/InputHandler.cpp 2012-04-28 16:37:09 UTC (rev 1257) @@ -91,35 +91,46 @@ CommandID CInputHandler::GeneralKeyEvent(InputTargetContext context, int code, WPARAM wParam , LPARAM lParam) //----------------------------------------------------------------------------------------------------------- { - CommandID executeCommand = kcNull; + CommandID executeCommand = kcNull; KeyEventType keyEventType; - if (code == HC_ACTION) { + if(code == HC_ACTION) + { //Get the KeyEventType (key up, key down, key repeat) DWORD scancode = lParam >> 16; - if ((scancode & 0xC000) == 0xC000) { + if((scancode & 0xC000) == 0xC000) + { keyEventType = kKeyEventUp; - } else if ((scancode & 0xC000) == 0x0000) { + } else if((scancode & 0xC000) == 0x0000) + { keyEventType = kKeyEventDown; - } else { + } else + { keyEventType = kKeyEventRepeat; } // Catch modifier change (ctrl, alt, shift) - Only check on keyDown or keyUp. // NB: we want to catch modifiers even when the input handler is locked - if (keyEventType == kKeyEventUp || keyEventType == kKeyEventDown) { + if(keyEventType == kKeyEventUp || keyEventType == kKeyEventDown) + { scancode =(lParam >> 16) & 0x1FF; CatchModifierChange(wParam, keyEventType, scancode); } - if (!InterceptSpecialKeys( wParam, lParam ) && !Bypass()) { + if(!InterceptSpecialKeys( wParam, lParam ) && !Bypass()) + { // only execute command when the input handler is not locked // and the input is not a consequence of special key interception. executeCommand = keyMap[context][modifierMask][wParam][keyEventType]; } } + if(code == HC_MIDI) + { + executeCommand = keyMap[context][HOTKEYF_MIDI][wParam][kKeyEventDown]; + } - if (m_pMainFrm && executeCommand != kcNull) { + if(m_pMainFrm && executeCommand != kcNull) + { m_pMainFrm->PostMessage(WM_MOD_KEYCOMMAND, executeCommand, wParam); } @@ -276,6 +287,19 @@ } +// Translate MIDI messages to shortcut commands +CommandID CInputHandler::HandleMIDIMessage(InputTargetContext context, uint32 message) +//------------------------------------------------------------------------------------ +{ + if(MIDIEvents::GetTypeFromEvent(message) == MIDIEvents::evControllerChange && MIDIEvents::GetDataByte2FromEvent(message) != 0) + { + // Only capture MIDI CCs for now. Some controllers constantly send some MIDI CCs with value 0 + // (f.e. the Roland D-50 sends CC123 whenenver releasing note keys), so we will ignore those. + return GeneralKeyEvent(context, HC_MIDI, MIDIEvents::GetDataByte1FromEvent(message), 0); + } + return kcNull; +} + //-------------------------------------------------------------- DWORD CInputHandler::GetKey(CommandID /*c*/) //------------------------------------------ Modified: trunk/OpenMPT/mptrack/InputHandler.h =================================================================== --- trunk/OpenMPT/mptrack/InputHandler.h 2012-04-28 13:00:47 UTC (rev 1256) +++ trunk/OpenMPT/mptrack/InputHandler.h 2012-04-28 16:37:09 UTC (rev 1257) @@ -10,28 +10,11 @@ #pragma once -#define END_VIEWPATTERNS 200 -#define END_CTRLPATTERNS 400 -#define END_VIEWSAMPLES 600 -#define END_CTRLSAMPLES 800 -#define END_VIEWINSTRUMENTS 1000 -#define END_CTRLINSTRUMENTS 1200 -#define END_VIEWCOMMENTS 1400 -#define END_CTRLCOMMENTS 1800 -#define END_VIEWGENERAL 2000 -#define END_CTRLGENERAL 2200 -#define END_MODDOCUMENT 2400 -#define END_MAINFRAME 2600 - //not sure why I shoved message IDs here anymore. Might want to move em. -rewbs -enum { +enum +{ WM_MOD_UPDATEPOSITION = (WM_USER+1973), - WM_MOD_DESTROYMODDOC, - WM_MOD_DESTROYPATEDIT, - WM_MOD_UPDATESOUNDBUFFER, WM_MOD_INVALIDATEPATTERNS, - WM_MOD_DESTROYSAMPLE, - WM_MOD_DESTROYINSTRUMENT, WM_MOD_ACTIVATEVIEW, WM_MOD_CHANGEVIEWCLASS, WM_MOD_UNLOCKCONTROLS, @@ -48,7 +31,13 @@ WM_MOD_RECORDPARAM, }; +// Hook codes +enum +{ + HC_MIDI = 0x8000, +}; + class CInputHandler { @@ -61,6 +50,7 @@ KeyEventType GetKeyEventType(UINT nFlags); DWORD GetKey(CommandID); bool isKeyPressHandledByTextBox(DWORD wparam); + CommandID CInputHandler::HandleMIDIMessage(InputTargetContext context, uint32 message); KeyCombination GetKey(CommandID cmd, UINT key); int GetKeyListSize(CommandID cmd); Modified: trunk/OpenMPT/mptrack/KeyConfigDlg.cpp =================================================================== --- trunk/OpenMPT/mptrack/KeyConfigDlg.cpp 2012-04-28 13:00:47 UTC (rev 1256) +++ trunk/OpenMPT/mptrack/KeyConfigDlg.cpp 2012-04-28 16:37:09 UTC (rev 1257) @@ -19,28 +19,40 @@ BEGIN_MESSAGE_MAP(CCustEdit, CEdit) ON_WM_SETFOCUS() ON_WM_KILLFOCUS() + ON_MESSAGE(WM_MOD_MIDIMSG, OnMidiMsg) END_MESSAGE_MAP() +LRESULT CCustEdit::OnMidiMsg(WPARAM dwMidiDataParam, LPARAM) +//---------------------------------------------------------- +{ + if(MIDIEvents::GetTypeFromEvent(dwMidiDataParam) == MIDIEvents::evControllerChange && MIDIEvents::GetDataByte2FromEvent(dwMidiDataParam) != 0 && isFocussed) + { + SetKey(HOTKEYF_MIDI, MIDIEvents::GetDataByte1FromEvent(dwMidiDataParam)); + m_pOptKeyDlg->OnSetKeyChoice(); + } + return 0; +} + + BOOL CCustEdit::PreTranslateMessage(MSG *pMsg) -//------------------------------------------------ +//-------------------------------------------- { - if (pMsg) + if(pMsg) { - if ((pMsg->message == WM_KEYDOWN) || (pMsg->message == WM_SYSKEYDOWN)) + if(pMsg->message == WM_KEYDOWN || pMsg->message == WM_SYSKEYDOWN) { //if (!(pMsg->lparam & 0x40000000)) { // only on first presss SetKey(CMainFrame::GetInputHandler()->GetModifierMask(), pMsg->wParam); //} return -1; // Keypress handled, don't pass on message. - } - else if ((pMsg->message == WM_KEYUP) || (pMsg->message == WM_SYSKEYUP)) + } else if(pMsg->message == WM_KEYUP || pMsg->message == WM_SYSKEYUP) { //if a key has been released but custom edit box is empty, we have probably just //navigated into the box with TAB or SHIFT-TAB. No need to set keychoice. - if (code!=0) - m_pOptKeyDlg->OnSetKeyChoice(); - } + if(code != 0) + m_pOptKeyDlg->OnSetKeyChoice(); + } } return CEdit::PreTranslateMessage(pMsg); } @@ -65,7 +77,7 @@ mod = inMod; code = inCode; //Setup display - SetWindowText(CMainFrame::GetInputHandler()->activeCommandSet->GetKeyText(mod, code)); + SetWindowText(CMainFrame::GetInputHandler()->activeCommandSet->GetKeyText(mod, code)); } @@ -74,12 +86,14 @@ CEdit::OnSetFocus(pOldWnd); //lock the input handler CMainFrame::GetInputHandler()->Bypass(true); + isFocussed = true; } void CCustEdit::OnKillFocus(CWnd* pNewWnd) { CEdit::OnKillFocus(pNewWnd); //unlock the input handler CMainFrame::GetInputHandler()->Bypass(false); + isFocussed = false; } @@ -151,6 +165,8 @@ m_bModified = false; m_bChoiceModified = false; m_sFullPathName = CMainFrame::GetSettings().m_szKbdFile; + + CMainFrame::GetMainFrame()->SetMidiRecordWnd(m_eCustHotKey.m_hWnd); plocalCmdSet = new CCommandSet(); plocalCmdSet->Copy(CMainFrame::GetInputHandler()->activeCommandSet); Modified: trunk/OpenMPT/mptrack/KeyConfigDlg.h =================================================================== --- trunk/OpenMPT/mptrack/KeyConfigDlg.h 2012-04-28 13:00:47 UTC (rev 1256) +++ trunk/OpenMPT/mptrack/KeyConfigDlg.h 2012-04-28 16:37:09 UTC (rev 1257) @@ -64,17 +64,18 @@ }; -//===================================== +//=========================== class CCustEdit: public CEdit -//===================================== +//=========================== { protected: - COptionsKeyboard* m_pOptKeyDlg; + COptionsKeyboard *m_pOptKeyDlg; HWND m_hParent; UINT m_nCtrlId; + bool isFocussed; public: - CCustEdit() { m_hParent = NULL; } + CCustEdit() : m_hParent(nullptr), isFocussed(false) { } UINT mod; UINT code; VOID SetParent(HWND h, UINT nID, COptionsKeyboard* pOKD) { m_hParent = h; m_nCtrlId = nID; m_pOptKeyDlg = pOKD;} @@ -84,6 +85,7 @@ DECLARE_MESSAGE_MAP() afx_msg void OnSetFocus(CWnd* pOldWnd); afx_msg void OnKillFocus(CWnd* pNewWnd); + afx_msg LRESULT OnMidiMsg(WPARAM, LPARAM); }; //========================================== @@ -149,7 +151,7 @@ afx_msg void OnSave(); afx_msg void OnClearLog(); afx_msg void OnRestoreDefaultKeymap(); - DECLARE_MESSAGE_MAP(); + DECLARE_MESSAGE_MAP(); public: afx_msg void OnDestroy(); }; Modified: trunk/OpenMPT/mptrack/View_ins.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_ins.cpp 2012-04-28 13:00:47 UTC (rev 1256) +++ trunk/OpenMPT/mptrack/View_ins.cpp 2012-04-28 16:37:09 UTC (rev 1257) @@ -2155,18 +2155,32 @@ BYTE midiByte1 = MIDIEvents::GetDataByte1FromEvent(dwMidiData); BYTE midiByte2 = MIDIEvents::GetDataByte2FromEvent(dwMidiData); - CSoundFile* pSndFile = (pModDoc) ? pModDoc->GetSoundFile() : NULL; - if (!pSndFile) return 0; + CSoundFile* pSndFile = (pModDoc) ? pModDoc->GetSoundFile() : nullptr; + if(!pSndFile) return 0; - const BYTE nNote = midiByte1 + 1; // +1 is for MPT, where middle C is 61 + const BYTE nNote = midiByte1 + NOTE_MIN; int nVol = midiByte2; MIDIEvents::EventType event = MIDIEvents::GetTypeFromEvent(dwMidiData); if((event == MIDIEvents::evNoteOn) && !nVol) event = MIDIEvents::evNoteOff; //Convert event to note-off if req'd BYTE mappedIndex = 0, paramValue = 0; uint32 paramIndex = 0; - if(pSndFile->GetMIDIMapper().OnMIDImsg(dwMidiData, mappedIndex, paramIndex, paramValue)) + bool captured = pSndFile->GetMIDIMapper().OnMIDImsg(dwMidiData, mappedIndex, paramIndex, paramValue); + + // Handle MIDI messages assigned to shortcuts + CInputHandler *ih = CMainFrame::GetMainFrame()->GetInputHandler(); + if(ih->HandleMIDIMessage(kCtxViewInstruments, dwMidiData) != kcNull + || ih->HandleMIDIMessage(kCtxAllContexts, dwMidiData) != kcNull) + { + // Mapped to a command, no need to pass message on. + captured = true; + } + + if(captured) + { + // Event captured by MIDI mapping or shortcut, no need to pass message on. return 0; + } switch(event) { Modified: trunk/OpenMPT/mptrack/View_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_pat.cpp 2012-04-28 13:00:47 UTC (rev 1256) +++ trunk/OpenMPT/mptrack/View_pat.cpp 2012-04-28 16:37:09 UTC (rev 1257) @@ -3543,10 +3543,10 @@ CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); CModDoc *pModDoc = GetDocument(); - if ((!pModDoc) || (!pMainFrm)) return 0; + if(pModDoc == nullptr || pMainFrm == nullptr) return 0; - CSoundFile *pSndFile = pModDoc->GetSoundFile(); - if(!pSndFile) return 0; + CSoundFile *pSndFile = GetSoundFile(); + if(pSndFile == nullptr) return 0; //Midi message from our perspective: // +---------------------------+---------------------------+-------------+-------------+ @@ -3568,7 +3568,7 @@ const uint8 nByte1 = MIDIEvents::GetDataByte1FromEvent(dwMidiData); const uint8 nByte2 = MIDIEvents::GetDataByte2FromEvent(dwMidiData); - const uint8 nNote = nByte1 + NOTE_MIN; // +1 is for MPT, where middle C is 61 + const uint8 nNote = nByte1 + NOTE_MIN; int nVol = nByte2; // At this stage nVol is a non linear value in [0;127] // Need to convert to linear in [0;64] - see below uint8 event = MIDIEvents::GetTypeFromEvent(dwMidiData); @@ -3580,10 +3580,20 @@ // Handle MIDI mapping. uint8 mappedIndex = uint8_max, paramValue = uint8_max; uint32 paramIndex = 0; - const bool bCaptured = pSndFile->GetMIDIMapper().OnMIDImsg(dwMidiData, mappedIndex, paramIndex, paramValue); + bool captured = pSndFile->GetMIDIMapper().OnMIDImsg(dwMidiData, mappedIndex, paramIndex, paramValue); + + // Handle MIDI messages assigned to shortcuts + CInputHandler *ih = pMainFrm->GetInputHandler(); + if(ih->HandleMIDIMessage(static_cast<InputTargetContext>(kCtxViewPatterns + 1 + m_Cursor.GetColumnType()), dwMidiData) != kcNull + || ih->HandleMIDIMessage(kCtxAllContexts, dwMidiData) != kcNull) + { + // Mapped to a command, no need to pass message on. + captured = true; + } + // Write parameter control commands if needed. - if (paramValue != uint8_max && IsEditingEnabled() && pSndFile->GetType() == MOD_TYPE_MPT) + if(paramValue != uint8_max && IsEditingEnabled() && pSndFile->GetType() == MOD_TYPE_MPT) { const bool liveRecord = IsLiveRecord(); @@ -3596,8 +3606,11 @@ pMainFrm->ThreadSafeSetModified(pModDoc); } - if (bCaptured) + if(captured) + { + // Event captured by MIDI mapping or shortcut, no need to pass message on. return 0; + } switch(event) { Modified: trunk/OpenMPT/mptrack/View_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_smp.cpp 2012-04-28 13:00:47 UTC (rev 1256) +++ trunk/OpenMPT/mptrack/View_smp.cpp 2012-04-28 16:37:09 UTC (rev 1257) @@ -2574,11 +2574,20 @@ CSoundFile* pSndFile = (pModDoc) ? pModDoc->GetSoundFile() : NULL; if (!pSndFile) return 0; - const BYTE nNote = midibyte1 + 1; // +1 is for MPT, where middle C is 61 + const BYTE nNote = midibyte1 + NOTE_MIN; int nVol = midibyte2; BYTE event = MIDIEvents::GetTypeFromEvent(dwMidiData); if ((event == MIDIEvents::evNoteOn) && !nVol) event = MIDIEvents::evNoteOff; //Convert event to note-off if req'd + // Handle MIDI messages assigned to shortcuts + CInputHandler *ih = CMainFrame::GetMainFrame()->GetInputHandler(); + if(ih->HandleMIDIMessage(kCtxViewSamples, dwMidiData) != kcNull + || ih->HandleMIDIMessage(kCtxAllContexts, dwMidiData) != kcNull) + { + // Mapped to a command, no need to pass message on. + return 0; + } + switch(event) { case MIDIEvents::evNoteOff: // Note Off Modified: trunk/OpenMPT/mptrack/mptrack.rc =================================================================== --- trunk/OpenMPT/mptrack/mptrack.rc 2012-04-28 13:00:47 UTC (rev 1256) +++ trunk/OpenMPT/mptrack/mptrack.rc 2012-04-28 16:37:09 UTC (rev 1257) @@ -467,7 +467,7 @@ LTEXT "Select category:",IDC_STATIC,7,5,131,11 COMBOBOX IDC_KEYCATEGORY,5,16,133,204,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP LISTBOX IDC_COMMAND_LIST,5,32,133,228,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP - COMBOBOX IDC_CHOICECOMBO,150,18,72,51,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_CHOICECOMBO,150,18,72,51,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP LTEXT "Key:",IDC_STATIC,150,38,16,8 EDITTEXT IDC_CUSTHOTKEY,168,36,54,13,ES_AUTOHSCROLL CONTROL "On Key Down",IDC_CHECKKEYDOWN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,150,54,66,8 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2012-04-28 16:39:56
|
Revision: 1258 http://modplug.svn.sourceforge.net/modplug/?rev=1258&view=rev Author: saga-games Date: 2012-04-28 16:39:50 +0000 (Sat, 28 Apr 2012) Log Message: ----------- [Fix] Pattern Editor: If undoing an edit switches to another pattern, OpenMPT tries to find a linked order for this pattern, so that continuous scroll keeps working (http://bugs.openmpt.org/view.php?id=189), [Mod] OpenMPT: Version is now 1.20.00.87 Modified Paths: -------------- trunk/OpenMPT/mptrack/View_pat.cpp trunk/OpenMPT/mptrack/version.h Modified: trunk/OpenMPT/mptrack/View_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_pat.cpp 2012-04-28 16:37:09 UTC (rev 1257) +++ trunk/OpenMPT/mptrack/View_pat.cpp 2012-04-28 16:39:50 UTC (rev 1258) @@ -3095,14 +3095,23 @@ CModDoc *pModDoc = GetDocument(); if (pModDoc && IsEditingEnabled_bmsg()) { - PATTERNINDEX nPat = pModDoc->GetPatternUndo().Undo(); - if (nPat < pModDoc->GetSoundFile()->Patterns.Size()) + PATTERNINDEX pat = pModDoc->GetPatternUndo().Undo(); + if(pat < pModDoc->GetSoundFile()->Patterns.Size()) { pModDoc->SetModified(); - if (nPat != m_nPattern) - SetCurrentPattern(nPat); - else + if(pat != m_nPattern) + { + // Find pattern in sequence. + ORDERINDEX matchingOrder = GetSoundFile()->Order.FindOrder(pat, static_cast<ORDERINDEX>(SendCtrlMessage(CTRLMSG_GETCURRENTORDER))); + if(matchingOrder != ORDERINDEX_INVALID) + { + SendCtrlMessage(CTRLMSG_SETCURRENTORDER, matchingOrder); + } + SetCurrentPattern(pat); + } else + { InvalidatePattern(true); + } } } } Modified: trunk/OpenMPT/mptrack/version.h =================================================================== --- trunk/OpenMPT/mptrack/version.h 2012-04-28 16:37:09 UTC (rev 1257) +++ trunk/OpenMPT/mptrack/version.h 2012-04-28 16:39:50 UTC (rev 1258) @@ -19,7 +19,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 20 #define VER_MINOR 00 -#define VER_MINORMINOR 86 +#define VER_MINORMINOR 87 //Creates version number from version parts that appears in version string. //For example MAKE_VERSION_NUMERIC(1,17,02,28) gives version number of This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2012-05-10 16:31:57
|
Revision: 1267 http://modplug.svn.sourceforge.net/modplug/?rev=1267&view=rev Author: saga-games Date: 2012-05-10 16:31:50 +0000 (Thu, 10 May 2012) Log Message: ----------- [Fix] MFC hardcodes F1 to help if ID_HELP is used (tx Diamond). [Mod] Mod Conversion: Don't write pattern breaks if E60 is on first row only. [Imp] After selecting a column through a double click, it is possible to extend this selection to other channels by keeping the mouse button down after the second click (http://bugs.openmpt.org/view.php?id=245). [Mod] OpenMPT: Version is now 1.20.01.01 Modified Paths: -------------- trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/ModConvert.cpp trunk/OpenMPT/mptrack/View_pat.cpp trunk/OpenMPT/mptrack/View_pat.h trunk/OpenMPT/mptrack/mptrack.rc trunk/OpenMPT/mptrack/resource.h trunk/OpenMPT/mptrack/version.h Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2012-05-10 16:26:32 UTC (rev 1266) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2012-05-10 16:31:50 UTC (rev 1267) @@ -82,10 +82,7 @@ ON_COMMAND(ID_VIEW_MIDIMAPPING, OnViewMIDIMapping) //ON_COMMAND(ID_HELP, CMDIFrameWnd::OnHelp) ON_COMMAND(ID_VIEW_SONGPROPERTIES, OnSongProperties) - ON_COMMAND(ID_HELP_FINDER, CMDIFrameWnd::OnHelpFinder) ON_COMMAND(ID_REPORT_BUG, OnReportBug) //rewbs.reportBug - ON_COMMAND(ID_CONTEXT_HELP, CMDIFrameWnd::OnContextHelp) - ON_COMMAND(ID_DEFAULT_HELP, CMDIFrameWnd::OnHelpFinder) ON_COMMAND(ID_NEXTOCTAVE, OnNextOctave) ON_COMMAND(ID_PREVOCTAVE, OnPrevOctave) ON_COMMAND_RANGE(ID_FILE_OPENTEMPLATE, ID_FILE_OPENTEMPLATE_LASTINRANGE, OnOpenTemplateModule) @@ -112,7 +109,7 @@ ON_MESSAGE(WM_MOD_KEYCOMMAND, OnCustomKeyMsg) //rewbs.customKeys ON_COMMAND(ID_INTERNETUPDATE, OnInternetUpdate) ON_COMMAND(ID_HELP_SHOWSETTINGSFOLDER, OnShowSettingsFolder) - ON_COMMAND(ID_HELP, OnHelp) + ON_COMMAND(ID_HELPSHOW, OnHelp) //}}AFX_MSG_MAP ON_WM_INITMENU() ON_WM_KILLFOCUS() //rewbs.fix3116 @@ -203,7 +200,7 @@ static UINT indicators[] = { - ID_SEPARATOR, // status line indicator + ID_SEPARATOR, // status line indicator ID_INDICATOR_XINFO, //rewbs.xinfo ID_INDICATOR_INFO, ID_INDICATOR_USER, @@ -1357,12 +1354,6 @@ } else { pModDoc->SetPause(FALSE); - //rewbs.fix3185: removed this check so play position stays on last pattern if song ends and loop is off. - //Otherwise play from cursor screws up. - //if (pSndFile->GetCurrentPos() + 2 >= pSndFile->GetMaxPosition()) pSndFile->SetCurrentPos(0); - - // Tentative fix for http://bugs.openmpt.org/view.php?id=11 - Moved following line out of any condition checks - //pSndFile->SetRepeatCount((gbLoopSong) ? -1 : 0); } } pSndFile->SetRepeatCount((GetSettings().gbLoopSong) ? -1 : 0); @@ -1826,7 +1817,7 @@ if (pModDoc == m_pModPlaying) PauseMod(); // Make sure that OnTimer() won't try to set the closed document modified anymore. - if (pModDoc == m_pJustModifiedDoc) m_pJustModifiedDoc = 0; + if (pModDoc == m_pJustModifiedDoc) m_pJustModifiedDoc = nullptr; m_wndTree.OnDocumentClosed(pModDoc); } @@ -2380,7 +2371,7 @@ case kcFileNew: theApp.OnFileNew(); break; case kcFileOpen: theApp.OnFileOpen(); break; case kcMidiRecord: OnMidiRecord(); break; - case kcHelp: CMDIFrameWnd::OnHelp(); break; + case kcHelp: OnHelp(); break; case kcViewAddPlugin: OnPluginManager(); break; case kcViewChannelManager: OnChannelManager(); break; case kcViewMIDImapping: OnViewMIDIMapping(); break; Modified: trunk/OpenMPT/mptrack/ModConvert.cpp =================================================================== --- trunk/OpenMPT/mptrack/ModConvert.cpp 2012-05-10 16:26:32 UTC (rev 1266) +++ trunk/OpenMPT/mptrack/ModConvert.cpp 2012-05-10 16:31:50 UTC (rev 1267) @@ -180,12 +180,14 @@ bool addBreak = false; // When converting to XM, avoid the E60 bug. CHANNELINDEX channel = 0; + ROWINDEX row = 0; for (UINT len = m_SndFile.Patterns[nPat].GetNumRows() * m_SndFile.GetNumChannels(); len; m++, len--, channel++) { if(channel >= GetNumChannels()) { channel = 0; + row++; } m->Convert(nOldType, nNewType); @@ -233,7 +235,7 @@ switch(m->command) { case CMD_MODCMDEX: - if((m->param & 0xF0) == 0x60) + if(m->param == 0x60 && row > 0) { addBreak = true; } Modified: trunk/OpenMPT/mptrack/View_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_pat.cpp 2012-05-10 16:26:32 UTC (rev 1266) +++ trunk/OpenMPT/mptrack/View_pat.cpp 2012-05-10 16:31:50 UTC (rev 1267) @@ -1225,6 +1225,8 @@ if((CMainFrame::GetSettings().m_dwPatternSetup & PATTERN_DBLCLICKSELECT)) { OnSelectCurrentColumn(); + m_dwStatus |= psChannelSelection; + m_bDragging = true; return; } else { @@ -1246,7 +1248,7 @@ m_bDragging = false; m_bInItemRect = false; ReleaseCapture(); - m_dwStatus &= ~(psMouseDragSelect|psRowSelection); + m_dwStatus &= ~(psMouseDragSelect | psRowSelection | psChannelSelection); // Drag & Drop Editing if (m_dwStatus & psDragnDropEdit) { @@ -1544,15 +1546,31 @@ } } - if ((m_dwStatus & psRowSelection) /*&& (point.x < m_szHeader.cx)*/ && (point.y > m_szHeader.cy)) + if((m_dwStatus & psChannelSelection)) { + // Double-clicked a pattern cell to select whole channel. + // Continue dragging to select more channels. + const CSoundFile *pSndFile = GetSoundFile(); + const ROWINDEX lastRow = pSndFile->Patterns[m_nPattern].GetNumRows() - 1; + + CHANNELINDEX startChannel = m_Cursor.GetChannel(); + CHANNELINDEX endChannel = GetPositionFromPoint(point).GetChannel(); + + m_StartSel = PatternCursor(0, startChannel, (startChannel <= endChannel ? PatternCursor::firstColumn : PatternCursor::lastColumn)); + PatternCursor endSel = PatternCursor(lastRow, endChannel, (startChannel <= endChannel ? PatternCursor::lastColumn : PatternCursor::firstColumn)); + + DragToSel(endSel, true, false, false); + + } else if((m_dwStatus & psRowSelection) && point.y > m_szHeader.cy) + { // Mark row number => mark whole row (continue) InvalidateSelection(); PatternCursor cursor(GetPositionFromPoint(point)); cursor.SetColumn(GetDocument()->GetNumChannels() - 1, PatternCursor::lastColumn); DragToSel(cursor, false, true, false); - } else if (m_dwStatus & psMouseDragSelect) + + } else if(m_dwStatus & psMouseDragSelect) { PatternCursor cursor(GetPositionFromPoint(point)); Modified: trunk/OpenMPT/mptrack/View_pat.h =================================================================== --- trunk/OpenMPT/mptrack/View_pat.h 2012-05-10 16:26:32 UTC (rev 1266) +++ trunk/OpenMPT/mptrack/View_pat.h 2012-05-10 16:31:50 UTC (rev 1267) @@ -123,6 +123,7 @@ psCtrlDragSelect = 0x1000, // Creating a selection using Ctrl psShowPluginNames = 0x2000, // Show plugin names in channel headers psRowSelection = 0x4000, // Selecting a whole pattern row by clicking the row numbers + psChannelSelection = 0x8000, // Double-clicked pattern to select a whole channel }; CFastBitmap m_Dib; Modified: trunk/OpenMPT/mptrack/mptrack.rc =================================================================== --- trunk/OpenMPT/mptrack/mptrack.rc 2012-05-10 16:26:32 UTC (rev 1266) +++ trunk/OpenMPT/mptrack/mptrack.rc 2012-05-10 16:31:50 UTC (rev 1267) @@ -2125,7 +2125,7 @@ END POPUP "&Help" BEGIN - MENUITEM "&Help...", ID_HELP + MENUITEM "&Help...", ID_HELPSHOW MENUITEM "&Report a Bug", ID_REPORT_BUG MENUITEM SEPARATOR MENUITEM "&Example Modules", ID_EXAMPLE_MODULES Modified: trunk/OpenMPT/mptrack/resource.h =================================================================== --- trunk/OpenMPT/mptrack/resource.h 2012-05-10 16:26:32 UTC (rev 1266) +++ trunk/OpenMPT/mptrack/resource.h 2012-05-10 16:31:50 UTC (rev 1267) @@ -1211,6 +1211,7 @@ // From here: Command range [ID_PLUGINEDITOR_EDIT_BASE, ID_PLUGINEDITOR_EDIT_BASE + NUM_PLUGINEDITOR_PARAMETERS] #define ID_HELP_SHOWSETTINGSFOLDER 44600 #define ID_FILE_CLOSEALL 44601 +#define ID_HELPSHOW 44602 // Next default values for new objects // @@ -1218,7 +1219,7 @@ #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_3D_CONTROLS 1 #define _APS_NEXT_RESOURCE_VALUE 535 -#define _APS_NEXT_COMMAND_VALUE 44602 +#define _APS_NEXT_COMMAND_VALUE 44603 #define _APS_NEXT_CONTROL_VALUE 2439 #define _APS_NEXT_SYMED_VALUE 901 #endif Modified: trunk/OpenMPT/mptrack/version.h =================================================================== --- trunk/OpenMPT/mptrack/version.h 2012-05-10 16:26:32 UTC (rev 1266) +++ trunk/OpenMPT/mptrack/version.h 2012-05-10 16:31:50 UTC (rev 1267) @@ -19,7 +19,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 20 #define VER_MINOR 01 -#define VER_MINORMINOR 00 +#define VER_MINORMINOR 01 //Creates version number from version parts that appears in version string. //For example MAKE_VERSION_NUMERIC(1,17,02,28) gives version number of This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2012-05-18 13:32:23
|
Revision: 1274 http://modplug.svn.sourceforge.net/modplug/?rev=1274&view=rev Author: saga-games Date: 2012-05-18 13:32:12 +0000 (Fri, 18 May 2012) Log Message: ----------- [Fix] Pattern Editor: Follow Song is ignored if making a channel selection (just like with all other drag modes) Modified Paths: -------------- trunk/OpenMPT/mptrack/View_pat.cpp trunk/OpenMPT/mptrack/View_pat.h Modified: trunk/OpenMPT/mptrack/View_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_pat.cpp 2012-05-17 12:00:13 UTC (rev 1273) +++ trunk/OpenMPT/mptrack/View_pat.cpp 2012-05-18 13:32:12 UTC (rev 1274) @@ -3391,7 +3391,8 @@ m_pEffectVis->SetPlayCursor(nPat, nRow); } - if ((m_dwStatus & (psFollowSong|psDragVScroll|psDragHScroll|psMouseDragSelect|psRowSelection)) == psFollowSong) + // Don't follow song if user drags selections or scrollbars. + if((m_dwStatus & (psFollowSong | psDragActive)) == psFollowSong) { if (nPat < pSndFile->Patterns.Size()) { Modified: trunk/OpenMPT/mptrack/View_pat.h =================================================================== --- trunk/OpenMPT/mptrack/View_pat.h 2012-05-17 12:00:13 UTC (rev 1273) +++ trunk/OpenMPT/mptrack/View_pat.h 2012-05-18 13:32:12 UTC (rev 1274) @@ -124,6 +124,9 @@ psShowPluginNames = 0x2000, // Show plugin names in channel headers psRowSelection = 0x4000, // Selecting a whole pattern row by clicking the row numbers psChannelSelection = 0x8000, // Double-clicked pattern to select a whole channel + + // All possible drag flags, to test if user is dragging a selection or a scrollbar + psDragActive = psDragVScroll | psDragHScroll | psMouseDragSelect | psRowSelection | psChannelSelection, }; CFastBitmap m_Dib; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2012-06-07 13:59:13
|
Revision: 1294 http://modplug.svn.sourceforge.net/modplug/?rev=1294&view=rev Author: saga-games Date: 2012-06-07 13:59:06 +0000 (Thu, 07 Jun 2012) Log Message: ----------- [Mod] Instrument Editor: When right-clicking on an envelope point, "insert point" will now insert the new point a tick to the right instead of inserting no point at all. [Mod] OpenMPT: Version is now 1.20.01.06 Modified Paths: -------------- trunk/OpenMPT/mptrack/View_ins.cpp trunk/OpenMPT/mptrack/version.h Modified: trunk/OpenMPT/mptrack/View_ins.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_ins.cpp 2012-06-07 13:58:15 UTC (rev 1293) +++ trunk/OpenMPT/mptrack/View_ins.cpp 2012-06-07 13:59:06 UTC (rev 1294) @@ -1014,6 +1014,7 @@ return envelope->Values[EnvGetReleaseNode()]; } + WORD CViewInstrument::EnvGetReleaseNodeTick() //------------------------------------------- { @@ -1022,6 +1023,7 @@ return envelope->Ticks[EnvGetReleaseNode()]; } + bool CViewInstrument::EnvRemovePoint(UINT nPoint) //--------------------------------------------- { @@ -1914,7 +1916,13 @@ void CViewInstrument::OnEnvInsertPoint() //-------------------------------------- { - EnvInsertPoint(ScreenToTick(m_ptMenu.x), ScreenToValue(m_ptMenu.y)); + const int tick = ScreenToTick(m_ptMenu.x), value = ScreenToValue(m_ptMenu.y); + if(!EnvInsertPoint(tick, value)) + { + // Couldn't insert point, maybe because there's already a point at this tick + // => Try next tick + EnvInsertPoint(tick + 1, value); + } } Modified: trunk/OpenMPT/mptrack/version.h =================================================================== --- trunk/OpenMPT/mptrack/version.h 2012-06-07 13:58:15 UTC (rev 1293) +++ trunk/OpenMPT/mptrack/version.h 2012-06-07 13:59:06 UTC (rev 1294) @@ -19,7 +19,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 20 #define VER_MINOR 01 -#define VER_MINORMINOR 05 +#define VER_MINORMINOR 06 //Creates version number from version parts that appears in version string. //For example MAKE_VERSION_NUMERIC(1,17,02,28) gives version number of This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2012-06-08 19:36:37
|
Revision: 1295 http://modplug.svn.sourceforge.net/modplug/?rev=1295&view=rev Author: saga-games Date: 2012-06-08 19:36:29 +0000 (Fri, 08 Jun 2012) Log Message: ----------- [Ref] Replaced some CArrays with vectors [Mod] Pattern Editor: Interpolation and transpose context menu items have been moved to sub menus. Modified Paths: -------------- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp trunk/OpenMPT/mptrack/AbstractVstEditor.h trunk/OpenMPT/mptrack/AutoSaver.cpp trunk/OpenMPT/mptrack/AutoSaver.h trunk/OpenMPT/mptrack/MoveFXSlotDialog.cpp trunk/OpenMPT/mptrack/MoveFXSlotDialog.h trunk/OpenMPT/mptrack/View_gen.cpp trunk/OpenMPT/mptrack/View_gen.h trunk/OpenMPT/mptrack/View_pat.cpp trunk/OpenMPT/mptrack/View_pat.h trunk/OpenMPT/mptrack/Vstplug.cpp trunk/OpenMPT/mptrack/Vstplug.h trunk/OpenMPT/mptrack/mptrack_08.vcproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters Removed Paths: ------------- trunk/OpenMPT/mptrack/ArrayUtils.cpp trunk/OpenMPT/mptrack/ArrayUtils.h Modified: trunk/OpenMPT/mptrack/AbstractVstEditor.cpp =================================================================== --- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2012-06-07 13:59:06 UTC (rev 1294) +++ trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2012-06-08 19:36:29 UTC (rev 1295) @@ -55,8 +55,6 @@ m_pMacroMenu = new CMenu(); m_pPresetMenu = new CMenu(); - m_pPresetMenuGroup.SetSize(0); - m_pOptionsMenu = new CMenu(); m_pMenu->LoadMenu(IDR_VSTMENU); @@ -86,15 +84,15 @@ delete m_pMacroMenu; delete m_pOptionsMenu; - for (int i=0; i<m_pPresetMenuGroup.GetSize(); i++) + for(size_t i = 0; i < m_pPresetMenuGroup.size(); i++) { - if (m_pPresetMenuGroup[i]->m_hMenu) + if(m_pPresetMenuGroup[i]->m_hMenu) { m_pPresetMenuGroup[i]->DestroyMenu(); delete m_pPresetMenuGroup[i]; } } - m_pPresetMenuGroup.RemoveAll(); + m_pPresetMenuGroup.clear(); m_pVstPlugin->m_pEditor = NULL; m_pVstPlugin = NULL; @@ -393,11 +391,11 @@ long curProg = m_pVstPlugin->GetCurrentProgram(); if (m_pPresetMenu->m_hMenu) // We rebuild menu from scratch - { // So remove any exiting menus... - if (curProg == m_nCurProg) //.. unless menu exists and is accurate, + { // So remove any exiting menus... + if (curProg == m_nCurProg) //.. unless menu exists and is accurate, return; //in which case we are done. - for (int i=0; i<m_pPresetMenuGroup.GetSize(); i++) + for(size_t i = 0; i < m_pPresetMenuGroup.size(); i++) { //Destroy any submenus if (m_pPresetMenuGroup[i]->m_hMenu) @@ -406,8 +404,7 @@ delete m_pPresetMenuGroup[i]; } } - m_pPresetMenuGroup.RemoveAll(); - m_pPresetMenuGroup.SetSize(0); + m_pPresetMenuGroup.clear(); m_pPresetMenu->DestroyMenu(); //Destroy Factory preset menu m_pMenu->DeleteMenu(1, MF_BYPOSITION); @@ -423,7 +420,7 @@ if(numSubMenus > 1) { // Create sub menus if necessary - m_pPresetMenuGroup.SetSize(numSubMenus); + m_pPresetMenuGroup.resize(numSubMenus); for(int bank = 0, prog = 1; bank < numSubMenus; bank++, prog += PRESETS_PER_GROUP) { m_pPresetMenuGroup[bank] = new CMenu(); @@ -490,19 +487,19 @@ CString name; - CArray<CVstPlugin*, CVstPlugin*> inputPlugs; + vector<CVstPlugin *> inputPlugs; m_pVstPlugin->GetInputPlugList(inputPlugs); - for (int nPlug=0; nPlug<inputPlugs.GetSize(); nPlug++) + for(size_t nPlug=0; nPlug < inputPlugs.size(); nPlug++) { name.Format("FX%02d: %s", inputPlugs[nPlug]->m_nSlot + 1, inputPlugs[nPlug]->m_pMixStruct->GetName()); m_pInputMenu->AppendMenu(MF_STRING, ID_PLUGSELECT + inputPlugs[nPlug]->m_nSlot, name); } - CArray<UINT, UINT> inputChannels; + vector<CHANNELINDEX> inputChannels; m_pVstPlugin->GetInputChannelList(inputChannels); - for (int nChn=0; nChn<inputChannels.GetSize(); nChn++) + for (size_t nChn=0; nChn<inputChannels.size(); nChn++) { - if (nChn==0 && inputPlugs.GetSize()) + if (nChn==0 && inputPlugs.size()) { m_pInputMenu->AppendMenu(MF_SEPARATOR); } @@ -510,12 +507,12 @@ m_pInputMenu->AppendMenu(MF_STRING, NULL, name); } - CArray<UINT, UINT> inputInstruments; + vector<INSTRUMENTINDEX> inputInstruments; m_pVstPlugin->GetInputInstrumentList(inputInstruments); - for(int nIns = 0; nIns<inputInstruments.GetSize(); nIns++) + for(size_t nIns = 0; nIns<inputInstruments.size(); nIns++) { bool checked = false; - if (nIns==0 && (inputPlugs.GetSize() || inputChannels.GetSize())) + if (nIns==0 && (inputPlugs.size() || inputChannels.size())) { m_pInputMenu->AppendMenu(MF_SEPARATOR); } @@ -524,9 +521,9 @@ m_pInputMenu->AppendMenu(MF_STRING|(checked?MF_CHECKED:0), ID_SELECTINST+inputInstruments[nIns], name); } - if ((inputPlugs.GetSize() == 0) && - (inputChannels.GetSize() == 0) && - (inputInstruments.GetSize() == 0)) + if ((inputPlugs.size() == 0) && + (inputChannels.size() == 0) && + (inputInstruments.size() == 0)) { m_pInputMenu->AppendMenu(MF_STRING|MF_GRAYED, NULL, "None"); } @@ -549,11 +546,11 @@ m_pOutputMenu->CreatePopupMenu(); } - CArray<CVstPlugin*, CVstPlugin*> outputPlugs; + vector<CVstPlugin *> outputPlugs; m_pVstPlugin->GetOutputPlugList(outputPlugs); CString name; - for (int nPlug = 0; nPlug < outputPlugs.GetSize(); nPlug++) + for (size_t nPlug = 0; nPlug < outputPlugs.size(); nPlug++) { if (outputPlugs[nPlug] != nullptr) { @@ -696,9 +693,9 @@ } */ //Then just take the first instrument that points to this plug.. - CArray<UINT, UINT> plugInstrumentList; + vector<INSTRUMENTINDEX> plugInstrumentList; m_pVstPlugin->GetInputInstrumentList(plugInstrumentList); - if(plugInstrumentList.GetSize()) + if(plugInstrumentList.size()) { return static_cast<INSTRUMENTINDEX>(plugInstrumentList[0]); } Modified: trunk/OpenMPT/mptrack/AbstractVstEditor.h =================================================================== --- trunk/OpenMPT/mptrack/AbstractVstEditor.h 2012-06-07 13:59:06 UTC (rev 1294) +++ trunk/OpenMPT/mptrack/AbstractVstEditor.h 2012-06-08 19:36:29 UTC (rev 1295) @@ -66,7 +66,7 @@ private: CMenu *m_pMenu; CMenu *m_pPresetMenu; - CArray<CMenu*,CMenu*> m_pPresetMenuGroup; + vector<CMenu *> m_pPresetMenuGroup; CMenu *m_pInputMenu; CMenu *m_pOutputMenu; CMenu *m_pMacroMenu; Deleted: trunk/OpenMPT/mptrack/ArrayUtils.cpp =================================================================== --- trunk/OpenMPT/mptrack/ArrayUtils.cpp 2012-06-07 13:59:06 UTC (rev 1294) +++ trunk/OpenMPT/mptrack/ArrayUtils.cpp 2012-06-08 19:36:29 UTC (rev 1295) @@ -1,57 +0,0 @@ -/* - * ArrayUtils.cpp - * -------------- - * Purpose: Some tools for handling CArrays. - * Notes : (currently none) - * Authors: OpenMPT Devs - * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. - */ - - -#include "stdafx.h" -#include "afxtempl.h" -#include "arrayutils.h" - -template <class Type> -static void CArrayUtils<Type>::Merge(CArray<Type,Type>& Dest, CArray<Type,Type>& Src) -//---------------------------------------------------------------------------------- -{ - Dest.Append(Src); - RemoveDuplicates(Dest); -} - -template <class Type> -static void CArrayUtils<Type>::RemoveDuplicates(CArray<Type,Type>& Src) -//------------------------------------------------------- -{ - Sort(Src, true); - - for (int i=0; i<Src.GetSize(); ++i) { - if(Src[i]==Src[i+1]) { - Src.RemoveAt(i); - } - } -} - -template <class Type> -static void CArrayUtils<Type>::Sort(CArray<Type,Type>& Src, bool Ascend=true) -//---------------------------------------------------------------- -{ - m_Ascend = Ascend; - qsort( Src.GetData(), Src.GetSize(), sizeof(Src[0]), Compare ); -} - -template <class Type> -static int CArrayUtils<Type>::Compare(const void*A, const void*B) -//-------------------------------------------------- -{ - Type* RealA; - Type* RealB; - RealA = (Type*)A; - RealB = (Type*)B; - if( *RealA < *RealB ) - return( m_Ascend? -1 : 1 ); - if( *RealA > *RealB ) - return( m_Ascend? 1 : -1 ); - return(0); -} \ No newline at end of file Deleted: trunk/OpenMPT/mptrack/ArrayUtils.h =================================================================== --- trunk/OpenMPT/mptrack/ArrayUtils.h 2012-06-07 13:59:06 UTC (rev 1294) +++ trunk/OpenMPT/mptrack/ArrayUtils.h 2012-06-08 19:36:29 UTC (rev 1295) @@ -1,22 +0,0 @@ -/* - * ArrayUtils.h - * ------------ - * Purpose: Some tools for handling CArrays. - * Notes : (currently none) - * Authors: OpenMPT Devs - * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. - */ - - -#pragma once - -template <class Type> -class CArrayUtils -{ -public: - static void Merge(CArray<Type,Type>& Dest, CArray<Type,Type>& Src); - static void RemoveDuplicates(CArray<Type,Type>& Src); - static void Sort( CArray<Type,Type>& Src, bool Ascend=true); - static int Compare(const void*A, const void*B); - static bool m_Ascend; -}; Modified: trunk/OpenMPT/mptrack/AutoSaver.cpp =================================================================== --- trunk/OpenMPT/mptrack/AutoSaver.cpp 2012-06-07 13:59:06 UTC (rev 1294) +++ trunk/OpenMPT/mptrack/AutoSaver.cpp 2012-06-08 19:36:29 UTC (rev 1295) @@ -330,24 +330,24 @@ CFileFind finder; BOOL bResult = finder.FindFile(searchPattern); - CArray<CString> foundfiles; + vector<CString> foundfiles; while(bResult) { bResult = finder.FindNextFile(); - foundfiles.Add(path+finder.GetFileName()); + foundfiles.push_back(path + finder.GetFileName()); } finder.Close(); - std::sort(foundfiles.GetData(), foundfiles.GetData() + foundfiles.GetSize()); - while (foundfiles.GetSize()>m_nBackupHistory) + std::sort(foundfiles.begin(), foundfiles.end()); + while(foundfiles.size() > m_nBackupHistory) { try { - CString toRemove=foundfiles[0]; + CString toRemove = foundfiles[0]; CFile::Remove(toRemove); } catch (CFileException* /*pEx*/){} - foundfiles.RemoveAt(0); + foundfiles.erase(foundfiles.begin()); } } Modified: trunk/OpenMPT/mptrack/AutoSaver.h =================================================================== --- trunk/OpenMPT/mptrack/AutoSaver.h 2012-06-07 13:59:06 UTC (rev 1294) +++ trunk/OpenMPT/mptrack/AutoSaver.h 2012-06-08 19:36:29 UTC (rev 1295) @@ -56,7 +56,7 @@ bool m_bEnabled; DWORD m_nLastSave; DWORD m_nSaveInterval; - int m_nBackupHistory; + size_t m_nBackupHistory; bool m_bUseOriginalPath; CString m_csPath; CString m_csFileNameTemplate; @@ -94,7 +94,7 @@ virtual BOOL OnInitDialog(); afx_msg void OnBnClickedAutosaveEnable(); afx_msg void OnBnClickedAutosaveUseorigdir(); - void OnSettingsChanged(); + void OnSettingsChanged(); BOOL OnSetActive(); }; Modified: trunk/OpenMPT/mptrack/MoveFXSlotDialog.cpp =================================================================== --- trunk/OpenMPT/mptrack/MoveFXSlotDialog.cpp 2012-06-07 13:59:06 UTC (rev 1294) +++ trunk/OpenMPT/mptrack/MoveFXSlotDialog.cpp 2012-06-08 19:36:29 UTC (rev 1295) @@ -48,13 +48,13 @@ CDialog::OnOK(); } -void CMoveFXSlotDialog::SetupMove(PLUGINDEX currentSlot, CArray<UINT, UINT> &emptySlots, PLUGINDEX defaultIndex) -//-------------------------------------------------------------------------------------------------------------- +void CMoveFXSlotDialog::SetupMove(PLUGINDEX currentSlot, vector<PLUGINDEX> &emptySlots, PLUGINDEX defaultIndex) +//------------------------------------------------------------------------------------------------------------- { m_nDefaultSlot = defaultIndex; m_csPrompt.Format("Move plugin in slot %d to the following empty slot:", currentSlot + 1); m_csTitle.Format("Move To Slot.."); - m_EmptySlots.Copy(emptySlots); + m_EmptySlots = emptySlots; } BOOL CMoveFXSlotDialog::OnInitDialog() @@ -67,7 +67,7 @@ CString slotText; int defaultSlot = 0; bool foundDefault = false; - for (int nSlot=0; nSlot<m_EmptySlots.GetSize(); nSlot++) + for(size_t nSlot=0; nSlot < m_EmptySlots.size(); nSlot++) { slotText.Format("FX%d", m_EmptySlots[nSlot] + 1); m_CbnEmptySlots.SetItemData(m_CbnEmptySlots.AddString(slotText), m_EmptySlots[nSlot]); Modified: trunk/OpenMPT/mptrack/MoveFXSlotDialog.h =================================================================== --- trunk/OpenMPT/mptrack/MoveFXSlotDialog.h 2012-06-07 13:59:06 UTC (rev 1294) +++ trunk/OpenMPT/mptrack/MoveFXSlotDialog.h 2012-06-08 19:36:29 UTC (rev 1295) @@ -20,7 +20,7 @@ public: CMoveFXSlotDialog(CWnd* pParent = NULL); // standard constructor virtual ~CMoveFXSlotDialog(); - void SetupMove(PLUGINDEX currentSlot, CArray<UINT, UINT> &emptySlots, PLUGINDEX defaultIndex); + void SetupMove(PLUGINDEX currentSlot, vector<PLUGINDEX> &emptySlots, PLUGINDEX defaultIndex); PLUGINDEX m_nToSlot; @@ -31,7 +31,7 @@ protected: CString m_csPrompt, m_csTitle; CEdit m_EditPrompt; - CArray<UINT, UINT> m_EmptySlots; + vector<PLUGINDEX> m_EmptySlots; virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support CComboBox m_CbnEmptySlots; PLUGINDEX m_nDefaultSlot; Modified: trunk/OpenMPT/mptrack/View_gen.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_gen.cpp 2012-06-07 13:59:06 UTC (rev 1294) +++ trunk/OpenMPT/mptrack/View_gen.cpp 2012-06-08 19:36:29 UTC (rev 1295) @@ -1267,8 +1267,6 @@ //----------------------------------- { CMoveFXSlotDialog dlg((CWnd*)this); - CArray<UINT, UINT> emptySlots; - BuildEmptySlotList(emptySlots); // If any plugin routes its output to the current plugin, we shouldn't try to move it before that plugin... PLUGINDEX defaultIndex = 0; @@ -1284,6 +1282,8 @@ } } + vector<PLUGINDEX> emptySlots; + BuildEmptySlotList(emptySlots); dlg.SetupMove(m_nCurrentPlugin, emptySlots, defaultIndex); if (dlg.DoModal() == IDOK) @@ -1391,19 +1391,19 @@ } -void CViewGlobals::BuildEmptySlotList(CArray<UINT, UINT> &emptySlots) -//------------------------------------------------------------------- +void CViewGlobals::BuildEmptySlotList(vector<PLUGINDEX> &emptySlots) +//------------------------------------------------------------------ { CModDoc *pModDoc = GetDocument(); CSoundFile* pSndFile = pModDoc->GetSoundFile(); - emptySlots.RemoveAll(); + emptySlots.clear(); - for (UINT nSlot=0; nSlot<MAX_MIXPLUGINS; nSlot++) + for(PLUGINDEX nSlot = 0; nSlot < MAX_MIXPLUGINS; nSlot++) { - if (pSndFile->m_MixPlugins[nSlot].pMixPlugin == nullptr) + if(pSndFile->m_MixPlugins[nSlot].pMixPlugin == nullptr) { - emptySlots.Add(nSlot); + emptySlots.push_back(nSlot); } } return; Modified: trunk/OpenMPT/mptrack/View_gen.h =================================================================== --- trunk/OpenMPT/mptrack/View_gen.h 2012-06-07 13:59:06 UTC (rev 1294) +++ trunk/OpenMPT/mptrack/View_gen.h 2012-06-08 19:36:29 UTC (rev 1295) @@ -68,7 +68,7 @@ void UnlockControls() { PostMessage(WM_MOD_UNLOCKCONTROLS); } BOOL IsLocked() const { return (m_nLockCount > 0); } int GetDlgItemIntEx(UINT nID); - void BuildEmptySlotList(CArray<UINT, UINT> &emptySlots); + void BuildEmptySlotList(vector<PLUGINDEX> &emptySlots); bool MovePlug(PLUGINDEX src, PLUGINDEX dest, bool bAdjustPat = AdjustPattern); public: Modified: trunk/OpenMPT/mptrack/View_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_pat.cpp 2012-06-07 13:59:06 UTC (rev 1294) +++ trunk/OpenMPT/mptrack/View_pat.cpp 2012-06-08 19:36:29 UTC (rev 1295) @@ -23,14 +23,12 @@ #include "EffectVis.h" //rewbs.fxvis #include "PatternGotoDialog.h" -#include "PatternRandomizer.h" -#include "arrayutils.h" #include "view_pat.h" #include "View_gen.h" #include "MIDIMacros.h" #include "../common/misc_util.h" #include "../soundlib/MIDIEvents.h" -#include <cmath> +#include <algorithm> #define PLUGNAME_HEIGHT 16 //rewbs.patPlugName @@ -116,7 +114,6 @@ ON_COMMAND(ID_PATTERN_INTERPOLATE_EFFECT, OnInterpolateEffect) ON_COMMAND(ID_PATTERN_INTERPOLATE_NOTE, OnInterpolateNote) ON_COMMAND(ID_PATTERN_VISUALIZE_EFFECT, OnVisualizeEffect) //rewbs.fxvis - ON_COMMAND(ID_PATTERN_OPEN_RANDOMIZER, OnOpenRandomizer) ON_COMMAND(ID_GROW_SELECTION, OnGrowSelection) ON_COMMAND(ID_SHRINK_SELECTION, OnShrinkSelection) ON_COMMAND(ID_PATTERN_SETINSTRUMENT, OnSetSelInstrument) @@ -150,7 +147,6 @@ //-------------------------- { m_pEffectVis = NULL; //rewbs.fxvis - m_pRandomizer = NULL; m_bLastNoteEntryBlocked=false; m_nPattern = 0; @@ -754,12 +750,6 @@ m_pGotoWnd = NULL; } - if (m_pRandomizer) - { - delete m_pRandomizer; - m_pRandomizer=NULL; - } - CModScrollView::OnDestroy(); } @@ -1453,33 +1443,29 @@ AppendMenu(hMenu, MF_SEPARATOR, 0, ""); BuildRecordCtxMenu(hMenu, nChn, pModDoc); BuildChannelControlCtxMenu(hMenu); - BuildChannelMiscCtxMenu(hMenu, pSndFile); + BuildChannelMiscCtxMenu(hMenu); } } //------ Standard Menu ---------- : else if ((pt.x >= m_szHeader.cx) && (pt.y >= m_szHeader.cy)) { - /*if (BuildSoloMuteCtxMenu(hMenu, ih, nChn, pSndFile)) - AppendMenu(hMenu, MF_SEPARATOR, 0, "");*/ - if (BuildSelectionCtxMenu(hMenu, ih)) + // When combining menus, use bitwise ORs to avoid shortcuts + if(BuildSelectionCtxMenu(hMenu, ih)) AppendMenu(hMenu, MF_SEPARATOR, 0, ""); - if (BuildEditCtxMenu(hMenu, ih, pModDoc)) + if(BuildEditCtxMenu(hMenu, ih, pModDoc)) AppendMenu(hMenu, MF_SEPARATOR, 0, ""); - if (BuildNoteInterpolationCtxMenu(hMenu, ih, pSndFile) | //Use bitwise ORs to avoid shortcuts - BuildVolColInterpolationCtxMenu(hMenu, ih, pSndFile) | - BuildEffectInterpolationCtxMenu(hMenu, ih, pSndFile) ) + if(BuildInterpolationCtxMenu(hMenu, ih) + | BuildTransposeCtxMenu(hMenu, ih)) AppendMenu(hMenu, MF_SEPARATOR, 0, ""); - if (BuildTransposeCtxMenu(hMenu, ih)) + if(BuildVisFXCtxMenu(hMenu, ih) + | BuildAmplifyCtxMenu(hMenu, ih) + | BuildSetInstCtxMenu(hMenu, ih)) AppendMenu(hMenu, MF_SEPARATOR, 0, ""); - if (BuildVisFXCtxMenu(hMenu, ih) | //Use bitwise ORs to avoid shortcuts - BuildAmplifyCtxMenu(hMenu, ih) | - BuildSetInstCtxMenu(hMenu, ih, pSndFile) ) + if(BuildPCNoteCtxMenu(hMenu, ih)) AppendMenu(hMenu, MF_SEPARATOR, 0, ""); - if (BuildPCNoteCtxMenu(hMenu, ih, pSndFile)) + if(BuildGrowShrinkCtxMenu(hMenu, ih)) AppendMenu(hMenu, MF_SEPARATOR, 0, ""); - if (BuildGrowShrinkCtxMenu(hMenu, ih)) - AppendMenu(hMenu, MF_SEPARATOR, 0, ""); if(BuildMiscCtxMenu(hMenu, ih)) AppendMenu(hMenu, MF_SEPARATOR, 0, ""); BuildRowInsDelCtxMenu(hMenu, ih); @@ -2566,34 +2552,6 @@ } -void CViewPattern::OnOpenRandomizer() -//----------------------------------- -{ - CModDoc *pModDoc = GetDocument(); - if (pModDoc) - { - if (m_pRandomizer) - { - if (m_pRandomizer->isGUIVisible()) - { - //window already there, update data - //m_pRandomizer->UpdateSelection(rowStart, rowEnd, nchn, pModDoc, m_nPattern); - } else - { - m_pRandomizer->showGUI(); - } - } else - { - //Open window & send data - m_pRandomizer = new CPatternRandomizer(this); - if (m_pRandomizer) - { - m_pRandomizer->showGUI(); - } - } - } -} - //begin rewbs.fxvis void CViewPattern::OnVisualizeEffect() //------------------------------------ @@ -2631,37 +2589,37 @@ void CViewPattern::Interpolate(PatternCursor::Columns type) //--------------------------------------------------------- { - CSoundFile *pSndFile = GetSoundFile(); - if(pSndFile == nullptr) + CSoundFile *sndFile = GetSoundFile(); + if(sndFile == nullptr) { return; } bool changed = false; - CArray<UINT,UINT> validChans; + vector<CHANNELINDEX> validChans; if(type == PatternCursor::effectColumn || type == PatternCursor::paramColumn) { - CArray<UINT,UINT> moreValidChans; - ListChansWhereColSelected(PatternCursor::effectColumn, validChans); - ListChansWhereColSelected(PatternCursor::paramColumn, moreValidChans); - //CArrayUtils<UINT>::Merge(validChans, moreValidChans); //Causes unresolved external, not sure why yet. - validChans.Append(moreValidChans); //for now we'll just interpolate the same data several times. :) + vector<CHANNELINDEX> effectChans; + vector<CHANNELINDEX> paramChans; + ListChansWhereColSelected(PatternCursor::effectColumn, effectChans); + ListChansWhereColSelected(PatternCursor::paramColumn, paramChans); + + validChans.resize(effectChans.size() + paramChans.size()); + validChans.resize(std::set_union(effectChans.begin(), effectChans.end(), paramChans.begin(), paramChans.end(), validChans.begin()) - validChans.begin()); } else { ListChansWhereColSelected(type, validChans); } - int nValidChans = validChans.GetCount(); - + const ROWINDEX row0 = m_Selection.GetStartRow(), row1 = m_Selection.GetEndRow(); + //for all channels where type is selected - for (int chnIdx=0; chnIdx<nValidChans; chnIdx++) + for(vector<CHANNELINDEX>::iterator iter = validChans.begin(); iter != validChans.end(); iter++) { - UINT nchn = validChans[chnIdx]; - ROWINDEX row0 = m_Selection.GetStartRow(); - ROWINDEX row1 = m_Selection.GetEndRow(); + CHANNELINDEX nchn = *iter; - if (!IsInterpolationPossible(row0, row1, nchn, type, pSndFile)) + if (!IsInterpolationPossible(row0, row1, nchn, type)) continue; //skip chans where interpolation isn't possible if (!changed) //ensure we save undo buffer only before any channels are interpolated @@ -2671,8 +2629,8 @@ int vsrc, vdest, vcmd = 0, verr = 0, distance = row1 - row0; - const ModCommand srcCmd = *pSndFile->Patterns[m_nPattern].GetpModCommand(row0, nchn); - const ModCommand destCmd = *pSndFile->Patterns[m_nPattern].GetpModCommand(row1, nchn); + const ModCommand srcCmd = *sndFile->Patterns[m_nPattern].GetpModCommand(row0, nchn); + const ModCommand destCmd = *sndFile->Patterns[m_nPattern].GetpModCommand(row1, nchn); ModCommand::NOTE PCnote = 0; uint16 PCinst = 0, PCparam = 0; @@ -2746,9 +2704,9 @@ if (vdest < vsrc) verr = -verr; - ModCommand* pcmd = pSndFile->Patterns[m_nPattern].GetpModCommand(row0, nchn); + ModCommand* pcmd = sndFile->Patterns[m_nPattern].GetpModCommand(row0, nchn); - for (int i = 0; i <= distance; i++, pcmd += pSndFile->GetNumChannels()) + for (int i = 0; i <= distance; i++, pcmd += sndFile->GetNumChannels()) { switch(type) @@ -2841,9 +2799,8 @@ { int note = m[chn].note; note += transp; - if (note < noteMin) note = noteMin; - if (note > noteMax) note = noteMax; - m[chn].note = (BYTE)note; + Limit(note, noteMin, noteMax); + m[chn].note = (ModCommand::NOTE)note; } } } @@ -3048,13 +3005,13 @@ CModDoc *pModDoc = GetDocument(); if (pModDoc == nullptr) return; - if(Reporting::Confirm(GetStrI18N(_TEXT("This affects all patterns, proceed?"))) != cnfYes) - return; - const CHANNELINDEX nDupChn = m_MenuCursor.GetChannel(); if(nDupChn >= pModDoc->GetNumChannels()) return; + if(!pModDoc->IsChannelUnused(nDupChn) && Reporting::Confirm(GetStrI18N(_TEXT("This affects all patterns, proceed?"))) != cnfYes) + return; + BeginWaitCursor(); // Create new channel order, with channel nDupChn duplicated. vector<CHANNELINDEX> channels(pModDoc->GetNumChannels() + 1, 0); @@ -4009,7 +3966,7 @@ case kcPatternInterpolateVol: OnInterpolateVolume(); return wParam; case kcPatternInterpolateEffect: OnInterpolateEffect(); return wParam; case kcPatternVisualizeEffect: OnVisualizeEffect(); return wParam; - case kcPatternOpenRandomizer: OnOpenRandomizer(); return wParam; + //case kcPatternOpenRandomizer: OnOpenRandomizer(); return wParam; case kcPatternGrowSelection: OnGrowSelection(); return wParam; case kcPatternShrinkSelection: OnShrinkSelection(); return wParam; @@ -5665,114 +5622,45 @@ return true; } -bool CViewPattern::BuildNoteInterpolationCtxMenu(HMENU hMenu, CInputHandler *ih, CSoundFile *pSndFile) const -//---------------------------------------------------------------------------------------------------------- -{ - CArray<UINT, UINT> validChans; - DWORD greyed = MF_GRAYED; - UINT startRow = m_Selection.GetStartRow(); - UINT endRow = m_Selection.GetEndRow(); - - if (ListChansWhereColSelected(PatternCursor::noteColumn, validChans) > 0) - { - for (int valChnIdx=0; valChnIdx<validChans.GetCount(); valChnIdx++) - { - if (IsInterpolationPossible(startRow, endRow, validChans[valChnIdx], PatternCursor::noteColumn, pSndFile)) - { - greyed = 0; // Can do interpolation. - break; - } - } - - } - if (!greyed || !(CMainFrame::GetSettings().m_dwPatternSetup & PATTERN_OLDCTXMENUSTYLE)) - { - AppendMenu(hMenu, MF_STRING | greyed, ID_PATTERN_INTERPOLATE_NOTE, "Interpolate Note\t" + ih->GetKeyTextFromCommand(kcPatternInterpolateNote)); - return true; - } - return false; -} - -bool CViewPattern::BuildVolColInterpolationCtxMenu(HMENU hMenu, CInputHandler *ih, CSoundFile *pSndFile) const -//------------------------------------------------------------------------------------------------------------ +bool CViewPattern::BuildInterpolationCtxMenu(HMENU hMenu, CInputHandler *ih) const +//-------------------------------------------------------------------------------- { - CArray<UINT, UINT> validChans; - DWORD greyed = MF_GRAYED; + const CSoundFile *sndFile = GetSoundFile(); + const bool isPCNote = sndFile->Patterns.IsValidPat(m_nPattern) && sndFile->Patterns[m_nPattern].GetpModCommand(m_Selection.GetStartRow(), m_Selection.GetStartChannel())->IsPcNote(); - UINT startRow = m_Selection.GetStartRow(); - UINT endRow = m_Selection.GetEndRow(); - - if (ListChansWhereColSelected(PatternCursor::volumeColumn, validChans) > 0) + HMENU subMenu = CreatePopupMenu(); + bool possible = BuildInterpolationCtxMenu(subMenu, PatternCursor::noteColumn, CString("Note Column\t") + ih->GetKeyTextFromCommand(kcPatternInterpolateNote), ID_PATTERN_INTERPOLATE_NOTE) + | BuildInterpolationCtxMenu(subMenu, PatternCursor::volumeColumn, (isPCNote ? CString("Parameter Column\t") : CString("Volume Column\t")) + ih->GetKeyTextFromCommand(kcPatternInterpolateVol), ID_PATTERN_INTERPOLATE_VOLUME) + | BuildInterpolationCtxMenu(subMenu, PatternCursor::effectColumn, (isPCNote ? CString("Value Column\t") : CString("Effect Column\t")) + ih->GetKeyTextFromCommand(kcPatternInterpolateEffect), ID_PATTERN_INTERPOLATE_EFFECT); + if(possible || !(CMainFrame::GetSettings().m_dwPatternSetup & PATTERN_OLDCTXMENUSTYLE)) { - for (int valChnIdx = 0; valChnIdx < validChans.GetCount(); valChnIdx++) - { - if (IsInterpolationPossible(startRow, endRow, validChans[valChnIdx], PatternCursor::volumeColumn, pSndFile)) - { - greyed = 0; // Can do interpolation. - break; - } - } - } - if (!greyed || !(CMainFrame::GetSettings().m_dwPatternSetup & PATTERN_OLDCTXMENUSTYLE)) - { - AppendMenu(hMenu, MF_STRING | greyed, ID_PATTERN_INTERPOLATE_VOLUME, "Interpolate Vol Col\t" + ih->GetKeyTextFromCommand(kcPatternInterpolateVol)); + AppendMenu(hMenu, MF_POPUP | (possible ? 0 : MF_GRAYED), reinterpret_cast<UINT_PTR>(subMenu), "Interpolate..."); return true; } return false; } -bool CViewPattern::BuildEffectInterpolationCtxMenu(HMENU hMenu, CInputHandler *ih, CSoundFile *pSndFile) const -//------------------------------------------------------------------------------------------------------------ +bool CViewPattern::BuildInterpolationCtxMenu(HMENU hMenu, PatternCursor::Columns colType, CString label, UINT command) const +//-------------------------------------------------------------------------------------------------------------------------- { - CArray<UINT, UINT> validChans; - DWORD greyed = MF_GRAYED; - - UINT startRow = m_Selection.GetStartRow(); - UINT endRow = m_Selection.GetEndRow(); - - if (ListChansWhereColSelected(PatternCursor::effectColumn, validChans) > 0) + bool possible = IsInterpolationPossible(colType); + if(!possible && colType == PatternCursor::effectColumn) { - for (int valChnIdx = 0; valChnIdx < validChans.GetCount(); valChnIdx++) - { - if (IsInterpolationPossible(startRow, endRow, validChans[valChnIdx], PatternCursor::effectColumn, pSndFile)) - { - greyed = 0; // Can do interpolation. - break; - } - } + // Extend search to param column + possible = IsInterpolationPossible(PatternCursor::paramColumn); } - if (ListChansWhereColSelected(PatternCursor::paramColumn, validChans) > 0) + if(possible || !(CMainFrame::GetSettings().m_dwPatternSetup & PATTERN_OLDCTXMENUSTYLE)) { - for (int valChnIdx=0; valChnIdx<validChans.GetCount(); valChnIdx++) - { - if (IsInterpolationPossible(startRow, endRow, validChans[valChnIdx], PatternCursor::paramColumn, pSndFile)) - { - greyed = 0; // Can do interpolation. - break; - } - } + AppendMenu(hMenu, MF_STRING | (possible ? 0 : MF_GRAYED), command, label); } - - if (!greyed || !(CMainFrame::GetSettings().m_dwPatternSetup & PATTERN_OLDCTXMENUSTYLE)) - { - // Figure out what we want to interpolate - CString interpolateWhat = "Effect"; - const CSoundFile *pSndFile = GetSoundFile(); - if(pSndFile->Patterns.IsValidPat(m_nPattern) && pSndFile->Patterns[m_nPattern].GetpModCommand(m_Selection.GetStartRow(), m_Selection.GetStartChannel())->IsPcNote()) - { - interpolateWhat = "Parameter"; - } - - AppendMenu(hMenu, MF_STRING | greyed, ID_PATTERN_INTERPOLATE_EFFECT, "Interpolate " + interpolateWhat + "\t" + ih->GetKeyTextFromCommand(kcPatternInterpolateEffect)); - return true; - } - return false; + return possible; } + bool CViewPattern::BuildEditCtxMenu(HMENU hMenu, CInputHandler *ih, CModDoc* pModDoc) const //----------------------------------------------------------------------------------------- { @@ -5780,7 +5668,7 @@ AppendMenu(hMenu, MF_STRING, ID_EDIT_CUT, "Cut\t" + ih->GetKeyTextFromCommand(kcEditCut)); AppendMenu(hMenu, MF_STRING, ID_EDIT_COPY, "Copy\t" + ih->GetKeyTextFromCommand(kcEditCopy)); AppendMenu(hMenu, MF_STRING, ID_EDIT_PASTE, "Paste\t" + ih->GetKeyTextFromCommand(kcEditPaste)); - AppendMenu(hMenu, MF_POPUP, (UINT)pasteSpecialMenu, "Paste Special"); + AppendMenu(hMenu, MF_POPUP, reinterpret_cast<UINT_PTR>(pasteSpecialMenu), "Paste Special"); AppendMenu(pasteSpecialMenu, MF_STRING, ID_EDIT_MIXPASTE, "Mix Paste\t" + ih->GetKeyTextFromCommand(kcEditMixPaste)); AppendMenu(pasteSpecialMenu, MF_STRING, ID_EDIT_MIXPASTE_ITSTYLE, "Mix Paste (IT Style)\t" + ih->GetKeyTextFromCommand(kcEditMixPasteITStyle)); AppendMenu(pasteSpecialMenu, MF_STRING, ID_EDIT_PASTEFLOOD, "Paste Flood\t" + ih->GetKeyTextFromCommand(kcEditPasteFlood)); @@ -5800,8 +5688,7 @@ bool CViewPattern::BuildVisFXCtxMenu(HMENU hMenu, CInputHandler *ih) const //------------------------------------------------------------------------ { - CArray<UINT, UINT> validChans; - DWORD greyed = (ListChansWhereColSelected(PatternCursor::effectColumn, validChans) > 0) ? FALSE:MF_GRAYED; + DWORD greyed = IsColumnSelected(PatternCursor::effectColumn) ? FALSE : MF_GRAYED; if (!greyed || !(CMainFrame::GetSettings().m_dwPatternSetup & PATTERN_OLDCTXMENUSTYLE)) { @@ -5821,15 +5708,18 @@ bool CViewPattern::BuildTransposeCtxMenu(HMENU hMenu, CInputHandler *ih) const //---------------------------------------------------------------------------- { - CArray<UINT, UINT> validChans; - DWORD greyed = (ListChansWhereColSelected(PatternCursor::noteColumn, validChans) > 0) ? FALSE:MF_GRAYED; + HMENU transMenu = CreatePopupMenu(); + vector<CHANNELINDEX> validChans; + DWORD greyed = IsColumnSelected(PatternCursor::noteColumn) ? FALSE : MF_GRAYED; + if (!greyed || !(CMainFrame::GetSettings().m_dwPatternSetup & PATTERN_OLDCTXMENUSTYLE)) { - AppendMenu(hMenu, MF_STRING|greyed, ID_TRANSPOSE_UP, "Transpose +1\t" + ih->GetKeyTextFromCommand(kcTransposeUp)); - AppendMenu(hMenu, MF_STRING|greyed, ID_TRANSPOSE_DOWN, "Transpose -1\t" + ih->GetKeyTextFromCommand(kcTransposeDown)); - AppendMenu(hMenu, MF_STRING|greyed, ID_TRANSPOSE_OCTUP, "Transpose +12\t" + ih->GetKeyTextFromCommand(kcTransposeOctUp)); - AppendMenu(hMenu, MF_STRING|greyed, ID_TRANSPOSE_OCTDOWN, "Transpose -12\t" + ih->GetKeyTextFromCommand(kcTransposeOctDown)); + AppendMenu(transMenu, MF_STRING | greyed, ID_TRANSPOSE_UP, "Transpose +1\t" + ih->GetKeyTextFromCommand(kcTransposeUp)); + AppendMenu(transMenu, MF_STRING | greyed, ID_TRANSPOSE_DOWN, "Transpose -1\t" + ih->GetKeyTextFromCommand(kcTransposeDown)); + AppendMenu(transMenu, MF_STRING | greyed, ID_TRANSPOSE_OCTUP, "Transpose +12\t" + ih->GetKeyTextFromCommand(kcTransposeOctUp)); + AppendMenu(transMenu, MF_STRING | greyed, ID_TRANSPOSE_OCTDOWN, "Transpose -12\t" + ih->GetKeyTextFromCommand(kcTransposeOctDown)); + AppendMenu(hMenu, MF_POPUP | greyed, reinterpret_cast<UINT_PTR>(transMenu), "Transpose..."); return true; } return false; @@ -5838,8 +5728,8 @@ bool CViewPattern::BuildAmplifyCtxMenu(HMENU hMenu, CInputHandler *ih) const //-------------------------------------------------------------------------- { - CArray<UINT, UINT> validChans; - DWORD greyed = (ListChansWhereColSelected(PatternCursor::volumeColumn, validChans) > 0) ? 0 : MF_GRAYED; + vector<CHANNELINDEX> validChans; + DWORD greyed = IsColumnSelected(PatternCursor::volumeColumn) ? 0 : MF_GRAYED; if (!greyed || !(CMainFrame::GetSettings().m_dwPatternSetup & PATTERN_OLDCTXMENUSTYLE)) { @@ -5858,12 +5748,12 @@ AppendMenu(hMenu, MF_STRING, ID_PATTERN_DUPLICATECHANNEL, "Duplicate this channel"); HMENU addChannelMenu = ::CreatePopupMenu(); - AppendMenu(hMenu, MF_POPUP, (UINT)addChannelMenu, "Add channel\t"); + AppendMenu(hMenu, MF_POPUP, reinterpret_cast<UINT_PTR>(addChannelMenu), "Add channel\t"); AppendMenu(addChannelMenu, MF_STRING, ID_PATTERN_ADDCHANNEL_FRONT, "Before this channel"); AppendMenu(addChannelMenu, MF_STRING, ID_PATTERN_ADDCHANNEL_AFTER, "After this channel"); HMENU removeChannelMenu = ::CreatePopupMenu(); - AppendMenu(hMenu, MF_POPUP, (UINT)removeChannelMenu, "Remove channel\t"); + AppendMenu(hMenu, MF_POPUP, reinterpret_cast<UINT_PTR>(removeChannelMenu), "Remove channel\t"); AppendMenu(removeChannelMenu, MF_STRING, ID_PATTERN_REMOVECHANNEL, "Remove this channel\t"); AppendMenu(removeChannelMenu, MF_STRING, ID_PATTERN_REMOVECHANNELDIALOG, "Choose channels to remove...\t"); @@ -5872,50 +5762,49 @@ } -bool CViewPattern::BuildSetInstCtxMenu(HMENU hMenu, CInputHandler *ih, CSoundFile *pSndFile) const -//------------------------------------------------------------------------------------------------ +bool CViewPattern::BuildSetInstCtxMenu(HMENU hMenu, CInputHandler *ih) const +//-------------------------------------------------------------------------- { - CArray<UINT, UINT> validChans; - DWORD greyed = (ListChansWhereColSelected(PatternCursor::instrColumn, validChans) > 0) ? 0 : MF_GRAYED; + const CSoundFile *sndFile = GetSoundFile(); + const CModDoc *modDoc; + if(sndFile == nullptr || (modDoc = sndFile->GetpModDoc()) == nullptr) + { + return false; + } + + vector<CHANNELINDEX> validChans; + DWORD greyed = IsColumnSelected(PatternCursor::instrColumn) ? 0 : MF_GRAYED; + if (!greyed || !(CMainFrame::GetSettings().m_dwPatternSetup & PATTERN_OLDCTXMENUSTYLE)) { - bool isPcNote = false; - ModCommand *mSelStart = nullptr; - if((pSndFile != nullptr) && (pSndFile->Patterns.IsValidPat(m_nPattern))) + if((sndFile->Patterns.IsValidPat(m_nPattern))) { - mSelStart = pSndFile->Patterns[m_nPattern].GetpModCommand(m_Selection.GetStartRow(), m_Selection.GetStartChannel()); - if(mSelStart != nullptr && mSelStart->IsPcNote()) + if(sndFile->Patterns[m_nPattern].GetpModCommand(m_Selection.GetStartRow(), m_Selection.GetStartChannel())->IsPcNote()) { - isPcNote = true; + // Don't build instrument menu for PC notes. + return false; } } - if(isPcNote) - return false; // Create the new menu and add it to the existing menu. HMENU instrumentChangeMenu = ::CreatePopupMenu(); - AppendMenu(hMenu, MF_POPUP | greyed, (UINT)instrumentChangeMenu, "Change Instrument\t" + ih->GetKeyTextFromCommand(kcPatternSetInstrument)); - - if(pSndFile == nullptr || pSndFile->GetpModDoc() == nullptr) - return false; - - CModDoc* const pModDoc = pSndFile->GetpModDoc(); + AppendMenu(hMenu, MF_POPUP | greyed, reinterpret_cast<UINT_PTR>(instrumentChangeMenu), "Change Instrument\t" + ih->GetKeyTextFromCommand(kcPatternSetInstrument)); if(!greyed) { bool addSeparator = false; - if (pSndFile->GetNumInstruments()) + if (sndFile->GetNumInstruments()) { - for (UINT i = 1; i <= pSndFile->GetNumInstruments() ; i++) + for (UINT i = 1; i <= sndFile->GetNumInstruments() ; i++) { - if (pSndFile->Instruments[i] == NULL) + if (sndFile->Instruments[i] == NULL) continue; - CString instString = pModDoc->GetPatternViewInstrumentName(i, true); + CString instString = modDoc->GetPatternViewInstrumentName(i, true); if(!instString.IsEmpty()) { - AppendMenu(instrumentChangeMenu, MF_STRING, ID_CHANGE_INSTRUMENT + i, pModDoc->GetPatternViewInstrumentName(i)); + AppendMenu(instrumentChangeMenu, MF_STRING, ID_CHANGE_INSTRUMENT + i, modDoc->GetPatternViewInstrumentName(i)); addSeparator = true; } } @@ -5923,9 +5812,9 @@ } else { CHAR s[64]; - for (UINT i = 1; i <= pSndFile->GetNumSamples(); i++) if (pSndFile->GetSample(i).pSample != nullptr) + for (UINT i = 1; i <= sndFile->GetNumSamples(); i++) if (sndFile->GetSample(i).pSample != nullptr) { - wsprintf(s, "%02d: %s", i, pSndFile->m_szNames[i]); + wsprintf(s, "%02d: %s", i, sndFile->GetSampleName(i)); AppendMenu(instrumentChangeMenu, MF_STRING, ID_CHANGE_INSTRUMENT + i, s); addSeparator = true; } @@ -5945,74 +5834,80 @@ } -bool CViewPattern::BuildChannelMiscCtxMenu(HMENU hMenu, CSoundFile *pSndFile) const +bool CViewPattern::BuildChannelMiscCtxMenu(HMENU hMenu) const //--------------------------------------------------------------------------------- { - if((pSndFile->GetType() & (MOD_TYPE_IT|MOD_TYPE_MPT)) == 0) return false; + if((GetSoundFile()->GetType() & (MOD_TYPE_IT|MOD_TYPE_MPT)) == 0) return false; AppendMenu(hMenu, MF_SEPARATOR, 0, 0); - AppendMenu(hMenu, MF_STRING, ID_CHANNEL_RENAME, "Rename channel"); + AppendMenu(hMenu, MF_STRING, ID_CHANNEL_RENAME, "Rename Channel"); return true; } // Context menu for Param Control notes -bool CViewPattern::BuildPCNoteCtxMenu(HMENU hMenu, CInputHandler *ih, CSoundFile *pSndFile) const -//----------------------------------------------------------------------------------------------- +bool CViewPattern::BuildPCNoteCtxMenu(HMENU hMenu, CInputHandler *ih) const +//------------------------------------------------------------------------- { - ModCommand *mSelStart = nullptr; - if((pSndFile == nullptr) || (!pSndFile->Patterns.IsValidPat(m_nPattern))) + const CSoundFile *sndFile = GetSoundFile(); + if(sndFile == nullptr || !sndFile->Patterns.IsValidPat(m_nPattern)) + { return false; - mSelStart = pSndFile->Patterns[m_nPattern].GetpModCommand(m_Selection.GetStartRow(), m_Selection.GetStartChannel()); - if((mSelStart == nullptr) || (!mSelStart->IsPcNote())) + } + + const ModCommand &selStart = *sndFile->Patterns[m_nPattern].GetpModCommand(m_Selection.GetStartRow(), m_Selection.GetStartChannel()); + if(!selStart.IsPcNote()) + { return false; + } char s[72]; // Create sub menu for "change plugin" HMENU pluginChangeMenu = ::CreatePopupMenu(); - AppendMenu(hMenu, MF_POPUP, (UINT)pluginChangeMenu, "Change Plugin\t" + ih->GetKeyTextFromCommand(kcPatternSetInstrument)); + AppendMenu(hMenu, MF_POPUP, reinterpret_cast<UINT_PTR>(pluginChangeMenu), "Change Plugin\t" + ih->GetKeyTextFromCommand(kcPatternSetInstrument)); for(PLUGINDEX nPlg = 0; nPlg < MAX_MIXPLUGINS; nPlg++) { - if(pSndFile->m_MixPlugins[nPlg].pMixPlugin != nullptr) + if(sndFile->m_MixPlugins[nPlg].pMixPlugin != nullptr) { - wsprintf(s, "%02d: %s", nPlg + 1, pSndFile->m_MixPlugins[nPlg].GetName()); - AppendMenu(pluginChangeMenu, MF_STRING | ((nPlg + 1) == mSelStart->instr) ? MF_CHECKED : 0, ID_CHANGE_INSTRUMENT + nPlg + 1, s); + wsprintf(s, "%02d: %s", nPlg + 1, sndFile->m_MixPlugins[nPlg].GetName()); + AppendMenu(pluginChangeMenu, MF_STRING | ((nPlg + 1) == selStart.instr) ? MF_CHECKED : 0, ID_CHANGE_INSTRUMENT + nPlg + 1, s); } } - if(mSelStart->instr >= 1 && mSelStart->instr <= MAX_MIXPLUGINS) + if(selStart.instr >= 1 && selStart.instr <= MAX_MIXPLUGINS) { - CVstPlugin *plug = (CVstPlugin *)(pSndFile->m_MixPlugins[mSelStart->instr - 1].pMixPlugin); + CVstPlugin *plug = (CVstPlugin *)(sndFile->m_MixPlugins[selStart.instr - 1].pMixPlugin); if(plug != nullptr) { // Create sub menu for "change plugin param" HMENU paramChangeMenu = ::CreatePopupMenu(); - AppendMenu(hMenu, MF_POPUP, (UINT)paramChangeMenu, "Change Plugin Parameter\t"); + AppendMenu(hMenu, MF_POPUP, reinterpret_cast<UINT_PTR>(paramChangeMenu), "Change Plugin Parameter\t"); - uint16 nThisParam = mSelStart->GetValueVolCol(); - UINT nParams = plug->GetNumParameters(); - for (UINT i = 0; i < nParams; i++) + const PlugParamIndex curParam = selStart.GetValueVolCol(), nParams = plug->GetNumParameters(); + + for(PlugParamIndex i = 0; i < nParams; i++) { - AppendMenu(paramChangeMenu, MF_STRING | (i == nThisParam) ? MF_CHECKED : 0, ID_CHANGE_PCNOTE_PARAM + i, plug->GetFormattedParamName(i)); + AppendMenu(paramChangeMenu, MF_STRING | (i == curParam) ? MF_CHECKED : 0, ID_CHANGE_PCNOTE_PARAM + i, plug->GetFormattedParamName(i)); } } - AppendMenu(hMenu, MF_STRING, ID_PATTERN_EDIT_PCNOTE_PLUGIN, "Toggle plugin editor\t" + ih->GetKeyTextFromCommand(kcPatternEditPCNotePlugin)); + AppendMenu(hMenu, MF_STRING, ID_PATTERN_EDIT_PCNOTE_PLUGIN, "Toggle Plugin Editor\t" + ih->GetKeyTextFromCommand(kcPatternEditPCNotePlugin)); } return true; } -// List all channels in which a given column type is selected. -UINT CViewPattern::ListChansWhereColSelected(PatternCursor::Columns colType, CArray<UINT, UINT> &chans) const -//----------------------------------------------------------------------------------------------------------- +// Returns an ordered list of all channels in which a given column type is selected. +CHANNELINDEX CViewPattern::ListChansWhereColSelected(PatternCursor::Columns colType, vector<CHANNELINDEX> &chans) const +//--------------------------------------------------------------------------------------------------------------------- { - chans.RemoveAll(); CHANNELINDEX startChan = m_Selection.GetStartChannel(); CHANNELINDEX endChan = m_Selection.GetEndChannel(); + chans.clear(); + chans.reserve(endChan - startChan); // Check in which channels this column is selected. // Actually this check is only important for the first and last channel, but to keep things clean and simple, all channels are checked in the same manner. @@ -6020,25 +5915,54 @@ { if(m_Selection.ContainsHorizontal(PatternCursor(0, i, colType))) { - chans.Add(i); + chans.push_back(i); } } - return chans.GetCount(); + return chans.size(); } +// Check if a column type is selected on any channel in the current selection. +bool CViewPattern::IsColumnSelected(PatternCursor::Columns colType) const +//----------------------------------------------------------------------- +{ + return m_Selection.ContainsHorizontal(PatternCursor(0, m_Selection.GetStartChannel(), colType)) + || m_Selection.ContainsHorizontal(PatternCursor(0, m_Selection.GetEndChannel(), colType)); +} + + +// Check if the given interpolation type is actually possible in the current selection. +bool CViewPattern::IsInterpolationPossible(PatternCursor::Columns colType) const +//------------------------------------------------------------------------------ +{ + vector<CHANNELINDEX> validChans; + ListChansWhereColSelected(colType, validChans); + + ROWINDEX startRow = m_Selection.GetStartRow(); + ROWINDEX endRow = m_Selection.GetEndRow(); + for(vector<CHANNELINDEX>::iterator iter = validChans.begin(); iter != validChans.end(); iter++) + { + if(IsInterpolationPossible(startRow, endRow, *iter, colType)) + { + return true; + } + } + return false; +} + + // Check if the given interpolation type is actually possible in a given channel. -bool CViewPattern::IsInterpolationPossible(ROWINDEX startRow, ROWINDEX endRow, CHANNELINDEX chan, - PatternCursor::Columns colType, CSoundFile *pSndFile) const -//---------------------------------------------------------------------------------------------------- +bool CViewPattern::IsInterpolationPossible(ROWINDEX startRow, ROWINDEX endRow, CHANNELINDEX chan, PatternCursor::Columns colType) const +//------------------------------------------------------------------------------------------------------------------------------------- { - if (startRow == endRow) + const CSoundFile *sndFile = GetSoundFile(); + if(startRow == endRow || sndFile == nullptr) return false; bool result = false; - const ModCommand startRowMC = *pSndFile->Patterns[m_nPattern].GetpModCommand(startRow, chan); - const ModCommand endRowMC = *pSndFile->Patterns[m_nPattern].GetpModCommand(endRow, chan); + const ModCommand startRowMC = *sndFile->Patterns[m_nPattern].GetpModCommand(startRow, chan); + const ModCommand endRowMC = *sndFile->Patterns[m_nPattern].GetpModCommand(endRow, chan); UINT startRowCmd, endRowCmd; if(colType == PatternCursor::effectColumn && (startRowMC.IsPcNote() || endRowMC.IsPcNote())) @@ -6148,7 +6072,7 @@ HMENU hMenu; - if ( (hMenu = ::CreatePopupMenu()) == NULL) return false; + if((hMenu = ::CreatePopupMenu()) == nullptr) return false; CPoint pt = GetPointFromPosition(m_Cursor); Modified: trunk/OpenMPT/mptrack/View_pat.h =================================================================== --- trunk/OpenMPT/mptrack/View_pat.h 2012-06-07 13:59:06 UTC (rev 1294) +++ trunk/OpenMPT/mptrack/View_pat.h 2012-06-08 19:36:29 UTC (rev 1295) @@ -177,7 +177,6 @@ int oldrow, oldchn, oldsplitchn; // -! NEW_FEATURE#0012 - CPatternRandomizer *m_pRandomizer; //rewbs.fxVis public: CEffectVis *m_pEffectVis; //rewbs.fxVis @@ -377,7 +376,6 @@ afx_msg void OnInterpolateEffect() { Interpolate(PatternCursor::effectColumn); } afx_msg void OnInterpolateNote() { Interpolate(PatternCursor::noteColumn); } afx_msg void OnVisualizeEffect(); //rewbs.fxvis - afx_msg void OnOpenRandomizer(); //rewbs.fxvis afx_msg void OnTransposeUp() { TransposeSelection(1); } afx_msg void OnTransposeDown() { TransposeSelection(-1); } afx_msg void OnTransposeOctUp() { TransposeSelection(12); } @@ -432,21 +430,24 @@ bool BuildMiscCtxMenu(HMENU hMenu, CInputHandler *ih) const; bool BuildSelectionCtxMenu(HMENU hMenu, CInputHandler *ih) const; bool BuildGrowShrinkCtxMenu(HMENU hMenu, CInputHandler *ih) const; - bool BuildNoteInterpolationCtxMenu(HMENU hMenu, CInputHandler *ih, CSoundFile *pSndFile) const; - bool BuildVolColInterpolationCtxMenu(HMENU hMenu, CInputHandler *ih, CSoundFile *pSndFile) const; - bool BuildEffectInterpolationCtxMenu(HMENU hMenu, CInputHandler *ih, CSoundFile *pSndFile) const; + bool BuildInterpolationCtxMenu(HMENU hMenu, CInputHandler *ih) const; + bool BuildInterpolationCtxMenu(HMENU hMenu, PatternCursor::Columns colType, CString label, UINT command) const; bool BuildEditCtxMenu(HMENU hMenu, CInputHandler *ih, CModDoc* pModDoc) const; bool BuildVisFXCtxMenu(HMENU hMenu, CInputHandler *ih) const; bool BuildRandomCtxMenu(HMENU hMenu, CInputHandler *ih) const; bool BuildTransposeCtxMenu(HMENU hMenu, CInputHandler *ih) const; - bool BuildSetInstCtxMenu(HMENU hMenu, CInputHandler *ih, CSoundFile *pSndFile) const; + bool BuildSetInstCtxMenu(HMENU hMenu, CInputHandler *ih) const; bool BuildAmplifyCtxMenu(HMENU hMenu, CInputHandler *ih) const; - bool BuildChannelMiscCtxMenu(HMENU hMenu, CSoundFile *pSndFile) const; - bool BuildPCNoteCtxMenu(HMENU hMenu, CInputHandler *ih, CSoundFile *pSndFile) const; + bool BuildChannelMiscCtxMenu(HMENU hMenu) const; + bool BuildPCNoteCtxMenu(HMENU hMenu, CInputHandler *ih) const; - UINT ListChansWhereColSelected(PatternCursor::Columns colType, CArray<UINT, UINT> &chans) const; + // Returns an ordered list of all channels in which a given column type is selected. + CHANNELINDEX ListChansWhereColSelected(PatternCursor::Columns colType, vector<CHANNELINDEX> &chans) const; + // Check if a column type is selected on any channel in the current selection. + bool IsColumnSelected(PatternCursor::Columns colType) const; - bool IsInterpolationPossible(ROWINDEX startRow, ROWINDEX endRow, CHANNELINDEX chan, PatternCursor::Columns colType, CSoundFile *pSndFile) const; + bool IsInterpolationPossible(PatternCursor::Columns colType) const; + bool IsInterpolationPossible(ROWINDEX startRow, ROWINDEX endRow, CHANNELINDEX chan, PatternCursor::Columns colType) const; void Interpolate(PatternCursor::Columns type); // Return true if recording live (i.e. editing while following playback). Modified: trunk/OpenMPT/mptrack/Vstplug.cpp =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.cpp 2012-06-07 13:59:06 UTC (rev 1294) +++ trunk/OpenMPT/mptrack/Vstplug.cpp 2012-06-08 19:36:29 UTC (rev 1295) @@ -859,7 +859,7 @@ case audioMasterGetPreviousPlug: if(pVstPlugin != nullptr) { - CArray<CVstPlugin *, CVstPlugin *> list; + vector<CVstPlugin *> list; pVstPlugin->GetInputPlugList(list); // We don't assign plugins to pins... return ToVstPtr(list[0]); @@ -870,7 +870,7 @@ case audioMasterGetNextPlug: if(pVstPlugin != nullptr) { - CArray<CVstPlugin *, CVstPlugin *> list; + vector<CVstPlugin *> list; pVstPlugin->GetOutputPlugList(list); // We don't assign plugins to pins... return ToVstPtr(list[0]); @@ -2840,12 +2840,12 @@ } -void CVstPlugin::GetOutputPlugList(CArray<CVstPlugin*, CVstPlugin*> &list) -//------------------------------------------------------------------------ +void CVstPlugin::GetOutputPlugList(vector<CVstPlugin *> &list) +//------------------------------------------------------------ { // At the moment we know there will only be 1 output. // Returning nullptr means plugin outputs directly to master. - list.RemoveAll(); + list.clear(); CVstPlugin *pOutputPlug = nullptr; if(!m_pMixStruct->IsOutputToMaster()) @@ -2856,19 +2856,19 @@ pOutputPlug = dynamic_cast<CVstPlugin *>(m_pSndFile->m_MixPlugins[nOutput].pMixPlugin); } } - list.Add(pOutputPlug); + list.push_back(pOutputPlug); return; } -void CVstPlugin::GetInputPlugList(CArray<CVstPlugin*, CVstPlugin*> &list) -//----------------------------------------------------------------------- +void CVstPlugin::GetInputPlugList(vector<CVstPlugin *> &list) +//----------------------------------------------------------- { - if(m_pSndFile == 0) return; + if(m_pSndFile == nullptr) return; - CArray<CVstPlugin*, CVstPlugin*> candidatePlugOutputs; + vector<CVstPlugin *> candidatePlugOutputs; CVstPlugin* pCandidatePlug = nullptr; - list.RemoveAll(); + list.clear(); for (int nPlug = 0; nPlug < MAX_MIXPLUGINS; nPlug++) { @@ -2877,24 +2877,22 @@ { pCandidatePlug->GetOutputPlugList(candidatePlugOutputs); - for(int nOutput=0; nOutput<candidatePlugOutputs.GetSize(); nOutput++) + for(vector<CVstPlugin *>::iterator plug = candidatePlugOutputs.begin(); plug != candidatePlugOutputs.end(); plug++) { - if (candidatePlugOutputs[nOutput] == this) + if(*plug == this) { - list.Add(pCandidatePlug); + list.push_back(pCandidatePlug); break; } } } } - - return; } -void CVstPlugin::GetInputInstrumentList(CArray<UINT,UINT> &list) -//-------------------------------------------------------------- +void CVstPlugin::GetInputInstrumentList(vector<INSTRUMENTINDEX> &list) +//-------------------------------------------------------------------- { - list.RemoveAll(); + list.clear(); if(m_pSndFile == nullptr) return; const PLUGINDEX nThisMixPlug = m_nSlot + 1; //m_nSlot is position in mixplug array. @@ -2902,19 +2900,17 @@ { if (m_pSndFile->Instruments[nIns] != nullptr && (m_pSndFile->Instruments[nIns]->nMixPlug == nThisMixPlug)) { - list.Add(nIns); + list.push_back(nIns); } } - return; - } -void CVstPlugin::GetInputChannelList(CArray<UINT, UINT> &list) -//------------------------------------------------------------ +void CVstPlugin::GetInputChannelList(vector<CHANNELINDEX> &list) +//-------------------------------------------------------------- { - if(m_pSndFile == 0) return; - list.RemoveAll(); + if(m_pSndFile == nullptr) return; + list.clear(); UINT nThisMixPlug = m_nSlot+1; //m_nSlot is position in mixplug array. const CHANNELINDEX chnCount = m_pSndFile->GetNumChannels(); @@ -2922,7 +2918,7 @@ { if (m_pSndFile->ChnSettings[nChn].nMixPlugin==nThisMixPlug) { - list.Add(nChn); + list.push_back(nChn); } } Modified: trunk/OpenMPT/mptrack/Vstplug.h =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.h 2012-06-07 13:59:06 UTC (rev 1294) +++ trunk/OpenMPT/mptrack/Vstplug.h 2012-06-08 19:36:29 UTC (rev 1295) @@ -177,10 +177,10 @@ bool isInstrument(); // ericus 18/02/2005 bool CanRecieveMidiEvents(); - void GetOutputPlugList(CArray<CVstPlugin*,CVstPlugin*> &list); - void GetInputPlugList(CArray<CVstPlugin*,CVstPlugin*> &list); - void GetInputInstrumentList(CArray<UINT,UINT> &list); - void GetInputChannelList(CArray<UINT,UINT> &list); + void GetOutputPlugList(vector<CVstPlugin *> &list); + void GetInputPlugList(vector<CVstPlugin *> &list); + void GetInputInstrumentList(vector<INSTRUMENTINDEX> &list); + void GetInputChannelList(vector<CHANNELINDEX> &list); public: int AddRef() { return ++m_nRefCount; } Modified: trunk/OpenMPT/mptrack/mptrack_08.vcproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_08.vcproj 2012-06-07 13:59:06 UTC (rev 1294) +++ trunk/OpenMPT/mptrack/mptrack_08.vcproj 2012-06-08 19:36:29 UTC (rev 1295) @@ -245,10 +245,6 @@ > </File> <File - RelativePath=".\ArrayUtils.cpp" - > - </File> - <File RelativePath=".\AutoSaver.cpp" > </File> @@ -931,10 +927,6 @@ > </File> <File - RelativePath=".\ArrayUtils.h" - > - </File> - <File RelativePath=".\AutoSaver.h" > </File> Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2012-06-07 13:59:06 UTC (rev 1294) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2012-06-08 19:36:29 UTC (rev 1295) @@ -183,7 +183,6 @@ <ClCompile Include="..\soundlib\XMTools.cpp" /> <ClCompile Include="AbstractVstEditor.cpp" /> <ClCompile Include="ACMConvert.cpp" /> - <ClCompile Include="ArrayUtils.cpp" /> <ClCompile Include="AutoSaver.cpp" /> <ClCompile Include="Autotune.cpp" /> <ClCompile Include="ChannelManagerDlg.cpp" /> @@ -377,7 +376,6 @@ <ClInclude Include="Vertex.h" /> <ClInclude Include="view_graph.h" /> <ClInclude Include="AbstractVstEditor.h" /> - <ClInclude Include="ArrayUtils.h" /> <ClInclude Include="AutoSaver.h" /> <ClInclude Include="ChannelManagerDlg.h" /> <ClInclude Include="ChildFrm.h" /> Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2012-06-07 13:59:06 UTC (rev 1294) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2012-06-08 19:36:29 UTC (rev 1295) @@ -1,9 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup> - <ClCompile Include="ArrayUtils.cpp"> - <Filter>Source Files</Filter> - </ClCompile> <ClCompile Include="AutoSaver.cpp"> <Filter>Source Files</Filter> </ClCompile> @@ -471,9 +468,6 @@ <ClInclude Include="AbstractVstEditor.h"> <Filter>Header Files</Filter> </ClInclude> - <ClInclude Include="ArrayUtils.h"> - <Filter>Header Files</Filter> - </ClInclude> <ClInclude Include="AutoSaver.h"> <Filter>Header Files</Filter> </ClInclude> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2012-06-23 21:08:39
|
Revision: 1307 http://modplug.svn.sourceforge.net/modplug/?rev=1307&view=rev Author: saga-games Date: 2012-06-23 21:08:32 +0000 (Sat, 23 Jun 2012) Log Message: ----------- [Fix] VST: Korg Wavestation plugin GUI didn't work until play was pressed for the first time since revision 1230. Revision Links: -------------- http://modplug.svn.sourceforge.net/modplug/?rev=1230&view=rev Modified Paths: -------------- trunk/OpenMPT/mptrack/Vstplug.cpp trunk/OpenMPT/mptrack/Vstplug.h Modified: trunk/OpenMPT/mptrack/Vstplug.cpp =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.cpp 2012-06-23 14:47:45 UTC (rev 1306) +++ trunk/OpenMPT/mptrack/Vstplug.cpp 2012-06-23 21:08:32 UTC (rev 1307) @@ -1398,7 +1398,7 @@ } - m_nSampleRate=CSoundFile::gdwMixingFreq; + m_nSampleRate = CSoundFile::gdwMixingFreq; Dispatch(effSetSampleRate, 0, 0, nullptr, static_cast<float>(CSoundFile::gdwMixingFreq)); Dispatch(effSetBlockSize, 0, MIXBUFFERSIZE, nullptr, 0.0f); if (m_pEffect->numPrograms > 0) @@ -1427,9 +1427,17 @@ RecalculateGain(); m_pProcessFP = (m_pEffect->flags & effFlagsCanReplacing) ? m_pEffect->processReplacing : m_pEffect->process; - // issue samplerate again here, cos some plugs like it before the block size, other like it right at the end. + // issue samplerate again here, cos some plugs like it before the block size, other like it right at the end. Dispatch(effSetSampleRate, 0, 0, nullptr, static_cast<float>(CSoundFile::gdwMixingFreq)); + // Korg Wavestation GUI won't work until plugin was resumed at least once. + // On the other hand, some other plugins (notably Synthedit plugins like Superwave P8 2.3 or Rez 3.0) don't like this + // and won't load their stored plugin data properly, so only do this for the Korg Wavestation... + if(GetUID() == CCONST('K', 'L', 'W', 'V')) + { + Resume(); + Suspend(); + } } @@ -2840,76 +2848,84 @@ } -void CVstPlugin::GetOutputPlugList(vector<CVstPlugin *> &list) -//------------------------------------------------------------ +// Get list of plugins to which output is sent. A nullptr indicates master output. +size_t CVstPlugin::GetOutputPlugList(vector<CVstPlugin *> &list) +//-------------------------------------------------------------- { // At the moment we know there will only be 1 output. // Returning nullptr means plugin outputs directly to master. list.clear(); - CVstPlugin *pOutputPlug = nullptr; + CVstPlugin *outputPlug = nullptr; if(!m_pMixStruct->IsOutputToMaster()) { PLUGINDEX nOutput = m_pMixStruct->GetOutputPlugin(); if(m_pSndFile && nOutput > m_nSlot && nOutput != PLUGINDEX_INVALID) { - pOutputPlug = dynamic_cast<CVstPlugin *>(m_pSndFile->m_MixPlugins[nOutput].pMixPlugin); + outputPlug = dynamic_cast<CVstPlugin *>(m_pSndFile->m_MixPlugins[nOutput].pMixPlugin); } } - list.push_back(pOutputPlug); + list.push_back(outputPlug); - return; + return 1; } -void CVstPlugin::GetInputPlugList(vector<CVstPlugin *> &list) -//----------------------------------------------------------- + +// Get a list of plugins that send data to this plugin. +size_t CVstPlugin::GetInputPlugList(vector<CVstPlugin *> &list) +//------------------------------------------------------------- { - if(m_pSndFile == nullptr) return; + if(m_pSndFile == nullptr) return 0; vector<CVstPlugin *> candidatePlugOutputs; - CVstPlugin* pCandidatePlug = nullptr; list.clear(); - for (int nPlug = 0; nPlug < MAX_MIXPLUGINS; nPlug++) + for(PLUGINDEX plug = 0; plug < MAX_MIXPLUGINS; plug++) { - pCandidatePlug = dynamic_cast<CVstPlugin *>(m_pSndFile->m_MixPlugins[nPlug].pMixPlugin); - if (pCandidatePlug) + CVstPlugin *candidatePlug = dynamic_cast<CVstPlugin *>(m_pSndFile->m_MixPlugins[plug].pMixPlugin); + if(candidatePlug) { - pCandidatePlug->GetOutputPlugList(candidatePlugOutputs); + candidatePlug->GetOutputPlugList(candidatePlugOutputs); - for(vector<CVstPlugin *>::iterator plug = candidatePlugOutputs.begin(); plug != candidatePlugOutputs.end(); plug++) + for(vector<CVstPlugin *>::iterator iter = candidatePlugOutputs.begin(); iter != candidatePlugOutputs.end(); iter++) { - if(*plug == this) + if(*iter == this) { - list.push_back(pCandidatePlug); + list.push_back(candidatePlug); break; } } } } + + return list.size(); } -void CVstPlugin::GetInputInstrumentList(vector<INSTRUMENTINDEX> &list) -//-------------------------------------------------------------------- + +// Get a list of instruments that send data to this plugin. +size_t CVstPlugin::GetInputInstrumentList(vector<INSTRUMENTINDEX> &list) +//---------------------------------------------------------------------- { list.clear(); - if(m_pSndFile == nullptr) return; + if(m_pSndFile == nullptr) return 0; const PLUGINDEX nThisMixPlug = m_nSlot + 1; //m_nSlot is position in mixplug array. - for (int nIns = 0; nIns <= m_pSndFile->GetNumInstruments(); nIns++) + for(INSTRUMENTINDEX ins = 0; ins <= m_pSndFile->GetNumInstruments(); ins++) { - if (m_pSndFile->Instruments[nIns] != nullptr && (m_pSndFile->Instruments[nIns]->nMixPlug == nThisMixPlug)) + if(m_pSndFile->Instruments[ins] != nullptr && (m_pSndFile->Instruments[ins]->nMixPlug == nThisMixPlug)) { - list.push_back(nIns); + list.push_back(ins); } } + return list.size(); } -void CVstPlugin::GetInputChannelList(vector<CHANNELINDEX> &list) -//-------------------------------------------------------------- + +size_t CVstPlugin::GetInputChannelList(vector<CHANNELINDEX> &list) +//---------------------------------------------------------------- { - if(m_pSndFile == nullptr) return; + if(m_pSndFile == nullptr) return 0; list.clear(); UINT nThisMixPlug = m_nSlot+1; //m_nSlot is position in mixplug array. @@ -2922,7 +2938,7 @@ } } - return; + return list.size(); } Modified: trunk/OpenMPT/mptrack/Vstplug.h =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.h 2012-06-23 14:47:45 UTC (rev 1306) +++ trunk/OpenMPT/mptrack/Vstplug.h 2012-06-23 21:08:32 UTC (rev 1307) @@ -177,10 +177,10 @@ bool isInstrument(); // ericus 18/02/2005 bool CanRecieveMidiEvents(); - void GetOutputPlugList(vector<CVstPlugin *> &list); - void GetInputPlugList(vector<CVstPlugin *> &list); - void GetInputInstrumentList(vector<INSTRUMENTINDEX> &list); - void GetInputChannelList(vector<CHANNELINDEX> &list); + size_t GetOutputPlugList(vector<CVstPlugin *> &list); + size_t GetInputPlugList(vector<CVstPlugin *> &list); + size_t GetInputInstrumentList(vector<INSTRUMENTINDEX> &list); + size_t GetInputChannelList(vector<CHANNELINDEX> &list); public: int AddRef() { return ++m_nRefCount; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2012-06-23 21:30:58
|
Revision: 1308 http://modplug.svn.sourceforge.net/modplug/?rev=1308&view=rev Author: saga-games Date: 2012-06-23 21:30:51 +0000 (Sat, 23 Jun 2012) Log Message: ----------- [New] VST: Plugin selection dialog categorizes plugins by their plugin type (as reported by the plugin). Modified Paths: -------------- trunk/OpenMPT/mptrack/SelectPluginDialog.cpp trunk/OpenMPT/mptrack/SelectPluginDialog.h trunk/OpenMPT/mptrack/Vstplug.cpp trunk/OpenMPT/mptrack/Vstplug.h Modified: trunk/OpenMPT/mptrack/SelectPluginDialog.cpp =================================================================== --- trunk/OpenMPT/mptrack/SelectPluginDialog.cpp 2012-06-23 21:08:32 UTC (rev 1307) +++ trunk/OpenMPT/mptrack/SelectPluginDialog.cpp 2012-06-23 21:30:51 UTC (rev 1308) @@ -244,29 +244,55 @@ } -void CSelectPluginDlg::UpdatePluginsList(DWORD forceSelect /* = 0*/) -//------------------------------------------------------------------ +void CSelectPluginDlg::UpdatePluginsList(VstInt32 forceSelect /* = 0*/) +//--------------------------------------------------------------------- { CVstPluginManager *pManager = theApp.GetPluginManager(); - HTREEITEM cursel, hDmo, hVst, hSynth; + HTREEITEM curSelection, categoryFolders[VSTPluginLib::numCategories]; + vector<bool> categoryUsed(VSTPluginLib::numCategories, false); m_treePlugins.SetRedraw(FALSE); m_treePlugins.DeleteAllItems(); - hSynth = AddTreeItem("VST Instruments", IMAGE_FOLDER, false); - hDmo = AddTreeItem("DirectX Media Audio Effects", IMAGE_FOLDER, false); - hVst = AddTreeItem("VST Audio Effects", IMAGE_FOLDER, false); - cursel = AddTreeItem("No plugin (empty slot)", IMAGE_NOPLUGIN, false); + static const struct + { + VSTPluginLib::PluginCategory category; + const char *description; + } categories[] = + { + { VSTPluginLib::catEffect, "Audio Effects" }, + { VSTPluginLib::catGenerator, "Tone Generators" }, + { VSTPluginLib::catRestoration, "Audio Restauration" }, + { VSTPluginLib::catSurroundFx, "Surround Effects" }, + { VSTPluginLib::catRoomFx, "Room Effects" }, + { VSTPluginLib::catSpacializer, "Spacializers" }, + { VSTPluginLib::catMastering, "Mastering Plugins" }, + { VSTPluginLib::catAnalysis, "Analysis Plugins" }, + { VSTPluginLib::catOfflineProcess, "Offline Processing" }, + { VSTPluginLib::catShell, "Shell Plugins" }, + { VSTPluginLib::catUnknown, "Unsorted" }, + { VSTPluginLib::catDMO, "DirectX Media Audio Effects" }, + { VSTPluginLib::catSynth, "Instrument Plugins" }, + }; + + for(size_t i = CountOf(categories); i != 0; ) + { + i--; + categoryFolders[categories[i].category] = AddTreeItem(categories[i].description, IMAGE_FOLDER, false); + } + curSelection = AddTreeItem("No plugin (empty slot)", IMAGE_NOPLUGIN, false); - if (pManager) + if(pManager) { - VSTPluginLib *pCurrent = NULL; + const bool nameFilterActive = !m_sNameFilter.IsEmpty(); + + VSTPluginLib *pCurrent = nullptr; VSTPluginLib *p = pManager->GetFirstPlugin(); - while (p) + while(p) { - // Apply name filter - if (m_sNameFilter != "") + if(nameFilterActive) { + // Apply name filter CString displayName = p->szLibraryName; if (displayName.MakeLower().Find(m_sNameFilter) == -1) { @@ -275,95 +301,92 @@ } } - HTREEITEM hParent; - if (p->dwPluginId1 == kDmoMagic) + HTREEITEM h = AddTreeItem(p->szLibraryName, p->isInstrument ? IMAGE_PLUGININSTRUMENT : IMAGE_EFFECTPLUGIN, true, categoryFolders[p->category], reinterpret_cast<LPARAM>(p)); + categoryUsed[p->category] = true; + + if(nameFilterActive) { - hParent = hDmo; - } else - { - hParent = (p->isInstrument) ? hSynth : hVst; + // If filter is active, expand nodes. + m_treePlugins.EnsureVisible(h); } - HTREEITEM h = AddTreeItem(p->szLibraryName, p->isInstrument ? IMAGE_PLUGININSTRUMENT : IMAGE_EFFECTPLUGIN, true, hParent, (LPARAM)p); - - //If filter is active, expand nodes. - if (m_sNameFilter != "") m_treePlugins.EnsureVisible(h); - - //Which plugin should be selected? - if (m_pPlugin) + if(m_pPlugin) { + //Which plugin should be selected? - //forced selection (e.g. just after add plugin) - if (forceSelect != 0) + if(forceSelect != 0 && p->dwPluginId2 == forceSelect) { - if (p->dwPluginId2 == forceSelect) - { - pCurrent = p; - } - } - - //Current slot's plugin - else if (m_pPlugin->pMixPlugin) + //forced selection (e.g. just after add plugin) + pCurrent = p; + } else if(m_pPlugin->pMixPlugin) { + //Current slot's plugin CVstPlugin *pVstPlug = (CVstPlugin *)m_pPlugin->pMixPlugin; if (pVstPlug->GetPluginFactory() == p) pCurrent = p; - } - - //Plugin with matching ID to current slot's plug - else if (/* (!pCurrent) && */ m_pPlugin->Info.dwPluginId1 !=0 || m_pPlugin->Info.dwPluginId2 != 0) + } else if(m_pPlugin->Info.dwPluginId1 != 0 || m_pPlugin->Info.dwPluginId2 != 0) { - if ((p->dwPluginId1 == m_pPlugin->Info.dwPluginId1) - && (p->dwPluginId2 == m_pPlugin->Info.dwPluginId2)) + //Plugin with matching ID to current slot's plug + if(p->dwPluginId1 == m_pPlugin->Info.dwPluginId1 + && p->dwPluginId2 == m_pPlugin->Info.dwPluginId2) { pCurrent = p; } - } - - //Last selected plugin - else + } else { + //Last selected plugin if (p->dwPluginId2 == CMainFrame::GetSettings().gnPlugWindowLast) { pCurrent = p; } } } - if (pCurrent == p) cursel = h; + + if(pCurrent == p) + { + curSelection = h; + } + p = p->pNext; } } + + // Remove empty categories + for(size_t i = 0; i < CountOf(categoryFolders); i++) + { + if(!categoryUsed[i]) + { + m_treePlugins.DeleteItem(categoryFolders[i]); + } + } + m_treePlugins.SetRedraw(TRUE); - if (cursel) + if(curSelection) { - m_treePlugins.SelectItem(cursel); - m_treePlugins.SetItemState(cursel, TVIS_BOLD, TVIS_BOLD); - m_treePlugins.EnsureVisible(cursel); + m_treePlugins.SelectItem(curSelection); + m_treePlugins.SetItemState(curSelection, TVIS_BOLD, TVIS_BOLD); + m_treePlugins.EnsureVisible(curSelection); } } -HTREEITEM CSelectPluginDlg::AddTreeItem(LPSTR szTitle, int iImage, bool bSort, HTREEITEM hParent, LPARAM lParam) -//-------------------------------------------------------------------------------------------------------------- + +HTREEITEM CSelectPluginDlg::AddTreeItem(const char *title, int image, bool sort, HTREEITEM hParent, LPARAM lParam) +//---------------------------------------------------------------------------------------------------------------- { - TVINSERTSTRUCT tvis; - MemsetZero(tvis); - - tvis.hParent = hParent; - tvis.hInsertAfter = (bSort) ? TVI_SORT : TVI_FIRST; - tvis.item.mask = TVIF_IMAGE | TVIF_PARAM | TVIF_TEXT | TVIF_SELECTEDIMAGE | TVIF_TEXT; - tvis.item.pszText = szTitle; - tvis.item.iImage = tvis.item.iSelectedImage = iImage; - tvis.item.lParam = lParam; - return m_treePlugins.InsertItem(&tvis); + return m_treePlugins.InsertItem( + TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM | TVIF_TEXT, + title, + image, image, + 0, 0, + lParam, + hParent, + (sort ? TVI_SORT : TVI_FIRST)); } void CSelectPluginDlg::OnSelDblClk(NMHDR *, LRESULT *result) //---------------------------------------------------------- { - // -> CODE#0002 - // -> DESC="list box to choose VST plugin presets (programs)" - if(m_pPlugin == NULL) return; - // -! NEW_FEATURE#0002 + if(m_pPlugin == nullptr) return; HTREEITEM hSel = m_treePlugins.GetSelectedItem(); int nImage, nSelectedImage; @@ -390,34 +413,30 @@ } -struct PROBLEMATIC_PLUG -{ - DWORD id1; - DWORD id2; - DWORD version; - LPCSTR name; - LPCSTR problem; -}; - -//TODO: Check whether the list is still valid. -static const PROBLEMATIC_PLUG gProblemPlugs[] = -{ - { kEffectMagic, CCONST('N', 'i', '4', 'S'), 1, "Native Instruments B4", "* v1.1.1 hangs on playback. Do not proceed unless you have v1.1.5 or newer. *" }, - { kEffectMagic, CCONST('m', 'd', 'a', 'C'), 1, "MDA Degrade", "* Old versions of this plugin can crash OpenMPT.\nEnsure that you have the latest version of this plugin. *" }, - { kEffectMagic, CCONST('f', 'V', '2', 's'), 1, "Farbrausch V2", "* This plugin can cause OpenMPT to freeze if being used in a combination with various other plugins.\nIt is recommended to not use V2 in combination with any other plugins. *" }, - { kEffectMagic, CCONST('f', 'r', 'V', '2'), 1, "Farbrausch V2", "* This plugin can cause OpenMPT to freeze if being used in a combination with various other plugins.\nIt is recommended to not use V2 in combination with any other plugins. *" }, -}; - bool CSelectPluginDlg::VerifyPlug(VSTPluginLib *plug) //--------------------------------------------------- { - CString s; - for (size_t p = 0; p < CountOf(gProblemPlugs); p++) + // TODO: Keep this list up-to-date. + static const struct { - if ( (gProblemPlugs[p].id2 == plug->dwPluginId2) - /*&& (gProblemPlugs[p].id1 == plug->dwPluginId1)*/) + VstInt32 id1; + VstInt32 id2; + char *name; + char *problem; + } problemPlugs[] = + { + { kEffectMagic, CCONST('N', 'i', '4', 'S'), "Native Instruments B4", "* v1.1.1 hangs on playback. Do not proceed unless you have v1.1.5 or newer. *" }, + { kEffectMagic, CCONST('m', 'd', 'a', 'C'), "MDA Degrade", "* Old versions of this plugin can crash OpenMPT.\nEnsure that you have the latest version of this plugin. *" }, + { kEffectMagic, CCONST('f', 'V', '2', 's'), "Farbrausch V2", "* This plugin can cause OpenMPT to freeze if being used in a combination with various other plugins.\nIt is recommended to not use V2 in combination with any other plugins. *" }, + { kEffectMagic, CCONST('f', 'r', 'V', '2'), "Farbrausch V2", "* This plugin can cause OpenMPT to freeze if being used in a combination with various other plugins.\nIt is recommended to not use V2 in combination with any other plugins. *" }, + }; + + for(size_t p = 0; p < CountOf(problemPlugs); p++) + { + if(problemPlugs[p].id2 == plug->dwPluginId2 /*&& gProblemPlugs[p].id1 == plug->dwPluginId1*/) { - s.Format("WARNING: This plugin has been identified as %s,\nwhich is known to have the following problem with OpenMPT:\n\n%s\n\nWould you still like to add this plugin to the library?", gProblemPlugs[p].name, gProblemPlugs[p].problem); + CString s; + s.Format("WARNING: This plugin has been identified as %s,\nwhich is known to have the following problem with OpenMPT:\n\n%s\n\nWould you still like to add this plugin to the library?", problemPlugs[p].name, problemPlugs[p].problem); return (Reporting::Confirm(s) == cnfYes); } } @@ -448,7 +467,7 @@ if (pManager) { - plugLib = pManager->AddPlugin(sFilename, FALSE); + plugLib = pManager->AddPlugin(sFilename, false); if (plugLib) { bOk = true; Modified: trunk/OpenMPT/mptrack/SelectPluginDialog.h =================================================================== --- trunk/OpenMPT/mptrack/SelectPluginDialog.h 2012-06-23 21:08:32 UTC (rev 1307) +++ trunk/OpenMPT/mptrack/SelectPluginDialog.h 2012-06-23 21:30:51 UTC (rev 1308) @@ -26,13 +26,13 @@ CTreeCtrl m_treePlugins; CString m_sNameFilter; - HTREEITEM AddTreeItem(LPSTR szTitle, int iImage, bool bSort, HTREEITEM hParent = TVI_ROOT, LPARAM lParam = NULL); + HTREEITEM AddTreeItem(const char *title, int image, bool sort, HTREEITEM hParent = TVI_ROOT, LPARAM lParam = NULL); public: CSelectPluginDlg(CModDoc *pModDoc, int nPlugSlot, CWnd *parent); //rewbs.plugDocAware ~CSelectPluginDlg(); void DoClose(); - void UpdatePluginsList(DWORD forceSelect = 0); + void UpdatePluginsList(VstInt32 forceSelect = 0); bool VerifyPlug(VSTPluginLib *plug); virtual void DoDataExchange(CDataExchange* pDX); virtual BOOL OnInitDialog(); Modified: trunk/OpenMPT/mptrack/Vstplug.cpp =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.cpp 2012-06-23 21:08:32 UTC (rev 1307) +++ trunk/OpenMPT/mptrack/Vstplug.cpp 2012-06-23 21:30:51 UTC (rev 1308) @@ -161,6 +161,7 @@ p->pNext = m_pVstHead; p->dwPluginId1 = kDmoMagic; p->dwPluginId2 = clsid.Data1; + p->category = VSTPluginLib::catDMO; lstrcpyn(p->szLibraryName, s, sizeof(p->szLibraryName)); StringFixer::SetNullTerminator(p->szLibraryName); @@ -246,14 +247,32 @@ } } + +// Extract instrument and category information from plugin. +void GetPluginInformation(AEffect *effect, VSTPluginLib &library) +//--------------------------------------------------------------- +{ + library.category = static_cast<VSTPluginLib::PluginCategory>(effect->dispatcher(effect, effGetPlugCategory, 0, nullptr, nullptr, 0.0f)); + library.isInstrument = ((effect->flags & effFlagsIsSynth) || !effect->numInputs); + + if(library.isInstrument) + { + library.category = VSTPluginLib::catSynth; + } else if(library.category >= VSTPluginLib::numCategories) + { + library.category = VSTPluginLib::catUnknown; + } +} + + // // PluginCache format: // LibraryName = ID100000ID200000 // ID100000ID200000 = FullDllPath -// ID100000ID200000.Flags = Plugin Flags (for now, just isInstrument). +// ID100000ID200000.Flags = Plugin Flags (isInstrument + category). -VSTPluginLib *CVstPluginManager::AddPlugin(LPCSTR pszDllPath, BOOL bCache, const bool checkFileExistence, CString *const errStr) -//------------------------------------------------------------------------------------------------------------------------------ +VSTPluginLib *CVstPluginManager::AddPlugin(LPCSTR pszDllPath, bool fromCache, const bool checkFileExistence, CString *const errStr) +//--------------------------------------------------------------------------------------------------------------------------------- { TCHAR szPath[_MAX_PATH]; @@ -273,7 +292,7 @@ pDup = pDup->pNext; } // Look if the plugin info is stored in the PluginCache - if (bCache) + if(fromCache) { const CString cacheSection = "PluginCache"; const CString cacheFile = theApp.GetPluginCacheFileName(); @@ -313,16 +332,17 @@ n &= 0x0f; if (i < 8) { - p->dwPluginId1 = (p->dwPluginId1<<4) | n; + p->dwPluginId1 = (p->dwPluginId1 << 4) | n; } else { - p->dwPluginId2 = (p->dwPluginId2<<4) | n; + p->dwPluginId2 = (p->dwPluginId2 << 4) | n; } } + CString flagKey; flagKey.Format("%s.Flags", IDs); - int infoex = CMainFrame::GetPrivateProfileLong(cacheSection, flagKey, 0, cacheFile); - if (infoex & 1) p->isInstrument = true; + p->DecodeCacheFlags(CMainFrame::GetPrivateProfileLong(cacheSection, flagKey, 0, cacheFile)); + #ifdef VST_USE_ALTERNATIVE_MAGIC if( p->dwPluginId1 == kEffectMagic ) { @@ -378,8 +398,9 @@ p->dwPluginId1 = pEffect->magic; #endif // VST_USE_ALTERNATIVE_MAGIC p->dwPluginId2 = pEffect->uniqueID; - p->isInstrument = ((pEffect->flags & effFlagsIsSynth) || !pEffect->numInputs); + GetPluginInformation(pEffect, *p); + #ifdef VST_LOG int nver = pEffect->dispatcher(pEffect, effGetVstVersion, 0,0, nullptr, 0); if (!nver) nver = pEffect->version; @@ -423,7 +444,7 @@ WritePrivateProfileString(cacheSection, IDs, szPath, cacheFile); CMainFrame::WritePrivateProfileCString(cacheSection, IDs, pszDllPath, cacheFile); CMainFrame::WritePrivateProfileCString(cacheSection, p->szLibraryName, IDs, cacheFile); - CMainFrame::WritePrivateProfileLong(cacheSection, flagsKey, p->isInstrument, cacheFile); + CMainFrame::WritePrivateProfileLong(cacheSection, flagsKey, p->EncodeCacheFlags(), cacheFile); } return (validPlug ? m_pVstHead : nullptr); @@ -579,20 +600,21 @@ { validPlugin = true; - if(pEffect->flags & effFlagsIsSynth || !pEffect->numInputs) + const bool oldIsInstrument = pFound->isInstrument; + const VSTPluginLib::PluginCategory oldCategory = pFound->category; + + GetPluginInformation(pEffect, *pFound); + + if(oldIsInstrument != pFound->isInstrument || oldCategory != pFound->category) { - // Flag as instrument plugin - if (!pFound->isInstrument) - { - CString cacheSection = "PluginCache"; - CString cacheFile = theApp.GetPluginCacheFileName(); - //LPCSTR pszSection = "PluginCache"; - pFound->isInstrument = true; - CString flagsKey; - flagsKey.Format("%08X%08X.Flags", pFound->dwPluginId1, pFound->dwPluginId2); - CMainFrame::WritePrivateProfileLong(cacheSection, flagsKey, 1, cacheFile); - } + // Update cached information + CString cacheSection = "PluginCache"; + CString cacheFile = theApp.GetPluginCacheFileName(); + CString flagsKey; + flagsKey.Format("%08X%08X.Flags", pFound->dwPluginId1, pFound->dwPluginId2); + CMainFrame::WritePrivateProfileLong(cacheSection, flagsKey, pFound->EncodeCacheFlags(), cacheFile); } + CVstPlugin *pVstPlug = new CVstPlugin(hLibrary, pFound, pMixPlugin, pEffect); if (pVstPlug) pVstPlug->Initialize(pSndFile); } Modified: trunk/OpenMPT/mptrack/Vstplug.h =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.h 2012-06-23 21:08:32 UTC (rev 1307) +++ trunk/OpenMPT/mptrack/Vstplug.h 2012-06-23 21:30:51 UTC (rev 1308) @@ -37,10 +37,32 @@ struct VSTPluginLib { + enum PluginCategory + { + // Same plugin categories as defined in VST SDK + catUnknown = 0, + catEffect, // Simple Effect + catSynth, // VST Instrument (Synths, samplers,...) + catAnalysis, // Scope, Tuner, ... + catMastering, // Dynamics, ... + catSpacializer, // Panners, ... + catRoomFx, // Delays and Reverbs + catSurroundFx, // Dedicated surround processor + catRestoration, // Denoiser, ... + catOfflineProcess, // Offline Process + catShell, // Plug-in is container of other plug-ins + catGenerator, // Tone Generator, ... + // Custom categories + catDMO, // DirectX media object plugin + + numCategories, + }; + VSTPluginLib *pPrev, *pNext; VstInt32 dwPluginId1; VstInt32 dwPluginId2; bool isInstrument; + PluginCategory category; CVstPlugin *pPluginsList; CHAR szLibraryName[_MAX_FNAME]; CHAR szDllPath[_MAX_PATH]; @@ -51,12 +73,32 @@ dwPluginId1 = dwPluginId2 = 0; isInstrument = false; pPluginsList = nullptr; + category = catUnknown; if(dllPath != nullptr) { lstrcpyn(szDllPath, dllPath, CountOf(szDllPath)); StringFixer::SetNullTerminator(szDllPath); } } + + uint32 EncodeCacheFlags() + { + return (isInstrument ? 1 : 0) | (category << 1); + } + + void DecodeCacheFlags(uint32 flags) + { + category = static_cast<PluginCategory>(flags >> 1); + if(category >= numCategories) + { + category = catUnknown; + } + if(flags & 1) + { + isInstrument = true; + category = catSynth; + } + } }; @@ -281,7 +323,7 @@ public: VSTPluginLib *GetFirstPlugin() const { return m_pVstHead; } BOOL IsValidPlugin(const VSTPluginLib *pLib); - VSTPluginLib *AddPlugin(LPCSTR pszDllPath, BOOL bCache=TRUE, const bool checkFileExistence = false, CString* const errStr = 0); + VSTPluginLib *AddPlugin(LPCSTR pszDllPath, bool fromCache = true, const bool checkFileExistence = false, CString* const errStr = 0); bool RemovePlugin(VSTPluginLib *); BOOL CreateMixPlugin(SNDMIXPLUGIN *, CSoundFile *); void OnIdle(); @@ -305,7 +347,7 @@ #else // NO_VST public: - VSTPluginLib *AddPlugin(LPCSTR, BOOL =TRUE, const bool = false, CString* const = 0) {return 0;} + VSTPluginLib *AddPlugin(LPCSTR, bool = true, const bool = false, CString* const = 0) {return 0;} VSTPluginLib *GetFirstPlugin() const { return 0; } void OnIdle() {} #endif // NO_VST This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2012-06-30 18:26:45
|
Revision: 1311 http://modplug.svn.sourceforge.net/modplug/?rev=1311&view=rev Author: saga-games Date: 2012-06-30 18:26:37 +0000 (Sat, 30 Jun 2012) Log Message: ----------- [New] Pattern Editor: Middle-clicking or Ctrl-Right-clicking a channel header shows quick channel properties, where channel name, volume and pan settings can be configured. [Reg] Pattern Editor: Removed "rename channel" channel header context menu entry in favour of new quick channel settings. [Ref] Refactored some pattern drawing code. [Mod] OpenMPT: Version is now 1.20.01.10 Modified Paths: -------------- trunk/OpenMPT/mptrack/Draw_pat.cpp trunk/OpenMPT/mptrack/KeyConfigDlg.cpp trunk/OpenMPT/mptrack/KeyConfigDlg.h trunk/OpenMPT/mptrack/PatternCursor.h trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp trunk/OpenMPT/mptrack/PatternEditorDialogs.h trunk/OpenMPT/mptrack/View_pat.cpp trunk/OpenMPT/mptrack/View_pat.h trunk/OpenMPT/mptrack/mptrack.rc trunk/OpenMPT/mptrack/resource.h trunk/OpenMPT/mptrack/version.h Modified: trunk/OpenMPT/mptrack/Draw_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/Draw_pat.cpp 2012-06-30 18:16:43 UTC (rev 1310) +++ trunk/OpenMPT/mptrack/Draw_pat.cpp 2012-06-30 18:26:37 UTC (rev 1311) @@ -532,7 +532,9 @@ CModDoc *pModDoc; CSoundFile *pSndFile; HDC hdc; - UINT xofs, yofs, nColumnWidth, ncols, nrows, ncolhdr; + CHANNELINDEX xofs; + ROWINDEX yofs; + UINT nColumnWidth, ncols, nrows, ncolhdr; int xpaint, ypaint, mixPlug; ASSERT(pDC); @@ -541,8 +543,8 @@ GetClientRect(&rcClient); hdc = pDC->m_hDC; oldpen = ::SelectObject(hdc, CMainFrame::penDarkGray); - xofs = GetXScrollPos(); - yofs = GetYScrollPos(); + xofs = static_cast<CHANNELINDEX>(GetXScrollPos()); + yofs = static_cast<ROWINDEX>(GetYScrollPos()); pSndFile = pModDoc->GetSoundFile(); nColumnWidth = m_szCell.cx; nrows = (pSndFile->Patterns[m_nPattern]) ? pSndFile->Patterns[m_nPattern].GetNumRows() : 0; @@ -663,8 +665,7 @@ } else { UINT nSkip = m_nMidRow - yofs; - UINT nPrevPat = m_nPattern; - bool bPrevPatFound = false; + PATTERNINDEX nPrevPat = PATTERNINDEX_INVALID; // Display previous pattern if (CMainFrame::GetSettings().m_dwPatternSetup & PATTERN_SHOWPREVIOUS) @@ -678,20 +679,19 @@ if(startOrder < pSndFile->Order.size() && pSndFile->Order[startOrder] == m_nPattern) { nPrevPat = pSndFile->Order[prevOrder]; - bPrevPatFound = true; } } } - if ((bPrevPatFound) && (nPrevPat < pSndFile->Patterns.Size()) && (pSndFile->Patterns[nPrevPat])) + if(pSndFile->Patterns.IsValidPat(nPrevPat)) { ROWINDEX nPrevRows = pSndFile->Patterns[nPrevPat].GetNumRows(); - UINT n = min(nSkip, nPrevRows); + ROWINDEX n = min(static_cast<ROWINDEX>(nSkip), nPrevRows); - ypaint += (nSkip-n)*m_szCell.cy; + ypaint += (nSkip - n) * m_szCell.cy; rect.SetRect(0, m_szHeader.cy, nColumnWidth * ncols + m_szHeader.cx, ypaint - 1); m_Dib.SetBlendMode(0x80); - DrawPatternData(hdc, pSndFile, nPrevPat, FALSE, FALSE, - nPrevRows-n, nPrevRows, xofs, rcClient, &ypaint); + DrawPatternData(hdc, pSndFile, nPrevPat, false, false, + nPrevRows - n, nPrevRows, xofs, rcClient, &ypaint); m_Dib.SetBlendMode(0); } else { @@ -708,7 +708,7 @@ } } int ypatternend = ypaint + (nrows-yofs)*m_szCell.cy; - DrawPatternData(hdc, pSndFile, m_nPattern, TRUE, (pMainFrm->GetModPlaying() == pModDoc) ? TRUE : FALSE, + DrawPatternData(hdc, pSndFile, m_nPattern, TRUE, (pMainFrm->GetModPlaying() == pModDoc), yofs, nrows, xofs, rcClient, &ypaint); // Display next pattern if ((CMainFrame::GetSettings().m_dwPatternSetup & PATTERN_SHOWPREVIOUS) && (ypaint < rcClient.bottom) && (ypaint == ypatternend)) @@ -716,8 +716,7 @@ int nVisRows = (rcClient.bottom - ypaint + m_szCell.cy - 1) / m_szCell.cy; if ((nVisRows > 0) && (m_nMidRow)) { - PATTERNINDEX nNextPat = m_nPattern; - bool bNextPatFound = false; + PATTERNINDEX nNextPat = PATTERNINDEX_INVALID; const ORDERINDEX startOrder= static_cast<ORDERINDEX>(SendCtrlMessage(CTRLMSG_GETCURRENTORDER)); ORDERINDEX nNextOrder = pSndFile->Order.GetNextOrderIgnoringSkips(startOrder); @@ -725,18 +724,17 @@ //Ignore skip items(+++) from sequence. const ORDERINDEX ordCount = pSndFile->Order.GetLength(); - if ((nNextOrder < ordCount) && (pSndFile->Order[startOrder] == m_nPattern)) + if(nNextOrder < ordCount && pSndFile->Order[startOrder] == m_nPattern) { nNextPat = pSndFile->Order[nNextOrder]; - bNextPatFound = true; } - if ((bNextPatFound) && (nNextPat < pSndFile->Patterns.Size()) && (pSndFile->Patterns[nNextPat])) + if(pSndFile->Patterns.IsValidPat(nNextPat)) { ROWINDEX nNextRows = pSndFile->Patterns[nNextPat].GetNumRows(); - UINT n = min((UINT)nVisRows, nNextRows); + ROWINDEX n = min(static_cast<ROWINDEX>(nVisRows), nNextRows); m_Dib.SetBlendMode(0x80); - DrawPatternData(hdc, pSndFile, nNextPat, FALSE, FALSE, + DrawPatternData(hdc, pSndFile, nNextPat, false, false, 0, n, xofs, rcClient, &ypaint); m_Dib.SetBlendMode(0); } @@ -779,11 +777,11 @@ } -void CViewPattern::DrawPatternData(HDC hdc, CSoundFile *pSndFile, UINT nPattern, BOOL bSelEnable, - BOOL bPlaying, UINT yofs, UINT nrows, UINT xofs, CRect &rcClient, int *pypaint) -//----------------------------------------------------------------------------------------------------- +void CViewPattern::DrawPatternData(HDC hdc, CSoundFile *pSndFile, PATTERNINDEX nPattern, bool selEnable, + bool isPlaying, ROWINDEX startRow, ROWINDEX numRows, CHANNELINDEX startChan, CRect &rcClient, int *pypaint) +//--------------------------------------------------------------------------------------------------------------------------------- { - BYTE bColSel[MAX_BASECHANNELS]; + uint8 selectedCols[MAX_BASECHANNELS]; // Bit mask of selected channel components static_assert(PatternCursor::lastColumn <= 7, "Columns are used as bitmasks here."); PCPATTERNFONT pfnt = GetCurrentPatternFont(); @@ -793,31 +791,21 @@ CRect rect; int xpaint, ypaint = *pypaint; int row_col, row_bkcol; - UINT bSpeedUp, nColumnWidth, ncols, maxcol; + UINT bSpeedUp, nColumnWidth; - ncols = pSndFile->GetNumChannels(); + CHANNELINDEX ncols = pSndFile->GetNumChannels(); nColumnWidth = m_szCell.cx; rect.SetRect(m_szHeader.cx, rcClient.top, m_szHeader.cx+nColumnWidth, rcClient.bottom); - for(UINT cmk=xofs; cmk<ncols; cmk++) + for(CHANNELINDEX cmk = startChan; cmk < ncols; cmk++) { - bColSel[cmk] = 0; - if (bSelEnable) - { - for(int n = PatternCursor::firstColumn; n <= PatternCursor::lastColumn; n++) - { - if(m_Selection.ContainsHorizontal(PatternCursor(0, static_cast<CHANNELINDEX>(cmk), static_cast<PatternCursor::Columns>(n)))) - { - bColSel[cmk] |= 1 << n; - } - } - } - if (!::RectVisible(hdc, &rect)) bColSel[cmk] |= 0x80; + selectedCols[cmk] = selEnable ? m_Selection.GetSelectionBits(cmk) : 0; + if (!::RectVisible(hdc, &rect)) selectedCols[cmk] |= 0x80; rect.left += nColumnWidth; rect.right += nColumnWidth; } // Max Visible Column - maxcol = ncols; - while ((maxcol > xofs) && (bColSel[maxcol-1] & 0x80)) maxcol--; + CHANNELINDEX maxcol = ncols; + while ((maxcol > startChan) && (selectedCols[maxcol-1] & 0x80)) maxcol--; // Init bitmap border { UINT maxndx = pSndFile->GetNumChannels() * m_szCell.cx; @@ -832,7 +820,7 @@ bool bRowSel = false; row_col = row_bkcol = -1; - for (UINT row=yofs; row<nrows; row++) + for (UINT row=startRow; row<numRows; row++) { UINT col, xbmp, nbmp, oldrowcolor; @@ -844,11 +832,11 @@ if (!::RectVisible(hdc, &rect)) { // No speedup for these columns next time - for (UINT iup=xofs; iup<maxcol; iup++) bColSel[iup] &= ~0x40; + for (UINT iup=startChan; iup<maxcol; iup++) selectedCols[iup] &= ~0x40; goto SkipRow; } rect.right = rect.left + m_szHeader.cx; - DrawButtonRect(hdc, &rect, s, !bSelEnable); + DrawButtonRect(hdc, &rect, s, !selEnable); oldrowcolor = (row_bkcol << 16) | (row_col << 8) | (bRowSel ? 1 : 0); bRowSel = (m_Selection.ContainsVertical(PatternCursor(row))); row_col = MODCOLOR_TEXTNORMAL; @@ -863,7 +851,7 @@ } // secondary highlight (beats) if ((CMainFrame::GetSettings().m_dwPatternSetup & PATTERN_2NDHIGHLIGHT) - && (nBeat) && (nBeat < nrows)) + && (nBeat) && (nBeat < numRows)) { if (!(row % nBeat)) { @@ -872,14 +860,14 @@ } // primary highlight (measures) if ((CMainFrame::GetSettings().m_dwPatternSetup & PATTERN_STDHIGHLIGHT) - && (nMeasure) && (nMeasure < nrows)) + && (nMeasure) && (nMeasure < numRows)) { if (!(row % nMeasure)) { row_bkcol = MODCOLOR_BACKHILIGHT; } } - if (bSelEnable) + if (selEnable) { if ((row == m_nPlayRow) && (nPattern == m_nPlayPat)) { @@ -893,7 +881,7 @@ row_col = MODCOLOR_TEXTCURROW; row_bkcol = MODCOLOR_BACKCURROW; } else - if ((m_dwStatus & psFollowSong) && (bPlaying)) + if ((m_dwStatus & psFollowSong) && (isPlaying)) { row_col = MODCOLOR_TEXTPLAYCURSOR; row_bkcol = MODCOLOR_BACKPLAYCURSOR; @@ -902,10 +890,10 @@ } // Eliminate non-visible column xpaint = m_szHeader.cx; - col = xofs; - while ((bColSel[col] & 0x80) && (col < maxcol)) + col = startChan; + while ((selectedCols[col] & 0x80) && (col < maxcol)) { - bColSel[col] &= ~0x40; + selectedCols[col] &= ~0x40; col++; xpaint += nColumnWidth; } @@ -922,7 +910,7 @@ const bool drawDefaultVolume = DrawDefaultVolume(m); DWORD dwSpeedUpMask = 0; - if ((bSpeedUp) && (bColSel[col] & 0x40) && (pPattern) && (row)) + if ((bSpeedUp) && (selectedCols[col] & 0x40) && (pPattern) && (row)) { const ModCommand *mold = m - ncols; const bool drawOldDefaultVolume = DrawDefaultVolume(mold); @@ -944,9 +932,9 @@ } if (dwSpeedUpMask == 0x1F) goto DoBlit; } - bColSel[col] |= 0x40; + selectedCols[col] |= 0x40; col_sel = 0; - if (bRowSel) col_sel = bColSel[col] & 0x3F; + if (bRowSel) col_sel = selectedCols[col] & 0x3F; tx_col = row_col; bk_col = row_bkcol; if (col_sel) Modified: trunk/OpenMPT/mptrack/KeyConfigDlg.cpp =================================================================== --- trunk/OpenMPT/mptrack/KeyConfigDlg.cpp 2012-06-30 18:16:43 UTC (rev 1310) +++ trunk/OpenMPT/mptrack/KeyConfigDlg.cpp 2012-06-30 18:26:37 UTC (rev 1311) @@ -50,28 +50,14 @@ { //if a key has been released but custom edit box is empty, we have probably just //navigated into the box with TAB or SHIFT-TAB. No need to set keychoice. - if(code != 0) - m_pOptKeyDlg->OnSetKeyChoice(); + if(code != 0 && !isDummy) + m_pOptKeyDlg->OnSetKeyChoice(); } } return CEdit::PreTranslateMessage(pMsg); } -void CCustEdit::SetKey(UINT /*inMod*/, CString /*c*/) -{ -/* - mod = inMod; - //Setup display - CString text = CMainFrame::GetInputHandler()->activeCommandSet->GetModifierText(mod); - text.Append(c); - if (text == "Ctrl+CNTRL") text="Ctrl"; - if (text == "Alt+ALT") text="Alt"; - if (text == "Shift+SHIFT") text="Shift"; - SetWindowText(text); -*/ -} - void CCustEdit::SetKey(UINT inMod, UINT inCode) { mod = inMod; @@ -126,6 +112,8 @@ ON_COMMAND(IDC_CLEARLOG, OnClearLog) ON_COMMAND(IDC_RESTORE_KEYMAP, OnRestoreDefaultKeymap) ON_EN_CHANGE(IDC_FIND, OnSearchTermChanged) + ON_EN_CHANGE(IDC_FINDHOTKEY, OnFindHotKey) + ON_EN_SETFOCUS(IDC_FINDHOTKEY, OnClearHotKey) ON_WM_DESTROY() END_MESSAGE_MAP() @@ -139,6 +127,7 @@ DDX_Control(pDX, IDC_CHORDDETECTWAITTIME, m_eChordWaitTime);//rewbs.autochord DDX_Control(pDX, IDC_KEYREPORT, m_eReport); DDX_Control(pDX, IDC_CUSTHOTKEY, m_eCustHotKey); + DDX_Control(pDX, IDC_FINDHOTKEY, m_eFindHotKey); DDX_Control(pDX, IDC_CHECKKEYDOWN, m_bKeyDown); DDX_Control(pDX, IDC_CHECKKEYHOLD, m_bKeyHold); DDX_Control(pDX, IDC_CHECKKEYUP, m_bKeyUp); @@ -182,6 +171,7 @@ UpdateDialog(); m_eCustHotKey.SetParent(m_hWnd, IDC_CUSTHOTKEY, this); + m_eFindHotKey.SetParent(m_hWnd, IDC_FINDHOTKEY, this); m_eReport.FmtLines(TRUE); m_eReport.SetWindowText(""); @@ -422,6 +412,20 @@ } +// Force last active category to be selected in dropdown menu. +void COptionsKeyboard::UpdateCategory() +//------------------------------------- +{ + for(int i = 0; i < m_cmbCategory.GetCount(); i++) + { + if((int)m_cmbCategory.GetItemData(i) == m_nCurCategory) + { + m_cmbCategory.SetCurSel(i); + break; + } + } +} + void COptionsKeyboard::OnSearchTermChanged() //------------------------------------------ { @@ -430,20 +434,31 @@ if(findString.IsEmpty()) { - // Go back to last found category - for(int i = 0; i < m_cmbCategory.GetCount(); i++) - { - if((int)m_cmbCategory.GetItemData(i) == m_nCurCategory) - { - m_cmbCategory.SetCurSel(i); - break; - } - } + UpdateCategory(); } UpdateShortcutList(findString.IsEmpty() ? m_nCurCategory : -1); } +void COptionsKeyboard::OnFindHotKey() +//----------------------------------- +{ + if(m_eFindHotKey.code == 0) + { + UpdateCategory(); + } + UpdateShortcutList(m_eFindHotKey.code == 0 ? m_nCurCategory : -1); +} + + +void COptionsKeyboard::OnClearHotKey() +//------------------------------------ +{ + // Focus key search: Clear input + m_eFindHotKey.SetKey(0, 0); +} + + // Fills command list and automatically selects first command. void COptionsKeyboard::UpdateShortcutList(int category) //----------------------------------------------------- @@ -452,7 +467,8 @@ m_eFind.GetWindowText(findString); findString.MakeLower(); - const bool doSearch = !findString.IsEmpty(); + const bool searchByName = !findString.IsEmpty(), searchByKey = (m_eFindHotKey.code != 0); + const bool doSearch = (searchByName || searchByKey); int firstCat = category, lastCat = category; if(category == -1) @@ -475,13 +491,28 @@ CommandID com = (CommandID)commandCategories[cat].commands[cmd]; CString cmdText = plocalCmdSet->GetCommandText(com); - bool addString = true; - if(doSearch) + bool addKey = true; + + if(searchByKey) { - addString = (cmdText.MakeLower().Find(findString) >= 0); + addKey = false; + size_t numChoices = plocalCmdSet->GetKeyListSize(com); + for(size_t choice = 0; choice < numChoices; choice++) + { + const KeyCombination &kc = plocalCmdSet->GetKey(com, choice); + if(kc.code == m_eFindHotKey.code && kc.mod == m_eFindHotKey.mod) + { + addKey = true; + break; + } + } } + if(searchByName && addKey) + { + addKey = (cmdText.MakeLower().Find(findString) >= 0); + } - if(addString) + if(addKey) { m_nCurCategory = cat; Modified: trunk/OpenMPT/mptrack/KeyConfigDlg.h =================================================================== --- trunk/OpenMPT/mptrack/KeyConfigDlg.h 2012-06-30 18:16:43 UTC (rev 1310) +++ trunk/OpenMPT/mptrack/KeyConfigDlg.h 2012-06-30 18:26:37 UTC (rev 1311) @@ -72,15 +72,15 @@ COptionsKeyboard *m_pOptKeyDlg; HWND m_hParent; UINT m_nCtrlId; - bool isFocussed; + bool isFocussed, isDummy; public: - CCustEdit() : m_hParent(nullptr), isFocussed(false) { } UINT mod; UINT code; + + CCustEdit(bool dummyField) : m_hParent(nullptr), isFocussed(false), isDummy(dummyField), mod(0), code(0) { } VOID SetParent(HWND h, UINT nID, COptionsKeyboard* pOKD) { m_hParent = h; m_nCtrlId = nID; m_pOptKeyDlg = pOKD;} void SetKey(UINT mod, UINT code); - void SetKey(UINT mod, CString c); virtual BOOL PreTranslateMessage(MSG *pMsg); DECLARE_MESSAGE_MAP() afx_msg void OnSetFocus(CWnd* pOldWnd); @@ -93,15 +93,13 @@ //========================================== { protected: -// CNotifyHotKey m_HotKey; - //CNotifyHotKey m_CommandHotKey; //rewbs.keys CListBox m_lbnHotKeys; CListBox m_lbnCommandKeys; //rewbs.keys CComboBox m_cmbKeyChoice; //rewbs.keys CComboBox m_cmbCategory; CButton m_bKeyDown, m_bKeyHold, m_bKeyUp; CButton m_bnReset; - CCustEdit m_eCustHotKey; + CCustEdit m_eCustHotKey, m_eFindHotKey; CEdit m_eFind; CEdit m_eReport, m_eChordWaitTime; UINT m_nKeyboardCfg; @@ -114,11 +112,11 @@ void ForceUpdateGUI(); void UpdateShortcutList(int category = -1); + void UpdateCategory(); int GetCategoryFromCommandID(CommandID command) const; public: - COptionsKeyboard():CPropertyPage(IDD_OPTIONS_KEYBOARD) { m_nKeyboardCfg = 0; } -// ~COptionsKeyboard(); + COptionsKeyboard() : CPropertyPage(IDD_OPTIONS_KEYBOARD), m_eCustHotKey(false), m_eFindHotKey(true), m_nKeyboardCfg(0) { } BOOL SetKey(UINT nId, UINT nChar, UINT nFlags); CArray<CommandCategory, CommandCategory> commandCategories; void DefineCommandCategories(); @@ -151,6 +149,8 @@ afx_msg void OnSave(); afx_msg void OnClearLog(); afx_msg void OnRestoreDefaultKeymap(); + afx_msg void OnClearHotKey(); + afx_msg void OnFindHotKey(); DECLARE_MESSAGE_MAP(); public: afx_msg void OnDestroy(); Modified: trunk/OpenMPT/mptrack/PatternCursor.h =================================================================== --- trunk/OpenMPT/mptrack/PatternCursor.h 2012-06-30 18:16:43 UTC (rev 1310) +++ trunk/OpenMPT/mptrack/PatternCursor.h 2012-06-30 18:26:37 UTC (rev 1311) @@ -323,6 +323,32 @@ return lowerRight.GetColumnType(); } + // Create a bitset of the selected columns of a channel. If a column is selected, the corresponding bit is set. + // Example: If the first and second column of the channel are selected, the bits 00000011 would be returned. + uint8 GetSelectionBits(CHANNELINDEX chn) const + { + const CHANNELINDEX startChn = GetStartChannel(), endChn = GetEndChannel(); + uint8 bits = 0; + + if(chn >= startChn && chn <= endChn) + { + // All columns could be selected (unless this is the first or last channel). + bits = uint8_max; + + if(chn == startChn) + { + // First channel: Remove columns left of the start column type. + bits <<= GetUpperLeft().GetColumnType(); + } + if(chn == endChn) + { + // Last channel: Remove columns right of the end column type. + bits &= (2 << GetLowerRight().GetColumnType()) - 1; + } + } + return (bits & 0x1F); + } + // Get number of rows in selection ROWINDEX GetNumRows() const { Modified: trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp =================================================================== --- trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp 2012-06-30 18:16:43 UTC (rev 1310) +++ trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp 2012-06-30 18:26:37 UTC (rev 1311) @@ -1606,37 +1606,279 @@ } -/////////////////////////////////////////////////////////// -// Rename a channel from pattern editor +///////////////////////////////////////////////////////////////////////// +// Show channel properties from pattern editor -BOOL CChannelRenameDlg::OnInitDialog() -//------------------------------------ +BEGIN_MESSAGE_MAP(QuickChannelProperties, CDialog) + ON_WM_HSCROLL() // Sliders + ON_EN_UPDATE(IDC_EDIT1, OnVolChanged) + ON_EN_UPDATE(IDC_EDIT2, OnPanChanged) + ON_EN_UPDATE(IDC_EDIT3, OnNameChanged) + ON_COMMAND(IDC_CHECK1, OnMuteChanged) + ON_COMMAND(IDC_CHECK2, OnSurroundChanged) + ON_COMMAND(IDC_BUTTON1, OnPrevChannel) + ON_COMMAND(IDC_BUTTON2, OnNextChannel) +END_MESSAGE_MAP() + + +void QuickChannelProperties::DoDataExchange(CDataExchange* pDX) +//------------------------------------------------------------- { - CDialog::OnInitDialog(); + DDX_Control(pDX, IDC_SLIDER1, volSlider); + DDX_Control(pDX, IDC_SLIDER2, panSlider); + DDX_Control(pDX, IDC_SPIN1, volSpin); + DDX_Control(pDX, IDC_SPIN2, panSpin); + DDX_Control(pDX, IDC_EDIT3, nameEdit); +} - CHAR s[32]; - wsprintf(s, "Set name for channel %d:", m_nChannel); - SetDlgItemText(IDC_STATIC_CHANNEL_NAME, s); - SetDlgItemText(IDC_EDIT_CHANNEL_NAME, m_sName); - ((CEdit*)(GetDlgItem(IDC_EDIT_CHANNEL_NAME)))->LimitText(MAX_CHANNELNAME - 1); - return TRUE; +QuickChannelProperties::QuickChannelProperties() +//---------------------------------------------- +{ + visible = false; + Create(IDD_CHANNELSETTINGS, nullptr); + + volSlider.SetRange(0, 64); + volSlider.SetTicFreq(8); + volSpin.SetRange(0, 64); + + panSlider.SetRange(0, 64); + panSlider.SetTicFreq(8); + panSpin.SetRange(0, 256); +}; + + +QuickChannelProperties::~QuickChannelProperties() +//----------------------------------------------- +{ + CDialog::OnCancel(); } -void CChannelRenameDlg::OnOK() -//---------------------------- +// Show channel properties for a given channel at a given screen position. +void QuickChannelProperties::Show(CModDoc *modDoc, CHANNELINDEX chn, PATTERNINDEX ptn, CPoint position) +//----------------------------------------------------------------------------------------------------- { - CHAR sNewName[MAX_CHANNELNAME]; - GetDlgItemText(IDC_EDIT_CHANNEL_NAME, sNewName, MAX_CHANNELNAME); - if(!strcmp(sNewName, m_sName)) + document = modDoc; + channel = chn; + pattern = ptn; + + SetParent(nullptr); + + // Center window around point where user clicked. + CRect rect, screenRect; + GetWindowRect(rect); + ::GetWindowRect(::GetDesktopWindow(), &screenRect); + rect.MoveToXY( + Clamp(static_cast<int>(position.x) - rect.Width() / 2, 0, static_cast<int>(screenRect.right) - rect.Width()), + Clamp(static_cast<int>(position.y) - rect.Height() / 2, 0, static_cast<int>(screenRect.bottom) - rect.Height())); + MoveWindow(rect); + + UpdateDisplay(); + + const BOOL enablePan = (document->GetModType() & (MOD_TYPE_XM | MOD_TYPE_MOD)) ? FALSE : TRUE; + const BOOL itOnly = (document->GetModType() & (MOD_TYPE_IT | MOD_TYPE_MPT)) ? TRUE : FALSE; + + // Volume controls + volSlider.EnableWindow(itOnly); + volSpin.EnableWindow(itOnly); + ::EnableWindow(::GetDlgItem(m_hWnd, IDC_EDIT1), itOnly); + + // Pan controls + panSlider.EnableWindow(enablePan); + panSpin.EnableWindow(enablePan); + ::EnableWindow(::GetDlgItem(m_hWnd, IDC_EDIT2), enablePan); + ::EnableWindow(::GetDlgItem(m_hWnd, IDC_CHECK2), itOnly); + + // Channel name + nameEdit.EnableWindow((document->GetModType() & (MOD_TYPE_IT | MOD_TYPE_MPT | MOD_TYPE_XM)) ? TRUE : FALSE); + + ShowWindow(SW_SHOW); + visible = true; +} + + +void QuickChannelProperties::UpdateDisplay() +//------------------------------------------ +{ + // Set up channel properties + settingsChanged = true; + const ModChannelSettings &settings = document->GetSoundFile()->ChnSettings[channel]; + SetDlgItemInt(IDC_EDIT1, settings.nVolume, FALSE); + SetDlgItemInt(IDC_EDIT2, settings.nPan, FALSE); + volSlider.SetPos(settings.nVolume); + panSlider.SetPos(settings.nPan / 4u); + CheckDlgButton(IDC_CHECK1, (settings.dwFlags & CHN_MUTE) ? TRUE : FALSE); + CheckDlgButton(IDC_CHECK2, (settings.dwFlags & CHN_SURROUND) ? TRUE : FALSE); + + char description[16]; + sprintf(description, "Channel %d:", channel + 1); + SetDlgItemText(IDC_STATIC_CHANNEL_NAME, description); + nameEdit.LimitText(MAX_CHANNELNAME - 1); + nameEdit.SetWindowText(settings.szName); + + settingsChanged = false; + + ::EnableWindow(::GetDlgItem(m_hWnd, IDC_BUTTON1), channel > 0 ? TRUE : FALSE); + ::EnableWindow(::GetDlgItem(m_hWnd, IDC_BUTTON2), channel < document->GetNumChannels() - 1 ? TRUE : FALSE); +} + +void QuickChannelProperties::PrepareUndo() +//---------------------------------------- +{ + if(!settingsChanged) { - bChanged = false; - CDialog::OnCancel(); - } else + // Backup old channel settings through pattern undo. + settingsChanged = true; + document->GetPatternUndo().PrepareUndo(pattern, 0, 0, 1, 1, false, true); + } +} + + +void QuickChannelProperties::Hide() +//--------------------------------- +{ + visible = false; + ShowWindow(SW_HIDE); +} + + +void QuickChannelProperties::OnVolChanged() +//----------------------------------------- +{ + if(!visible) { - strcpy(m_sName, sNewName); - bChanged = true; - CDialog::OnOK(); + return; } + uint16 volume = static_cast<uint16>(GetDlgItemInt(IDC_EDIT1)); + if(volume >= 0 && volume <= 64) + { + PrepareUndo(); + document->SetChannelGlobalVolume(channel, volume); + volSlider.SetPos(volume); + document->UpdateAllViews(nullptr, HINT_MODCHANNELS); + } } + + +void QuickChannelProperties::OnPanChanged() +//----------------------------------------- +{ + if(!visible) + { + return; + } + uint16 panning = static_cast<uint16>(GetDlgItemInt(IDC_EDIT2)); + if(panning >= 0 && panning <= 256) + { + PrepareUndo(); + document->SetChannelDefaultPan(channel, panning); + panSlider.SetPos(panning / 4u); + document->UpdateAllViews(nullptr, HINT_MODCHANNELS); + } +} + + +void QuickChannelProperties::OnHScroll(UINT, UINT, CScrollBar *) +//-------------------------------------------------------------- +{ + if(!visible) + { + return; + } + + bool update = false; + + // Volume slider + uint16 pos = static_cast<uint16>(volSlider.GetPos()); + if(pos >= 0 && pos <= 64) + { + PrepareUndo(); + if(document->SetChannelGlobalVolume(channel, pos)) + { + SetDlgItemInt(IDC_EDIT1, pos); + update = true; + } + } + // Pan slider + pos = static_cast<uint16>(panSlider.GetPos()); + if(pos >= 0 && pos <= 64) + { + PrepareUndo(); + if(document->SetChannelDefaultPan(channel, pos * 4u)) + { + SetDlgItemInt(IDC_EDIT2, pos * 4u); + CheckDlgButton(IDC_CHECK2, BST_UNCHECKED); + update = true; + } + } + + if(update) + { + document->UpdateAllViews(nullptr, HINT_MODCHANNELS); + } +} + + +void QuickChannelProperties::OnMuteChanged() +//------------------------------------------ +{ + if(!visible) + { + return; + } + document->MuteChannel(channel, IsDlgButtonChecked(IDC_CHECK1) != BST_UNCHECKED); + document->UpdateAllViews(nullptr, HINT_MODCHANNELS); +} + + +void QuickChannelProperties::OnSurroundChanged() +//---------------------------------------------- +{ + if(!visible) + { + return; + } + PrepareUndo(); + document->SurroundChannel(channel, IsDlgButtonChecked(IDC_CHECK2) != BST_UNCHECKED); + document->UpdateAllViews(nullptr, HINT_MODCHANNELS); + UpdateDisplay(); +} + + +void QuickChannelProperties::OnNameChanged() +//------------------------------------------ +{ + if(!visible) + { + return; + } + + ModChannelSettings &settings = document->GetSoundFile()->ChnSettings[channel]; + char newName[MAX_CHANNELNAME]; + nameEdit.GetWindowText(newName, MAX_CHANNELNAME); + + if(strcmp(newName, settings.szName)) + { + PrepareUndo(); + strcpy(settings.szName, newName); + document->SetModified(); + document->UpdateAllViews(nullptr, HINT_MODCHANNELS); + } +} + + +void QuickChannelProperties::OnPrevChannel() +//------------------------------------------ +{ + channel--; + UpdateDisplay(); +} + + +void QuickChannelProperties::OnNextChannel() +//------------------------------------------ +{ + channel++; + UpdateDisplay(); +} \ No newline at end of file Modified: trunk/OpenMPT/mptrack/PatternEditorDialogs.h =================================================================== --- trunk/OpenMPT/mptrack/PatternEditorDialogs.h 2012-06-30 18:16:43 UTC (rev 1310) +++ trunk/OpenMPT/mptrack/PatternEditorDialogs.h 2012-06-30 18:26:37 UTC (rev 1311) @@ -338,27 +338,44 @@ ///////////////////////////////////////////////////////////////////////// -// Rename a channel from pattern editor +// Show channel properties from pattern editor -//===================================== -class CChannelRenameDlg: public CDialog -//===================================== +//=========================================== +class QuickChannelProperties : public CDialog +//=========================================== { protected: - CHANNELINDEX m_nChannel; + CModDoc *document; + CHANNELINDEX channel; + PATTERNINDEX pattern; + bool visible; + bool settingsChanged; -public: - CHAR m_sName[MAX_CHANNELNAME]; - bool bChanged; + CSliderCtrl volSlider, panSlider; + CSpinButtonCtrl volSpin, panSpin; + CEdit nameEdit; public: - CChannelRenameDlg(CWnd *parent, CHAR *sName, CHANNELINDEX nChannel) : CDialog(IDD_CHANNEL_NAME, parent) - { - strcpy(m_sName, sName); - m_nChannel = nChannel; - bChanged = false; - } + QuickChannelProperties(); + ~QuickChannelProperties(); - virtual BOOL OnInitDialog(); - virtual void OnOK(); + void Show(CModDoc *modDoc, CHANNELINDEX chn, PATTERNINDEX ptn, CPoint position); + void Hide(); + +protected: + virtual void DoDataExchange(CDataExchange* pDX); + + void UpdateDisplay(); + void PrepareUndo(); + + afx_msg void OnVolChanged(); + afx_msg void OnPanChanged(); + afx_msg void OnHScroll(UINT, UINT, CScrollBar *); + afx_msg void OnMuteChanged(); + afx_msg void OnSurroundChanged(); + afx_msg void OnNameChanged(); + afx_msg void OnPrevChannel(); + afx_msg void OnNextChannel(); + + DECLARE_MESSAGE_MAP(); }; Modified: trunk/OpenMPT/mptrack/View_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_pat.cpp 2012-06-30 18:16:43 UTC (rev 1310) +++ trunk/OpenMPT/mptrack/View_pat.cpp 2012-06-30 18:26:37 UTC (rev 1311) @@ -14,7 +14,6 @@ #include "mainfrm.h" #include "childfrm.h" #include "moddoc.h" -#include "PatternEditorDialogs.h" #include "SampleEditorDialogs.h" // For amplification dialog (which is re-used from sample editor) #include "globals.h" #include "view_pat.h" @@ -127,7 +126,6 @@ ON_COMMAND(ID_PATTERN_AMPLIFY, OnPatternAmplify) ON_COMMAND(ID_CLEAR_SELECTION, OnClearSelectionFromMenu) ON_COMMAND(ID_SHOWTIMEATROW, OnShowTimeAtRow) - ON_COMMAND(ID_CHANNEL_RENAME, OnRenameChannel) ON_COMMAND(ID_PATTERN_EDIT_PCNOTE_PLUGIN, OnTogglePCNotePluginEditor) ON_COMMAND_RANGE(ID_CHANGE_INSTRUMENT, ID_CHANGE_INSTRUMENT+MAX_INSTRUMENTS, OnSelectInstrument) ON_COMMAND_RANGE(ID_CHANGE_PCNOTE_PARAM, ID_CHANGE_PCNOTE_PARAM + ModCommand::maxColumnValue, OnSelectPCNoteParam) @@ -671,7 +669,6 @@ { if (pMsg) { - //rewbs.customKeys //We handle keypresses before Windows has a chance to handle them (for alt etc..) if ((pMsg->message == WM_SYSKEYUP) || (pMsg->message == WM_KEYUP) || (pMsg->message == WM_SYSKEYDOWN) || (pMsg->message == WM_KEYDOWN)) @@ -707,9 +704,21 @@ } } //end HACK. + } else if(pMsg->message == WM_MBUTTONDOWN) + { + // Open quick channel properties dialog if we're middle-clicking a channel header. + CPoint point(GET_X_LPARAM(pMsg->lParam), GET_Y_LPARAM(pMsg->lParam)); + if(point.y < m_szHeader.cy - ((m_dwStatus & psShowPluginNames) ? PLUGNAME_HEIGHT : 0)) + { + PatternCursor cursor = GetPositionFromPoint(point); + if(cursor.GetChannel() < GetDocument()->GetNumChannels()) + { + ClientToScreen(&point); + quickChannelProperties.Show(GetDocument(), cursor.GetChannel(), m_nPattern, point); + return true; + } + } } - //end rewbs.customKeys - } return CModScrollView::PreTranslateMessage(pMsg); @@ -760,6 +769,7 @@ CScrollView::OnSetFocus(pOldWnd); m_dwStatus |= psFocussed; InvalidateRow(); + quickChannelProperties.Hide(); CModDoc *pModDoc = GetDocument(); if (pModDoc) { @@ -1135,7 +1145,7 @@ PatternCursor pointCursor(GetPositionFromPoint(point)); SetCapture(); - if(point.x >= m_szHeader.cx && point.y <= m_szHeader.cy) + if(point.x >= m_szHeader.cx && point.y <= m_szHeader.cy - ((m_dwStatus & psShowPluginNames) ? PLUGNAME_HEIGHT : 0)) { // Click on channel header if (nFlags & MK_CONTROL) @@ -1212,6 +1222,7 @@ PatternCursor cursor = GetPositionFromPoint(point); if(cursor == m_Cursor && point.y >= m_szHeader.cy) { + // Double-click pattern cell: Select whole column or show cell properties. if((CMainFrame::GetSettings().m_dwPatternSetup & PATTERN_DBLCLICKSELECT)) { OnSelectCurrentColumn(); @@ -1223,6 +1234,7 @@ if(ShowEditWindow()) return; } } + OnLButtonDown(uFlags, point); } @@ -1367,8 +1379,8 @@ } -void CViewPattern::OnRButtonDown(UINT, CPoint pt) -//----------------------------------------------- +void CViewPattern::OnRButtonDown(UINT flags, CPoint pt) +//----------------------------------------------------- { CModDoc *pModDoc = GetDocument(); CSoundFile *pSndFile; @@ -1419,8 +1431,14 @@ } } const CHANNELINDEX nChn = m_MenuCursor.GetChannel(); - if ((nChn < pSndFile->GetNumChannels()) && (pSndFile->Patterns[m_nPattern])) + + if((flags & MK_CONTROL) != 0 && nChn < pSndFile->GetNumChannels() && (pt.y < m_szHeader.cy)) { + // Ctrl+Right-Click: Open quick channel properties. + ClientToScreen(&pt); + quickChannelProperties.Show(GetDocument(), nChn, m_nPattern, pt); + } else if(nChn < pSndFile->GetNumChannels() && pSndFile->Patterns.IsValidPat(m_nPattern) && !(flags & (MK_CONTROL | MK_SHIFT))) + { CString MenuText; CInputHandler *ih = (CMainFrame::GetMainFrame())->GetInputHandler(); @@ -1443,7 +1461,6 @@ AppendMenu(hMenu, MF_SEPARATOR, 0, ""); BuildRecordCtxMenu(hMenu, nChn, pModDoc); BuildChannelControlCtxMenu(hMenu); - BuildChannelMiscCtxMenu(hMenu); } } @@ -1506,8 +1523,12 @@ void CViewPattern::OnMouseMove(UINT nFlags, CPoint point) //------------------------------------------------------- { - if (!m_bDragging) return; + if(!m_bDragging) + { + return; + } + // Drag&Drop actions if (m_nDragItem) { const CRect oldDropRect = m_rcDropItem; @@ -5834,16 +5855,6 @@ } -bool CViewPattern::BuildChannelMiscCtxMenu(HMENU hMenu) const -//--------------------------------------------------------------------------------- -{ - if((GetSoundFile()->GetType() & (MOD_TYPE_IT|MOD_TYPE_MPT)) == 0) return false; - AppendMenu(hMenu, MF_SEPARATOR, 0, 0); - AppendMenu(hMenu, MF_STRING, ID_CHANNEL_RENAME, "Rename Channel"); - return true; -} - - // Context menu for Param Control notes bool CViewPattern::BuildPCNoteCtxMenu(HMENU hMenu, CInputHandler *ih) const //------------------------------------------------------------------------- @@ -6137,28 +6148,6 @@ } -// Set a channel's name -void CViewPattern::OnRenameChannel() -//---------------------------------- -{ - CModDoc *pModDoc = GetDocument(); - if(pModDoc == nullptr) return; - CSoundFile *pSndFile = pModDoc->GetSoundFile(); - if(pSndFile == nullptr) return; - - const CHANNELINDEX nChn = m_MenuCursor.GetChannel(); - CChannelRenameDlg dlg(this, pSndFile->ChnSettings[nChn].szName, nChn + 1); - if(dlg.DoModal() != IDOK || dlg.bChanged == false) return; - - // Backup old name. - pModDoc->GetPatternUndo().PrepareUndo(m_nPattern, 0, 0, 1, 1, false, true); - - strcpy(pSndFile->ChnSettings[nChn].szName, dlg.m_sName); - pModDoc->SetModified(); - pModDoc->UpdateAllViews(NULL, HINT_MODCHANNELS); -} - - // Set up split keyboard void CViewPattern::SetSplitKeyboardSettings() //------------------------------------------- Modified: trunk/OpenMPT/mptrack/View_pat.h =================================================================== --- trunk/OpenMPT/mptrack/View_pat.h 2012-06-30 18:16:43 UTC (rev 1310) +++ trunk/OpenMPT/mptrack/View_pat.h 2012-06-30 18:26:37 UTC (rev 1311) @@ -14,6 +14,7 @@ #include "globals.h" #include "PatternCursor.h" #include "PatternClipboard.h" +#include "PatternEditorDialogs.h" class CModDoc; class CEditCommand; @@ -177,6 +178,8 @@ int oldrow, oldchn, oldsplitchn; // -! NEW_FEATURE#0012 + QuickChannelProperties quickChannelProperties; + public: CEffectVis *m_pEffectVis; //rewbs.fxVis @@ -260,7 +263,7 @@ void ProcessChar(UINT nChar, UINT nFlags); public: - void DrawPatternData(HDC, CSoundFile *, UINT, BOOL, BOOL, UINT, UINT, UINT, CRect&, int *); + void DrawPatternData(HDC hdc, CSoundFile *pSndFile, PATTERNINDEX nPattern, bool selEnable, bool isPlaying, ROWINDEX startRow, ROWINDEX numRows, CHANNELINDEX startChan, CRect &rcClient, int *pypaint); void DrawLetter(int x, int y, char letter, int sizex=10, int ofsx=0); void DrawNote(int x, int y, UINT note, CTuning* pTuning = NULL); void DrawInstrument(int x, int y, UINT instr); @@ -401,7 +404,6 @@ afx_msg void OnSelectPCNoteParam(UINT nid); afx_msg void OnRunScript(); afx_msg void OnShowTimeAtRow(); - afx_msg void OnRenameChannel(); afx_msg void OnTogglePCNotePluginEditor(); //}}AFX_MSG DECLARE_MESSAGE_MAP() @@ -438,7 +440,6 @@ bool BuildTransposeCtxMenu(HMENU hMenu, CInputHandler *ih) const; bool BuildSetInstCtxMenu(HMENU hMenu, CInputHandler *ih) const; bool BuildAmplifyCtxMenu(HMENU hMenu, CInputHandler *ih) const; - bool BuildChannelMiscCtxMenu(HMENU hMenu) const; bool BuildPCNoteCtxMenu(HMENU hMenu, CInputHandler *ih) const; // Returns an ordered list of all channels in which a given column type is selected. Modified: trunk/OpenMPT/mptrack/mptrack.rc =================================================================== --- trunk/OpenMPT/mptrack/mptrack.rc 2012-06-30 18:16:43 UTC (rev 1310) +++ trunk/OpenMPT/mptrack/mptrack.rc 2012-06-30 18:26:37 UTC (rev 1311) @@ -74,17 +74,6 @@ CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,6,132,312,1 END -IDD_CHANNEL_NAME DIALOGEX 0, 0, 154, 58 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Channel name" -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - LTEXT "IDC_STATIC_CHANNEL_NAME",IDC_STATIC_CHANNEL_NAME,6,6,138,8 - EDITTEXT IDC_EDIT_CHANNEL_NAME,6,18,138,12,ES_AUTOHSCROLL - DEFPUSHBUTTON "OK",IDOK,42,36,50,14 - PUSHBUTTON "Cancel",IDCANCEL,96,36,50,14 -END - IDD_KEYBOARD_SPLIT DIALOGEX 0, 0, 184, 137 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Keyboard Split Settings" @@ -234,7 +223,27 @@ CONTROL "",IDC_STATIC,"Static",SS_BLACKFRAME | SS_SUNKEN,6,48,150,1 END +IDD_CHANNELSETTINGS DIALOGEX 0, 0, 244, 76 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + EDITTEXT IDC_EDIT1,150,30,36,12,ES_NUMBER + CONTROL "",IDC_SPIN1,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY,174,30,11,14 + CONTROL "",IDC_SLIDER1,"msctls_trackbar32",TBS_AUTOTICKS | TBS_BOTH | WS_TABSTOP,54,24,92,22 + EDITTEXT IDC_EDIT2,150,54,36,12,ES_NUMBER + CONTROL "",IDC_SPIN2,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY,174,54,11,14 + CONTROL "",IDC_SLIDER2,"msctls_trackbar32",TBS_AUTOTICKS | TBS_BOTH | WS_TABSTOP,54,48,92,22 + CONTROL "Mute",IDC_CHECK1,"Button",BS_AUTOCHECKBOX | BS_PUSHLIKE | WS_TABSTOP,192,30,42,12 + CONTROL "Surround",IDC_CHECK2,"Button",BS_AUTOCHECKBOX | BS_PUSHLIKE | WS_TABSTOP,192,54,42,12 + LTEXT "Initial Volume:",IDC_STATIC,6,30,45,8 + LTEXT "Initial Pan:",IDC_STATIC,6,54,34,8 + PUSHBUTTON "<<",IDC_BUTTON1,192,6,18,12 + PUSHBUTTON ">>",IDC_BUTTON2,216,6,18,12 + EDITTEXT IDC_EDIT3,60,6,126,12,ES_AUTOHSCROLL + CONTROL "Channel 1:",IDC_STATIC_CHANNEL_NAME,"Static",SS_LEFTNOWORDWRAP | WS_GROUP,6,8,45,8 +END + ///////////////////////////////////////////////////////////////////////////// // // DESIGNINFO @@ -259,14 +268,6 @@ BOTTOMMARGIN, 147 END - IDD_CHANNEL_NAME, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 147 - TOPMARGIN, 7 - BOTTOMMARGIN, 51 - END - IDD_KEYBOARD_SPLIT, DIALOG BEGIN LEFTMARGIN, 7 @@ -338,6 +339,14 @@ TOPMARGIN, 7 BOTTOMMARGIN, 75 END + + IDD_CHANNELSETTINGS, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 237 + TOPMARGIN, 7 + BOTTOMMARGIN, 69 + END END #endif // APSTUDIO_INVOKED @@ -466,7 +475,7 @@ BEGIN LTEXT "Select category:",IDC_STATIC,7,5,131,11 COMBOBOX IDC_KEYCATEGORY,5,16,133,204,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - LISTBOX IDC_COMMAND_LIST,5,32,133,228,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP + LISTBOX IDC_COMMAND_LIST,5,32,133,226,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP COMBOBOX IDC_CHOICECOMBO,150,18,72,51,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP LTEXT "Key:",IDC_STATIC,150,38,16,8 EDITTEXT IDC_CUSTHOTKEY,168,36,54,13,ES_AUTOHSCROLL @@ -493,8 +502,10 @@ PUSHBUTTON "xm",IDC_EFFECTLETTERSXM,119,223,12,9,NOT WS_VISIBLE LTEXT "Effect letters like:",IDC_STATIC,11,225,73,11,NOT WS_VISIBLE PUSHBUTTON "Restore default configuration",IDC_RESTORE_KEYMAP,150,174,114,12 - EDITTEXT IDC_FIND,30,264,108,12,ES_AUTOHSCROLL + EDITTEXT IDC_FIND,30,264,54,12,ES_AUTOHSCROLL LTEXT "Find:",IDC_STATIC,6,266,24,8 + EDITTEXT IDC_FINDHOTKEY,108,264,30,12,ES_AUTOHSCROLL + LTEXT "Key:",IDC_STATIC,90,266,18,8 END IDD_OPTIONS_COLORS DIALOGEX 0, 0, 272, 281 Modified: trunk/OpenMPT/mptrack/resource.h =================================================================== --- trunk/OpenMPT/mptrack/resource.h 2012-06-30 18:16:43 UTC (rev 1310) +++ trunk/OpenMPT/mptrack/resource.h 2012-06-30 18:26:37 UTC (rev 1311) @@ -143,7 +143,7 @@ #define IDR_DEFAULT_KEYBINDINGS 519 #define IDR_BUILTIN_TUNINGS 520 #define IDD_CLEANUP_SONG 521 -#define IDD_CHANNEL_NAME 522 +#define IDD_CHANNELSETTINGS 522 #define IDD_KEYBOARD_SPLIT 523 #define IDD_SAMPLE_GENERATOR 524 #define IDD_SAMPLE_GENERATOR_PRESETS 525 @@ -915,7 +915,7 @@ #define IDC_CHK_MERGE_SEQUENCES 2408 #define IDC_CHECK_PT1X 2409 #define IDC_STATIC_CHANNEL_NAME 2410 -#define IDC_EDIT_CHANNEL_NAME 2411 +#define IDC_FINDHOTKEY 2411 #define IDC_STATIC_PATTERNNAME 2412 #define IDC_EDIT_SAMPLE_LENGTH 2413 #define IDC_EDIT_SAMPLE_FREQ 2414 Modified: trunk/OpenMPT/mptrack/version.h =================================================================== --- trunk/OpenMPT/mptrack/version.h 2012-06-30 18:16:43 UTC (rev 1310) +++ trunk/OpenMPT/mptrack/version.h 2012-06-30 18:26:37 UTC (rev 1311) @@ -19,7 +19,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 20 #define VER_MINOR 01 -#define VER_MINORMINOR 09 +#define VER_MINORMINOR 10 //Creates version number from version parts that appears in version string. //For example MAKE_VERSION_NUMERIC(1,17,02,28) gives version number of This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2012-07-17 21:08:48
|
Revision: 1329 http://modplug.svn.sourceforge.net/modplug/?rev=1329&view=rev Author: saga-games Date: 2012-07-17 21:08:41 +0000 (Tue, 17 Jul 2012) Log Message: ----------- [Imp] Quick Channel Settings are now always hidden when changing focus to another window, not only when switching back to the lower pattern view. [Fix] Fixed memory leak that occoured when trying to load invalid/missing plugins (e.g. on startup). [Mod] OpenMPT: Version is now 1.20.02.02 Modified Paths: -------------- trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp trunk/OpenMPT/mptrack/PatternEditorDialogs.h trunk/OpenMPT/mptrack/View_pat.cpp trunk/OpenMPT/mptrack/Vstplug.cpp trunk/OpenMPT/mptrack/version.h Modified: trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp =================================================================== --- trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp 2012-07-17 21:08:15 UTC (rev 1328) +++ trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp 2012-07-17 21:08:41 UTC (rev 1329) @@ -14,7 +14,6 @@ #include "Mainfrm.h" #include "PatternEditorDialogs.h" #include "view_pat.h" -#include "../muParser/include/muParser.h" // -> CODE#0010 @@ -1610,7 +1609,8 @@ // Show channel properties from pattern editor BEGIN_MESSAGE_MAP(QuickChannelProperties, CDialog) - ON_WM_HSCROLL() // Sliders + ON_WM_HSCROLL() // Sliders + ON_WM_ACTIVATE() // Catch Window focus change ON_EN_UPDATE(IDC_EDIT1, OnVolChanged) ON_EN_UPDATE(IDC_EDIT2, OnPanChanged) ON_EN_UPDATE(IDC_EDIT3, OnNameChanged) @@ -1645,6 +1645,8 @@ panSlider.SetRange(0, 64); panSlider.SetTicFreq(8); panSpin.SetRange(0, 256); + + nameEdit.SetFocus(); }; @@ -1655,6 +1657,17 @@ } +void QuickChannelProperties::OnActivate(UINT nState, CWnd *, BOOL) +//---------------------------------------------------------------- +{ + if(nState == WA_INACTIVE) + { + // Hide window when changing focus to another window. + visible = false; + ShowWindow(SW_HIDE); + } +} + // Show channel properties for a given channel at a given screen position. void QuickChannelProperties::Show(CModDoc *modDoc, CHANNELINDEX chn, PATTERNINDEX ptn, CPoint position) //----------------------------------------------------------------------------------------------------- @@ -1735,14 +1748,6 @@ } -void QuickChannelProperties::Hide() -//--------------------------------- -{ - visible = false; - ShowWindow(SW_HIDE); -} - - void QuickChannelProperties::OnVolChanged() //----------------------------------------- { Modified: trunk/OpenMPT/mptrack/PatternEditorDialogs.h =================================================================== --- trunk/OpenMPT/mptrack/PatternEditorDialogs.h 2012-07-17 21:08:15 UTC (rev 1328) +++ trunk/OpenMPT/mptrack/PatternEditorDialogs.h 2012-07-17 21:08:41 UTC (rev 1329) @@ -360,7 +360,6 @@ ~QuickChannelProperties(); void Show(CModDoc *modDoc, CHANNELINDEX chn, PATTERNINDEX ptn, CPoint position); - void Hide(); protected: virtual void DoDataExchange(CDataExchange* pDX); @@ -368,6 +367,7 @@ void UpdateDisplay(); void PrepareUndo(); + afx_msg void OnActivate(UINT nState, CWnd *, BOOL); afx_msg void OnVolChanged(); afx_msg void OnPanChanged(); afx_msg void OnHScroll(UINT, UINT, CScrollBar *); Modified: trunk/OpenMPT/mptrack/View_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_pat.cpp 2012-07-17 21:08:15 UTC (rev 1328) +++ trunk/OpenMPT/mptrack/View_pat.cpp 2012-07-17 21:08:41 UTC (rev 1329) @@ -769,7 +769,6 @@ CScrollView::OnSetFocus(pOldWnd); m_dwStatus |= psFocussed; InvalidateRow(); - quickChannelProperties.Hide(); CModDoc *pModDoc = GetDocument(); if (pModDoc) { @@ -795,9 +794,10 @@ InvalidateRow(); } + //rewbs.customKeys void CViewPattern::OnGrowSelection() -//----------------------------------- +//---------------------------------- { CSoundFile *pSndFile = GetSoundFile(); if(pSndFile == nullptr) Modified: trunk/OpenMPT/mptrack/Vstplug.cpp =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.cpp 2012-07-17 21:08:15 UTC (rev 1328) +++ trunk/OpenMPT/mptrack/Vstplug.cpp 2012-07-17 21:08:41 UTC (rev 1329) @@ -369,7 +369,7 @@ HINSTANCE hLib; bool validPlug = false; - VSTPluginLib *p = nullptr; + VSTPluginLib *p; try { p = new VSTPluginLib(pszDllPath); @@ -445,6 +445,9 @@ CMainFrame::WritePrivateProfileCString(cacheSection, IDs, pszDllPath, cacheFile); CMainFrame::WritePrivateProfileCString(cacheSection, p->szLibraryName, IDs, cacheFile); CMainFrame::WritePrivateProfileLong(cacheSection, flagsKey, p->EncodeCacheFlags(), cacheFile); + } else + { + delete p; } return (validPlug ? m_pVstHead : nullptr); Modified: trunk/OpenMPT/mptrack/version.h =================================================================== --- trunk/OpenMPT/mptrack/version.h 2012-07-17 21:08:15 UTC (rev 1328) +++ trunk/OpenMPT/mptrack/version.h 2012-07-17 21:08:41 UTC (rev 1329) @@ -19,7 +19,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 20 #define VER_MINOR 02 -#define VER_MINORMINOR 01 +#define VER_MINORMINOR 02 //Creates version number from version parts that appears in version string. //For example MAKE_VERSION_NUMERIC(1,17,02,28) gives version number of This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2012-08-20 13:24:21
|
Revision: 1343 http://modplug.svn.sourceforge.net/modplug/?rev=1343&view=rev Author: saga-games Date: 2012-08-20 13:24:10 +0000 (Mon, 20 Aug 2012) Log Message: ----------- [Fix] Pattern Editor: Cursor doesn't exceed the pattern anymore when moving it beyond the right border (fixed live at Evoke, forgot to commit :)) [Mod] Pattern Editor: Entering note stops via MIDI doesn't put an instrument number next to them anymore. [Mod] OpenMPT: Version is now 1.20.02.06 Modified Paths: -------------- trunk/OpenMPT/mptrack/View_pat.cpp trunk/OpenMPT/mptrack/version.h Modified: trunk/OpenMPT/mptrack/View_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_pat.cpp 2012-08-05 18:41:19 UTC (rev 1342) +++ trunk/OpenMPT/mptrack/View_pat.cpp 2012-08-20 13:24:10 UTC (rev 1343) @@ -4268,10 +4268,17 @@ } else { // Move cursor one column to the right - if((CMainFrame::GetSettings().m_dwPatternSetup & PATTERN_WRAP) && (m_Cursor.CompareColumn(PatternCursor(0, GetDocument()->GetNumChannels() - 1, m_nDetailLevel)) >= 0)) + const PatternCursor rightmost(0, GetDocument()->GetNumChannels() - 1, m_nDetailLevel); + if(m_Cursor.CompareColumn(rightmost) >= 0) { - // Wrap around to first channel. - SetCurrentColumn(0); + if((CMainFrame::GetSettings().m_dwPatternSetup & PATTERN_WRAP)) + { + // Wrap around to first channel. + SetCurrentColumn(0); + } else + { + SetCurrentColumn(rightmost); + } } else { do @@ -4612,8 +4619,7 @@ pTarget->param = 0; } } - pTarget->instr = (bChordMode) ? 0 : ins; //p->instr = 0; - //Writing the instrument as well - probably someone finds this annoying :) + pTarget->instr = 0; // Instrument numbers next to note-offs can do all kinds of weird things in XM files, and they are pointless anyway. pTarget->volcmd = VOLCMD_NONE; pTarget->vol = 0; Modified: trunk/OpenMPT/mptrack/version.h =================================================================== --- trunk/OpenMPT/mptrack/version.h 2012-08-05 18:41:19 UTC (rev 1342) +++ trunk/OpenMPT/mptrack/version.h 2012-08-20 13:24:10 UTC (rev 1343) @@ -19,7 +19,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 20 #define VER_MINOR 02 -#define VER_MINORMINOR 05 +#define VER_MINORMINOR 06 //Creates version number from version parts that appears in version string. //For example MAKE_VERSION_NUMERIC(1,17,02,28) gives version number of This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2012-09-04 21:36:56
|
Revision: 1347 http://modplug.svn.sourceforge.net/modplug/?rev=1347&view=rev Author: saga-games Date: 2012-09-04 21:36:50 +0000 (Tue, 04 Sep 2012) Log Message: ----------- [Fix] Plugin Editor: Randomize params reset focus to main window instead of plugin window (http://bugs.openmpt.org/view.php?id=294) [Mod] OpenMPT: Version is now 1.20.02.08 Modified Paths: -------------- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp trunk/OpenMPT/mptrack/version.h Modified: trunk/OpenMPT/mptrack/AbstractVstEditor.cpp =================================================================== --- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2012-08-27 00:17:44 UTC (rev 1346) +++ trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2012-09-04 21:36:50 UTC (rev 1347) @@ -143,10 +143,9 @@ VOID CAbstractVstEditor::OnRandomizePreset() //----------------------------------------- { - if (m_pVstPlugin) + if(m_pVstPlugin && Reporting::Confirm("Are you sure you want to randomize parameters?\nYou will lose current parameter values.", false, false, this) == cnfYes) { - if (Reporting::Confirm("Are you sure you want to randomize parameters?\nYou will lose current parameter values.") == cnfYes) - m_pVstPlugin->RandomizeParams(); + m_pVstPlugin->RandomizeParams(); UpdateParamDisplays(); } } @@ -534,7 +533,7 @@ void CAbstractVstEditor::UpdateOutputMenu() //----------------------------------------- { - CMenu* pInfoMenu = m_pMenu->GetSubMenu(2); + CMenu* pInfoMenu = m_pMenu->GetSubMenu(2); pInfoMenu->DeleteMenu(1, MF_BYPOSITION); if (m_pOutputMenu->m_hMenu) Modified: trunk/OpenMPT/mptrack/version.h =================================================================== --- trunk/OpenMPT/mptrack/version.h 2012-08-27 00:17:44 UTC (rev 1346) +++ trunk/OpenMPT/mptrack/version.h 2012-09-04 21:36:50 UTC (rev 1347) @@ -19,7 +19,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 20 #define VER_MINOR 02 -#define VER_MINORMINOR 07 +#define VER_MINORMINOR 08 //Creates version number from version parts that appears in version string. //For example MAKE_VERSION_NUMERIC(1,17,02,28) gives version number of This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2012-09-05 21:24:26
|
Revision: 1348 http://modplug.svn.sourceforge.net/modplug/?rev=1348&view=rev Author: saga-games Date: 2012-09-05 21:24:20 +0000 (Wed, 05 Sep 2012) Log Message: ----------- [Imp] Non-existing patterns are now greyed out in the order list. Modified Paths: -------------- trunk/OpenMPT/mptrack/Ctrl_pat.h trunk/OpenMPT/mptrack/Ctrl_seq.cpp Modified: trunk/OpenMPT/mptrack/Ctrl_pat.h =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_pat.h 2012-09-04 21:36:50 UTC (rev 1347) +++ trunk/OpenMPT/mptrack/Ctrl_pat.h 2012-09-05 21:24:20 UTC (rev 1348) @@ -31,7 +31,7 @@ friend class CCtrlPatterns; protected: HFONT m_hFont; - COLORREF colorText, colorTextSel; + COLORREF colorText, colorTextSel, colorInvalid; int m_cxFont, m_cyFont; //m_nXScroll : The order at the beginning of shown orderlist //m_nScrollPos: The same as order Modified: trunk/OpenMPT/mptrack/Ctrl_seq.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_seq.cpp 2012-09-04 21:36:50 UTC (rev 1347) +++ trunk/OpenMPT/mptrack/Ctrl_seq.cpp 2012-09-05 21:24:20 UTC (rev 1348) @@ -144,6 +144,7 @@ m_pModDoc = pModDoc; m_hFont = hFont; colorText = GetSysColor(COLOR_WINDOWTEXT); + colorInvalid = GetSysColor(COLOR_GRAYTEXT); colorTextSel = GetSysColor(COLOR_HIGHLIGHTTEXT); SendMessage(WM_SETFONT, (WPARAM)m_hFont); SetScrollPos(SB_HORZ, 0); @@ -870,7 +871,14 @@ else if (nPat < pSndFile->Patterns.Size()) wsprintf(s, "%u", nPat); else strcpy(s, "???"); } - dc.SetTextColor((bHighLight) ? colorTextSel : colorText); + + const COLORREF &textCol = + (bHighLight + ? colorTextSel // Highlighted pattern + : (pSndFile->Patterns.IsValidPat(nPat) + ? colorText // Normal pattern + : colorInvalid)); // Non-existent pattern + dc.SetTextColor(textCol); dc.DrawText(s, -1, &rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER); rect.left += m_cxFont; nIndex++; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2012-09-20 23:44:45
|
Revision: 1355 http://modplug.svn.sourceforge.net/modplug/?rev=1355&view=rev Author: saga-games Date: 2012-09-20 23:44:38 +0000 (Thu, 20 Sep 2012) Log Message: ----------- [Fix] VST: Tone portamento was still a bit off (tx coda) [Mod] OpenMPT: Version is now 1.20.02.11 Modified Paths: -------------- trunk/OpenMPT/mptrack/Vstplug.cpp trunk/OpenMPT/mptrack/version.h Modified: trunk/OpenMPT/mptrack/Vstplug.cpp =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.cpp 2012-09-20 23:43:52 UTC (rev 1354) +++ trunk/OpenMPT/mptrack/Vstplug.cpp 2012-09-20 23:44:38 UTC (rev 1355) @@ -1617,7 +1617,7 @@ LimitMax(max, m_pEffect->numParams); - for (VstInt32 p = min; p < max; p++) + for(VstInt32 p = min; p < max; p++) param[p - min]=GetParameter(p); return true; @@ -2298,7 +2298,7 @@ return vstEvents.Enqueue(event, insertAtFront); } -//rewbs.VSTiNoteHoldonStopFix + void CVstPlugin::HardAllNotesOff() //-------------------------------- { @@ -2344,8 +2344,8 @@ } } -//end rewbs.VSTiNoteHoldonStopFix + void CVstPlugin::MidiCC(uint8 nMidiCh, MIDIEvents::MidiCC nController, uint8 nParam, CHANNELINDEX /*trackChannel*/) //----------------------------------------------------------------------------------------------------------------- { @@ -2365,8 +2365,7 @@ { if(pwd != 0) { - // 16383 / 127 = 129 - value = (value * ((MIDIEvents::pitchBendMax - MIDIEvents::pitchBendMin) / 127)) / pwd; + value = (value * ((MIDIEvents::pitchBendMax - MIDIEvents::pitchBendCentre + 1) / 64)) / pwd; } else { value = 0; Modified: trunk/OpenMPT/mptrack/version.h =================================================================== --- trunk/OpenMPT/mptrack/version.h 2012-09-20 23:43:52 UTC (rev 1354) +++ trunk/OpenMPT/mptrack/version.h 2012-09-20 23:44:38 UTC (rev 1355) @@ -19,7 +19,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 20 #define VER_MINOR 02 -#define VER_MINORMINOR 10 +#define VER_MINORMINOR 11 //Creates version number from version parts that appears in version string. //For example MAKE_VERSION_NUMERIC(1,17,02,28) gives version number of This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2012-10-21 15:27:03
|
Revision: 1374 http://modplug.svn.sourceforge.net/modplug/?rev=1374&view=rev Author: saga-games Date: 2012-10-21 15:26:55 +0000 (Sun, 21 Oct 2012) Log Message: ----------- [Fix] Plugin Editor: Bypassing a plugin from its editor didn't mark the document as modified. Modified Paths: -------------- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp trunk/OpenMPT/mptrack/AbstractVstEditor.h Modified: trunk/OpenMPT/mptrack/AbstractVstEditor.cpp =================================================================== --- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2012-10-12 18:30:20 UTC (rev 1373) +++ trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2012-10-21 15:26:55 UTC (rev 1374) @@ -31,8 +31,6 @@ ON_COMMAND(ID_PLUG_PASSKEYS, OnPassKeypressesToPlug) ON_COMMAND(ID_PRESET_SAVE, OnSavePreset) ON_COMMAND(ID_PRESET_RANDOM, OnRandomizePreset) - ON_COMMAND(ID_VSTMACRO_INFO, OnMacroInfo) - ON_COMMAND(ID_VSTINPUT_INFO, OnInputInfo) ON_COMMAND(ID_PREVIOUSVSTPRESET, OnSetPreviousVSTPreset) ON_COMMAND(ID_NEXTVSTPRESET, OnSetNextVSTPreset) ON_COMMAND(ID_VSTPRESETBACKWARDJUMP,OnVSTPresetBackwardJump) @@ -193,7 +191,7 @@ //-------------------------------------------- { int nIndex = nID - ID_PRESET_SET; - if (nIndex >= 0) + if(nIndex >= 0) { m_pVstPlugin->SetCurrentProgram(nIndex); UpdatePresetField(); @@ -202,47 +200,41 @@ } } + void CAbstractVstEditor::OnBypassPlug() //------------------------------------- { - if (m_pVstPlugin) + if(m_pVstPlugin) { m_pVstPlugin->ToggleBypass(); + if(m_pVstPlugin->m_pSndFile->GetModSpecifications().supportsPlugins) + { + m_pVstPlugin->GetModDoc()->SetModified(); + } } } + void CAbstractVstEditor::OnRecordAutomation() //------------------------------------------- { - if (m_pVstPlugin) + if(m_pVstPlugin) { m_pVstPlugin->m_bRecordAutomation = !m_pVstPlugin->m_bRecordAutomation; } } + void CAbstractVstEditor::OnPassKeypressesToPlug() //----------------------------------------------- { - if (m_pVstPlugin) + if(m_pVstPlugin) { m_pVstPlugin->m_bPassKeypressesToPlug = !m_pVstPlugin->m_bPassKeypressesToPlug; } } -void CAbstractVstEditor::OnMacroInfo() -{ //TODO -/* - for (UINT m=0; m<NUM_MACROS; m++) - { - } -*/ -} -void CAbstractVstEditor::OnInputInfo() -{ //TODO -} -//end rewbs.defaultPlugGUI - BOOL CAbstractVstEditor::PreTranslateMessage(MSG* pMsg) //----------------------------------------------------- { @@ -466,6 +458,7 @@ m_nCurProg=curProg; } + void CAbstractVstEditor::UpdateInputMenu() //---------------------------------------- { @@ -530,6 +523,7 @@ pInfoMenu->InsertMenu(0, MF_BYPOSITION|MF_POPUP, (UINT)m_pInputMenu->m_hMenu, "I&nputs"); } + void CAbstractVstEditor::UpdateOutputMenu() //----------------------------------------- { @@ -566,6 +560,7 @@ pInfoMenu->InsertMenu(1, MF_BYPOSITION|MF_POPUP, (UINT)m_pOutputMenu->m_hMenu, "Ou&tputs"); } + void CAbstractVstEditor::UpdateMacroMenu() //---------------------------------------- { @@ -598,7 +593,7 @@ const MIDIMacroConfig &midiCfg = pModDoc->GetSoundFile()->m_MidiCfg; - const parameteredMacroType macroType = midiCfg.GetParameteredMacroType(nMacro); + const parameteredMacroType macroType = midiCfg.GetParameteredMacroType(nMacro); if(macroType == sfx_unused) { Modified: trunk/OpenMPT/mptrack/AbstractVstEditor.h =================================================================== --- trunk/OpenMPT/mptrack/AbstractVstEditor.h 2012-10-12 18:30:20 UTC (rev 1373) +++ trunk/OpenMPT/mptrack/AbstractVstEditor.h 2012-10-21 15:26:55 UTC (rev 1374) @@ -38,8 +38,6 @@ afx_msg void OnSavePreset(); afx_msg void OnRandomizePreset(); afx_msg void OnSetPreset(UINT nID); - afx_msg void OnMacroInfo(); - afx_msg void OnInputInfo(); afx_msg void OnBypassPlug(); afx_msg void OnRecordAutomation(); afx_msg void OnPassKeypressesToPlug(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |