| 322 | } |
| 323 | |
| 324 | void DexedAudioProcessorEditor::storeProgram() { |
| 325 | String currentName = Cartridge::normalizePgmName((const char *) processor->data+145); |
| 326 | Cartridge destSysex = processor->currentCart; |
| 327 | File *externalFile = NULL; |
| 328 | |
| 329 | bool activeCartridgeFound = processor->activeFileCartridge.exists(); |
| 330 | |
| 331 | while (true) { |
| 332 | String msg; |
| 333 | |
| 334 | if ( externalFile == NULL ) { |
| 335 | if ( activeCartridgeFound ) |
| 336 | msg = "Store program to current (" + processor->activeFileCartridge.getFileName() + ") / new cartridge"; |
| 337 | else |
| 338 | msg = "Store program to current / new cartridge"; |
| 339 | } else { |
| 340 | msg = "Store program to " + externalFile->getFileName(); |
| 341 | } |
| 342 | |
| 343 | AlertWindow dialog("Store Program", msg, AlertWindow::NoIcon, this); |
| 344 | dialog.addTextEditor("Name", currentName, String("Name"), false); |
| 345 | // TODO: fix the name length to 10 |
| 346 | |
| 347 | StringArray programs; |
| 348 | destSysex.getProgramNames(programs); |
| 349 | dialog.addComboBox("Dest", programs, "Program Destination"); |
| 350 | |
| 351 | if ( externalFile == NULL ) { |
| 352 | StringArray saveAction; |
| 353 | saveAction.add("Store program to DAW plugin song state"); |
| 354 | saveAction.add("Store program and create a new copy of the .syx cartridge"); |
| 355 | if ( activeCartridgeFound ) |
| 356 | saveAction.add("Store program and overwrite current .syx cartridge"); |
| 357 | |
| 358 | dialog.addComboBox("SaveAction", saveAction, "Store Action"); |
| 359 | } |
| 360 | |
| 361 | dialog.addButton("OK", 0, KeyPress(KeyPress::returnKey)); |
| 362 | dialog.addButton("CANCEL", 1, KeyPress(KeyPress::escapeKey)); |
| 363 | dialog.addButton("EXTERNAL FILE", 2, KeyPress()); |
| 364 | int response = dialog.runModalLoop(); |
| 365 | |
| 366 | if ( response == 2 ) { |
| 367 | FileChooser fc("Destination Sysex", processor->dexedCartDir, "*.syx;*.SYX;*.*", 1); |
| 368 | |
| 369 | if ( fc.browseForFileToOpen() ) { |
| 370 | if ( externalFile != NULL ) |
| 371 | delete externalFile; |
| 372 | |
| 373 | externalFile = new File(fc.getResults().getReference(0)); |
| 374 | if ( destSysex.load(*externalFile) == 0 ) |
| 375 | continue; |
| 376 | AlertWindow::showMessageBoxAsync(AlertWindow::WarningIcon, "Read error", "Unable to read file"); |
| 377 | } |
| 378 | } |
| 379 | |
| 380 | if ( response == 0 ) { |
| 381 | TextEditor *name = dialog.getTextEditor("Name"); |
no test coverage detected