void GrooveDialog::ApplySelectedGroove() { int index = (int)SendDlgItemMessage(m_hwnd, IDC_GROOVELIST, LB_GETCURSEL, 0, 0); std::string grooveName = __LOCALIZE("** User Groove **","sws_DLG_157"); GrooveTemplateMemento memento = GrooveTemplateHandler::GetMemento(); if(index > 0) { std::string itemLocation; char itemText[MAX_PATH]; SendDlgItemMessage(m_hwnd, IDC_GROOVELIST, LB_GETTEXT, index, (LPARAM)itemText); grooveName = itemText; itemLocation = currentDir; itemLocation += PATH_SEP; itemLocation += grooveName; itemLocation += ".rgt"; GrooveTemplateHandler *me = GrooveTemplateHandler::Instance(); std::string errMessage; if(!me->LoadGroove(itemLocation, errMessage)) MessageBox(GetMainHwnd(), errMessage.c_str(), __LOCALIZE("FNG - Error","sws_DLG_157"), 0); } if(index >= 0) { GrooveTemplateHandler *me = GrooveTemplateHandler::Instance(); int beatDivider = me->GetGrooveTolerance(); bool midiEditorTarget = SendDlgItemMessage(m_hwnd, IDC_TARG_NOTES, BM_GETCHECK, 0, 0) == BST_CHECKED; HWND editControl = GetDlgItem(m_hwnd, IDC_STRENGTH); char percentage[16]; GetWindowText(editControl, percentage, 16); double posStrength = (double)atoi(percentage) / 100.0; editControl = GetDlgItem(m_hwnd, IDC_VELSTRENGTH); GetWindowText(editControl, percentage, 16); double velStrength = (double)atoi(percentage) / 100.0; std::string undoMessage = __LOCALIZE("FNG: load and apply groove - ","sws_DLG_157") + grooveName; try { if(midiEditorTarget) me->ApplyGrooveToMidiEditor(beatDivider, posStrength, velStrength); else me->ApplyGroove(beatDivider, posStrength, velStrength); Undo_OnStateChange2(0, undoMessage.c_str()); } catch(RprLibException &e) { if(e.notify()) { MessageBox(GetMainHwnd(), e.what(), __LOCALIZE("FNG - Error","sws_DLG_157"), 0); } } } GrooveTemplateHandler::SetMemento(memento); }
static void LoadGrooveFromFile(int flags, void *data) { GrooveTemplateHandler *me = GrooveTemplateHandler::Instance(); char* cFilename = BrowseForFiles("Select groove template", me->GetGrooveDir().c_str(), NULL, false, "Reaper Groove Templates (*.rgt)\0*.rgt\0All Files (*.*)\0*.*\0"); if (cFilename) { std::string errMessage; std::string fName = cFilename; if(!me->LoadGroove(fName, errMessage)) MessageBox(GetMainHwnd(), errMessage.c_str(), __LOCALIZE("FNG - Error","sws_mbox"), 0); free(cFilename); } }