Ticket #486: DeleteMachine_and_RestoreConnections.patch
| File DeleteMachine_and_RestoreConnections.patch, 6.4 kB (added by user, 3 months ago) |
|---|
-
buzelib/buze.rc
983 983 BEGIN 984 984 VK_F1, ID_HELP, VIRTKEY, NOINVERT 985 985 986 // TODO: don't know wether this one should be here or in `IDR_MAINFRAME ACCELERATORS` 987 VK_DELETE, ID_MACHINE_DELETE_AND_RESTORE, VIRTKEY, SHIFT, NOINVERT 988 986 989 VK_UP, ID_MACHINE_MOVE_UP, VIRTKEY, CONTROL, NOINVERT 987 990 VK_DOWN, ID_MACHINE_MOVE_DOWN, VIRTKEY, CONTROL, NOINVERT 988 991 VK_LEFT, ID_MACHINE_MOVE_LEFT, VIRTKEY, CONTROL, NOINVERT -
buzelib/Document.cpp
383 383 } 384 384 385 385 } 386 void CDocument::deleteSelectedMachinesAndRestoreConnections() { 387 // TODO: this patch handles only audio connection. `Midi` and `event` connection can be 388 // easily added here by analogy 386 389 390 // It is be too difficult for now to perform and test delete->restore for more that one machine 391 if(getSelectedMachines() == 1) { 392 int plugin = getSelectedMachine(0); 393 394 // checking if machine has both input and output connections 395 // otherwise there is no sense to store and recall volumes 396 if(zzub_plugin_get_input_connection_count(player, plugin) > 0 && zzub_plugin_get_output_connection_count(player, plugin) > 0) { 397 int inputVolume = 0, outputVolume = 0; 398 399 // looping through input connections 400 for (int i = 0; i < zzub_plugin_get_input_connection_count(player, plugin); i++) { 401 int in_plugin = zzub_plugin_get_input_connection_plugin(player, plugin, i); 402 int audioconn_in = zzub_plugin_get_input_connection_by_type(player, plugin, in_plugin, zzub_connection_type_audio); 403 assert(audioconn_in != -1); 404 // geting input volume 405 int inputVolume = zzub_plugin_get_parameter_value(player, plugin, 0, audioconn_in, 0); 406 407 // looping through output connections 408 for (int i = 0; i < zzub_plugin_get_output_connection_count(player, plugin); i++) { 409 int out_plugin = zzub_plugin_get_output_connection_plugin(player, plugin, i); 410 int audioconn_out = zzub_plugin_get_output_connection_by_type(player, plugin, out_plugin, zzub_connection_type_audio); 411 assert(audioconn_out != -1); 412 // geting input volume 413 int outputVolume = zzub_plugin_get_parameter_value(player, plugin, 0, audioconn_out, 0); 414 415 // connecting "in_plugin" to "out_plugin" and setting in+out volume taken from plugin been deleted 416 // Formula could be (inputVolume + outputVolume)/2 but in real situations it is better 417 // to have just `inputVolume` 418 connectMachinesAudio(in_plugin, out_plugin, inputVolume, 0x4000); 419 } 420 } 421 } 422 } 423 // Let's delete that machine at last 424 deleteSelectedMachines(); 425 } 426 427 387 428 void CDocument::doublePatternRows(int machine, int pattern) { 388 429 389 430 int pattern_length = zzub_plugin_get_pattern_length(player, machine, pattern); -
buzelib/Document.h
187 187 bool connectMachinesMidi(int output, int input, string midiOutDevice); 188 188 bool disconnectMachines(int output, int input, zzub_connection_type type); 189 189 void deleteSelectedMachines(); 190 void deleteSelectedMachinesAndRestoreConnections(); 190 191 bool importSong(std::vector<char>& bytes, int allowundo, std::string* error_messages); 191 192 bool importSong(std::string filename, int allowundo, std::string* error_messages); 192 193 -
buzelib/MachineView.cpp
2229 2229 return 0; 2230 2230 } 2231 2231 2232 LRESULT CMachineView::OnDeleteAndRestoreConnections(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& bHandled) { 2233 // MessageBox("Yooo"); 2234 2235 document->deleteSelectedMachinesAndRestoreConnections(); 2236 zzub_player_history_commit(player, "Delete Plugin(s)"); 2237 2238 //document->updateAllViews(this, UpdateMachineSelection); 2239 return 0; 2240 } 2241 2232 2242 LRESULT CMachineView::OnSelectAll(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& bHandled) { 2233 2243 for (size_t i = 0; i < zzub_player_get_plugin_count(mainFrame->player); i++) { 2234 2244 int plugin_id = zzub_plugin_get_id(player, i); -
buzelib/MachineView.h
139 139 COMMAND_ID_HANDLER(ID_EDIT_COPY, OnCopy) 140 140 COMMAND_ID_HANDLER(ID_EDIT_PASTE, OnPaste) 141 141 COMMAND_ID_HANDLER(ID_EDIT_DELETE, OnDelete) 142 COMMAND_ID_HANDLER(ID_MACHINE_DELETE_AND_RESTORE, OnDeleteAndRestoreConnections) 142 143 COMMAND_ID_HANDLER(ID_EDIT_SELECTALL, OnSelectAll) 143 144 COMMAND_ID_HANDLER(ID_EDIT_CLEARSELECTION, OnClearSelection) 144 145 COMMAND_ID_HANDLER(ID_VIEW_PROPERTIES, OnViewProperties) … … 196 197 LRESULT OnCopy(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); 197 198 LRESULT OnPaste(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); 198 199 LRESULT OnDelete(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); 200 LRESULT OnDeleteAndRestoreConnections(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); 199 201 LRESULT OnSelectAll(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); 200 202 LRESULT OnClearSelection(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); 201 203 LRESULT OnViewProperties(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); -
buzelib/resource.h
436 436 #define ID_MACHINE_MOVE_DOWN_RIGHT_STEP 53584 437 437 #define ID_MACHINE_MOVE_UP_RIGHT_STEP 53585 438 438 439 440 #define ID_MACHINE_DELETE_AND_RESTORE 53600 441 439 442 // Next default values for new objects 440 443 // 441 444 #ifdef APSTUDIO_INVOKED 442 445 #ifndef APSTUDIO_READONLY_SYMBOLS 443 446 #define _APS_NEXT_RESOURCE_VALUE 238 444 #define _APS_NEXT_COMMAND_VALUE 53 586447 #define _APS_NEXT_COMMAND_VALUE 53601 445 448 #define _APS_NEXT_CONTROL_VALUE 1084 446 449 #define _APS_NEXT_SYMED_VALUE 101 447 450 #endif
